diff --git a/.hgtags b/.hgtags index eae140588de..18f00fc6ce6 100644 --- a/.hgtags +++ b/.hgtags @@ -300,3 +300,5 @@ d6224d6021459ac8b3832e822f5acc849fa944af jdk9-b52 c97e2d1bad9708d379793ba2a4c848eda14c741e jdk9-b55 47544495db2d3d2edf0f85862d8715592fdb919f jdk9-b56 ddb95d8f169b09544cc17e72a6baaff2400092f5 jdk9-b57 +f40752db7773ca0c737f2ad88371e35c57fdfed7 jdk9-b58 +da950f343762a856d69751570a4c07cfa68a415b jdk9-b59 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 0fcca9bbfdb..2b62f114837 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -300,3 +300,5 @@ cb7367141e910e265b8344a8facee740bd1e5467 jdk9-b54 0c37a832458f0e0b7d2a3f1a6f69aeae311aeb18 jdk9-b55 eb7febe45865ba6b81f2ea68082262d0708a0b22 jdk9-b56 f25ee9f62427a9ba27418e5531a89754791a305b jdk9-b57 +6e78dd9b121037719a065fe8fb25b936babdfecb jdk9-b58 +39e8a131289e8386aa4c3e4b184faa812a7c0421 jdk9-b59 diff --git a/Makefile b/Makefile index 825bad1fcb7..2460cd414d8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -23,200 +23,42 @@ # questions. # -# This must be the first rule -default: +### +### This file is just a very small wrapper needed to run the real make/Init.gmk. +### It also performs some sanity checks on make. +### -# Inclusion of this pseudo-target will cause make to execute this file -# serially, regardless of -j. Recursively called makefiles will not be -# affected, however. This is required for correct dependency management. -.NOTPARALLEL: - -# The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU make. +# The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU Make. # /usr/ccs/bin/make lacks basically every other flow control mechanism. -.TEST_FOR_NON_GNUMAKE:sh=echo You are not using GNU make/gmake, this is a requirement. Check your path. 1>&2 && exit 1 +.TEST_FOR_NON_GNUMAKE:sh=echo You are not using GNU Make/gmake, this is a requirement. Check your path. 1>&2 && exit 1 -# Assume we have GNU make, but check version. +# The .FEATURES variable is likely to be unique for GNU Make. +ifeq ($(.FEATURES), ) + $(info Error: '$(MAKE)' does not seem to be GNU Make, which is a requirement.) + $(info Check your path, or upgrade to GNU Make 3.81 or newer.) + $(error Cannot continue) +endif + +# Assume we have GNU Make, but check version. ifeq ($(strip $(foreach v, 3.81% 3.82% 4.%, $(filter $v, $(MAKE_VERSION)))), ) - $(error This version of GNU Make is too low ($(MAKE_VERSION)). Check your path, or upgrade to 3.81 or newer.) + $(info Error: This version of GNU Make is too low ($(MAKE_VERSION)).) + $(info Check your path, or upgrade to GNU Make 3.81 or newer.) + $(error Cannot continue) +endif + +# In Cygwin, the MAKE variable gets prepended with the current directory if the +# make executable is called using a Windows mixed path (c:/cygwin/bin/make.exe). +ifneq ($(findstring :, $(MAKE)), ) + MAKE := $(patsubst $(CURDIR)%, %, $(patsubst $(CURDIR)/%, %, $(MAKE))) endif # Locate this Makefile -ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),) - makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST)) +ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))),) + makefile_path := $(CURDIR)/$(strip $(lastword $(MAKEFILE_LIST))) else - makefile_path:=$(lastword $(MAKEFILE_LIST)) + makefile_path := $(lastword $(MAKEFILE_LIST)) endif -root_dir:=$(patsubst %/,%,$(dir $(makefile_path))) +topdir := $(strip $(patsubst %/, %, $(dir $(makefile_path)))) -ifeq ($(MAIN_TARGETS), ) - COMMAND_LINE_VARIABLES:=$(subst =command,,$(filter %=command,$(foreach var,$(.VARIABLES),$(var)=$(firstword $(origin $(var)))))) - MAKE_CONTROL_VARIABLES:=LOG CONF SPEC JOBS TEST IGNORE_OLD_CONFIG - UNKNOWN_COMMAND_LINE_VARIABLES:=$(strip $(filter-out $(MAKE_CONTROL_VARIABLES), $(COMMAND_LINE_VARIABLES))) - ifneq ($(UNKNOWN_COMMAND_LINE_VARIABLES), ) - $(info Note: Command line contains non-control variables: $(UNKNOWN_COMMAND_LINE_VARIABLES).) - $(info Make sure it is not mistyped, and that you intend to override this variable.) - $(info 'make help' will list known control variables) - endif -endif - -ifneq ($(findstring qp,$(MAKEFLAGS)),) - # When called with -qp, assume an external part (e.g. bash completion) is trying - # to understand our targets. - # Duplication of global targets, needed before ParseConfAndSpec in case we have - # no configurations. - help: - # If both CONF and SPEC are unset, look for all available configurations by - # setting CONF to the empty string. - ifeq ($(SPEC), ) - CONF?= - endif -endif - -# ... and then we can include our helper functions -include $(root_dir)/make/MakeHelpers.gmk - -$(eval $(call ParseLogLevel)) -$(eval $(call ParseConfAndSpec)) - -# Now determine if we have zero, one or several configurations to build. -ifeq ($(SPEC),) - # Since we got past ParseConfAndSpec, we must be building a global target. Do nothing. -else - # In Cygwin, the MAKE variable gets messed up if the make executable is called with - # a Windows mixed path (c:/cygwin/bin/make.exe). If that's the case, fix it by removing - # the prepended root_dir. - ifneq ($(findstring :, $(MAKE)), ) - MAKE := $(patsubst $(root_dir)%, %, $(MAKE)) - endif - - # We are potentially building multiple configurations. - # First, find out the valid targets - # Run the makefile with an arbitrary SPEC using -p -q (quiet dry-run and dump rules) to find - # available PHONY targets. Use this list as valid targets to pass on to the repeated calls. - all_phony_targets := $(sort $(filter-out $(global_targets), $(strip $(shell \ - cd $(root_dir)/make && $(MAKE) -f Main.gmk -p -q FRC SPEC=$(firstword $(SPEC)) \ - -I $(root_dir)/make/common | grep "^.PHONY:" | head -n 1 | cut -d " " -f 2-)))) - - # Loop through the configurations and call the main-wrapper for each one. The wrapper - # target will execute with a single configuration loaded. - $(all_phony_targets): - @$(if $(TARGET_RUN),,\ - $(foreach spec,$(SPEC),\ - (cd $(root_dir) && $(MAKE) SPEC=$(spec) MAIN_TARGETS="$(call GetRealTarget)" \ - $(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) main-wrapper) &&) true) - @echo > /dev/null - $(eval TARGET_RUN=true) - - .PHONY: $(all_phony_targets) - - ifneq ($(MAIN_TARGETS), ) - # The wrapper target was called so we now have a single configuration. Load the spec file - # and call the real Main.gmk. - include $(SPEC) - include $(SRC_ROOT)/make/common/MakeBase.gmk - - ### Clean up from previous run - # Remove any build.log from a previous run, if they exist - ifneq (,$(BUILD_LOG)) - ifneq (,$(BUILD_LOG_PREVIOUS)) - # Rotate old log - $(shell $(RM) $(BUILD_LOG_PREVIOUS) 2> /dev/null) - $(shell $(MV) $(BUILD_LOG) $(BUILD_LOG_PREVIOUS) 2> /dev/null) - else - $(shell $(RM) $(BUILD_LOG) 2> /dev/null) - endif - $(shell $(RM) $(OUTPUT_ROOT)/build-trace-time.log 2> /dev/null) - endif - # Remove any javac server logs and port files. This - # prevents a new make run to reuse the previous servers. - ifneq (,$(SJAVAC_SERVER_DIR)) - $(shell $(MKDIR) -p $(SJAVAC_SERVER_DIR) && $(RM) -rf $(SJAVAC_SERVER_DIR)/*) - endif - - # Split out the targets requiring sequential execution. Run these targets separately - # from the rest so that the rest may still enjoy full parallel execution. - SEQUENTIAL_TARGETS := $(filter dist-clean clean% reconfigure, $(MAIN_TARGETS)) - PARALLEL_TARGETS := $(filter-out $(SEQUENTIAL_TARGETS), $(MAIN_TARGETS)) - - main-wrapper: - ifneq ($(SEQUENTIAL_TARGETS), ) - (cd $(SRC_ROOT)/make && $(MAKE) -f Main.gmk SPEC=$(SPEC) -j 1 \ - $(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) $(SEQUENTIAL_TARGETS)) - endif - ifneq ($(PARALLEL_TARGETS), ) - @$(call AtMakeStart) - (cd $(SRC_ROOT)/make && $(BUILD_LOG_WRAPPER) $(MAKE) -f Main.gmk SPEC=$(SPEC) -j $(JOBS) \ - $(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) $(PARALLEL_TARGETS) \ - $(if $(filter true, $(OUTPUT_SYNC_SUPPORTED)), -O$(OUTPUT_SYNC))) - @$(call AtMakeEnd) - endif - - .PHONY: main-wrapper - - endif -endif - -# Here are "global" targets, i.e. targets that can be executed without specifying a single configuration. -# If you add more global targets, please update the variable global_targets in MakeHelpers. - -# Helper macro to allow $(info) to properly print strings beginning with spaces. -_:= - -help: - $(info ) - $(info OpenJDK Makefile help) - $(info =====================) - $(info ) - $(info Common make targets) - $(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 j2sdk and j2re images) - $(info $(_) make # 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) - $(info $(_) # dependencies for the target. This is faster but may) - $(info $(_) # result in incorrect build results!) - $(info $(_) make docs # Create all docs) - $(info $(_) make docs-javadoc # Create just javadocs, depends on less than full docs) - $(info $(_) make profiles # Create complete j2re compact profile images) - $(info $(_) make bootcycle-images # Build images twice, second time with newly built JDK) - $(info $(_) make install # Install the generated images locally) - $(info $(_) make reconfigure # Rerun configure with the same arguments as last time) - $(info $(_) make help # Give some help on using make) - $(info $(_) make test # Run tests, default is all tests (see TEST below)) - $(info ) - $(info Targets for cleaning) - $(info $(_) make clean # Remove all files generated by make, but not those) - $(info $(_) # generated by configure) - $(info $(_) make dist-clean # Remove all files, including configuration) - $(info $(_) make clean- # Remove the subdir in the output dir with the name) - $(info $(_) make clean- # Remove all build results related to a certain build) - $(info $(_) # phase (gensrc, java, libs, launchers)) - $(info $(_) make clean- # Remove all build results related to a certain module) - $(info $(_) make clean-- # Remove all build results related to a certain) - $(info $(_) # module and phase) - $(info ) - $(info Targets for specific modules) - $(info $(_) make # Build and everything it depends on.) - $(info $(_) make - # Compile the specified phase for the specified module) - $(info $(_) # and everything it depends on) - $(info $(_) # (gensrc, java, copy, libs, launchers, gendata, rmic)) - $(info ) - $(info Make control variables) - $(info $(_) CONF= # Build all configurations (note, assignment is empty)) - $(info $(_) CONF= # Build the configuration(s) with a name matching) - $(info $(_) # ) - $(info $(_) SPEC= # Build the configuration given by the spec file) - $(info $(_) LOG= # Change the log level from warn to ) - $(info $(_) # Available log levels are:) - $(info $(_) # 'warn' (default), 'info', 'debug' and 'trace') - $(info $(_) # To see executed command lines, use LOG=debug) - $(info $(_) JOBS= # Run parallel make jobs) - $(info $(_) # Note that -jN does not work as expected!) - $(info $(_) IGNORE_OLD_CONFIG=true # Skip tests if spec file is up to date) - $(info $(_) make test TEST= # Only run the given test or tests, e.g.) - $(info $(_) # make test TEST="jdk_lang jdk_net") - $(info ) - -.PHONY: help +# ... and then we can include the real makefile +include $(topdir)/make/Init.gmk diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index 422837aae88..02a096ed8c1 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -78,7 +78,7 @@ AC_DEFUN([BASIC_PREPEND_TO_PATH], AC_DEFUN([BASIC_FIXUP_PATH], [ # Only process if variable expands to non-empty - + if test "x[$]$1" != x; then if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then BASIC_FIXUP_PATH_CYGWIN($1) @@ -118,7 +118,7 @@ AC_DEFUN([BASIC_FIXUP_PATH], AC_DEFUN([BASIC_FIXUP_EXECUTABLE], [ # Only process if variable expands to non-empty - + if test "x[$]$1" != x; then if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then BASIC_FIXUP_EXECUTABLE_CYGWIN($1) @@ -459,12 +459,21 @@ AC_DEFUN_ONCE([BASIC_SETUP_PATHS], AC_MSG_RESULT([$TOPDIR]) AC_SUBST(TOPDIR) + # Save the original version of TOPDIR for string comparisons + ORIGINAL_TOPDIR="$TOPDIR" + AC_SUBST(ORIGINAL_TOPDIR) + # We can only call BASIC_FIXUP_PATH after BASIC_CHECK_PATHS_WINDOWS. BASIC_FIXUP_PATH(CURDIR) BASIC_FIXUP_PATH(TOPDIR) # SRC_ROOT is a traditional alias for TOPDIR. SRC_ROOT=$TOPDIR + # Calculate a canonical version of TOPDIR for string comparisons + CANONICAL_TOPDIR=$TOPDIR + BASIC_REMOVE_SYMBOLIC_LINKS([CANONICAL_TOPDIR]) + AC_SUBST(CANONICAL_TOPDIR) + # Locate the directory of this script. AUTOCONF_DIR=$TOPDIR/common/autoconf ]) @@ -649,6 +658,8 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR], fi OUTPUT_ROOT="$SRC_ROOT/build/${CONF_NAME}" $MKDIR -p "$OUTPUT_ROOT" + CONFIGURESUPPORT_OUTPUTDIR="$OUTPUT_ROOT/configure-support" + $MKDIR -p "$CONFIGURESUPPORT_OUTPUTDIR" if test ! -d "$OUTPUT_ROOT"; then AC_MSG_ERROR([Could not create build directory $OUTPUT_ROOT]) fi @@ -694,6 +705,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR], AC_SUBST(SPEC, $OUTPUT_ROOT/spec.gmk) AC_SUBST(CONF_NAME, $CONF_NAME) AC_SUBST(OUTPUT_ROOT, $OUTPUT_ROOT) + AC_SUBST(CONFIGURESUPPORT_OUTPUTDIR) # The spec.gmk file contains all variables for the make system. AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in]) @@ -709,18 +721,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR], AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in]) ]) -AC_DEFUN_ONCE([BASIC_SETUP_LOGGING], -[ - # Setup default logging of stdout and stderr to build.log in the output root. - BUILD_LOG='$(OUTPUT_ROOT)/build.log' - BUILD_LOG_PREVIOUS='$(OUTPUT_ROOT)/build.log.old' - BUILD_LOG_WRAPPER='$(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)' - AC_SUBST(BUILD_LOG) - AC_SUBST(BUILD_LOG_PREVIOUS) - AC_SUBST(BUILD_LOG_WRAPPER) -]) - - #%%% Simple tools %%% # Check if we have found a usable version of make diff --git a/common/autoconf/basics_windows.m4 b/common/autoconf/basics_windows.m4 index 1bcb6151486..7ce14a82d8b 100644 --- a/common/autoconf/basics_windows.m4 +++ b/common/autoconf/basics_windows.m4 @@ -383,45 +383,46 @@ AC_DEFUN_ONCE([BASIC_COMPILE_FIXPATH], if test "x$OPENJDK_BUILD_OS" = xwindows; then AC_MSG_CHECKING([if fixpath can be created]) FIXPATH_SRC="$SRC_ROOT/common/src/fixpath.c" - FIXPATH_BIN="$OUTPUT_ROOT/fixpath.exe" + FIXPATH_BIN="$CONFIGURESUPPORT_OUTPUTDIR/bin/fixpath.exe" + FIXPATH_DIR="$CONFIGURESUPPORT_OUTPUTDIR/fixpath" if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then - FIXPATH_SRC=`$CYGPATH -m $FIXPATH_SRC` - FIXPATH_BIN=`$CYGPATH -m $FIXPATH_BIN` # Important to keep the .exe suffix on Cygwin for Hotspot makefiles - FIXPATH="$OUTPUT_ROOT/fixpath.exe -c" + FIXPATH="$FIXPATH_BIN -c" elif test "x$OPENJDK_BUILD_OS_ENV" = xwindows.msys; then - FIXPATH_SRC=`cmd //c echo $FIXPATH_SRC` - FIXPATH_BIN=`cmd //c echo $FIXPATH_BIN` - # Take all collected prefixes and turn them into a -m/c/foo@/c/bar@... command line # @ was chosen as separator to minimize risk of other tools messing around with it - all_unique_prefixes=`echo "${all_fixpath_prefixes@<:@@@:>@}" | tr ' ' '\n' | grep '^/./' | sort | uniq` + all_unique_prefixes=`echo "${all_fixpath_prefixes@<:@@@:>@}" \ + | tr ' ' '\n' | grep '^/./' | sort | uniq` fixpath_argument_list=`echo $all_unique_prefixes | tr ' ' '@'` - - FIXPATH="$OUTPUT_ROOT/fixpath -m$fixpath_argument_list" + FIXPATH="$FIXPATH_BIN -m$fixpath_argument_list" fi - rm -f $OUTPUT_ROOT/fixpath* - cd $OUTPUT_ROOT - $CC $FIXPATH_SRC -Fe$FIXPATH_BIN > $OUTPUT_ROOT/fixpath1.log 2>&1 + FIXPATH_SRC_W="$FIXPATH_SRC" + FIXPATH_BIN_W="$FIXPATH_BIN" + BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_SRC_W]) + BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_BIN_W]) + $RM -rf $FIXPATH_BIN $FIXPATH_DIR + $MKDIR -p $FIXPATH_DIR $CONFIGURESUPPORT_OUTPUTDIR/bin + cd $FIXPATH_DIR + $CC $FIXPATH_SRC_W -Fe$FIXPATH_BIN_W > $FIXPATH_DIR/fixpath1.log 2>&1 cd $CURDIR - if test ! -x $OUTPUT_ROOT/fixpath.exe; then + if test ! -x $FIXPATH_BIN; then AC_MSG_RESULT([no]) - cat $OUTPUT_ROOT/fixpath1.log - AC_MSG_ERROR([Could not create $OUTPUT_ROOT/fixpath.exe]) + cat $FIXPATH_DIR/fixpath1.log + AC_MSG_ERROR([Could not create $FIXPATH_BIN]) fi AC_MSG_RESULT([yes]) AC_MSG_CHECKING([if fixpath.exe works]) - cd $OUTPUT_ROOT - $FIXPATH $CC $SRC_ROOT/common/src/fixpath.c -Fe$OUTPUT_ROOT/fixpath2.exe > $OUTPUT_ROOT/fixpath2.log 2>&1 + cd $FIXPATH_DIR + $FIXPATH $CC $FIXPATH_SRC -Fe$FIXPATH_DIR/fixpath2.exe \ + > $FIXPATH_DIR/fixpath2.log 2>&1 cd $CURDIR - if test ! -x $OUTPUT_ROOT/fixpath2.exe; then + if test ! -x $FIXPATH_DIR/fixpath2.exe; then AC_MSG_RESULT([no]) - cat $OUTPUT_ROOT/fixpath2.log + cat $FIXPATH_DIR/fixpath2.log AC_MSG_ERROR([fixpath did not work!]) fi AC_MSG_RESULT([yes]) - rm -f $OUTPUT_ROOT/fixpath?.??? $OUTPUT_ROOT/fixpath.obj fi AC_SUBST(FIXPATH) diff --git a/common/autoconf/build-performance.m4 b/common/autoconf/build-performance.m4 index 5b3dbdd1fe4..b5911b789a7 100644 --- a/common/autoconf/build-performance.m4 +++ b/common/autoconf/build-performance.m4 @@ -336,11 +336,4 @@ AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC], AC_MSG_CHECKING([whether to use sjavac]) AC_MSG_RESULT([$ENABLE_SJAVAC]) AC_SUBST(ENABLE_SJAVAC) - - if test "x$ENABLE_SJAVAC" = xyes; then - SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers" - else - SJAVAC_SERVER_DIR= - fi - AC_SUBST(SJAVAC_SERVER_DIR) ]) diff --git a/common/autoconf/configure.ac b/common/autoconf/configure.ac index 14497a039ad..560f4525b6a 100644 --- a/common/autoconf/configure.ac +++ b/common/autoconf/configure.ac @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -88,7 +88,6 @@ PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET # Continue setting up basic stuff. Most remaining code require fundamental tools. BASIC_SETUP_PATHS -BASIC_SETUP_LOGGING # Check if it's a pure open build or if custom sources are to be used. JDKOPT_SETUP_OPEN_OR_CUSTOM @@ -262,7 +261,7 @@ CUSTOM_LATE_HOOK # We're messing a bit with internal autoconf variables to put the config.status # in the output directory instead of the current directory. -CONFIG_STATUS="$OUTPUT_ROOT/config.status" +CONFIG_STATUS="$CONFIGURESUPPORT_OUTPUTDIR/config.status" # Create the actual output files. Now the main work of configure is done. AC_OUTPUT @@ -270,7 +269,7 @@ CUSTOM_CONFIG_OUTPUT_GENERATED_HOOK # Try to move the config.log file to the output directory. if test -e ./config.log; then - $MV -f ./config.log "$OUTPUT_ROOT/config.log" 2> /dev/null + $MV -f ./config.log "$CONFIGURESUPPORT_OUTPUTDIR/config.log" 2> /dev/null fi # Make the compare script executable diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 54b40ca2a39..a7fc898624c 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -632,7 +632,6 @@ LIBOBJS CFLAGS_CCACHE CCACHE USE_PRECOMPILED_HEADER -SJAVAC_SERVER_DIR ENABLE_SJAVAC SJAVAC_SERVER_JAVA_FLAGS SJAVAC_SERVER_JAVA @@ -884,6 +883,7 @@ CHECK_TOOLSDIR_GMAKE CHECK_MAKE CHECK_GMAKE PKGHANDLER +CONFIGURESUPPORT_OUTPUTDIR OUTPUT_ROOT CONF_NAME SPEC @@ -907,9 +907,8 @@ JVM_VARIANTS JVM_INTERPRETER JDK_VARIANT SET_OPENJDK -BUILD_LOG_WRAPPER -BUILD_LOG_PREVIOUS -BUILD_LOG +CANONICAL_TOPDIR +ORIGINAL_TOPDIR TOPDIR PATH_SEP ZERO_ARCHDEF @@ -3471,9 +3470,6 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - - #%%% Simple tools %%% # Check if we have found a usable version of make @@ -4369,7 +4365,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1428017006 +DATE_WHEN_GENERATED=1428676283 ############################################################################### # @@ -14141,6 +14137,10 @@ $as_echo_n "checking for top-level directory... " >&6; } $as_echo "$TOPDIR" >&6; } + # Save the original version of TOPDIR for string comparisons + ORIGINAL_TOPDIR="$TOPDIR" + + # We can only call BASIC_FIXUP_PATH after BASIC_CHECK_PATHS_WINDOWS. # Only process if variable expands to non-empty @@ -14397,19 +14397,62 @@ $as_echo "$as_me: The path of TOPDIR, which resolves as \"$path\", is invalid." # SRC_ROOT is a traditional alias for TOPDIR. SRC_ROOT=$TOPDIR + # Calculate a canonical version of TOPDIR for string comparisons + CANONICAL_TOPDIR=$TOPDIR + + if test "x$OPENJDK_BUILD_OS" != xwindows; then + # Follow a chain of symbolic links. Use readlink + # where it exists, else fall back to horribly + # complicated shell code. + if test "x$READLINK_TESTED" != yes; then + # On MacOSX there is a readlink tool with a different + # purpose than the GNU readlink tool. Check the found readlink. + ISGNU=`$READLINK --version 2>&1 | $GREP GNU` + if test "x$ISGNU" = x; then + # A readlink that we do not know how to use. + # Are there other non-GNU readlinks out there? + READLINK_TESTED=yes + READLINK= + fi + fi + + if test "x$READLINK" != x; then + CANONICAL_TOPDIR=`$READLINK -f $CANONICAL_TOPDIR` + else + # Save the current directory for restoring afterwards + STARTDIR=$PWD + COUNTER=0 + sym_link_dir=`$DIRNAME $CANONICAL_TOPDIR` + sym_link_file=`$BASENAME $CANONICAL_TOPDIR` + cd $sym_link_dir + # Use -P flag to resolve symlinks in directories. + cd `$THEPWDCMD -P` + sym_link_dir=`$THEPWDCMD -P` + # Resolve file symlinks + while test $COUNTER -lt 20; do + ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` + if test "x$ISLINK" == x; then + # This is not a symbolic link! We are done! + break + fi + # Again resolve directory symlinks since the target of the just found + # link could be in a different directory + cd `$DIRNAME $ISLINK` + sym_link_dir=`$THEPWDCMD -P` + sym_link_file=`$BASENAME $ISLINK` + let COUNTER=COUNTER+1 + done + cd $STARTDIR + CANONICAL_TOPDIR=$sym_link_dir/$sym_link_file + fi + fi + + + # Locate the directory of this script. AUTOCONF_DIR=$TOPDIR/common/autoconf - # Setup default logging of stdout and stderr to build.log in the output root. - BUILD_LOG='$(OUTPUT_ROOT)/build.log' - BUILD_LOG_PREVIOUS='$(OUTPUT_ROOT)/build.log.old' - BUILD_LOG_WRAPPER='$(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)' - - - - - # Check if it's a pure open build or if custom sources are to be used. # Check whether --enable-openjdk-only was given. @@ -15223,6 +15266,8 @@ $as_echo "in build directory with custom name" >&6; } fi OUTPUT_ROOT="$SRC_ROOT/build/${CONF_NAME}" $MKDIR -p "$OUTPUT_ROOT" + CONFIGURESUPPORT_OUTPUTDIR="$OUTPUT_ROOT/configure-support" + $MKDIR -p "$CONFIGURESUPPORT_OUTPUTDIR" if test ! -d "$OUTPUT_ROOT"; then as_fn_error $? "Could not create build directory $OUTPUT_ROOT" "$LINENO" 5 fi @@ -15407,6 +15452,7 @@ $as_echo "$as_me: The path of OUTPUT_ROOT, which resolves as \"$path\", is inval OUTPUT_ROOT=$OUTPUT_ROOT + # The spec.gmk file contains all variables for the make system. ac_config_files="$ac_config_files $OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in" @@ -27579,7 +27625,7 @@ $as_echo "$as_me: Rewriting VS_ENV_CMD to \"$new_complete\"" >&6;} $as_echo "$as_me: Trying to extract Visual Studio environment variables" >&6;} # We need to create a couple of temporary files. - VS_ENV_TMP_DIR="$OUTPUT_ROOT/vs-env" + VS_ENV_TMP_DIR="$CONFIGURESUPPORT_OUTPUTDIR/vs-env" $MKDIR -p $VS_ENV_TMP_DIR # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment). @@ -43093,50 +43139,69 @@ $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fixpath can be created" >&5 $as_echo_n "checking if fixpath can be created... " >&6; } FIXPATH_SRC="$SRC_ROOT/common/src/fixpath.c" - FIXPATH_BIN="$OUTPUT_ROOT/fixpath.exe" + FIXPATH_BIN="$CONFIGURESUPPORT_OUTPUTDIR/bin/fixpath.exe" + FIXPATH_DIR="$CONFIGURESUPPORT_OUTPUTDIR/fixpath" if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then - FIXPATH_SRC=`$CYGPATH -m $FIXPATH_SRC` - FIXPATH_BIN=`$CYGPATH -m $FIXPATH_BIN` # Important to keep the .exe suffix on Cygwin for Hotspot makefiles - FIXPATH="$OUTPUT_ROOT/fixpath.exe -c" + FIXPATH="$FIXPATH_BIN -c" elif test "x$OPENJDK_BUILD_OS_ENV" = xwindows.msys; then - FIXPATH_SRC=`cmd //c echo $FIXPATH_SRC` - FIXPATH_BIN=`cmd //c echo $FIXPATH_BIN` - # Take all collected prefixes and turn them into a -m/c/foo@/c/bar@... command line # @ was chosen as separator to minimize risk of other tools messing around with it - all_unique_prefixes=`echo "${all_fixpath_prefixes[@]}" | tr ' ' '\n' | grep '^/./' | sort | uniq` + all_unique_prefixes=`echo "${all_fixpath_prefixes[@]}" \ + | tr ' ' '\n' | grep '^/./' | sort | uniq` fixpath_argument_list=`echo $all_unique_prefixes | tr ' ' '@'` - - FIXPATH="$OUTPUT_ROOT/fixpath -m$fixpath_argument_list" + FIXPATH="$FIXPATH_BIN -m$fixpath_argument_list" fi - rm -f $OUTPUT_ROOT/fixpath* - cd $OUTPUT_ROOT - $CC $FIXPATH_SRC -Fe$FIXPATH_BIN > $OUTPUT_ROOT/fixpath1.log 2>&1 + FIXPATH_SRC_W="$FIXPATH_SRC" + FIXPATH_BIN_W="$FIXPATH_BIN" + + unix_path="$FIXPATH_SRC_W" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + windows_path=`$CYGPATH -m "$unix_path"` + FIXPATH_SRC_W="$windows_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + windows_path=`cmd //c echo $unix_path` + FIXPATH_SRC_W="$windows_path" + fi + + + unix_path="$FIXPATH_BIN_W" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + windows_path=`$CYGPATH -m "$unix_path"` + FIXPATH_BIN_W="$windows_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + windows_path=`cmd //c echo $unix_path` + FIXPATH_BIN_W="$windows_path" + fi + + $RM -rf $FIXPATH_BIN $FIXPATH_DIR + $MKDIR -p $FIXPATH_DIR $CONFIGURESUPPORT_OUTPUTDIR/bin + cd $FIXPATH_DIR + $CC $FIXPATH_SRC_W -Fe$FIXPATH_BIN_W > $FIXPATH_DIR/fixpath1.log 2>&1 cd $CURDIR - if test ! -x $OUTPUT_ROOT/fixpath.exe; then + if test ! -x $FIXPATH_BIN; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - cat $OUTPUT_ROOT/fixpath1.log - as_fn_error $? "Could not create $OUTPUT_ROOT/fixpath.exe" "$LINENO" 5 + cat $FIXPATH_DIR/fixpath1.log + as_fn_error $? "Could not create $FIXPATH_BIN" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if fixpath.exe works" >&5 $as_echo_n "checking if fixpath.exe works... " >&6; } - cd $OUTPUT_ROOT - $FIXPATH $CC $SRC_ROOT/common/src/fixpath.c -Fe$OUTPUT_ROOT/fixpath2.exe > $OUTPUT_ROOT/fixpath2.log 2>&1 + cd $FIXPATH_DIR + $FIXPATH $CC $FIXPATH_SRC -Fe$FIXPATH_DIR/fixpath2.exe \ + > $FIXPATH_DIR/fixpath2.log 2>&1 cd $CURDIR - if test ! -x $OUTPUT_ROOT/fixpath2.exe; then + if test ! -x $FIXPATH_DIR/fixpath2.exe; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - cat $OUTPUT_ROOT/fixpath2.log + cat $FIXPATH_DIR/fixpath2.log as_fn_error $? "fixpath did not work!" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - rm -f $OUTPUT_ROOT/fixpath?.??? $OUTPUT_ROOT/fixpath.obj fi @@ -51372,13 +51437,6 @@ $as_echo_n "checking whether to use sjavac... " >&6; } $as_echo "$ENABLE_SJAVAC" >&6; } - if test "x$ENABLE_SJAVAC" = xyes; then - SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers" - else - SJAVAC_SERVER_DIR= - fi - - # Can the C/C++ compiler use precompiled headers? @@ -51806,7 +51864,7 @@ $as_echo "$OUTPUT_DIR_IS_LOCAL" >&6; } # We're messing a bit with internal autoconf variables to put the config.status # in the output directory instead of the current directory. -CONFIG_STATUS="$OUTPUT_ROOT/config.status" +CONFIG_STATUS="$CONFIGURESUPPORT_OUTPUTDIR/config.status" # Create the actual output files. Now the main work of configure is done. cat >confcache <<\_ACEOF @@ -52974,7 +53032,7 @@ fi # Try to move the config.log file to the output directory. if test -e ./config.log; then - $MV -f ./config.log "$OUTPUT_ROOT/config.log" 2> /dev/null + $MV -f ./config.log "$CONFIGURESUPPORT_OUTPUTDIR/config.log" 2> /dev/null fi # Make the compare script executable diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index d21ab83451a..8ae516585e0 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -55,25 +55,12 @@ CONFIGURE_COMMAND_LINE:=@CONFIGURE_COMMAND_LINE@ # A self-referential reference to this file. SPEC:=@SPEC@ -# Specify where the spec file is. -MAKE_ARGS="SPEC=$(SPEC)" +# What make to use for main processing, after bootstrapping top-level Makefile. +MAKE := @MAKE@ -MAKE:=@MAKE@ - -# Pass along the verbosity and log level settings. -ifeq (,$(findstring VERBOSE=,$(MAKE))) - MAKE:=$(MAKE) $(VERBOSE) VERBOSE="$(VERBOSE)" LOG_LEVEL="$(LOG_LEVEL)" -endif - -# No implicit variables or rules! -ifeq (,$(findstring -R,$(MAKE))) - MAKE:=$(MAKE) -R -endif - -# Specify where the common include directory for makefiles is. -ifeq (,$(findstring -I @TOPDIR@/make/common,$(MAKE))) - MAKE:=$(MAKE) -I @TOPDIR@/make/common -endif +# The default make arguments +MAKE_ARGS = $(MAKE_LOG_FLAGS) -r -R -I $(TOPDIR)/make/common SPEC=$(SPEC) \ + MAKE_LOG_FLAGS="$(MAKE_LOG_FLAGS)" LOG_LEVEL=$(LOG_LEVEL) OUTPUT_SYNC_SUPPORTED:=@OUTPUT_SYNC_SUPPORTED@ OUTPUT_SYNC:=@OUTPUT_SYNC@ @@ -146,6 +133,9 @@ OVERRIDE_SRC_ROOT:=@OVERRIDE_SRC_ROOT@ # The top-level directory of the forest (SRC_ROOT is a traditional alias) TOPDIR:=@TOPDIR@ +# These two versions of TOPDIR are used in string comparisons +ORIGINAL_TOPDIR:=@ORIGINAL_TOPDIR@ +CANONICAL_TOPDIR:=@CANONICAL_TOPDIR@ SRC_ROOT:=@TOPDIR@ OUTPUT_ROOT:=@OUTPUT_ROOT@ @@ -241,13 +231,14 @@ BUILD_OUTPUT:=@BUILD_OUTPUT@ # Colon left out to be able to override IMAGES_OUTPUTDIR for bootcycle-images SUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/support BUILDTOOLS_OUTPUTDIR=$(BUILD_OUTPUT)/buildtools -MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/makesupport HOTSPOT_OUTPUTDIR=$(BUILD_OUTPUT)/hotspot JDK_OUTPUTDIR=$(BUILD_OUTPUT)/jdk IMAGES_OUTPUTDIR=$(BUILD_OUTPUT)/images TESTMAKE_OUTPUTDIR=$(BUILD_OUTPUT)/test-make MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/make-support +# This does not get overridden in a bootcycle build +CONFIGURESUPPORT_OUTPUTDIR:=@CONFIGURESUPPORT_OUTPUTDIR@ HOTSPOT_DIST=@HOTSPOT_DIST@ @@ -269,7 +260,7 @@ MEMORY_SIZE:=@MEMORY_SIZE@ ENABLE_SJAVAC:=@ENABLE_SJAVAC@ # Store sjavac server synchronization files here, and # the sjavac server log files. -SJAVAC_SERVER_DIR:=@SJAVAC_SERVER_DIR@ +SJAVAC_SERVER_DIR=$(MAKESUPPORT_OUTPUTDIR)/javacservers # Number of parallel jobs to use for compilation JOBS?=@JOBS@ @@ -573,18 +564,6 @@ JTREGEXE:=@JTREGEXE@ XCODEBUILD=@XCODEBUILD@ FIXPATH:=@FIXPATH@ -# Where the build output is stored for your convenience. -BUILD_LOG:=@BUILD_LOG@ -BUILD_LOG_PREVIOUS:=@BUILD_LOG_PREVIOUS@ -# Disable the build log wrapper on sjavac+windows until -# we have solved how to prevent the log wrapper to wait -# for the background sjavac server process. -ifeq (@ENABLE_SJAVAC@X@OPENJDK_BUILD_OS@,yesXwindows) - BUILD_LOG_WRAPPER:= -else - BUILD_LOG_WRAPPER:=@BUILD_LOG_WRAPPER@ -endif - # Build setup ENABLE_JFR=@ENABLE_JFR@ ENABLE_INTREE_EC=@ENABLE_INTREE_EC@ diff --git a/common/autoconf/toolchain_windows.m4 b/common/autoconf/toolchain_windows.m4 index dc1a24875c2..87850a25b2f 100644 --- a/common/autoconf/toolchain_windows.m4 +++ b/common/autoconf/toolchain_windows.m4 @@ -270,7 +270,7 @@ AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV], AC_MSG_NOTICE([Trying to extract Visual Studio environment variables]) # We need to create a couple of temporary files. - VS_ENV_TMP_DIR="$OUTPUT_ROOT/vs-env" + VS_ENV_TMP_DIR="$CONFIGURESUPPORT_OUTPUTDIR/vs-env" $MKDIR -p $VS_ENV_TMP_DIR # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment). diff --git a/configure b/configure index 4ab8846d575..af0b5b57bd8 100644 --- a/configure +++ b/configure @@ -31,4 +31,5 @@ this_script_dir=`cd $this_script_dir > /dev/null && pwd` # Delegate to wrapper, forcing wrapper to believe $0 is this script by using -c. # This trick is needed to get autoconf to co-operate properly. -bash -c ". $this_script_dir/common/autoconf/configure" $this_script_dir/configure CHECKME $this_script_dir "$@" +# The ${-:+-$-} construction passes on bash options. +bash ${-:+-$-} -c ". $this_script_dir/common/autoconf/configure" $this_script_dir/configure CHECKME $this_script_dir "$@" diff --git a/corba/.hgtags b/corba/.hgtags index 7eefe327fce..263095cc353 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -300,3 +300,5 @@ d469c5ad0c763e325a78e0af3016878a57dfc5cc jdk9-b54 734ca5311a225711b79618f3e92f47f07c82154a jdk9-b55 ef4afd6832b00b8687832c2a36c90e43750ebe40 jdk9-b56 d8ebf1a5b18ccbc849f5bf0f80aa3d78583eee68 jdk9-b57 +86dd5de1f5cb09073019bd629e22cfcd012d8b4b jdk9-b58 +cda6ae062f85fac5555f4e1318885b0ecd998bd1 jdk9-b59 diff --git a/corba/src/java.corba/share/classes/javax/activity/package.html b/corba/src/java.corba/share/classes/javax/activity/package.html index bceb353231a..d9696cc090a 100644 --- a/corba/src/java.corba/share/classes/javax/activity/package.html +++ b/corba/src/java.corba/share/classes/javax/activity/package.html @@ -2,7 +2,7 @@ @@ -34,7 +33,7 @@ Provides methods for the input and output of value types, and contains other updates to the org/omg/CORBA/portable package. -

+ @since 1.3 @serial exclude diff --git a/corba/src/java.corba/share/classes/org/omg/CosNaming/NamingContextExtPackage/package.html b/corba/src/java.corba/share/classes/org/omg/CosNaming/NamingContextExtPackage/package.html index 1d5e960eafa..4f4284cff2d 100644 --- a/corba/src/java.corba/share/classes/org/omg/CosNaming/NamingContextExtPackage/package.html +++ b/corba/src/java.corba/share/classes/org/omg/CosNaming/NamingContextExtPackage/package.html @@ -3,7 +3,7 @@ + * + * + * + * + * * ... - * </xs:sequence> - * </xs:complexType> - * </xs:element> - * </xs:schema> + * + * + * + * * * JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" ); * Unmarshaller u = jc.createUnmarshaller(); @@ -308,8 +308,8 @@ import java.io.Reader; * // local element declaration in schema. * * // FooType is the JAXB mapping of the type of local element declaration foo. - * JAXBElement<FooType> foo = u.unmarshal( fooSubtree, FooType.class); - * + * JAXBElement foo = u.unmarshal( fooSubtree, FooType.class); + * } * * *

diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAnyElement.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAnyElement.java index 0fcd2dc372f..ce76369549a 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAnyElement.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAnyElement.java @@ -94,15 +94,15 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; *

Schema To Java example

* * The following schema would produce the following Java class: - *
- * <xs:complexType name="foo">
- *   <xs:sequence>
- *     <xs:element name="a" type="xs:int" />
- *     <xs:element name="b" type="xs:int" />
- *     <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
- *   </xs:sequence>
- * </xs:complexType>
- * 
+ *
{@code
+ * 
+ *   
+ *     
+ *     
+ *     
+ *   
+ * 
+ * }
* *
  * class Foo {
@@ -115,30 +115,30 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
  *
  * It can unmarshal instances like
  *
- * 
- * <foo xmlns:e="extra">
- *   <a>1</a>
- *   <e:other />  // this will be bound to DOM, because unmarshalling is orderless
- *   <b>3</b>
- *   <e:other />
- *   <c>5</c>     // this will be bound to DOM, because the annotation doesn't remember namespaces.
- * </foo>
- * 
+ *
{@code
+ * 
+ *   1
+ *     // this will be bound to DOM, because unmarshalling is orderless
+ *   3
+ *   
+ *   5     // this will be bound to DOM, because the annotation doesn't remember namespaces.
+ * 
+ * }
* * * * The following schema would produce the following Java class: - *
- * <xs:complexType name="bar">
- *   <xs:complexContent>
- *   <xs:extension base="foo">
- *     <xs:sequence>
- *       <xs:element name="c" type="xs:int" />
- *       <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
- *     </xs:sequence>
- *   </xs:extension>
- * </xs:complexType>
- * 
+ *
{@code
+ * 
+ *   
+ *   
+ *     
+ *       
+ *       
+ *     
+ *   
+ * 
+ * }
* *
  * class Bar extends Foo {
@@ -150,16 +150,16 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
  *
  * It can unmarshal instances like
  *
- * 
- * <bar xmlns:e="extra">
- *   <a>1</a>
- *   <e:other />  // this will be bound to DOM, because unmarshalling is orderless
- *   <b>3</b>
- *   <e:other />
- *   <c>5</c>     // this now goes to Bar.c
- *   <e:other />  // this will go to Foo.any
- * </bar>
- * 
+ *
{@code
+ * 
+ *   1
+ *     // this will be bound to DOM, because unmarshalling is orderless
+ *   3
+ *   
+ *   5     // this now goes to Bar.c
+ *     // this will go to Foo.any
+ * 
+ * }
* * * @@ -171,15 +171,15 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * *

* The following schema would produce the following Java class: - *

- * <xs:complexType name="foo">
- *   <xs:choice maxOccurs="unbounded" minOccurs="0">
- *     <xs:element name="a" type="xs:int" />
- *     <xs:element name="b" type="xs:int" />
- *     <xs:any namespace="##other" processContents="lax" />
- *   </xs:choice>
- * </xs:complexType>
- * 
+ *
{@code
+ * 
+ *   
+ *     
+ *     
+ *     
+ *   
+ * 
+ * }
* *
  * class Foo {
@@ -204,11 +204,11 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
  * It can unmarshal instances like
  *
  * 
- * <foo xmlns:e="extra">
- *   <a>1</a>     // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
- *   <e:other />  // this will unmarshal to a DOM {@link Element}.
- *   <b>3</b>     // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
- * </foo>
+ *{@code }
+ *{@code   1}     // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
+ *{@code   }  // this will unmarshal to a DOM {@link Element}.
+ *{@code   3}     // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
+ *{@code }
  * 
* * @@ -225,11 +225,11 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * } *
* then the following document will unmarshal like this: - *
- * <foo>
- *   <unknown />
- *   <foo />
- * </foo>
+ * 
{@code
+ * 
+ *   
+ *   
+ * 
  *
  * Foo foo = unmarshal();
  * // 1 for 'unknown', another for 'foo'
@@ -239,7 +239,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
  * // because of lax=true, the 'foo' element eagerly
  * // unmarshals to a Foo object.
  * assert foo.others[1] instanceof Foo;
- * 
+ * }
* * @author Kohsuke Kawaguchi * @since 1.6, JAXB 2.0 diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttachmentRef.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttachmentRef.java index 92d8e91eb3a..a658a0801cb 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttachmentRef.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttachmentRef.java @@ -51,16 +51,16 @@ import java.lang.annotation.Target; * } *
* The above code maps to the following XML: - *
- * <xs:element name="foo" xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd">
- *   <xs:complexType>
- *     <xs:sequence>
- *       <xs:element name="body" type="ref:swaRef" minOccurs="0" />
- *     </xs:sequence>
- *     <xs:attribute name="data" type="ref:swaRef" use="optional" />
- *   </xs:complexType>
- * </xs:element>
- * 
+ *
{@code
+ * 
+ *   
+ *     
+ *       
+ *     
+ *     
+ *   
+ * 
+ * }
* *

* The above binding supports WS-I AP 1.0 WS-I Attachments Profile Version 1.0. diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttribute.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttribute.java index 8e367582ca3..713c5c0f5c0 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttribute.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttribute.java @@ -89,14 +89,15 @@ import static java.lang.annotation.RetentionPolicy.*; * public java.math.BigDecimal getPrice() {...} ; * public void setPrice(java.math.BigDecimal ) {...}; * } + * {@code * - * <!-- Example: XML Schema fragment --> - * <xs:complexType name="USPrice"> - * <xs:sequence> - * </xs:sequence> - * <xs:attribute name="price" type="xs:decimal"/> - * </xs:complexType> - *

+ * + * + * + * + * + * + * } * *

Example 2: Map a JavaBean property to an XML attribute with anonymous type.

* See Example 7 in @{@link XmlType}. @@ -108,17 +109,18 @@ import static java.lang.annotation.RetentionPolicy.*; * ... * @XmlAttribute List<Integer> items; * } + * {@code * - * <!-- Example: XML Schema fragment --> - * <xs:complexType name="foo"> + * + * * ... - * <xs:attribute name="items"> - * <xs:simpleType> - * <xs:list itemType="xs:int"/> - * </xs:simpleType> - * </xs:complexType> + * + * + * + * + * * - * + * } * @author Sekhar Vajjhala, Sun Microsystems, Inc. * @see XmlType * @since 1.6, JAXB 2.0 diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElement.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElement.java index 3d7c89dc836..8f2d881236b 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElement.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElement.java @@ -82,14 +82,15 @@ import static java.lang.annotation.RetentionPolicy.*; * @XmlElement(name="itemprice") * public java.math.BigDecimal price; * } + * {@code * - * <!-- Example: Local XML Schema element --> - * <xs:complexType name="USPrice"/> - * <xs:sequence> - * <xs:element name="itemprice" type="xs:decimal" minOccurs="0"/> - * </sequence> - * </xs:complexType> - * + * + * + * + * + * + * + * } *

* * Example 2: Map a field to a nillable element. @@ -100,14 +101,15 @@ import static java.lang.annotation.RetentionPolicy.*; * @XmlElement(nillable=true) * public java.math.BigDecimal price; * } + * {@code * - * <!-- Example: Local XML Schema element --> - * <xs:complexType name="USPrice"> - * <xs:sequence> - * <xs:element name="price" type="xs:decimal" nillable="true" minOccurs="0"/> - * </sequence> - * </xs:complexType> - * + * + * + * + * + * + * + * } *

* Example 3: Map a field to a nillable, required element. *

@@ -117,14 +119,15 @@ import static java.lang.annotation.RetentionPolicy.*;
  *         @XmlElement(nillable=true, required=true)
  *         public java.math.BigDecimal price;
  *     }
+ * {@code
  *
- *     <!-- Example: Local XML Schema element -->
- *     <xs:complexType name="USPrice">
- *       <xs:sequence>
- *         <xs:element name="price" type="xs:decimal" nillable="true" minOccurs="1"/>
- *       </sequence>
- *     </xs:complexType>
- *   
+ * + * + * + * + * + * + * } * *

Example 4: Map a JavaBean property to an XML element * with anonymous type.

@@ -179,7 +182,7 @@ public @interface XmlElement { * the enclosing class. * *
  • - * Otherwise '' (which produces unqualified element in the default + * Otherwise {@literal ''} (which produces unqualified element in the default * namespace. * */ diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementDecl.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementDecl.java index 6920957a5e6..6d791e95c05 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementDecl.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementDecl.java @@ -65,21 +65,22 @@ import static java.lang.annotation.ElementType.METHOD; * JAXBElement<String> createFoo(String s) { ... } * } * - *
    - *     <!-- XML input -->
    - *       <foo>string</foo>
    + * 
     {@code
    + *
    + *     
    + *     string
      *
      *     // Example: code fragment corresponding to XML input
    - *     JAXBElement<String> o =
    - *     (JAXBElement<String>)unmarshaller.unmarshal(aboveDocument);
    + *     JAXBElement o =
    + *     (JAXBElement)unmarshaller.unmarshal(aboveDocument);
      *     // print JAXBElement instance to show values
      *     System.out.println(o.getName());   // prints  "{}foo"
      *     System.out.println(o.getValue());  // prints  "string"
      *     System.out.println(o.getValue().getClass()); // prints "java.lang.String"
      *
    - *     <!-- Example: XML schema definition -->
    - *     <xs:element name="foo" type="xs:string"/>
    - * 
    + * + * + * }
    * *

    Example 2: Element declaration with non local scope *

    @@ -90,18 +91,18 @@ import static java.lang.annotation.ElementType.METHOD; * The following example may be replaced in a future revision of * this javadoc. * - *

    - *     <!-- Example: XML schema definition -->
    - *     <xs:schema>
    - *       <xs:complexType name="pea">
    - *         <xs:choice maxOccurs="unbounded">
    - *           <xs:element name="foo" type="xs:string"/>
    - *           <xs:element name="bar" type="xs:string"/>
    - *         </xs:choice>
    - *       </xs:complexType>
    - *       <xs:element name="foo" type="xs:int"/>
    - *     </xs:schema>
    - * 
    + *
    {@code
    + *     
    + *     
    + *       
    + *         
    + *           
    + *           
    + *         
    + *       
    + *       
    + *     
    + * }
    *
      *     // Example: expected default binding
      *     class Pea {
    diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementRef.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementRef.java
    index 9f99ca3d80b..b420d7b1414 100644
    --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementRef.java
    +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementRef.java
    @@ -56,10 +56,10 @@ import static java.lang.annotation.ElementType.METHOD;
      * support for substitution groups using an element property,
      * (section 5.5.5, "Element Property" of JAXB 2.0 specification). An
      * element property method signature is of the form:
    - * 
    - *     public void setTerm(JAXBElement<? extends Operator>);
    - *     public JAXBElement<? extends Operator> getTerm();
    - * 
    + *
    {@code
    + *     public void setTerm(JAXBElement);
    + *     public JAXBElement getTerm();
    + * }
    *

    * An element factory method annotated with {@link XmlElementDecl} is * used to create a JAXBElement instance, containing an XML @@ -121,19 +121,20 @@ import static java.lang.annotation.ElementType.METHOD; * class JavacTask extends Task { * ... * } + * {@code * - * <!-- XML Schema fragment --> - * <xs:element name="target" type="Target"> - * <xs:complexType name="Target"> - * <xs:sequence> - * <xs:choice maxOccurs="unbounded"> - * <xs:element ref="jar"> - * <xs:element ref="javac"> - * </xs:choice> - * </xs:sequence> - * </xs:complexType> + * + * + * + * + * + * + * + * + * + * * - *

    + * } *

    * Thus the following code fragment: *

    @@ -143,16 +144,16 @@ import static java.lang.annotation.ElementType.METHOD;
      *     marshal(target);
      * 
    * will produce the following XML output: - *
    - *     <target>
    - *       <jar>
    + * 
    {@code
    + *     
    + *       
      *         ....
    - *       </jar>
    - *       <javac>
    + *       
    + *       
      *         ....
    - *       </javac>
    - *     </target>
    - * 
    + * + * + * }
    *

    * It is not an error to have a class that extends Task * that doesn't have {@link XmlRootElement}. But they can't show up in an @@ -207,11 +208,11 @@ import static java.lang.annotation.ElementType.METHOD; * marshal(m); * * will produce the following XML output: - *

    - *     <math>
    - *       <add>...</add>
    - *     </math>
    - * 
    + *
    {@code
    + *     
    + *       ...
    + *     
    + * }
    * * * @author
    • Kohsuke Kawaguchi, Sun Microsystems,Inc.
    • Sekhar Vajjhala, Sun Microsystems, Inc.
    diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementWrapper.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementWrapper.java index fc7d09c05e8..69f50411fdc 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementWrapper.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementWrapper.java @@ -39,21 +39,21 @@ import java.lang.annotation.Target; * XML element around collections. The annotation therefore supports * two forms of serialization shown below. * - *
    + * 
    {@code
      *    //Example: code fragment
      *      int[] names;
      *
      *    // XML Serialization Form 1 (Unwrapped collection)
    - *    <names> ... </names>
    - *    <names> ... </names>
    + *     ... 
    + *     ... 
      *
      *    // XML Serialization Form 2 ( Wrapped collection )
    - *    <wrapperElement>
    - *       <names> value-of-item </names>
    - *       <names> value-of-item </names>
    + *    
    + *        value-of-item 
    + *        value-of-item 
      *       ....
    - *    </wrapperElement>
    - * 
    + * + * }
    * *

    The two serialized XML forms allow a null collection to be * represented either by absence or presence of an element with a diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElements.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElements.java index e15bb1e4146..fb64513d697 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElements.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElements.java @@ -44,7 +44,7 @@ import java.lang.annotation.Target; * @XmlElements({ @XmlElement(...),@XmlElement(...) }) * * - *

    The @XmlElements annnotation can be used with the + *

    The @XmlElements annotation can be used with the * following program elements:

    *
      *
    • a JavaBean property
    • @@ -78,28 +78,29 @@ import java.lang.annotation.Target; * @XmlElements( * @XmlElement(name="A", type=Integer.class), * @XmlElement(name="B", type=Float.class) - * } + * ) * public List items; * } + * {@code * - * <!-- XML Representation for a List of {1,2.5} - * XML output is not wrapped using another element --> + * * ... - * <A> 1 </A> - * <B> 2.5 </B> + * 1 + * 2.5 * ... * - * <!-- XML Schema fragment --> - * <xs:complexType name="Foo"> - * <xs:sequence> - * <xs:choice minOccurs="0" maxOccurs="unbounded"> - * <xs:element name="A" type="xs:int"/> - * <xs:element name="B" type="xs:float"/> - * <xs:choice> - * </xs:sequence> - * </xs:complexType> + * + * + * + * + * + * + * + * + * * - * + * } * *

      Example 2: Map to a list of elements wrapped with another element *

      @@ -114,21 +115,22 @@ import java.lang.annotation.Target; * } * public List items; * } + * {@code * - * <!-- XML Schema fragment --> - * <xs:complexType name="Foo"> - * <xs:sequence> - * <xs:element name="bar"> - * <xs:complexType> - * <xs:choice minOccurs="0" maxOccurs="unbounded"> - * <xs:element name="A" type="xs:int"/> - * <xs:element name="B" type="xs:float"/> - * </xs:choice> - * </xs:complexType> - * </xs:element> - * </xs:sequence> - * </xs:complexType> - * + * + * + * + * + * + * + * + * + * + * + * + * + * + * } * *

      Example 3: Change element name based on type using an adapter. *

      @@ -145,21 +147,22 @@ import java.lang.annotation.Target; * @XmlType abstract class P {...} * @XmlType(name="PX") class PX extends P {...} * @XmlType(name="PY") class PY extends P {...} + * {@code * - * <!-- XML Schema fragment --> - * <xs:complexType name="Foo"> - * <xs:sequence> - * <xs:element name="bar"> - * <xs:complexType> - * <xs:choice minOccurs="0" maxOccurs="unbounded"> - * <xs:element name="A" type="PX"/> - * <xs:element name="B" type="PY"/> - * </xs:choice> - * </xs:complexType> - * </xs:element> - * </xs:sequence> - * </xs:complexType> - * + * + * + * + * + * + * + * + * + * + * + * + * + * + * } * * @author
      • Kohsuke Kawaguchi, Sun Microsystems, Inc.
      • Sekhar Vajjhala, Sun Microsystems, Inc.
      * @see XmlElement diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlEnumValue.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlEnumValue.java index bcdebcb1a5f..fc29ac0786b 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlEnumValue.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlEnumValue.java @@ -56,23 +56,24 @@ import static java.lang.annotation.ElementType.FIELD; *

      In the absence of this annotation, {@link Enum#name()} is used * as the XML representation. * - *

      Example 1: Map enum constant name -> enumeration facet

      + *

      Example 1: Map enum constant name {@literal ->} enumeration facet

      *
        *     //Example: Code fragment
        *     @XmlEnum(String.class)
        *     public enum Card { CLUBS, DIAMONDS, HEARTS, SPADES }
      + * {@code
        *
      - *     <!-- Example: XML Schema fragment -->
      - *     <xs:simpleType name="Card">
      - *       <xs:restriction base="xs:string"/>
      - *         <xs:enumeration value="CLUBS"/>
      - *         <xs:enumeration value="DIAMONDS"/>
      - *         <xs:enumeration value="HEARTS"/>
      - *         <xs:enumeration value="SPADES"/>
      - *     </xs:simpleType>
      - * 
      + * + * + * + * + * + * + * + * + * } * - *

      Example 2: Map enum constant name(value) -> enumeration facet

      + *

      Example 2: Map enum constant name(value) {@literal ->} enumeration facet

      *
        *     //Example: code fragment
        *     @XmlType
      @@ -82,19 +83,20 @@ import static java.lang.annotation.ElementType.FIELD;
        *         @XmlEnumValue("5") NICKEL(5),
        *         @XmlEnumValue("10") DIME(10),
        *         @XmlEnumValue("25") QUARTER(25) }
      + * {@code
        *
      - *     <!-- Example: XML Schema fragment -->
      - *     <xs:simpleType name="Coin">
      - *       <xs:restriction base="xs:int">
      - *         <xs:enumeration value="1"/>
      - *         <xs:enumeration value="5"/>
      - *         <xs:enumeration value="10"/>
      - *         <xs:enumeration value="25"/>
      - *       </xs:restriction>
      - *     </xs:simpleType>
      - * 
      + * + * + * + * + * + * + * + * + * + * } * - *

      Example 3: Map enum constant name -> enumeration facet

      + *

      Example 3: Map enum constant name {@literal ->} enumeration facet

      * *
        *     //Code fragment
      @@ -104,15 +106,16 @@ import static java.lang.annotation.ElementType.FIELD;
        *         @XmlEnumValue("1") ONE,
        *         @XmlEnumValue("2") TWO;
        *     }
      + * {@code
        *
      - *     <!-- Example: XML Schema fragment -->
      - *     <xs:simpleType name="Code">
      - *       <xs:restriction base="xs:int">
      - *         <xs:enumeration value="1"/>
      - *         <xs:enumeration value="2"/>
      - *       </xs:restriction>
      - *     </xs:simpleType>
      - * 
      + * + * + * + * + * + * + * + * } * * @since 1.6, JAXB 2.0 */ diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlID.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlID.java index 441dc5d101b..52d03609f02 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlID.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlID.java @@ -73,17 +73,18 @@ import static java.lang.annotation.RetentionPolicy.*; * public void setCustomerID(String id); * .... other properties not shown * } + * {@code * - * <!-- Example: XML Schema fragment --> - * <xs:complexType name="Customer"> - * <xs:complexContent> - * <xs:sequence> + * + * + * + * * .... - * </xs:sequence> - * <xs:attribute name="customerID" type="xs:ID"/> - * </xs:complexContent> - * </xs:complexType> - * + * + * + * + * + * } * * @author Sekhar Vajjhala, Sun Microsystems, Inc. * @see XmlIDREF diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlIDREF.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlIDREF.java index 2ad68419da9..503f936d03e 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlIDREF.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlIDREF.java @@ -37,7 +37,7 @@ import static java.lang.annotation.RetentionPolicy.*; *

      * To preserve referential integrity of an object graph across XML * serialization followed by a XML deserialization, requires an object - * reference to be marshalled by reference or containment + * reference to be marshaled by reference or containment * appropriately. Annotations @XmlID and @XmlIDREF * together allow a customized mapping of a JavaBean property's * type by containment or reference. @@ -82,18 +82,19 @@ import static java.lang.annotation.RetentionPolicy.*; * public void setCustomer(Customer customer); * .... * } + * {@code * - * <!-- Example: XML Schema fragment --> - * <xs:complexType name="Shipping"> - * <xs:complexContent> - * <xs:sequence> - * <xs:element name="customer" type="xs:IDREF"/> + * + * + * + * + * * .... - * </xs:sequence> - * </xs:complexContent> - * </xs:complexType> + * + * + * * - * + * } * * *

      Example 2: The following is a complete example of @@ -142,64 +143,65 @@ import static java.lang.annotation.RetentionPolicy.*; * // maps reference to Invoice by containment by default. * public Invoice getInvoice(); * } + * {@code * - * <!-- XML Schema mapping for above code frament --> + * * - * <xs:complexType name="Invoice"> - * <xs:complexContent> - * <xs:sequence> - * <xs:element name="customer" type="xs:IDREF"/> + * + * + * + * * .... - * </xs:sequence> - * </xs:complexContent> - * </xs:complexType> + * + * + * * - * <xs:complexType name="Shipping"> - * <xs:complexContent> - * <xs:sequence> - * <xs:element name="customer" type="xs:IDREF"/> + * + * + * + * * .... - * </xs:sequence> - * </xs:complexContent> - * </xs:complexType> + * + * + * * - * <xs:complexType name="Customer"> - * <xs:complexContent> - * <xs:sequence> + * + * + * * .... - * </xs:sequence> - * <xs:attribute name="CustomerID" type="xs:ID"/> - * </xs:complexContent> - * </xs:complexType> + * + * + * + * * - * <xs:complexType name="CustomerData"> - * <xs:complexContent> - * <xs:sequence> - * <xs:element name="customer" type="xs:Customer"/> - * <xs:element name="shipping" type="xs:Shipping"/> - * <xs:element name="invoice" type="xs:Invoice"/> - * </xs:sequence> - * </xs:complexContent> - * </xs:complexType> + * + * + * + * + * + * + * + * + * * - * <xs:element name"customerData" type="xs:CustomerData"/> + * * - * <!-- Instance document conforming to the above XML Schema --> - * <customerData> - * <customer customerID="Alice"> + * + * + * * .... - * </customer> + * * - * <shipping customer="Alice"> + * * .... - * </shipping> + * * - * <invoice customer="Alice"> + * * .... - * </invoice> - * </customerData> + * + * * - * + * } * *

      Example 3: Mapping List to repeating element of type IDREF *

      @@ -209,16 +211,17 @@ import static java.lang.annotation.RetentionPolicy.*;
        *         @XmlElement(name="Alice")
        *             public List customers;
        *     }
      + * {@code
        *
      - *     <!-- XML schema fragment -->
      - *     <xs:complexType name="Shipping">
      - *       <xs:sequence>
      - *         <xs:choice minOccurs="0" maxOccurs="unbounded">
      - *           <xs:element name="Alice" type="xs:IDREF"/>
      - *         </xs:choice>
      - *       </xs:sequence>
      - *     </xs:complexType>
      - * 
      + * + * + * + * + * + * + * + * + * } * *

      Example 4: Mapping a List to a list of elements of type IDREF. *

      @@ -230,17 +233,18 @@ import static java.lang.annotation.RetentionPolicy.*;
        *              @XmlElement(name="John", type="InternationalCustomer.class")
        *         public List customers;
        *     }
      + * {@code
        *
      - *     <!-- XML Schema fragment -->
      - *     <xs:complexType name="Shipping">
      - *       <xs:sequence>
      - *         <xs:choice minOccurs="0" maxOccurs="unbounded">
      - *           <xs:element name="Alice" type="xs:IDREF"/>
      - *           <xs:element name="John" type="xs:IDREF"/>
      - *         </xs:choice>
      - *       </xs:sequence>
      - *     </xs:complexType>
      - * 
      + * + * + * + * + * + * + * + * + * + * } * @author Sekhar Vajjhala, Sun Microsystems, Inc. * @see XmlID * @since 1.6, JAXB 2.0 diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlList.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlList.java index 9bd81d03355..675fbb4b7f2 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlList.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlList.java @@ -59,12 +59,12 @@ import static java.lang.annotation.ElementType.PARAMETER; * * would produce XML like this: * - *
      - * <foo>
      - *   <data>abc</data>
      - *   <data>def</data>
      - * </foo>
      - * 
      + *
      {@code
      + * 
      + *   abc
      + *   def
      + * 
      + * }
      * * @XmlList annotation, on the other hand, allows multiple values to be * represented as whitespace-separated tokens in a single element. For example, @@ -80,11 +80,11 @@ import static java.lang.annotation.ElementType.PARAMETER; * * the above code will produce XML like this: * - *
      - * <foo>
      - *   <data>abc def</data>
      - * </foo>
      - * 
      + *
      {@code
      + * 
      + *   abc def
      + * 
      + * }
      * *

      This annotation can be used with the following annotations: * {@link XmlElement}, diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlMixed.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlMixed.java index 83c5da66d12..87d160d54d6 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlMixed.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlMixed.java @@ -56,32 +56,33 @@ import javax.xml.bind.JAXBElement; *

    * * Below is an example of binding and creation of mixed content. - *
    - *  <!-- schema fragment having  mixed content -->
    - *  <xs:complexType name="letterBody" mixed="true">
    - *    <xs:sequence>
    - *      <xs:element name="name" type="xs:string"/>
    - *      <xs:element name="quantity" type="xs:positiveInteger"/>
    - *      <xs:element name="productName" type="xs:string"/>
    - *      <!-- etc. -->
    - *    </xs:sequence>
    - *  </xs:complexType>
    - *  <xs:element name="letterBody" type="letterBody"/>
    + * 
    {@code
    + *
    + *  
    + *  
    + *    
    + *      
    + *      
    + *      
    + *      
    + *    
    + *  
    + *  
      *
      * // Schema-derived Java code:
      * // (Only annotations relevant to mixed content are shown below,
    - * //  others are ommitted.)
    + * //  others are omitted.)
      * import java.math.BigInteger;
      * public class ObjectFactory {
      *      // element instance factories
    - *      JAXBElement<LetterBody> createLetterBody(LetterBody value);
    - *      JAXBElement<String>     createLetterBodyName(String value);
    - *      JAXBElement<BigInteger> createLetterBodyQuantity(BigInteger value);
    - *      JAXBElement<String>     createLetterBodyProductName(String value);
    + *      JAXBElement createLetterBody(LetterBody value);
    + *      JAXBElement     createLetterBodyName(String value);
    + *      JAXBElement createLetterBodyQuantity(BigInteger value);
    + *      JAXBElement     createLetterBodyProductName(String value);
      *      // type instance factory
      *      LetterBody createLetterBody();
      * }
    - * 
    + * }
    *
      * public class LetterBody {
      *      // Mixed content can contain instances of Element classes
    @@ -96,17 +97,17 @@ import javax.xml.bind.JAXBElement;
      * }
      * 
    * The following is an XML instance document with mixed content - *
    - * <letterBody>
    - * Dear Mr.<name>Robert Smith</name>
    - * Your order of <quantity>1</quantity> <productName>Baby
    - * Monitor</productName> shipped from our warehouse. ....
    - * </letterBody>
    - * 
    + *
    {@code
    + * 
    + * Dear Mr.Robert Smith
    + * Your order of 1 Baby
    + * Monitor shipped from our warehouse. ....
    + * 
    + * }
    * that can be constructed using following JAXB API calls. - *
    + * 
    {@code
      * LetterBody lb = ObjectFactory.createLetterBody();
    - * JAXBElement<LetterBody> lbe = ObjectFactory.createLetterBody(lb);
    + * JAXBElement lbe = ObjectFactory.createLetterBody(lb);
      * List gcl = lb.getContent();  //add mixed content to general content property.
      * gcl.add("Dear Mr.");  // add text information item as a String.
      *
    @@ -119,7 +120,7 @@ import javax.xml.bind.JAXBElement;
      *                      createLetterBodyQuantity(new BigInteger("1")));
      * gcl.add(ObjectFactory.createLetterBodyProductName("Baby Monitor"));
      * gcl.add("shipped from our warehouse");  // add text information item
    - * 
    + * }
    * *

    See "Package Specification" in javax.xml.bind.package javadoc for * additional common information.

    diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlRootElement.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlRootElement.java index b84e71beca2..fbbf2f69dc9 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlRootElement.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlRootElement.java @@ -73,28 +73,30 @@ import static java.lang.annotation.ElementType.TYPE; * marshal( new Point(3,5), System.out); * * - *
    - *     <!-- Example: XML output -->
    - *     <point>
    - *       <x> 3 </x>
    - *       <y> 5 </y>
    - *     </point>
    - * 
    + *
    {@code
    + *
    + *     
    + *     
    + *        3 
    + *        5 
    + *     
    + * }
    * * The annotation causes an global element declaration to be produced * in the schema. The global element declaration is associated with * the XML schema type to which the class is mapped. * - *
    - *     <!-- Example: XML schema definition -->
    - *     <xs:element name="point" type="point"/>
    - *     <xs:complexType name="point">
    - *       <xs:sequence>
    - *         <xs:element name="x" type="xs:int"/>
    - *         <xs:element name="y" type="xs:int"/>
    - *       </xs:sequence>
    - *     </xs:complexType>
    - * 
    + *
    {@code
    + *
    + *     
    + *     
    + *     
    + *       
    + *         
    + *         
    + *       
    + *     
    + * }
    * *

    * @@ -113,27 +115,28 @@ import static java.lang.annotation.ElementType.TYPE; * * //Example: Code fragment corresponding to XML output * * marshal( new Point3D(3,5,0), System.out ); + * {@code * - * <!-- Example: XML output --> - * <!-- The element name is point3D not point --> - * <point3D> - * <x>3</x> - * <y>5</y> - * <z>0</z> - * </point3D> + * + * + * + * 3 + * 5 + * 0 + * * - * <!-- Example: XML schema definition --> - * <xs:element name="point3D" type="point3D"/> - * <xs:complexType name="point3D"> - * <xs:complexContent> - * <xs:extension base="point"> - * <xs:sequence> - * <xs:element name="z" type="xs:int"/> - * </xs:sequence> - * </xs:extension> - * </xs:complexContent> - * </xs:complexType> - * + * + * + * + * + * + * + * + * + * + * + * + * } * * Example 3: Associate a global element with XML Schema type * to which the class is mapped. @@ -144,15 +147,16 @@ import static java.lang.annotation.ElementType.TYPE; * @XmlElement * public java.math.BigDecimal price; * } + * {@code * - * <!-- Example: XML schema definition --> - * <xs:element name="PriceElement" type="USPrice"/> - * <xs:complexType name="USPrice"> - * <xs:sequence> - * <xs:element name="price" type="xs:decimal"/> - * </sequence> - * </xs:complexType> - * + * + * + * + * + * + * + * + * } * * @author Sekhar Vajjhala, Sun Microsystems, Inc. * @since 1.6, JAXB 2.0 diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchema.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchema.java index 6d25d57a266..db25ef00765 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchema.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchema.java @@ -63,16 +63,17 @@ import static java.lang.annotation.RetentionPolicy.*; * @javax.xml.bind.annotation.XmlSchema ( * namespace = "http://www.example.com/MYPO1" * ) + * {@code * - * <!-- XML Schema fragment --> - * <schema + * + * + * > + * + * } * *

    Example 2: Customize namespace prefix, namespace URI * mapping

    @@ -86,16 +87,17 @@ import static java.lang.annotation.RetentionPolicy.*; * * @javax.xml.bind.annotation.XmlNs(prefix="xs", * namespaceURI="http://www.w3.org/2001/XMLSchema") - * ) + * } * ) + * {@code * - * <!-- XML Schema fragment --> - * <schema + * + * * - * + * } * *

    Example 3: Customize elementFormDefault

    *
    @@ -103,14 +105,15 @@ import static java.lang.annotation.RetentionPolicy.*;
      *      elementFormDefault=XmlNsForm.UNQUALIFIED
      *      ...
      *    )
    + * {@code
      *
    - *    <!-- XML Schema fragment -->
    - *    <schema
    + *    
    + *    
      *
    - * 
    + * } * @author Sekhar Vajjhala, Sun Microsystems, Inc. * @since 1.6, JAXB 2.0 diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchemaType.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchemaType.java index a25b291df06..a1d2859eceb 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchemaType.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchemaType.java @@ -65,14 +65,15 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * @XmlSchemaType(name="date") * public XMLGregorianCalendar date; * } + * {@code * - * <!-- Example: Local XML Schema element --> - * <xs:complexType name="USPrice"/> - * <xs:sequence> - * <xs:element name="date" type="xs:date"/> - * </sequence> - * </xs:complexType> - * + * + * + * + * + * + * + * } * *

    Example 2: Customize mapping of XMLGregorianCalendar at package * level

    diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlTransient.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlTransient.java index 055e90e3ca0..b3394d5465f 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlTransient.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlTransient.java @@ -78,14 +78,15 @@ import static java.lang.annotation.RetentionPolicy.*; * String setName() {..}; * } * + * {@code * - * <!-- Example: XML Schema fragment --> - * <xs:complexType name="USAddress"> - * <xs:sequence> - * <xs:element name="name" type="xs:string"/> - * </xs:sequence> - * </xs:complexType> - * + * + * + * + * + * + * + * } * * @author Sekhar Vajjhala, Sun Microsystems, Inc. * @since 1.6, JAXB 2.0 diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java index 42e71396338..f20d4055860 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java @@ -112,7 +112,7 @@ import java.lang.annotation.Target; * The following table shows the mapping of the class to a XML Schema * complex type or simple type. The notational symbols used in the table are: *
      - *
    • -> : represents a mapping
    • + *
    • {@literal ->} : represents a mapping
    • *
    • [x]+ : one or more occurances of x
    • *
    • [ @XmlValue property ]: JavaBean property annotated with * @XmlValue
    • @@ -132,7 +132,7 @@ import java.lang.annotation.Target; * * Class * {} - * [property]+ -> elements + * [property]+ {@literal ->} elements * complexcontent
      xs:all * * @@ -140,7 +140,7 @@ import java.lang.annotation.Target; * * Class * non empty - * [property]+ -> elements + * [property]+ {@literal ->} elements * complexcontent
      xs:sequence * * @@ -148,7 +148,7 @@ import java.lang.annotation.Target; * * Class * X - * no property -> element + * no property {@literal ->} element * complexcontent
      empty sequence * * @@ -156,7 +156,7 @@ import java.lang.annotation.Target; * * Class * X - * 1 [@XmlValue property] {@literal &&}
      [property]+ -> attributes + * 1 [@XmlValue property] {@literal &&}
      [property]+ {@literal ->} attributes * simplecontent * * @@ -164,7 +164,7 @@ import java.lang.annotation.Target; * * Class * X - * 1 [@XmlValue property] {@literal &&}
      no properties -> attribute + * 1 [@XmlValue property] {@literal &&}
      no properties {@literal ->} attribute * * simpletype * @@ -208,35 +208,37 @@ import java.lang.annotation.Target; * java.math.BigDecimal getZip() {..}; * void setZip(java.math.BigDecimal) {..}; * } + * {@code * - * <!-- XML Schema mapping for USAddress --> - * <xs:complexType name="USAddress"> - * <xs:sequence> - * <xs:element name="street" type="xs:string"/> - * <xs:element name="city" type="xs:string"/> - * <xs:element name="state" type="xs:string"/> - * <xs:element name="zip" type="xs:decimal"/> - * <xs:element name="name" type="xs:string"/> - * </xs:all> - * </xs:complexType> - * + * + * + * + * + * + * + * + * + * + * + * } *

      Example 2: Map a class to a complex type with * xs:all

      *
        * @XmlType(propOrder={})
        * public class USAddress { ...}
      + * {@code
        *
      - * <!-- XML Schema mapping for USAddress -->
      - * <xs:complexType name="USAddress">
      - *   <xs:all>
      - *     <xs:element name="name" type="xs:string"/>
      - *     <xs:element name="street" type="xs:string"/>
      - *     <xs:element name="city" type="xs:string"/>
      - *     <xs:element name="state" type="xs:string"/>
      - *     <xs:element name="zip" type="xs:decimal"/>
      - *   </xs:sequence>
      - * </xs:complexType>
      - *
      + * + * + * + * + * + * + * + * + * + * + *} *

      Example 3: Map a class to a global element with an * anonymous type. *

      @@ -244,20 +246,21 @@ import java.lang.annotation.Target; * @XmlRootElement * @XmlType(name="") * public class USAddress { ...} + * {@code * - * <!-- XML Schema mapping for USAddress --> - * <xs:element name="USAddress"> - * <xs:complexType> - * <xs:sequence> - * <xs:element name="name" type="xs:string"/> - * <xs:element name="street" type="xs:string"/> - * <xs:element name="city" type="xs:string"/> - * <xs:element name="state" type="xs:string"/> - * <xs:element name="zip" type="xs:decimal"/> - * </xs:sequence> - * </xs:complexType> - * </xs:element> - * + * + * + * + * + * + * + * + * + * + * + * + * + * } * *

      Example 4: Map a property to a local element with * anonymous type. @@ -271,22 +274,23 @@ import java.lang.annotation.Target; * @XmlType(name="") * public class USAddress { ... } * } + * {@code * - * <!-- XML Schema mapping for USAddress --> - * <xs:complexType name="Invoice"> - * <xs:sequence> - * <xs:element name="addr"> - * <xs:complexType> - * <xs:element name="name", type="xs:string"/> - * <xs:element name="city", type="xs:string"/> - * <xs:element name="city" type="xs:string"/> - * <xs:element name="state" type="xs:string"/> - * <xs:element name="zip" type="xs:decimal"/> - * </xs:complexType> + * + * + * + * + * + * + * + * + * + * + * * ... - * </xs:sequence> - * </xs:complexType> - * + * + * + * } * *

      Example 5: Map a property to an attribute with * anonymous type. @@ -306,19 +310,20 @@ import java.lang.annotation.Target; * @XmlValue * public java.math.BigDecimal price; * } + * {@code * - * <!-- Example: XML Schema fragment --> - * <xs:complexType name="Item"> - * <xs:sequence> - * <xs:element name="name" type="xs:string"/> - * <xs:attribute name="price"> - * <xs:simpleType> - * <xs:restriction base="xs:decimal"/> - * </xs:simpleType> - * </xs:attribute> - * </xs:sequence> - * </xs:complexType> - * + * + * + * + * + * + * + * + * + * + * + * + * } * *

      Example 6: Define a factoryClass and factoryMethod * diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlValue.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlValue.java index 1ab10854a4f..675305b5821 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlValue.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlValue.java @@ -87,13 +87,14 @@ import static java.lang.annotation.RetentionPolicy.*; * @XmlValue * public java.math.BigDecimal price; * } + * {@code * - * <!-- Example 1: XML Schema fragment --> - * <xs:simpleType name="USPrice"> - * <xs:restriction base="xs:decimal"/> - * </xs:simpleType> + * + * + * + * * - * + * } * *

      Example 2: Map a class to XML Schema complexType with * with simpleContent.

      @@ -108,17 +109,18 @@ import static java.lang.annotation.RetentionPolicy.*; * @XmlAttribute * public String currency; * } + * {@code * - * <!-- Example 2: XML Schema fragment --> - * <xs:complexType name="InternationalPrice"> - * <xs:simpleContent> - * <xs:extension base="xs:decimal"> - * <xs:attribute name="currency" type="xs:string"/> - * </xs:extension> - * </xs:simpleContent> - * </xs:complexType> + * + * + * + * + * + * + * + * * - * + * } * * @author Sekhar Vajjhala, Sun Microsystems, Inc. * @see XmlType diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.java index 9a589653c12..38865a0c32f 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ package javax.xml.bind.annotation.adapters; * *

      * This adapter removes leading and trailing whitespaces, then truncate any - * sequnce of tab, CR, LF, and SP by a single whitespace character ' '. + * sequence of tab, CR, LF, and SP by a single whitespace character ' '. * * @author Kohsuke Kawaguchi * @since 1.6, JAXB 2.0 @@ -41,7 +41,7 @@ public class CollapsedStringAdapter extends XmlAdapter { /** * Removes leading and trailing whitespaces of the string * given as the parameter, then truncate any - * sequnce of tab, CR, LF, and SP by a single whitespace character ' '. + * sequence of tab, CR, LF, and SP by a single whitespace character ' '. */ public String unmarshal(String text) { if(text==null) return null; // be defensive diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlAdapter.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlAdapter.java index 4a500814f02..3c5bd422512 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlAdapter.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlAdapter.java @@ -75,35 +75,35 @@ package javax.xml.bind.annotation.adapters; * *

      Step 1: Determine the desired XML representation for HashMap. * - *

      - *     <hashmap>
      - *         <entry key="id123">this is a value</entry>
      - *         <entry key="id312">this is another value</entry>
      + * 
      {@code
      + *     
      + *         this is a value
      + *         this is another value
        *         ...
      - *       </hashmap>
      - * 
      + * + * }
      * *

      Step 2: Determine the schema definition that the * desired XML representation shown above should follow. * - *

      + * 
      {@code
        *
      - *     <xs:complexType name="myHashMapType">
      - *       <xs:sequence>
      - *         <xs:element name="entry" type="myHashMapEntryType"
      - *                        minOccurs = "0" maxOccurs="unbounded"/>
      - *       </xs:sequence>
      - *     </xs:complexType>
      + *     
      + *       
      + *         
      + *       
      + *     
        *
      - *     <xs:complexType name="myHashMapEntryType">
      - *       <xs:simpleContent>
      - *         <xs:extension base="xs:string">
      - *           <xs:attribute name="key" type="xs:int"/>
      - *         </xs:extension>
      - *       </xs:simpleContent>
      - *     </xs:complexType>
      + *     
      + *       
      + *         
      + *           
      + *         
      + *       
      + *     
        *
      - * 
      + * }
      * *

      Step 3: Write value types that can generate the above * schema definition. @@ -125,11 +125,11 @@ package javax.xml.bind.annotation.adapters; *

      Step 4: Write the adapter that adapts the value type, * MyHashMapType to a bound type, HashMap, used by the application. * - *

      + * 
      {@code
        *     public final class MyHashMapAdapter extends
      - *                        XmlAdapter<MyHashMapType,HashMap> { ... }
      + *                        XmlAdapter { ... }
        *
      - * 
      + * }
      * *

      Step 5: Use the adapter. * @@ -143,13 +143,13 @@ package javax.xml.bind.annotation.adapters; * * The above code fragment will map to the following schema: * - *

      - *     <xs:complexType name="Foo">
      - *       <xs:sequence>
      - *         <xs:element name="hashmap" type="myHashMapType">
      - *       </xs:sequence>
      - *     </xs:complexType>
      - * 
      + *
      {@code
      + *     
      + *       
      + *         
      + *       
      + *     
      + * }
      * * @param * The type that JAXB doesn't know how to handle. An adapter is written diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java index 6cebcf89dc9..2f1ee037750 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ import java.lang.annotation.Target; * @XmlJavaTypeAdapters ({ @XmlJavaTypeAdapter(...),@XmlJavaTypeAdapter(...) }) * * - *

      The @XmlJavaTypeAdapters annnotation is useful for + *

      The @XmlJavaTypeAdapters annotation is useful for * defining {@link XmlJavaTypeAdapter} annotations for different types * at the package level. * diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/addressing/EPRHeader.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/addressing/EPRHeader.java index 3c73af04610..642dee10f70 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/addressing/EPRHeader.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/addressing/EPRHeader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -119,7 +119,7 @@ final class EPRHeader extends AbstractHeaderImpl { epr.writeTo(localName, w); w.flush(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory fac = XmlUtil.newDocumentBuilderFactory(false); fac.setNamespaceAware(true); Node eprNode = fac.newDocumentBuilder().parse(bais).getDocumentElement(); Node eprNodeToAdd = header.getOwnerDocument().importNode(eprNode, true); diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/message/stream/StreamHeader.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/message/stream/StreamHeader.java index 6415f1319bb..ae268e2f86f 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/message/stream/StreamHeader.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/message/stream/StreamHeader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -194,7 +194,7 @@ public abstract class StreamHeader extends AbstractHeaderImpl { // TODO what about in-scope namespaces // Not very efficient consider implementing a stream buffer // processor that produces a DOM node from the buffer. - TransformerFactory tf = XmlUtil.newTransformerFactory(); + TransformerFactory tf = XmlUtil.newTransformerFactory(true); Transformer t = tf.newTransformer(); XMLStreamBufferSource source = new XMLStreamBufferSource(_mark); DOMResult result = new DOMResult(); diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/spi/db/BindingHelper.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/spi/db/BindingHelper.java index 86d36466e45..84047b67d24 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/spi/db/BindingHelper.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/spi/db/BindingHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,9 @@ import com.sun.xml.internal.bind.marshaller.SAX2DOMEx; //TODO DOMHeader DOMMessage SAAJMessage StatefulInstanceResolver import com.sun.xml.internal.bind.unmarshaller.DOMScanner; +//TODO MtomCodec +import com.sun.xml.internal.bind.v2.runtime.output.Encoded; + //TODO ExceptionBean import com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper; diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/DOMUtil.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/DOMUtil.java index e5f8cb7c0ad..47fb059f2c5 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/DOMUtil.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/DOMUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ public class DOMUtil { synchronized (DOMUtil.class) { if (db == null) { try { - DocumentBuilderFactory dbf = XmlUtil.newDocumentBuilderFactory(); + DocumentBuilderFactory dbf = XmlUtil.newDocumentBuilderFactory(true); dbf.setNamespaceAware(true); db = dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/pipe/AbstractSchemaValidationTube.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/pipe/AbstractSchemaValidationTube.java index 6241299d41a..9a8641035bd 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/pipe/AbstractSchemaValidationTube.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/pipe/AbstractSchemaValidationTube.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -92,7 +92,7 @@ public abstract class AbstractSchemaValidationTube extends AbstractFilterTubeImp super(next); this.binding = binding; feature = binding.getFeature(SchemaValidationFeature.class); - sf = allowExternalAccess(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI), "file", false); + sf = allowExternalAccess(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI), "all", false); } protected AbstractSchemaValidationTube(AbstractSchemaValidationTube that, TubeCloner cloner) { diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties index b18bbc710b0..8cc250fb181 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ # questions. # -build-id=2.2.11-b150127.1410 -build-version=JAX-WS RI 2.2.11-b150127.1410 +build-id=2.2.11-b150402.1412 +build-version=JAX-WS RI 2.2.11-b150402.1412 major-version=2.2.11 -svn-revision=28121d09ed8ac02b76788709ccb4cdb66e03bbfa +svn-revision=f923291dedcf386c5f408263984a99d7cedf0012 diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XMLStreamReaderToXMLStreamWriter.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XMLStreamReaderToXMLStreamWriter.java index 14ad9743353..d30bb8aba62 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XMLStreamReaderToXMLStreamWriter.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XMLStreamReaderToXMLStreamWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -187,14 +187,11 @@ public class XMLStreamReaderToXMLStreamWriter { protected void handleStartElement() throws XMLStreamException { String nsUri = in.getNamespaceURI(); - if(nsUri==null) - out.writeStartElement(in.getLocalName()); - else - out.writeStartElement( - fixNull(in.getPrefix()), - in.getLocalName(), - nsUri - ); + out.writeStartElement( + fixNull(in.getPrefix()), + in.getLocalName(), + fixNull(nsUri) + ); // start namespace bindings int nsCount = in.getNamespaceCount(); diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java index 10ad6086112..18d7fcd55ed 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -231,7 +231,7 @@ public class XmlUtil { static final ContextClassloaderLocal saxParserFactory = new ContextClassloaderLocal() { @Override protected SAXParserFactory initialValue() throws Exception { - SAXParserFactory factory = SAXParserFactory.newInstance(); + SAXParserFactory factory = newSAXParserFactory(true); factory.setNamespaceAware(true); return factory; } @@ -371,57 +371,49 @@ public class XmlUtil { } }; - public static DocumentBuilderFactory newDocumentBuilderFactory() { - return newDocumentBuilderFactory(true); - } - - public static DocumentBuilderFactory newDocumentBuilderFactory(boolean secureXmlProcessing) { + public static DocumentBuilderFactory newDocumentBuilderFactory(boolean disableSecurity) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { - factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, isXMLSecurityDisabled(secureXmlProcessing)); + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity)); } catch (ParserConfigurationException e) { LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[] { factory.getClass().getName() } ); } return factory; } - public static TransformerFactory newTransformerFactory(boolean secureXmlProcessingEnabled) { + public static TransformerFactory newTransformerFactory(boolean disableSecurity) { TransformerFactory factory = TransformerFactory.newInstance(); try { - factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, isXMLSecurityDisabled(secureXmlProcessingEnabled)); + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity)); } catch (TransformerConfigurationException e) { LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[]{factory.getClass().getName()}); } return factory; } - public static TransformerFactory newTransformerFactory() { - return newTransformerFactory(true); - } - - public static SAXParserFactory newSAXParserFactory(boolean secureXmlProcessingEnabled) { + public static SAXParserFactory newSAXParserFactory(boolean disableSecurity) { SAXParserFactory factory = SAXParserFactory.newInstance(); try { - factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, isXMLSecurityDisabled(secureXmlProcessingEnabled)); + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity)); } catch (Exception e) { LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[]{factory.getClass().getName()}); } return factory; } - public static XPathFactory newXPathFactory(boolean secureXmlProcessingEnabled) { + public static XPathFactory newXPathFactory(boolean disableSecurity) { XPathFactory factory = XPathFactory.newInstance(); try { - factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, isXMLSecurityDisabled(secureXmlProcessingEnabled)); + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity)); } catch (XPathFactoryConfigurationException e) { LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[] { factory.getClass().getName() } ); } return factory; } - public static XMLInputFactory newXMLInputFactory(boolean secureXmlProcessingEnabled) { + public static XMLInputFactory newXMLInputFactory(boolean disableSecurity) { XMLInputFactory factory = XMLInputFactory.newInstance(); - if (isXMLSecurityDisabled(secureXmlProcessingEnabled)) { + if (xmlSecurityDisabled(disableSecurity)) { // TODO-Miran: are those apppropriate defaults? factory.setProperty(XMLInputFactory.SUPPORT_DTD, false); factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); @@ -429,14 +421,14 @@ public class XmlUtil { return factory; } - private static boolean isXMLSecurityDisabled(boolean runtimeDisabled) { + private static boolean xmlSecurityDisabled(boolean runtimeDisabled) { return XML_SECURITY_DISABLED || runtimeDisabled; } - public static SchemaFactory allowExternalAccess(SchemaFactory sf, String value, boolean disableSecureProcessing) { + public static SchemaFactory allowExternalAccess(SchemaFactory sf, String value, boolean disableSecurity) { // if xml security (feature secure processing) disabled, nothing to do, no restrictions applied - if (isXMLSecurityDisabled(disableSecureProcessing)) { + if (xmlSecurityDisabled(disableSecurity)) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Xml Security disabled, no JAXP xsd external access configuration necessary."); } diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle.properties index 427db1f466e..19f062ab0b0 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -30,10 +30,10 @@ BASEDIR_DOESNT_EXIST = \ Non-existent directory: {0} VERSION = \ - schemagen 2.2.12-b150126.1924 + schemagen 2.2.12-b150331.1824 FULLVERSION = \ - schemagen full version "2.2.12-b150126.1924" + schemagen full version "2.2.12-b150331.1824" USAGE = \ Usage: schemagen [-options ...] \n\ diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_de.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_de.properties index 435ed7150a6..1de04cc98b7 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_de.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_de.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = Nicht erkanntes {0} in Zeile {1} Spalte {2} BASEDIR_DOESNT_EXIST = Nicht vorhandenes Verzeichnis: {0} -VERSION = schemagen 2.2.12-b150126.1924 +VERSION = schemagen 2.2.12-b150331.1824 -FULLVERSION = schemagen vollst\u00E4ndige Version "2.2.12-b150126.1924" +FULLVERSION = schemagen vollst\u00E4ndige Version "2.2.12-b150331.1824" USAGE = Verwendung: schemagen [-options ...] \nOptionen: \n\\ \\ \\ \\ -d : Gibt an, wo die von Prozessor und javac generierten Klassendateien gespeichert werden sollen\n\\ \\ \\ \\ -cp : Gibt an, wo die vom Benutzer angegebenen Dateien gespeichert sind\n\\ \\ \\ \\ -classpath : Gibt an, wo die vom Benutzer angegebenen Dateien gespeichert sind\n\\ \\ \\ \\ -encoding : Gibt die Codierung f\u00FCr die Annotationsverarbeitung/den javac-Aufruf an \n\\ \\ \\ \\ -episode : Generiert Episodendatei f\u00FCr separate Kompilierung\n\\ \\ \\ \\ -version : Zeigt Versionsinformation an\n\\ \\ \\ \\ -fullversion : Zeigt vollst\u00E4ndige Versionsinformationen an\n\\ \\ \\ \\ -help : Zeigt diese Verwendungsmeldung an diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_es.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_es.properties index c6d5aad27fa..015e45a1be0 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_es.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_es.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = Aparece un {0} inesperado en la l\u00EDnea {1} y la colu BASEDIR_DOESNT_EXIST = Directorio no existente: {0} -VERSION = schemagen 2.2.12-b150126.1924 +VERSION = schemagen 2.2.12-b150331.1824 -FULLVERSION = versi\u00F3n completa de schemagen "2.2.12-b150126.1924" +FULLVERSION = versi\u00F3n completa de schemagen "2.2.12-b150331.1824" USAGE = Sintaxis: schemagen [-options ...] \nOpciones: \n\\ \\ \\ \\ -d : especifique d\u00F3nde se colocan los archivos de clase generados por javac y el procesador\n\\ \\ \\ \\ -cp : especifique d\u00F3nde se encuentran los archivos especificados por el usuario\n\\ \\ \\ \\ -encoding : especifique la codificaci\u00F3n que se va a utilizar para el procesamiento de anotaciones/llamada de javac\n\\ \\ \\ \\ -episode : genera un archivo de episodio para una compilaci\u00F3n diferente\n\\ \\ \\ \\ -version : muestra la informaci\u00F3n de la versi\u00F3n\n\\ \\ \\ \\ -fullversion : muestra la informaci\u00F3n completa de la versi\u00F3n\n\\ \\ \\ \\ -help : muestra este mensaje de sintaxis diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties index 756a94788fa..a006426db90 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = Un \u00E9l\u00E9ment {0} inattendu appara\u00EEt \u00E0 BASEDIR_DOESNT_EXIST = R\u00E9pertoire {0} inexistant -VERSION = schemagen 2.2.12-b150126.1924 +VERSION = schemagen 2.2.12-b150331.1824 -FULLVERSION = version compl\u00E8te de schemagen "2.2.12-b150126.1924" +FULLVERSION = version compl\u00E8te de schemagen "2.2.12-b150331.1824" USAGE = Syntaxe : schemagen [-options ...] \nOptions : \n\ \ \ \ -d : indiquez o\u00F9 placer les fichiers de classe g\u00E9n\u00E9r\u00E9s par le processeur et le compilateur javac\n\ \ \ \ -cp : indiquez o\u00F9 trouver les fichiers sp\u00E9cifi\u00E9s par l'utilisateur\n\ \ \ \ -classpath : indiquez o\u00F9 trouver les fichiers sp\u00E9cifi\u00E9s par l'utilisateur\n\ \ \ \ -encoding : indiquez l'encodage \u00E0 utiliser pour l'appel de javac/traitement de l'annotation \n\ \ \ \ -episode : g\u00E9n\u00E9rez un fichier d'\u00E9pisode pour la compilation s\u00E9par\u00E9e\n\ \ \ \ -version : affichez les informations de version\n\ \ \ \ -fullversion : affichez les informations compl\u00E8tes de version\n\ \ \ \ -help : affichez ce message de syntaxe diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_it.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_it.properties index 992b68e2c77..ca32febc263 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_it.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_it.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = {0} imprevisto visualizzato sulla riga {1} colonna {2} BASEDIR_DOESNT_EXIST = Directory non esistente: {0} -VERSION = schemagen 2.2.12-b150126.1924 +VERSION = schemagen 2.2.12-b150331.1824 -FULLVERSION = versione completa schemagen "2.2.12-b150126.1924" +FULLVERSION = versione completa schemagen "2.2.12-b150331.1824" USAGE = Uso: schemagen [-options ...] \nOpzioni: \n\ \ \ \ -d : specifica dove posizionare il processore e i file della classe generata javac\n\ \ \ \ -cp : specifica dove trovare i file specificati dall'utente\n\ \ \ \ -classpath : specifica dove trovare i file specificati dall'utente\n\ \ \ \ -encoding : specifica la codifica da usare per l'elaborazione dell'annotazione/richiamo javac \n\ \ \ \ -episode : genera il file di episodio per la compilazione separata\n\ \ \ \ -version : visualizza le informazioni sulla versione\n\ \ \ \ -fullversion : visualizza le informazioni sulla versione completa\n\ \ \ \ -help : visualizza questo messaggio sull'uso diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties index bf3e933ce1c..28f152ffcbd 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \u4E88\u671F\u3057\u306A\u3044{0}\u304C\u884C{1}\u3001\u BASEDIR_DOESNT_EXIST = \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u5B58\u5728\u3057\u307E\u305B\u3093: {0} -VERSION = schemagen 2.2.12-b150126.1924 +VERSION = schemagen 2.2.12-b150331.1824 -FULLVERSION = schemagen\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b150126.1924" +FULLVERSION = schemagen\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b150331.1824" USAGE = \u4F7F\u7528\u65B9\u6CD5: schemagen [-options ...] \n\u30AA\u30D7\u30B7\u30E7\u30F3: \n\ \ \ \ -d : \u30D7\u30ED\u30BB\u30C3\u30B5\u304A\u3088\u3073javac\u304C\u751F\u6210\u3057\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -cp : \u30E6\u30FC\u30B6\u30FC\u304C\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -classpath : \u30E6\u30FC\u30B6\u30FC\u304C\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -encoding : \u6CE8\u91C8\u51E6\u7406/javac\u547C\u51FA\u3057\u306B\u4F7F\u7528\u3059\u308B\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -episode : \u30B3\u30F3\u30D1\u30A4\u30EB\u3054\u3068\u306B\u30A8\u30D4\u30BD\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u3057\u307E\u3059\n\ \ \ \ -version : \u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3057\u307E\u3059\n\ \ \ \ -fullversion : \u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3057\u307E\u3059\n\ \ \ \ -help : \u3053\u306E\u4F7F\u7528\u4F8B\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3057\u307E\u3059 diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties index 31ba0ab9637..1f7cd2ef605 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \uC608\uC0C1\uCE58 \uC54A\uC740 {0}\uC774(\uAC00) {1}\uD BASEDIR_DOESNT_EXIST = \uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 \uB514\uB809\uD1A0\uB9AC: {0} -VERSION = schemagen 2.2.12-b150126.1924 +VERSION = schemagen 2.2.12-b150331.1824 -FULLVERSION = schemagen \uC815\uC2DD \uBC84\uC804 "2.2.12-b150126.1924" +FULLVERSION = schemagen \uC815\uC2DD \uBC84\uC804 "2.2.12-b150331.1824" USAGE = \uC0AC\uC6A9\uBC95: schemagen [-options ...] \n\uC635\uC158: \n\ \ \ \ -d : \uD504\uB85C\uC138\uC11C \uBC0F javac\uC5D0\uC11C \uC0DD\uC131\uD55C \uD074\uB798\uC2A4 \uD30C\uC77C\uC744 \uBC30\uCE58\uD560 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -cp : \uC0AC\uC6A9\uC790\uAC00 \uC9C0\uC815\uD55C \uD30C\uC77C\uC744 \uCC3E\uC744 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -classpath : \uC0AC\uC6A9\uC790\uAC00 \uC9C0\uC815\uD55C \uD30C\uC77C\uC744 \uCC3E\uC744 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -encoding : \uC8FC\uC11D \uCC98\uB9AC/javac \uD638\uCD9C\uC5D0 \uC0AC\uC6A9\uD560 \uC778\uCF54\uB529\uC744 \uC9C0\uC815\uD569\uB2C8\uB2E4. \n\ \ \ \ -episode : \uBCC4\uB3C4 \uCEF4\uD30C\uC77C\uC744 \uC704\uD574 episode \uD30C\uC77C\uC744 \uC0DD\uC131\uD569\uB2C8\uB2E4.\n\ \ \ \ -version : \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n\ \ \ \ -fullversion : \uC815\uC2DD \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n\ \ \ \ -help : \uC774 \uC0AC\uC6A9\uBC95 \uBA54\uC2DC\uC9C0\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4. diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties index c2f4155d874..0596527faad 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = {0} inesperado aparece na linha {1} coluna {2} BASEDIR_DOESNT_EXIST = Diret\u00F3rio n\u00E3o existente: {0} -VERSION = gera\u00E7\u00E3o do esquema 2.2.12-b150126.1924 +VERSION = gera\u00E7\u00E3o do esquema 2.2.12-b150331.1824 -FULLVERSION = vers\u00E3o completa da gera\u00E7\u00E3o do esquema "2.2.12-b150126.1924" +FULLVERSION = vers\u00E3o completa da gera\u00E7\u00E3o do esquema "2.2.12-b150331.1824" USAGE = Uso: gera\u00E7\u00E3o do esquema [-options ...] \nOp\u00E7\u00F5es: \n\\ \\ \\ \\ -d : especificar onde colocar o processador e os arquivos da classe gerados por javac\n\\ \\ \\ \\ -cp : especificar onde localizar arquivos especificados pelo usu\u00E1rio\n\\ \\ \\ \\ -classpath : especificar onde localizar os arquivos especificados pelo usu\u00E1rio\n\\ \\ \\ \\ -encoding : especificar codifica\u00E7\u00E3o a ser usada para processamento de anota\u00E7\u00E3o/chamada javac \n\\ \\ \\ \\ -episode : gerar arquivo do epis\u00F3dio para compila\u00E7\u00E3o separada\n\\ \\ \\ \\ -version : exibir informa\u00E7\u00F5es da vers\u00E3o\n\\ \\ \\ \\ -fullversion : exibir informa\u00E7\u00F5es da vers\u00E3o completa\n\\ \\ \\ \\ -help : exibir esta mensagem de uso diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties index cec06517656..3d780676808 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \u5728\u7B2C {1} \u884C, \u7B2C {2} \u5217\u51FA\u73B0\u BASEDIR_DOESNT_EXIST = \u4E0D\u5B58\u5728\u7684\u76EE\u5F55: {0} -VERSION = schemagen 2.2.12-b150126.1924 +VERSION = schemagen 2.2.12-b150331.1824 -FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924" +FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b150331.1824" USAGE = \u7528\u6CD5: schemagen [-options ...] \n\u9009\u9879: \n\ \ \ \ -d : \u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u548C javac \u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -cp : \u6307\u5B9A\u67E5\u627E\u7528\u6237\u6307\u5B9A\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -classpath : \u6307\u5B9A\u67E5\u627E\u7528\u6237\u6307\u5B9A\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -encoding : \u6307\u5B9A\u7528\u4E8E\u6CE8\u91CA\u5904\u7406/javac \u8C03\u7528\u7684\u7F16\u7801\n\ \ \ \ -episode : \u751F\u6210\u7247\u6BB5\u6587\u4EF6\u4EE5\u4F9B\u5355\u72EC\u7F16\u8BD1\n\ \ \ \ -version : \u663E\u793A\u7248\u672C\u4FE1\u606F\n\ \ \ \ -fullversion : \u663E\u793A\u5B8C\u6574\u7684\u7248\u672C\u4FE1\u606F\n\ \ \ \ -help : \u663E\u793A\u6B64\u7528\u6CD5\u6D88\u606F diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties index 938aef76528..1ded7446a25 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \u672A\u9810\u671F\u7684 {0} \u986F\u793A\u65BC\u884C {1 BASEDIR_DOESNT_EXIST = \u4E0D\u5B58\u5728\u7684\u76EE\u9304: {0} -VERSION = schemagen 2.2.12-b150126.1924 +VERSION = schemagen 2.2.12-b150331.1824 -FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924" +FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b150331.1824" USAGE = \u7528\u6CD5: schemagen [-options ...] \n\u9078\u9805: \n\\ \\ \\ \\ -d : \u6307\u5B9A\u8655\u7406\u5668\u4EE5\u53CA javac \u7522\u751F\u7684\u985E\u5225\u6A94\u6848\u653E\u7F6E\u4F4D\u7F6E\n\\ \\ \\ \\ -cp : \u6307\u5B9A\u8981\u5C0B\u627E\u4F7F\u7528\u8005\u6307\u5B9A\u6A94\u6848\u7684\u4F4D\u7F6E\n\\ \\ \\ \\ -classpath : \u6307\u5B9A\u8981\u5C0B\u627E\u4F7F\u7528\u8005\u6307\u5B9A\u6A94\u6848\u7684\u4F4D\u7F6E\n\\ \\ \\ \\ -encoding : \u6307\u5B9A\u8981\u7528\u65BC\u8A3B\u89E3\u8655\u7406/javac \u547C\u53EB\u7684\u7DE8\u78BC \n\\ \\ \\ \\ -episode : \u7522\u751F\u7368\u7ACB\u7DE8\u8B6F\u7684\u4E8B\u4EF6 (episode) \u6A94\u6848\n\\ \\ \\ \\ -version : \u986F\u793A\u7248\u672C\u8CC7\u8A0A\n\\ \\ \\ \\ -fullversion : \u986F\u793A\u5B8C\u6574\u7248\u672C\u8CC7\u8A0A\n\\ \\ \\ \\ -help : \u986F\u793A\u6B64\u7528\u6CD5\u8A0A\u606F diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java index 47d62d8e713..6a3eec71d50 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -158,7 +158,12 @@ public class SchemaGenerator { while (cl != null) { if (cl instanceof URLClassLoader) { for (URL url : ((URLClassLoader) cl).getURLs()) { - appendPath(cp, url.getPath()); + try { + appendPath(cp,new File(url.toURI()).getPath()); + } catch(URISyntaxException ex) { + /*If the URL is not properly formated - skip it*/ + LOGGER.log(Level.SEVERE, ex.getMessage(), ex); + } } } cl = cl.getParent(); diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/ap/SchemaGenerator.java b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/ap/SchemaGenerator.java index a15b1453e9f..2a8b59894fe 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/ap/SchemaGenerator.java +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/ap/SchemaGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,6 @@ * questions. */ - - package com.sun.tools.internal.jxc.ap; import com.sun.tools.internal.jxc.api.JXC; @@ -89,12 +87,12 @@ public class SchemaGenerator extends AbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { final ErrorReceiverImpl errorListener = new ErrorReceiverImpl(processingEnv); - List classes = new ArrayList(); + List classesToBeBound = new ArrayList(); // simply ignore all the interface definitions, // so that users won't have to manually exclude interfaces, which is silly. - filterClass(classes, roundEnv.getRootElements()); + filterClass(classesToBeBound, roundEnv.getRootElements()); - J2SJAXBModel model = JXC.createJavaCompiler().bind(classes, Collections.emptyMap(), null, processingEnv); + J2SJAXBModel model = JXC.createJavaCompiler().bind(classesToBeBound, Collections.emptyMap(), null, processingEnv); if (model == null) return false; // error @@ -133,11 +131,17 @@ public class SchemaGenerator extends AbstractProcessor { return false; } - private void filterClass(List classes, Collection elements) { + /** + * Filter classes (note that enum is kind of class) from elements tree + * @param result list of found classes + * @param elements tree to be filtered + */ + private void filterClass(List result, Collection elements) { for (Element element : elements) { - if (element.getKind().equals(ElementKind.CLASS) || element.getKind().equals(ElementKind.ENUM)) { - classes.add(new Reference((TypeElement) element, processingEnv)); - filterClass(classes, ElementFilter.typesIn(element.getEnclosedElements())); + final ElementKind kind = element.getKind(); + if (ElementKind.CLASS.equals(kind) || ElementKind.ENUM.equals(kind)) { + result.add(new Reference((TypeElement) element, processingEnv)); + filterClass(result, ElementFilter.typesIn(element.getEnclosedElements())); } } } diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/model/nav/ApNavigator.java b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/model/nav/ApNavigator.java index 803d32973a9..359bfc4cec0 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/model/nav/ApNavigator.java +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/model/nav/ApNavigator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,12 @@ import com.sun.source.util.TreePath; import com.sun.source.util.Trees; import com.sun.xml.internal.bind.v2.model.nav.Navigator; import com.sun.xml.internal.bind.v2.runtime.Location; - +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; @@ -52,12 +57,6 @@ import javax.lang.model.util.ElementFilter; import javax.lang.model.util.Elements; import javax.lang.model.util.SimpleTypeVisitor6; import javax.lang.model.util.Types; -import java.lang.annotation.Annotation; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; /** * {@link Navigator} implementation for annotation processing. @@ -241,7 +240,7 @@ public final class ApNavigator implements Navigator elements = env.getElementUtils().getAllMembers(clazz); - Collection constants = new HashSet(); + Collection constants = new ArrayList(); for (Element element : elements) { if (element.getKind().equals(ElementKind.ENUM_CONSTANT)) { constants.add((VariableElement) element); diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties index fd88f7f2d7f..de2930362f8 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -171,20 +171,20 @@ Driver.CompilingSchema = \ Driver.FailedToGenerateCode = \ Failed to produce code. -# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn +# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn Driver.FilePrologComment = \ - This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150126.1924 \n\ + This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150331.1824 \n\ See http://java.sun.com/xml/jaxb \n\ Any modifications to this file will be lost upon recompilation of the source schema. \n\ Generated on: {0} \n Driver.Version = \ - xjc 2.2.12-b150126.1924 + xjc 2.2.12-b150331.1824 Driver.FullVersion = \ - xjc full version "2.2.12-b150126.1924" + xjc full version "2.2.12-b150331.1824" -Driver.BuildID = 2.2.12-b150126.1924 +Driver.BuildID = 2.2.12-b150331.1824 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_de.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_de.properties index 97271e9de79..6c30fbf39cc 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_de.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_de.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -96,14 +96,14 @@ Driver.CompilingSchema = Ein Schema wird kompiliert ... Driver.FailedToGenerateCode = Code konnte nicht erzeugt werden. -# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn -Driver.FilePrologComment = Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150126.1924 generiert \nSiehe http://java.sun.com/xml/jaxb \n\u00c4nderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren. \nGeneriert: {0} \n +# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn +Driver.FilePrologComment = Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150331.1824 generiert \nSiehe http://java.sun.com/xml/jaxb \n\u00c4nderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren. \nGeneriert: {0} \n -Driver.Version = xjc 2.2.12-b150126.1924 +Driver.Version = xjc 2.2.12-b150331.1824 -Driver.FullVersion = xjc vollst\u00E4ndige Version "2.2.12-b150126.1924" +Driver.FullVersion = xjc vollst\u00E4ndige Version "2.2.12-b150331.1824" -Driver.BuildID = 2.2.12-b150126.1924 +Driver.BuildID = 2.2.12-b150331.1824 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_es.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_es.properties index eadb52fac88..0ad71a458d2 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_es.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_es.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -96,14 +96,14 @@ Driver.CompilingSchema = Compilando un esquema... Driver.FailedToGenerateCode = Fallo al producir c\u00f3digo. -# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn -Driver.FilePrologComment = Este archivo ha sido generado por la arquitectura JavaTM para la implantaci\u00f3n de la referencia de enlace (JAXB) XML v2.2.12-b150126.1924 \nVisite http://java.sun.com/xml/jaxb \nTodas las modificaciones realizadas en este archivo se perder\u00e1n si se vuelve a compilar el esquema de origen. \nGenerado el: {0} \n +# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn +Driver.FilePrologComment = Este archivo ha sido generado por la arquitectura JavaTM para la implantaci\u00f3n de la referencia de enlace (JAXB) XML v2.2.12-b150331.1824 \nVisite http://java.sun.com/xml/jaxb \nTodas las modificaciones realizadas en este archivo se perder\u00e1n si se vuelve a compilar el esquema de origen. \nGenerado el: {0} \n -Driver.Version = xjc 2.2.12-b150126.1924 +Driver.Version = xjc 2.2.12-b150331.1824 -Driver.FullVersion = versi\u00F3n completa de xjc "2.2.12-b150126.1924" +Driver.FullVersion = versi\u00F3n completa de xjc "2.2.12-b150331.1824" -Driver.BuildID = 2.2.12-b150126.1924 +Driver.BuildID = 2.2.12-b150331.1824 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties index dd19a1687df..dab13109b69 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -96,14 +96,14 @@ Driver.CompilingSchema = compilation d'un sch\u00e9ma... Driver.FailedToGenerateCode = Echec de la production du code. -# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn -Driver.FilePrologComment = Ce fichier a \u00e9t\u00e9 g\u00e9n\u00e9r\u00e9 par l''impl\u00e9mentation de r\u00e9f\u00e9rence JavaTM Architecture for XML Binding (JAXB), v2.2.12-b150126.1924 \nVoir http://java.sun.com/xml/jaxb \nToute modification apport\u00e9e \u00e0 ce fichier sera perdue lors de la recompilation du sch\u00e9ma source. \nG\u00e9n\u00e9r\u00e9 le : {0} \n +# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn +Driver.FilePrologComment = Ce fichier a \u00e9t\u00e9 g\u00e9n\u00e9r\u00e9 par l''impl\u00e9mentation de r\u00e9f\u00e9rence JavaTM Architecture for XML Binding (JAXB), v2.2.12-b150331.1824 \nVoir http://java.sun.com/xml/jaxb \nToute modification apport\u00e9e \u00e0 ce fichier sera perdue lors de la recompilation du sch\u00e9ma source. \nG\u00e9n\u00e9r\u00e9 le : {0} \n -Driver.Version = xjc 2.2.12-b150126.1924 +Driver.Version = xjc 2.2.12-b150331.1824 -Driver.FullVersion = version compl\u00E8te xjc "2.2.12-b150126.1924" +Driver.FullVersion = version compl\u00E8te xjc "2.2.12-b150331.1824" -Driver.BuildID = 2.2.12-b150126.1924 +Driver.BuildID = 2.2.12-b150331.1824 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_it.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_it.properties index f259cb3d291..32b7221ef35 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_it.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_it.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -96,14 +96,14 @@ Driver.CompilingSchema = compilazione di uno schema in corso... Driver.FailedToGenerateCode = Produzione del codice non riuscita. -# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn -Driver.FilePrologComment = Questo file \u00e8 stato generato dall''architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.12-b150126.1924 \nVedere http://java.sun.com/xml/jaxb \nQualsiasi modifica a questo file andr\u00e0 persa durante la ricompilazione dello schema di origine. \nGenerato il: {0} \n +# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn +Driver.FilePrologComment = Questo file \u00e8 stato generato dall''architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.12-b150331.1824 \nVedere http://java.sun.com/xml/jaxb \nQualsiasi modifica a questo file andr\u00e0 persa durante la ricompilazione dello schema di origine. \nGenerato il: {0} \n -Driver.Version = xjc 2.2.12-b150126.1924 +Driver.Version = xjc 2.2.12-b150331.1824 -Driver.FullVersion = versione completa xjc "2.2.12-b150126.1924" +Driver.FullVersion = versione completa xjc "2.2.12-b150331.1824" -Driver.BuildID = 2.2.12-b150126.1924 +Driver.BuildID = 2.2.12-b150331.1824 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties index 9674081427e..366edb4becc 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -96,14 +96,14 @@ Driver.CompilingSchema = \u30b9\u30ad\u30fc\u30de\u306e\u30b3\u30f3\u30d1\u30a4\ Driver.FailedToGenerateCode = \u30b3\u30fc\u30c9\u306e\u751f\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002 -# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn -Driver.FilePrologComment = \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3001JavaTM Architecture for XML Binding(JAXB) Reference Implementation\u3001v2.2.12-b150126.1924\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u307e\u3057\u305f \nhttp://java.sun.com/xml/jaxb\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044 \n\u30bd\u30fc\u30b9\u30fb\u30b9\u30ad\u30fc\u30de\u306e\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u306f\u5931\u308f\u308c\u307e\u3059\u3002 \n\u751f\u6210\u65e5: {0} \n +# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn +Driver.FilePrologComment = \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3001JavaTM Architecture for XML Binding(JAXB) Reference Implementation\u3001v2.2.12-b150331.1824\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u307e\u3057\u305f \nhttp://java.sun.com/xml/jaxb\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044 \n\u30bd\u30fc\u30b9\u30fb\u30b9\u30ad\u30fc\u30de\u306e\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u306f\u5931\u308f\u308c\u307e\u3059\u3002 \n\u751f\u6210\u65e5: {0} \n -Driver.Version = xjc 2.2.12-b150126.1924 +Driver.Version = xjc 2.2.12-b150331.1824 -Driver.FullVersion = xjc\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b150126.1924" +Driver.FullVersion = xjc\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b150331.1824" -Driver.BuildID = 2.2.12-b150126.1924 +Driver.BuildID = 2.2.12-b150331.1824 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties index 3715185d805..ffb08b6952e 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -96,14 +96,14 @@ Driver.CompilingSchema = \uc2a4\ud0a4\ub9c8\ub97c \ucef4\ud30c\uc77c\ud558\ub294 Driver.FailedToGenerateCode = \ucf54\ub4dc \uc0dd\uc131\uc744 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4. -# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn -Driver.FilePrologComment = \uc774 \ud30c\uc77c\uc740 JAXB(JavaTM Architecture for XML Binding) \ucc38\uc870 \uad6c\ud604 2.2.12-b150126.1924 \ubc84\uc804\uc744 \ud1b5\ud574 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \nhttp://java.sun.com/xml/jaxb\ub97c \ucc38\uc870\ud558\uc2ed\uc2dc\uc624. \n\uc774 \ud30c\uc77c\uc744 \uc218\uc815\ud558\uba74 \uc18c\uc2a4 \uc2a4\ud0a4\ub9c8\ub97c \uc7ac\ucef4\ud30c\uc77c\ud560 \ub54c \uc218\uc815 \uc0ac\ud56d\uc774 \uc190\uc2e4\ub429\ub2c8\ub2e4. \n\uc0dd\uc131 \ub0a0\uc9dc: {0} \n +# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn +Driver.FilePrologComment = \uc774 \ud30c\uc77c\uc740 JAXB(JavaTM Architecture for XML Binding) \ucc38\uc870 \uad6c\ud604 2.2.12-b150331.1824 \ubc84\uc804\uc744 \ud1b5\ud574 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \nhttp://java.sun.com/xml/jaxb\ub97c \ucc38\uc870\ud558\uc2ed\uc2dc\uc624. \n\uc774 \ud30c\uc77c\uc744 \uc218\uc815\ud558\uba74 \uc18c\uc2a4 \uc2a4\ud0a4\ub9c8\ub97c \uc7ac\ucef4\ud30c\uc77c\ud560 \ub54c \uc218\uc815 \uc0ac\ud56d\uc774 \uc190\uc2e4\ub429\ub2c8\ub2e4. \n\uc0dd\uc131 \ub0a0\uc9dc: {0} \n -Driver.Version = XJC 2.2.12-b150126.1924 +Driver.Version = XJC 2.2.12-b150331.1824 -Driver.FullVersion = XJC \uC815\uC2DD \uBC84\uC804 "2.2.12-b150126.1924" +Driver.FullVersion = XJC \uC815\uC2DD \uBC84\uC804 "2.2.12-b150331.1824" -Driver.BuildID = 2.2.12-b150126.1924 +Driver.BuildID = 2.2.12-b150331.1824 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties index 9f44278b4eb..5712ddafe10 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -96,14 +96,14 @@ Driver.CompilingSchema = compilando um esquema... Driver.FailedToGenerateCode = Falha ao produzir o c\u00f3digo. -# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn -Driver.FilePrologComment = Este arquivo foi gerado pela Arquitetura JavaTM para Implementa\u00e7\u00e3o de Refer\u00eancia (JAXB) de Bind XML, v2.2.12-b150126.1924 \nConsulte http://java.sun.com/xml/jaxb \nTodas as modifica\u00e7\u00f5es neste arquivo ser\u00e3o perdidas ap\u00f3s a recompila\u00e7\u00e3o do esquema de origem. \nGerado em: {0} \n +# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn +Driver.FilePrologComment = Este arquivo foi gerado pela Arquitetura JavaTM para Implementa\u00e7\u00e3o de Refer\u00eancia (JAXB) de Bind XML, v2.2.12-b150331.1824 \nConsulte http://java.sun.com/xml/jaxb \nTodas as modifica\u00e7\u00f5es neste arquivo ser\u00e3o perdidas ap\u00f3s a recompila\u00e7\u00e3o do esquema de origem. \nGerado em: {0} \n -Driver.Version = xjc 2.2.12-b150126.1924 +Driver.Version = xjc 2.2.12-b150331.1824 -Driver.FullVersion = vers\u00E3o completa de xjc "2.2.12-b150126.1924" +Driver.FullVersion = vers\u00E3o completa de xjc "2.2.12-b150331.1824" -Driver.BuildID = 2.2.12-b150126.1924 +Driver.BuildID = 2.2.12-b150331.1824 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties index 11276a8352a..b5f2d8a505a 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -96,14 +96,14 @@ Driver.CompilingSchema = \u6b63\u5728\u7f16\u8bd1\u6a21\u5f0f... Driver.FailedToGenerateCode = \u65e0\u6cd5\u751f\u6210\u4ee3\u7801\u3002 -# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn -Driver.FilePrologComment = \u6b64\u6587\u4ef6\u662f\u7531 JavaTM Architecture for XML Binding (JAXB) \u5f15\u7528\u5b9e\u73b0 v2.2.12-b150126.1924 \u751f\u6210\u7684\n\u8bf7\u8bbf\u95ee http://java.sun.com/xml/jaxb \n\u5728\u91cd\u65b0\u7f16\u8bd1\u6e90\u6a21\u5f0f\u65f6, \u5bf9\u6b64\u6587\u4ef6\u7684\u6240\u6709\u4fee\u6539\u90fd\u5c06\u4e22\u5931\u3002\n\u751f\u6210\u65f6\u95f4: {0} \n +# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn +Driver.FilePrologComment = \u6b64\u6587\u4ef6\u662f\u7531 JavaTM Architecture for XML Binding (JAXB) \u5f15\u7528\u5b9e\u73b0 v2.2.12-b150331.1824 \u751f\u6210\u7684\n\u8bf7\u8bbf\u95ee http://java.sun.com/xml/jaxb \n\u5728\u91cd\u65b0\u7f16\u8bd1\u6e90\u6a21\u5f0f\u65f6, \u5bf9\u6b64\u6587\u4ef6\u7684\u6240\u6709\u4fee\u6539\u90fd\u5c06\u4e22\u5931\u3002\n\u751f\u6210\u65f6\u95f4: {0} \n -Driver.Version = xjc 2.2.12-b150126.1924 +Driver.Version = xjc 2.2.12-b150331.1824 -Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924" +Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b150331.1824" -Driver.BuildID = 2.2.12-b150126.1924 +Driver.BuildID = 2.2.12-b150331.1824 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties index 27227f5b5c5..d722fc105cc 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -96,14 +96,14 @@ Driver.CompilingSchema = \u6b63\u5728\u7de8\u8b6f\u7db1\u8981... Driver.FailedToGenerateCode = \u7121\u6cd5\u7522\u751f\u7a0b\u5f0f\u78bc. -# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn -Driver.FilePrologComment = \u6b64\u6a94\u6848\u662f\u7531 JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150126.1924 \u6240\u7522\u751f \n\u8acb\u53c3\u95b1 http://java.sun.com/xml/jaxb \n\u4e00\u65e6\u91cd\u65b0\u7de8\u8b6f\u4f86\u6e90\u7db1\u8981, \u5c0d\u6b64\u6a94\u6848\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u5c07\u6703\u907a\u5931. \n\u7522\u751f\u6642\u9593: {0} \n +# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn +Driver.FilePrologComment = \u6b64\u6a94\u6848\u662f\u7531 JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150331.1824 \u6240\u7522\u751f \n\u8acb\u53c3\u95b1 http://java.sun.com/xml/jaxb \n\u4e00\u65e6\u91cd\u65b0\u7de8\u8b6f\u4f86\u6e90\u7db1\u8981, \u5c0d\u6b64\u6a94\u6848\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u5c07\u6703\u907a\u5931. \n\u7522\u751f\u6642\u9593: {0} \n -Driver.Version = xjc 2.2.12-b150126.1924 +Driver.Version = xjc 2.2.12-b150331.1824 -Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924" +Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b150331.1824" -Driver.BuildID = 2.2.12-b150126.1924 +Driver.BuildID = 2.2.12-b150331.1824 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/addon/code_injector/PluginImpl.java b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/addon/code_injector/PluginImpl.java index 626e97232f5..2d82bab915f 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/addon/code_injector/PluginImpl.java +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/addon/code_injector/PluginImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,13 +25,15 @@ package com.sun.tools.internal.xjc.addon.code_injector; +import java.util.Collection; import java.util.Collections; import java.util.List; +import com.sun.istack.internal.NotNull; import com.sun.tools.internal.xjc.Options; import com.sun.tools.internal.xjc.Plugin; import com.sun.tools.internal.xjc.model.CPluginCustomization; -import com.sun.tools.internal.xjc.outline.ClassOutline; +import com.sun.tools.internal.xjc.outline.CustomizableOutline; import com.sun.tools.internal.xjc.outline.Outline; import com.sun.tools.internal.xjc.util.DOMUtils; @@ -54,7 +56,7 @@ public class PluginImpl extends Plugin { } public boolean isCustomizationTagName(String nsUri, String localName) { - return nsUri.equals(Const.NS) && localName.equals("code"); + return Const.NS.equals(nsUri) && "code".equals(localName); } public String getUsage() { @@ -62,9 +64,15 @@ public class PluginImpl extends Plugin { } // meat of the processing - public boolean run(Outline model, Options opt, ErrorHandler errorHandler) { - for( ClassOutline co : model.getClasses() ) { - CPluginCustomization c = co.target.getCustomizations().find(Const.NS,"code"); + public boolean run(@NotNull Outline model, Options opt, ErrorHandler errorHandler) { + checkAndInject(model.getClasses()); + checkAndInject(model.getEnums()); + return true; + } + + private static void checkAndInject(Collection outlines) { + for (CustomizableOutline co : outlines) { + CPluginCustomization c = co.getTarget().getCustomizations().find(Const.NS, "code"); if(c==null) continue; // no customization --- nothing to inject here @@ -74,9 +82,7 @@ public class PluginImpl extends Plugin { String codeFragment = DOMUtils.getElementText(c.element); // inject the specified code fragment into the implementation class. - co.implClass.direct(codeFragment); + co.getImplClass().direct(codeFragment); } - - return true; } } diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ClassOutline.java b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ClassOutline.java index 1b6e1b664d9..dde38ae363c 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ClassOutline.java +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ClassOutline.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import java.util.List; import com.sun.codemodel.internal.JClass; import com.sun.codemodel.internal.JDefinedClass; import com.sun.tools.internal.xjc.model.CClassInfo; +import com.sun.tools.internal.xjc.model.CCustomizable; import com.sun.tools.internal.xjc.model.CPropertyInfo; import com.sun.istack.internal.NotNull; @@ -44,7 +45,7 @@ import com.sun.istack.internal.NotNull; * * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) */ -public abstract class ClassOutline { +public abstract class ClassOutline implements CustomizableOutline { /** * A {@link Outline} that encloses all the class outlines. @@ -122,4 +123,14 @@ public abstract class ClassOutline { if(s==null) return null; return parent().getClazz(s); } + + @Override + public JDefinedClass getImplClass() { + return implClass; + } + + @Override + public CCustomizable getTarget() { + return target; + } } diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/CustomizableOutline.java b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/CustomizableOutline.java new file mode 100644 index 00000000000..79c223d5c57 --- /dev/null +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/CustomizableOutline.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.internal.xjc.outline; + +import com.sun.codemodel.internal.JDefinedClass; +import com.sun.istack.internal.NotNull; +import com.sun.tools.internal.xjc.model.CCustomizable; + +/** + * This interface describes that outline class could be customized. + * It provides the bound info from {@link CCustomizable} target. And + * customization output - implementation class. + * + * @author yaroska + * @since 2.2.12 + */ +public interface CustomizableOutline { + + /** + * Provides bound information about customizable target. + * @return customizable target + */ + @NotNull CCustomizable getTarget(); + + /** + * Provides customization output. + * @return Implementation class + */ + @NotNull JDefinedClass getImplClass(); +} diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ElementOutline.java b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ElementOutline.java index 34609aa8fec..72d768719ba 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ElementOutline.java +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ElementOutline.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package com.sun.tools.internal.xjc.outline; import com.sun.codemodel.internal.JDefinedClass; +import com.sun.tools.internal.xjc.model.CCustomizable; import com.sun.tools.internal.xjc.model.CElementInfo; /** @@ -39,7 +40,7 @@ import com.sun.tools.internal.xjc.model.CElementInfo; * * @author Kohsuke Kawaguchi */ -public abstract class ElementOutline { +public abstract class ElementOutline implements CustomizableOutline { /** * A {@link Outline} that encloses all the class outlines. @@ -69,4 +70,14 @@ public abstract class ElementOutline { this.target = target; this.implClass = implClass; } + + @Override + public CCustomizable getTarget() { + return target; + } + + @Override + public JDefinedClass getImplClass() { + return implClass; + } } diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/EnumOutline.java b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/EnumOutline.java index 9ac6b7a97d3..ae48a7212e2 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/EnumOutline.java +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/EnumOutline.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; import com.sun.codemodel.internal.JDefinedClass; +import com.sun.tools.internal.xjc.model.CCustomizable; import com.sun.tools.internal.xjc.model.CEnumLeafInfo; import com.sun.istack.internal.NotNull; @@ -40,7 +41,7 @@ import com.sun.istack.internal.NotNull; * * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) */ -public abstract class EnumOutline { +public abstract class EnumOutline implements CustomizableOutline { /** * This {@link EnumOutline} holds information about this {@link CEnumLeafInfo}. @@ -74,4 +75,14 @@ public abstract class EnumOutline { this.target = target; this.clazz = clazz; } + + @Override + public JDefinedClass getImplClass() { + return clazz; + } + + @Override + public CCustomizable getTarget() { + return target; + } } diff --git a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties index b18bbc710b0..8cc250fb181 100644 --- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties +++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ # questions. # -build-id=2.2.11-b150127.1410 -build-version=JAX-WS RI 2.2.11-b150127.1410 +build-id=2.2.11-b150402.1412 +build-version=JAX-WS RI 2.2.11-b150402.1412 major-version=2.2.11 -svn-revision=28121d09ed8ac02b76788709ccb4cdb66e03bbfa +svn-revision=f923291dedcf386c5f408263984a99d7cedf0012 diff --git a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/document/soap/SOAPConstants.java b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/document/soap/SOAPConstants.java index aabf2579a43..ee1582ed285 100644 --- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/document/soap/SOAPConstants.java +++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/document/soap/SOAPConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package com.sun.tools.internal.ws.wsdl.document.soap; +import com.sun.xml.internal.ws.encoding.soap.streaming.SOAPNamespaceConstants; + import javax.xml.namespace.QName; /** @@ -35,9 +37,7 @@ import javax.xml.namespace.QName; public interface SOAPConstants { // namespace URIs - public static final String URI_ENVELOPE = - "http://schemas.xmlsoap.org/soap/envelope/"; - + public static final String URI_ENVELOPE = SOAPNamespaceConstants.ENVELOPE; public static final String NS_WSDL_SOAP = "http://schemas.xmlsoap.org/wsdl/soap/"; public static final String NS_SOAP_ENCODING = "http://schemas.xmlsoap.org/soap/encoding/"; diff --git a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java index c153cce7f68..d216e6f3608 100644 --- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java +++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,7 +78,7 @@ public class Internalizer { private static final ContextClassloaderLocal xpf = new ContextClassloaderLocal() { @Override protected XPathFactory initialValue() throws Exception { - return XPathFactory.newInstance(); + return XmlUtil.newXPathFactory(true); } }; /** diff --git a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java index 0f12222220c..6801dd9f474 100644 --- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java +++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,10 @@ package com.sun.tools.internal.ws.wsdl.parser; +import com.sun.tools.internal.ws.util.xml.XmlUtil; import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible; import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension; import com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext; -import com.sun.tools.internal.ws.util.xml.XmlUtil; import com.sun.tools.internal.ws.wsdl.document.*; import com.sun.tools.internal.ws.wsdl.document.jaxws.CustomName; import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBinding; @@ -57,7 +57,7 @@ public class JAXWSBindingExtensionHandler extends AbstractExtensionHandler { private static final ContextClassloaderLocal xpf = new ContextClassloaderLocal() { @Override protected XPathFactory initialValue() throws Exception { - return XPathFactory.newInstance(); + return XmlUtil.newXPathFactory(false); } }; diff --git a/jdk/.hgtags b/jdk/.hgtags index 87758c23e6c..0b955733484 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -300,3 +300,5 @@ a0dad230aeb3b0d5cfd5b0715029e48d50573f8c jdk9-b51 d49e247dade61f29f771f09b2105857492241156 jdk9-b55 7969f7b6465e47ce4afa77670ca600b04c1d746c jdk9-b56 c76339e86ea7da5d9ac7856f3fae9ef73eef04a2 jdk9-b57 +36fc65e80d811ee43aedfc69284224b86a403662 jdk9-b58 +48ee960f29df93a9b2a895621321358a86909086 jdk9-b59 diff --git a/jdk/make/launcher/Launcher-jdk.pack200.gmk b/jdk/make/launcher/Launcher-jdk.pack200.gmk index affdbdb26eb..dbc135bc76d 100644 --- a/jdk/make/launcher/Launcher-jdk.pack200.gmk +++ b/jdk/make/launcher/Launcher-jdk.pack200.gmk @@ -61,13 +61,19 @@ ifeq ($(OPENJDK_TARGET_OS), solaris) UNPACKEXE_LANG := C++ 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) + # The linker on older SuSE distros (e.g. on SLES 10) complains with: # "Invalid version tag `SUNWprivate_1.1'. Only anonymous version tag is allowed in executable." # if feeded with a version script which contains named tags. ifeq ($(USING_BROKEN_SUSE_LD), yes) - UNPACK_MAPFILE = $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers-unpack200.anonymous + UNPACK_MAPFILE := $(UNPACK_MAPFILE_DIR)/mapfile-vers-unpack200.anonymous +else ifneq ($(wildcard $(UNPACK_MAPFILE_PLATFORM_FILE)), ) + UNPACK_MAPFILE := $(UNPACK_MAPFILE_PLATFORM_FILE) else - UNPACK_MAPFILE = $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers-unpack200 + UNPACK_MAPFILE := $(UNPACK_MAPFILE_DIR)/mapfile-vers-unpack200 endif $(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE, \ diff --git a/jdk/make/lib/Lib-java.management.gmk b/jdk/make/lib/Lib-java.management.gmk index 9f4435d7707..e0e6f1d9476 100644 --- a/jdk/make/lib/Lib-java.management.gmk +++ b/jdk/make/lib/Lib-java.management.gmk @@ -38,6 +38,11 @@ BUILD_LIBMANAGEMENT_CFLAGS := -I$(JDK_TOPDIR)/src/java.management/share/native/i $(LIBJAVA_HEADER_FLAGS) \ # +# In (at least) VS2013 and later, -DPSAPI_VERSION=1 is needed to generate +# a binary that is compatible with windows versions older than 7/2008R2. +# See MSDN documentation for GetProcessMemoryInfo for more information. +BUILD_LIBMANAGEMENT_CFLAGS += -DPSAPI_VERSION=1 + BUILD_LIBMANAGEMENT_EXCLUDES := ifneq ($(OPENJDK_TARGET_OS), solaris) diff --git a/jdk/make/mapfiles/launchers/mapfile-x86_64 b/jdk/make/mapfiles/launchers/mapfile-x86_64 index 61c2d1cc3f2..5700d67f2a0 100644 --- a/jdk/make/mapfiles/launchers/mapfile-x86_64 +++ b/jdk/make/mapfiles/launchers/mapfile-x86_64 @@ -34,6 +34,14 @@ SUNWprivate_1.1 { _environ; __environ_lock; + # These are needed by the c runtime in SS12u4 + ___Argv; + __xargv; + __xargc; + _start; + __longdouble_used; + _lib_version; + local: *; }; diff --git a/langtools/make/Makefile b/jdk/make/mapfiles/libunpack/mapfile-vers-unpack200-solaris-sparc similarity index 54% rename from langtools/make/Makefile rename to jdk/make/mapfiles/libunpack/mapfile-vers-unpack200-solaris-sparc index ce3a3333405..63f2a41a478 100644 --- a/langtools/make/Makefile +++ b/jdk/make/mapfiles/libunpack/mapfile-vers-unpack200-solaris-sparc @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -23,27 +23,19 @@ # questions. # -# Locate this Makefile -ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))), ) - makefile_path := $(CURDIR)/$(lastword $(MAKEFILE_LIST)) -else - makefile_path := $(lastword $(MAKEFILE_LIST)) -endif -repo_dir := $(patsubst %/make/Makefile, %, $(makefile_path)) +# Define library interface. -# What is the name of this subsystem (langtools, corba, etc)? -subsystem_name := $(notdir $(repo_dir)) +SUNWprivate_1.1 { + global: + # These are needed by the c runtime in SS12u4 + _environ; + __environ_lock; + ___Argv; + __xargv; + __xargc; + _start; + _lib_version; -# Try to locate top-level makefile -top_level_makefile := $(repo_dir)/../Makefile -ifneq ($(wildcard $(top_level_makefile)), ) - $(info Will run $(subsystem_name) target on top-level Makefile) - $(info WARNING: This is a non-recommended way of building!) - $(info ===================================================) -else - $(info Cannot locate top-level Makefile. Is this repo not checked out as part of a complete forest?) - $(error Build from top-level Makefile instead) -endif - -all: - @$(MAKE) -f $(top_level_makefile) $(subsystem_name) + local: + *; +}; diff --git a/nashorn/make/Makefile b/jdk/make/mapfiles/libunpack/mapfile-vers-unpack200-solaris-x86 similarity index 53% rename from nashorn/make/Makefile rename to jdk/make/mapfiles/libunpack/mapfile-vers-unpack200-solaris-x86 index 4570070f45b..60220b18ad3 100644 --- a/nashorn/make/Makefile +++ b/jdk/make/mapfiles/libunpack/mapfile-vers-unpack200-solaris-x86 @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -23,27 +23,20 @@ # questions. # -# Locate this Makefile -ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))), ) - makefile_path := $(CURDIR)/$(lastword $(MAKEFILE_LIST)) -else - makefile_path := $(lastword $(MAKEFILE_LIST)) -endif -repo_dir := $(patsubst %/make/Makefile, %, $(makefile_path)) +# Define library interface. -# What is the name of this subsystem (langtools, corba, etc)? -subsystem_name := $(notdir $(repo_dir)) +SUNWprivate_1.1 { + global: + # These are needed by the c runtime in SS12u4 + _environ; + __environ_lock; + ___Argv; + __xargv; + __xargc; + _start; + __longdouble_used; + _lib_version; -# Try to locate top-level makefile -top_level_makefile := $(repo_dir)/../Makefile -ifneq ($(wildcard $(top_level_makefile)), ) - $(info Will run $(subsystem_name) target on top-level Makefile) - $(info WARNING: This is a non-recommended way of building!) - $(info ===================================================) -else - $(info Cannot locate top-level Makefile. Is this repo not checked out as part of a complete forest?) - $(error Build from top-level Makefile instead) -endif - -all: - @$(MAKE) -f $(top_level_makefile) $(subsystem_name) + local: + *; +}; diff --git a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java index a8f70915012..90c6108c244 100644 --- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java +++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java @@ -70,6 +70,7 @@ import static java.time.temporal.ChronoField.NANO_OF_SECOND; import static java.time.temporal.ChronoField.OFFSET_SECONDS; import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.ERA; import java.lang.ref.SoftReference; import java.math.BigDecimal; @@ -84,6 +85,7 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.chrono.ChronoLocalDate; import java.time.chrono.Chronology; +import java.time.chrono.Era; import java.time.chrono.IsoChronology; import java.time.format.DateTimeTextProvider.LocaleStore; import java.time.temporal.ChronoField; @@ -3131,6 +3133,16 @@ public final class DateTimeFormatterBuilder { return context.setParsedField(field, entry.getValue(), position, position + itText.length()); } } + if (field == ERA && !context.isStrict()) { + // parse the possible era name from era.toString() + List eras = chrono.eras(); + for (Era era : eras) { + String name = era.toString(); + if (context.subSequenceEquals(name, 0, parseText, position, name.length())) { + return context.setParsedField(field, era.getValue(), position, position + name.length()); + } + } + } if (context.isStrict()) { return ~position; } diff --git a/jdk/src/java.base/share/classes/java/util/BitSet.java b/jdk/src/java.base/share/classes/java/util/BitSet.java index 901a5a75800..f444072a185 100644 --- a/jdk/src/java.base/share/classes/java/util/BitSet.java +++ b/jdk/src/java.base/share/classes/java/util/BitSet.java @@ -1229,7 +1229,7 @@ public class BitSet implements Cloneable, java.io.Serializable { public int nextInt() { if (next != -1) { int ret = next; - next = nextSetBit(next+1); + next = (next == Integer.MAX_VALUE) ? -1 : nextSetBit(next+1); return ret; } else { throw new NoSuchElementException(); diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java b/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java index b61e334c131..aa93bcb368d 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java @@ -481,6 +481,8 @@ class ZipEntry implements ZipConstants, Cloneable { } break; case EXTID_NTFS: + if (sz < 32) // reserved 4 bytes + tag 2 bytes + size 2 bytes + break; // m[a|c]time 24 bytes int pos = off + 4; // reserved 4 bytes if (get16(extra, pos) != 0x0001 || get16(extra, pos + 2) != 24) break; diff --git a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java index 691ce46078f..9c8bc81393a 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java +++ b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java @@ -25,7 +25,11 @@ package javax.crypto; -import java.io.*; +import java.io.InputStream; +import java.io.FilterInputStream; +import java.io.IOException; +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; /** * A CipherInputStream is composed of an InputStream and a Cipher so @@ -88,8 +92,6 @@ public class CipherInputStream extends FilterInputStream { private int ofinish = 0; // stream status private boolean closed = false; - // The stream has been read from. False if the stream has never been read. - private boolean read = false; /** * private convenience function. @@ -101,11 +103,15 @@ public class CipherInputStream extends FilterInputStream { * return (ofinish-ostart) (we have this many bytes for you) * return 0 (no data now, but could have more later) * return -1 (absolutely no more data) + * + * Note: Exceptions are only thrown after the stream is completely read. + * For AEAD ciphers a read() of any length will internally cause the + * whole stream to be read fully and verify the authentication tag before + * returning decrypted data or exceptions. */ private int getMoreData() throws IOException { if (done) return -1; int readin = input.read(ibuffer); - read = true; if (readin == -1) { done = true; try { @@ -301,17 +307,16 @@ public class CipherInputStream extends FilterInputStream { closed = true; input.close(); - try { - // throw away the unprocessed data - if (!done) { + + // Throw away the unprocessed data and throw no crypto exceptions. + // AEAD ciphers are fully readed before closing. Any authentication + // exceptions would occur while reading. + if (!done) { + try { cipher.doFinal(); } - } - catch (BadPaddingException | IllegalBlockSizeException ex) { - /* If no data has been read from the stream to be en/decrypted, - we supress any exceptions, and close quietly. */ - if (read) { - throw new IOException(ex); + catch (BadPaddingException | IllegalBlockSizeException ex) { + // Catch exceptions as the rest of the stream is unused. } } ostart = 0; diff --git a/jdk/src/java.base/share/classes/javax/security/auth/Policy.java b/jdk/src/java.base/share/classes/javax/security/auth/Policy.java index 2463102b266..6ed9a4e3f2c 100644 --- a/jdk/src/java.base/share/classes/javax/security/auth/Policy.java +++ b/jdk/src/java.base/share/classes/javax/security/auth/Policy.java @@ -322,7 +322,7 @@ public abstract class Policy { * in conjunction with the provided * {@code CodeSource}, determines the Permissions * returned by this method. This parameter - * may be {@code null}.

      + * may be {@code null}. * * @param cs the code specified by its {@code CodeSource} * that determines, in conjunction with the provided diff --git a/jdk/src/java.base/share/classes/javax/security/auth/login/LoginContext.java b/jdk/src/java.base/share/classes/javax/security/auth/login/LoginContext.java index d86a91443ff..e266c4706f0 100644 --- a/jdk/src/java.base/share/classes/javax/security/auth/login/LoginContext.java +++ b/jdk/src/java.base/share/classes/javax/security/auth/login/LoginContext.java @@ -25,18 +25,18 @@ package javax.security.auth.login; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; -import java.util.LinkedList; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Map; import java.util.HashMap; import java.text.MessageFormat; import javax.security.auth.Subject; import javax.security.auth.AuthPermission; import javax.security.auth.callback.*; -import java.security.AccessController; +import javax.security.auth.spi.LoginModule; import java.security.AccessControlContext; +import java.util.ServiceLoader; + import sun.security.util.PendingException; import sun.security.util.ResourcesMgr; @@ -192,7 +192,6 @@ import sun.security.util.ResourcesMgr; */ public class LoginContext { - private static final String INIT_METHOD = "initialize"; private static final String LOGIN_METHOD = "login"; private static final String COMMIT_METHOD = "commit"; private static final String ABORT_METHOD = "abort"; @@ -210,7 +209,6 @@ public class LoginContext { private AccessControlContext creatorAcc = null; // customized config only private ModuleInfo[] moduleStack; private ClassLoader contextClassLoader = null; - private static final Class[] PARAMS = { }; // state saved in the event a user-specified asynchronous exception // was specified and thrown @@ -678,64 +676,64 @@ public class LoginContext { for (int i = moduleIndex; i < moduleStack.length; i++, moduleIndex++) { try { - int mIndex = 0; - Method[] methods = null; + if (moduleStack[i].module == null) { - if (moduleStack[i].module != null) { - methods = moduleStack[i].module.getClass().getMethods(); - } else { - - // instantiate the LoginModule + // locate and instantiate the LoginModule // - // Allow any object to be a LoginModule as long as it - // conforms to the interface. - Class c = Class.forName( - moduleStack[i].entry.getLoginModuleName(), - true, - contextClassLoader); - - Constructor constructor = c.getConstructor(PARAMS); - Object[] args = { }; - moduleStack[i].module = constructor.newInstance(args); - - // call the LoginModule's initialize method - methods = moduleStack[i].module.getClass().getMethods(); - for (mIndex = 0; mIndex < methods.length; mIndex++) { - if (methods[mIndex].getName().equals(INIT_METHOD)) { + String name = moduleStack[i].entry.getLoginModuleName(); + ServiceLoader sc = AccessController.doPrivileged( + (PrivilegedAction>) + () -> ServiceLoader.load( + LoginModule.class, contextClassLoader)); + for (LoginModule m: sc) { + if (m.getClass().getName().equals(name)) { + moduleStack[i].module = m; + if (debug != null) { + debug.println(name + " loaded as a service"); + } break; } } - Object[] initArgs = {subject, - callbackHandler, - state, - moduleStack[i].entry.getOptions() }; + if (moduleStack[i].module == null) { + try { + moduleStack[i].module = (LoginModule) Class.forName( + name, false, contextClassLoader).newInstance(); + if (debug != null) { + debug.println(name + " loaded via reflection"); + } + } catch (ClassNotFoundException e) { + throw new LoginException("No LoginModule found for " + + name); + } + } + // invoke the LoginModule initialize method - // - // Throws ArrayIndexOutOfBoundsException if no such - // method defined. May improve to use LoginException in - // the future. - methods[mIndex].invoke(moduleStack[i].module, initArgs); + moduleStack[i].module.initialize(subject, + callbackHandler, + state, + moduleStack[i].entry.getOptions()); } // find the requested method in the LoginModule - for (mIndex = 0; mIndex < methods.length; mIndex++) { - if (methods[mIndex].getName().equals(methodName)) { + boolean status; + switch (methodName) { + case LOGIN_METHOD: + status = moduleStack[i].module.login(); break; - } + case COMMIT_METHOD: + status = moduleStack[i].module.commit(); + break; + case LOGOUT_METHOD: + status = moduleStack[i].module.logout(); + break; + case ABORT_METHOD: + status = moduleStack[i].module.abort(); + break; + default: + throw new AssertionError("Unknown method " + methodName); } - // set up the arguments to be passed to the LoginModule method - Object[] args = { }; - - // invoke the LoginModule method - // - // Throws ArrayIndexOutOfBoundsException if no such - // method defined. May improve to use LoginException in - // the future. - boolean status = ((Boolean)methods[mIndex].invoke - (moduleStack[i].module, args)).booleanValue(); - if (status == true) { // if SUFFICIENT, return if no prior REQUIRED errors @@ -760,31 +758,12 @@ public class LoginContext { if (debug != null) debug.println(methodName + " ignored"); } - - } catch (NoSuchMethodException nsme) { - MessageFormat form = new MessageFormat(ResourcesMgr.getString - ("unable.to.instantiate.LoginModule.module.because.it.does.not.provide.a.no.argument.constructor")); - Object[] source = {moduleStack[i].entry.getLoginModuleName()}; - throwException(null, new LoginException(form.format(source))); - } catch (InstantiationException ie) { - throwException(null, new LoginException(ResourcesMgr.getString - ("unable.to.instantiate.LoginModule.") + - ie.getMessage())); - } catch (ClassNotFoundException cnfe) { - throwException(null, new LoginException(ResourcesMgr.getString - ("unable.to.find.LoginModule.class.") + - cnfe.getMessage())); - } catch (IllegalAccessException iae) { - throwException(null, new LoginException(ResourcesMgr.getString - ("unable.to.access.LoginModule.") + - iae.getMessage())); - } catch (InvocationTargetException ite) { + } catch (Exception ite) { // failure cases - LoginException le; - if (ite.getCause() instanceof PendingException && + if (ite instanceof PendingException && methodName.equals(LOGIN_METHOD)) { // XXX @@ -808,13 +787,13 @@ public class LoginContext { // the only time that is not true is in this case - // do not call throwException here. - throw (PendingException)ite.getCause(); + throw (PendingException)ite; - } else if (ite.getCause() instanceof LoginException) { + } else if (ite instanceof LoginException) { - le = (LoginException)ite.getCause(); + le = (LoginException)ite; - } else if (ite.getCause() instanceof SecurityException) { + } else if (ite instanceof SecurityException) { // do not want privacy leak // (e.g., sensitive file path in exception msg) @@ -826,14 +805,14 @@ public class LoginContext { ("original security exception with detail msg " + "replaced by new exception with empty detail msg"); debug.println("original security exception: " + - ite.getCause().toString()); + ite.toString()); } } else { // capture an unexpected LoginModule exception java.io.StringWriter sw = new java.io.StringWriter(); - ite.getCause().printStackTrace - (new java.io.PrintWriter(sw)); + ite.printStackTrace + (new java.io.PrintWriter(sw)); sw.flush(); le = new LoginException(sw.toString()); } @@ -938,9 +917,9 @@ public class LoginContext { */ private static class ModuleInfo { AppConfigurationEntry entry; - Object module; + LoginModule module; - ModuleInfo(AppConfigurationEntry newEntry, Object newModule) { + ModuleInfo(AppConfigurationEntry newEntry, LoginModule newModule) { this.entry = newEntry; this.module = newModule; } diff --git a/jdk/src/java.base/share/classes/javax/security/auth/spi/LoginModule.java b/jdk/src/java.base/share/classes/javax/security/auth/spi/LoginModule.java index 871bbbc60d3..3206b5a5d27 100644 --- a/jdk/src/java.base/share/classes/javax/security/auth/spi/LoginModule.java +++ b/jdk/src/java.base/share/classes/javax/security/auth/spi/LoginModule.java @@ -32,10 +32,9 @@ import javax.security.auth.login.*; import java.util.Map; /** - *

      {@code LoginModule} describes the interface - * implemented by authentication technology providers. LoginModules - * are plugged in under applications to provide a particular type of - * authentication. + *

      Service-provider interface for authentication technology providers. + * LoginModules are plugged in under applications to provide a particular + * type of authentication. * *

      While applications write to the {@code LoginContext} API, * authentication technology providers implement the diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java index 8c55da5fa98..63336da2e78 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -104,7 +104,7 @@ import java.io.OutputStream; * operations on the GSSContext object are presented, * including: object instantiation, setting of desired flags, context * establishment, query of actual context flags, per-message operations on - * application data, and finally context deletion.

      + * application data, and finally context deletion. * *

        *    // Create a context using default credentials
      @@ -209,7 +209,7 @@ public interface GSSContext {
            * Some mechanism providers might require that the caller be granted
            * permission to initiate a security context. A failed permission check
            * might cause a {@link java.lang.SecurityException SecurityException}
      -     * to be thrown from this method.

      + * to be thrown from this method. * * @return a byte[] containing the token to be sent to the * peer. null indicates that no token is generated. @@ -276,7 +276,7 @@ public interface GSSContext { * to be thrown from this method.

      * * The following example code demonstrates how this method might be - * used:

      + * used: *

            *     InputStream is ...
            *     OutputStream os ...
      @@ -346,7 +346,7 @@ public interface GSSContext {
            * to be thrown from this method.

      * * The following example code demonstrates how this method might be - * used:

      + * used: *

            *     byte[] inToken;
            *     byte[] outToken;
      @@ -423,7 +423,7 @@ public interface GSSContext {
            * to be thrown from this method.

      * * The following example code demonstrates how this method might be - * used:

      + * used: *

            *     InputStream is ...
            *     OutputStream os ...
      @@ -510,7 +510,7 @@ public interface GSSContext {
            * GSS-API implementations are recommended but not required to detect
            * invalid QOP values when getWrapSizeLimit is called.
            * This routine guarantees only a maximum message size, not the
      -     * availability of specific QOP values for message protection.

      + * availability of specific QOP values for message protection. * * @param qop the level of protection wrap will be asked to provide. * @param confReq true if wrap will be asked to provide @@ -595,7 +595,7 @@ public interface GSSContext { * * Since some application-level protocols may wish to use tokens * emitted by wrap to provide "secure framing", implementations should - * support the wrapping of zero-length messages.

      + * support the wrapping of zero-length messages. * * @param inStream an InputStream containing the application data to be * protected. All of the data that is available in @@ -630,7 +630,7 @@ public interface GSSContext { * * Since some application-level protocols may wish to use tokens * emitted by wrap to provide "secure framing", implementations should - * support the wrapping and unwrapping of zero-length messages.

      + * support the wrapping and unwrapping of zero-length messages. * * @param inBuf a byte array containing the wrap token received from * peer. @@ -679,7 +679,7 @@ public interface GSSContext { * * Other than the possible blocking behavior described above, this * method is equivalent to the byte array based {@link #unwrap(byte[], - * int, int, MessageProp) unwrap} method.

      + * int, int, MessageProp) unwrap} method. * * @param inStream an InputStream that contains the wrap token generated * by the peer. @@ -827,7 +827,7 @@ public interface GSSContext { * * Other than the possible blocking behavior described above, this * method is equivalent to the byte array based {@link #verifyMIC(byte[], - * int, int, byte[], int, int, MessageProp) verifyMIC} method.

      + * int, int, byte[], int, int, MessageProp) verifyMIC} method. * * @param tokStream an InputStream containing the token generated by the * peer's getMIC method. @@ -913,7 +913,7 @@ public interface GSSContext { * might require mutual authentication even if the application * doesn't. Therefore, the application should check to see if the * request was honored with the {@link #getMutualAuthState() - * getMutualAuthState} method.

      + * getMutualAuthState} method. * * @param state a boolean value indicating whether mutual * authentication should be used or not. @@ -943,7 +943,7 @@ public interface GSSContext { * MessageProp#isOldToken() MessageProp.isOldToken} methods will return * valid results for the MessageProp object that is passed * in to the unwrap method or the verifyMIC - * method.

      + * method. * * @param state a boolean value indicating whether replay detection * should be enabled over the established context or not. @@ -975,7 +975,7 @@ public interface GSSContext { * {@link MessageProp#isGapToken() MessageProp.isGapToken} methods will return * valid results for the MessageProp object that is passed * in to the unwrap method or the verifyMIC - * method.

      + * method. * * @param state a boolean value indicating whether sequence checking * should be enabled over the established context or not. @@ -1001,7 +1001,7 @@ public interface GSSContext { * delegation must not be used, then the mechanism will honor the * request and delegation will not occur. This is an exception * to the general rule that a mechanism may enable a service even if it - * is not requested.

      + * is not requested. * * @param state a boolean value indicating whether the credentials * should be delegated or not. @@ -1021,7 +1021,7 @@ public interface GSSContext { * * Not all mechanisms support anonymity for the initiator. Therefore, the * application should check to see if the request was honored with the - * {@link #getAnonymityState() getAnonymityState} method.

      + * {@link #getAnonymityState() getAnonymityState} method. * * @param state a boolean value indicating if the initiator should * be authenticated to the acceptor as an anonymous principal. @@ -1048,7 +1048,7 @@ public interface GSSContext { * object that is passed in to the wrap method.

      * * Enabling confidentiality will also automatically enable - * integrity.

      + * integrity. * * @param state a boolean value indicating whether confidentiality * should be enabled or not. @@ -1075,7 +1075,7 @@ public interface GSSContext { * the {@link #getIntegState() getIntegState} method.

      * * Disabling integrity will also automatically disable - * confidentiality.

      + * confidentiality. * * @param state a boolean value indicating whether integrity * should be enabled or not. @@ -1095,7 +1095,7 @@ public interface GSSContext { * * The actual lifetime of the context will depend on the capabilities of * the underlying mechanism and the application should call the {@link - * #getLifetime() getLifetime} method to determine this.

      + * #getLifetime() getLifetime} method to determine this. * * @param lifetime the desired context lifetime in seconds. Use * INDEFINITE_LIFETIME to request an indefinite lifetime @@ -1133,7 +1133,7 @@ public interface GSSContext { * initiator requests that delegation not be allowed the {@link * #requestCredDeleg(boolean) requestCredDeleg} method will honor that * request and this method will return false on the - * initiator's side from that point onwards.

      + * initiator's side from that point onwards. * * @return true if delegation is enabled, false otherwise. * @see #requestCredDeleg(boolean) @@ -1147,7 +1147,7 @@ public interface GSSContext { * called only after context establishment is complete. An initiator * that requests mutual authentication can call this method after * context completion and dispose the context if its request was not - * honored.

      + * honored. * * @return true if mutual authentication is enabled, false otherwise. * @see #requestMutualAuth(boolean) @@ -1161,7 +1161,7 @@ public interface GSSContext { * definitive answer this method must be called only after context * establishment is complete. An initiator that requests replay * detection can call this method after context completion and - * dispose the context if its request was not honored.

      + * dispose the context if its request was not honored. * * @return true if replay detection is enabled, false otherwise. * @see #requestReplayDet(boolean) @@ -1175,7 +1175,7 @@ public interface GSSContext { * definitive answer this method must be called only after context * establishment is complete. An initiator that requests sequence * checking can call this method after context completion and - * dispose the context if its request was not honored.

      + * dispose the context if its request was not honored. * * @return true if sequence checking is enabled, false otherwise. * @see #requestSequenceDet(boolean) @@ -1195,7 +1195,7 @@ public interface GSSContext { * should be sent to the peer or the context aborted. On the * acceptor side, a call to this method determines if any of the tokens * processed by acceptSecContext thus far have divulged - * the identity of the initiator.

      + * the identity of the initiator. * * @return true if the context initiator is still anonymous, false * otherwise. @@ -1235,7 +1235,7 @@ public interface GSSContext { * #isProtReady() isProtReady} or {@link #isEstablished() * isEstablished} return true. If this method returns * true, so will {@link #getIntegState() - * getIntegState}

      + * getIntegState} * * @return true if confidentiality services are available, false * otherwise. @@ -1250,7 +1250,7 @@ public interface GSSContext { * #isProtReady() isProtReady} or {@link #isEstablished() * isEstablished} return true. This method will always * return true if {@link #getConfState() getConfState} - * returns true.

      + * returns true. * * @return true if integrity services are available, false otherwise. * @see #requestInteg(boolean) @@ -1262,7 +1262,7 @@ public interface GSSContext { * context is. It can be called by both the context initiator and the * context acceptor, but for a definitive answer it should be called * only after {@link #isEstablished() isEstablished} returns - * true.

      + * true. * * @return the remaining lifetime in seconds * @see #requestLifetime(int) diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSCredential.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSCredential.java index fbe379ef2e6..115ee74a41b 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSCredential.java +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSCredential.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,7 @@ package org.ietf.jgss; * * This example code demonstrates the creation of a GSSCredential * implementation for a specific entity, querying of its fields, and its - * release when it is no longer needed:

      + * release when it is no longer needed: *

        *    GSSManager manager = GSSManager.getInstance();
        *
      diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSException.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSException.java
      index cfde0e58fe2..ed7e3ad6332 100644
      --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSException.java
      +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSException.java
      @@ -1,5 +1,5 @@
       /*
      - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
      + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
        * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
        *
        * This code is free software; you can redistribute it and/or modify it
      @@ -34,7 +34,7 @@ package org.ietf.jgss;
        * mechanism implementation is responsible for setting appropriate minor
        * status codes when throwing this exception.  Aside from delivering the
        * numeric error codes to the caller, this class performs the mapping from
      - * their numeric values to textual representations. 

      + * their numeric values to textual representations. * * @author Mayank Upadhyay * @since 1.4 diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSManager.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSManager.java index 3bf99e409ab..f9ae3efafee 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSManager.java +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,7 @@ import java.security.Provider; * of this and recover cleanly by catching the exception.

      * * It is envisioned that there will be three most common ways in which - * providers will be used:

      + * providers will be used: *

        *
      1. The application does not care about what provider is used (the * default case). @@ -87,7 +87,7 @@ import java.security.Provider; * the addProviderAtFront method on a GSSManager that has * already created an object.

        * - * Here is some sample code showing how the GSSManager might be used:

        + * Here is some sample code showing how the GSSManager might be used: *

          *     GSSManager manager = GSSManager.getInstance();
          *
        @@ -116,7 +116,7 @@ import java.security.Provider;
          *                                                GSSContext.DEFAULT_LIFETIME);
          * 

        * - * The server side might use the following variation of this source:

        + * The server side might use the following variation of this source: * *

          *     // Acquire credentials for the server
        @@ -387,7 +387,7 @@ public abstract class GSSManager {
              * Non-default values for lifetime cannot always be honored by the
              * underlying mechanisms, thus applications should be prepared to call
              * {@link GSSCredential#getRemainingLifetime() getRemainingLifetime}
        -     * on the returned credential.

        + * on the returned credential. * * @param name the name of the principal for whom this credential is to be * acquired. Use null to specify the default principal. @@ -442,7 +442,7 @@ public abstract class GSSManager { * Non-default values for lifetime cannot always be honored by the * underlying mechanisms, thus applications should be prepared to call * {@link GSSCredential#getRemainingLifetime() getRemainingLifetime} - * on the returned credential.

        + * on the returned credential. * * @param name the name of the principal for whom this credential is to * be acquired. Use null to specify the default @@ -492,7 +492,7 @@ public abstract class GSSManager { * Non-default values for lifetime cannot always be honored by the * underlying mechanism, thus applications should be prepared to call * {@link GSSContext#getLifetime() getLifetime} on the returned - * context.

        + * context. * * @param peer the name of the target peer. * @param mech the Oid of the desired mechanism. Use null @@ -610,7 +610,7 @@ public abstract class GSSManager { * operation is unavailable.

        * * Suppose an application desired that the provider A always be checked - * first when any mechanism is needed, it would call:

        + * first when any mechanism is needed, it would call: *

              *         GSSManager mgr = GSSManager.getInstance();
              *         // mgr may at this point have its own pre-configured list
        @@ -621,7 +621,7 @@ public abstract class GSSManager {
              * 
        * Now if it also desired that the mechanism of Oid m1 always be * obtained from the provider B before the previously set A was checked, - * it would call:

        + * it would call: *

              *         mgr.addProviderAtFront(B, m1);
              * 
        @@ -632,7 +632,7 @@ public abstract class GSSManager { * directly.

        * * Suppose at a later time the following call is made to the same - * GSSManager instance:

        + * GSSManager instance: *

              *         mgr.addProviderAtFront(B, null)
              * 
        @@ -684,14 +684,14 @@ public abstract class GSSManager { * Suppose an application desired that when a mechanism of Oid m1 is * needed the system default providers always be checked first, and only * when they do not support m1 should a provider A be checked. It would - * then make the call:

        + * then make the call: *

              *         GSSManager mgr = GSSManager.getInstance();
              *         mgr.addProviderAtEnd(A, m1);
              * 
        * Now, if it also desired that for all mechanisms the provider B be * checked after all configured providers have been checked, it would - * then call:

        + * then call: *

              *         mgr.addProviderAtEnd(B, null);
              * 
        @@ -699,7 +699,7 @@ public abstract class GSSManager { * null)}.

        * * Suppose at a later time the following call is made to the same - * GSSManager instance:

        + * GSSManager instance: *

              *         mgr.addProviderAtEnd(B, m2)
              * 
        @@ -708,7 +708,7 @@ public abstract class GSSManager { * request is made for the already existing pairs of (A, m1) or (B, * null).

        * - * Please note, however, that the following call:

        + * Please note, however, that the following call: *

              *         mgr.addProviderAtEnd(A, null)
              * 
        diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java index 580ab39383a..185a6c2f7b4 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ package org.ietf.jgss; * The code below creates a GSSName, converts it to an MN, performs a * comparison, obtains a printable representation of the name, exports it * to a byte array and then re-imports to obtain a - * new GSSName.

        + * new GSSName. *

          *      GSSManager manager = GSSManager.getInstance();
          *
        @@ -236,7 +236,8 @@ public interface GSSName {
              * method {@link GSSManager#createName(byte[], Oid)
              * GSSManager.createName} and specifying the NT_EXPORT_NAME as the name
              * type object identifier. The resulting GSSName name will
        -     * also be a MN.

        + * also be a MN. + * * @return a byte[] containing the exported name. RFC 2743 defines the * "Mechanism-Independent Exported Name Object Format" for these bytes. * diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/MessageProp.java b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/MessageProp.java index 2f776ebc2e6..8568f57ef11 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/MessageProp.java +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/MessageProp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ package org.ietf.jgss; * false. Upon return from these methods, this object will also * contain any supplementary status values applicable to the processed * token. The supplementary status values can indicate old tokens, out - * of sequence tokens, gap tokens or duplicate tokens.

        + * of sequence tokens, gap tokens or duplicate tokens. * * @see GSSContext#wrap * @see GSSContext#unwrap diff --git a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/package.html b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/package.html index 1dc1ec4985b..2049a263abe 100644 --- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/package.html +++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/package.html @@ -2,7 +2,7 @@

        If in one release a type or package is - * @Exported(true), in a subsequent major release such a - * type or package can transition to @Exported(false). - * - *

        If a type or package is @Exported(false) in a - * release, it may be removed in a subsequent major release. - * - *

        If a top-level type has an @Exported annotation, - * any nested member types with the top-level type should have an - * @Exported annotation with the same value. - * - * (In exceptional cases, if a nested type is going to be removed - * before its enclosing type, the nested type's could be - * @Exported(false) while its enclosing type was - * @Exported(true).) - * - * Likewise, if a package has an @Exported annotation, - * top-level types within that package should also have an - * @Exported annotation. - * - * Sometimes a top-level type may have a different - * @Exported value than its package. - * - * @since 1.8 - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.PACKAGE}) -@Exported -public @interface Exported { - /** - * Whether or not the annotated type or package is an exported - * part of the JDK. - * @return whether or not the annotated type or package is an exported - * part of the JDK - */ - boolean value() default true; -} diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java index 20dc4160aa2..f51b575410d 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java @@ -40,6 +40,7 @@ import com.sun.source.tree.*; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.comp.*; +import com.sun.tools.javac.file.BaseFileManager; import com.sun.tools.javac.main.*; import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.parser.Parser; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java index b7811f5719e..99b79820762 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java @@ -44,7 +44,7 @@ import com.sun.source.util.JavacTask; import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.main.Arguments; import com.sun.tools.javac.main.Option; -import com.sun.tools.javac.util.BaseFileManager; +import com.sun.tools.javac.file.BaseFileManager; import com.sun.tools.javac.util.ClientCodeException; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.DefinedBy; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java index 35174e9832a..ddd7a881d91 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java @@ -696,7 +696,8 @@ public class JavacTrees extends DocTrees { @DefinedBy(Api.COMPILER_TREE) public TypeMirror getTypeMirror(TreePath path) { Tree t = path.getLeaf(); - return ((JCTree)t).type; + Type ty = ((JCTree)t).type; + return ty == null ? null : ty.stripMetadataIfNeeded(); } @DefinedBy(Api.COMPILER_TREE) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java index 40802254d72..a2abf1bc46b 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ package com.sun.tools.javac.code; -import java.io.*; +import java.io.IOException; +import java.io.File; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; @@ -38,16 +39,15 @@ import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; import com.sun.tools.javac.code.Scope.WriteableScope; -import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.Completer; import com.sun.tools.javac.code.Symbol.CompletionFailure; import com.sun.tools.javac.code.Symbol.PackageSymbol; import com.sun.tools.javac.code.Symbol.TypeSymbol; import com.sun.tools.javac.comp.Annotate; +import com.sun.tools.javac.comp.Enter; import com.sun.tools.javac.file.JRTIndex; import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.file.RelativePath.RelativeDirectory; import com.sun.tools.javac.jvm.ClassReader; import com.sun.tools.javac.jvm.Profile; import com.sun.tools.javac.util.*; @@ -75,7 +75,7 @@ public class ClassFinder { ClassReader reader; - Annotate annotate; + private final Annotate annotate; /** Switch: verbose output. */ @@ -272,18 +272,13 @@ public class ClassFinder { try { ClassSymbol c = (ClassSymbol) sym; dependencies.push(c, CompletionCause.CLASS_READER); + annotate.blockAnnotations(); c.members_field = new Scope.ErrorScope(c); // make sure it's always defined - annotate.enterStart(); - try { - completeOwners(c.owner); - completeEnclosing(c); - } finally { - // The flush needs to happen only after annotations - // are filled in. - annotate.enterDoneWithoutFlush(); - } + completeOwners(c.owner); + completeEnclosing(c); fillIn(c); } finally { + annotate.unblockAnnotationsNoFlush(); dependencies.pop(); } } else if (sym.kind == PCK) { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Kinds.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Kinds.java index c29549a221b..263d0c50bd9 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Kinds.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Kinds.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,22 +66,22 @@ public class Kinds { MTH(Category.BASIC, KindName.METHOD, KindSelector.MTH), POLY(Category.BASIC, KindSelector.POLY), ERR(Category.ERROR, KindSelector.ERR), - AMBIGUOUS(Category.OVERLOAD), - HIDDEN(Category.OVERLOAD), - STATICERR(Category.OVERLOAD), - MISSING_ENCL(Category.OVERLOAD), - ABSENT_VAR(Category.OVERLOAD, KindName.VAR), - WRONG_MTHS(Category.OVERLOAD, KindName.METHOD), - WRONG_MTH(Category.OVERLOAD, KindName.METHOD), - ABSENT_MTH(Category.OVERLOAD, KindName.METHOD), - ABSENT_TYP(Category.OVERLOAD, KindName.CLASS); + AMBIGUOUS(Category.RESOLUTION_TARGET), // overloaded target + HIDDEN(Category.RESOLUTION_TARGET), // not overloaded non-target + STATICERR(Category.RESOLUTION_TARGET), // overloaded? target + MISSING_ENCL(Category.RESOLUTION), // not overloaded non-target + ABSENT_VAR(Category.RESOLUTION_TARGET, KindName.VAR), // not overloaded non-target + WRONG_MTHS(Category.RESOLUTION_TARGET, KindName.METHOD), // overloaded target + WRONG_MTH(Category.RESOLUTION_TARGET, KindName.METHOD), // not overloaded target + ABSENT_MTH(Category.RESOLUTION_TARGET, KindName.METHOD), // not overloaded non-target + ABSENT_TYP(Category.RESOLUTION_TARGET, KindName.CLASS); // not overloaded non-target // There are essentially two "levels" to the Kind datatype. // The first is a totally-ordered set of categories of // solutions. Within each category, we have more // possibilities. private enum Category { - BASIC, ERROR, OVERLOAD; + BASIC, ERROR, RESOLUTION, RESOLUTION_TARGET; } private final KindName kindName; @@ -127,8 +127,12 @@ public class Kinds { return selector.contains(kindSelectors); } - public boolean isOverloadError() { - return category == Category.OVERLOAD; + public boolean isResolutionError() { + return category == Category.RESOLUTION || category == Category.RESOLUTION_TARGET; + } + + public boolean isResolutionTargetError() { + return category == Category.RESOLUTION_TARGET; } public boolean isValid() { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java index 5f2dd39c32a..687012387de 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java @@ -209,6 +209,9 @@ public enum Source { public boolean allowPrivateSafeVarargs() { return compareTo(JDK1_9) >= 0; } + public boolean allowDiamondWithAnonymousClassCreation() { + return compareTo(JDK1_9) >= 0; + } public boolean allowUnderscoreIdentifier() { return compareTo(JDK1_8) <= 0; } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java index e4b88fa22c8..d19cda62150 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,11 @@ import java.util.concurrent.Callable; import javax.lang.model.element.*; import javax.tools.JavaFileObject; +import com.sun.tools.javac.code.Attribute.Compound; +import com.sun.tools.javac.code.TypeAnnotations.AnnotationType; +import com.sun.tools.javac.code.TypeMetadata.Entry; +import com.sun.tools.javac.comp.Annotate.AnnotationTypeCompleter; +import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata; import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Type.*; import com.sun.tools.javac.comp.Attr; @@ -738,6 +743,13 @@ public abstract class Symbol extends AnnoConstruct implements Element { return list; } + public AnnotationTypeMetadata getAnnotationTypeMetadata() { + Assert.error("Only on ClassSymbol"); + return null; //unreachable + } + + public boolean isAnnotationType() { return false; } + @Override public R accept(Symbol.Visitor v, P p) { return v.visitTypeSymbol(this, p); @@ -958,6 +970,9 @@ public abstract class Symbol extends AnnoConstruct implements Element { */ public Pool pool; + /** the annotation metadata attached to this class */ + private AnnotationTypeMetadata annotationTypeMetadata; + public ClassSymbol(long flags, Name name, Type type, Symbol owner) { super(TYP, flags, name, type, owner); this.members_field = null; @@ -966,6 +981,7 @@ public abstract class Symbol extends AnnoConstruct implements Element { this.sourcefile = null; this.classfile = null; this.pool = null; + this.annotationTypeMetadata = AnnotationTypeMetadata.notAnAnnotationType(); } public ClassSymbol(long flags, Name name, Symbol owner) { @@ -1202,8 +1218,24 @@ public abstract class Symbol extends AnnoConstruct implements Element { t.all_interfaces_field = null; } metadata = null; + annotationTypeMetadata = AnnotationTypeMetadata.notAnAnnotationType(); } + @Override + public AnnotationTypeMetadata getAnnotationTypeMetadata() { + return annotationTypeMetadata; + } + + @Override + public boolean isAnnotationType() { + return (flags_field & Flags.ANNOTATION) != 0; + } + + public void setAnnotationTypeMetadata(AnnotationTypeMetadata a) { + Assert.checkNonNull(a); + Assert.check(!annotationTypeMetadata.isMetadataForAnnotationType()); + this.annotationTypeMetadata = a; + } } @@ -1360,7 +1392,7 @@ public abstract class Symbol extends AnnoConstruct implements Element { /** The names of the parameters */ public List savedParameterNames; - /** For an attribute field accessor, its default value if any. + /** For an annotation type element, its default value if any. * The value is null if none appeared in the method * declaration. */ diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java index e2d3208c211..ad9e6291796 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ import java.util.function.Function; import javax.lang.model.type.*; import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.code.Types.MapVisitor; +import com.sun.tools.javac.code.TypeMetadata.Entry; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.DefinedBy.Api; import static com.sun.tools.javac.code.BoundKind.*; @@ -87,11 +87,10 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { return metadata; } - public TypeMetadata.Element getMetadataOfKind(final TypeMetadata.Element.Kind kind) { + public Entry getMetadataOfKind(final Entry.Kind kind) { return metadata != null ? metadata.get(kind) : null; } - /** Constant type: no type at all. */ public static final JCNoType noType = new JCNoType() { @Override @DefinedBy(Api.LANGUAGE_MODEL) @@ -238,7 +237,12 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { List typarams = t.getTypeArguments(); List typarams1 = visit(typarams, s); if (outer1 == outer && typarams1 == typarams) return t; - else return new ClassType(outer1, typarams1, t.tsym, t.metadata); + else return new ClassType(outer1, typarams1, t.tsym, t.metadata) { + @Override + protected boolean needsStripping() { + return true; + } + }; } @Override @@ -249,7 +253,12 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { if (t == wt.type) return wt; else - return new WildcardType(t, wt.kind, wt.tsym, wt.bound, wt.metadata); + return new WildcardType(t, wt.kind, wt.tsym, wt.bound, wt.metadata) { + @Override + protected boolean needsStripping() { + return true; + } + }; } @Override @@ -257,7 +266,12 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { Type elemtype = t.elemtype; Type elemtype1 = visit(elemtype, s); if (elemtype1 == elemtype) return t; - else return new ArrayType(elemtype1, t.tsym, t.metadata); + else return new ArrayType(elemtype1, t.tsym, t.metadata) { + @Override + protected boolean needsStripping() { + return true; + } + }; } @Override @@ -271,7 +285,12 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { if (argtypes1 == argtypes && restype1 == restype && thrown1 == thrown) return t; - else return new MethodType(argtypes1, restype1, thrown1, t.tsym); + else return new MethodType(argtypes1, restype1, thrown1, t.tsym) { + @Override + protected boolean needsStripping() { + return true; + } + }; } @Override @@ -313,38 +332,78 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } /** - * Create a new type with exactly the given metadata. The - * argument is guaranteed to always be non-empty, and should have - * already been copied/combined with the current type's metadata. - * This is used internally by other methods. - * + * Returns the original version of this type, before metadata were added. This routine is meant + * for internal use only (i.e. {@link Type#equalsIgnoreMetadata(Type)}, {@link Type#stripMetadata}); + * it should not be used outside this class. */ - public abstract Type clone(TypeMetadata md); - - public Type combineMetadata(final TypeMetadata.Element md) { - return clone(metadata.combine(md)); + protected Type typeNoMetadata() { + return metadata == TypeMetadata.EMPTY ? this : baseType(); } + /** + * Create a new copy of this type but with the specified TypeMetadata. + */ + public abstract Type cloneWithMetadata(TypeMetadata metadata); + + /** + * Does this type require annotation stripping for API clients? + */ + protected boolean needsStripping() { + return false; + } + + /** + * Strip all metadata associated with this type - this could return a new clone of the type. + * This routine is only used to present the correct annotated types back to the users when types + * are accessed through compiler APIs; it should not be used anywhere in the compiler internals + * as doing so might result in performance penalties. + */ + public Type stripMetadataIfNeeded() { + return needsStripping() ? + accept(stripMetadata, null) : + this; + } + //where + private final static TypeMapping stripMetadata = new TypeMapping() { + @Override + public Type visitClassType(ClassType t, Void aVoid) { + return super.visitClassType((ClassType)t.typeNoMetadata(), aVoid); + } + + @Override + public Type visitArrayType(ArrayType t, Void aVoid) { + return super.visitArrayType((ArrayType)t.typeNoMetadata(), aVoid); + } + + @Override + public Type visitTypeVar(TypeVar t, Void aVoid) { + return super.visitTypeVar((TypeVar)t.typeNoMetadata(), aVoid); + } + + @Override + public Type visitWildcardType(WildcardType wt, Void aVoid) { + return super.visitWildcardType((WildcardType)wt.typeNoMetadata(), aVoid); + } + }; + public Type annotatedType(final List annos) { - final TypeMetadata.Element annoMetadata = new TypeMetadata.Annotations(annos); - return combineMetadata(annoMetadata); + final Entry annoMetadata = new TypeMetadata.Annotations(annos); + return cloneWithMetadata(metadata.combine(annoMetadata)); } public boolean isAnnotated() { final TypeMetadata.Annotations metadata = - (TypeMetadata.Annotations)getMetadataOfKind(TypeMetadata.Element.Kind.ANNOTATIONS); + (TypeMetadata.Annotations)getMetadataOfKind(Entry.Kind.ANNOTATIONS); return null != metadata && !metadata.getAnnotations().isEmpty(); } - private static final List noAnnotations = List.nil(); - @Override @DefinedBy(Api.LANGUAGE_MODEL) public List getAnnotationMirrors() { final TypeMetadata.Annotations metadata = - (TypeMetadata.Annotations)getMetadataOfKind(TypeMetadata.Element.Kind.ANNOTATIONS); + (TypeMetadata.Annotations)getMetadataOfKind(Entry.Kind.ANNOTATIONS); - return metadata == null ? noAnnotations : metadata.getAnnotations(); + return metadata == null ? List.nil() : metadata.getAnnotations(); } @@ -431,13 +490,15 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } /** - * This method is analogous to isSameType, but weaker, since we - * never complete classes. Where isSameType would complete a - * class, equals assumes that the two types are different. + * Override this method with care. For most Type instances this should behave as ==. */ @Override @DefinedBy(Api.LANGUAGE_MODEL) public boolean equals(Object t) { - return super.equals(t); + return this == t; + } + + public boolean equalsIgnoreMetadata(Type t) { + return typeNoMetadata().equals(t.typeNoMetadata()); } @Override @DefinedBy(Api.LANGUAGE_MODEL) @@ -547,7 +608,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { * Does this type contain occurrences of type t? */ public boolean contains(Type t) { - return t == this; + return t.equalsIgnoreMetadata(this); } public static boolean contains(List ts, Type t) { @@ -615,19 +676,21 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { TypeTag tag; public JCPrimitiveType(TypeTag tag, TypeSymbol tsym) { - this(tag, tsym, TypeMetadata.empty); + this(tag, tsym, TypeMetadata.EMPTY); } - private JCPrimitiveType(TypeTag tag, TypeSymbol tsym, - TypeMetadata metadata) { + private JCPrimitiveType(TypeTag tag, TypeSymbol tsym, TypeMetadata metadata) { super(tsym, metadata); this.tag = tag; Assert.check(tag.isPrimitive); } @Override - public JCPrimitiveType clone(TypeMetadata md) { - return new JCPrimitiveType(tag, tsym, md); + public JCPrimitiveType cloneWithMetadata(TypeMetadata md) { + return new JCPrimitiveType(tag, tsym, md) { + @Override + public Type baseType() { return JCPrimitiveType.this.baseType(); } + }; } @Override @@ -740,7 +803,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } public WildcardType(Type type, BoundKind kind, TypeSymbol tsym) { - this(type, kind, tsym, null, TypeMetadata.empty); + this(type, kind, tsym, null, TypeMetadata.EMPTY); } public WildcardType(Type type, BoundKind kind, TypeSymbol tsym, @@ -750,7 +813,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public WildcardType(Type type, BoundKind kind, TypeSymbol tsym, TypeVar bound) { - this(type, kind, tsym, bound, TypeMetadata.empty); + this(type, kind, tsym, bound, TypeMetadata.EMPTY); } public WildcardType(Type type, BoundKind kind, TypeSymbol tsym, @@ -762,8 +825,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } @Override - public WildcardType clone(TypeMetadata md) { - return new WildcardType(type, kind, tsym, bound, md); + public WildcardType cloneWithMetadata(TypeMetadata md) { + return new WildcardType(type, kind, tsym, bound, md) { + @Override + public Type baseType() { return WildcardType.this.baseType(); } + }; } @Override @@ -883,7 +949,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public List all_interfaces_field; public ClassType(Type outer, List typarams, TypeSymbol tsym) { - this(outer, typarams, tsym, TypeMetadata.empty); + this(outer, typarams, tsym, TypeMetadata.EMPTY); } public ClassType(Type outer, List typarams, TypeSymbol tsym, @@ -897,13 +963,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } @Override - public ClassType clone(TypeMetadata md) { - final ClassType out = - new ClassType(outer_field, typarams_field, tsym, md); - out.allparams_field = allparams_field; - out.supertype_field = supertype_field; - out.interfaces_field = interfaces_field; - return out; + public ClassType cloneWithMetadata(TypeMetadata md) { + return new ClassType(outer_field, typarams_field, tsym, md) { + @Override + public Type baseType() { return ClassType.this.baseType(); } + }; } @Override @@ -935,14 +999,16 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { @DefinedBy(Api.LANGUAGE_MODEL) public String toString() { StringBuilder buf = new StringBuilder(); - appendAnnotationsString(buf); if (getEnclosingType().hasTag(CLASS) && tsym.owner.kind == TYP) { buf.append(getEnclosingType().toString()); buf.append("."); + appendAnnotationsString(buf); buf.append(className(tsym, false)); } else { + appendAnnotationsString(buf); buf.append(className(tsym, true)); } + if (getTypeArguments().nonEmpty()) { buf.append('<'); buf.append(getTypeArguments().toString()); @@ -1050,7 +1116,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public boolean contains(Type elem) { return - elem == this + elem.equalsIgnoreMetadata(this) || (isParameterized() && (getEnclosingType().contains(elem) || contains(getTypeArguments(), elem))) || (isCompound() @@ -1073,10 +1139,6 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } public static class ErasedClassType extends ClassType { - public ErasedClassType(Type outer, TypeSymbol tsym) { - super(outer, List.nil(), tsym); - } - public ErasedClassType(Type outer, TypeSymbol tsym, TypeMetadata metadata) { super(outer, List.nil(), tsym, metadata); @@ -1104,7 +1166,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } @Override - public UnionClassType clone(TypeMetadata md) { + public UnionClassType cloneWithMetadata(TypeMetadata md) { throw new AssertionError("Cannot add metadata to a union type"); } @@ -1155,7 +1217,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } @Override - public IntersectionClassType clone(TypeMetadata md) { + public IntersectionClassType cloneWithMetadata(TypeMetadata md) { throw new AssertionError("Cannot add metadata to an intersection type"); } @@ -1196,7 +1258,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public Type elemtype; public ArrayType(Type elemtype, TypeSymbol arrayClass) { - this(elemtype, arrayClass, TypeMetadata.empty); + this(elemtype, arrayClass, TypeMetadata.EMPTY); } public ArrayType(Type elemtype, TypeSymbol arrayClass, @@ -1205,9 +1267,18 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { this.elemtype = elemtype; } + public ArrayType(ArrayType that) { + //note: type metadata is deliberately shared here, as we want side-effects from annotation + //processing to flow from original array to the cloned array. + this(that.elemtype, that.tsym, that.getMetadata()); + } + @Override - public ArrayType clone(TypeMetadata md) { - return new ArrayType(elemtype, tsym, md); + public ArrayType cloneWithMetadata(TypeMetadata md) { + return new ArrayType(elemtype, tsym, md) { + @Override + public Type baseType() { return ArrayType.this.baseType(); } + }; } @Override @@ -1228,12 +1299,15 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { return sb.toString(); } - @DefinedBy(Api.LANGUAGE_MODEL) + @Override @DefinedBy(Api.LANGUAGE_MODEL) public boolean equals(Object obj) { - return - this == obj || - (obj instanceof ArrayType && - this.elemtype.equals(((ArrayType)obj).elemtype)); + if (obj instanceof ArrayType) { + ArrayType that = (ArrayType)obj; + return this == that || + elemtype.equals(that.elemtype); + } + + return false; } @DefinedBy(Api.LANGUAGE_MODEL) @@ -1279,7 +1353,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } public boolean contains(Type elem) { - return elem == this || elemtype.contains(elem); + return elem.equalsIgnoreMetadata(this) || elemtype.contains(elem); } public void complete() { @@ -1318,14 +1392,14 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { TypeSymbol methodClass) { // Presently no way to refer to a method type directly, so // we cannot put type annotations on it. - super(methodClass, TypeMetadata.empty); + super(methodClass, TypeMetadata.EMPTY); this.argtypes = argtypes; this.restype = restype; this.thrown = thrown; } @Override - public MethodType clone(TypeMetadata md) { + public MethodType cloneWithMetadata(TypeMetadata md) { throw new AssertionError("Cannot add metadata to a method type"); } @@ -1370,7 +1444,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } public boolean contains(Type elem) { - return elem == this || contains(argtypes, elem) || restype.contains(elem) || contains(thrown, elem); + return elem.equalsIgnoreMetadata(this) || contains(argtypes, elem) || restype.contains(elem) || contains(thrown, elem); } public MethodType asMethodType() { return this; } @@ -1408,11 +1482,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { PackageType(TypeSymbol tsym) { // Package types cannot be annotated - super(tsym, TypeMetadata.empty); + super(tsym, TypeMetadata.EMPTY); } @Override - public PackageType clone(TypeMetadata md) { + public PackageType cloneWithMetadata(TypeMetadata md) { throw new AssertionError("Cannot add metadata to a package type"); } @@ -1464,14 +1538,14 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public Type lower; public TypeVar(Name name, Symbol owner, Type lower) { - super(null, TypeMetadata.empty); + super(null, TypeMetadata.EMPTY); tsym = new TypeVariableSymbol(0, name, this, owner); - this.bound = bound; + this.bound = null; this.lower = lower; } public TypeVar(TypeSymbol tsym, Type bound, Type lower) { - this(tsym, bound, lower, TypeMetadata.empty); + this(tsym, bound, lower, TypeMetadata.EMPTY); } public TypeVar(TypeSymbol tsym, Type bound, Type lower, @@ -1482,8 +1556,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } @Override - public TypeVar clone(TypeMetadata md) { - return new TypeVar(tsym, bound, lower, md); + public TypeVar cloneWithMetadata(TypeMetadata md) { + return new TypeVar(tsym, bound, lower, md) { + @Override + public Type baseType() { return TypeVar.this.baseType(); } + }; } @Override @@ -1566,8 +1643,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } @Override - public CapturedType clone(TypeMetadata md) { - return new CapturedType(tsym, bound, bound, lower, wildcard, md); + public CapturedType cloneWithMetadata(TypeMetadata md) { + return new CapturedType(tsym, bound, bound, lower, wildcard, md) { + @Override + public Type baseType() { return CapturedType.this.baseType(); } + }; } @Override @@ -1597,7 +1677,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public TypeTag tag; public DelegatedType(TypeTag tag, Type qtype) { - this(tag, qtype, TypeMetadata.empty); + this(tag, qtype, TypeMetadata.EMPTY); } public DelegatedType(TypeTag tag, Type qtype, @@ -1635,7 +1715,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } @Override - public ForAll clone(TypeMetadata md) { + public ForAll cloneWithMetadata(TypeMetadata md) { throw new AssertionError("Cannot add metadata to a forall type"); } @@ -1785,7 +1865,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } @Override - public UndetVar clone(TypeMetadata md) { + public UndetVar cloneWithMetadata(TypeMetadata md) { throw new AssertionError("Cannot add metadata to an UndetVar type"); } @@ -1940,11 +2020,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { // Need to use List.nil(), because JCNoType constructor // gets called in static initializers in Type, where // noAnnotations is also defined. - super(null, TypeMetadata.empty); + super(null, TypeMetadata.EMPTY); } @Override - public JCNoType clone(TypeMetadata md) { + public JCNoType cloneWithMetadata(TypeMetadata md) { throw new AssertionError("Cannot add metadata to a JCNoType"); } @@ -1973,11 +2053,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public JCVoidType() { // Void cannot be annotated - super(null, TypeMetadata.empty); + super(null, TypeMetadata.EMPTY); } @Override - public JCVoidType clone(TypeMetadata md) { + public JCVoidType cloneWithMetadata(TypeMetadata md) { throw new AssertionError("Cannot add metadata to a void type"); } @@ -2008,11 +2088,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { static class BottomType extends Type implements NullType { public BottomType() { // Bottom is a synthesized internal type, so it cannot be annotated - super(null, TypeMetadata.empty); + super(null, TypeMetadata.EMPTY); } @Override - public BottomType clone(TypeMetadata md) { + public BottomType cloneWithMetadata(TypeMetadata md) { throw new AssertionError("Cannot add metadata to a bottom type"); } @@ -2077,8 +2157,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } @Override - public ErrorType clone(TypeMetadata md) { - return new ErrorType(originalType, tsym, md); + public ErrorType cloneWithMetadata(TypeMetadata md) { + return new ErrorType(originalType, tsym, md) { + @Override + public Type baseType() { return ErrorType.this.baseType(); } + }; } @Override @@ -2145,11 +2228,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public UnknownType() { // Unknown is a synthesized internal type, so it cannot be // annotated. - super(null, TypeMetadata.empty); + super(null, TypeMetadata.EMPTY); } @Override - public UnknownType clone(TypeMetadata md) { + public UnknownType cloneWithMetadata(TypeMetadata md) { throw new AssertionError("Cannot add metadata to an unknown type"); } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java index d3aecdb2126..3d1c6b5e795 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -118,14 +118,10 @@ public class TypeAnnotationPosition { public static final List emptyPath = List.nil(); - // NOTE: All of these will be converted to final fields eventually. - public final TargetType type; // For generic/array types. - // This field is in the process of being made final. Do not - // introduce new mutations. public List location; // Tree position. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java index d7a03ee4665..1bc02106b2e 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import javax.lang.model.type.TypeKind; import javax.tools.JavaFileObject; +import com.sun.tools.javac.code.Attribute.Array; import com.sun.tools.javac.code.Attribute.TypeCompound; import com.sun.tools.javac.code.Type.ArrayType; import com.sun.tools.javac.code.Type.CapturedType; @@ -47,8 +48,8 @@ import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntryKind; import com.sun.tools.javac.code.Symbol.VarSymbol; import com.sun.tools.javac.code.Symbol.MethodSymbol; +import com.sun.tools.javac.code.TypeMetadata.Entry.Kind; import com.sun.tools.javac.comp.Annotate; -import com.sun.tools.javac.comp.Annotate.Worker; import com.sun.tools.javac.comp.Attr; import com.sun.tools.javac.comp.AttrContext; import com.sun.tools.javac.comp.Env; @@ -71,7 +72,6 @@ import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Log; import com.sun.tools.javac.util.Names; -import com.sun.tools.javac.util.Options; import static com.sun.tools.javac.code.Kinds.Kind.*; @@ -105,7 +105,6 @@ public class TypeAnnotations { syms = Symtab.instance(context); annotate = Annotate.instance(context); attr = Attr.instance(context); - Options options = Options.instance(context); } /** @@ -113,12 +112,9 @@ public class TypeAnnotations { * determine the correct positions for type annotations. * This version only visits types in signatures and should be * called from MemberEnter. - * The method takes the Annotate object as parameter and - * adds an Annotate.Worker to the correct Annotate queue for - * later processing. */ public void organizeTypeAnnotationsSignatures(final Env env, final JCClassDecl tree) { - annotate.afterRepeated( new Worker() { + annotate.afterTypes(new Runnable() { @Override public void run() { JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile); @@ -129,11 +125,11 @@ public class TypeAnnotations { log.useSource(oldSource); } } - } ); + }); } public void validateTypeAnnotationsSignatures(final Env env, final JCClassDecl tree) { - annotate.validate(new Worker() { //validate annotations + annotate.validate(new Runnable() { //validate annotations @Override public void run() { JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile); @@ -144,7 +140,7 @@ public class TypeAnnotations { log.useSource(oldSource); } } - } ); + }); } /** @@ -155,101 +151,106 @@ public class TypeAnnotations { new TypeAnnotationPositions(false).scan(tree); } - public enum AnnotationType { DECLARATION, TYPE, BOTH } + public enum AnnotationType { DECLARATION, TYPE, NONE, BOTH } + + public List annotationTargets(Attribute.Compound anno) { + Attribute.Compound atTarget = anno.type.tsym.getAnnotationTypeMetadata().getTarget(); + if (atTarget == null) { + return null; + } + + Attribute atValue = atTarget.member(names.value); + if (!(atValue instanceof Attribute.Array)) { + return null; + } + + List targets = ((Array)atValue).getValue(); + if (targets.stream().anyMatch(a -> !(a instanceof Attribute.Enum))) { + return null; + } + + return targets; + } /** * Determine whether an annotation is a declaration annotation, * a type annotation, or both. */ - public AnnotationType annotationType(Attribute.Compound a, Symbol s) { - Attribute.Compound atTarget = - a.type.tsym.attribute(syms.annotationTargetType.tsym); - if (atTarget == null) { - return inferTargetMetaInfo(a, s); - } - Attribute atValue = atTarget.member(names.value); - if (!(atValue instanceof Attribute.Array)) { - Assert.error("annotationType(): bad @Target argument " + atValue + - " (" + atValue.getClass() + ")"); - return AnnotationType.DECLARATION; // error recovery - } - Attribute.Array arr = (Attribute.Array) atValue; - boolean isDecl = false, isType = false; - for (Attribute app : arr.values) { - if (!(app instanceof Attribute.Enum)) { - Assert.error("annotationType(): unrecognized Attribute kind " + app + - " (" + app.getClass() + ")"); - isDecl = true; - continue; - } - Attribute.Enum e = (Attribute.Enum) app; - if (e.value.name == names.TYPE) { - if (s.kind == TYP) - isDecl = true; - } else if (e.value.name == names.FIELD) { - if (s.kind == VAR && - s.owner.kind != MTH) - isDecl = true; - } else if (e.value.name == names.METHOD) { - if (s.kind == MTH && - !s.isConstructor()) - isDecl = true; - } else if (e.value.name == names.PARAMETER) { - if (s.kind == VAR && - s.owner.kind == MTH && - (s.flags() & Flags.PARAMETER) != 0) - isDecl = true; - } else if (e.value.name == names.CONSTRUCTOR) { - if (s.kind == MTH && - s.isConstructor()) - isDecl = true; - } else if (e.value.name == names.LOCAL_VARIABLE) { - if (s.kind == VAR && - s.owner.kind == MTH && - (s.flags() & Flags.PARAMETER) == 0) - isDecl = true; - } else if (e.value.name == names.ANNOTATION_TYPE) { - if (s.kind == TYP && - (s.flags() & Flags.ANNOTATION) != 0) - isDecl = true; - } else if (e.value.name == names.PACKAGE) { - if (s.kind == PCK) - isDecl = true; - } else if (e.value.name == names.TYPE_USE) { - if (s.kind == TYP || - s.kind == VAR || - (s.kind == MTH && !s.isConstructor() && - !s.type.getReturnType().hasTag(TypeTag.VOID)) || - (s.kind == MTH && s.isConstructor())) - isType = true; - } else if (e.value.name == names.TYPE_PARAMETER) { - /* Irrelevant in this case */ - // TYPE_PARAMETER doesn't aid in distinguishing between - // Type annotations and declaration annotations on an - // Element - } else { - Assert.error("annotationType(): unrecognized Attribute name " + e.value.name + - " (" + e.value.name.getClass() + ")"); - isDecl = true; - } - } - if (isDecl && isType) { + public AnnotationType annotationTargetType(Attribute.Compound a, Symbol s) { + List targets = annotationTargets(a); + return (targets == null) ? + AnnotationType.DECLARATION : + targets.stream() + .map(attr -> targetToAnnotationType(attr, s)) + .reduce(AnnotationType.NONE, this::combineAnnotationType); + } + + private AnnotationType combineAnnotationType(AnnotationType at1, AnnotationType at2) { + if (at1 == AnnotationType.NONE) { + return at2; + } else if (at2 == AnnotationType.NONE) { + return at1; + } else if (at1 != at2) { return AnnotationType.BOTH; - } else if (isType) { - return AnnotationType.TYPE; } else { + return at1; + } + } + + private AnnotationType targetToAnnotationType(Attribute a, Symbol s) { + Attribute.Enum e = (Attribute.Enum)a; + if (e.value.name == names.TYPE) { + if (s.kind == TYP) + return AnnotationType.DECLARATION; + } else if (e.value.name == names.FIELD) { + if (s.kind == VAR && + s.owner.kind != MTH) + return AnnotationType.DECLARATION; + } else if (e.value.name == names.METHOD) { + if (s.kind == MTH && + !s.isConstructor()) + return AnnotationType.DECLARATION; + } else if (e.value.name == names.PARAMETER) { + if (s.kind == VAR && + s.owner.kind == MTH && + (s.flags() & Flags.PARAMETER) != 0) + return AnnotationType.DECLARATION; + } else if (e.value.name == names.CONSTRUCTOR) { + if (s.kind == MTH && + s.isConstructor()) + return AnnotationType.DECLARATION; + } else if (e.value.name == names.LOCAL_VARIABLE) { + if (s.kind == VAR && + s.owner.kind == MTH && + (s.flags() & Flags.PARAMETER) == 0) + return AnnotationType.DECLARATION; + } else if (e.value.name == names.ANNOTATION_TYPE) { + if (s.kind == TYP && + (s.flags() & Flags.ANNOTATION) != 0) + return AnnotationType.DECLARATION; + } else if (e.value.name == names.PACKAGE) { + if (s.kind == PCK) + return AnnotationType.DECLARATION; + } else if (e.value.name == names.TYPE_USE) { + if (s.kind == TYP || + s.kind == VAR || + (s.kind == MTH && !s.isConstructor() && + !s.type.getReturnType().hasTag(TypeTag.VOID)) || + (s.kind == MTH && s.isConstructor())) + return AnnotationType.TYPE; + } else if (e.value.name == names.TYPE_PARAMETER) { + /* Irrelevant in this case */ + // TYPE_PARAMETER doesn't aid in distinguishing between + // Type annotations and declaration annotations on an + // Element + } else { + Assert.error("annotationTargetType(): unrecognized Attribute name " + e.value.name + + " (" + e.value.name.getClass() + ")"); return AnnotationType.DECLARATION; } + return AnnotationType.NONE; } - /** Infer the target annotation kind, if none is give. - * We only infer declaration annotations. - */ - private static AnnotationType inferTargetMetaInfo(Attribute.Compound a, Symbol s) { - return AnnotationType.DECLARATION; - } - - private class TypeAnnotationPositions extends TreeScanner { private final boolean sigOnly; @@ -262,18 +263,29 @@ public class TypeAnnotations { * When traversing the AST we keep the "frames" of visited * trees in order to determine the position of annotations. */ - private ListBuffer frames = new ListBuffer<>(); + private List frames = List.nil(); - protected void push(JCTree t) { frames = frames.prepend(t); } - protected JCTree pop() { return frames.next(); } + protected void push(JCTree t) { + frames = frames.prepend(t); + } + protected JCTree pop() { + JCTree t = frames.head; + frames = frames.tail; + return t; + } // could this be frames.elems.tail.head? - private JCTree peek2() { return frames.toList().tail.head; } + private JCTree peek2() { + return frames.tail.head; + } @Override public void scan(JCTree tree) { push(tree); - super.scan(tree); - pop(); + try { + super.scan(tree); + } finally { + pop(); + } } /** @@ -283,41 +295,44 @@ public class TypeAnnotations { * we never build an JCAnnotatedType. This step finds these * annotations and marks them as if they were part of the type. */ - private void separateAnnotationsKinds(JCTree typetree, Type type, Symbol sym, - TypeAnnotationPosition pos) { - List annotations = sym.getRawAttributes(); + private void separateAnnotationsKinds(JCTree typetree, Type type, + Symbol sym, TypeAnnotationPosition pos) + { + List allAnnotations = sym.getRawAttributes(); ListBuffer declAnnos = new ListBuffer<>(); ListBuffer typeAnnos = new ListBuffer<>(); ListBuffer onlyTypeAnnos = new ListBuffer<>(); - for (Attribute.Compound a : annotations) { - switch (annotationType(a, sym)) { - case DECLARATION: - declAnnos.append(a); - break; - case BOTH: { - declAnnos.append(a); - Attribute.TypeCompound ta = toTypeCompound(a, pos); - typeAnnos.append(ta); - break; - } - case TYPE: { - Attribute.TypeCompound ta = toTypeCompound(a, pos); - typeAnnos.append(ta); - // Also keep track which annotations are only type annotations - onlyTypeAnnos.append(ta); - break; - } + for (Attribute.Compound a : allAnnotations) { + switch (annotationTargetType(a, sym)) { + case DECLARATION: + declAnnos.append(a); + break; + case BOTH: { + declAnnos.append(a); + Attribute.TypeCompound ta = toTypeCompound(a, pos); + typeAnnos.append(ta); + break; + } + case TYPE: { + Attribute.TypeCompound ta = toTypeCompound(a, pos); + typeAnnos.append(ta); + // Also keep track which annotations are only type annotations + onlyTypeAnnos.append(ta); + break; + } } } - sym.resetAnnotations(); - sym.setDeclarationAttributes(declAnnos.toList()); - + // If we have no type annotations we are done for this Symbol if (typeAnnos.isEmpty()) { return; } + // Reset decl annotations to the set {all - type only} + sym.resetAnnotations(); + sym.setDeclarationAttributes(declAnnos.toList()); + List typeAnnotations = typeAnnos.toList(); if (type == null) { @@ -328,7 +343,7 @@ public class TypeAnnotations { // Declaration annotations are always allowed on constructor returns. // Therefore, use typeAnnotations instead of onlyTypeAnnos. - type = typeWithAnnotations(typetree, type, typeAnnotations, typeAnnotations); + typeWithAnnotations(typetree, type, typeAnnotations, typeAnnotations, pos); // Note that we don't use the result, the call to // typeWithAnnotations side-effects the type annotation positions. // This is important for constructors of nested classes. @@ -336,8 +351,8 @@ public class TypeAnnotations { return; } - // type is non-null and annotations are added to that type - type = typeWithAnnotations(typetree, type, typeAnnotations, onlyTypeAnnos.toList()); + // type is non-null, add type annotations from declaration context to the type + type = typeWithAnnotations(typetree, type, typeAnnotations, onlyTypeAnnos.toList(), pos); if (sym.getKind() == ElementKind.METHOD) { sym.type.asMethodType().restype = type; @@ -390,59 +405,23 @@ public class TypeAnnotations { // Note that it is assumed that all annotations share the same position. private Type typeWithAnnotations(final JCTree typetree, final Type type, final List annotations, - final List onlyTypeAnnotations) { - //System.err.printf("typeWithAnnotations(typetree: %s, type: %s, annotations: %s, onlyTypeAnnotations: %s)%n", - // typetree, type, annotations, onlyTypeAnnotations); + final List onlyTypeAnnotations, + final TypeAnnotationPosition pos) + { if (annotations.isEmpty()) { return type; } - if (type.hasTag(TypeTag.ARRAY)) { - Type.ArrayType arType = (Type.ArrayType) type; - Type.ArrayType tomodify = new Type.ArrayType(null, arType.tsym); - Type toreturn; - if (type.isAnnotated()) { - toreturn = tomodify.annotatedType(type.getAnnotationMirrors()); - } else { - toreturn = tomodify; - } - JCArrayTypeTree arTree = arrayTypeTree(typetree); + if (type.hasTag(TypeTag.ARRAY)) + return rewriteArrayType((ArrayType)type, annotations, pos); - ListBuffer depth = new ListBuffer<>(); - depth = depth.append(TypePathEntry.ARRAY); - while (arType.elemtype.hasTag(TypeTag.ARRAY)) { - if (arType.elemtype.isAnnotated()) { - Type aelemtype = arType.elemtype; - arType = (Type.ArrayType) aelemtype; - ArrayType prevToMod = tomodify; - tomodify = new Type.ArrayType(null, arType.tsym); - prevToMod.elemtype = tomodify.annotatedType(arType.elemtype.getAnnotationMirrors()); - } else { - arType = (Type.ArrayType) arType.elemtype; - tomodify.elemtype = new Type.ArrayType(null, arType.tsym); - tomodify = (Type.ArrayType) tomodify.elemtype; - } - arTree = arrayTypeTree(arTree.elemtype); - depth = depth.append(TypePathEntry.ARRAY); - } - Type arelemType = typeWithAnnotations(arTree.elemtype, arType.elemtype, annotations, onlyTypeAnnotations); - tomodify.elemtype = arelemType; - { - // All annotations share the same position; modify the first one. - Attribute.TypeCompound a = annotations.get(0); - TypeAnnotationPosition p = a.position; - p.location = p.location.prependList(depth.toList()); - } - typetree.type = toreturn; - return toreturn; - } else if (type.hasTag(TypeTag.TYPEVAR)) { - // Nothing to do for type variables. - return type; + if (type.hasTag(TypeTag.TYPEVAR)) { + return type.annotatedType(onlyTypeAnnotations); } else if (type.getKind() == TypeKind.UNION) { // There is a TypeKind, but no TypeTag. - JCTypeUnion tutree = (JCTypeUnion) typetree; + JCTypeUnion tutree = (JCTypeUnion)typetree; JCExpression fst = tutree.alternatives.get(0); - Type res = typeWithAnnotations(fst, fst.type, annotations, onlyTypeAnnotations); + Type res = typeWithAnnotations(fst, fst.type, annotations, onlyTypeAnnotations, pos); fst.type = res; // TODO: do we want to set res as first element in uct.alternatives? // UnionClassType uct = (com.sun.tools.javac.code.Type.UnionClassType)type; @@ -459,8 +438,8 @@ public class TypeAnnotations { enclTy.getKind() != TypeKind.NONE && enclTy.getKind() != TypeKind.ERROR && (enclTr.getKind() == JCTree.Kind.MEMBER_SELECT || - enclTr.getKind() == JCTree.Kind.PARAMETERIZED_TYPE || - enclTr.getKind() == JCTree.Kind.ANNOTATED_TYPE)) { + enclTr.getKind() == JCTree.Kind.PARAMETERIZED_TYPE || + enclTr.getKind() == JCTree.Kind.ANNOTATED_TYPE)) { // Iterate also over the type tree, not just the type: the type is already // completely resolved and we cannot distinguish where the annotation // belongs for a nested type. @@ -483,20 +462,20 @@ public class TypeAnnotations { if (enclTy != null && enclTy.hasTag(TypeTag.NONE)) { switch (onlyTypeAnnotations.size()) { - case 0: - // Don't issue an error if all type annotations are - // also declaration annotations. - // If the annotations are also declaration annotations, they are - // illegal as type annotations but might be legal as declaration annotations. - // The normal declaration annotation checks make sure that the use is valid. - break; - case 1: - log.error(typetree.pos(), "cant.type.annotate.scoping.1", - onlyTypeAnnotations); - break; - default: - log.error(typetree.pos(), "cant.type.annotate.scoping", - onlyTypeAnnotations); + case 0: + // Don't issue an error if all type annotations are + // also declaration annotations. + // If the annotations are also declaration annotations, they are + // illegal as type annotations but might be legal as declaration annotations. + // The normal declaration annotation checks make sure that the use is valid. + break; + case 1: + log.error(typetree.pos(), "cant.type.annotate.scoping.1", + onlyTypeAnnotations); + break; + default: + log.error(typetree.pos(), "cant.type.annotate.scoping", + onlyTypeAnnotations); } return type; } @@ -539,15 +518,62 @@ public class TypeAnnotations { } } - private JCArrayTypeTree arrayTypeTree(JCTree typetree) { - if (typetree.getKind() == JCTree.Kind.ARRAY_TYPE) { - return (JCArrayTypeTree) typetree; - } else if (typetree.getKind() == JCTree.Kind.ANNOTATED_TYPE) { - return (JCArrayTypeTree) ((JCAnnotatedType)typetree).underlyingType; - } else { - Assert.error("Could not determine array type from type tree: " + typetree); - return null; + /** + * Create a copy of the {@code Type type} with the help of the Tree for a type + * {@code JCTree typetree} inserting all type annotations in {@code annotations} to the + * innermost array component type. + * + * SIDE EFFECT: Update position for the annotations to be {@code pos}. + */ + private Type rewriteArrayType(ArrayType type, List annotations, TypeAnnotationPosition pos) { + ArrayType tomodify = new ArrayType(type); + ArrayType res = tomodify; + + List loc = List.nil(); + + // peel one and update loc + Type tmpType = type.elemtype; + loc = loc.prepend(TypePathEntry.ARRAY); + + while (tmpType.hasTag(TypeTag.ARRAY)) { + ArrayType arr = (ArrayType)tmpType; + + // Update last type with new element type + ArrayType tmp = new ArrayType(arr); + tomodify.elemtype = tmp; + tomodify = tmp; + + tmpType = arr.elemtype; + loc = loc.prepend(TypePathEntry.ARRAY); } + + // Fix innermost element type + Type elemType; + if (tmpType.getMetadata() != null) { + List tcs; + if (tmpType.getAnnotationMirrors().isEmpty()) { + tcs = annotations; + } else { + // Special case, lets prepend + tcs = annotations.appendList(tmpType.getAnnotationMirrors()); + } + elemType = tmpType.cloneWithMetadata(tmpType + .getMetadata() + .without(Kind.ANNOTATIONS) + .combine(new TypeMetadata.Annotations(tcs))); + } else { + elemType = tmpType.cloneWithMetadata(new TypeMetadata(new TypeMetadata.Annotations(annotations))); + } + tomodify.elemtype = elemType; + + // Update positions + for (TypeCompound tc : annotations) { + if (tc.position == null) + tc.position = pos; + tc.position.location = loc; + } + + return res; } /** Return a copy of the first type that only differs by @@ -569,7 +595,6 @@ public class TypeAnnotations { private Type typeWithAnnotations(final Type type, final Type stopAt, final List annotations) { - //System.err.println("typeWithAnnotations " + type + " " + annotations + " stopAt " + stopAt); Visitor> visitor = new Type.Visitor>() { @Override @@ -660,20 +685,14 @@ public class TypeAnnotations { /* This is the beginning of the second part of organizing * type annotations: determine the type annotation positions. */ - - // This method is considered deprecated, and will be removed - // in the near future. Don't use it for anything new. private TypeAnnotationPosition resolveFrame(JCTree tree, JCTree frame, List path, JCLambda currentLambda, int outer_type_index, - ListBuffer location) { - /* - System.out.println("Resolving tree: " + tree + " kind: " + tree.getKind()); - System.out.println(" Framing tree: " + frame + " kind: " + frame.getKind()); - */ + ListBuffer location) + { // Note that p.offset is set in // com.sun.tools.javac.jvm.Gen.setTypeAnnotationPositions(int) @@ -695,20 +714,17 @@ public class TypeAnnotations { if (frameNewClass.def != null) { // Special handling for anonymous class instantiations final JCClassDecl frameClassDecl = frameNewClass.def; - if (frameClassDecl.extending == tree) { - return TypeAnnotationPosition - .classExtends(location.toList(), currentLambda, - frame.pos); - } else if (frameClassDecl.implementing.contains(tree)) { + if (frameClassDecl.implementing.contains(tree)) { final int type_index = frameClassDecl.implementing.indexOf(tree); return TypeAnnotationPosition .classExtends(location.toList(), currentLambda, type_index, frame.pos); } else { - // In contrast to CLASS below, typarams cannot occur here. - throw new AssertionError("Could not determine position of tree " + tree + - " within frame " + frame); + //for encl.new @TA Clazz(), tree may be different from frameClassDecl.extending + return TypeAnnotationPosition + .classExtends(location.toList(), currentLambda, + frame.pos); } } else if (frameNewClass.typeargs.contains(tree)) { final int type_index = @@ -1120,29 +1136,31 @@ public class TypeAnnotations { // Nothing to do for separateAnnotationsKinds if // there are no annotations of either kind. // TODO: make sure there are no declaration annotations. - final TypeAnnotationPosition pos = - TypeAnnotationPosition.methodReceiver(tree.recvparam.vartype.pos); - separateAnnotationsKinds(tree.recvparam.vartype, - tree.recvparam.sym.type, - tree.recvparam.sym, pos); + final TypeAnnotationPosition pos = TypeAnnotationPosition.methodReceiver(tree.recvparam.vartype.pos); + push(tree.recvparam); + try { + separateAnnotationsKinds(tree.recvparam.vartype, tree.recvparam.sym.type, tree.recvparam.sym, pos); + } finally { + pop(); + } } int i = 0; for (JCVariableDecl param : tree.params) { if (!param.mods.annotations.isEmpty()) { // Nothing to do for separateAnnotationsKinds if // there are no annotations of either kind. - final TypeAnnotationPosition pos = - TypeAnnotationPosition.methodParameter(i, param.vartype.pos); - separateAnnotationsKinds(param.vartype, - param.sym.type, - param.sym, pos); + final TypeAnnotationPosition pos = TypeAnnotationPosition.methodParameter(i, param.vartype.pos); + push(param); + try { + separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos); + } finally { + pop(); + } } ++i; } } - push(tree); - // super.visitMethodDef(tree); if (sigOnly) { scan(tree.mods); scan(tree.restype); @@ -1154,7 +1172,6 @@ public class TypeAnnotations { scan(tree.defaultValue); scan(tree.body); } - pop(); } /* Store a reference to the current lambda expression, to @@ -1172,18 +1189,20 @@ public class TypeAnnotations { if (!param.mods.annotations.isEmpty()) { // Nothing to do for separateAnnotationsKinds if // there are no annotations of either kind. - final TypeAnnotationPosition pos = - TypeAnnotationPosition.methodParameter(tree, i, - param.vartype.pos); - separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos); + final TypeAnnotationPosition pos = TypeAnnotationPosition + .methodParameter(tree, i, param.vartype.pos); + push(param); + try { + separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos); + } finally { + pop(); + } } ++i; } - push(tree); scan(tree.body); scan(tree.params); - pop(); } finally { currentLambda = prevLambda; } @@ -1227,17 +1246,14 @@ public class TypeAnnotations { // No type annotations can occur here. } else { // There is nothing else in a variable declaration that needs separation. - Assert.error("Unhandled variable kind: " + tree + " of kind: " + tree.sym.getKind()); + Assert.error("Unhandled variable kind"); } - push(tree); - // super.visitVarDef(tree); scan(tree.mods); scan(tree.vartype); if (!sigOnly) { scan(tree.init); } - pop(); } @Override @@ -1363,31 +1379,37 @@ public class TypeAnnotations { scan(tree.elems); } - private void findPosition(JCTree tree, JCTree frame, List annotations) { + + private void findTypeCompoundPosition(JCTree tree, JCTree frame, List annotations) { if (!annotations.isEmpty()) { - /* - System.err.println("Finding pos for: " + annotations); - System.err.println(" tree: " + tree + " kind: " + tree.getKind()); - System.err.println(" frame: " + frame + " kind: " + frame.getKind()); - */ final TypeAnnotationPosition p = - resolveFrame(tree, frame, frames.toList(), currentLambda, 0, - new ListBuffer()); + resolveFrame(tree, frame, frames, currentLambda, 0, new ListBuffer<>()); + for (TypeCompound tc : annotations) + tc.position = p; + } + } + + private void findPosition(JCTree tree, JCTree frame, List annotations) { + if (!annotations.isEmpty()) + { + final TypeAnnotationPosition p = + resolveFrame(tree, frame, frames, currentLambda, 0, new ListBuffer<>()); + setTypeAnnotationPos(annotations, p); } } - private void setTypeAnnotationPos(List annotations, - TypeAnnotationPosition position) { + private void setTypeAnnotationPos(List annotations, TypeAnnotationPosition position) + { + // attribute might be null during DeferredAttr; + // we will be back later. for (JCAnnotation anno : annotations) { - // attribute might be null during DeferredAttr; - // we will be back later. - if (anno.attribute != null) { + if (anno.attribute != null) ((Attribute.TypeCompound) anno.attribute).position = position; - } } } + @Override public String toString() { return super.toString() + ": sigOnly: " + sigOnly; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeMetadata.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeMetadata.java index 22e821e5ee9..71aefc3a697 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeMetadata.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeMetadata.java @@ -30,46 +30,63 @@ import com.sun.tools.javac.util.Assert; import com.sun.tools.javac.util.List; import java.util.EnumMap; import java.util.HashSet; -import java.util.Map; import java.util.Set; /** - * A super-interface for all type metadata elements. Metadata classes - * can be created for any metadata on types with the following - * properties: + * TypeMetadata is essentially an immutable {@code EnumMap>} * - *

          - *
        • They have a default value (preferably empty)
        • - *
        • The field is usually the default value
        • - *
        • Different values of the field are visible, and denote distinct - * types
        • - *
        + * A metadata class represented by a subtype of Entry can express a property on a Type instance. + * Thers should be at most one instance of an Entry per Entry.Kind on any given Type instance. + * + * Metadata classes of a specific kind are responsible for how they combine themselvs. + * + * @implNote {@code Entry:combine} need not be commutative. */ public class TypeMetadata { + public static final TypeMetadata EMPTY = new TypeMetadata(); - public static final TypeMetadata empty = new TypeMetadata(); - private final EnumMap contents; + private final EnumMap contents; + /** + * Create a new empty TypeMetadata map. + */ private TypeMetadata() { - contents = new EnumMap(Element.Kind.class); + contents = new EnumMap<>(Entry.Kind.class); } - public TypeMetadata(final Element elem) { + /** + * Create a new TypeMetadata map containing the Entry {@code elem}. + * + * @param elem the sole contents of this map + */ + public TypeMetadata(Entry elem) { this(); + Assert.checkNonNull(elem); contents.put(elem.kind(), elem); } - public TypeMetadata(final TypeMetadata other) { + /** + * Creates a copy of TypeMetadata {@code other} with a shallow copy the other's metadata contents. + * + * @param other the TypeMetadata to copy contents from. + */ + public TypeMetadata(TypeMetadata other) { + Assert.checkNonNull(other); contents = other.contents.clone(); } - public TypeMetadata copy() { - return new TypeMetadata(this); - } + /** + * Return a copy of this TypeMetadata with the metadata entry for {@code elem.kind()} combined + * with {@code elem}. + * + * @param elem the new value + * @return a new TypeMetadata updated with {@code Entry elem} + */ + public TypeMetadata combine(Entry elem) { + Assert.checkNonNull(elem); - public TypeMetadata combine(final Element elem) { - final TypeMetadata out = new TypeMetadata(this); - final Element.Kind key = elem.kind(); + TypeMetadata out = new TypeMetadata(this); + Entry.Kind key = elem.kind(); if (contents.containsKey(key)) { out.add(key, this.contents.get(key).combine(elem)); } else { @@ -78,17 +95,26 @@ public class TypeMetadata { return out; } - public TypeMetadata combine(final TypeMetadata other) { - final TypeMetadata out = new TypeMetadata(); - final Set keys = new HashSet<>(this.contents.keySet()); + /** + * Return a copy of this TypeMetadata with the metadata entry for all kinds from {@code other} + * combined with the same kind from this. + * + * @param other the TypeMetadata to combine with this + * @return a new TypeMetadata updated with all entries from {@code other} + */ + public TypeMetadata combineAll(TypeMetadata other) { + Assert.checkNonNull(other); + + TypeMetadata out = new TypeMetadata(); + Set keys = new HashSet<>(contents.keySet()); keys.addAll(other.contents.keySet()); - for(final Element.Kind key : keys) { - if (this.contents.containsKey(key)) { + for(Entry.Kind key : keys) { + if (contents.containsKey(key)) { if (other.contents.containsKey(key)) { - out.add(key, this.contents.get(key).combine(other.contents.get(key))); + out.add(key, contents.get(key).combine(other.contents.get(key))); } else { - out.add(key, this.contents.get(key)); + out.add(key, contents.get(key)); } } else if (other.contents.containsKey(key)) { out.add(key, other.contents.get(key)); @@ -97,26 +123,35 @@ public class TypeMetadata { return out; } - public Element get(final Element.Kind kind) { + /** + * Return a TypeMetadata with the metadata entry for {@code kind} removed. + * + * This may be the same instance or a new TypeMetadata. + * + * @param kind the {@code Kind} to remove metadata for + * @return a new TypeMetadata without {@code Kind kind} + */ + public TypeMetadata without(Entry.Kind kind) { + if (this == EMPTY || contents.get(kind) == null) + return this; + + TypeMetadata out = new TypeMetadata(this); + out.contents.remove(kind); + return out.contents.isEmpty() ? EMPTY : out; + } + + public Entry get(Entry.Kind kind) { return contents.get(kind); } - public boolean isEmpty() { - return contents.isEmpty(); - } - - private void add(final Element.Kind kind, final Element elem) { + private void add(Entry.Kind kind, Entry elem) { contents.put(kind, elem); } - private void addAll(final Map m) { - contents.putAll(m); - } - - public interface Element { + public interface Entry { public enum Kind { - ANNOTATIONS; + ANNOTATIONS } /** @@ -131,16 +166,18 @@ public class TypeMetadata { * @param other The metadata with which to combine this one. * @return The combined metadata. */ - public Element combine(Element other); + public Entry combine(Entry other); } /** * A type metadata object holding type annotations. */ - public static class Annotations implements Element { - private final List annos; + public static class Annotations implements Entry { + private List annos; - public Annotations(final List annos) { + public static final List TO_BE_SET = List.nil(); + + public Annotations(List annos) { this.annos = annos; } @@ -154,18 +191,16 @@ public class TypeMetadata { } @Override - public Annotations combine(final Element other) { - // Temporary: we should append the lists, but that won't - // work with type annotations today. Instead, we replace - // the list. - return new Annotations(((Annotations) other).annos); + public Annotations combine(Entry other) { + Assert.check(annos == TO_BE_SET); + annos = ((Annotations)other).annos; + return this; } @Override public Kind kind() { return Kind.ANNOTATIONS; } @Override - public String toString() { return "ANNOTATIONS { " + annos + " }"; } + public String toString() { return "ANNOTATIONS [ " + annos + " ]"; } } - } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java index 70ce0435abb..94c3d210e33 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java @@ -40,6 +40,7 @@ import javax.tools.JavaFileObject; import com.sun.tools.javac.code.Attribute.RetentionPolicy; import com.sun.tools.javac.code.Lint.LintCategory; import com.sun.tools.javac.code.Type.UndetVar.InferenceBound; +import com.sun.tools.javac.code.TypeMetadata.Entry.Kind; import com.sun.tools.javac.comp.AttrContext; import com.sun.tools.javac.comp.Check; import com.sun.tools.javac.comp.Enter; @@ -809,7 +810,7 @@ public class Types { return isSubtype(t, s, false); } public boolean isSubtype(Type t, Type s, boolean capture) { - if (t == s) + if (t.equalsIgnoreMetadata(s)) return true; if (s.isPartial()) return isSuperType(s, t); @@ -1081,14 +1082,11 @@ public class Types { isSameTypeStrict.visit(t, s) : isSameTypeLoose.visit(t, s); } - public boolean isSameAnnotatedType(Type t, Type s) { - return isSameAnnotatedType.visit(t, s); - } // where abstract class SameTypeVisitor extends TypeRelation { public Boolean visitType(Type t, Type s) { - if (t == s) + if (t.equalsIgnoreMetadata(s)) return true; if (s.isPartial()) @@ -1281,39 +1279,6 @@ public class Types { // - TypeRelation isSameAnnotatedType = new LooseSameTypeVisitor() { - private Boolean compareAnnotations(Type t1, Type t2) { - List annos1 = t1.getAnnotationMirrors(); - List annos2 = t2.getAnnotationMirrors(); - return annos1.containsAll(annos2) && annos2.containsAll(annos1); - } - - @Override - public Boolean visitType(Type t, Type s) { - return compareAnnotations(t, s) && super.visitType(t, s); - } - - @Override - public Boolean visitWildcardType(WildcardType t, Type s) { - return compareAnnotations(t, s) && super.visitWildcardType(t, s); - } - - @Override - public Boolean visitClassType(ClassType t, Type s) { - return compareAnnotations(t, s) && super.visitClassType(t, s); - } - - @Override - public Boolean visitArrayType(ArrayType t, Type s) { - return compareAnnotations(t, s) && super.visitArrayType(t, s); - } - - @Override - public Boolean visitForAll(ForAll t, Type s) { - return compareAnnotations(t, s) && super.visitForAll(t, s); - } - }; - // public boolean containedBy(Type t, Type s) { switch (t.getTag()) { @@ -2167,7 +2132,7 @@ public class Types { * type parameters in t are deleted. */ public Type erasure(Type t) { - return eraseNotNeeded(t)? t : erasure(t, false); + return eraseNotNeeded(t) ? t : erasure(t, false); } //where private boolean eraseNotNeeded(Type t) { @@ -2187,23 +2152,23 @@ public class Types { } // where private TypeMapping erasure = new TypeMapping() { - private Type combineMetadata(final Type ty, - final TypeMetadata md) { - if (!md.isEmpty()) { - switch (ty.getKind()) { - default: return ty.clone(ty.metadata.combine(md)); - case OTHER: - case UNION: - case INTERSECTION: - case PACKAGE: - case EXECUTABLE: - case NONE: - case VOID: - case ERROR: - return ty; + private Type combineMetadata(final Type s, + final Type t) { + if (t.getMetadata() != TypeMetadata.EMPTY) { + switch (s.getKind()) { + case OTHER: + case UNION: + case INTERSECTION: + case PACKAGE: + case EXECUTABLE: + case NONE: + case VOID: + case ERROR: + return s; + default: return s.cloneWithMetadata(s.getMetadata().without(Kind.ANNOTATIONS)); } } else { - return ty; + return s; } } @@ -2212,7 +2177,7 @@ public class Types { return t; /*fast special case*/ else { //other cases already handled - return combineMetadata(t, t.getMetadata()); + return combineMetadata(t, t); } } @@ -2220,17 +2185,18 @@ public class Types { public Type visitClassType(ClassType t, Boolean recurse) { Type erased = t.tsym.erasure(Types.this); if (recurse) { - erased = new ErasedClassType(erased.getEnclosingType(),erased.tsym, t.getMetadata()); + erased = new ErasedClassType(erased.getEnclosingType(),erased.tsym, + t.getMetadata().without(Kind.ANNOTATIONS)); return erased; } else { - return combineMetadata(erased, t.getMetadata()); + return combineMetadata(erased, t); } } @Override public Type visitTypeVar(TypeVar t, Boolean recurse) { Type erased = erasure(t.bound, recurse); - return combineMetadata(erased, t.getMetadata()); + return combineMetadata(erased, t); } }; @@ -2932,7 +2898,7 @@ public class Types { public List subst(List ts, List from, List to) { - return new Subst(from, to).subst(ts); + return ts.map(new Subst(from, to)); } /** @@ -2942,10 +2908,10 @@ public class Types { * elements of the longer list. */ public Type subst(Type t, List from, List to) { - return new Subst(from, to).subst(t); + return t.map(new Subst(from, to)); } - private class Subst extends UnaryVisitor { + private class Subst extends TypeMapping { List from; List to; @@ -2964,76 +2930,25 @@ public class Types { this.to = to; } - Type subst(Type t) { - if (from.tail == null) - return t; - else - return visit(t); - } - - List subst(List ts) { - if (from.tail == null) - return ts; - boolean wild = false; - if (ts.nonEmpty() && from.nonEmpty()) { - Type head1 = subst(ts.head); - List tail1 = subst(ts.tail); - if (head1 != ts.head || tail1 != ts.tail) - return tail1.prepend(head1); - } - return ts; - } - - public Type visitType(Type t, Void ignored) { - return t; - } - - @Override - public Type visitMethodType(MethodType t, Void ignored) { - List argtypes = subst(t.argtypes); - Type restype = subst(t.restype); - List thrown = subst(t.thrown); - if (argtypes == t.argtypes && - restype == t.restype && - thrown == t.thrown) - return t; - else - return new MethodType(argtypes, restype, thrown, t.tsym); - } - @Override public Type visitTypeVar(TypeVar t, Void ignored) { for (List from = this.from, to = this.to; from.nonEmpty(); from = from.tail, to = to.tail) { - if (t == from.head) { + if (t.equalsIgnoreMetadata(from.head)) { return to.head.withTypeVar(t); } } return t; } - @Override - public Type visitUndetVar(UndetVar t, Void ignored) { - //do nothing - we should not replace inside undet variables - return t; - } - @Override public Type visitClassType(ClassType t, Void ignored) { if (!t.isCompound()) { - List typarams = t.getTypeArguments(); - List typarams1 = subst(typarams); - Type outer = t.getEnclosingType(); - Type outer1 = subst(outer); - if (typarams1 == typarams && outer1 == outer) - return t; - else - return new ClassType(outer1, typarams1, t.tsym, - t.getMetadata()); + return super.visitClassType(t, ignored); } else { - Type st = subst(supertype(t)); - List is = subst(interfaces(t)); + Type st = visit(supertype(t)); + List is = visit(interfaces(t), ignored); if (st == supertype(t) && is == interfaces(t)) return t; else @@ -3043,26 +2958,11 @@ public class Types { @Override public Type visitWildcardType(WildcardType t, Void ignored) { - Type bound = t.type; - if (t.kind != BoundKind.UNBOUND) - bound = subst(bound); - if (bound == t.type) { - return t; - } else { - if (t.isExtendsBound() && bound.isExtendsBound()) - bound = wildUpperBound(bound); - return new WildcardType(bound, t.kind, syms.boundClass, - t.bound, t.getMetadata()); + WildcardType t2 = (WildcardType)super.visitWildcardType(t, ignored); + if (t2 != t && t.isExtendsBound() && t2.type.isExtendsBound()) { + t2.type = wildUpperBound(t2.type); } - } - - @Override - public Type visitArrayType(ArrayType t, Void ignored) { - Type elemtype = subst(t.elemtype); - if (elemtype == t.elemtype) - return t; - else - return new ArrayType(elemtype, t.tsym, t.getMetadata()); + return t2; } @Override @@ -3075,21 +2975,25 @@ public class Types { Types.this.subst(t.qtype, t.tvars, freevars)); } List tvars1 = substBounds(t.tvars, from, to); - Type qtype1 = subst(t.qtype); + Type qtype1 = visit(t.qtype); if (tvars1 == t.tvars && qtype1 == t.qtype) { return t; } else if (tvars1 == t.tvars) { - return new ForAll(tvars1, qtype1); + return new ForAll(tvars1, qtype1) { + @Override + public boolean needsStripping() { + return true; + } + }; } else { - return new ForAll(tvars1, - Types.this.subst(qtype1, t.tvars, tvars1)); + return new ForAll(tvars1, Types.this.subst(qtype1, t.tvars, tvars1)) { + @Override + public boolean needsStripping() { + return true; + } + }; } } - - @Override - public Type visitErrorType(ErrorType t, Void ignored) { - return t; - } } public List substBounds(List tvars, @@ -4232,8 +4136,7 @@ public class Types { } private boolean containsTypeEquivalent(Type t, Type s) { - return - isSameType(t, s) || // shortcut + return isSameType(t, s) || // shortcut containsType(t, s) && containsType(s, t); } @@ -4675,7 +4578,7 @@ public class Types { return getRetention(a.type.tsym); } - public RetentionPolicy getRetention(Symbol sym) { + public RetentionPolicy getRetention(TypeSymbol sym) { RetentionPolicy vis = RetentionPolicy.CLASS; // the default Attribute.Compound c = sym.attribute(syms.retentionType.tsym); if (c != null) { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java index 1eb1ab48808..f5975776fa2 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,6 +90,7 @@ public class Analyzer { final DeferredAttr deferredAttr; final TreeMaker make; final Names names; + private final boolean allowDiamondWithAnonymousClassCreation; final EnumSet analyzerModes; @@ -112,6 +113,7 @@ public class Analyzer { String findOpt = options.get("find"); //parse modes Source source = Source.instance(context); + allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation(); analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source); } @@ -210,7 +212,7 @@ public class Analyzer { boolean match(JCNewClass tree) { return tree.clazz.hasTag(TYPEAPPLY) && !TreeInfo.isDiamond(tree) && - tree.def == null; + (tree.def == null || allowDiamondWithAnonymousClassCreation); } @Override diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java index feadce3ad42..35fe5bb2b47 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,28 +25,39 @@ package com.sun.tools.javac.comp; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; +import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Attribute.Compound; +import com.sun.tools.javac.code.Attribute.TypeCompound; +import com.sun.tools.javac.code.Scope.WriteableScope; +import com.sun.tools.javac.code.Symbol.*; +import com.sun.tools.javac.code.TypeMetadata.Entry.Kind; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.*; +import com.sun.tools.javac.tree.TreeInfo; +import com.sun.tools.javac.tree.TreeMaker; +import com.sun.tools.javac.tree.TreeScanner; +import com.sun.tools.javac.util.*; +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; +import com.sun.tools.javac.util.List; import javax.tools.JavaFileObject; +import java.util.*; -import com.sun.tools.javac.util.*; -import com.sun.tools.javac.util.DefinedBy.Api; -import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.tree.*; -import com.sun.tools.javac.tree.JCTree.*; - -import static com.sun.tools.javac.code.Kinds.Kind.*; +import static com.sun.tools.javac.code.Flags.SYNTHETIC; +import static com.sun.tools.javac.code.Kinds.Kind.MTH; +import static com.sun.tools.javac.code.Kinds.Kind.VAR; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.ARRAY; import static com.sun.tools.javac.code.TypeTag.CLASS; -import static com.sun.tools.javac.tree.JCTree.Tag.*; +import static com.sun.tools.javac.tree.JCTree.Tag.ANNOTATION; +import static com.sun.tools.javac.tree.JCTree.Tag.ASSIGN; +import static com.sun.tools.javac.tree.JCTree.Tag.IDENT; +import static com.sun.tools.javac.tree.JCTree.Tag.NEWARRAY; -/** Enter annotations on symbols. Annotations accumulate in a queue, - * which is processed at the top level of any set of recursive calls - * requesting it be processed. +/** Enter annotations onto symbols and types (and trees). + * + * This is also a pseudo stage in the compiler taking care of scheduling when annotations are + * entered. * *

        This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. @@ -64,95 +75,98 @@ public class Annotate { } private final Attr attr; - private final TreeMaker make; - private final Log log; - private final Symtab syms; - private final Names names; - private final Resolve rs; - private final Types types; - private final ConstFold cfolder; private final Check chk; - private final Lint lint; + private final ConstFold cfolder; private final DeferredLintHandler deferredLintHandler; - private final Source source; + private final Enter enter; + private final Lint lint; + private final Log log; + private final Names names; + private final Resolve resolve; + private final TreeMaker make; + private final Symtab syms; + private final TypeEnvs typeEnvs; + private final Types types; - private boolean allowTypeAnnos; - private boolean allowRepeatedAnnos; + private final Attribute theUnfinishedDefaultValue; + private final boolean allowRepeatedAnnos; protected Annotate(Context context) { context.put(annotateKey, this); + attr = Attr.instance(context); - make = TreeMaker.instance(context); - log = Log.instance(context); - syms = Symtab.instance(context); - names = Names.instance(context); - rs = Resolve.instance(context); - types = Types.instance(context); - cfolder = ConstFold.instance(context); chk = Check.instance(context); - source = Source.instance(context); - lint = Lint.instance(context); + cfolder = ConstFold.instance(context); deferredLintHandler = DeferredLintHandler.instance(context); + enter = Enter.instance(context); + log = Log.instance(context); + lint = Lint.instance(context); + make = TreeMaker.instance(context); + names = Names.instance(context); + resolve = Resolve.instance(context); + syms = Symtab.instance(context); + typeEnvs = TypeEnvs.instance(context); + types = Types.instance(context); + + theUnfinishedDefaultValue = new Attribute.Error(syms.errType); + + Source source = Source.instance(context); allowRepeatedAnnos = source.allowRepeatedAnnotations(); - allowTypeAnnos = source.allowTypeAnnotations(); } -/* ******************************************************************** - * Queue maintenance - *********************************************************************/ + /** Semaphore to delay annotation processing */ + private int blockCount = 0; - private int enterCount = 0; - - ListBuffer q = new ListBuffer<>(); - ListBuffer typesQ = new ListBuffer<>(); - ListBuffer repeatedQ = new ListBuffer<>(); - ListBuffer afterRepeatedQ = new ListBuffer<>(); - ListBuffer validateQ = new ListBuffer<>(); - - public void earlier(Worker a) { - q.prepend(a); + /** Called when annotations processing needs to be postponed. */ + public void blockAnnotations() { + blockCount++; } - public void normal(Worker a) { - q.append(a); - } - - public void typeAnnotation(Worker a) { - typesQ.append(a); - } - - public void repeated(Worker a) { - repeatedQ.append(a); - } - - public void afterRepeated(Worker a) { - afterRepeatedQ.append(a); - } - - public void validate(Worker a) { - validateQ.append(a); - } - - /** Called when the Enter phase starts. */ - public void enterStart() { - enterCount++; - } - - /** Called after the Enter phase completes. */ - public void enterDone() { - enterCount--; - flush(); + /** Called when annotation processing can be resumed. */ + public void unblockAnnotations() { + blockCount--; + if (blockCount == 0) + flush(); } /** Variant which allows for a delayed flush of annotations. * Needed by ClassReader */ - public void enterDoneWithoutFlush() { - enterCount--; + public void unblockAnnotationsNoFlush() { + blockCount--; } + /** are we blocking annotation processing? */ + public boolean annotationsBlocked() {return blockCount > 0; } + + public List fromAnnotations(List annotations) { + if (annotations.isEmpty()) { + return List.nil(); + } + + ListBuffer buf = new ListBuffer<>(); + for (JCAnnotation anno : annotations) { + Assert.checkNonNull(anno.attribute); + buf.append((TypeCompound) anno.attribute); + } + return buf.toList(); + } + + /** Annotate (used for everything else) */ + public void normal(Runnable r) { + q.append(r); + } + + /** Validate, triggers after 'normal' */ + public void validate(Runnable a) { + validateQ.append(a); + } + + /** Flush all annotation queues */ public void flush() { - if (enterCount != 0) return; - enterCount++; + if (annotationsBlocked()) return; + if (isFlushing()) return; + + startFlushing(); try { while (q.nonEmpty()) { q.next().run(); @@ -160,35 +174,502 @@ public class Annotate { while (typesQ.nonEmpty()) { typesQ.next().run(); } - while (repeatedQ.nonEmpty()) { - repeatedQ.next().run(); - } - while (afterRepeatedQ.nonEmpty()) { - afterRepeatedQ.next().run(); + while (afterTypesQ.nonEmpty()) { + afterTypesQ.next().run(); } while (validateQ.nonEmpty()) { validateQ.next().run(); } } finally { - enterCount--; + doneFlushing(); } } - /** A client that needs to run during {@link #flush()} registers an worker - * into one of the queues defined in this class. The queues are: {@link #earlier(Worker)}, - * {@link #normal(Worker)}, {@link #typeAnnotation(Worker)}, {@link #repeated(Worker)}, - * {@link #afterRepeated(Worker)}, {@link #validate(Worker)}. - * The {@link Worker#run()} method will called inside the {@link #flush()} - * call. Queues are empties in the abovementioned order. - */ - public interface Worker { - void run(); - String toString(); + private ListBuffer q = new ListBuffer<>(); + private ListBuffer validateQ = new ListBuffer<>(); + + private int flushCount = 0; + private boolean isFlushing() { return flushCount > 0; } + private void startFlushing() { flushCount++; } + private void doneFlushing() { flushCount--; } + + ListBuffer typesQ = new ListBuffer<>(); + ListBuffer afterTypesQ = new ListBuffer<>(); + + + public void typeAnnotation(Runnable a) { + typesQ.append(a); + } + + public void afterTypes(Runnable a) { + afterTypesQ.append(a); } + /** + * Queue annotations for later attribution and entering. This is probably the method you are looking for. + * + * @param annotations the list of JCAnnotations to attribute and enter + * @param localEnv the enclosing env + * @param s ths Symbol on which to enter the annotations + * @param deferPos report errors here + */ + public void annotateLater(List annotations, Env localEnv, + Symbol s, DiagnosticPosition deferPos) + { + if (annotations.isEmpty()) { + return; + } + + s.resetAnnotations(); // mark Annotations as incomplete for now + + normal(new Runnable() { + @Override + public String toString() { + return "Annotate " + annotations + " onto " + s + " in " + s.owner; + } + + @Override + public void run() { + Assert.check(s.annotationsPendingCompletion()); + JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); + DiagnosticPosition prevLintPos = + deferPos != null + ? deferredLintHandler.setPos(deferPos) + : deferredLintHandler.immediate(); + Lint prevLint = deferPos != null ? null : chk.setLint(lint); + try { + if (s.hasAnnotations() && annotations.nonEmpty()) + log.error(annotations.head.pos, "already.annotated", Kinds.kindName(s), s); + + Assert.checkNonNull(s, "Symbol argument to actualEnterAnnotations is null"); + annotateNow(s, annotations, localEnv, false); + } finally { + if (prevLint != null) + chk.setLint(prevLint); + deferredLintHandler.setPos(prevLintPos); + log.useSource(prev); + } + } + }); + + validate(new Runnable() { //validate annotations + @Override + public void run() { + JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); + try { + chk.validateAnnotations(annotations, s); + } finally { + log.useSource(prev); + } + } + + @Override + public String toString() { + return "validate annotations: " + annotations + " on " + s; + } + }); + } + + + /** Queue processing of an attribute default value. */ + public void annotateDefaultValueLater(JCExpression defaultValue, Env localEnv, + MethodSymbol m, DiagnosticPosition deferPos) + { + normal(new Runnable() { + @Override + public void run() { + JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); + DiagnosticPosition prevLintPos = deferredLintHandler.setPos(deferPos); + try { + enterDefaultValue(defaultValue, localEnv, m); + } finally { + deferredLintHandler.setPos(prevLintPos); + log.useSource(prev); + } + } + + @Override + public String toString() { + return "Annotate " + m.owner + "." + + m + " default " + defaultValue; + } + }); + + validate(new Runnable() { //validate annotations + @Override + public void run() { + JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); + try { + // if default value is an annotation, check it is a well-formed + // annotation value (e.g. no duplicate values, no missing values, etc.) + chk.validateAnnotationTree(defaultValue); + } finally { + log.useSource(prev); + } + } + + @Override + public String toString() { + return "Validate default value " + m.owner + "." + m + " default " + defaultValue; + } + }); + } + + /** Enter a default value for an annotation element. */ + private void enterDefaultValue(JCExpression defaultValue, + Env localEnv, MethodSymbol m) { + m.defaultValue = attributeAnnotationValue(m.type.getReturnType(), defaultValue, localEnv); + } + + /** + * Gather up annotations into a map from type symbols to lists of Compound attributes, + * then continue on with repeating annotations processing. + */ + private void annotateNow(Symbol toAnnotate, + List withAnnotations, Env env, boolean typeAnnotations) + { + Map> annotated = new LinkedHashMap<>(); + Map pos = new HashMap<>(); + boolean allowRepeatedAnnos = this.allowRepeatedAnnos; + + for (List al = withAnnotations; !al.isEmpty(); al = al.tail) { + JCAnnotation a = al.head; + + T c; + if (typeAnnotations) { + @SuppressWarnings("unchecked") + T tmp = (T)attributeTypeAnnotation(a, syms.annotationType, env); + c = tmp; + } else { + @SuppressWarnings("unchecked") + T tmp = (T)attributeAnnotation(a, syms.annotationType, env); + c = tmp; + } + + Assert.checkNonNull(c, "Failed to create annotation"); + + if (annotated.containsKey(a.type.tsym)) { + if (!allowRepeatedAnnos) { + log.error(a.pos(), "repeatable.annotations.not.supported.in.source"); + allowRepeatedAnnos = true; + } + ListBuffer l = annotated.get(a.type.tsym); + l = l.append(c); + annotated.put(a.type.tsym, l); + pos.put(c, a.pos()); + } else { + annotated.put(a.type.tsym, ListBuffer.of(c)); + pos.put(c, a.pos()); + } + + // Note: @Deprecated has no effect on local variables and parameters + if (!c.type.isErroneous() + && toAnnotate.owner.kind != MTH + && types.isSameType(c.type, syms.deprecatedType)) { + toAnnotate.flags_field |= Flags.DEPRECATED; + } + } + + List buf = List.nil(); + for (ListBuffer lb : annotated.values()) { + if (lb.size() == 1) { + buf = buf.prepend(lb.first()); + } else { + AnnotationContext ctx = new AnnotationContext<>(env, annotated, pos, typeAnnotations); + T res = makeContainerAnnotation(lb.toList(), ctx, toAnnotate); + if (res != null) + buf = buf.prepend(res); + } + } + + if (typeAnnotations) { + @SuppressWarnings("unchecked") + List attrs = (List)buf.reverse(); + toAnnotate.appendUniqueTypeAttributes(attrs); + } else { + @SuppressWarnings("unchecked") + List attrs = (List)buf.reverse(); + toAnnotate.resetAnnotations(); + toAnnotate.setDeclarationAttributes(attrs); + } + } + + /** + * Attribute and store a semantic representation of the annotation tree {@code tree} into the + * tree.attribute field. + * + * @param tree the tree representing an annotation + * @param expectedAnnotationType the expected (super)type of the annotation + * @param env the current env in where the annotation instance is found + */ + public Attribute.Compound attributeAnnotation(JCAnnotation tree, Type expectedAnnotationType, + Env env) + { + // The attribute might have been entered if it is Target or Repetable + // Because TreeCopier does not copy type, redo this if type is null + if (tree.attribute != null && tree.type != null) + return tree.attribute; + + List> elems = attributeAnnotationValues(tree, expectedAnnotationType, env); + Attribute.Compound ac = new Attribute.Compound(tree.type, elems); + + return tree.attribute = ac; + } + + /** Attribute and store a semantic representation of the type annotation tree {@code tree} into + * the tree.attribute field. + * + * @param a the tree representing an annotation + * @param expectedAnnotationType the expected (super)type of the annotation + * @param env the the current env in where the annotation instance is found + */ + public Attribute.TypeCompound attributeTypeAnnotation(JCAnnotation a, Type expectedAnnotationType, + Env env) + { + // The attribute might have been entered if it is Target or Repetable + // Because TreeCopier does not copy type, redo this if type is null + if (a.attribute == null || a.type == null || !(a.attribute instanceof Attribute.TypeCompound)) { + // Create a new TypeCompound + List> elems = + attributeAnnotationValues(a, expectedAnnotationType, env); + + Attribute.TypeCompound tc = + new Attribute.TypeCompound(a.type, elems, TypeAnnotationPosition.unknown); + a.attribute = tc; + return tc; + } else { + // Use an existing TypeCompound + return (Attribute.TypeCompound)a.attribute; + } + } + + /** + * Attribute annotation elements creating a list of pairs of the Symbol representing that + * element and the value of that element as an Attribute. */ + private List> attributeAnnotationValues(JCAnnotation a, + Type expected, Env env) + { + // The annotation might have had its type attributed (but not + // checked) by attr.attribAnnotationTypes during MemberEnter, + // in which case we do not need to do it again. + Type at = (a.annotationType.type != null ? + a.annotationType.type : attr.attribType(a.annotationType, env)); + a.type = chk.checkType(a.annotationType.pos(), at, expected); + + boolean isError = a.type.isErroneous(); + if (!a.type.tsym.isAnnotationType() && !isError) { + log.error(a.annotationType.pos(), + "not.annotation.type", a.type.toString()); + isError = true; + } + + // List of name=value pairs (or implicit "value=" if size 1) + List args = a.args; + + boolean elidedValue = false; + // special case: elided "value=" assumed + if (args.length() == 1 && !args.head.hasTag(ASSIGN)) { + args.head = make.at(args.head.pos). + Assign(make.Ident(names.value), args.head); + elidedValue = true; + } + + ListBuffer> buf = new ListBuffer<>(); + for (List tl = args; tl.nonEmpty(); tl = tl.tail) { + Pair p = attributeAnnotationNameValuePair(tl.head, a.type, isError, env, elidedValue); + if (p != null && !p.fst.type.isErroneous()) + buf.append(p); + } + return buf.toList(); + } + + // where + private Pair attributeAnnotationNameValuePair(JCExpression nameValuePair, + Type thisAnnotationType, boolean badAnnotation, Env env, boolean elidedValue) + { + if (!nameValuePair.hasTag(ASSIGN)) { + log.error(nameValuePair.pos(), "annotation.value.must.be.name.value"); + attributeAnnotationValue(nameValuePair.type = syms.errType, nameValuePair, env); + return null; + } + JCAssign assign = (JCAssign)nameValuePair; + if (!assign.lhs.hasTag(IDENT)) { + log.error(nameValuePair.pos(), "annotation.value.must.be.name.value"); + attributeAnnotationValue(nameValuePair.type = syms.errType, nameValuePair, env); + return null; + } + + // Resolve element to MethodSym + JCIdent left = (JCIdent)assign.lhs; + Symbol method = resolve.resolveQualifiedMethod(elidedValue ? assign.rhs.pos() : left.pos(), + env, thisAnnotationType, + left.name, List.nil(), null); + left.sym = method; + left.type = method.type; + if (method.owner != thisAnnotationType.tsym && !badAnnotation) + log.error(left.pos(), "no.annotation.member", left.name, thisAnnotationType); + Type resultType = method.type.getReturnType(); + + // Compute value part + Attribute value = attributeAnnotationValue(resultType, assign.rhs, env); + nameValuePair.type = resultType; + + return method.type.isErroneous() ? null : new Pair<>((MethodSymbol)method, value); + + } + + /** Attribute an annotation element value */ + private Attribute attributeAnnotationValue(Type expectedElementType, JCExpression tree, + Env env) + { + //first, try completing the symbol for the annotation value - if acompletion + //error is thrown, we should recover gracefully, and display an + //ordinary resolution diagnostic. + try { + expectedElementType.tsym.complete(); + } catch(CompletionFailure e) { + log.error(tree.pos(), "cant.resolve", Kinds.kindName(e.sym), e.sym); + expectedElementType = syms.errType; + } + + if (expectedElementType.hasTag(ARRAY)) { + return getAnnotationArrayValue(expectedElementType, tree, env); + + } + + //error recovery + if (tree.hasTag(NEWARRAY)) { + if (!expectedElementType.isErroneous()) + log.error(tree.pos(), "annotation.value.not.allowable.type"); + JCNewArray na = (JCNewArray)tree; + if (na.elemtype != null) { + log.error(na.elemtype.pos(), "new.not.allowed.in.annotation"); + } + for (List l = na.elems; l.nonEmpty(); l=l.tail) { + attributeAnnotationValue(syms.errType, + l.head, + env); + } + return new Attribute.Error(syms.errType); + } + + if (expectedElementType.tsym.isAnnotationType()) { + if (tree.hasTag(ANNOTATION)) { + return attributeAnnotation((JCAnnotation)tree, expectedElementType, env); + } else { + log.error(tree.pos(), "annotation.value.must.be.annotation"); + expectedElementType = syms.errType; + } + } + + //error recovery + if (tree.hasTag(ANNOTATION)) { + if (!expectedElementType.isErroneous()) + log.error(tree.pos(), "annotation.not.valid.for.type", expectedElementType); + attributeAnnotation((JCAnnotation)tree, syms.errType, env); + return new Attribute.Error(((JCAnnotation)tree).annotationType.type); + } + + if (expectedElementType.isPrimitive() || + (types.isSameType(expectedElementType, syms.stringType) && !expectedElementType.hasTag(TypeTag.ERROR))) { + return getAnnotationPrimitiveValue(expectedElementType, tree, env); + } + + if (expectedElementType.tsym == syms.classType.tsym) { + return getAnnotationClassValue(expectedElementType, tree, env); + } + + if (expectedElementType.hasTag(CLASS) && + (expectedElementType.tsym.flags() & Flags.ENUM) != 0) { + return getAnnotationEnumValue(expectedElementType, tree, env); + } + + //error recovery: + if (!expectedElementType.isErroneous()) + log.error(tree.pos(), "annotation.value.not.allowable.type"); + return new Attribute.Error(attr.attribExpr(tree, env, expectedElementType)); + } + + private Attribute getAnnotationEnumValue(Type expectedElementType, JCExpression tree, Env env) { + Type result = attr.attribExpr(tree, env, expectedElementType); + Symbol sym = TreeInfo.symbol(tree); + if (sym == null || + TreeInfo.nonstaticSelect(tree) || + sym.kind != VAR || + (sym.flags() & Flags.ENUM) == 0) { + log.error(tree.pos(), "enum.annotation.must.be.enum.constant"); + return new Attribute.Error(result.getOriginalType()); + } + VarSymbol enumerator = (VarSymbol) sym; + return new Attribute.Enum(expectedElementType, enumerator); + } + + private Attribute getAnnotationClassValue(Type expectedElementType, JCExpression tree, Env env) { + Type result = attr.attribExpr(tree, env, expectedElementType); + if (result.isErroneous()) { + // Does it look like an unresolved class literal? + if (TreeInfo.name(tree) == names._class && + ((JCFieldAccess) tree).selected.type.isErroneous()) { + Name n = (((JCFieldAccess) tree).selected).type.tsym.flatName(); + return new Attribute.UnresolvedClass(expectedElementType, + types.createErrorType(n, + syms.unknownSymbol, syms.classType)); + } else { + return new Attribute.Error(result.getOriginalType()); + } + } + + // Class literals look like field accesses of a field named class + // at the tree level + if (TreeInfo.name(tree) != names._class) { + log.error(tree.pos(), "annotation.value.must.be.class.literal"); + return new Attribute.Error(syms.errType); + } + return new Attribute.Class(types, + (((JCFieldAccess) tree).selected).type); + } + + private Attribute getAnnotationPrimitiveValue(Type expectedElementType, JCExpression tree, Env env) { + Type result = attr.attribExpr(tree, env, expectedElementType); + if (result.isErroneous()) + return new Attribute.Error(result.getOriginalType()); + if (result.constValue() == null) { + log.error(tree.pos(), "attribute.value.must.be.constant"); + return new Attribute.Error(expectedElementType); + } + result = cfolder.coerce(result, expectedElementType); + return new Attribute.Constant(expectedElementType, result.constValue()); + } + + private Attribute getAnnotationArrayValue(Type expectedElementType, JCExpression tree, Env env) { + // Special case, implicit array + if (!tree.hasTag(NEWARRAY)) { + tree = make.at(tree.pos). + NewArray(null, List.nil(), List.of(tree)); + } + + JCNewArray na = (JCNewArray)tree; + if (na.elemtype != null) { + log.error(na.elemtype.pos(), "new.not.allowed.in.annotation"); + } + ListBuffer buf = new ListBuffer<>(); + for (List l = na.elems; l.nonEmpty(); l=l.tail) { + buf.append(attributeAnnotationValue(types.elemtype(expectedElementType), + l.head, + env)); + } + na.type = expectedElementType; + return new Attribute. + Array(expectedElementType, buf.toArray(new Attribute[buf.length()])); + } + + /* ********************************* + * Support for repeating annotations + ***********************************/ + /** * This context contains all the information needed to synthesize new - * annotations trees by the completer for repeating annotations. + * annotations trees for repeating annotations. */ private class AnnotationContext { public final Env env; @@ -209,280 +690,15 @@ public class Annotate { this.pos = pos; this.isTypeCompound = isTypeCompound; } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("RepeatedContext["); - for (Map.Entry> entry : - annotated.entrySet()) { - sb.append(" "); - sb.append(entry.getKey()); - sb.append(" = { "); - sb.append(entry.getValue()); - sb.append(" }"); - } - sb.append(" ]"); - return sb.toString(); - } } - private static class Placeholder extends Attribute.Compound { - - private final Annotate.AnnotationContext ctx; - private final List placeholderFor; - private final Symbol on; - - public Placeholder(Annotate.AnnotationContext ctx, - List placeholderFor, Symbol on) { - super(on.type, List.>nil(), - placeholderFor.head.position); - this.ctx = ctx; - this.placeholderFor = placeholderFor; - this.on = on; - } - - @Override @DefinedBy(Api.LANGUAGE_MODEL) - public String toString() { - return ""; - } - - public List getPlaceholderFor() { - return placeholderFor; - } - - public Annotate.AnnotationContext getRepeatedContext() { - return ctx; - } - } - - -/* ******************************************************************** - * Compute an attribute from its annotation. - *********************************************************************/ - - /** Process a single compound annotation, returning its - * Attribute. Used from MemberEnter for attaching the attributes - * to the annotated symbol. - */ - Attribute.Compound enterAnnotation(JCAnnotation a, - Type expected, - Env env) { - List> elems = - enterAttributeValues(a, expected, env); - Attribute.Compound ac = new Attribute.Compound(a.type, elems); - a.attribute = ac; - - return ac; - } - - Attribute.TypeCompound enterTypeAnnotation(JCAnnotation a, - Type expected, - Env env) { - List> elems = - enterAttributeValues(a, expected, env); - - if (a.attribute == null || !(a.attribute instanceof Attribute.TypeCompound)) { - // Create a new TypeCompound - - Attribute.TypeCompound tc = - new Attribute.TypeCompound(a.type, elems, - // TODO: Eventually, we will get rid of this use of - // unknown, because we'll get a position from - // MemberEnter (task 8027262). - TypeAnnotationPosition.unknown); - a.attribute = tc; - return tc; - } else { - // Use an existing TypeCompound - return (Attribute.TypeCompound)a.attribute; - } - } - - private List> - enterAttributeValues(JCAnnotation a, - Type expected, - Env env) { - // The annotation might have had its type attributed (but not - // checked) by attr.attribAnnotationTypes during MemberEnter, - // in which case we do not need to do it again. - Type at = (a.annotationType.type != null ? a.annotationType.type - : attr.attribType(a.annotationType, env)); - a.type = chk.checkType(a.annotationType.pos(), at, expected); - boolean isError = a.type.isErroneous(); - if ((a.type.tsym.flags() & Flags.ANNOTATION) == 0 && !isError) { - log.error(a.annotationType.pos(), - "not.annotation.type", a.type.toString()); - isError = true; - } - List args = a.args; - boolean elidedValue = false; - if (args.length() == 1 && !args.head.hasTag(ASSIGN)) { - // special case: elided "value=" assumed - elidedValue = true; - args.head = make.at(args.head.pos). - Assign(make.Ident(names.value), args.head); - } - ListBuffer> buf = - new ListBuffer<>(); - for (List tl = args; tl.nonEmpty(); tl = tl.tail) { - JCExpression t = tl.head; - if (!t.hasTag(ASSIGN)) { - log.error(t.pos(), "annotation.value.must.be.name.value"); - enterAttributeValue(t.type = syms.errType, t, env); - continue; - } - JCAssign assign = (JCAssign)t; - if (!assign.lhs.hasTag(IDENT)) { - log.error(t.pos(), "annotation.value.must.be.name.value"); - enterAttributeValue(t.type = syms.errType, t, env); - continue; - } - JCIdent left = (JCIdent)assign.lhs; - Symbol method = rs.resolveQualifiedMethod(elidedValue ? assign.rhs.pos() : left.pos(), - env, - a.type, - left.name, - List.nil(), - null); - left.sym = method; - left.type = method.type; - if (method.owner != a.type.tsym && !isError) - log.error(left.pos(), "no.annotation.member", left.name, a.type); - Type result = method.type.getReturnType(); - Attribute value = enterAttributeValue(result, assign.rhs, env); - if (!method.type.isErroneous()) - buf.append(new Pair<>((MethodSymbol)method, value)); - t.type = result; - } - return buf.toList(); - } - - Attribute enterAttributeValue(Type expected, - JCExpression tree, - Env env) { - //first, try completing the attribution value sym - if a completion - //error is thrown, we should recover gracefully, and display an - //ordinary resolution diagnostic. - try { - expected.tsym.complete(); - } catch(CompletionFailure e) { - log.error(tree.pos(), "cant.resolve", Kinds.kindName(e.sym), e.sym); - expected = syms.errType; - } - if (expected.hasTag(ARRAY)) { - if (!tree.hasTag(NEWARRAY)) { - tree = make.at(tree.pos). - NewArray(null, List.nil(), List.of(tree)); - } - JCNewArray na = (JCNewArray)tree; - if (na.elemtype != null) { - log.error(na.elemtype.pos(), "new.not.allowed.in.annotation"); - } - ListBuffer buf = new ListBuffer<>(); - for (List l = na.elems; l.nonEmpty(); l=l.tail) { - buf.append(enterAttributeValue(types.elemtype(expected), - l.head, - env)); - } - na.type = expected; - return new Attribute. - Array(expected, buf.toArray(new Attribute[buf.length()])); - } - if (tree.hasTag(NEWARRAY)) { //error recovery - if (!expected.isErroneous()) - log.error(tree.pos(), "annotation.value.not.allowable.type"); - JCNewArray na = (JCNewArray)tree; - if (na.elemtype != null) { - log.error(na.elemtype.pos(), "new.not.allowed.in.annotation"); - } - for (List l = na.elems; l.nonEmpty(); l=l.tail) { - enterAttributeValue(syms.errType, - l.head, - env); - } - return new Attribute.Error(syms.errType); - } - if ((expected.tsym.flags() & Flags.ANNOTATION) != 0) { - if (tree.hasTag(ANNOTATION)) { - return enterAnnotation((JCAnnotation)tree, expected, env); - } else { - log.error(tree.pos(), "annotation.value.must.be.annotation"); - expected = syms.errType; - } - } - if (tree.hasTag(ANNOTATION)) { //error recovery - if (!expected.isErroneous()) - log.error(tree.pos(), "annotation.not.valid.for.type", expected); - enterAnnotation((JCAnnotation)tree, syms.errType, env); - return new Attribute.Error(((JCAnnotation)tree).annotationType.type); - } - if (expected.isPrimitive() || - (types.isSameType(expected, syms.stringType) && !expected.hasTag(TypeTag.ERROR))) { - Type result = attr.attribExpr(tree, env, expected); - if (result.isErroneous()) - return new Attribute.Error(result.getOriginalType()); - if (result.constValue() == null) { - log.error(tree.pos(), "attribute.value.must.be.constant"); - return new Attribute.Error(expected); - } - result = cfolder.coerce(result, expected); - return new Attribute.Constant(expected, result.constValue()); - } - if (expected.tsym == syms.classType.tsym) { - Type result = attr.attribExpr(tree, env, expected); - if (result.isErroneous()) { - // Does it look like an unresolved class literal? - if (TreeInfo.name(tree) == names._class && - ((JCFieldAccess) tree).selected.type.isErroneous()) { - Name n = (((JCFieldAccess) tree).selected).type.tsym.flatName(); - return new Attribute.UnresolvedClass(expected, - types.createErrorType(n, - syms.unknownSymbol, syms.classType)); - } else { - return new Attribute.Error(result.getOriginalType()); - } - } - - // Class literals look like field accesses of a field named class - // at the tree level - if (TreeInfo.name(tree) != names._class) { - log.error(tree.pos(), "annotation.value.must.be.class.literal"); - return new Attribute.Error(syms.errType); - } - return new Attribute.Class(types, - (((JCFieldAccess) tree).selected).type); - } - if (expected.hasTag(CLASS) && - (expected.tsym.flags() & Flags.ENUM) != 0) { - Type result = attr.attribExpr(tree, env, expected); - Symbol sym = TreeInfo.symbol(tree); - if (sym == null || - TreeInfo.nonstaticSelect(tree) || - sym.kind != VAR || - (sym.flags() & Flags.ENUM) == 0) { - log.error(tree.pos(), "enum.annotation.must.be.enum.constant"); - return new Attribute.Error(result.getOriginalType()); - } - VarSymbol enumerator = (VarSymbol) sym; - return new Attribute.Enum(expected, enumerator); - } - //error recovery: - if (!expected.isErroneous()) - log.error(tree.pos(), "annotation.value.not.allowable.type"); - return new Attribute.Error(attr.attribExpr(tree, env, expected)); - } - - /* ********************************* - * Support for repeating annotations - ***********************************/ - /* Process repeated annotations. This method returns the * synthesized container annotation or null IFF all repeating * annotation are invalid. This method reports errors/warnings. */ private T processRepeatedAnnotations(List annotations, - AnnotationContext ctx, - Symbol on) { + AnnotationContext ctx, Symbol on) + { T firstOccurrence = annotations.head; List repeated = List.nil(); Type origAnnoType = null; @@ -490,14 +706,10 @@ public class Annotate { Type targetContainerType = null; MethodSymbol containerValueSymbol = null; - Assert.check(!annotations.isEmpty() && - !annotations.tail.isEmpty()); // i.e. size() > 1 + Assert.check(!annotations.isEmpty() && !annotations.tail.isEmpty()); // i.e. size() > 1 int count = 0; - for (List al = annotations; - !al.isEmpty(); - al = al.tail) - { + for (List al = annotations; !al.isEmpty(); al = al.tail) { count++; // There must be more than a single anno in the annotation list @@ -532,18 +744,23 @@ public class Annotate { repeated = repeated.prepend(currentAnno); } + if (!repeated.isEmpty() && targetContainerType == null) { + log.error(ctx.pos.get(annotations.head), "duplicate.annotation.invalid.repeated", origAnnoType); + return null; + } + if (!repeated.isEmpty()) { repeated = repeated.reverse(); TreeMaker m = make.at(ctx.pos.get(firstOccurrence)); Pair p = new Pair(containerValueSymbol, - new Attribute.Array(arrayOfOrigAnnoType, repeated)); + new Attribute.Array(arrayOfOrigAnnoType, repeated)); if (ctx.isTypeCompound) { /* TODO: the following code would be cleaner: Attribute.TypeCompound at = new Attribute.TypeCompound(targetContainerType, List.of(p), ((Attribute.TypeCompound)annotations.head).position); JCTypeAnnotation annoTree = m.TypeAnnotation(at); - at = enterTypeAnnotation(annoTree, targetContainerType, ctx.env); + at = attributeTypeAnnotation(annoTree, targetContainerType, ctx.env); */ // However, we directly construct the TypeCompound to keep the // direct relation to the contained TypeCompounds. @@ -562,12 +779,13 @@ public class Annotate { JCAnnotation annoTree = m.Annotation(c); if (!chk.annotationApplicable(annoTree, on)) - log.error(annoTree.pos(), "invalid.repeatable.annotation.incompatible.target", targetContainerType, origAnnoType); + log.error(annoTree.pos(), "invalid.repeatable.annotation.incompatible.target", + targetContainerType, origAnnoType); if (!chk.validateAnnotationDeferErrors(annoTree)) log.error(annoTree.pos(), "duplicate.annotation.invalid.repeated", origAnnoType); - c = enterAnnotation(annoTree, targetContainerType, ctx.env); + c = attributeAnnotation(annoTree, targetContainerType, ctx.env); c.setSynthesized(true); @SuppressWarnings("unchecked") @@ -579,17 +797,19 @@ public class Annotate { } } - /** Fetches the actual Type that should be the containing annotation. */ + /** + * Fetches the actual Type that should be the containing annotation. + */ private Type getContainingType(Attribute.Compound currentAnno, - DiagnosticPosition pos, - boolean reportError) + DiagnosticPosition pos, + boolean reportError) { Type origAnnoType = currentAnno.type; TypeSymbol origAnnoDecl = origAnnoType.tsym; // Fetch the Repeatable annotation from the current // annotation's declaration, or null if it has none - Attribute.Compound ca = origAnnoDecl.attribute(syms.repeatableType.tsym); + Attribute.Compound ca = origAnnoDecl.getAnnotationTypeMetadata().getRepeatable(); if (ca == null) { // has no Repeatable annotation if (reportError) log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.repeatableType); @@ -597,7 +817,7 @@ public class Annotate { } return filterSame(extractContainingType(ca, pos, origAnnoDecl), - origAnnoType); + origAnnoType); } // returns null if t is same as 's', returns 't' otherwise @@ -611,8 +831,8 @@ public class Annotate { /** Extract the actual Type to be used for a containing annotation. */ private Type extractContainingType(Attribute.Compound ca, - DiagnosticPosition pos, - TypeSymbol annoDecl) + DiagnosticPosition pos, + TypeSymbol annoDecl) { // The next three checks check that the Repeatable annotation // on the declaration of the annotation type that is repeating is @@ -657,7 +877,7 @@ public class Annotate { nr_value_elems++; if (nr_value_elems == 1 && - elm.kind == MTH) { + elm.kind == MTH) { containerValueSymbol = (MethodSymbol)elm; } else { error = true; @@ -665,14 +885,14 @@ public class Annotate { } if (error) { log.error(pos, - "invalid.repeatable.annotation.multiple.values", - targetContainerType, - nr_value_elems); + "invalid.repeatable.annotation.multiple.values", + targetContainerType, + nr_value_elems); return null; } else if (nr_value_elems == 0) { log.error(pos, - "invalid.repeatable.annotation.no.value", - targetContainerType); + "invalid.repeatable.annotation.no.value", + targetContainerType); return null; } @@ -680,8 +900,8 @@ public class Annotate { // probably "impossible" to fail this if (containerValueSymbol.kind != MTH) { log.error(pos, - "invalid.repeatable.annotation.invalid.value", - targetContainerType); + "invalid.repeatable.annotation.invalid.value", + targetContainerType); fatalError = true; } @@ -690,174 +910,24 @@ public class Annotate { Type valueRetType = containerValueSymbol.type.getReturnType(); Type expectedType = types.makeArrayType(originalAnnoType); if (!(types.isArray(valueRetType) && - types.isSameType(expectedType, valueRetType))) { + types.isSameType(expectedType, valueRetType))) { log.error(pos, - "invalid.repeatable.annotation.value.return", - targetContainerType, - valueRetType, - expectedType); + "invalid.repeatable.annotation.value.return", + targetContainerType, + valueRetType, + expectedType); fatalError = true; } - if (error) { - fatalError = true; - } - - // The conditions for a valid containing annotation are made - // in Check.validateRepeatedAnnotaton(); return fatalError ? null : containerValueSymbol; } - private AnnotationContext - prepareEnterAnnotations(List annotations, - Env env, - Symbol sym, - AttributeCreator creator, - boolean isTypeCompound) { - Map> annotated = new LinkedHashMap<>(); - Map pos = new HashMap<>(); - - for (List al = annotations; !al.isEmpty(); al = al.tail) { - JCAnnotation a = al.head; - T c = creator.create(a, syms.annotationType, env); - - Assert.checkNonNull(c, "Failed to create annotation"); - - if (annotated.containsKey(a.type.tsym)) { - if (!allowRepeatedAnnos) { - log.error(a.pos(), "repeatable.annotations.not.supported.in.source"); - allowRepeatedAnnos = true; - } - ListBuffer l = annotated.get(a.type.tsym); - l = l.append(c); - annotated.put(a.type.tsym, l); - pos.put(c, a.pos()); - } else { - annotated.put(a.type.tsym, ListBuffer.of(c)); - pos.put(c, a.pos()); - } - - // Note: @Deprecated has no effect on local variables and parameters - if (!c.type.isErroneous() - && sym.owner.kind != MTH - && types.isSameType(c.type, syms.deprecatedType)) { - sym.flags_field |= Flags.DEPRECATED; - } - } - - return new AnnotationContext<>(env, annotated, pos, - isTypeCompound); - } - - // Gather up annotations into a map from type symbols to lists of - // Compound attributes, then continue on with repeating - // annotations processing - private - void attachAttributesLater(final List annotations, - final Env env, - final Symbol sym, - final boolean isTypeCompound, - final AttributeCreator creator, - final AttributeAttacher attacher) { - final AnnotationContext ctx = - prepareEnterAnnotations(annotations, env, sym, creator, isTypeCompound); - final Map> annotated = - ctx.annotated; - boolean hasRepeated = false; - - List buf = List.nil(); - for (ListBuffer lb : annotated.values()) { - if (lb.size() == 1) { - buf = buf.prepend(lb.first()); - } else { - @SuppressWarnings("unchecked") - T res = (T) new Placeholder<>(ctx, lb.toList(), sym); - buf = buf.prepend(res); - hasRepeated = true; - } - } - - final List attrs = buf.reverse(); - - if (!isTypeCompound) { - // Attach declaration attributes early, so - // that @Repeatable and other annotations get attached. - // Since the attacher uses setDeclarationAttributes, this - // will be overwritten later. - attacher.attach(sym, attrs); - } - if (hasRepeated) { - repeated(new Annotate.Worker() { - @Override - public String toString() { - return "repeated annotation pass of: " + sym + " in: " + sym.owner; - } - - @Override - public void run() { - JavaFileObject oldSource = - log.useSource(env.toplevel.sourcefile); - try { - attacher.attach(sym, replacePlaceholders(attrs, ctx, sym)); - } finally { - log.useSource(oldSource); - } - } - }); - } else { - attacher.attach(sym, attrs); - } - } - - private interface AttributeAttacher { - public void attach(Symbol sym, List attrs); - } - - private final AttributeAttacher declAnnotationsAttacher = - new AttributeAttacher() { - @Override - public void attach(Symbol sym, List attrs) { - sym.resetAnnotations(); - sym.setDeclarationAttributes(attrs); - } - }; - - private final AttributeAttacher typeAnnotationsAttacher = - new AttributeAttacher() { - @Override - public void attach(Symbol sym, List attrs) { - sym.appendUniqueTypeAttributes(attrs); - } - }; - - private List - replacePlaceholders(List buf, - Annotate.AnnotationContext ctx, - Symbol sym) { - List result = List.nil(); - for (T a : buf) { - if (a instanceof Placeholder) { - @SuppressWarnings("unchecked") - T replacement = replaceOne((Placeholder) a, ctx, sym); - - if (null != replacement) { - result = result.prepend(replacement); - } - } else { - result = result.prepend(a); - } - } - - return result.reverse(); - } - - private T replaceOne(Placeholder placeholder, - Annotate.AnnotationContext ctx, - Symbol sym) { + private T makeContainerAnnotation(List toBeReplaced, + AnnotationContext ctx, Symbol sym) + { // Process repeated annotations T validRepeated = - processRepeatedAnnotations(placeholder.getPlaceholderFor(), - ctx, sym); + processRepeatedAnnotations(toBeReplaced, ctx, sym); if (validRepeated != null) { // Check that the container isn't manually @@ -865,7 +935,8 @@ public class Annotate { // its contained annotation. ListBuffer manualContainer = ctx.annotated.get(validRepeated.type.tsym); if (manualContainer != null) { - log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present", + log.error(ctx.pos.get(manualContainer.first()), + "invalid.repeatable.annotation.repeated.and.container.present", manualContainer.first().type.tsym); } } @@ -874,107 +945,16 @@ public class Annotate { return validRepeated; } -/* ******************************************************************** - * Annotation processing - *********************************************************************/ + /******************** + * Type annotations * + ********************/ - /** Queue annotations for later processing. */ - void annotateLater(final List annotations, - final Env localEnv, - final Symbol s, - final DiagnosticPosition deferPos) { - if (annotations.isEmpty()) { - return; - } - if (s.kind != PCK) { - s.resetAnnotations(); // mark Annotations as incomplete for now - } - normal(new Annotate.Worker() { - @Override - public String toString() { - return "annotate " + annotations + " onto " + s + " in " + s.owner; - } - - @Override - public void run() { - Assert.check(s.kind == PCK || s.annotationsPendingCompletion()); - JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); - DiagnosticPosition prevLintPos = - deferPos != null - ? deferredLintHandler.setPos(deferPos) - : deferredLintHandler.immediate(); - Lint prevLint = deferPos != null ? null : chk.setLint(lint); - try { - if (s.hasAnnotations() && - annotations.nonEmpty()) - log.error(annotations.head.pos, - "already.annotated", - Kinds.kindName(s), s); - actualEnterAnnotations(annotations, localEnv, s); - } finally { - if (prevLint != null) - chk.setLint(prevLint); - deferredLintHandler.setPos(prevLintPos); - log.useSource(prev); - } - } - }); - - validate(new Annotate.Worker() { //validate annotations - @Override - public void run() { - JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); - try { - chk.validateAnnotations(annotations, s); - } finally { - log.useSource(prev); - } - } - }); - } - - private interface AttributeCreator { - public T create(JCAnnotation a, Type expected, Env env); - } - - // TODO: When SE8 features can be used, these can go away and be - // replaced by method refs. - private final AttributeCreator enterAnnotationsCreator = - new AttributeCreator() { - @Override - public Attribute.Compound create(JCAnnotation a, - Type expected, - Env env) { - return enterAnnotation(a, syms.annotationType, env); - } - }; - private final AttributeCreator enterTypeAnnotationsCreator = - new AttributeCreator() { - @Override - public Attribute.TypeCompound create(JCAnnotation a, - Type expected, - Env env) { - return enterTypeAnnotation(a, syms.annotationType, env); - } - }; - - /** Enter a set of annotations. */ - private void actualEnterAnnotations(List annotations, - Env env, - Symbol s) { - Assert.checkNonNull(s, "Symbol argument to actualEnterAnnotations is null"); - attachAttributesLater(annotations, env, s, false, - enterAnnotationsCreator, - declAnnotationsAttacher); - } - - /* - * If the symbol is non-null, attach the type annotation to it. + /** + * Attribute the list of annotations and enter them onto s. */ - private void actualEnterTypeAnnotations(final List annotations, - final Env env, - final Symbol s, - final DiagnosticPosition deferPos) { + public void enterTypeAnnotations(List annotations, Env env, + Symbol s, DiagnosticPosition deferPos) + { Assert.checkNonNull(s, "Symbol argument to actualEnterTypeAnnotations is nul/"); JavaFileObject prev = log.useSource(env.toplevel.sourcefile); DiagnosticPosition prevLintPos = null; @@ -983,9 +963,7 @@ public class Annotate { prevLintPos = deferredLintHandler.setPos(deferPos); } try { - attachAttributesLater(annotations, env, s, true, - enterTypeAnnotationsCreator, - typeAnnotationsAttacher); + annotateNow(s, annotations, env, true); } finally { if (prevLintPos != null) deferredLintHandler.setPos(prevLintPos); @@ -993,21 +971,61 @@ public class Annotate { } } - public void annotateTypeLater(final JCTree tree, - final Env env, - final Symbol sym, - final DiagnosticPosition deferPos) { + /** + * Enqueue tree for scanning of type annotations, attaching to the Symbol sym. + */ + public void queueScanTreeAndTypeAnnotate(JCTree tree, Env env, Symbol sym, + DiagnosticPosition deferPos) + { Assert.checkNonNull(sym); - normal(new Annotate.Worker() { - @Override - public String toString() { - return "type annotate " + tree + " onto " + sym + " in " + sym.owner; - } - @Override - public void run() { - tree.accept(new TypeAnnotate(env, sym, deferPos)); - } - }); + normal(new Runnable() { + @Override + public String toString() { + return "type annotate " + tree + " onto " + sym + " in " + sym.owner; + } + + @Override + public void run() { + tree.accept(new TypeAnnotate(env, sym, deferPos)); + } + }); + } + + /** + * Apply the annotations to the particular type. + */ + public void annotateTypeSecondStage(JCTree tree, List annotations, Type storeAt) { + typeAnnotation(new Runnable() { + @Override + public String toString() { + return "Type annotate 2:nd stage " + annotations + " onto " + tree; + } + + @Override + public void run() { + List compounds = fromAnnotations(annotations); + Assert.check(annotations.size() == compounds.size()); + storeAt.getMetadataOfKind(Kind.ANNOTATIONS).combine(new TypeMetadata.Annotations(compounds)); + } + }); + } + + /** + * Apply the annotations to the particular type. + */ + public void annotateTypeParameterSecondStage(JCTree tree, List annotations) { + typeAnnotation(new Runnable() { + @Override + public String toString() { + return "Type annotate 2:nd stage " + annotations + " onto " + tree; + } + + @Override + public void run() { + List compounds = fromAnnotations(annotations); + Assert.check(annotations.size() == compounds.size()); + } + }); } /** @@ -1019,9 +1037,7 @@ public class Annotate { private final Symbol sym; private DiagnosticPosition deferPos; - public TypeAnnotate(final Env env, - final Symbol sym, - final DiagnosticPosition deferPos) { + public TypeAnnotate(Env env, Symbol sym, DiagnosticPosition deferPos) { this.env = env; this.sym = sym; @@ -1029,27 +1045,28 @@ public class Annotate { } @Override - public void visitAnnotatedType(final JCAnnotatedType tree) { - actualEnterTypeAnnotations(tree.annotations, env, sym, deferPos); - super.visitAnnotatedType(tree); + public void visitAnnotatedType(JCAnnotatedType tree) { + enterTypeAnnotations(tree.annotations, env, sym, deferPos); + scan(tree.underlyingType); } @Override - public void visitTypeParameter(final JCTypeParameter tree) { - actualEnterTypeAnnotations(tree.annotations, env, sym, deferPos); - super.visitTypeParameter(tree); + public void visitTypeParameter(JCTypeParameter tree) { + enterTypeAnnotations(tree.annotations, env, sym, deferPos); + scan(tree.bounds); } @Override - public void visitNewArray(final JCNewArray tree) { - actualEnterTypeAnnotations(tree.annotations, env, sym, deferPos); + public void visitNewArray(JCNewArray tree) { + enterTypeAnnotations(tree.annotations, env, sym, deferPos); for (List dimAnnos : tree.dimAnnotations) - actualEnterTypeAnnotations(dimAnnos, env, sym, deferPos); - super.visitNewArray(tree); + enterTypeAnnotations(dimAnnos, env, sym, deferPos); + scan(tree.elemtype); + scan(tree.elems); } @Override - public void visitMethodDef(final JCMethodDecl tree) { + public void visitMethodDef(JCMethodDecl tree) { scan(tree.mods); scan(tree.restype); scan(tree.typarams); @@ -1058,11 +1075,10 @@ public class Annotate { scan(tree.thrown); scan(tree.defaultValue); // Do not annotate the body, just the signature. - // scan(tree.body); } @Override - public void visitVarDef(final JCVariableDecl tree) { + public void visitVarDef(JCVariableDecl tree) { DiagnosticPosition prevPos = deferPos; deferPos = tree.pos(); try { @@ -1094,4 +1110,238 @@ public class Annotate { } } } + + /********************* + * Completer support * + *********************/ + + private AnnotationTypeCompleter theSourceCompleter = new AnnotationTypeCompleter() { + @Override + public void complete(ClassSymbol sym) throws CompletionFailure { + Env context = typeEnvs.get(sym); + Annotate.this.attributeAnnotationType(context); + } + }; + + /* Last stage completer to enter just enough annotations to have a prototype annotation type. + * This currently means entering @Target and @Repetable. + */ + public AnnotationTypeCompleter annotationTypeSourceCompleter() { + return theSourceCompleter; + } + + private void attributeAnnotationType(Env env) { + Assert.check(((JCClassDecl)env.tree).sym.isAnnotationType(), + "Trying to annotation type complete a non-annotation type"); + + JavaFileObject prev = log.useSource(env.toplevel.sourcefile); + try { + JCClassDecl tree = (JCClassDecl)env.tree; + AnnotationTypeVisitor v = new AnnotationTypeVisitor(attr, chk, syms, typeEnvs); + v.scanAnnotationType(tree); + tree.sym.getAnnotationTypeMetadata().setRepeatable(v.repeatable); + tree.sym.getAnnotationTypeMetadata().setTarget(v.target); + } finally { + log.useSource(prev); + } + } + + public Attribute unfinishedDefaultValue() { + return theUnfinishedDefaultValue; + } + + public static interface AnnotationTypeCompleter { + void complete(ClassSymbol sym) throws CompletionFailure; + } + + /** Visitor to determine a prototype annotation type for a class declaring an annotation type. + * + *

        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. + */ + public class AnnotationTypeVisitor extends TreeScanner { + private Env env; + + private final Attr attr; + private final Check check; + private final Symtab tab; + private final TypeEnvs typeEnvs; + + private Compound target; + private Compound repeatable; + + public AnnotationTypeVisitor(Attr attr, Check check, Symtab tab, TypeEnvs typeEnvs) { + this.attr = attr; + this.check = check; + this.tab = tab; + this.typeEnvs = typeEnvs; + } + + public Compound getRepeatable() { + return repeatable; + } + + public Compound getTarget() { + return target; + } + + public void scanAnnotationType(JCClassDecl decl) { + visitClassDef(decl); + } + + @Override + public void visitClassDef(JCClassDecl tree) { + Env prevEnv = env; + env = typeEnvs.get(tree.sym); + try { + scan(tree.mods); // look for repeatable and target + // don't descend into body + } finally { + env = prevEnv; + } + } + + @Override + public void visitAnnotation(JCAnnotation tree) { + Type t = tree.annotationType.type; + if (t == null) { + t = attr.attribType(tree.annotationType, env); + tree.annotationType.type = t = check.checkType(tree.annotationType.pos(), t, tab.annotationType); + } + + if (t == tab.annotationTargetType) { + target = Annotate.this.attributeAnnotation(tree, tab.annotationTargetType, env); + } else if (t == tab.repeatableType) { + repeatable = Annotate.this.attributeAnnotation(tree, tab.repeatableType, env); + } + } + } + + /** Represents the semantics of an Annotation Type. + * + *

        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. + */ + public static class AnnotationTypeMetadata { + final ClassSymbol metaDataFor; + private Compound target; + private Compound repeatable; + private AnnotationTypeCompleter annotationTypeCompleter; + + public AnnotationTypeMetadata(ClassSymbol metaDataFor, AnnotationTypeCompleter annotationTypeCompleter) { + this.metaDataFor = metaDataFor; + this.annotationTypeCompleter = annotationTypeCompleter; + } + + private void init() { + // Make sure metaDataFor is member entered + while (metaDataFor.completer != null) + metaDataFor.complete(); + + if (annotationTypeCompleter != null) { + AnnotationTypeCompleter c = annotationTypeCompleter; + annotationTypeCompleter = null; + c.complete(metaDataFor); + } + } + + public void complete() { + init(); + } + + public Compound getRepeatable() { + init(); + return repeatable; + } + + public void setRepeatable(Compound repeatable) { + Assert.checkNull(this.repeatable); + this.repeatable = repeatable; + } + + public Compound getTarget() { + init(); + return target; + } + + public void setTarget(Compound target) { + Assert.checkNull(this.target); + this.target = target; + } + + public Set getAnnotationElements() { + init(); + Set members = new LinkedHashSet<>(); + WriteableScope s = metaDataFor.members(); + Iterable ss = s.getSymbols(NON_RECURSIVE); + for (Symbol sym : ss) + if (sym.kind == MTH && + sym.name != sym.name.table.names.clinit && + (sym.flags() & SYNTHETIC) == 0) + members.add((MethodSymbol)sym); + return members; + } + + public Set getAnnotationElementsWithDefault() { + init(); + Set members = getAnnotationElements(); + Set res = new LinkedHashSet<>(); + for (MethodSymbol m : members) + if (m.defaultValue != null) + res.add(m); + return res; + } + + @Override + public String toString() { + return "Annotation type for: " + metaDataFor; + } + + public boolean isMetadataForAnnotationType() { return true; } + + public static AnnotationTypeMetadata notAnAnnotationType() { + return NOT_AN_ANNOTATION_TYPE; + } + + private static final AnnotationTypeMetadata NOT_AN_ANNOTATION_TYPE = + new AnnotationTypeMetadata(null, null) { + @Override + public void complete() { + } // do nothing + + @Override + public String toString() { + return "Not an annotation type"; + } + + @Override + public Set getAnnotationElements() { + return new LinkedHashSet<>(0); + } + + @Override + public Set getAnnotationElementsWithDefault() { + return new LinkedHashSet<>(0); + } + + @Override + public boolean isMetadataForAnnotationType() { + return false; + } + + @Override + public Compound getTarget() { + return null; + } + + @Override + public Compound getRepeatable() { + return null; + } + }; + } } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index c3b467de0e5..02340511e52 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -40,12 +40,17 @@ import com.sun.tools.javac.code.Lint.LintCategory; import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Type.*; +import com.sun.tools.javac.code.TypeMetadata.Annotations; import com.sun.tools.javac.code.Types.FunctionDescriptorLookupError; import com.sun.tools.javac.comp.Check.CheckContext; import com.sun.tools.javac.comp.DeferredAttr.AttrMode; import com.sun.tools.javac.comp.Infer.InferenceContext; import com.sun.tools.javac.comp.Infer.FreeTypeListener; import com.sun.tools.javac.jvm.*; +import static com.sun.tools.javac.resources.CompilerProperties.Fragments.Diamond; +import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArg; +import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArgs; +import com.sun.tools.javac.resources.CompilerProperties.Errors; import com.sun.tools.javac.resources.CompilerProperties.Fragments; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; @@ -54,6 +59,7 @@ import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.Dependencies.AttributionKind; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; +import com.sun.tools.javac.util.JCDiagnostic.Fragment; import com.sun.tools.javac.util.List; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Flags.ANNOTATION; @@ -98,11 +104,11 @@ public class Attr extends JCTree.Visitor { final Target target; final Types types; final JCDiagnostic.Factory diags; - final Annotate annotate; final TypeAnnotations typeAnnotations; final DeferredLintHandler deferredLintHandler; final TypeEnvs typeEnvs; final Dependencies dependencies; + final Annotate annotate; public static Attr instance(Context context) { Attr instance = context.get(attrKey); @@ -219,6 +225,26 @@ public class Attr extends JCTree.Visitor { final Type found, final KindSelector ownkind, final ResultInfo resultInfo) { + return check(tree, found, ownkind, resultInfo, true); + } + /** Check kind and type of given tree against protokind and prototype. + * If check succeeds, store type in tree and return it. + * If check fails, store errType in tree and return it. + * No checks are performed if the prototype is a method type. + * It is not necessary in this case since we know that kind and type + * are correct. + * + * @param tree The tree whose kind and type is checked + * @param found The computed type of the tree + * @param ownkind The computed kind of the tree + * @param resultInfo The expected result of the tree + * @param recheckPostInference If true and inference is underway, arrange to recheck the tree after inference finishes. + */ + Type check(final JCTree tree, + final Type found, + final KindSelector ownkind, + final ResultInfo resultInfo, + boolean recheckPostInference) { InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext(); Type owntype; boolean shouldCheck = !found.hasTag(ERROR) && @@ -233,12 +259,14 @@ public class Attr extends JCTree.Visitor { //delay the check if there are inference variables in the found type //this means we are dealing with a partially inferred poly expression owntype = shouldCheck ? resultInfo.pt : found; - inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), - instantiatedContext -> { - ResultInfo pendingResult = - resultInfo.dup(inferenceContext.asInstType(resultInfo.pt)); - check(tree, inferenceContext.asInstType(found), ownkind, pendingResult); - }); + if (recheckPostInference) { + inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), + instantiatedContext -> { + ResultInfo pendingResult = + resultInfo.dup(inferenceContext.asInstType(resultInfo.pt)); + check(tree, inferenceContext.asInstType(found), ownkind, pendingResult, false); + }); + } } else { owntype = shouldCheck ? resultInfo.check(tree, found) : @@ -862,7 +890,7 @@ public class Attr extends JCTree.Visitor { } else { chk.checkOverrideClashes(tree.pos(), env.enclClass.type, m); } - chk.checkOverride(tree, m); + chk.checkOverride(env, tree, m); if (isDefaultMethod && types.overridesObjectMethod(m.enclClass(), m)) { log.error(tree, "default.overrides.object.member", m.name, Kinds.kindName(m.location()), m.location()); @@ -970,7 +998,7 @@ public class Attr extends JCTree.Visitor { } // Attribute all type annotations in the body - annotate.annotateTypeLater(tree.body, localEnv, m, null); + annotate.queueScanTreeAndTypeAnnotate(tree.body, localEnv, m, null); annotate.flush(); // Attribute method body. @@ -993,16 +1021,16 @@ public class Attr extends JCTree.Visitor { env.info.scope.enter(tree.sym); } else { try { - annotate.enterStart(); + annotate.blockAnnotations(); memberEnter.memberEnter(tree, env); } finally { - annotate.enterDone(); + annotate.unblockAnnotations(); } } } else { if (tree.init != null) { // Field initializer expression need to be entered. - annotate.annotateTypeLater(tree.init, env, tree.sym, tree.pos()); + annotate.queueScanTreeAndTypeAnnotate(tree.init, env, tree.sym, tree.pos()); annotate.flush(); } } @@ -1063,7 +1091,7 @@ public class Attr extends JCTree.Visitor { if ((tree.flags & STATIC) != 0) localEnv.info.staticLevel++; // Attribute all type annotations in the block - annotate.annotateTypeLater(tree, localEnv, localEnv.info.scope.owner, null); + annotate.queueScanTreeAndTypeAnnotate(tree, localEnv, localEnv.info.scope.owner, null); annotate.flush(); attribStats(tree.stats, localEnv); @@ -1926,9 +1954,16 @@ public class Attr extends JCTree.Visitor { // Attribute clazz expression and store // symbol + type back into the attributed tree. - Type clazztype = TreeInfo.isEnumInit(env.tree) ? - attribIdentAsEnumType(env, (JCIdent)clazz) : - attribType(clazz, env); + Type clazztype; + + try { + env.info.isNewClass = true; + clazztype = TreeInfo.isEnumInit(env.tree) ? + attribIdentAsEnumType(env, (JCIdent)clazz) : + attribType(clazz, env); + } finally { + env.info.isNewClass = false; + } clazztype = chk.checkDiamond(tree, clazztype); chk.validate(clazz, localEnv); @@ -1969,11 +2004,16 @@ public class Attr extends JCTree.Visitor { (((JCVariableDecl) env.tree).mods.flags & Flags.ENUM) == 0 || ((JCVariableDecl) env.tree).init != tree)) log.error(tree.pos(), "enum.cant.be.instantiated"); + + boolean isSpeculativeDiamondInferenceRound = TreeInfo.isDiamond(tree) && + resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE; + boolean skipNonDiamondPath = false; // Check that class is not abstract - if (cdef == null && + if (cdef == null && !isSpeculativeDiamondInferenceRound && // class body may be nulled out in speculative tree copy (clazztype.tsym.flags() & (ABSTRACT | INTERFACE)) != 0) { log.error(tree.pos(), "abstract.cant.be.instantiated", clazztype.tsym); + skipNonDiamondPath = true; } else if (cdef != null && clazztype.tsym.isInterface()) { // Check that no constructor arguments are given to // anonymous classes implementing an interface @@ -1986,7 +2026,9 @@ public class Attr extends JCTree.Visitor { // Error recovery: pretend no arguments were supplied. argtypes = List.nil(); typeargtypes = List.nil(); - } else if (TreeInfo.isDiamond(tree)) { + skipNonDiamondPath = true; + } + if (TreeInfo.isDiamond(tree)) { ClassType site = new ClassType(clazztype.getEnclosingType(), clazztype.tsym.type.getTypeArguments(), clazztype.tsym, @@ -2022,7 +2064,7 @@ public class Attr extends JCTree.Visitor { tree.clazz.type = types.createErrorType(clazztype); if (!constructorType.isErroneous()) { - tree.clazz.type = clazztype = constructorType.getReturnType(); + tree.clazz.type = clazz.type = constructorType.getReturnType(); tree.constructorType = types.createMethodTypeWithReturn(constructorType, syms.voidType); } clazztype = chk.checkClassType(tree.clazz, tree.clazz.type, true); @@ -2031,7 +2073,7 @@ public class Attr extends JCTree.Visitor { // Resolve the called constructor under the assumption // that we are referring to a superclass instance of the // current instance (JLS ???). - else { + else if (!skipNonDiamondPath) { //the following code alters some of the fields in the current //AttrContext - hence, the current context must be dup'ed in //order to avoid downstream failures @@ -2052,70 +2094,8 @@ public class Attr extends JCTree.Visitor { } if (cdef != null) { - // We are seeing an anonymous class instance creation. - // In this case, the class instance creation - // expression - // - // E.new C(args) { ... } - // - // is represented internally as - // - // E . new C(args) ( class { ... } ) . - // - // This expression is then *transformed* as follows: - // - // (1) add an extends or implements clause - // (2) add a constructor. - // - // For instance, if C is a class, and ET is the type of E, - // the expression - // - // E.new C(args) { ... } - // - // is translated to (where X is a fresh name and typarams is the - // parameter list of the super constructor): - // - // new X(<*nullchk*>E, args) where - // X extends C { - // X(ET e, args) { - // e.super(args) - // } - // ... - // } - - if (clazztype.tsym.isInterface()) { - cdef.implementing = List.of(clazz); - } else { - cdef.extending = clazz; - } - - if (resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && - isSerializable(clazztype)) { - localEnv.info.isSerializable = true; - } - - attribStat(cdef, localEnv); - - // If an outer instance is given, - // prefix it to the constructor arguments - // and delete it from the new expression - if (tree.encl != null && !clazztype.tsym.isInterface()) { - tree.args = tree.args.prepend(makeNullCheck(tree.encl)); - argtypes = argtypes.prepend(tree.encl.type); - tree.encl = null; - } - - // Reassign clazztype and recompute constructor. - clazztype = cdef.sym.type; - Symbol sym = tree.constructor = rs.resolveConstructor( - tree.pos(), localEnv, clazztype, argtypes, typeargtypes); - Assert.check(!sym.kind.isOverloadError()); - tree.constructor = sym; - tree.constructorType = checkId(noCheckTree, - clazztype, - tree.constructor, - localEnv, - new ResultInfo(pkind, newMethodTemplate(syms.voidType, argtypes, typeargtypes))); + visitAnonymousClassDefinition(tree, clazz, clazztype, cdef, localEnv, argtypes, typeargtypes, pkind); + return; } if (tree.constructor != null && tree.constructor.kind == MTH) @@ -2133,6 +2113,125 @@ public class Attr extends JCTree.Visitor { chk.validate(tree.typeargs, localEnv); } + // where + private void visitAnonymousClassDefinition(JCNewClass tree, JCExpression clazz, Type clazztype, + JCClassDecl cdef, Env localEnv, + List argtypes, List typeargtypes, + KindSelector pkind) { + // We are seeing an anonymous class instance creation. + // In this case, the class instance creation + // expression + // + // E.new C(args) { ... } + // + // is represented internally as + // + // E . new C(args) ( class { ... } ) . + // + // This expression is then *transformed* as follows: + // + // (1) add an extends or implements clause + // (2) add a constructor. + // + // For instance, if C is a class, and ET is the type of E, + // the expression + // + // E.new C(args) { ... } + // + // is translated to (where X is a fresh name and typarams is the + // parameter list of the super constructor): + // + // new X(<*nullchk*>E, args) where + // X extends C { + // X(ET e, args) { + // e.super(args) + // } + // ... + // } + InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext(); + final boolean isDiamond = TreeInfo.isDiamond(tree); + if (isDiamond + && ((tree.constructorType != null && inferenceContext.free(tree.constructorType)) + || (tree.clazz.type != null && inferenceContext.free(tree.clazz.type)))) { + inferenceContext.addFreeTypeListener(List.of(tree.constructorType, tree.clazz.type), + instantiatedContext -> { + tree.constructorType = instantiatedContext.asInstType(tree.constructorType); + clazz.type = instantiatedContext.asInstType(clazz.type); + visitAnonymousClassDefinition(tree, clazz, clazz.type, cdef, localEnv, argtypes, typeargtypes, pkind); + }); + } else { + if (isDiamond && clazztype.hasTag(CLASS)) { + List invalidDiamondArgs = chk.checkDiamondDenotable((ClassType)clazztype); + if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) { + // One or more types inferred in the previous steps is non-denotable. + Fragment fragment = Diamond(clazztype.tsym); + log.error(tree.clazz.pos(), + Errors.CantApplyDiamond1( + fragment, + invalidDiamondArgs.size() > 1 ? + DiamondInvalidArgs(invalidDiamondArgs, fragment) : + DiamondInvalidArg(invalidDiamondArgs, fragment))); + } + // For <>(){}, inferred types must also be accessible. + for (Type t : clazztype.getTypeArguments()) { + rs.checkAccessibleType(env, t); + } + } + + // If we already errored, be careful to avoid a further avalanche. ErrorType answers + // false for isInterface call even when the original type is an interface. + boolean implementing = clazztype.tsym.isInterface() || + clazztype.isErroneous() && clazztype.getOriginalType().tsym.isInterface(); + + if (implementing) { + cdef.implementing = List.of(clazz); + } else { + cdef.extending = clazz; + } + + if (resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && + isSerializable(clazztype)) { + localEnv.info.isSerializable = true; + } + + attribStat(cdef, localEnv); + + List finalargtypes; + // If an outer instance is given, + // prefix it to the constructor arguments + // and delete it from the new expression + if (tree.encl != null && !clazztype.tsym.isInterface()) { + tree.args = tree.args.prepend(makeNullCheck(tree.encl)); + finalargtypes = argtypes.prepend(tree.encl.type); + tree.encl = null; + } else { + finalargtypes = argtypes; + } + + // Reassign clazztype and recompute constructor. As this necessarily involves + // another attribution pass for deferred types in the case of <>, replicate + // them. Original arguments have right decorations already. + if (isDiamond && pkind.contains(KindSelector.POLY)) { + finalargtypes = finalargtypes.map(deferredAttr.deferredCopier); + } + + clazztype = cdef.sym.type; + Symbol sym = tree.constructor = rs.resolveConstructor( + tree.pos(), localEnv, clazztype, finalargtypes, typeargtypes); + Assert.check(!sym.kind.isResolutionError()); + tree.constructor = sym; + tree.constructorType = checkId(noCheckTree, + clazztype, + tree.constructor, + localEnv, + new ResultInfo(pkind, newMethodTemplate(syms.voidType, finalargtypes, typeargtypes))); + } + Type owntype = (tree.constructor != null && tree.constructor.kind == MTH) ? + clazztype : types.createErrorType(tree.type); + result = check(tree, owntype, KindSelector.VAL, resultInfo, false); + chk.validate(tree.typeargs, localEnv); + } + /** Make an attributed null check tree. */ public JCExpression makeNullCheck(JCExpression arg) { @@ -2647,17 +2746,20 @@ public class Attr extends JCTree.Visitor { Symbol refSym = refResult.fst; Resolve.ReferenceLookupHelper lookupHelper = refResult.snd; + /** this switch will need to go away and be replaced by the new RESOLUTION_TARGET testing + * JDK-8075541 + */ if (refSym.kind != MTH) { boolean targetError; switch (refSym.kind) { case ABSENT_MTH: + case MISSING_ENCL: targetError = false; break; case WRONG_MTH: case WRONG_MTHS: case AMBIGUOUS: case HIDDEN: - case MISSING_ENCL: case STATICERR: targetError = true; break; @@ -3908,7 +4010,7 @@ public class Attr extends JCTree.Visitor { TypeVar typeVar = (TypeVar) tree.type; if (tree.annotations != null && tree.annotations.nonEmpty()) { - annotateType(tree, tree.annotations); + annotate.annotateTypeParameterSecondStage(tree, tree.annotations); } if (!typeVar.bound.isErroneous()) { @@ -3998,45 +4100,17 @@ public class Attr extends JCTree.Visitor { } public void visitAnnotation(JCAnnotation tree) { - Assert.error("should be handled in Annotate"); + Assert.error("should be handled in annotate"); } public void visitAnnotatedType(JCAnnotatedType tree) { - Type underlyingType = attribType(tree.getUnderlyingType(), env); - this.attribAnnotationTypes(tree.annotations, env); - annotateType(tree, tree.annotations); - result = tree.type = underlyingType; - } + attribAnnotationTypes(tree.annotations, env); + Type underlyingType = attribType(tree.underlyingType, env); + Type annotatedType = underlyingType.annotatedType(Annotations.TO_BE_SET); - /** - * Apply the annotations to the particular type. - */ - public void annotateType(final JCTree tree, final List annotations) { - annotate.typeAnnotation(new Annotate.Worker() { - @Override - public String toString() { - return "annotate " + annotations + " onto " + tree; - } - @Override - public void run() { - List compounds = fromAnnotations(annotations); - Assert.check(annotations.size() == compounds.size()); - tree.type = tree.type.annotatedType(compounds); - } - }); - } - - private static List fromAnnotations(List annotations) { - if (annotations.isEmpty()) { - return List.nil(); - } - - ListBuffer buf = new ListBuffer<>(); - for (JCAnnotation anno : annotations) { - Assert.checkNonNull(anno.attribute); - buf.append((Attribute.TypeCompound) anno.attribute); - } - return buf.toList(); + if (!env.info.isNewClass) + annotate.annotateTypeSecondStage(tree, tree.annotations, annotatedType); + result = tree.type = annotatedType; } public void visitErroneous(JCErroneous tree) { @@ -4204,8 +4278,9 @@ public class Attr extends JCTree.Visitor { log.error(tree.typarams.head.pos(), "intf.annotation.cant.have.type.params"); - // If this annotation has a @Repeatable, validate - Attribute.Compound repeatable = c.attribute(syms.repeatableType.tsym); + // If this annotation type has a @Repeatable, validate + Attribute.Compound repeatable = c.getAnnotationTypeMetadata().getRepeatable(); + // If this annotation type has a @Repeatable, validate if (repeatable != null) { // get diagnostic position for error reporting DiagnosticPosition cbPos = getDiagnosticPosition(tree, repeatable.type); @@ -4581,7 +4656,7 @@ public class Attr extends JCTree.Visitor { // This method will raise an error for such a type. for (JCAnnotation ai : annotations) { if (!ai.type.isErroneous() && - typeAnnotations.annotationType(ai.attribute, sym) == TypeAnnotations.AnnotationType.DECLARATION) { + typeAnnotations.annotationTargetType(ai.attribute, sym) == TypeAnnotations.AnnotationType.DECLARATION) { log.error(ai.pos(), "annotation.type.not.applicable"); } } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java index db812ff0687..dd1436ed1c6 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,6 +63,16 @@ public class AttrContext { */ boolean isSpeculative = false; + /** + * Is this an attribution environment for an anonymous class instantiated using <> ? + */ + boolean isAnonymousDiamond = false; + + /** + * Is this an attribution environment for an instance creation expression? + */ + boolean isNewClass = false; + /** Are arguments to current function applications boxed into an array for varargs? */ Resolve.MethodResolutionPhase pendingResolutionPhase = null; @@ -100,6 +110,8 @@ public class AttrContext { info.defaultSuperCallSite = defaultSuperCallSite; info.isSerializable = isSerializable; info.isSpeculative = isSpeculative; + info.isAnonymousDiamond = isAnonymousDiamond; + info.isNewClass = isNewClass; return info; } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index b2af981a8ea..3a31e365da9 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -31,7 +31,10 @@ import javax.tools.JavaFileManager; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Attribute.Compound; +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.tree.*; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; @@ -79,11 +82,13 @@ public class Check { private final DeferredAttr deferredAttr; private final Infer infer; private final Types types; + private final TypeAnnotations typeAnnotations; private final JCDiagnostic.Factory diags; private boolean warnOnSyntheticConflicts; private boolean suppressAbortOnBadClassFile; private boolean enableSunApiLintControl; private final JavaFileManager fileManager; + private final Source source; private final Profile profile; private final boolean warnOnAccessToSensitiveMembers; @@ -117,16 +122,18 @@ public class Check { deferredAttr = DeferredAttr.instance(context); infer = Infer.instance(context); types = Types.instance(context); + typeAnnotations = TypeAnnotations.instance(context); diags = JCDiagnostic.Factory.instance(context); Options options = Options.instance(context); lint = Lint.instance(context); fileManager = context.get(JavaFileManager.class); - Source source = Source.instance(context); + source = Source.instance(context); allowSimplifiedVarargs = source.allowSimplifiedVarargs(); allowDefaultMethods = source.allowDefaultMethods(); allowStrictMethodClashCheck = source.allowStrictMethodClashCheck(); allowPrivateSafeVarargs = source.allowPrivateSafeVarargs(); + allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation(); complexInference = options.isSet("complexinference"); warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); @@ -169,6 +176,10 @@ public class Check { */ boolean allowPrivateSafeVarargs; + /** Switch: can diamond inference be used in anonymous instance creation ? + */ + boolean allowDiamondWithAnonymousClassCreation; + /** Switch: -complexinference option set? */ boolean complexInference; @@ -518,7 +529,7 @@ public class Check { * @param found The type that was found. * @param req The type that was required. */ - Type checkType(DiagnosticPosition pos, Type found, Type req) { + public Type checkType(DiagnosticPosition pos, Type found, Type req) { return checkType(pos, found, req, basicHandler); } @@ -579,7 +590,7 @@ public class Check { public void report() { if (lint.isEnabled(Lint.LintCategory.CAST)) log.warning(Lint.LintCategory.CAST, - tree.pos(), "redundant.cast", tree.expr.type); + tree.pos(), "redundant.cast", tree.clazz.type); } }); } @@ -773,10 +784,9 @@ public class Check { if (!TreeInfo.isDiamond(tree) || t.isErroneous()) { return checkClassType(tree.clazz.pos(), t, true); - } else if (tree.def != null) { + } else if (tree.def != null && !allowDiamondWithAnonymousClassCreation) { log.error(tree.clazz.pos(), - "cant.apply.diamond.1", - t, diags.fragment("diamond.and.anon.class", t)); + Errors.CantApplyDiamond1(t, Fragments.DiamondAndAnonClassNotSupportedInSource(source.name))); return types.createErrorType(t); } else if (t.tsym.type.getTypeArguments().isEmpty()) { log.error(tree.clazz.pos(), @@ -794,6 +804,59 @@ public class Check { } } + /** Check that the type inferred using the diamond operator does not contain + * non-denotable types such as captured types or intersection types. + * @param t the type inferred using the diamond operator + * @return the (possibly empty) list of non-denotable types. + */ + List checkDiamondDenotable(ClassType t) { + ListBuffer buf = new ListBuffer<>(); + for (Type arg : t.getTypeArguments()) { + if (!diamondTypeChecker.visit(arg, null)) { + buf.append(arg); + } + } + return buf.toList(); + } + // where + + /** diamondTypeChecker: A type visitor that descends down the given type looking for non-denotable + * types. The visit methods return false as soon as a non-denotable type is encountered and true + * otherwise. + */ + private static final Types.SimpleVisitor diamondTypeChecker = new Types.SimpleVisitor() { + @Override + public Boolean visitType(Type t, Void s) { + return true; + } + @Override + public Boolean visitClassType(ClassType t, Void s) { + if (t.isCompound()) { + return false; + } + for (Type targ : t.getTypeArguments()) { + if (!visit(targ, s)) { + return false; + } + } + return true; + } + @Override + public Boolean visitCapturedType(CapturedType t, Void s) { + return false; + } + + @Override + public Boolean visitArrayType(ArrayType t, Void s) { + return visit(t.elemtype, s); + } + + @Override + public Boolean visitWildcardType(WildcardType t, Void s) { + return visit(t.type, s); + } + }; + void checkVarargsMethodDecl(Env env, JCMethodDecl tree) { MethodSymbol m = tree.sym; if (!allowSimplifiedVarargs) return; @@ -1917,7 +1980,7 @@ public class Check { * for errors. * @param m The overriding method. */ - void checkOverride(JCMethodDecl tree, MethodSymbol m) { + void checkOverride(Env env, JCMethodDecl tree, MethodSymbol m) { ClassSymbol origin = (ClassSymbol)m.owner; if ((origin.flags() & ENUM) != 0 && names.finalize.equals(m.name)) if (m.overrides(syms.enumFinalFinalize, origin, types, false)) { @@ -1934,7 +1997,12 @@ public class Check { } } - if (m.attribute(syms.overrideType.tsym) != null && !isOverrider(m)) { + // Check if this method must override a super method due to being annotated with @Override + // or by virtue of being a member of a diamond inferred anonymous class. Latter case is to + // be treated "as if as they were annotated" with @Override. + boolean mustOverride = m.attribute(syms.overrideType.tsym) != null || + (env.info.isAnonymousDiamond && !m.isConstructor() && !m.isPrivate()); + if (mustOverride && !isOverrider(m)) { DiagnosticPosition pos = tree.pos(); for (JCAnnotation a : tree.getModifiers().annotations) { if (a.annotationType.type.tsym == syms.overrideType.tsym) { @@ -2765,7 +2833,7 @@ public class Check { } } - private void validateRetention(Symbol container, Symbol contained, DiagnosticPosition pos) { + private void validateRetention(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) { Attribute.RetentionPolicy containerRetention = types.getRetention(container); Attribute.RetentionPolicy containedRetention = types.getRetention(contained); @@ -2804,7 +2872,7 @@ public class Check { } } - private void validateTarget(Symbol container, Symbol contained, DiagnosticPosition pos) { + private void validateTarget(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) { // The set of targets the container is applicable to must be a subset // (with respect to annotation target semantics) of the set of targets // the contained is applicable to. The target sets may be implicit or @@ -2931,32 +2999,18 @@ public class Check { /** Is the annotation applicable to types? */ protected boolean isTypeAnnotation(JCAnnotation a, boolean isTypeParameter) { - Attribute.Compound atTarget = - a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym); - if (atTarget == null) { - // An annotation without @Target is not a type annotation. - return false; - } - - Attribute atValue = atTarget.member(names.value); - if (!(atValue instanceof Attribute.Array)) { - return false; // error recovery - } - - Attribute.Array arr = (Attribute.Array) atValue; - for (Attribute app : arr.values) { - if (!(app instanceof Attribute.Enum)) { - return false; // recovery - } - Attribute.Enum e = (Attribute.Enum) app; - - if (e.value.name == names.TYPE_USE) - return true; - else if (isTypeParameter && e.value.name == names.TYPE_PARAMETER) - return true; - } - return false; + List targets = typeAnnotations.annotationTargets(a.attribute); + return (targets == null) ? + false : + targets.stream() + .anyMatch(attr -> isTypeAnnotation(attr, isTypeParameter)); } + //where + boolean isTypeAnnotation(Attribute a, boolean isTypeParameter) { + Attribute.Enum e = (Attribute.Enum)a; + return (e.value.name == names.TYPE_USE || + (isTypeParameter && e.value.name == names.TYPE_PARAMETER)); + } /** Is the annotation applicable to the symbol? */ boolean annotationApplicable(JCAnnotation a, Symbol s) { @@ -2978,51 +3032,55 @@ public class Check { } } for (Name target : targets) { - if (target == names.TYPE) - { if (s.kind == TYP) return true; } - else if (target == names.FIELD) - { if (s.kind == VAR && s.owner.kind != MTH) return true; } - else if (target == names.METHOD) - { if (s.kind == MTH && !s.isConstructor()) return true; } - else if (target == names.PARAMETER) - { if (s.kind == VAR && s.owner.kind == MTH && - (s.flags() & PARAMETER) != 0) + if (target == names.TYPE) { + if (s.kind == TYP) + return true; + } else if (target == names.FIELD) { + if (s.kind == VAR && s.owner.kind != MTH) + return true; + } else if (target == names.METHOD) { + if (s.kind == MTH && !s.isConstructor()) + return true; + } else if (target == names.PARAMETER) { + if (s.kind == VAR && s.owner.kind == MTH && + (s.flags() & PARAMETER) != 0) { return true; } - else if (target == names.CONSTRUCTOR) - { if (s.kind == MTH && s.isConstructor()) return true; } - else if (target == names.LOCAL_VARIABLE) - { if (s.kind == VAR && s.owner.kind == MTH && - (s.flags() & PARAMETER) == 0) + } else if (target == names.CONSTRUCTOR) { + if (s.kind == MTH && s.isConstructor()) + return true; + } else if (target == names.LOCAL_VARIABLE) { + if (s.kind == VAR && s.owner.kind == MTH && + (s.flags() & PARAMETER) == 0) { return true; } - else if (target == names.ANNOTATION_TYPE) - { if (s.kind == TYP && (s.flags() & ANNOTATION) != 0) + } else if (target == names.ANNOTATION_TYPE) { + if (s.kind == TYP && (s.flags() & ANNOTATION) != 0) { return true; } - else if (target == names.PACKAGE) - { if (s.kind == PCK) return true; } - else if (target == names.TYPE_USE) - { if (s.kind == TYP || s.kind == VAR || - (s.kind == MTH && !s.isConstructor() && - !s.type.getReturnType().hasTag(VOID)) || - (s.kind == MTH && s.isConstructor())) + } else if (target == names.PACKAGE) { + if (s.kind == PCK) + return true; + } else if (target == names.TYPE_USE) { + if (s.kind == TYP || s.kind == VAR || + (s.kind == MTH && !s.isConstructor() && + !s.type.getReturnType().hasTag(VOID)) || + (s.kind == MTH && s.isConstructor())) { return true; } - else if (target == names.TYPE_PARAMETER) - { if (s.kind == TYP && s.type.hasTag(TYPEVAR)) + } else if (target == names.TYPE_PARAMETER) { + if (s.kind == TYP && s.type.hasTag(TYPEVAR)) return true; - } - else - return true; // recovery + } else + return true; // Unknown ElementType. This should be an error at declaration site, + // assume applicable. } return false; } - Attribute.Array getAttributeTargetAttribute(Symbol s) { - Attribute.Compound atTarget = - s.attribute(syms.annotationTargetType.tsym); + Attribute.Array getAttributeTargetAttribute(TypeSymbol s) { + Attribute.Compound atTarget = s.getAnnotationTypeMetadata().getTarget(); if (atTarget == null) return null; // ok, is applicable Attribute atValue = atTarget.member(names.value); if (!(atValue instanceof Attribute.Array)) return null; // error recovery @@ -3052,32 +3110,33 @@ public class Check { private boolean validateAnnotation(JCAnnotation a) { boolean isValid = true; + AnnotationTypeMetadata metadata = a.annotationType.type.tsym.getAnnotationTypeMetadata(); + // collect an inventory of the annotation elements - Set members = new LinkedHashSet<>(); - for (Symbol sym : a.annotationType.type.tsym.members().getSymbols(NON_RECURSIVE)) - if (sym.kind == MTH && sym.name != names.clinit && - (sym.flags() & SYNTHETIC) == 0) - members.add((MethodSymbol) sym); + Set elements = metadata.getAnnotationElements(); // remove the ones that are assigned values for (JCTree arg : a.args) { if (!arg.hasTag(ASSIGN)) continue; // recovery - JCAssign assign = (JCAssign) arg; + JCAssign assign = (JCAssign)arg; Symbol m = TreeInfo.symbol(assign.lhs); if (m == null || m.type.isErroneous()) continue; - if (!members.remove(m)) { + if (!elements.remove(m)) { isValid = false; log.error(assign.lhs.pos(), "duplicate.annotation.member.value", - m.name, a.type); + m.name, a.type); } } // all the remaining ones better have default values List missingDefaults = List.nil(); - for (MethodSymbol m : members) { - if (m.defaultValue == null && !m.type.isErroneous()) { + Set membersWithDefault = metadata.getAnnotationElementsWithDefault(); + for (MethodSymbol m : elements) { + if (m.type.isErroneous()) + continue; + + if (!membersWithDefault.contains(m)) missingDefaults = missingDefaults.append(m.name); - } } missingDefaults = missingDefaults.reverse(); if (missingDefaults.nonEmpty()) { @@ -3088,12 +3147,18 @@ public class Check { log.error(a.pos(), key, a.type, missingDefaults); } + return isValid && validateTargetAnnotationValue(a); + } + + /* Validate the special java.lang.annotation.Target annotation */ + boolean validateTargetAnnotationValue(JCAnnotation a) { // special case: java.lang.annotation.Target must not have // repeated values in its value member if (a.annotationType.type.tsym != syms.annotationTargetType.tsym || - a.args.tail == null) - return isValid; + a.args.tail == null) + return true; + boolean isValid = true; if (!a.args.head.hasTag(ASSIGN)) return false; // error recovery JCAssign assign = (JCAssign) a.args.head; Symbol m = TreeInfo.symbol(assign.lhs); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index 8a7156155fd..385cc9828d8 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -26,6 +26,7 @@ package com.sun.tools.javac.comp; import com.sun.source.tree.LambdaExpressionTree.BodyKind; +import com.sun.source.tree.NewClassTree; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Type.TypeMapping; import com.sun.tools.javac.comp.Resolve.ResolveError; @@ -81,6 +82,8 @@ public class DeferredAttr extends JCTree.Visitor { final Log log; final Symtab syms; final TreeMaker make; + final TreeCopier treeCopier; + final TypeMapping deferredCopier; final Types types; final Flow flow; final Names names; @@ -125,6 +128,35 @@ public class DeferredAttr extends JCTree.Visitor { return "Empty deferred context!"; } }; + + // For speculative attribution, skip the class definition in <>. + treeCopier = + new TreeCopier(make) { + @Override @DefinedBy(Api.COMPILER_TREE) + public JCTree visitNewClass(NewClassTree node, Void p) { + JCNewClass t = (JCNewClass) node; + if (TreeInfo.isDiamond(t)) { + JCExpression encl = copy(t.encl, p); + List typeargs = copy(t.typeargs, p); + JCExpression clazz = copy(t.clazz, p); + List args = copy(t.args, p); + JCClassDecl def = null; + return make.at(t.pos).NewClass(encl, typeargs, clazz, args, def); + } else { + return super.visitNewClass(node, p); + } + } + }; + deferredCopier = new TypeMapping () { + @Override + public Type visitType(Type t, Void v) { + if (t.hasTag(DEFERRED)) { + DeferredType dt = (DeferredType) t; + return new DeferredType(treeCopier.copy(dt.tree), dt.env); + } + return t; + } + }; } /** shared tree for stuck expressions */ @@ -144,14 +176,14 @@ public class DeferredAttr extends JCTree.Visitor { SpeculativeCache speculativeCache; DeferredType(JCExpression tree, Env env) { - super(null, TypeMetadata.empty); + super(null, TypeMetadata.EMPTY); this.tree = tree; this.env = attr.copyEnv(env); this.speculativeCache = new SpeculativeCache(); } @Override - public DeferredType clone(TypeMetadata md) { + public DeferredType cloneWithMetadata(TypeMetadata md) { throw new AssertionError("Cannot add metadata to a deferred type"); } @@ -364,7 +396,7 @@ public class DeferredAttr extends JCTree.Visitor { * disabled during speculative type-checking. */ JCTree attribSpeculative(JCTree tree, Env env, ResultInfo resultInfo) { - return attribSpeculative(tree, env, resultInfo, new TreeCopier<>(make), + return attribSpeculative(tree, env, resultInfo, treeCopier, (newTree)->new DeferredAttrDiagHandler(log, newTree)); } @@ -1209,8 +1241,8 @@ public class DeferredAttr extends JCTree.Visitor { rs.getMemberReference(tree, localEnv, mref2, exprTree.type, tree.name); tree.sym = res; - if (res.kind.isOverloadError() || - res.type.hasTag(FORALL) || + if (res.kind.isResolutionTargetError() || + res.type != null && res.type.hasTag(FORALL) || (res.flags() & Flags.VARARGS) != 0 || (TreeInfo.isStaticSelector(exprTree, tree.name.table.names) && exprTree.type.isRaw())) { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java index d8abe3b6855..7ab179305ef 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ package com.sun.tools.javac.comp; -import java.util.*; import javax.tools.JavaFileObject; import javax.tools.JavaFileManager; @@ -34,7 +33,6 @@ import com.sun.tools.javac.code.Kinds.KindSelector; import com.sun.tools.javac.code.Scope.*; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Type.*; -import com.sun.tools.javac.jvm.*; import com.sun.tools.javac.main.Option.PkgInfo; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; @@ -87,11 +85,11 @@ import static com.sun.tools.javac.code.Kinds.Kind.*; public class Enter extends JCTree.Visitor { protected static final Context.Key enterKey = new Context.Key<>(); + Annotate annotate; Log log; Symtab syms; Check chk; TreeMaker make; - Annotate annotate; TypeEnter typeEnter; Types types; Lint lint; @@ -192,6 +190,7 @@ public class Enter extends JCTree.Visitor { localEnv.info.isSelfCall = false; localEnv.info.lint = null; // leave this to be filled in by Attr, // when annotations have been processed + localEnv.info.isAnonymousDiamond = TreeInfo.isDiamond(env.tree); return localEnv; } @@ -252,11 +251,13 @@ public class Enter extends JCTree.Visitor { Env prevEnv = this.env; try { this.env = env; + annotate.blockAnnotations(); tree.accept(this); return result; } catch (CompletionFailure ex) { return chk.completionError(tree.pos(), ex); } finally { + annotate.unblockAnnotations(); this.env = prevEnv; } } @@ -473,7 +474,7 @@ public class Enter extends JCTree.Visitor { * @param c The class symbol to be processed or null to process all. */ public void complete(List trees, ClassSymbol c) { - annotate.enterStart(); + annotate.blockAnnotations(); ListBuffer prevUncompleted = uncompleted; if (typeEnter.completionEnabled) uncompleted = new ListBuffer<>(); @@ -496,7 +497,7 @@ public class Enter extends JCTree.Visitor { } } finally { uncompleted = prevUncompleted; - annotate.enterDone(); + annotate.unblockAnnotations(); } } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index 933950c02b8..1b0b7d18ca7 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -1885,7 +1885,7 @@ public class LambdaToMethod extends TreeTranslator { * Translate a symbol of a given kind into something suitable for the * synthetic lambda body */ - Symbol translate(Name name, final Symbol sym, LambdaSymbolKind skind) { + Symbol translate(final Symbol sym, LambdaSymbolKind skind) { Symbol ret; switch (skind) { case CAPTURED_THIS: @@ -1893,7 +1893,7 @@ public class LambdaToMethod extends TreeTranslator { break; case TYPE_VAR: // Just erase the type var - ret = new VarSymbol(sym.flags(), name, + ret = new VarSymbol(sym.flags(), sym.name, types.erasure(sym.type), sym.owner); /* this information should also be kept for LVT generation at Gen @@ -1902,7 +1902,7 @@ public class LambdaToMethod extends TreeTranslator { ((VarSymbol)ret).pos = ((VarSymbol)sym).pos; break; case CAPTURED_VAR: - ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) { + ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, sym.name, types.erasure(sym.type), translatedSym) { @Override public Symbol baseSymbol() { //keep mapping with original captured symbol @@ -1911,16 +1911,16 @@ public class LambdaToMethod extends TreeTranslator { }; break; case LOCAL_VAR: - ret = new VarSymbol(sym.flags() & FINAL, name, sym.type, translatedSym); + ret = new VarSymbol(sym.flags() & FINAL, sym.name, sym.type, translatedSym); ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; break; case PARAM: - ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, name, types.erasure(sym.type), translatedSym); + ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, sym.name, types.erasure(sym.type), translatedSym); ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; break; default: - ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym); - ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; + Assert.error(skind.name()); + throw new AssertionError(); } if (ret != sym) { ret.setDeclarationAttributes(sym.getRawAttributes()); @@ -1931,27 +1931,8 @@ public class LambdaToMethod extends TreeTranslator { void addSymbol(Symbol sym, LambdaSymbolKind skind) { Map transMap = getSymbolMap(skind); - Name preferredName; - switch (skind) { - case CAPTURED_THIS: - preferredName = names.fromString("encl$" + transMap.size()); - break; - case CAPTURED_VAR: - preferredName = names.fromString("cap$" + transMap.size()); - break; - case LOCAL_VAR: - preferredName = sym.name; - break; - case PARAM: - preferredName = sym.name; - break; - case TYPE_VAR: - preferredName = sym.name; - break; - default: throw new AssertionError(); - } if (!transMap.containsKey(sym)) { - transMap.put(sym, translate(preferredName, sym, skind)); + transMap.put(sym, translate(sym, skind)); } } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java index 4558aeb9350..72a432676ff 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java @@ -2766,20 +2766,6 @@ public class Lower extends TreeTranslator { return translationMap; } - public void visitAnnotatedType(JCAnnotatedType tree) { - // No need to retain type annotations in the tree - // tree.annotations = translate(tree.annotations); - tree.annotations = List.nil(); - tree.underlyingType = translate(tree.underlyingType); - // but maintain type annotations in the type. - if (tree.type.isAnnotated()) { - tree.type = tree.underlyingType.type.annotatedType(tree.type.getAnnotationMirrors()); - } else if (tree.underlyingType.type.isAnnotated()) { - tree.type = tree.underlyingType.type; - } - result = tree; - } - public void visitTypeCast(JCTypeCast tree) { tree.clazz = translate(tree.clazz); if (tree.type.isPrimitive() != tree.expr.type.isPrimitive()) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java index 92072680708..46b65e5be4d 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,6 @@ package com.sun.tools.javac.comp; -import javax.tools.JavaFileObject; - import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.tree.*; @@ -224,10 +222,12 @@ public class MemberEnter extends JCTree.Visitor { annotate.annotateLater(tree.mods.annotations, localEnv, m, tree.pos()); // Visit the signature of the method. Note that // TypeAnnotate doesn't descend into the body. - annotate.annotateTypeLater(tree, localEnv, m, tree.pos()); + annotate.queueScanTreeAndTypeAnnotate(tree, localEnv, m, tree.pos()); - if (tree.defaultValue != null) - annotateDefaultValueLater(tree.defaultValue, localEnv, m, tree.pos()); + if (tree.defaultValue != null) { + m.defaultValue = annotate.unfinishedDefaultValue(); // set it to temporary sentinel for now + annotate.annotateDefaultValueLater(tree.defaultValue, localEnv, m, tree.pos()); + } } /** Create a fresh environment for method bodies. @@ -255,6 +255,7 @@ public class MemberEnter extends JCTree.Visitor { localEnv.info.staticLevel++; } DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); + try { if (TreeInfo.isEnumInit(tree)) { attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype); @@ -297,7 +298,7 @@ public class MemberEnter extends JCTree.Visitor { } annotate.annotateLater(tree.mods.annotations, localEnv, v, tree.pos()); - annotate.annotateTypeLater(tree.vartype, localEnv, v, tree.pos()); + annotate.queueScanTreeAndTypeAnnotate(tree.vartype, localEnv, v, tree.pos()); v.pos = tree.pos; } @@ -434,53 +435,4 @@ public class MemberEnter extends JCTree.Visitor { Env iEnv = initEnv(tree, env); return iEnv; } - - /** Queue processing of an attribute default value. */ - void annotateDefaultValueLater(final JCExpression defaultValue, - final Env localEnv, - final MethodSymbol m, - final DiagnosticPosition deferPos) { - annotate.normal(new Annotate.Worker() { - @Override - public String toString() { - return "annotate " + m.owner + "." + - m + " default " + defaultValue; - } - - @Override - public void run() { - JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); - DiagnosticPosition prevLintPos = deferredLintHandler.setPos(deferPos); - try { - enterDefaultValue(defaultValue, localEnv, m); - } finally { - deferredLintHandler.setPos(prevLintPos); - log.useSource(prev); - } - } - }); - annotate.validate(new Annotate.Worker() { //validate annotations - @Override - public void run() { - JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); - try { - // if default value is an annotation, check it is a well-formed - // annotation value (e.g. no duplicate values, no missing values, etc.) - chk.validateAnnotationTree(defaultValue); - } finally { - log.useSource(prev); - } - } - }); - } - - /** Enter a default value for an attribute method. */ - private void enterDefaultValue(final JCExpression defaultValue, - final Env localEnv, - final MethodSymbol m) { - m.defaultValue = annotate.enterAttributeValue(m.type.getReturnType(), - defaultValue, - localEnv); - } - } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java index 5e1fb9e8040..ba0e01df0a2 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -194,7 +194,7 @@ public class Resolve { void reportVerboseResolutionDiagnostic(DiagnosticPosition dpos, Name name, Type site, List argtypes, List typeargtypes, Symbol bestSoFar) { - boolean success = !bestSoFar.kind.isOverloadError(); + boolean success = !bestSoFar.kind.isResolutionError(); if (success && !verboseResolutionMode.contains(VerboseResolutionMode.SUCCESS)) { return; @@ -1389,7 +1389,7 @@ public class Resolve { if (currentSymbol.kind != VAR) continue; // invariant: sym.kind == Symbol.Kind.VAR - if (!bestSoFar.kind.isOverloadError() && + if (!bestSoFar.kind.isResolutionError() && currentSymbol.owner != bestSoFar.owner) return new AmbiguityError(bestSoFar, currentSymbol); else if (!bestSoFar.kind.betterThan(VAR)) { @@ -1432,11 +1432,11 @@ public class Resolve { !sym.isInheritedIn(site.tsym, types)) { return bestSoFar; } else if (useVarargs && (sym.flags() & VARARGS) == 0) { - return bestSoFar.kind.isOverloadError() ? + return bestSoFar.kind.isResolutionError() ? new BadVarargsMethod((ResolveError)bestSoFar.baseSymbol()) : bestSoFar; } - Assert.check(!sym.kind.isOverloadError()); + Assert.check(!sym.kind.isResolutionError()); try { Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes, allowBoxing, useVarargs, types.noWarnings); @@ -1457,7 +1457,7 @@ public class Resolve { ? new AccessError(env, site, sym) : bestSoFar; } - return (bestSoFar.kind.isOverloadError() && bestSoFar.kind != AMBIGUOUS) + return (bestSoFar.kind.isResolutionError() && bestSoFar.kind != AMBIGUOUS) ? sym : mostSpecific(argtypes, sym, bestSoFar, env, site, useVarargs); } @@ -1939,8 +1939,8 @@ public class Resolve { bestSoFar.kind != AMBIGUOUS && l.nonEmpty(); l = l.tail) { sym = findMemberType(env, site, name, l.head.tsym); - if (!bestSoFar.kind.isOverloadError() && - !sym.kind.isOverloadError() && + if (!bestSoFar.kind.isResolutionError() && + !sym.kind.isResolutionError() && sym.owner != bestSoFar.owner) bestSoFar = new AmbiguityError(bestSoFar, sym); else @@ -2176,7 +2176,7 @@ public class Resolve { List argtypes, List typeargtypes, LogResolveHelper logResolveHelper) { - if (sym.kind.isOverloadError()) { + if (sym.kind.isResolutionError()) { ResolveError errSym = (ResolveError)sym.baseSymbol(); sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol); argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes); @@ -2366,7 +2366,7 @@ public class Resolve { } @Override Symbol access(Env env, DiagnosticPosition pos, Symbol location, Symbol sym) { - if (sym.kind.isOverloadError()) { + if (sym.kind.isResolutionError()) { sym = super.access(env, pos, location, sym); } else if (allowMethodHandles) { MethodSymbol msym = (MethodSymbol)sym; @@ -2523,7 +2523,7 @@ public class Resolve { } @Override Symbol access(Env env, DiagnosticPosition pos, Symbol location, Symbol sym) { - if (sym.kind.isOverloadError()) { + if (sym.kind.isResolutionError()) { if (sym.kind != WRONG_MTH && sym.kind != WRONG_MTHS) { sym = super.access(env, pos, location, sym); @@ -2555,7 +2555,8 @@ public class Resolve { boolean allowBoxing, boolean useVarargs) { Symbol bestSoFar = methodNotFound; - for (final Symbol sym : site.tsym.members().getSymbolsByName(names.init)) { + TypeSymbol tsym = site.tsym.isInterface() ? syms.objectType.tsym : site.tsym; + for (final Symbol sym : tsym.members().getSymbolsByName(names.init)) { //- System.out.println(" e " + e.sym); if (sym.kind == MTH && (sym.flags_field & SYNTHETIC) == 0) { @@ -2933,7 +2934,7 @@ public class Resolve { */ final boolean shouldStop(Symbol sym, MethodResolutionPhase phase) { return phase.ordinal() > maxPhase.ordinal() || - !sym.kind.isOverloadError() || sym.kind == AMBIGUOUS; + !sym.kind.isResolutionError() || sym.kind == AMBIGUOUS; } /** @@ -2979,7 +2980,7 @@ public class Resolve { @Override Symbol access(Env env, DiagnosticPosition pos, Symbol location, Symbol sym) { - if (sym.kind.isOverloadError()) { + if (sym.kind.isResolutionError()) { //if nothing is found return the 'first' error sym = accessMethod(sym, pos, location, site, name, true, argtypes, typeargtypes); } @@ -3321,7 +3322,7 @@ public class Resolve { boolean hasEnclosingInstance(Env env, Type type) { Symbol encl = resolveSelfContainingInternal(env, type.tsym, false); - return encl != null && !encl.kind.isOverloadError(); + return encl != null && !encl.kind.isResolutionError(); } private Symbol resolveSelfContainingInternal(Env env, @@ -3503,7 +3504,7 @@ public class Resolve { @Override public Symbol access(Name name, TypeSymbol location) { - if (!sym.kind.isOverloadError() && sym.kind.matches(KindSelector.TYP)) + if (!sym.kind.isResolutionError() && sym.kind.matches(KindSelector.TYP)) return types.createErrorType(name, location, sym.type).tsym; else return sym; @@ -4053,7 +4054,7 @@ public class Resolve { } else { key = "bad.instance.method.in.unbound.lookup"; } - return sym.kind.isOverloadError() ? + return sym.kind.isResolutionError() ? ((ResolveError)sym).getDiagnostic(dkind, pos, location, site, name, argtypes, typeargtypes) : diags.create(dkind, log.currentSource(), pos, key, Kinds.kindName(sym), sym); } @@ -4232,8 +4233,8 @@ public class Resolve { @Override public Symbol mergeResults(Symbol bestSoFar, Symbol sym) { //Check invariants (see {@code LookupHelper.shouldStop}) - Assert.check(bestSoFar.kind.isOverloadError() && bestSoFar.kind != AMBIGUOUS); - if (!sym.kind.isOverloadError()) { + Assert.check(bestSoFar.kind.isResolutionError() && bestSoFar.kind != AMBIGUOUS); + if (!sym.kind.isResolutionError()) { //varargs resolution successful return sym; } else { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java index 90521531f54..f3dbb34b4b7 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -28,6 +28,7 @@ package com.sun.tools.javac.comp; import java.util.*; import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Attribute.TypeCompound; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; @@ -68,6 +69,7 @@ public class TransTypes extends TreeTranslator { private TreeMaker make; private Enter enter; private Types types; + private Annotate annotate; private final Resolve resolve; private final CompileStates compileStates; @@ -91,6 +93,7 @@ public class TransTypes extends TreeTranslator { Source source = Source.instance(context); allowInterfaceBridges = source.allowDefaultMethods(); allowGraphInference = source.allowGraphInference(); + annotate = Annotate.instance(context); } /** A hashtable mapping bridge methods to the methods they override after @@ -751,6 +754,15 @@ public class TransTypes extends TreeTranslator { result = tree; } + public void visitAnnotatedType(JCAnnotatedType tree) { + // For now, we need to keep the annotations in the tree because of the current + // MultiCatch implementation wrt type annotations + List mirrors = annotate.fromAnnotations(tree.annotations); + tree.underlyingType = translate(tree.underlyingType); + tree.type = tree.underlyingType.type.annotatedType(mirrors); + result = tree; + } + public void visitTypeCast(JCTypeCast tree) { tree.clazz = translate(tree.clazz, null); Type originalTarget = tree.type; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java index a27378c6034..c54cfd6db65 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import com.sun.tools.javac.code.Scope.ImportFilter; import com.sun.tools.javac.code.Scope.NamedImportScope; import com.sun.tools.javac.code.Scope.StarImportScope; import com.sun.tools.javac.code.Scope.WriteableScope; +import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.DefinedBy.Api; @@ -135,6 +136,7 @@ public class TypeEnter implements Completer { lint = Lint.instance(context); typeEnvs = TypeEnvs.instance(context); dependencies = Dependencies.instance(context); + Source source = Source.instance(context); allowTypeAnnos = source.allowTypeAnnotations(); allowDeprecationOnImport = source.allowDeprecationOnImport(); } @@ -164,7 +166,7 @@ public class TypeEnter implements Completer { Env topEnv = enter.topLevelEnv(tree); finishImports(tree, () -> { completeClass.resolveImports(tree, topEnv); }); } - } + } } /* ******************************************************************** @@ -184,7 +186,7 @@ public class TypeEnter implements Completer { } try { - annotate.enterStart(); + annotate.blockAnnotations(); sym.flags_field |= UNATTRIBUTED; List> queue; @@ -206,7 +208,7 @@ public class TypeEnter implements Completer { } } } finally { - annotate.enterDone(); + annotate.unblockAnnotations(); } } @@ -780,9 +782,9 @@ public class TypeEnter implements Completer { Env baseEnv = baseEnv(tree, env); if (tree.extending != null) - annotate.annotateTypeLater(tree.extending, baseEnv, sym, tree.pos()); + annotate.queueScanTreeAndTypeAnnotate(tree.extending, baseEnv, sym, tree.pos()); for (JCExpression impl : tree.implementing) - annotate.annotateTypeLater(impl, baseEnv, sym, tree.pos()); + annotate.queueScanTreeAndTypeAnnotate(impl, baseEnv, sym, tree.pos()); annotate.flush(); attribSuperTypes(env, baseEnv); @@ -800,7 +802,7 @@ public class TypeEnter implements Completer { attr.attribTypeVariables(tree.typarams, baseEnv); for (JCTypeParameter tp : tree.typarams) - annotate.annotateTypeLater(tp, baseEnv, sym, tree.pos()); + annotate.queueScanTreeAndTypeAnnotate(tp, baseEnv, sym, tree.pos()); // check that no package exists with same fully qualified name, // but admit classes in the unnamed package which have the same @@ -899,6 +901,11 @@ public class TypeEnter implements Completer { addEnumMembers(tree, env); } memberEnter.memberEnter(tree.defs, env); + + if (tree.sym.isAnnotationType()) { + Assert.checkNull(tree.sym.completer); + tree.sym.setAnnotationTypeMetadata(new AnnotationTypeMetadata(tree.sym, annotate.annotationTypeSourceCompleter())); + } } /** Add the implicit members for an enum type diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/BaseFileManager.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java similarity index 98% rename from langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/BaseFileManager.java rename to langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java index 93a5c68ceef..26d23361bb3 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/BaseFileManager.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java @@ -23,7 +23,7 @@ * questions. */ -package com.sun.tools.javac.util; +package com.sun.tools.javac.file; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -60,8 +60,12 @@ import com.sun.tools.javac.file.Locations; import com.sun.tools.javac.main.Option; import com.sun.tools.javac.main.OptionHelper; import com.sun.tools.javac.main.OptionHelper.GrumpyHelper; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; +import com.sun.tools.javac.util.Log; +import com.sun.tools.javac.util.Options; /** * Utility methods for building a filemanager. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileObject.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileObject.java index a14881b74fe..71c869fc1a3 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileObject.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileObject.java @@ -38,7 +38,6 @@ import javax.lang.model.element.NestingKind; import javax.tools.FileObject; import javax.tools.JavaFileObject; -import com.sun.tools.javac.util.BaseFileManager; import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy.Api; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JRTIndex.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JRTIndex.java index 889ef82d6a6..85752a263c7 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JRTIndex.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JRTIndex.java @@ -48,7 +48,6 @@ import java.util.Set; import javax.tools.FileObject; import com.sun.tools.javac.file.RelativePath.RelativeDirectory; -import com.sun.tools.javac.nio.PathFileObject; import com.sun.tools.javac.util.Context; /** diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java index d513e3763d9..bf9dec5e7f0 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java @@ -63,8 +63,6 @@ import javax.tools.StandardJavaFileManager; import com.sun.tools.javac.file.RelativePath.RelativeDirectory; import com.sun.tools.javac.file.RelativePath.RelativeFile; -import com.sun.tools.javac.nio.PathFileObject; -import com.sun.tools.javac.util.BaseFileManager; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy.Api; @@ -73,8 +71,6 @@ import com.sun.tools.javac.util.ListBuffer; import static javax.tools.StandardLocation.*; -import static com.sun.tools.javac.util.BaseFileManager.getKind; - /** * This class provides access to the source, class and other files * used by the compiler and related tools. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java index 4192482045c..b45aa9bf82f 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java @@ -108,37 +108,23 @@ public class Locations { // Locations can use Paths.get(URI.create("jrt:")) static final Path JRT_MARKER_FILE = Paths.get("JRT_MARKER_FILE"); - public Locations() { + Locations() { initHandlers(); } // could replace Lint by "boolean warn" - public void update(Log log, Lint lint, FSInfo fsInfo) { + void update(Log log, Lint lint, FSInfo fsInfo) { this.log = log; warn = lint.isEnabled(Lint.LintCategory.PATH); this.fsInfo = fsInfo; } - public Collection bootClassPath() { - return getLocation(PLATFORM_CLASS_PATH); - } - - public boolean isDefaultBootClassPath() { + boolean isDefaultBootClassPath() { BootClassPathLocationHandler h = (BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH); return h.isDefault(); } - public Collection userClassPath() { - return getLocation(CLASS_PATH); - } - - public Collection sourcePath() { - Collection p = getLocation(SOURCE_PATH); - // TODO: this should be handled by the LocationHandler - return p == null || p.isEmpty() ? null : p; - } - /** * Split a search path into its elements. Empty path elements will be ignored. * @@ -753,7 +739,7 @@ public class Locations { } } - public boolean handleOption(Option option, String value) { + boolean handleOption(Option option, String value) { LocationHandler h = handlersForOption.get(option); return (h == null ? false : h.handleOption(option, value)); } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/PathFileObject.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java similarity index 99% rename from langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/PathFileObject.java rename to langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java index 36bd8162799..5a5c3761a74 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/PathFileObject.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java @@ -23,7 +23,7 @@ * questions. */ -package com.sun.tools.javac.nio; +package com.sun.tools.javac.file; import java.io.IOException; import java.io.InputStream; @@ -40,11 +40,11 @@ import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; import java.util.Objects; + import javax.lang.model.element.Modifier; import javax.lang.model.element.NestingKind; import javax.tools.JavaFileObject; -import com.sun.tools.javac.util.BaseFileManager; import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy.Api; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java index 641098642ae..abcf45da00f 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -36,17 +36,17 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; - import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; - +import com.sun.tools.javac.comp.Annotate; +import com.sun.tools.javac.comp.Annotate.AnnotationTypeCompleter; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Lint.LintCategory; import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.code.Type.*; -import com.sun.tools.javac.comp.Annotate; +import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata; import com.sun.tools.javac.file.BaseFileObject; import com.sun.tools.javac.jvm.ClassFile.NameAndType; import com.sun.tools.javac.jvm.ClassFile.Version; @@ -81,7 +81,7 @@ public class ClassReader { public static final int INITIAL_BUFFER_SIZE = 0x0fff0; - Annotate annotate; + private final Annotate annotate; /** Switch: verbose output. */ @@ -190,6 +190,18 @@ public class ClassReader { */ Set warnedAttrs = new HashSet<>(); + /** + * The prototype @Target Attribute.Compound if this class is an annotation annotated with + * @Target + */ + CompoundAnnotationProxy target; + + /** + * The prototype @Repetable Attribute.Compound if this class is an annotation annotated with + * @Repeatable + */ + CompoundAnnotationProxy repeatable; + /** Get the ClassReader instance for this invocation. */ public static ClassReader instance(Context context) { ClassReader instance = context.get(classReaderKey); @@ -201,6 +213,7 @@ public class ClassReader { /** Construct a new class reader. */ protected ClassReader(Context context) { context.put(classReaderKey, this); + annotate = Annotate.instance(context); names = Names.instance(context); syms = Symtab.instance(context); types = Types.instance(context); @@ -212,9 +225,8 @@ public class ClassReader { log = Log.instance(context); Options options = Options.instance(context); - annotate = Annotate.instance(context); - verbose = options.isSet(VERBOSE); - checkClassFile = options.isSet("-checkclassfile"); + verbose = options.isSet(VERBOSE); + checkClassFile = options.isSet("-checkclassfile"); Source source = Source.instance(context); allowSimplifiedVarargs = source.allowSimplifiedVarargs(); @@ -1304,6 +1316,13 @@ public class ClassReader { ListBuffer proxies = new ListBuffer<>(); for (int i = 0; i deproxyCompoundList(List pl) { // also must fill in types!!!! @@ -1855,19 +1877,19 @@ public class ClassReader { } } - class AnnotationDefaultCompleter extends AnnotationDeproxy implements Annotate.Worker { + class AnnotationDefaultCompleter extends AnnotationDeproxy implements Runnable { final MethodSymbol sym; final Attribute value; final JavaFileObject classFile = currentClassFile; - @Override - public String toString() { - return " ClassReader store default for " + sym.owner + "." + sym + " is " + value; - } + AnnotationDefaultCompleter(MethodSymbol sym, Attribute value) { + super(currentOwner.kind == MTH + ? currentOwner.enclClass() : (ClassSymbol)currentOwner); this.sym = sym; this.value = value; } - // implement Annotate.Worker.run() + + @Override public void run() { JavaFileObject previousClassFile = currentClassFile; try { @@ -1880,22 +1902,27 @@ public class ClassReader { currentClassFile = previousClassFile; } } + + @Override + public String toString() { + return " ClassReader store default for " + sym.owner + "." + sym + " is " + value; + } } - class AnnotationCompleter extends AnnotationDeproxy implements Annotate.Worker { + class AnnotationCompleter extends AnnotationDeproxy implements Runnable { final Symbol sym; final List l; final JavaFileObject classFile; - @Override - public String toString() { - return " ClassReader annotate " + sym.owner + "." + sym + " with " + l; - } + AnnotationCompleter(Symbol sym, List l) { + super(currentOwner.kind == MTH + ? currentOwner.enclClass() : (ClassSymbol)currentOwner); this.sym = sym; this.l = l; this.classFile = currentClassFile; } - // implement Annotate.Worker.run() + + @Override public void run() { JavaFileObject previousClassFile = currentClassFile; try { @@ -1910,6 +1937,11 @@ public class ClassReader { currentClassFile = previousClassFile; } } + + @Override + public String toString() { + return " ClassReader annotate " + sym.owner + "." + sym + " with " + l; + } } class TypeAnnotationCompleter extends AnnotationCompleter { @@ -2298,6 +2330,8 @@ public class ClassReader { currentClassFile = c.classfile; warnedAttrs.clear(); filling = true; + target = null; + repeatable = null; try { bp = 0; buf = readInputStream(buf, c.classfile.openInputStream()); @@ -2318,6 +2352,12 @@ public class ClassReader { Name name = missingTypeVariables.head.tsym.name; throw badClassFile("undecl.type.var", name); } + + if ((c.flags_field & Flags.ANNOTATION) != 0) { + c.setAnnotationTypeMetadata(new AnnotationTypeMetadata(c, new CompleterDeproxy(c, target, repeatable))); + } else { + c.setAnnotationTypeMetadata(AnnotationTypeMetadata.notAnAnnotationType()); + } } catch (IOException ex) { throw badClassFile("unable.to.access.file", ex.getMessage()); } catch (ArrayIndexOutOfBoundsException ex) { @@ -2515,4 +2555,42 @@ public class ClassReader { return name.hashCode(); } } + + private class CompleterDeproxy implements AnnotationTypeCompleter { + ClassSymbol proxyOn; + CompoundAnnotationProxy target; + CompoundAnnotationProxy repeatable; + + public CompleterDeproxy(ClassSymbol c, CompoundAnnotationProxy target, + CompoundAnnotationProxy repeatable) + { + this.proxyOn = c; + this.target = target; + this.repeatable = repeatable; + } + + @Override + public void complete(ClassSymbol sym) { + Assert.check(proxyOn == sym); + Attribute.Compound theTarget = null, theRepeatable = null; + AnnotationDeproxy deproxy; + + try { + if (target != null) { + deproxy = new AnnotationDeproxy(proxyOn); + theTarget = deproxy.deproxyCompound(target); + } + + if (repeatable != null) { + deproxy = new AnnotationDeproxy(proxyOn); + theRepeatable = deproxy.deproxyCompound(repeatable); + } + } catch (Exception e) { + throw new CompletionFailure(sym, e.getMessage()); + } + + sym.getAnnotationTypeMetadata().setTarget(theTarget); + sym.getAnnotationTypeMetadata().setRepeatable(theRepeatable); + } + } } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java index 329deb81353..305847f6ac3 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java @@ -497,13 +497,9 @@ public class Code { case aaload: { state.pop(1);// index Type a = state.stack[state.stacksize-1]; + Assert.check(!a.hasTag(BOT)); // null type as is cannot be indexed. state.pop(1); - //sometimes 'null type' is treated as a one-dimensional array type - //see Gen.visitLiteral - we should handle this case accordingly - Type stackType = a.hasTag(BOT) ? - syms.objectType : - types.erasure(types.elemtype(a)); - state.push(stackType); } + state.push(types.erasure(types.elemtype(a))); } break; case goto_: markDead(); @@ -2166,7 +2162,11 @@ public class Code { boolean keepLocalVariables = varDebugInfo || (var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations()); if (!keepLocalVariables) return; - if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; + //don't keep synthetic vars, unless they are lambda method parameters + boolean ignoredSyntheticVar = (var.sym.flags() & Flags.SYNTHETIC) != 0 && + ((var.sym.owner.flags() & Flags.LAMBDA_METHOD) == 0 || + (var.sym.flags() & Flags.PARAMETER) == 0); + if (ignoredSyntheticVar) return; if (varBuffer == null) varBuffer = new LocalVar[20]; else diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java index 67f47e6b8e6..32adf0723a0 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -75,6 +75,7 @@ public class Gen extends JCTree.Visitor { private final Types types; private final Lower lower; private final Flow flow; + private final Annotate annotate; /** Format of stackmap tables to be generated. */ private final Code.StackMapFormat stackMap; @@ -142,6 +143,7 @@ public class Gen extends JCTree.Visitor { } this.jsrlimit = setjsrlimit; this.useJsrLocally = false; // reset in visitTry + annotate = Annotate.instance(context); } /** Switches @@ -1468,21 +1470,18 @@ public class Gen extends JCTree.Visitor { int startpc, int endpc, List gaps) { if (startpc != endpc) { - List subClauses = TreeInfo.isMultiCatch(tree) ? - ((JCTypeUnion)tree.param.vartype).alternatives : - List.of(tree.param.vartype); + List, JCExpression>> catchTypeExprs + = catchTypesWithAnnotations(tree); while (gaps.nonEmpty()) { - for (JCExpression subCatch : subClauses) { + for (Pair, JCExpression> subCatch1 : catchTypeExprs) { + JCExpression subCatch = subCatch1.snd; int catchType = makeRef(tree.pos(), subCatch.type); int end = gaps.head.intValue(); registerCatch(tree.pos(), startpc, end, code.curCP(), catchType); - if (subCatch.type.isAnnotated()) { - for (Attribute.TypeCompound tc : - subCatch.type.getAnnotationMirrors()) { + for (Attribute.TypeCompound tc : subCatch1.fst) { tc.position.setCatchInfo(catchType, startpc); - } } } gaps = gaps.tail; @@ -1490,16 +1489,14 @@ public class Gen extends JCTree.Visitor { gaps = gaps.tail; } if (startpc < endpc) { - for (JCExpression subCatch : subClauses) { + for (Pair, JCExpression> subCatch1 : catchTypeExprs) { + JCExpression subCatch = subCatch1.snd; int catchType = makeRef(tree.pos(), subCatch.type); registerCatch(tree.pos(), startpc, endpc, code.curCP(), catchType); - if (subCatch.type.isAnnotated()) { - for (Attribute.TypeCompound tc : - subCatch.type.getAnnotationMirrors()) { - tc.position.setCatchInfo(catchType, startpc); - } + for (Attribute.TypeCompound tc : subCatch1.fst) { + tc.position.setCatchInfo(catchType, startpc); } } } @@ -1507,7 +1504,7 @@ public class Gen extends JCTree.Visitor { code.statBegin(tree.pos); code.markStatBegin(); int limit = code.nextreg; - int exlocal = code.newLocal(exparam); + code.newLocal(exparam); items.makeLocalItem(exparam).store(); code.statBegin(TreeInfo.firstStatPos(tree.body)); genStat(tree.body, env, CRT_BLOCK); @@ -1515,6 +1512,30 @@ public class Gen extends JCTree.Visitor { code.statBegin(TreeInfo.endPos(tree.body)); } } + // where + List, JCExpression>> catchTypesWithAnnotations(JCCatch tree) { + return TreeInfo.isMultiCatch(tree) ? + catchTypesWithAnnotationsFromMulticatch((JCTypeUnion)tree.param.vartype, tree.param.sym.getRawTypeAttributes()) : + List.of(new Pair<>(tree.param.sym.getRawTypeAttributes(), tree.param.vartype)); + } + // where + List, JCExpression>> catchTypesWithAnnotationsFromMulticatch(JCTypeUnion tree, List first) { + List alts = tree.alternatives; + List, JCExpression>> res = List.of(new Pair<>(first, alts.head)); + alts = alts.tail; + + while(alts != null && alts.head != null) { + JCExpression alt = alts.head; + if (alt instanceof JCAnnotatedType) { + JCAnnotatedType a = (JCAnnotatedType)alt; + res = res.prepend(new Pair<>(annotate.fromAnnotations(a.annotations), alt)); + } else { + res = res.prepend(new Pair<>(List.nil(), alt)); + } + alts = alts.tail; + } + return res.reverse(); + } /** Register a catch clause in the "Exceptions" code-attribute. */ @@ -1860,6 +1881,13 @@ public class Gen extends JCTree.Visitor { public void visitAssign(JCAssign tree) { Item l = genExpr(tree.lhs, tree.lhs.type); genExpr(tree.rhs, tree.lhs.type).load(); + if (tree.rhs.type.hasTag(BOT)) { + /* This is just a case of widening reference conversion that per 5.1.5 simply calls + for "regarding a reference as having some other type in a manner that can be proved + correct at compile time." + */ + code.state.forceStackTop(tree.lhs.type); + } result = items.makeAssignItem(l); } @@ -2045,7 +2073,7 @@ public class Gen extends JCTree.Visitor { code.emitop2(new_, makeRef(pos, stringBufferType)); code.emitop0(dup); callMethod( - pos, stringBufferType, names.init, List.nil(), false); + pos, stringBufferType, names.init, List.nil(), false); } /** Append value (on tos) to string buffer (on tos - 1). @@ -2093,11 +2121,11 @@ public class Gen extends JCTree.Visitor { */ void bufferToString(DiagnosticPosition pos) { callMethod( - pos, - stringBufferType, - names.toString, - List.nil(), - false); + pos, + stringBufferType, + names.toString, + List.nil(), + false); } /** Complete generating code for operation, with left operand @@ -2272,12 +2300,7 @@ public class Gen extends JCTree.Visitor { public void visitLiteral(JCLiteral tree) { if (tree.type.hasTag(BOT)) { code.emitop0(aconst_null); - if (types.dimensions(pt) > 1) { - code.emitop2(checkcast, makeRef(tree.pos(), pt)); - result = items.makeStackItem(pt); - } else { - result = items.makeStackItem(tree.type); - } + result = items.makeStackItem(tree.type); } else result = items.makeImmediateItem(tree.type, tree.value); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/UninitializedType.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/UninitializedType.java index d1dacc35369..5b40f6419fa 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/UninitializedType.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/UninitializedType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ class UninitializedType extends Type.DelegatedType { } @Override - public UninitializedType clone(final TypeMetadata md) { + public UninitializedType cloneWithMetadata(final TypeMetadata md) { return new UninitializedType(tag, qtype, offset, md); } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java index a37f37aa084..c08b59febdc 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java @@ -42,7 +42,7 @@ import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.jvm.Profile; import com.sun.tools.javac.jvm.Target; import com.sun.tools.javac.main.OptionHelper.GrumpyHelper; -import com.sun.tools.javac.util.BaseFileManager; +import com.sun.tools.javac.file.BaseFileManager; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java index 909cb2b505d..46d591ee93e 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java @@ -39,6 +39,7 @@ import javax.tools.JavaFileManager; import com.sun.tools.javac.api.BasicJavacTask; import com.sun.tools.javac.file.CacheFSInfo; +import com.sun.tools.javac.file.BaseFileManager; import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.processing.AnnotationProcessingError; import com.sun.tools.javac.util.*; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java index 9849f2d0c47..ed6642857ae 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,11 +25,13 @@ package com.sun.tools.javac.model; +import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import javax.lang.model.element.*; import javax.lang.model.type.*; @@ -115,14 +117,17 @@ public class JavacTypes implements javax.lang.model.util.Types { @DefinedBy(Api.LANGUAGE_MODEL) public List directSupertypes(TypeMirror t) { validateTypeNotIn(t, EXEC_OR_PKG); - return types.directSupertypes((Type) t); + Type ty = (Type)t; + return types.directSupertypes(ty).stream() + .map(Type::stripMetadataIfNeeded) + .collect(Collectors.toList()); } @DefinedBy(Api.LANGUAGE_MODEL) public TypeMirror erasure(TypeMirror t) { if (t.getKind() == TypeKind.PACKAGE) throw new IllegalArgumentException(t.toString()); - return types.erasure((Type) t); + return types.erasure((Type)t).stripMetadataIfNeeded(); } @DefinedBy(Api.LANGUAGE_MODEL) @@ -143,7 +148,7 @@ public class JavacTypes implements javax.lang.model.util.Types { @DefinedBy(Api.LANGUAGE_MODEL) public TypeMirror capture(TypeMirror t) { validateTypeNotIn(t, EXEC_OR_PKG); - return types.capture((Type) t); + return types.capture((Type)t).stripMetadataIfNeeded(); } @DefinedBy(Api.LANGUAGE_MODEL) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java deleted file mode 100644 index 3161afeb8c0..00000000000 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java +++ /dev/null @@ -1,547 +0,0 @@ -/* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javac.nio; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.charset.Charset; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.FileVisitOption; -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.Collection; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import javax.lang.model.SourceVersion; -import javax.tools.FileObject; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; -import javax.tools.JavaFileObject.Kind; -import javax.tools.StandardLocation; - -import com.sun.tools.javac.util.BaseFileManager; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; -import com.sun.tools.javac.util.List; -import com.sun.tools.javac.util.ListBuffer; - -import static java.nio.file.FileVisitOption.*; - -import static javax.tools.StandardLocation.*; - -import static com.sun.tools.javac.main.Option.*; - - -// NOTE the imports carefully for this compilation unit. -// -// Path: java.nio.file.Path -- the new NIO type for which this file manager exists -// -// Paths: com.sun.tools.javac.file.Paths -- legacy javac type for handling path options -// The other Paths (java.nio.file.Paths) is not used - -// NOTE this and related classes depend on new API in JDK 7. -// This requires special handling while bootstrapping the JDK build, -// when these classes might not yet have been compiled. To workaround -// this, the build arranges to make stubs of these classes available -// when compiling this and related classes. The set of stub files -// is specified in make/build.properties. - -/** - * Implementation of PathFileManager: a JavaFileManager based on the use - * of java.nio.file.Path. - * - *

        Just as a Path is somewhat analagous to a File, so too is this - * JavacPathFileManager analogous to JavacFileManager, as it relates to the - * support of FileObjects based on File objects (i.e. just RegularFileObject, - * not ZipFileObject and its variants.) - * - *

        The default values for the standard locations supported by this file - * manager are the same as the default values provided by JavacFileManager -- - * i.e. as determined by the javac.file.Paths class. To override these values, - * call {@link #setLocation}. - * - *

        To reduce confusion with Path objects, the locations such as "class path", - * "source path", etc, are generically referred to here as "search paths". - * - *

        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. - */ -public class JavacPathFileManager extends BaseFileManager implements PathFileManager { - protected FileSystem defaultFileSystem; - - /** - * Create a JavacPathFileManager using a given context, optionally registering - * it as the JavaFileManager for that context. - */ - public JavacPathFileManager(Context context, boolean register, Charset charset) { - super(charset); - if (register) - context.put(JavaFileManager.class, this); - pathsForLocation = new HashMap<>(); - fileSystems = new HashMap<>(); - setContext(context); - } - - /** - * Set the context for JavacPathFileManager. - */ - @Override - public void setContext(Context context) { - super.setContext(context); - } - - @Override - public FileSystem getDefaultFileSystem() { - if (defaultFileSystem == null) - defaultFileSystem = FileSystems.getDefault(); - return defaultFileSystem; - } - - @Override - public void setDefaultFileSystem(FileSystem fs) { - defaultFileSystem = fs; - } - - @Override @DefinedBy(Api.COMPILER) - public void flush() throws IOException { - contentCache.clear(); - } - - @Override @DefinedBy(Api.COMPILER) - public void close() throws IOException { - for (FileSystem fs: fileSystems.values()) - fs.close(); - } - - @Override @DefinedBy(Api.COMPILER) - public ClassLoader getClassLoader(Location location) { - nullCheck(location); - Iterable path = getLocation(location); - if (path == null) - return null; - ListBuffer lb = new ListBuffer<>(); - for (Path p: path) { - try { - lb.append(p.toUri().toURL()); - } catch (MalformedURLException e) { - throw new AssertionError(e); - } - } - - return getClassLoader(lb.toArray(new URL[lb.size()])); - } - - // - - @DefinedBy(Api.COMPILER) - public boolean hasLocation(Location location) { - return (getLocation(location) != null); - } - - public Iterable getLocation(Location location) { - nullCheck(location); - lazyInitSearchPaths(); - PathsForLocation path = pathsForLocation.get(location); - if (path == null && !pathsForLocation.containsKey(location)) { - setDefaultForLocation(location); - path = pathsForLocation.get(location); - } - return path; - } - - private Path getOutputLocation(Location location) { - Iterable paths = getLocation(location); - return (paths == null ? null : paths.iterator().next()); - } - - public void setLocation(Location location, Iterable searchPath) - throws IOException - { - nullCheck(location); - lazyInitSearchPaths(); - if (searchPath == null) { - setDefaultForLocation(location); - } else { - if (location.isOutputLocation()) - checkOutputPath(searchPath); - PathsForLocation pl = new PathsForLocation(); - for (Path p: searchPath) - pl.add(p); // TODO -Xlint:path warn if path not found - pathsForLocation.put(location, pl); - } - } - - private void checkOutputPath(Iterable searchPath) throws IOException { - Iterator pathIter = searchPath.iterator(); - if (!pathIter.hasNext()) - throw new IllegalArgumentException("empty path for directory"); - Path path = pathIter.next(); - if (pathIter.hasNext()) - throw new IllegalArgumentException("path too long for directory"); - if (!isDirectory(path)) - throw new IOException(path + ": not a directory"); - } - - private void setDefaultForLocation(Location locn) { - Collection files = null; - if (locn instanceof StandardLocation) { - switch ((StandardLocation) locn) { - case CLASS_PATH: - files = locations.userClassPath(); - break; - case PLATFORM_CLASS_PATH: - files = locations.bootClassPath(); - break; - case SOURCE_PATH: - files = locations.sourcePath(); - break; - case CLASS_OUTPUT: { - String arg = options.get(D); - files = (arg == null ? null : Collections.singleton(Paths.get(arg))); - break; - } - case SOURCE_OUTPUT: { - String arg = options.get(S); - files = (arg == null ? null : Collections.singleton(Paths.get(arg))); - break; - } - } - } - - PathsForLocation pl = new PathsForLocation(); - if (files != null) { - for (Path f: files) - pl.add(f); - } - if (!pl.isEmpty()) - pathsForLocation.put(locn, pl); - } - - private void lazyInitSearchPaths() { - if (!inited) { - setDefaultForLocation(PLATFORM_CLASS_PATH); - setDefaultForLocation(CLASS_PATH); - setDefaultForLocation(SOURCE_PATH); - inited = true; - } - } - // where - private boolean inited = false; - - private Map pathsForLocation; - - private static class PathsForLocation extends LinkedHashSet { - private static final long serialVersionUID = 6788510222394486733L; - } - - // - - // - - @Override - public Path getPath(FileObject fo) { - nullCheck(fo); - if (!(fo instanceof PathFileObject)) - throw new IllegalArgumentException(); - return ((PathFileObject) fo).getPath(); - } - - @Override @DefinedBy(Api.COMPILER) - public boolean isSameFile(FileObject a, FileObject b) { - nullCheck(a); - nullCheck(b); - if (!(a instanceof PathFileObject)) - throw new IllegalArgumentException("Not supported: " + a); - if (!(b instanceof PathFileObject)) - throw new IllegalArgumentException("Not supported: " + b); - return ((PathFileObject) a).isSameFile((PathFileObject) b); - } - - @Override @DefinedBy(Api.COMPILER) - public Iterable list(Location location, - String packageName, Set kinds, boolean recurse) - throws IOException { - // validatePackageName(packageName); - nullCheck(packageName); - nullCheck(kinds); - - Iterable paths = getLocation(location); - if (paths == null) - return List.nil(); - ListBuffer results = new ListBuffer<>(); - - for (Path path : paths) - list(path, packageName, kinds, recurse, results); - - return results.toList(); - } - - private void list(Path path, String packageName, final Set kinds, - boolean recurse, final ListBuffer results) - throws IOException { - if (!Files.exists(path)) - return; - - final Path pathDir; - if (isDirectory(path)) - pathDir = path; - else { - FileSystem fs = getFileSystem(path); - if (fs == null) - return; - pathDir = fs.getRootDirectories().iterator().next(); - } - String sep = path.getFileSystem().getSeparator(); - Path packageDir = packageName.isEmpty() ? pathDir - : pathDir.resolve(packageName.replace(".", sep)); - if (!Files.exists(packageDir)) - return; - -/* Alternate impl of list, superceded by use of Files.walkFileTree */ -// Deque queue = new LinkedList(); -// queue.add(packageDir); -// -// Path dir; -// while ((dir = queue.poll()) != null) { -// DirectoryStream ds = dir.newDirectoryStream(); -// try { -// for (Path p: ds) { -// String name = p.getFileName().toString(); -// if (isDirectory(p)) { -// if (recurse && SourceVersion.isIdentifier(name)) { -// queue.add(p); -// } -// } else { -// if (kinds.contains(getKind(name))) { -// JavaFileObject fe = -// PathFileObject.createDirectoryPathFileObject(this, p, pathDir); -// results.append(fe); -// } -// } -// } -// } finally { -// ds.close(); -// } -// } - int maxDepth = (recurse ? Integer.MAX_VALUE : 1); - Set opts = EnumSet.of(FOLLOW_LINKS); - Files.walkFileTree(packageDir, opts, maxDepth, - new SimpleFileVisitor() { - @Override - public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { - Path name = dir.getFileName(); - if (name == null || SourceVersion.isIdentifier(name.toString())) - return FileVisitResult.CONTINUE; - else - return FileVisitResult.SKIP_SUBTREE; - } - - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { - if (attrs.isRegularFile() && kinds.contains(getKind(file.getFileName().toString()))) { - // WORKAROUND for .jimage files - if (!file.isAbsolute()) - file = pathDir.resolve(file); - JavaFileObject fe = - PathFileObject.createDirectoryPathFileObject( - JavacPathFileManager.this, file, pathDir); - results.append(fe); - } - return FileVisitResult.CONTINUE; - } - }); - } - - @Override - public Iterable getJavaFileObjectsFromPaths( - Iterable paths) { - ArrayList result; - if (paths instanceof Collection) - result = new ArrayList<>(((Collection)paths).size()); - else - result = new ArrayList<>(); - for (Path p: paths) - result.add(PathFileObject.createSimplePathFileObject(this, nullCheck(p))); - return result; - } - - @Override - public Iterable getJavaFileObjects(Path... paths) { - return getJavaFileObjectsFromPaths(Arrays.asList(nullCheck(paths))); - } - - @Override @DefinedBy(Api.COMPILER) - public JavaFileObject getJavaFileForInput(Location location, - String className, Kind kind) throws IOException { - return getFileForInput(location, getRelativePath(className, kind)); - } - - @Override @DefinedBy(Api.COMPILER) - public FileObject getFileForInput(Location location, - String packageName, String relativeName) throws IOException { - return getFileForInput(location, getRelativePath(packageName, relativeName)); - } - - private JavaFileObject getFileForInput(Location location, String relativePath) - throws IOException { - for (Path p: getLocation(location)) { - if (isDirectory(p)) { - Path f = resolve(p, relativePath); - if (Files.exists(f)) - return PathFileObject.createDirectoryPathFileObject(this, f, p); - } else { - FileSystem fs = getFileSystem(p); - if (fs != null) { - Path file = getPath(fs, relativePath); - if (Files.exists(file)) - return PathFileObject.createJarPathFileObject(this, file); - } - } - } - return null; - } - - @Override @DefinedBy(Api.COMPILER) - public JavaFileObject getJavaFileForOutput(Location location, - String className, Kind kind, FileObject sibling) throws IOException { - return getFileForOutput(location, getRelativePath(className, kind), sibling); - } - - @Override @DefinedBy(Api.COMPILER) - public FileObject getFileForOutput(Location location, String packageName, - String relativeName, FileObject sibling) - throws IOException { - return getFileForOutput(location, getRelativePath(packageName, relativeName), sibling); - } - - private JavaFileObject getFileForOutput(Location location, - String relativePath, FileObject sibling) { - Path dir = getOutputLocation(location); - if (dir == null) { - if (location == CLASS_OUTPUT) { - Path siblingDir = null; - if (sibling != null && sibling instanceof PathFileObject) { - siblingDir = ((PathFileObject) sibling).getPath().getParent(); - } - return PathFileObject.createSiblingPathFileObject(this, - siblingDir.resolve(getBaseName(relativePath)), - relativePath); - } else if (location == SOURCE_OUTPUT) { - dir = getOutputLocation(CLASS_OUTPUT); - } - } - - Path file; - if (dir != null) { - file = resolve(dir, relativePath); - return PathFileObject.createDirectoryPathFileObject(this, file, dir); - } else { - file = getPath(getDefaultFileSystem(), relativePath); - return PathFileObject.createSimplePathFileObject(this, file); - } - - } - - @Override @DefinedBy(Api.COMPILER) - public String inferBinaryName(Location location, JavaFileObject fo) { - nullCheck(fo); - // Need to match the path semantics of list(location, ...) - Iterable paths = getLocation(location); - if (paths == null) { - return null; - } - - if (!(fo instanceof PathFileObject)) - throw new IllegalArgumentException(fo.getClass().getName()); - - return ((PathFileObject) fo).inferBinaryName(paths); - } - - private FileSystem getFileSystem(Path p) throws IOException { - FileSystem fs = fileSystems.get(p); - if (fs == null) { - fs = FileSystems.newFileSystem(p, null); - fileSystems.put(p, fs); - } - return fs; - } - - private Map fileSystems; - - // - - // - - private static String getRelativePath(String className, Kind kind) { - return className.replace(".", "/") + kind.extension; - } - - private static String getRelativePath(String packageName, String relativeName) { - return packageName.isEmpty() - ? relativeName : packageName.replace(".", "/") + "/" + relativeName; - } - - private static String getBaseName(String relativePath) { - int lastSep = relativePath.lastIndexOf("/"); - return relativePath.substring(lastSep + 1); // safe if "/" not found - } - - private static boolean isDirectory(Path path) throws IOException { - BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class); - return attrs.isDirectory(); - } - - private static Path getPath(FileSystem fs, String relativePath) { - return fs.getPath(relativePath.replace("/", fs.getSeparator())); - } - - private static Path resolve(Path base, String relativePath) { - FileSystem fs = base.getFileSystem(); - Path rp = fs.getPath(relativePath.replace("/", fs.getSeparator())); - return base.resolve(rp); - } - - // - -} diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/PathFileManager.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/PathFileManager.java deleted file mode 100644 index 762b8ed21fe..00000000000 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/PathFileManager.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javac.nio; - -import java.io.IOException; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Path; -import javax.tools.FileObject; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; - -/** - * File manager based on {@link java.nio.file.Path}. - * - * Eventually, this should be moved to javax.tools. - * Also, JavaCompiler might reasonably provide a method getPathFileManager, - * similar to {@link javax.tools.JavaCompiler#getStandardFileManager - * getStandardFileManager}. However, would need to be handled carefully - * as another forward reference from langtools to jdk. - * - *

        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. - */ -public interface PathFileManager extends JavaFileManager { - /** - * Get the default file system used to create paths. If no value has been - * set, the default file system is {@link FileSystems#getDefault}. - */ - FileSystem getDefaultFileSystem(); - - /** - * Set the default file system used to create paths. - * @param fs the default file system used to create any new paths. - */ - void setDefaultFileSystem(FileSystem fs); - - /** - * Get file objects representing the given files. - * - * @param paths a list of paths - * @return a list of file objects - * @throws IllegalArgumentException if the list of paths includes - * a directory - */ - Iterable getJavaFileObjectsFromPaths( - Iterable paths); - - /** - * Get file objects representing the given paths. - * Convenience method equivalent to: - * - *

        -     *     getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths))
        -     * 
        - * - * @param paths an array of paths - * @return a list of file objects - * @throws IllegalArgumentException if the array of files includes - * a directory - * @throws NullPointerException if the given array contains null - * elements - */ - Iterable getJavaFileObjects(Path... paths); - - /** - * Return the Path for a file object that has been obtained from this - * file manager. - * - * @param fo A file object that has been obtained from this file manager. - * @return The underlying Path object. - * @throws IllegalArgumentException is the file object was not obtained from - * from this file manager. - */ - Path getPath(FileObject fo); - - /** - * Get the search path associated with the given location. - * - * @param location a location - * @return a list of paths or {@code null} if this location has no - * associated search path - * @see #setLocation - */ - Iterable getLocation(Location location); - - /** - * Associate the given search path with the given location. Any - * previous value will be discarded. - * - * @param location a location - * @param searchPath a list of files, if {@code null} use the default - * search path for this location - * @see #getLocation - * @throws IllegalArgumentException if location is an output - * location and searchpath does not contain exactly one element - * @throws IOException if location is an output location and searchpath - * does not represent an existing directory - */ - void setLocation(Location location, Iterable searchPath) throws IOException; -} diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java index 17409cca180..1dee684f910 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -797,7 +797,7 @@ public class DocCommentParser { loop: while (isIdentifierStart(ch)) { int namePos = bp; - Name name = readIdentifier(); + Name name = readAttributeName(); skipWhitespace(); List value = null; ValueKind vkind = ValueKind.EMPTY; @@ -905,6 +905,14 @@ public class DocCommentParser { return names.fromChars(buf, start, bp - start); } + protected Name readAttributeName() { + int start = bp; + nextChar(); + while (bp < buflen && (Character.isUnicodeIdentifierPart(ch) || ch == '-')) + nextChar(); + return names.fromChars(buf, start, bp - start); + } + protected Name readTagName() { int start = bp; nextChar(); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index c3a8900c57c..6dc46740995 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -2010,6 +2010,16 @@ compiler.misc.diamond=\ compiler.misc.diamond.non.generic=\ cannot use ''<>'' with non-generic class {0} +# 0: list of type, 1: message segment +compiler.misc.diamond.invalid.arg=\ + type argument {0} inferred for {1} is not allowed in this context\n\ + inferred argument is not expressible in the Signature attribute + +# 0: list of type, 1: message segment +compiler.misc.diamond.invalid.args=\ + type arguments {0} inferred for {1} are not allowed in this context\n\ + inferred arguments are not expressible in the Signature attribute + # 0: unused compiler.misc.diamond.and.explicit.params=\ cannot use ''<>'' with explicit type parameters for constructor @@ -2271,10 +2281,6 @@ compiler.misc.varargs.implement=\ compiler.misc.varargs.clash.with=\ {0} in {1} overrides {2} in {3} -# 0: unused -compiler.misc.diamond.and.anon.class=\ - cannot use ''<>'' with anonymous inner classes - # 0: symbol kind, 1: symbol, 2: symbol, 3: message segment compiler.misc.inapplicable.method=\ {0} {1}.{2} is not applicable\n\ @@ -2283,6 +2289,11 @@ compiler.misc.inapplicable.method=\ ######################################## # Diagnostics for language feature changes ######################################## +# 0: string +compiler.misc.diamond.and.anon.class.not.supported.in.source=\ + cannot use ''<>'' with anonymous inner classes in -source {0}\n\ + (use -source 9 or higher to enable ''<>'' with anonymous inner classes) + # 0: string compiler.err.unsupported.binary.lit=\ binary literals are not supported in -source {0}\n\ diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java index 656079aa763..a1efba6612f 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,8 +34,6 @@ import javax.lang.model.type.TypeKind; import javax.tools.JavaFileObject; import com.sun.source.tree.*; -import com.sun.source.tree.LambdaExpressionTree.BodyKind; -import com.sun.source.tree.MemberReferenceTree.ReferenceMode; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Scope.*; import com.sun.tools.javac.code.Symbol.*; @@ -2502,12 +2500,6 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { public JCTree annotationType; public List args; - - // Attribute.Compound if tag is ANNOTATION - // Attribute.TypeCompound if tag is TYPE_ANNOTATION - // - // NOTE: This field is slated for removal in the future. Do - // not use it for anything new. public Attribute.Compound attribute; protected JCAnnotation(Tag tag, JCTree annotationType, List args) { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java index b97af9782ef..af23690482f 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -190,6 +190,18 @@ public class TreeInfo { } } + /** Return true if the given tree represents a type elided anonymous class instance creation. */ + public static boolean isAnonymousDiamond(JCTree tree) { + switch(tree.getTag()) { + case NEWCLASS: { + JCNewClass nc = (JCNewClass)tree; + return nc.def != null && isDiamond(nc.clazz); + } + case ANNOTATED_TYPE: return isAnonymousDiamond(((JCAnnotatedType)tree).underlyingType); + default: return false; + } + } + public static boolean isEnumInit(JCTree tree) { switch (tree.getTag()) { case VARDEF: diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java index c543782b888..0925fd1b815 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -234,6 +234,8 @@ public class RichDiagnosticFormatter extends } private boolean unique(TypeVar typevar) { + typevar = (TypeVar)typevar.stripMetadataIfNeeded(); + int found = 0; for (Type t : whereClauses.get(WhereClauseKind.TYPEVAR).keySet()) { if (t.toString().equals(typevar.toString())) { @@ -542,6 +544,7 @@ public class RichDiagnosticFormatter extends @Override public Void visitTypeVar(TypeVar t, Void ignored) { + t = (TypeVar)t.stripMetadataIfNeeded(); if (indexOf(t, WhereClauseKind.TYPEVAR) == -1) { //access the bound type and skip error types Type bound = t.bound; diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java index af11b189914..db34c5cc5c9 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java @@ -56,17 +56,10 @@ abstract class DocFileFactory { DocFileFactory f = factories.get(configuration); if (f == null) { JavaFileManager fm = configuration.getFileManager(); - if (fm instanceof StandardJavaFileManager) + if (fm instanceof StandardJavaFileManager) { f = new StandardDocFileFactory(configuration); - else { - try { - Class pathFileManagerClass = - Class.forName("com.sun.tools.javac.nio.PathFileManager"); - if (pathFileManagerClass.isAssignableFrom(fm.getClass())) - f = new PathDocFileFactory(configuration); - } catch (Throwable t) { - throw new IllegalStateException(t); - } + } else { + throw new IllegalStateException(); } factories.put(configuration, f); } diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java deleted file mode 100644 index 8d208aa5fcf..00000000000 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.tools.doclets.internal.toolkit.util; - - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.io.Writer; -import java.nio.file.DirectoryStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import javax.tools.DocumentationTool; -import javax.tools.FileObject; -import javax.tools.JavaFileManager.Location; -import javax.tools.JavaFileObject; -import javax.tools.StandardLocation; - -import com.sun.tools.doclets.internal.toolkit.Configuration; -import com.sun.tools.javac.nio.PathFileManager; - - -/** - * Implementation of DocFileFactory using a {@link PathFileManager}. - * - *

        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. - * - * @since 1.8 - */ -class PathDocFileFactory extends DocFileFactory { - private final PathFileManager fileManager; - private final Path destDir; - - public PathDocFileFactory(Configuration configuration) { - super(configuration); - fileManager = (PathFileManager) configuration.getFileManager(); - - if (!configuration.destDirName.isEmpty() - || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) { - try { - String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName; - Path dir = fileManager.getDefaultFileSystem().getPath(dirName); - fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir)); - } catch (IOException e) { - throw new DocletAbortException(e); - } - } - - destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next(); - } - - public DocFile createFileForDirectory(String file) { - return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file)); - } - - public DocFile createFileForInput(String file) { - return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file)); - } - - public DocFile createFileForOutput(DocPath path) { - return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path); - } - - @Override - Iterable list(Location location, DocPath path) { - if (location != StandardLocation.SOURCE_PATH) - throw new IllegalArgumentException(); - - Set files = new LinkedHashSet<>(); - if (fileManager.hasLocation(location)) { - for (Path f: fileManager.getLocation(location)) { - if (Files.isDirectory(f)) { - f = f.resolve(path.getPath()); - if (Files.exists(f)) - files.add(new StandardDocFile(f)); - } - } - } - return files; - } - - class StandardDocFile extends DocFile { - private Path file; - - /** Create a StandardDocFile for a given file. */ - private StandardDocFile(Path file) { - super(configuration); - this.file = file; - } - - /** Create a StandardDocFile for a given location and relative path. */ - private StandardDocFile(Location location, DocPath path) { - super(configuration, location, path); - this.file = destDir.resolve(path.getPath()); - } - - /** Open an input stream for the file. */ - public InputStream openInputStream() throws IOException { - JavaFileObject fo = getJavaFileObjectForInput(file); - return new BufferedInputStream(fo.openInputStream()); - } - - /** - * Open an output stream for the file. - * The file must have been created with a location of - * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. - */ - public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException { - if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT) - throw new IllegalStateException(); - - OutputStream out = getFileObjectForOutput(path).openOutputStream(); - return new BufferedOutputStream(out); - } - - /** - * Open an writer for the file, using the encoding (if any) given in the - * doclet configuration. - * The file must have been created with a location of - * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. - */ - public Writer openWriter() throws IOException, UnsupportedEncodingException { - if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT) - throw new IllegalStateException(); - - OutputStream out = getFileObjectForOutput(path).openOutputStream(); - if (configuration.docencoding == null) { - return new BufferedWriter(new OutputStreamWriter(out)); - } else { - return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding)); - } - } - - /** Return true if the file can be read. */ - public boolean canRead() { - return Files.isReadable(file); - } - - /** Return true if the file can be written. */ - public boolean canWrite() { - return Files.isWritable(file); - } - - /** Return true if the file exists. */ - public boolean exists() { - return Files.exists(file); - } - - /** Return the base name (last component) of the file name. */ - public String getName() { - return file.getFileName().toString(); - } - - /** Return the file system path for this file. */ - public String getPath() { - return file.toString(); - } - - /** Return true is file has an absolute path name. */ - public boolean isAbsolute() { - return file.isAbsolute(); - } - - /** Return true is file identifies a directory. */ - public boolean isDirectory() { - return Files.isDirectory(file); - } - - /** Return true is file identifies a file. */ - public boolean isFile() { - return Files.isRegularFile(file); - } - - /** Return true if this file is the same as another. */ - public boolean isSameFile(DocFile other) { - if (!(other instanceof StandardDocFile)) - return false; - - try { - return Files.isSameFile(file, ((StandardDocFile) other).file); - } catch (IOException e) { - return false; - } - } - - /** If the file is a directory, list its contents. */ - public Iterable list() throws IOException { - List files = new ArrayList<>(); - try (DirectoryStream ds = Files.newDirectoryStream(file)) { - for (Path f: ds) { - files.add(new StandardDocFile(f)); - } - } - return files; - } - - /** Create the file as a directory, including any parent directories. */ - public boolean mkdirs() { - try { - Files.createDirectories(file); - return true; - } catch (IOException e) { - return false; - } - } - - /** - * Derive a new file by resolving a relative path against this file. - * The new file will inherit the configuration and location of this file - * If this file has a path set, the new file will have a corresponding - * new path. - */ - public DocFile resolve(DocPath p) { - return resolve(p.getPath()); - } - - /** - * Derive a new file by resolving a relative path against this file. - * The new file will inherit the configuration and location of this file - * If this file has a path set, the new file will have a corresponding - * new path. - */ - public DocFile resolve(String p) { - if (location == null && path == null) { - return new StandardDocFile(file.resolve(p)); - } else { - return new StandardDocFile(location, path.resolve(p)); - } - } - - /** - * Resolve a relative file against the given output location. - * @param locn Currently, only - * {@link DocumentationTool.Location.DOCUMENTATION_OUTPUT} is supported. - */ - public DocFile resolveAgainst(Location locn) { - if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT) - throw new IllegalArgumentException(); - return new StandardDocFile(destDir.resolve(file)); - } - - /** Return a string to identify the contents of this object, - * for debugging purposes. - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("PathDocFile["); - if (location != null) - sb.append("locn:").append(location).append(","); - if (path != null) - sb.append("path:").append(path.getPath()).append(","); - sb.append("file:").append(file); - sb.append("]"); - return sb.toString(); - } - - private JavaFileObject getJavaFileObjectForInput(Path file) { - return fileManager.getJavaFileObjects(file).iterator().next(); - } - - private FileObject getFileObjectForOutput(DocPath path) throws IOException { - // break the path into a package-part and the rest, by finding - // the position of the last '/' before an invalid character for a - // package name, such as the "." before an extension or the "-" - // in filenames like package-summary.html, doc-files or src-html. - String p = path.getPath(); - int lastSep = -1; - for (int i = 0; i < p.length(); i++) { - char ch = p.charAt(i); - if (ch == '/') { - lastSep = i; - } else if (i == lastSep + 1 && !Character.isJavaIdentifierStart(ch) - || !Character.isJavaIdentifierPart(ch)) { - break; - } - } - String pkg = (lastSep == -1) ? "" : p.substring(0, lastSep); - String rest = p.substring(lastSep + 1); - return fileManager.getFileForOutput(location, pkg, rest, null); - } - } - -} diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java index 7b8aa70ea27..0d893a634dd 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java @@ -42,7 +42,7 @@ import com.sun.javadoc.*; import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.main.CommandLine; import com.sun.tools.javac.main.Option; -import com.sun.tools.javac.util.BaseFileManager; +import com.sun.tools.javac.file.BaseFileManager; import com.sun.tools.javac.util.ClientCodeException; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.List; diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTool.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTool.java index eb63a51473a..2aa5c1691dd 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTool.java +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTool.java @@ -46,7 +46,7 @@ import javax.tools.StandardJavaFileManager; import com.sun.tools.javac.api.ClientCodeWrapper; import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.util.BaseFileManager; +import com.sun.tools.javac.file.BaseFileManager; import com.sun.tools.javac.util.ClientCodeException; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.DefinedBy; diff --git a/langtools/test/tools/javac/MethodParameters/LambdaTest.out b/langtools/test/tools/javac/MethodParameters/LambdaTest.out index 2349dd0e0c5..d8367934afd 100644 --- a/langtools/test/tools/javac/MethodParameters/LambdaTest.out +++ b/langtools/test/tools/javac/MethodParameters/LambdaTest.out @@ -2,6 +2,6 @@ class LambdaTest -- LambdaTest.() LambdaTest.foo(i) LambdaTest.lambda$static$1(x1/*synthetic*/)/*synthetic*/ -LambdaTest.lambda$null$0(final cap$0/*synthetic*/, x2/*synthetic*/)/*synthetic*/ +LambdaTest.lambda$null$0(final x1/*synthetic*/, x2/*synthetic*/)/*synthetic*/ static interface LambdaTest$I -- inner LambdaTest$I.m(x) diff --git a/langtools/test/tools/javac/T7040592/CoerceNullToMoreSpecificTypeTest.java b/langtools/test/tools/javac/T7040592/CoerceNullToMoreSpecificTypeTest.java new file mode 100644 index 00000000000..ba84ef5f795 --- /dev/null +++ b/langtools/test/tools/javac/T7040592/CoerceNullToMoreSpecificTypeTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7040592 + * @summary Test that the assertion in State.forceStackTop does not fail at compile time. + */ + +import java.lang.reflect.Field; +import java.util.ArrayList; +import org.w3c.dom.Element; + +public class CoerceNullToMoreSpecificTypeTest { + abstract class NodeImpl { + } + + NodeImpl ownerNode; + + public Element getElement() { + return (Element) (isOwned() ? ownerNode : null); + } + + boolean isOwned() { + return true; + } + + static void processArrays(boolean expectNulls, Object [] nulla, Object [][] nullaa) { + if (expectNulls) { + if (nulla != null || nullaa != null) { + throw new AssertionError("Null actual, but not null formal"); + } + } else { + if (nulla.length != 123 || nullaa.length != 321) + throw new AssertionError("Wrong arrays received"); + } + } + + public static void main(String[] args) { + ArrayList> typeList = new ArrayList<>(); + Field rf = null; + typeList.add((rf != null) ? rf.getType() : null); + processArrays(true, null, null); + processArrays(false, new Object[123], new Object[321][]); + } +} diff --git a/langtools/test/tools/javac/T7040592/T7040592.java b/langtools/test/tools/javac/T7040592/T7040592.java new file mode 100644 index 00000000000..04939cbcc2b --- /dev/null +++ b/langtools/test/tools/javac/T7040592/T7040592.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7040592 + * @summary Verify that null can be assigned freely to array types without a checkcast + */ + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.file.Paths; + +public class T7040592 { + + private static final String assertionErrorMsg = + "null should be assignable to array type without a checkcast"; + + public static void main(String[] args) { + new T7040592().run(); + } + + void run() { + check("-c", Paths.get(System.getProperty("test.classes"), + "T7040592_01.class").toString()); + } + + void check(String... params) { + StringWriter s; + String out; + try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { + com.sun.tools.javap.Main.run(params, pw); + out = s.toString(); + } + if (out.contains("checkcast")) { + throw new AssertionError(assertionErrorMsg); + } + } + +} + +class T7040592_01 { + static void handleArrays(Object [] a, Object [][] b, Object [][][] c) { + } + public static void main(String[] args) { + Object a[]; + Object o = (a = null)[0]; + Object b[][]; + o = (b = null)[0][0]; + Object c[][][]; + o = (c = null)[0][0][0]; + handleArrays(null, null, null); + } +} diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/api/AnnotatedArrayOrder.java b/langtools/test/tools/javac/annotations/typeAnnotations/api/AnnotatedArrayOrder.java index 2c7ac550764..4e457f7832f 100644 --- a/langtools/test/tools/javac/annotations/typeAnnotations/api/AnnotatedArrayOrder.java +++ b/langtools/test/tools/javac/annotations/typeAnnotations/api/AnnotatedArrayOrder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test + * @bug 8031744 * @summary Checks the annotation types targeting array types */ @@ -34,7 +35,6 @@ import java.util.List; import java.util.Map; import java.util.HashMap; import java.lang.annotation.*; -import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import com.sun.source.tree.*; import com.sun.source.util.JavacTask; diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/BasicTest.java b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/BasicTest.java index dac16370cff..71bab2f32ee 100644 --- a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/BasicTest.java +++ b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/BasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6843077 8006775 + * @bug 6843077 8006775 8031744 * @summary random tests for new locations * @author Matt Papi * @compile BasicTest.java @@ -41,12 +41,16 @@ import java.io.*; @interface C {} @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface D {} +@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) +@interface E {} +@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) +@interface F {} /** * Tests basic JSR 308 parser functionality. We don't really care about what * the parse tree looks like, just that these annotations can be parsed. */ -class BasicTest extends @B LinkedList implements @C List { +class BasicTest<@D T extends @A Object> extends @B LinkedList<@E T> implements @C List<@F T> { void test() { diff --git a/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java b/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java index 78a5287f6c7..04a563ce99f 100644 --- a/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java +++ b/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8042251 + * @bug 8042251 8062373 * @summary Testing InnerClasses_attribute of inner classes in anonymous class. * @library /tools/lib /tools/javac/lib ../lib * @build InnerClassesTestBase TestResult TestBase InMemoryFileManager ToolBox @@ -73,6 +73,6 @@ public class InnerClassesInAnonymousClassTest extends InnerClassesTestBase { public void getAdditionalFlags(Map> class2Flags, ClassType type, Modifier... flags) { super.getAdditionalFlags(class2Flags, type, flags); class2Flags.put("Anonymous", getFlags(currentClassType, Arrays.asList(flags))); - class2Flags.put("1", new HashSet<>()); + class2Flags.put("1", new HashSet<>() {}); } } diff --git a/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java b/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java index ce4f3238abd..112862cd2ef 100644 --- a/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java +++ b/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,9 +21,8 @@ * questions. */ -// key: compiler.err.prob.found.req // key: compiler.misc.cant.access.inner.cls.constr -// key: compiler.misc.invalid.mref +// key: compiler.err.invalid.mref class CantAccessInnerClsConstructor { diff --git a/langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java b/langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java index 26ef5e7cfb5..8e94de00630 100644 --- a/langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java +++ b/langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,8 +21,10 @@ * questions. */ -// key: compiler.misc.diamond.and.anon.class +// key: compiler.misc.diamond.and.anon.class.not.supported.in.source // key: compiler.err.cant.apply.diamond.1 +// key: compiler.warn.source.no.bootclasspath +// options: -source 8 import java.util.*; diff --git a/langtools/test/tools/javac/diags/examples/DiamondAndNonDenotableTypes.java b/langtools/test/tools/javac/diags/examples/DiamondAndNonDenotableTypes.java new file mode 100644 index 00000000000..0f2650d3e47 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/DiamondAndNonDenotableTypes.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.misc.diamond +// key: compiler.err.cant.apply.diamond.1 +// key: compiler.misc.diamond.invalid.arg +// key: compiler.misc.diamond.invalid.args + +import java.util.*; + +class DiamondAndNonDenotableType { + DiamondAndNonDenotableType(T t) {} +} + +class DiamondAndNonDenotableTypes { + DiamondAndNonDenotableTypes(T t, S s) {} + void m() { + List wl = null; + new DiamondAndNonDenotableTypes<>(wl, wl) {}; + new DiamondAndNonDenotableType<>(wl) {}; + }; +} diff --git a/langtools/test/tools/javac/doctree/AttrTest.java b/langtools/test/tools/javac/doctree/AttrTest.java index 2e13a16059a..9eace1357b7 100644 --- a/langtools/test/tools/javac/doctree/AttrTest.java +++ b/langtools/test/tools/javac/doctree/AttrTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 7021614 + * @bug 7021614 8076026 * @summary extend com.sun.source API to support parsing javadoc comments * @build DocCommentTester * @run main DocCommentTester AttrTest.java @@ -52,6 +52,30 @@ DocComment[DOC_COMMENT, pos:1 body: empty block tags: empty ] +*/ + + /** + * foo + */ + void hyphened_attr() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + StartElement[START_ELEMENT, pos:1 + name:a + attributes: 1 + Attribute[ATTRIBUTE, pos:4 + name: name-test + vkind: UNQUOTED + value: 1 + Text[TEXT, pos:14, hyphened] + ] + ] + Text[TEXT, pos:23, foo] + EndElement[END_ELEMENT, pos:26, a] + body: empty + block tags: empty +] */ /** diff --git a/langtools/test/tools/javac/failover/CheckAttributedTree.java b/langtools/test/tools/javac/failover/CheckAttributedTree.java index 34222c8736d..66f91ee5e91 100644 --- a/langtools/test/tools/javac/failover/CheckAttributedTree.java +++ b/langtools/test/tools/javac/failover/CheckAttributedTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6970584 8006694 + * @bug 6970584 8006694 8062373 * @summary assorted position errors in compiler syntax trees * temporarily workaround combo tests are causing time out in several platforms * @library ../lib @@ -290,7 +290,7 @@ public class CheckAttributedTree extends JavacTestingAbstractThreadedTest { } public void finished(TaskEvent e) { } }); - + int i = 0; try { Iterable trees = task.parse(); // JavaCompiler c = JavaCompiler.instance(((JavacTaskImpl) task).getContext()); @@ -308,7 +308,7 @@ public class CheckAttributedTree extends JavacTestingAbstractThreadedTest { if (def.hasTag(CLASSDEF) && analyzedElems.contains(((JCTree.JCClassDecl)def).sym)) { //System.err.println("Adding pair..." + cu.sourcefile + " " + ((JCTree.JCClassDecl) def).name); - res.add(new Pair<>(cu, def)); + res.add((i++ % 2) == 0 ? new Pair<>(cu, def) {} : new Pair<>(cu, def)); } } } diff --git a/langtools/test/tools/javac/generics/diamond/6939780/T6939780.java b/langtools/test/tools/javac/generics/diamond/6939780/T6939780.java index 6d7ef0da676..603d48bae4b 100644 --- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780.java +++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780.java @@ -1,11 +1,12 @@ /* * @test /nodynamiccopyright/ - * @bug 6939780 7020044 8009459 8021338 8064365 + * @bug 6939780 7020044 8009459 8021338 8064365 8062373 * - * @summary add a warning to detect diamond sites + * @summary add a warning to detect diamond sites (including anonymous class instance creation at source >= 9) * @author mcimadamore * @compile/ref=T6939780_7.out -Xlint:-options -source 7 T6939780.java -XDrawDiagnostics -XDfind=diamond - * @compile/ref=T6939780_8.out T6939780.java -XDrawDiagnostics -XDfind=diamond + * @compile/ref=T6939780_8.out -Xlint:-options -source 8 T6939780.java -XDrawDiagnostics -XDfind=diamond + * @compile/ref=T6939780_9.out -Xlint:-options -source 9 T6939780.java -XDrawDiagnostics -XDfind=diamond * */ diff --git a/langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out index 52d621d78df..fbf2fe6a0c8 100644 --- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out +++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out @@ -1,5 +1,5 @@ -T6939780.java:21:28: compiler.warn.diamond.redundant.args -T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo, T6939780.Foo -T6939780.java:30:19: compiler.warn.diamond.redundant.args -T6939780.java:31:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo, T6939780.Foo +T6939780.java:22:28: compiler.warn.diamond.redundant.args +T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo, T6939780.Foo +T6939780.java:31:19: compiler.warn.diamond.redundant.args +T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo, T6939780.Foo 4 warnings diff --git a/langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out index 3d979d15147..76e2ea00260 100644 --- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out +++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out @@ -1,7 +1,7 @@ -T6939780.java:20:33: compiler.warn.diamond.redundant.args -T6939780.java:21:28: compiler.warn.diamond.redundant.args -T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo, T6939780.Foo -T6939780.java:29:19: compiler.warn.diamond.redundant.args +T6939780.java:21:33: compiler.warn.diamond.redundant.args +T6939780.java:22:28: compiler.warn.diamond.redundant.args +T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo, T6939780.Foo T6939780.java:30:19: compiler.warn.diamond.redundant.args -T6939780.java:31:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo, T6939780.Foo +T6939780.java:31:19: compiler.warn.diamond.redundant.args +T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo, T6939780.Foo 6 warnings diff --git a/langtools/test/tools/javac/generics/diamond/6939780/T6939780_9.out b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_9.out new file mode 100644 index 00000000000..308851596b5 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_9.out @@ -0,0 +1,13 @@ +T6939780.java:21:33: compiler.warn.diamond.redundant.args +T6939780.java:22:28: compiler.warn.diamond.redundant.args +T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo, T6939780.Foo +T6939780.java:24:33: compiler.warn.diamond.redundant.args +T6939780.java:25:28: compiler.warn.diamond.redundant.args +T6939780.java:26:28: compiler.warn.diamond.redundant.args +T6939780.java:30:19: compiler.warn.diamond.redundant.args +T6939780.java:31:19: compiler.warn.diamond.redundant.args +T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo, T6939780.Foo +T6939780.java:33:19: compiler.warn.diamond.redundant.args +T6939780.java:34:19: compiler.warn.diamond.redundant.args +T6939780.java:35:19: compiler.warn.diamond.redundant.args +12 warnings diff --git a/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java b/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java index 47e7f98a40c..b0f42327d86 100644 --- a/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java +++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6996914 7020044 + * @bug 6996914 7020044 8062373 * @summary Diamond inference: problem when accessing protected constructor * @run main T6996914a */ @@ -53,6 +53,17 @@ public class T6996914a { } } + enum DiamondKind { + STANDARD("new Foo<>();"), + ANON("new Foo<>() {};"); + + String expr; + + DiamondKind(String expr) { + this.expr = expr; + } + } + enum ConstructorKind { PACKAGE(""), PROTECTED("protected"), @@ -93,14 +104,14 @@ public class T6996914a { final static String sourceStub = "#I\n" + "class Test {\n" + - " Foo fs = new Foo<>();\n" + + " Foo fs = #D\n" + "}\n"; String source; - public ClientClass(PackageKind pk) { + public ClientClass(PackageKind pk, DiamondKind dk) { super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); - source = sourceStub.replace("#I", pk.importDecl); + source = sourceStub.replace("#I", pk.importDecl).replace("#D", dk.expr); } @Override @@ -112,20 +123,22 @@ public class T6996914a { public static void main(String... args) throws Exception { for (PackageKind pk : PackageKind.values()) { for (ConstructorKind ck : ConstructorKind.values()) { - compileAndCheck(pk, ck); + for (DiamondKind dk : DiamondKind.values()) { + compileAndCheck(pk, ck, dk); + } } } } - static void compileAndCheck(PackageKind pk, ConstructorKind ck) throws Exception { + static void compileAndCheck(PackageKind pk, ConstructorKind ck, DiamondKind dk) throws Exception { FooClass foo = new FooClass(pk, ck); - ClientClass client = new ClientClass(pk); + ClientClass client = new ClientClass(pk, dk); final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); ErrorListener el = new ErrorListener(); JavacTask ct = (JavacTask)tool.getTask(null, null, el, null, null, Arrays.asList(foo, client)); ct.analyze(); - if (el.errors > 0 == check(pk, ck)) { + if (el.errors > 0 == check(pk, ck, dk)) { String msg = el.errors > 0 ? "Error compiling files" : "No error when compiling files"; @@ -133,9 +146,10 @@ public class T6996914a { } } - static boolean check(PackageKind pk, ConstructorKind ck) { + static boolean check(PackageKind pk, ConstructorKind ck, DiamondKind dk) { switch (pk) { - case A: return ck == ConstructorKind.PUBLIC; + case A: return ck == ConstructorKind.PUBLIC || + (ck == ConstructorKind.PROTECTED && dk == DiamondKind.ANON); case DEFAULT: return ck != ConstructorKind.PRIVATE; default: throw new AssertionError("Unknown package kind"); } diff --git a/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java b/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java index 42339dbb0aa..651ce36a36a 100644 --- a/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java +++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6996914 7020044 + * @bug 6996914 7020044 8062373 * @summary Diamond inference: problem when accessing protected constructor * @compile T6996914b.java */ @@ -35,4 +35,5 @@ class Super { class Test { Super ssi1 = new Super<>(1, "", 2); + Super ssi2 = new Super<>(1, "", 2) {}; } diff --git a/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.java b/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.java index 40a6a8b573e..9793363d9c9 100644 --- a/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.java +++ b/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8065986 + * @bug 8065986 8062373 * * @summary Compiler fails to NullPointerException when calling super with Object<>() * @compile/fail/ref=T8065986b.out T8065986b.java -XDrawDiagnostics @@ -29,5 +29,12 @@ class T8065986b { this(cond ? o1 : o2); } + T8065986b(int x) { + this(new Object<>() {}); + } + + T8065986b(int x, int y) { + this(new ArrayList<>() {}); + } static void m() { } } diff --git a/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.out b/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.out index 30bcfb6eb65..ec65f48b075 100644 --- a/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.out +++ b/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.out @@ -1,6 +1,8 @@ T8065986b.java:13:24: compiler.err.cant.apply.diamond.1: java.lang.Object, (compiler.misc.diamond.non.generic: java.lang.Object) -T8065986b.java:17:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))} -T8065986b.java:21:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @435,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))} -T8065986b.java:25:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @516,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))} -T8065986b.java:29:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @603,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))} -5 errors +T8065986b.java:17:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))} +T8065986b.java:21:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @443,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))} +T8065986b.java:25:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @524,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))} +T8065986b.java:29:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @611,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))} +T8065986b.java:33:24: compiler.err.cant.apply.diamond.1: java.lang.Object, (compiler.misc.diamond.non.generic: java.lang.Object) +T8065986b.java:37:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))} +7 errors diff --git a/langtools/test/tools/javac/generics/diamond/MultipleInferenceHooksTest.java b/langtools/test/tools/javac/generics/diamond/MultipleInferenceHooksTest.java new file mode 100644 index 00000000000..af3f943bedc --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/MultipleInferenceHooksTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8062373 + * @summary Test that <>(){} works fine without verify error when there are multiple post inference hooks. + */ + +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.Set; + +public class MultipleInferenceHooksTest { + public static void main(String[] args) { + Set result = Collections.newSetFromMap(new IdentityHashMap<>() {}); + } +} diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg01.java b/langtools/test/tools/javac/generics/diamond/neg/Neg01.java index acbb06cd6c2..f0e98394110 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg01.java +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary Check that diamond fails when inference violates declared bounds * (basic test with nested class, generic/non-generic constructors) @@ -25,5 +25,16 @@ class Neg01 { Neg01 n6 = new Neg01<>("", ""); Neg01 n7 = new Neg01<>("", ""); Foo n8 = new Neg01<>("", ""); + + Neg01 n9 = new Neg01<>("", ""){}; + Neg01 n10 = new Neg01<>("", ""){}; + Neg01 n11 = new Neg01<>("", ""){}; + Neg01 n12 = new Neg01<>("", ""){}; + + Neg01 n13 = new Neg01<>(""){}; + Neg01 n14 = new Neg01<>(""){}; + Neg01 n15 = new Neg01<>(""){}; + Neg01 n16 = new Neg01<>(""){}; + } } diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg01.out b/langtools/test/tools/javac/generics/diamond/neg/Neg01.out index c2bbf4c35b9..4f54718d44e 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg01.out +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.out @@ -12,4 +12,18 @@ Neg01.java:25:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01 Neg01.java:26:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null Neg01.java:27:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01, null) Neg01.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null -14 errors +Neg01.java:29:15: compiler.err.not.within.bounds: java.lang.String, X +Neg01.java:29:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null +Neg01.java:30:15: compiler.err.not.within.bounds: ? extends java.lang.String, X +Neg01.java:30:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null +Neg01.java:31:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null +Neg01.java:32:15: compiler.err.not.within.bounds: ? super java.lang.String, X +Neg01.java:32:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null +Neg01.java:34:15: compiler.err.not.within.bounds: java.lang.String, X +Neg01.java:34:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null +Neg01.java:35:15: compiler.err.not.within.bounds: ? extends java.lang.String, X +Neg01.java:35:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null +Neg01.java:36:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null +Neg01.java:37:15: compiler.err.not.within.bounds: ? super java.lang.String, X +Neg01.java:37:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null +28 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg02.java b/langtools/test/tools/javac/generics/diamond/neg/Neg02.java index ac4cc2cb998..26ff47d9949 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg02.java +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary Check that diamond fails when inference violates declared bounds * (test with nested class, qualified/simple type expressions) @@ -26,6 +26,16 @@ class Neg02 { Foo f6 = new Foo<>("", ""); Foo f7 = new Foo<>("", ""); Foo f8 = new Foo<>("", ""); + + Foo f9 = new Foo<>(""){}; + Foo f10 = new Foo<>(""){}; + Foo f11 = new Foo<>(""){}; + Foo f12 = new Foo<>(""){}; + + Foo f13 = new Foo<>("", ""){}; + Foo f14 = new Foo<>("", ""){}; + Foo f15 = new Foo<>("", ""){}; + Foo f16 = new Foo<>("", ""){}; } void testQualified() { @@ -38,5 +48,15 @@ class Neg02 { Foo f6 = new Neg02.Foo<>("", ""); Foo f7 = new Neg02.Foo<>("", ""); Foo f8 = new Neg02.Foo<>("", ""); + + Foo f9 = new Neg02.Foo<>(""){}; + Foo f10 = new Neg02.Foo<>(""){}; + Foo f11 = new Neg02.Foo<>(""){}; + Foo f12 = new Neg02.Foo<>(""){}; + + Foo f13 = new Neg02.Foo<>("", ""){}; + Foo f14 = new Neg02.Foo<>("", ""){}; + Foo f15 = new Neg02.Foo<>("", ""){}; + Foo f16 = new Neg02.Foo<>("", ""){}; } } diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg02.out b/langtools/test/tools/javac/generics/diamond/neg/Neg02.out index 4e3d7d201ce..73126ec1f8d 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg02.out +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.out @@ -12,18 +12,46 @@ Neg02.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02 Neg02.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null Neg02.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, X Neg02.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null -Neg02.java:32:13: compiler.err.not.within.bounds: java.lang.String, X -Neg02.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null -Neg02.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, X -Neg02.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null -Neg02.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null -Neg02.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, X -Neg02.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null -Neg02.java:37:13: compiler.err.not.within.bounds: java.lang.String, X -Neg02.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null -Neg02.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, X -Neg02.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null -Neg02.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null -Neg02.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, X -Neg02.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null -28 errors +Neg02.java:30:13: compiler.err.not.within.bounds: java.lang.String, X +Neg02.java:30:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:31:13: compiler.err.not.within.bounds: ? extends java.lang.String, X +Neg02.java:31:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:32:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:33:13: compiler.err.not.within.bounds: ? super java.lang.String, X +Neg02.java:33:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:35:13: compiler.err.not.within.bounds: java.lang.String, X +Neg02.java:35:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:36:13: compiler.err.not.within.bounds: ? extends java.lang.String, X +Neg02.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:37:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:38:13: compiler.err.not.within.bounds: ? super java.lang.String, X +Neg02.java:38:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:42:13: compiler.err.not.within.bounds: java.lang.String, X +Neg02.java:42:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:43:13: compiler.err.not.within.bounds: ? extends java.lang.String, X +Neg02.java:43:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:44:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:45:13: compiler.err.not.within.bounds: ? super java.lang.String, X +Neg02.java:45:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:47:13: compiler.err.not.within.bounds: java.lang.String, X +Neg02.java:47:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:48:13: compiler.err.not.within.bounds: ? extends java.lang.String, X +Neg02.java:48:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:49:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:50:13: compiler.err.not.within.bounds: ? super java.lang.String, X +Neg02.java:50:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:52:13: compiler.err.not.within.bounds: java.lang.String, X +Neg02.java:52:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:53:13: compiler.err.not.within.bounds: ? extends java.lang.String, X +Neg02.java:53:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:54:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:55:13: compiler.err.not.within.bounds: ? super java.lang.String, X +Neg02.java:55:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:57:13: compiler.err.not.within.bounds: java.lang.String, X +Neg02.java:57:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:58:13: compiler.err.not.within.bounds: ? extends java.lang.String, X +Neg02.java:58:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:59:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +Neg02.java:60:13: compiler.err.not.within.bounds: ? super java.lang.String, X +Neg02.java:60:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null +56 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg03.java b/langtools/test/tools/javac/generics/diamond/neg/Neg03.java index 83994b3b42e..54e68129398 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg03.java +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary Check that diamond fails when inference violates declared bounds * (test with inner class, qualified/simple type expressions) @@ -26,6 +26,16 @@ class Neg03 { Foo f6 = new Foo<>("", ""); Foo f7 = new Foo<>("", ""); Foo f8 = new Foo<>("", ""); + + Foo f9 = new Foo<>(""){}; + Foo f10 = new Foo<>(""){}; + Foo f11 = new Foo<>(""){}; + Foo f12 = new Foo<>(""){}; + + Foo f13 = new Foo<>("", ""){}; + Foo f14 = new Foo<>("", ""){}; + Foo f15 = new Foo<>("", ""){}; + Foo f16 = new Foo<>("", ""){}; } void testQualified_1() { @@ -38,6 +48,16 @@ class Neg03 { Foo f6 = new Neg03.Foo<>("", ""); Foo f7 = new Neg03.Foo<>("", ""); Foo f8 = new Neg03.Foo<>("", ""); + + Foo f9 = new Neg03.Foo<>(""){}; + Foo f10 = new Neg03.Foo<>(""){}; + Foo f11 = new Neg03.Foo<>(""){}; + Foo f12 = new Neg03.Foo<>(""){}; + + Foo f13 = new Neg03.Foo<>("", ""){}; + Foo f14 = new Neg03.Foo<>("", ""){}; + Foo f15 = new Neg03.Foo<>("", ""){}; + Foo f16 = new Neg03.Foo<>("", ""){}; } void testQualified_2(Neg03 n) { @@ -50,5 +70,15 @@ class Neg03 { Foo f6 = n.new Foo<>("", ""); Foo f7 = n.new Foo<>("", ""); Foo f8 = n.new Foo<>("", ""); + + Foo f9 = n.new Foo<>(""){}; + Foo f10 = n.new Foo<>(""){}; + Foo f11 = n.new Foo<>(""){}; + Foo f12 = n.new Foo<>(""){}; + + Foo f13 = n.new Foo<>("", ""){}; + Foo f14 = n.new Foo<>("", ""){}; + Foo f15 = n.new Foo<>("", ""){}; + Foo f16 = n.new Foo<>("", ""){}; } } diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg03.out b/langtools/test/tools/javac/generics/diamond/neg/Neg03.out index b255fca3c99..20ecb6ca326 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg03.out +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.out @@ -12,32 +12,74 @@ Neg03.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03 Neg03.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null Neg03.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, V Neg03.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:32:13: compiler.err.not.within.bounds: java.lang.String, V -Neg03.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, V -Neg03.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, V -Neg03.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:37:13: compiler.err.not.within.bounds: java.lang.String, V -Neg03.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, V -Neg03.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, V -Neg03.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:44:13: compiler.err.not.within.bounds: java.lang.String, V -Neg03.java:44:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:45:13: compiler.err.not.within.bounds: ? extends java.lang.String, V -Neg03.java:45:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:46:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:47:13: compiler.err.not.within.bounds: ? super java.lang.String, V -Neg03.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:49:13: compiler.err.not.within.bounds: java.lang.String, V -Neg03.java:49:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:50:13: compiler.err.not.within.bounds: ? extends java.lang.String, V -Neg03.java:50:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:51:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -Neg03.java:52:13: compiler.err.not.within.bounds: ? super java.lang.String, V -Neg03.java:52:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null -42 errors +Neg03.java:30:13: compiler.err.not.within.bounds: java.lang.String, V +Neg03.java:30:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:31:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg03.java:31:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:32:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:33:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg03.java:33:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:35:13: compiler.err.not.within.bounds: java.lang.String, V +Neg03.java:35:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:36:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg03.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:37:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:38:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg03.java:38:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:42:13: compiler.err.not.within.bounds: java.lang.String, V +Neg03.java:42:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:43:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg03.java:43:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:44:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:45:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg03.java:45:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:47:13: compiler.err.not.within.bounds: java.lang.String, V +Neg03.java:47:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:48:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg03.java:48:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:49:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:50:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg03.java:50:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:52:13: compiler.err.not.within.bounds: java.lang.String, V +Neg03.java:52:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:53:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg03.java:53:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:54:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:55:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg03.java:55:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:57:13: compiler.err.not.within.bounds: java.lang.String, V +Neg03.java:57:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:58:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg03.java:58:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:59:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:60:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg03.java:60:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:64:13: compiler.err.not.within.bounds: java.lang.String, V +Neg03.java:64:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:65:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg03.java:65:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:66:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:67:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg03.java:67:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:69:13: compiler.err.not.within.bounds: java.lang.String, V +Neg03.java:69:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:70:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg03.java:70:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:71:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:72:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg03.java:72:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:74:13: compiler.err.not.within.bounds: java.lang.String, V +Neg03.java:74:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:75:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg03.java:75:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:76:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:77:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg03.java:77:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:79:13: compiler.err.not.within.bounds: java.lang.String, V +Neg03.java:79:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:80:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg03.java:80:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:81:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +Neg03.java:82:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg03.java:82:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null +84 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg04.java b/langtools/test/tools/javac/generics/diamond/neg/Neg04.java index 94aa8d638b3..28b01b4de67 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg04.java +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary Check that diamond fails when inference violates declared bounds * (test with local class, qualified/simple type expressions) @@ -25,5 +25,15 @@ class Neg04 { Foo n6 = new Foo<>("", ""); Foo n7 = new Foo<>("", ""); Foo n8 = new Foo<>("", ""); + + Foo n9 = new Foo<>(""){}; + Foo n10 = new Foo<>(""){}; + Foo n11 = new Foo<>(""){}; + Foo n12 = new Foo<>(""){}; + + Foo n13 = new Foo<>("", ""){}; + Foo n14 = new Foo<>("", ""){}; + Foo n15 = new Foo<>("", ""){}; + Foo n16 = new Foo<>("", ""){}; } } diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg04.out b/langtools/test/tools/javac/generics/diamond/neg/Neg04.out index 656d268015f..d8d7512aee1 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg04.out +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.out @@ -12,4 +12,18 @@ Neg04.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), Neg04.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null Neg04.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, V Neg04.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null -14 errors +Neg04.java:29:13: compiler.err.not.within.bounds: java.lang.String, V +Neg04.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null +Neg04.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg04.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null +Neg04.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null +Neg04.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg04.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null +Neg04.java:34:13: compiler.err.not.within.bounds: java.lang.String, V +Neg04.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null +Neg04.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String, V +Neg04.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null +Neg04.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null +Neg04.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String, V +Neg04.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null +28 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg05.java b/langtools/test/tools/javac/generics/diamond/neg/Neg05.java index 53ee397b50f..960f5729cde 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg05.java +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary Check that usage of rare types doesn't cause spurious diamond diagnostics * @author mcimadamore @@ -25,6 +25,16 @@ class Neg05 { Neg05.Foo f6 = new Neg05.Foo<>("", ""); Neg05.Foo f7 = new Neg05.Foo<>("", ""); Neg05.Foo f8 = new Neg05.Foo<>("", ""); + + Neg05.Foo f9 = new Neg05.Foo<>(""){}; + Neg05.Foo f10 = new Neg05.Foo<>(""){}; + Neg05.Foo f11 = new Neg05.Foo<>(""){}; + Neg05.Foo f12 = new Neg05.Foo<>(""){}; + + Neg05.Foo f13 = new Neg05.Foo<>("", ""){}; + Neg05.Foo f14 = new Neg05.Foo<>("", ""){}; + Neg05.Foo f15 = new Neg05.Foo<>("", ""){}; + Neg05.Foo f16 = new Neg05.Foo<>("", ""){}; } void testRare_2(Neg05 n) { @@ -37,5 +47,15 @@ class Neg05 { Neg05.Foo f6 = n.new Foo<>("", ""); Neg05.Foo f7 = n.new Foo<>("", ""); Neg05.Foo f8 = n.new Foo<>("", ""); + + Neg05.Foo f9 = n.new Foo<>(""){}; + Neg05.Foo f10 = n.new Foo<>(""){}; + Neg05.Foo f11 = n.new Foo<>(""){}; + Neg05.Foo f12 = n.new Foo<>(""){}; + + Neg05.Foo f13 = n.new Foo<>("", ""){}; + Neg05.Foo f14 = n.new Foo<>("", ""){}; + Neg05.Foo f15 = n.new Foo<>("", ""){}; + Neg05.Foo f16 = n.new Foo<>("", ""){}; } } diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg05.out b/langtools/test/tools/javac/generics/diamond/neg/Neg05.out index 7ab2ece7e0e..8f31285f0ef 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg05.out +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.out @@ -6,20 +6,52 @@ Neg05.java:24:48: compiler.err.improperly.formed.type.inner.raw.param Neg05.java:25:58: compiler.err.improperly.formed.type.inner.raw.param Neg05.java:26:43: compiler.err.improperly.formed.type.inner.raw.param Neg05.java:27:56: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:31:37: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:31:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) -Neg05.java:32:47: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:32:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) -Neg05.java:33:32: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:33:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) -Neg05.java:34:45: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:34:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) -Neg05.java:36:37: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:36:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) -Neg05.java:37:47: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:37:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) -Neg05.java:38:32: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:38:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) -Neg05.java:39:45: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:39:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) -24 errors +Neg05.java:29:48: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:29:35: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: , (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V)) +Neg05.java:30:59: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:30:46: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: , (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V)) +Neg05.java:31:44: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:31:31: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: , (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V)) +Neg05.java:32:57: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:32:44: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: , (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V)) +Neg05.java:34:49: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:34:36: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: , (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V)) +Neg05.java:35:59: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:35:46: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: , (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V)) +Neg05.java:36:44: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:36:31: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: , (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V)) +Neg05.java:37:57: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:37:44: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: , (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V)) +Neg05.java:41:37: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:41:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) +Neg05.java:42:47: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:42:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) +Neg05.java:43:32: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:43:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) +Neg05.java:44:45: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:44:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) +Neg05.java:46:37: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:46:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) +Neg05.java:47:47: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:47:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) +Neg05.java:48:32: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:48:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) +Neg05.java:49:45: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:49:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) +Neg05.java:51:37: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:51:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) +Neg05.java:52:48: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:52:55: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) +Neg05.java:53:33: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:53:40: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) +Neg05.java:54:46: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:54:53: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo, Neg05.Foo)) +Neg05.java:56:38: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:56:45: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) +Neg05.java:57:48: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:57:55: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) +Neg05.java:58:33: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:58:40: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) +Neg05.java:59:46: compiler.err.improperly.formed.type.inner.raw.param +Neg05.java:59:53: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo, Neg05.Foo)) +56 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg06.java b/langtools/test/tools/javac/generics/diamond/neg/Neg06.java index 73aae17b00e..e4f98dccd6b 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.java +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary Check that diamond works where LHS is supertype of RHS (nilary constructor) * @author mcimadamore @@ -9,9 +9,13 @@ */ class Neg06 { + interface ISuperFoo {} + interface IFoo extends ISuperFoo {} static class CSuperFoo {} static class CFoo extends CSuperFoo {} + ISuperFoo isf = new IFoo<>() {}; CSuperFoo csf1 = new CFoo<>(); + CSuperFoo csf2 = new CFoo<>() {}; } diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg06.out b/langtools/test/tools/javac/generics/diamond/neg/Neg06.out index bf439f78f89..c085b5ebdd6 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.out +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.out @@ -1,2 +1,6 @@ -Neg06.java:16:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number)) -1 error +Neg06.java:18:36: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number)) +Neg06.java:18:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: java.lang.Object, Neg06.ISuperFoo) +Neg06.java:19:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number)) +Neg06.java:20:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number)) +Neg06.java:20:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: , Neg06.CSuperFoo) +5 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg07.java b/langtools/test/tools/javac/generics/diamond/neg/Neg07.java index f65bee8e1d8..199a2e861f4 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg07.java +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary Check that diamond works where LHS is supertype of RHS (1-ary constructor) * @author mcimadamore @@ -15,4 +15,5 @@ class Neg07 { } SuperFoo sf1 = new Foo<>(""); + SuperFoo sf2 = new Foo<>("") {}; } diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg07.out b/langtools/test/tools/javac/generics/diamond/neg/Neg07.out index 59c37899ed0..8bec602bdba 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg07.out +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.out @@ -1,2 +1,3 @@ Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number) -1 error +Neg07.java:18:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number) +2 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg09.java b/langtools/test/tools/javac/generics/diamond/neg/Neg09.java index 4a85619e45b..729a3f1d10b 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg09.java +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.java @@ -1,10 +1,10 @@ /* * @test /nodynamiccopyright/ - * @bug 7020044 + * @bug 7020044 8062373 * - * @summary Check that diamond is not allowed with anonymous inner class expressions + * @summary Check that diamond is not allowed with anonymous inner class expressions at source < 9 * @author Maurizio Cimadamore - * @compile/fail/ref=Neg09.out Neg09.java -XDrawDiagnostics + * @compile/fail/ref=Neg09.out Neg09.java -source 8 -XDrawDiagnostics * */ diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg09.out b/langtools/test/tools/javac/generics/diamond/neg/Neg09.out index 5893555fba8..af5238b72ca 100644 --- a/langtools/test/tools/javac/generics/diamond/neg/Neg09.out +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.out @@ -1,5 +1,7 @@ -Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member) -Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested) -Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member) -Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested) +- compiler.warn.source.no.bootclasspath: 1.8 +Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8) +Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8) +Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8) +Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8) 4 errors +1 warning diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg12.java b/langtools/test/tools/javac/generics/diamond/neg/Neg12.java new file mode 100644 index 00000000000..526f84626f5 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg12.java @@ -0,0 +1,33 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8062373 + * + * @summary Test diamond + anonymous classes with non-denotable types + * @author mcimadamore + * @compile/fail/ref=Neg12.out Neg12.java -XDrawDiagnostics + * + */ + + class Neg12 { + static class Foo { + Foo(X x) { } + } + + static class DoubleFoo { + DoubleFoo(X x,Y y) { } + } + + static class TripleFoo { + TripleFoo(X x,Y y,Z z) { } + } + + Foo fi = new Foo<>(1); + Foo fw = new Foo<>(fi) {}; // Error. + Foo fw1 = new Foo<>(fi); // OK. + Foo fd = new Foo<>(3.0); + DoubleFoo dw = new DoubleFoo<>(fi,fd) {}; // Error. + DoubleFoo dw1 = new DoubleFoo<>(fi,fd); // OK. + Foo fs = new Foo<>("one"); + TripleFoo tw = new TripleFoo<>(fi,fd,fs) {}; // Error. + TripleFoo tw1 = new TripleFoo<>(fi,fd,fs); // OK. + } diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg12.out b/langtools/test/tools/javac/generics/diamond/neg/Neg12.out new file mode 100644 index 00000000000..aaa54b38073 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg12.out @@ -0,0 +1,4 @@ +Neg12.java:25:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.Foo), (compiler.misc.diamond.invalid.arg: Neg12.Foo, (compiler.misc.diamond: Neg12.Foo)) +Neg12.java:28:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.DoubleFoo), (compiler.misc.diamond.invalid.args: Neg12.Foo,Neg12.Foo, (compiler.misc.diamond: Neg12.DoubleFoo)) +Neg12.java:31:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.TripleFoo), (compiler.misc.diamond.invalid.args: Neg12.Foo,Neg12.Foo, (compiler.misc.diamond: Neg12.TripleFoo)) +3 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg13.java b/langtools/test/tools/javac/generics/diamond/neg/Neg13.java new file mode 100644 index 00000000000..45c6ecaae98 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg13.java @@ -0,0 +1,49 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8062373 + * + * @summary Test diamond + anonymous classes with abstract super type + * @author sadayapalam + * @compile/fail/ref=Neg13.out Neg13.java -XDrawDiagnostics + * + */ +class Neg13 { + + static abstract class A { + abstract void foo(); + } + + static void foo(A as) {} + + public static void main(String[] args) { + + // Method invocation context - good <>(){} + foo(new A<>() { + public void foo() {} + }); + + // Assignment context - good <>(){} + A aq = new A<>() { + public void foo() {} + }; + + // When the anonymous type subtypes an abstract class but is missing definitions for + // abstract methods, expect no overload resolution error, but an attribution error + // while attributing anonymous class body. + + + // Method invocation context - bad <>(){} + foo(new A<>() { + }); + + // Assignment invocation context - bad <>(){} + aq = new A<>() { + }; + + // Method invocation context - bad <>() + foo(new A<>()); + + // Assignment invocation context - bad <>() + aq = new A<>(); + } +} diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg13.out b/langtools/test/tools/javac/generics/diamond/neg/Neg13.out new file mode 100644 index 00000000000..a179a772a54 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg13.out @@ -0,0 +1,5 @@ +Neg13.java:36:23: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg13$3, foo(), Neg13.A +Neg13.java:40:24: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg13$4, foo(), Neg13.A +Neg13.java:44:13: compiler.err.abstract.cant.be.instantiated: Neg13.A +Neg13.java:47:14: compiler.err.abstract.cant.be.instantiated: Neg13.A +4 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg14.java b/langtools/test/tools/javac/generics/diamond/neg/Neg14.java new file mode 100644 index 00000000000..0ad9114c784 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg14.java @@ -0,0 +1,49 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8062373 + * + * @summary Test diamond + anonymous classes with super type being an interface. + * @author sadayapalam + * @compile/fail/ref=Neg14.out Neg14.java -XDrawDiagnostics + * + */ +class Neg14 { + + static interface A { + void foo(); + } + + static void foo(A as) {} + + public static void main(String[] args) { + + // Method invocation context - good <>(){} + foo(new A<>() { + public void foo() {} + }); + + // Assignment context - good <>(){} + A aq = new A<>() { + public void foo() {} + }; + + // When the anonymous type subtypes an interface but is missing definitions for + // abstract methods, expect no overload resolution error, but an attribution error + // while attributing anonymous class body. + + + // Method invocation context - bad <>(){} + foo(new A<>() { + }); + + // Assignment invocation context - bad <>(){} + aq = new A<>() { + }; + + // Method invocation context - bad <>() + foo(new A<>()); + + // Assignment invocation context - bad <>() + aq = new A<>(); + } +} diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg14.out b/langtools/test/tools/javac/generics/diamond/neg/Neg14.out new file mode 100644 index 00000000000..8b0514018a7 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg14.out @@ -0,0 +1,5 @@ +Neg14.java:36:23: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg14$3, foo(), Neg14.A +Neg14.java:40:24: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg14$4, foo(), Neg14.A +Neg14.java:44:13: compiler.err.abstract.cant.be.instantiated: Neg14.A +Neg14.java:47:14: compiler.err.abstract.cant.be.instantiated: Neg14.A +4 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg15.java b/langtools/test/tools/javac/generics/diamond/neg/Neg15.java new file mode 100644 index 00000000000..2c0d28607fa --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg15.java @@ -0,0 +1,66 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8062373 + * + * @summary Test that javac complains when a <> inferred class contains a public method that does override a supertype method. + * @author sadayapalam + * @compile/fail/ref=Neg15.out Neg15.java -XDrawDiagnostics + * + */ + +class Neg15 { + + interface Predicate { + default boolean test(T t) { + System.out.println("Default method"); + return false; + } + } + + + static void someMethod(Predicate p) { + if (!p.test(null)) + throw new Error("Blew it"); + } + + public static void main(String[] args) { + + someMethod(new Predicate() { + public boolean test(Integer n) { + System.out.println("Override"); + return true; + } + boolean test(Integer n, int i) { + System.out.println("Override"); + return true; + } + protected boolean test(Integer n, int i, int j) { + System.out.println("Override"); + return true; + } + private boolean test(Integer n, int i, long j) { + System.out.println("Override"); + return true; + } + }); + + someMethod(new Predicate<>() { + public boolean test(Integer n) { // bad. + System.out.println("Override"); + return true; + } + boolean test(Integer n, int i) { // bad, package access. + System.out.println("Override"); + return true; + } + protected boolean test(Integer n, int i, int j) { // bad, protected access. + System.out.println("Override"); + return true; + } + private boolean test(Integer n, int i, long j) { // OK, private method. + System.out.println("Override"); + return true; + } + }); + } +} diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg15.out b/langtools/test/tools/javac/generics/diamond/neg/Neg15.out new file mode 100644 index 00000000000..1e6f1efa8ac --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg15.out @@ -0,0 +1,4 @@ +Neg15.java:48:28: compiler.err.method.does.not.override.superclass +Neg15.java:52:21: compiler.err.method.does.not.override.superclass +Neg15.java:56:31: compiler.err.method.does.not.override.superclass +3 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg16.java b/langtools/test/tools/javac/generics/diamond/neg/Neg16.java new file mode 100644 index 00000000000..775c17231d5 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg16.java @@ -0,0 +1,36 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8062373 + * @summary Test that javac does not recommend a diamond site that would result in error. + * @compile/ref=Neg16.out -Xlint:-options Neg16.java -XDrawDiagnostics -XDfind=diamond + */ + +class Neg16 { + + interface Predicate { + default boolean test(T t) { + System.out.println("Default method"); + return false; + } + } + + static void someMethod(Predicate p) { + if (!p.test(null)) + throw new Error("Blew it"); + } + + public static void main(String[] args) { + someMethod(new Predicate() { // cannot convert to diamond + public boolean test(Integer n) { + System.out.println("Override"); + return true; + } + }); + someMethod(new Predicate() { // can convert to diamond. + public boolean test(Number n) { + System.out.println("Override"); + return true; + } + }); + } +} diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg16.out b/langtools/test/tools/javac/generics/diamond/neg/Neg16.out new file mode 100644 index 00000000000..712aa4fba63 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg16.out @@ -0,0 +1,2 @@ +Neg16.java:29:33: compiler.warn.diamond.redundant.args +1 warning diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg17.java b/langtools/test/tools/javac/generics/diamond/neg/Neg17.java new file mode 100644 index 00000000000..960fbd77a63 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg17.java @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8062373 + * @summary Test that the anonymous class constructor appears to returns a Foo, when it actually returns a Anon$1. (status as of now - may change in future) + * @compile/fail/ref=Neg17.out Neg17.java -XDrawDiagnostics + */ + +import java.util.Collections; + +abstract class Neg17 { + + abstract void m(); + + public static void main(String[] args) { + Collections.singletonList(new Neg17<>() { void m() {} }).get(0).m(); // good. + Collections.singletonList(new Neg17<>() { + void m() {} + private void n() {} + }).get(0).n(); // bad unknown method n() + } +} diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg17.out b/langtools/test/tools/javac/generics/diamond/neg/Neg17.out new file mode 100644 index 00000000000..aeb7601d59b --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg17.out @@ -0,0 +1,2 @@ +Neg17.java:19:21: compiler.err.cant.resolve.location.args: kindname.method, n, , , (compiler.misc.location: kindname.class, Neg17, null) +1 error diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg18.java b/langtools/test/tools/javac/generics/diamond/neg/Neg18.java new file mode 100644 index 00000000000..4acb7ef2f09 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg18.java @@ -0,0 +1,16 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8062373 + * @summary Test that inaccessible vararg element type triggers an error during diamond inferred anonymous class instance creation. + * @compile/fail/ref=Neg18.out Neg18.java -XDrawDiagnostics + */ + +import java.util.Collections; +import pkg.Neg18_01; + +class Neg18 { + + public static void main(String[] args) { + new Neg18_01<>() {}; + } +} diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg18.out b/langtools/test/tools/javac/generics/diamond/neg/Neg18.out new file mode 100644 index 00000000000..edbff10f635 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg18.out @@ -0,0 +1,3 @@ +Neg18.java:14:21: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: pkg.Neg18_01), (compiler.misc.inaccessible.varargs.type: pkg.Neg18_01.PkgPrivate, kindname.class, Neg18)) +Neg18.java:14:26: compiler.err.not.def.public.cant.access: pkg.Neg18_01.PkgPrivate, pkg.Neg18_01 +2 errors diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg19.java b/langtools/test/tools/javac/generics/diamond/neg/Neg19.java new file mode 100644 index 00000000000..173a72a8db9 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg19.java @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8062373 + * @summary Test that when inaccessible types constitute the inferred types of <> the compiler complains. + * @compile/fail/ref=Neg19.out Neg19.java -XDrawDiagnostics + */ + + + +class Neg19 { + public static void main(String[] args) { + new Neg19_01().foo(new Neg19_01<>()); // OK. + new Neg19_01().foo(new Neg19_01<>() {}); // ERROR. + } +} + +class Neg19_01 { + private class Private {} + Neg19_01() {} + void foo(Neg19_01 p) {} +} diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg19.out b/langtools/test/tools/javac/generics/diamond/neg/Neg19.out new file mode 100644 index 00000000000..aaba880ed1c --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg19.out @@ -0,0 +1,2 @@ +Neg19.java:13:34: compiler.err.report.access: Neg19_01.Private, private, Neg19_01 +1 error diff --git a/langtools/test/tools/javac/generics/diamond/neg/pkg/Neg18_01.java b/langtools/test/tools/javac/generics/diamond/neg/pkg/Neg18_01.java new file mode 100644 index 00000000000..569096025a4 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/pkg/Neg18_01.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +public class Neg18_01 { + static class PkgPrivate {} + public Neg18_01 (PkgPrivate ... pp) {} +} diff --git a/langtools/test/tools/javac/generics/diamond/pos/Pos01.java b/langtools/test/tools/javac/generics/diamond/pos/Pos01.java index 1ae7f9bf76b..9a60314f4a8 100644 --- a/langtools/test/tools/javac/generics/diamond/pos/Pos01.java +++ b/langtools/test/tools/javac/generics/diamond/pos/Pos01.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary basic test for diamond (generic/non-generic constructors) * @author mcimadamore @@ -48,7 +48,17 @@ public class Pos01 { Pos01 p6 = new Pos01<>(1, ""); Pos01 p7 = new Pos01<>(1, ""); Pos01 p8 = new Pos01<>(1, ""); - } + + Pos01 p9 = new Pos01<>(1){}; + Pos01 p10 = new Pos01<>(1){}; + Pos01 p11 = new Pos01<>(1){}; + Pos01 p12 = new Pos01<>(1){}; + + Pos01 p13 = new Pos01<>(1, ""){}; + Pos01 p14= new Pos01<>(1, ""){}; + Pos01 p15 = new Pos01<>(1, ""){}; + Pos01 p16 = new Pos01<>(1, ""){}; + } public static void main(String[] args) { Pos01 p1 = new Pos01<>(""); diff --git a/langtools/test/tools/javac/generics/diamond/pos/Pos02.java b/langtools/test/tools/javac/generics/diamond/pos/Pos02.java index 835020c40a1..72800e1814f 100644 --- a/langtools/test/tools/javac/generics/diamond/pos/Pos02.java +++ b/langtools/test/tools/javac/generics/diamond/pos/Pos02.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary basic test for diamond (simple/qualified type-expressions) * @author mcimadamore @@ -48,6 +48,16 @@ public class Pos02 { Foo f6 = new Foo<>(1, ""); Foo f7 = new Foo<>(1, ""); Foo f8 = new Foo<>(1, ""); + + Foo f9 = new Foo<>(1){}; + Foo f10 = new Foo<>(1){}; + Foo f11 = new Foo<>(1){}; + Foo f12 = new Foo<>(1){}; + + Foo f13 = new Foo<>(1, ""){}; + Foo f14 = new Foo<>(1, ""){}; + Foo f15 = new Foo<>(1, ""){}; + Foo f16 = new Foo<>(1, ""){}; } void testQualified() { @@ -60,6 +70,16 @@ public class Pos02 { Foo f6 = new Pos02.Foo<>(1, ""); Foo f7 = new Pos02.Foo<>(1, ""); Foo f8 = new Pos02.Foo<>(1, ""); + + Foo f9 = new Pos02.Foo<>(1){}; + Foo f10 = new Pos02.Foo<>(1){}; + Foo f11 = new Pos02.Foo<>(1){}; + Foo f12 = new Pos02.Foo<>(1){}; + + Foo f13 = new Pos02.Foo<>(1, ""){}; + Foo f14 = new Pos02.Foo<>(1, ""){}; + Foo f15 = new Pos02.Foo<>(1, ""){}; + Foo f16 = new Pos02.Foo<>(1, ""){}; } public static void main(String[] args) { diff --git a/langtools/test/tools/javac/generics/diamond/pos/Pos03.java b/langtools/test/tools/javac/generics/diamond/pos/Pos03.java index 9f975cfc642..aa7fed2f464 100644 --- a/langtools/test/tools/javac/generics/diamond/pos/Pos03.java +++ b/langtools/test/tools/javac/generics/diamond/pos/Pos03.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary basic test for diamond (simple/qualified type-expressions, member inner) * @author mcimadamore @@ -49,6 +49,16 @@ public class Pos03 { Foo f6 = new Foo<>(1, ""); Foo f7 = new Foo<>(1, ""); Foo f8 = new Foo<>(1, ""); + + Foo f9 = new Foo<>(1){}; + Foo f10 = new Foo<>(1){}; + Foo f11 = new Foo<>(1){}; + Foo f12 = new Foo<>(1){}; + + Foo f13 = new Foo<>(1, ""){}; + Foo f14 = new Foo<>(1, ""){}; + Foo f15 = new Foo<>(1, ""){}; + Foo f16 = new Foo<>(1, ""){}; } void testQualified_1() { @@ -61,6 +71,16 @@ public class Pos03 { Foo f6 = new Pos03.Foo<>(1, ""); Foo f7 = new Pos03.Foo<>(1, ""); Foo f8 = new Pos03.Foo<>(1, ""); + + Foo f9 = new Pos03.Foo<>(1){}; + Foo f10 = new Pos03.Foo<>(1){}; + Foo f11 = new Pos03.Foo<>(1){}; + Foo f12 = new Pos03.Foo<>(1){}; + + Foo f13 = new Pos03.Foo<>(1, ""){}; + Foo f14 = new Pos03.Foo<>(1, ""){}; + Foo f15 = new Pos03.Foo<>(1, ""){}; + Foo f16 = new Pos03.Foo<>(1, ""){}; } void testQualified_2(Pos03 p) { @@ -73,6 +93,16 @@ public class Pos03 { Foo f6 = p.new Foo<>(1, ""); Foo f7 = p.new Foo<>(1, ""); Foo f8 = p.new Foo<>(1, ""); + + Foo f9 = p.new Foo<>(1){}; + Foo f10 = p.new Foo<>(1){}; + Foo f11 = p.new Foo<>(1){}; + Foo f12 = p.new Foo<>(1){}; + + Foo f13 = p.new Foo<>(1, ""){}; + Foo f14 = p.new Foo<>(1, ""){}; + Foo f15 = p.new Foo<>(1, ""){}; + Foo f16 = p.new Foo<>(1, ""){}; } public static void main(String[] args) { diff --git a/langtools/test/tools/javac/generics/diamond/pos/Pos04.java b/langtools/test/tools/javac/generics/diamond/pos/Pos04.java index c0a3516f91e..664cfa1ea75 100644 --- a/langtools/test/tools/javac/generics/diamond/pos/Pos04.java +++ b/langtools/test/tools/javac/generics/diamond/pos/Pos04.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary basic test for diamond (simple/qualified type-expressions, local class) * @author mcimadamore @@ -48,6 +48,16 @@ public class Pos04 { Foo p6 = new Foo<>(1, ""); Foo p7 = new Foo<>(1, ""); Foo p8 = new Foo<>(1, ""); + + Foo p9 = new Foo<>(1){}; + Foo p10 = new Foo<>(1){}; + Foo p11 = new Foo<>(1){}; + Foo p12 = new Foo<>(1){}; + + Foo p13 = new Foo<>(1, ""){}; + Foo p14 = new Foo<>(1, ""){}; + Foo p15 = new Foo<>(1, ""){}; + Foo p16 = new Foo<>(1, ""){}; } public static void main(String[] args) { diff --git a/langtools/test/tools/javac/generics/diamond/pos/Pos05.java b/langtools/test/tools/javac/generics/diamond/pos/Pos05.java index 9223ae8f2a7..74fc84cf388 100644 --- a/langtools/test/tools/javac/generics/diamond/pos/Pos05.java +++ b/langtools/test/tools/javac/generics/diamond/pos/Pos05.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,10 @@ /* * @test - * @bug 6939620 7020044 + * @bug 6939620 7020044 8062373 * * @summary Check that 'complex' inference sometimes works in method context * @author mcimadamore - * @compile Pos05.java * */ @@ -41,5 +40,11 @@ public class Pos05 { void test() { m(new Foo<>(1)); + m(new Foo<>(1) {}); } + + public static void main(String [] args) { + new Pos05().test(); + } + } diff --git a/langtools/test/tools/javac/generics/inference/5073060/GenericsAndPackages.java b/langtools/test/tools/javac/generics/inference/5073060/GenericsAndPackages.java index 15e9a1c96fc..0779e9d38a8 100644 --- a/langtools/test/tools/javac/generics/inference/5073060/GenericsAndPackages.java +++ b/langtools/test/tools/javac/generics/inference/5073060/GenericsAndPackages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /** * @test - * @bug 5073060 + * @bug 5073060 8075610 * @summary Package private members not found for intersection types * @author Bruce Eckel * see http://www.artima.com/forums/flat.jsp?forum=106&thread=136204 @@ -33,7 +33,7 @@ package code; interface HasColor { - java.awt.Color getColor(); + String getColor(); } class Dimension { @@ -44,6 +44,6 @@ class ColoredDimension { T item; ColoredDimension(T item) { this.item = item; } T getItem() { return item; } - java.awt.Color f() { return item.getColor(); } + String f() { return item.getColor(); } int getX() { return item.x; } } diff --git a/langtools/test/tools/javac/generics/inference/8055963/T8055963.java b/langtools/test/tools/javac/generics/inference/8055963/T8055963.java index 82f00275b8d..0d4e12076d5 100644 --- a/langtools/test/tools/javac/generics/inference/8055963/T8055963.java +++ b/langtools/test/tools/javac/generics/inference/8055963/T8055963.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,11 +25,10 @@ /** * @test - * @bug 8055963 + * @bug 8055963 8062373 * @summary Inference failure with nested invocation - * @compile T8055963.java */ -class T8055963 { +public class T8055963 { static class C {} @@ -38,4 +37,8 @@ class T8055963 { void test() { C cs = choose(new C(), new C<>()); } + + public static void main(String [] args) { + new T8055963().test(); + } } diff --git a/langtools/test/tools/javac/lambda/8066974/T8066974.java b/langtools/test/tools/javac/lambda/8066974/T8066974.java index 8f47277f734..fd8119dd970 100644 --- a/langtools/test/tools/javac/lambda/8066974/T8066974.java +++ b/langtools/test/tools/javac/lambda/8066974/T8066974.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8066974 + * @bug 8066974 8062373 * @summary Compiler doesn't infer method's generic type information in lambda body * @compile/fail/ref=T8066974.out -XDrawDiagnostics T8066974.java */ @@ -34,11 +34,13 @@ class T8066974 { map(p->p.m(rt)); map(mapper(rt)); map(new ThrowingMapper<>(rt)); + map(new ThrowingMapper<>(rt) {}); } void testChecked(CheckedThrowing ct) { map(p->p.m(ct)); map(mapper(ct)); map(new ThrowingMapper<>(ct)); + map(new ThrowingMapper<>(ct) {}); } } diff --git a/langtools/test/tools/javac/lambda/8066974/T8066974.out b/langtools/test/tools/javac/lambda/8066974/T8066974.out index 59772fc59a4..101a18ac191 100644 --- a/langtools/test/tools/javac/lambda/8066974/T8066974.out +++ b/langtools/test/tools/javac/lambda/8066974/T8066974.out @@ -1,4 +1,5 @@ -T8066974.java:40:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception T8066974.java:41:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception -T8066974.java:42:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception -3 errors +T8066974.java:42:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception +T8066974.java:43:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception +T8066974.java:44:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception +4 errors diff --git a/langtools/test/tools/javac/lambda/LocalVariableTable.java b/langtools/test/tools/javac/lambda/LocalVariableTable.java index 8a4d04a061b..b70bc73556a 100644 --- a/langtools/test/tools/javac/lambda/LocalVariableTable.java +++ b/langtools/test/tools/javac/lambda/LocalVariableTable.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8025998 8026749 + * @bug 8025998 8026749 8054220 8058227 * @summary Missing LV table in lambda bodies * @compile -g LocalVariableTable.java * @run main LocalVariableTable @@ -183,7 +183,7 @@ public class LocalVariableTable { Run1 r = (a) -> { int x = a; }; } - @Expect({ "a", "x" }) + @Expect({ "a", "x", "v" }) static class Lambda_Args1_Local1_Captured1 { void m() { int v = 0; @@ -191,7 +191,7 @@ public class LocalVariableTable { } } - @Expect({ "a1", "a2", "x1", "x2", "this" }) + @Expect({ "a1", "a2", "x1", "x2", "this", "v1", "v2" }) static class Lambda_Args2_Local2_Captured2_this { int v; void m() { @@ -204,7 +204,7 @@ public class LocalVariableTable { } } - @Expect({ "e" }) + @Expect({ "e", "c" }) static class Lambda_Try_Catch { private static Runnable asUncheckedRunnable(Closeable c) { return () -> { diff --git a/langtools/test/tools/javac/lambda/MethodReference23.java b/langtools/test/tools/javac/lambda/MethodReference23.java index b7610389a02..2ac0e04b3ee 100644 --- a/langtools/test/tools/javac/lambda/MethodReference23.java +++ b/langtools/test/tools/javac/lambda/MethodReference23.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8003280 + * @bug 8003280 8075184 * @summary Add lambda tests * check that pair of bound/non-bound constructor references is flagged as ambiguous * @author Maurizio Cimadamore diff --git a/langtools/test/tools/javac/lambda/MethodReference23.out b/langtools/test/tools/javac/lambda/MethodReference23.out index 462a75105ff..456a002bd99 100644 --- a/langtools/test/tools/javac/lambda/MethodReference23.out +++ b/langtools/test/tools/javac/lambda/MethodReference23.out @@ -1,6 +1,6 @@ -MethodReference23.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23)) -MethodReference23.java:53:15: compiler.err.cant.apply.symbol: kindname.method, call11, MethodReference23.SAM11, @1140, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23))) -MethodReference23.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)) -MethodReference23.java:58:15: compiler.err.cant.apply.symbol: kindname.method, call12, MethodReference23.SAM12, @1282, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23))) +MethodReference23.java:52:19: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23) +MethodReference23.java:53:16: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23) +MethodReference23.java:57:19: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23) +MethodReference23.java:58:16: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23) MethodReference23.java:72:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference23.SAM21), MethodReference23, kindname.method, call3(MethodReference23.SAM22), MethodReference23 5 errors diff --git a/langtools/test/tools/javac/lambda/TargetType46.java b/langtools/test/tools/javac/lambda/TargetType46.java index da371231427..680ff3a7bed 100644 --- a/langtools/test/tools/javac/lambda/TargetType46.java +++ b/langtools/test/tools/javac/lambda/TargetType46.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8003280 + * @bug 8003280 8062373 * @summary Add lambda tests * compiler doesn't report accessibility problem due to inaccessible target * @compile/fail/ref=TargetType46.out -XDrawDiagnostics TargetType46.java @@ -22,6 +22,7 @@ class TargetType46 { outer.m(()->{}); //access error outer.m(this::g); //access error outer.m(new ArrayList<>()); //ok + outer.m(new ArrayList<>() {}); // access error outer.m(Collections.emptyList()); //ok } diff --git a/langtools/test/tools/javac/lambda/TargetType46.out b/langtools/test/tools/javac/lambda/TargetType46.out index ac3a1254589..30cd7034217 100644 --- a/langtools/test/tools/javac/lambda/TargetType46.out +++ b/langtools/test/tools/javac/lambda/TargetType46.out @@ -1,3 +1,4 @@ TargetType46.java:22:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer TargetType46.java:23:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer -2 errors +TargetType46.java:25:16: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer +3 errors diff --git a/langtools/test/tools/javac/lambda/TargetType68.java b/langtools/test/tools/javac/lambda/TargetType68.java index 92ce99bd8ad..13cad4f16b0 100644 --- a/langtools/test/tools/javac/lambda/TargetType68.java +++ b/langtools/test/tools/javac/lambda/TargetType68.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,9 @@ /* * @test - * @bug 8010303 + * @bug 8010303 8062373 * @summary Graph inference: missing incorporation step causes spurious inference error - * @compile TargetType68.java + * @compile/fail/ref=TargetType68.out -XDrawDiagnostics TargetType68.java */ import java.util.*; @@ -58,6 +58,6 @@ class TargetType68 { List> data_2 = new ArrayList<>(); numberChart.getData().setAll( Arrays.asList(new XYChart.Series<>("Data", FXCollections.observableList(data_1)), - new XYChart.Series<>("Data", FXCollections.observableList(data_2)))); + new XYChart.Series<>("Data", FXCollections.observableList(data_2)) {})); } } diff --git a/langtools/test/tools/javac/lambda/TargetType68.out b/langtools/test/tools/javac/lambda/TargetType68.out new file mode 100644 index 00000000000..6dd8e49c233 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType68.out @@ -0,0 +1,3 @@ +TargetType68.java:61:32: compiler.err.cant.inherit.from.final: TargetType68.XYChart.Series +TargetType68.java:61:39: compiler.err.cant.inherit.from.final: TargetType68.XYChart.Series +2 errors diff --git a/langtools/test/tools/javac/lambda/TargetType69.java b/langtools/test/tools/javac/lambda/TargetType69.java index 065c1e95fb2..46b7a22ce9b 100644 --- a/langtools/test/tools/javac/lambda/TargetType69.java +++ b/langtools/test/tools/javac/lambda/TargetType69.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8010303 + * @bug 8010303 8062373 * @summary Graph inference: missing incorporation step causes spurious inference error * @compile TargetType69.java */ @@ -47,5 +47,6 @@ class TargetType69 { void test(Function classifier, Function>> coll) { exerciseMapTabulation(coll, new GroupedMapAssertion<>(classifier)); + exerciseMapTabulation(coll, new GroupedMapAssertion<>(classifier) {}); } } diff --git a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceNullCheckTest.java b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceNullCheckTest.java index fd2bf655649..c0fcedd068a 100644 --- a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceNullCheckTest.java +++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceNullCheckTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,12 +25,11 @@ /** * @test - * @bug 8024696 + * @bug 8024696 8075752 * @summary Missing null check in bound method reference capture */ -import com.sun.tools.javac.util.Assert; -import java.util.function.*; +import java.util.function.Supplier; public class MethodReferenceNullCheckTest { public static void main(String[] args) { @@ -41,7 +40,8 @@ public class MethodReferenceNullCheckTest { } catch (NullPointerException npe) { npeFired = true; } finally { - Assert.check(npeFired, "NPE should have been thrown"); + if (!npeFired) + throw new AssertionError("NPE should have been thrown"); } } } diff --git a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java index d63f7734dbf..813c588349f 100644 --- a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java +++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,9 +108,10 @@ public class FDTest { public static List> generateCases() { ArrayList> list = new ArrayList<>(); HierarchyGenerator hg = new HierarchyGenerator(); + int i = 0; for (TestKind tk : TestKind.values()) { for (Hierarchy hs : tk.getHierarchy(hg)) { - list.add(new Pair<>(tk, hs)); + list.add((i++ % 2) == 0 ? new Pair<>(tk, hs) {} : new Pair<>(tk, hs)); } } return list; diff --git a/langtools/test/tools/javac/lib/DPrinter.java b/langtools/test/tools/javac/lib/DPrinter.java index da9f62da6a2..d5907fd7a4a 100644 --- a/langtools/test/tools/javac/lib/DPrinter.java +++ b/langtools/test/tools/javac/lib/DPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -477,7 +477,7 @@ public class DPrinter { out.print(label); out.println(": " + info(sym.getClass(), - String.format("0x%x--%s", sym.kind, Kinds.kindName(sym)), + String.format("0x%x--%s", sym.kind.ordinal(), Kinds.kindName(sym)), sym.getKind()) + " " + sym.name + " " + hashString(sym)); diff --git a/langtools/test/tools/javac/processing/model/type/BasicAnnoTests.java b/langtools/test/tools/javac/processing/model/type/BasicAnnoTests.java index aafe60a4dd3..c2e4e86161b 100644 --- a/langtools/test/tools/javac/processing/model/type/BasicAnnoTests.java +++ b/langtools/test/tools/javac/processing/model/type/BasicAnnoTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,21 +23,27 @@ /* * @test - * @bug 8013852 + * @bug 8013852 8031744 * @summary Annotations on types * @library /tools/javac/lib - * @ignore 8057688 type annotations in type argument position are lost - * @ignore 8031744 Annotations on many Language Model elements are not returned * @build JavacTestingAbstractProcessor DPrinter BasicAnnoTests * @compile/process -processor BasicAnnoTests -proc:only BasicAnnoTests.java */ import java.io.PrintWriter; +import java.io.Serializable; import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; import java.lang.annotation.Target; +import java.util.ArrayList; + +import java.util.HashSet; +import java.util.List; import java.util.Map; +import java.util.NavigableMap; import java.util.Set; +import java.util.TreeMap; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; @@ -48,15 +54,23 @@ import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.ArrayType; +import javax.lang.model.type.DeclaredType; import javax.lang.model.type.ExecutableType; +import javax.lang.model.type.IntersectionType; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; import javax.lang.model.type.WildcardType; +import javax.lang.model.util.Types; import javax.tools.Diagnostic.Kind; +import com.sun.tools.javac.code.Attribute; import com.sun.tools.javac.code.Symbol; -import com.sun.tools.javac.code.Type; import com.sun.tools.javac.processing.JavacProcessingEnvironment; +import com.sun.tools.javac.util.Name; + +import static com.sun.tools.javac.code.Attribute.Array; +import static com.sun.tools.javac.code.Attribute.Constant; +import static com.sun.tools.javac.code.Attribute.Compound; /** * The test scans this file looking for test cases annotated with @Test. @@ -77,7 +91,7 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { TestElementScanner s = new TestElementScanner(); for (Element e: roundEnv.getRootElements()) { - s.scan(e); + s.scan(e, null); } return true; } @@ -95,17 +109,17 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor { */ class TestElementScanner extends ElementScanner { public Void scan(Element elem, Void ignore) { + List tests = new ArrayList<>(); AnnotationMirror test = getAnnotation(elem, Test.class.getName().replace('$', '.')); if (test != null) { + tests.add(test); + } + tests.addAll(getAnnotations(elem, Tests.class.getName().replace('$', '.'))); + + if (tests.size() > 0) { out.println("Test: " + elem + " " + test); - TestTypeScanner s = new TestTypeScanner(elem, test); - s.scan(elem.asType(), null); - if (getPosn(test) >= s.count) - error(elem, "position " + getPosn(test) + " not found"); - if (!s.found) { - dprinter.printSymbol("element", (Symbol) elem); - dprinter.printType("type", (Type) elem.asType()); - } + TestTypeScanner s = new TestTypeScanner(elem, tests, types); + s.test(elem.asType()); out.println(); } return super.scan(elem, ignore); @@ -118,45 +132,110 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor { */ class TestTypeScanner extends TypeScanner { Element elem; - AnnotationMirror test; + NavigableMap toBeFound; int count = 0; - boolean found = false; + Set seen = new HashSet<>(); - TestTypeScanner(Element elem, AnnotationMirror test) { + TestTypeScanner(Element elem, List tests, Types types) { + super(types); this.elem = elem; - this.test = test; + + NavigableMap testByPos = new TreeMap<>(); + for (AnnotationMirror test : tests) { + for (int pos : getPosn(test)) { + testByPos.put(pos, test); + } + } + this.toBeFound = testByPos; + } + + public void test(TypeMirror t) { + scan(t, null); } @Override Void scan(TypeMirror t, Void ignore) { if (t == null) return DEFAULT_VALUE; - if (verbose) - out.println("scan " + count + ": " + t); - if (count == getPosn(test)) { - String annoType = getAnnoType(test); - AnnotationMirror anno = getAnnotation(t, annoType); - if (anno == null) { - error(elem, "annotation not found on " + count + ": " + t); - } else { - String v = getValue(anno, "value").toString(); - if (v.equals(getExpect(test))) { - out.println("found " + anno + " as expected"); - found = true; + + if (!seen.contains(t)) { + try { + seen.add(t); + if (verbose) + out.println("scan " + count + ": " + t); + if (toBeFound.size() > 0) { + if (toBeFound.firstKey().equals(count)) { + AnnotationMirror test = toBeFound.pollFirstEntry().getValue(); + String annoType = getAnnoType(test); + AnnotationMirror anno = getAnnotation(t, annoType); + if (anno == null) { + error(elem, "annotation not found on " + count + ": " + t); + } else { + String v = getValue(anno, "value").toString(); + if (v.equals(getExpect(test))) { + out.println("found " + anno + " as expected"); + } else { + error(elem, "Unexpected value: " + v + ", expected: " + getExpect(test)); + } + } + } else if (count > toBeFound.firstKey()) { + rescue(); + } else { + List annos = t.getAnnotationMirrors(); + if (annos.size() > 0) { + for (AnnotationMirror a : annos) + error(elem, "annotation " + a + " found on " + count + ": " + t); + } + } } else { - error(elem, "Unexpected value: " + v + ", expected: " + getExpect(test)); + List annos = t.getAnnotationMirrors(); + if (annos.size() > 0) { + for (AnnotationMirror a : annos) + error(elem, "annotation " + a + " found on " + count + ": " + t); + } } + count++; + return super.scan(t, ignore); + + } finally { + seen.remove(t); } } - count++; - return super.scan(t, ignore); + + return DEFAULT_VALUE; + + } + + private void rescue() { + while (toBeFound.size() > 0 && toBeFound.firstKey() >= count) + toBeFound.pollFirstEntry(); } } - /** Get the position value from an @Test annotation mirror. */ - static int getPosn(AnnotationMirror test) { + /** Get the position value from an element annotated with a @Test annotation mirror. */ + static int[] getPosn(Element elem) { + return elem.getAnnotation(Test.class).posn(); + } + + /** Get the position value from a @Test annotation mirror. */ + static Integer[] getPosn(AnnotationMirror test) { AnnotationValue v = getValue(test, "posn"); - return (Integer) v.getValue(); + Object value = v.getValue(); + Integer i = 0; + if (value instanceof Constant) { + i = (Integer)((Constant)value).getValue(); + Integer[] res = new Integer[1]; + res[0] = i; + return res; + } else if (value instanceof List) { + List l = (List)value; + Integer[] res = new Integer[l.size()]; + for (int c = 0; c < l.size(); c++) { + res[c] = (Integer)l.get(c).getValue(); + } + return res; + } + return null; } /** Get the expect value from an @Test annotation mirror. */ @@ -185,6 +264,25 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor { return null; } + static List getAnnotations(Element e, String name) { + Name valueName = ((Symbol)e).getSimpleName().table.names.value; + List res = new ArrayList<>(); + + for (AnnotationMirror m : e.getAnnotationMirrors()) { + TypeElement te = (TypeElement) m.getAnnotationType().asElement(); + if (te.getQualifiedName().contentEquals(name)) { + Compound theAnno = (Compound)m; + Array valueArray = (Array)theAnno.member(valueName); + for (Attribute a : valueArray.getValue()) { + AnnotationMirror theMirror = (AnnotationMirror) a; + + res.add(theMirror); + } + } + } + return res; + } + /** * Get a specific value from an annotation mirror. */ @@ -203,6 +301,13 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor { * one sufficient for our needs. */ static class TypeScanner extends SimpleTypeVisitor { + private Types types; + + public TypeScanner(Types types) { + super(); + this.types = types; + } + @Override public R visitArray(ArrayType t, P p) { scan(t.getComponentType(), p); @@ -211,16 +316,33 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor { @Override public R visitExecutable(ExecutableType t, P p) { + //out.println(" type parameters: " + t.getTypeVariables()); + scan(t.getTypeVariables(), p); + //out.println(" return: " + t.getReturnType()); + scan(t.getReturnType(), p); + //out.println(" receiver: " + t.getReceiverTypes()); scan(t.getReceiverType()); //out.println(" params: " + t.getParameterTypes()); scan(t.getParameterTypes(), p); - //out.println(" return: " + t.getReturnType()); - scan(t.getReturnType(), p); //out.println(" throws: " + t.getThrownTypes()); scan(t.getThrownTypes(), p); return super.visitExecutable(t, p); } + @Override + public R visitDeclared(DeclaredType t, P p) { + scan(t.getTypeArguments(), p); + // don't scan enclosing + scan(types.directSupertypes(t), p); + return super.visitDeclared(t, p); + } + + @Override + public R visitIntersection(IntersectionType t, P p) { + scan(t.getBounds(), p); + return super.visitIntersection(t, p); + } + @Override public R visitTypeVariable(TypeVariable t, P p) { scan(t.getLowerBound(), p); @@ -254,36 +376,194 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor { } /** Annotation to identify test cases. */ + @Repeatable(Tests.class) @interface Test { /** Where to look for the annotation, expressed as a scan index. */ - int posn(); + int[] posn(); /** The annotation to look for. */ Class annoType(); /** The string representation of the annotation's value. */ String expect(); } + @interface Tests { + Test[] value(); + } + /** Type annotation to use in test cases. */ @Target(ElementType.TYPE_USE) public @interface TA { int value(); } + @Target(ElementType.TYPE_USE) + public @interface TB { + int value(); + } + + // Test cases + + // TODO: add more cases for arrays + // all annotated + // all but one annotated + // vary position of one not annotated + // only one annotated + // vary position of one annotated + // the three above with the corner case of the ambiguos decl + type anno added @Test(posn=0, annoType=TA.class, expect="1") public @TA(1) int f1; + @Test(posn=0, annoType=TA.class, expect="11") + @TA(11) public int f11; + + @Test(posn=1, annoType=TA.class, expect="111") + @TA(111) public int [] f111; + + @Test(posn=1, annoType=TA.class, expect="1120") + @Test(posn=0, annoType=TB.class, expect="1121") + @TA(1120) public int @TB(1121) [] f112; + + @Test(posn=0, annoType=TB.class, expect="11211") + @Test(posn=1, annoType=TA.class, expect="11200") + public @TA(11200) int @TB(11211) [] f112b; + + @Test(posn=1, annoType=TB.class, expect="1131") + @Test(posn=2, annoType=TA.class, expect="1130") + @TA(1130) public int [] @TB(1131) [] f113; + + @Test(posn=5, annoType=TA.class, expect="12") + public @TA(12) int [] [] [] [] [] f12; + + @Test(posn=6, annoType=TA.class, expect="13") + public @TA(13) int [] [] [] [] [] [] f13; + + @Test(posn=7, annoType=TA.class, expect="14") + @TA(14) public int [] [] [] [] [] [] [] f14; + + @Test(posn=6, annoType=TA.class, expect="150") + @Test(posn=7, annoType=TB.class, expect="151") + @TB(151) public int [] [] [] [] [] [] @TA(150) [] f15; + + @Test(posn=0, annoType=TB.class, expect="1511") + @Test(posn=3, annoType=TA.class, expect="1512") + @Test(posn=6, annoType=TA.class, expect="150") + @Test(posn=7, annoType=TB.class, expect="151") + @TB(151) public int @TB(1511) [] [] [] @TA(1512) [] [] [] @TA(150) [] f15b; + + @Test(posn=0, annoType=TB.class, expect="1521") + @Test(posn=3, annoType=TA.class, expect="1522") + @Test(posn=6, annoType=TA.class, expect="152") + public int @TB(1521) [] [] [] @TA(1522) [] [] [] @TA(152) [] f15c; + + @Test(posn=5, annoType=TA.class, expect="160") + @Test(posn=6, annoType=TB.class, expect="161") + public int [] [] [] [] [] @TA(160) [] @TB(161) [] f16; + @Test(posn=0, annoType=TA.class, expect="2") public int @TA(2) [] f2; + @Test(posn=0, annoType=TB.class, expect="33") @Test(posn=1, annoType=TA.class, expect="3") - public @TA(3) int [] f3; + public @TA(3) int @TB(33) [] f3; - @Test(posn=1, annoType=TA.class, expect="4") + @Test(posn=2, annoType=TA.class, expect="4") public int m1(@TA(4) float a) throws Exception { return 0; } - @Test(posn=2, annoType=TA.class, expect="5") + @Test(posn=1, annoType=TA.class, expect="5") public @TA(5) int m2(float a) throws Exception { return 0; } @Test(posn=3, annoType=TA.class, expect="6") public int m3(float a) throws @TA(6) Exception { return 0; } + + // Also tests that a decl anno on a typevar doesn't show up on the Type + @Test(posn=7, annoType=TA.class, expect="8") + public <@TA(7) M> M m4(@TA(8) float a) throws Exception { return null; } + + // Also tests that a decl anno on a typevar doesn't show up on the Type + @Test(posn=4, annoType=TA.class, expect="10") + public class Inner1<@TA(9) S> extends @TA(10) Object implements Cloneable {} + + // Also tests that a decl anno on a typevar doesn't show up on the Type + @Test(posn=5, annoType=TA.class, expect="12") + public class Inner2<@TA(11) S> extends Object implements @TA(12) Cloneable {} + + @Test(posn={3,6}, annoType=TA.class, expect="13") + public M m5(float a) { return null; } + + @Test(posn=3, annoType=TA.class, expect="14") + public class Inner3 {} + + @Test(posn=4, annoType=TA.class, expect="15") + public class Inner4 {} + + @Test(posn=5, annoType=TA.class, expect="16") + public class Inner5 {} + + @Test(posn=7, annoType=TA.class, expect="17") + public class Inner6 {} + + // Test annotated bounds + + @Test(posn=1, annoType=TA.class, expect="18") + public Set<@TA(18) ? extends Object> f4; + + @Test(posn=2, annoType=TA.class, expect="19") + public Set f5; + + @Test(posn=3, annoType=TA.class, expect="20") + public Set> f6; + + @Test(posn=4, annoType=TA.class, expect="21") + public Set> f7; + + @Test(posn=1, annoType=TA.class, expect="22") + public Set<@TA(22) ?> f8; + + @Test(posn=1, annoType=TA.class, expect="23") + public Set<@TA(23) ? super Object> f9; + + // Test type use annotations on uses of type variables + @Test(posn=5, annoType = TA.class, expect = "25") + @Test(posn=5, annoType = TB.class, expect = "26") + void m6(@TA(25) @TB(26) T t) { } + + class Inner7 { + @Test(posn=0, annoType = TA.class, expect = "30") + @Test(posn=0, annoType = TB.class, expect = "31") + @TA(30) @TB(31) T f; + } + + // Test type use annotations on uses of type variables + @Test(posn=5, annoType = TB.class, expect = "41") + <@TA(40) T> void m7(@TB(41) T t) { } + + class Inner8<@TA(50) T> { + @Test(posn=0, annoType = TB.class, expect = "51") + @TB(51) T f; + } + + // Test type use annotations on uses of Class types + @Test(posn=5, annoType = TA.class, expect = "60") + @Test(posn=5, annoType = TB.class, expect = "61") + void m60(@TA(60) @TB(61) String t) { } + + class Inner70 { + @Test(posn=0, annoType = TA.class, expect = "70") + @Test(posn=0, annoType = TB.class, expect = "71") + @TA(70) @TB(71) String f; + } + + // Test type use annotations on uses of type variables + @Test(posn=5, annoType = TB.class, expect = "81") + <@TA(80) T> void m80(@TB(81) String t) { } + + class Inner90<@TA(90) T> { + @Test(posn=0, annoType = TB.class, expect = "91") + @TB(91) String f; + } + + // Recursive bound + @Test(posn=4, annoType = TB.class, expect = "100") + class Inner100> { + } } diff --git a/langtools/test/tools/javac/scope/DupUnsharedTest.java b/langtools/test/tools/javac/scope/DupUnsharedTest.java index 7506648aa85..b60a2d1c7cb 100644 --- a/langtools/test/tools/javac/scope/DupUnsharedTest.java +++ b/langtools/test/tools/javac/scope/DupUnsharedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ public class DupUnsharedTest { } void runScopeContentTest() throws Exception { - Set expected = Collections.newSetFromMap(new IdentityHashMap<>()); + Set expected = Collections.newSetFromMap(new IdentityHashMap<>() {}); Set notExpected = Collections.newSetFromMap(new IdentityHashMap<>()); WriteableScope s1 = WriteableScope.create(symtab.rootPackage); ClassSymbol acceptSym = symtab.arrayClass; @@ -105,7 +105,7 @@ public class DupUnsharedTest { } Set toSet(Iterable it) { - Set result = Collections.newSetFromMap(new IdentityHashMap<>()); + Set result = Collections.newSetFromMap(new IdentityHashMap<>() {}); for (Symbol sym : it) { result.add(sym); diff --git a/langtools/test/tools/javac/warnings/6747671/T6747671.out b/langtools/test/tools/javac/warnings/6747671/T6747671.out index 518804d68b5..1176234cd39 100644 --- a/langtools/test/tools/javac/warnings/6747671/T6747671.out +++ b/langtools/test/tools/javac/warnings/6747671/T6747671.out @@ -7,6 +7,6 @@ T6747671.java:29:28: compiler.warn.raw.class.use: T6747671.B, T6747671.B T6747671.java:32:9: compiler.warn.raw.class.use: T6747671.A, T6747671.A T6747671.java:32:20: compiler.warn.raw.class.use: T6747671.A, T6747671.A T6747671.java:33:16: compiler.warn.raw.class.use: T6747671.A.Z, T6747671.A.Z -T6747671.java:36:9: compiler.warn.raw.class.use: @T6747671.TA T6747671.B, T6747671.B +T6747671.java:36:9: compiler.warn.raw.class.use: T6747671.B, T6747671.B T6747671.java:36:27: compiler.warn.raw.class.use: T6747671.B, T6747671.B 11 warnings diff --git a/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java b/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java index d5b34bd15a6..c86bdc56bbf 100644 --- a/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java +++ b/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java @@ -45,8 +45,6 @@ import javax.tools.StandardJavaFileManager; import javax.tools.ToolProvider; import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.nio.JavacPathFileManager; -import com.sun.tools.javac.nio.PathFileManager; import com.sun.tools.javac.util.Context; /** @@ -59,7 +57,7 @@ public class GetTask_FileManagerTest extends APITest { /** * Verify that an alternate file manager can be specified: - * in this case, a PathFileManager. + * in this case, a TestFileManager. */ @Test public void testFileManager() throws Exception { diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index 066802688e7..e0ad0f63bb8 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -151,9 +151,19 @@ java.desktop_EXCLUDE_FILES += \ ifeq ($(OPENJDK_TARGET_OS), macosx) # exclude all X11 on Mac. - java.desktop_EXCLUDES += sun/awt/X11 + java.desktop_EXCLUDES += \ + sun/awt/X11 \ + sun/java2d/x11 \ + sun/java2d/jules \ + sun/java2d/xr \ + com/sun/java/swing/plaf/gtk \ + # java.desktop_EXCLUDE_FILES += \ - $(JDK_TOPDIR)/src/java.desktop/unix/classes/sun/java2d/BackBufferCapsProvider.java \ + $(wildcard $(JDK_TOPDIR)/src/java.desktop/unix/classes/sun/java2d/*.java) \ + $(wildcard $(JDK_TOPDIR)/src/java.desktop/unix/classes/sun/java2d/opengl/*.java) \ + $(wildcard $(JDK_TOPDIR)/src/java.desktop/unix/classes/sun/awt/*.java) \ + $(wildcard $(JDK_TOPDIR)/src/java.desktop/unix/classes/sun/awt/motif/*.java) \ + $(wildcard $(JDK_TOPDIR)/src/java.desktop/unix/classes/sun/font/*.java) \ # else # TBD: figure out how to eliminate this long list diff --git a/make/Help.gmk b/make/Help.gmk new file mode 100644 index 00000000000..739a85e2ee7 --- /dev/null +++ b/make/Help.gmk @@ -0,0 +1,102 @@ +# +# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +### +### Global targets for printing help etc. +### + +# Helper macro to allow $(info) to properly print strings beginning with spaces. +_:= + +help: + $(info ) + $(info OpenJDK Makefile help) + $(info =====================) + $(info ) + $(info Common make targets) + $(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 # 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) + $(info $(_) # dependencies for the target. This is faster but may) + $(info $(_) # result in incorrect build results!) + $(info $(_) make docs # Create all docs) + $(info $(_) make docs-javadoc # Create just javadocs, depends on less than full docs) + $(info $(_) make profiles # Create complete jre compact profile images) + $(info $(_) make bootcycle-images # Build images twice, second time with newly built JDK) + $(info $(_) make install # Install the generated images locally) + $(info $(_) make reconfigure # Rerun configure with the same arguments as last time) + $(info $(_) make help # Give some help on using make) + $(info $(_) make test # Run tests, default is all tests (see TEST below)) + $(info ) + $(info Targets for cleaning) + $(info $(_) make clean # Remove all files generated by make, but not those) + $(info $(_) # generated by configure) + $(info $(_) make dist-clean # Remove all files, including configuration) + $(info $(_) make clean- # Remove the subdir in the output dir with the name) + $(info $(_) make clean- # Remove all build results related to a certain build) + $(info $(_) # phase (gensrc, java, libs, launchers)) + $(info $(_) make clean- # Remove all build results related to a certain module) + $(info $(_) make clean-- # Remove all build results related to a certain) + $(info $(_) # module and phase) + $(info ) + $(info Targets for specific modules) + $(info $(_) make # Build and everything it depends on) + $(info $(_) make - # Compile the specified phase for the specified module) + $(info $(_) # and everything it depends on) + $(info $(_) # (gensrc, java, copy, libs, launchers, gendata, rmic)) + $(info ) + $(info Make control variables) + $(info $(_) CONF= # Build all configurations (note, assignment is empty)) + $(info $(_) CONF= # Build the configuration(s) with a name matching) + $(info $(_) # ) + $(info $(_) SPEC= # Build the configuration given by the spec file) + $(info $(_) LOG= # Change the log level from warn to ) + $(info $(_) # Available log levels are:) + $(info $(_) # 'warn' (default), 'info', 'debug' and 'trace') + $(info $(_) # To see executed command lines, use LOG=debug) + $(info $(_) JOBS= # Run parallel make jobs) + $(info $(_) # Note that -jN does not work as expected!) + $(info $(_) CONF_CHECK= # What to do if spec file is out of date) + $(info $(_) # method is 'auto', 'ignore' or 'fail' (default)) + $(info $(_) make test TEST= # Only run the given test or tests, e.g.) + $(info $(_) # make test TEST="jdk_lang jdk_net") + $(info ) + $(if $(all_confs), $(info Available configurations in $(build_dir):) $(foreach var,$(all_confs),$(info * $(var))),\ + $(info No configurations were found in $(build_dir).) $(info Run 'bash configure' to create a configuration.)) + # We need a dummy rule otherwise make will complain + @true + +print-configurations: + $(foreach var, $(all_confs), $(info $(var))) + # We need a dummy rule otherwise make will complain + @true + +ALL_GLOBAL_TARGETS := help print-configurations + +.PHONY: $(ALL_GLOBAL_TARGETS) diff --git a/make/HotspotWrapper.gmk b/make/HotspotWrapper.gmk index 0677deb0080..e5ec544abcb 100644 --- a/make/HotspotWrapper.gmk +++ b/make/HotspotWrapper.gmk @@ -42,7 +42,7 @@ HOTSPOT_FILES := $(shell $(FIND) -L $(HOTSPOT_TOPDIR) -name ".hg" -prune -o -pri # not doing it breaks builds on msys. $(HOTSPOT_OUTPUTDIR)/_hotspot.timestamp: $(HOTSPOT_FILES) @$(MKDIR) -p $(HOTSPOT_OUTPUTDIR) - @($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(HOTSPOT_MAKE_ARGS) SPEC=$(HOTSPOT_SPEC) BASE_SPEC=$(BASE_SPEC)) + @($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(HOTSPOT_MAKE_ARGS) LOG_LEVEL=$(LOG_LEVEL) SPEC=$(HOTSPOT_SPEC) BASE_SPEC=$(BASE_SPEC)) $(TOUCH) $@ hotspot: $(HOTSPOT_OUTPUTDIR)/_hotspot.timestamp diff --git a/make/Init.gmk b/make/Init.gmk new file mode 100644 index 00000000000..431b3a7f7b5 --- /dev/null +++ b/make/Init.gmk @@ -0,0 +1,279 @@ +# +# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# This is the bootstrapping part of the build. This file is included from the +# top level Makefile, and is responsible for launching the Main.gmk file with +# the proper make and the proper make arguments. +################################################################################ + +# This must be the first rule +default: +.PHONY: default + +# Inclusion of this pseudo-target will cause make to execute this file +# serially, regardless of -j. +.NOTPARALLEL: + +ifeq ($(HAS_SPEC),) + ############################################################################## + # This is the default mode. We have not been recursively called with a SPEC. + ############################################################################## + + # Include our helper functions. + include $(topdir)/make/InitSupport.gmk + + # Here are "global" targets, i.e. targets that can be executed without having + # a configuration. This will define ALL_GLOBAL_TARGETS. + include $(topdir)/make/Help.gmk + + # Targets provided by Init.gmk. + ALL_INIT_TARGETS := print-modules print-targets reconfigure + + # CALLED_TARGETS is the list of targets that the user provided, + # or "default" if unspecified. + CALLED_TARGETS := $(if $(MAKECMDGOALS), $(MAKECMDGOALS), default) + + # Extract non-global targets that require a spec file. + CALLED_SPEC_TARGETS := $(filter-out $(ALL_GLOBAL_TARGETS), $(CALLED_TARGETS)) + + # If we have only global targets, or if we are called with -qp (assuming an + # external part, e.g. bash completion, is trying to understand our targets), + # we will skip SPEC location and the sanity checks. + ifeq ($(CALLED_SPEC_TARGETS), ) + ONLY_GLOBAL_TARGETS := true + endif + ifneq ($(findstring qp, $(MAKEFLAGS)),) + ONLY_GLOBAL_TARGETS := true + endif + + ifeq ($(ONLY_GLOBAL_TARGETS), true) + ############################################################################ + # We have only global targets, or are called with -pq. + ############################################################################ + + ifeq ($(wildcard $(SPEC)), ) + # If we have no SPEC provided, we will just make a "best effort" target list. + # First try to grab any available pre-existing main-targets.gmk. + main_targets_file := $(firstword $(wildcard $(build_dir)/*/make-support/main-targets.gmk)) + ifneq ($(main_targets_file), ) + # Extract the SPEC that corresponds to this main-targets.gmk file. + SPEC := $(patsubst %/make-support/main-targets.gmk, %/spec.gmk, $(main_targets_file)) + else + # None found, pick an arbitrary SPEC for which to generate a file + SPEC := $(firstword $(all_spec_files)) + endif + endif + + ifneq ($(wildcard $(SPEC)), ) + $(eval $(call DefineMainTargets, LAZY, $(SPEC))) + else + # If we have no configurations we can not provide any main targets. + ALL_MAIN_TARGETS := + endif + + ALL_TARGETS := $(sort $(ALL_GLOBAL_TARGETS) $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS)) + + # Just list all our targets. + $(ALL_TARGETS): + + .PHONY: $(ALL_TARGETS) + + else + ############################################################################ + # This is the normal case, we have been called from the command line by the + # user and we need to call ourself back with a proper SPEC. + # We have at least one non-global target, so we need to find a spec file. + ############################################################################ + + # Basic checks on environment and command line. + $(eval $(call CheckControlVariables)) + $(eval $(call CheckDeprecatedEnvironment)) + $(eval $(call CheckInvalidMakeFlags)) + + # Check that CONF_CHECK is valid. + $(eval $(call ParseConfCheckOption)) + + # Check that the LOG given is valid, and set LOG_LEVEL, LOG_NOFILE and MAKE_LOG_FLAGS. + $(eval $(call ParseLogLevel)) + + # After this SPECS contain 1..N spec files (otherwise ParseConfAndSpec fails). + $(eval $(call ParseConfAndSpec)) + + # Extract main targets from Main.gmk using the spec(s) provided. In theory, + # with multiple specs, we should find the intersection of targets provided + # by all specs, but we approximate this by an arbitrary spec from the list. + # This will setup ALL_MAIN_TARGETS. + $(eval $(call DefineMainTargets, FORCE, $(firstword $(SPECS)))) + + # Separate called targets depending on type. + INIT_TARGETS := $(filter $(ALL_INIT_TARGETS), $(CALLED_SPEC_TARGETS)) + MAIN_TARGETS := $(filter $(ALL_MAIN_TARGETS), $(CALLED_SPEC_TARGETS)) + SEQUENTIAL_TARGETS := $(filter dist-clean clean%, $(MAIN_TARGETS)) + PARALLEL_TARGETS := $(filter-out $(SEQUENTIAL_TARGETS), $(MAIN_TARGETS)) + + # The spec files depend on the autoconf source code. This check makes sure + # the configuration is up to date after changes to configure. + $(SPECS): $(wildcard $(topdir)/common/autoconf/*) + ifeq ($(CONF_CHECK), fail) + @echo "Error: The configuration is not up to date for '$(lastword $(subst /, , $(dir $@)))'." + $(call PrintConfCheckFailed) + @exit 2 + else ifeq ($(CONF_CHECK), auto) + @echo "Note: The configuration is not up to date for '$(lastword $(subst /, , $(dir $@)))'." + @( cd $(topdir) && \ + $(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -f $(topdir)/make/Init.gmk \ + SPEC=$@ HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) \ + reconfigure ) + else ifeq ($(CONF_CHECK), ignore) + # Do nothing + endif + + # Unless reconfigure is explicitely called, let all main targets depend on + # the spec files to be up to date. + ifeq ($(findstring reconfigure, $(INIT_TARGETS)), ) + $(MAIN_TARGETS): $(SPECS) + endif + + make-info: + ifneq ($(findstring $(LOG_LEVEL),info debug trace),) + $(info Running make as '$(strip $(MAKE) $(MFLAGS) \ + $(COMMAND_LINE_VARIABLES) $(MAKECMDGOALS))') + endif + + # Now the init and main targets will be called, once for each SPEC. The + # recipe will be run once for every target specified, but we only want to + # execute the recipe a single time, hence the TARGET_DONE with a dummy + # command if true. + $(ALL_INIT_TARGETS) $(ALL_MAIN_TARGETS): make-info + @$(if $(TARGET_DONE), \ + true \ + , \ + $(foreach spec, $(SPECS), \ + ( cd $(topdir) && \ + $(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -j 1 -f $(topdir)/make/Init.gmk \ + SPEC=$(spec) HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) \ + USER_MAKE_VARS="$(USER_MAKE_VARS)" MAKE_LOG_FLAGS=$(MAKE_LOG_FLAGS) \ + LOG_LEVEL=$(LOG_LEVEL) LOG_NOFILE=$(LOG_NOFILE) \ + INIT_TARGETS="$(INIT_TARGETS)" \ + SEQUENTIAL_TARGETS="$(SEQUENTIAL_TARGETS)" \ + PARALLEL_TARGETS="$(PARALLEL_TARGETS)" \ + main ) && \ + ) true \ + $(eval TARGET_DONE=true) \ + ) + + .PHONY: $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS) + + endif # $(ONLY_GLOBAL_TARGETS)!=true + +else # HAS_SPEC=true + + ############################################################################## + # Now we have a spec. This part provides the "main" target that acts as a + # trampoline to call the Main.gmk with the value of $(MAKE) found in the spec + # file. + ############################################################################## + + include $(SPEC) + + # Our helper functions. + include $(TOPDIR)/make/InitSupport.gmk + + # Verify that the spec file we included seems okay. + $(eval $(call CheckSpecSanity)) + + ifeq ($(LOG_NOFILE), true) + # Disable log wrapper if LOG=[level,]nofile was given + override BUILD_LOG_WRAPPER := + endif + + ifeq ($(OUTPUT_SYNC_SUPPORTED), true) + OUTPUT_SYNC_FLAG := -O$(OUTPUT_SYNC) + endif + + ############################################################################## + # Init targets + ############################################################################## + + print-modules: + ( cd $(TOPDIR) && \ + $(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \ + NO_RECIPES=true print-modules ) + + print-targets: + ( cd $(TOPDIR) && \ + $(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \ + NO_RECIPES=true print-targets ) + + reconfigure: + ifneq ($(CONFIGURE_COMMAND_LINE), ) + $(ECHO) "Re-running configure using arguments '$(CONFIGURE_COMMAND_LINE)'" + else + $(ECHO) "Re-running configure using default settings" + endif + ( cd $(OUTPUT_ROOT) && PATH="$(ORIGINAL_PATH)" \ + $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) ) + + ############################################################################## + # The main target, for delegating into Main.gmk + ############################################################################## + + MAIN_TARGETS := $(SEQUENTIAL_TARGETS) $(PARALLEL_TARGETS) + TARGET_DESCRIPTION := target$(if $(word 2, $(MAIN_TARGETS)),s) \ + '$(strip $(MAIN_TARGETS))' in configuration '$(CONF_NAME)' + + # MAKEOVERRIDES is automatically set and propagated by Make to sub-Make calls. + # We need to clear it of the init-specific variables. The user-specified + # variables are explicitely propagated using $(USER_MAKE_VARS). + main: MAKEOVERRIDES := + + main: $(INIT_TARGETS) + ifneq ($(SEQUENTIAL_TARGETS)$(PARALLEL_TARGETS), ) + $(call RotateLogFiles) + $(BUILD_LOG_WRAPPER) $(PRINTF) "Building $(TARGET_DESCRIPTION)\n" + ifneq ($(SEQUENTIAL_TARGETS), ) + # Don't touch build output dir since we might be cleaning. That + # means no log wrapper. + ( cd $(TOPDIR) && \ + $(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \ + $(SEQUENTIAL_TARGETS) ) + endif + ifneq ($(PARALLEL_TARGETS), ) + $(call StartGlobalTimer) + $(call PrepareSmartJavac) + ( cd $(TOPDIR) && \ + $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(OUTPUT_SYNC_FLAG) \ + -j $(JOBS) -f make/Main.gmk $(USER_MAKE_VARS) \ + $(PARALLEL_TARGETS) ) + $(call CleanupSmartJavac) + $(call StopGlobalTimer) + $(call ReportBuildTimes) + endif + $(BUILD_LOG_WRAPPER) $(PRINTF) "Finished building $(TARGET_DESCRIPTION)\n" + endif + + .PHONY: print-targets print-modules reconfigure main +endif diff --git a/make/InitSupport.gmk b/make/InitSupport.gmk new file mode 100644 index 00000000000..b41b10808a4 --- /dev/null +++ b/make/InitSupport.gmk @@ -0,0 +1,359 @@ +# +# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# This file contains helper functions for Init.gmk. +# It is divided in two parts, depending on if a SPEC is present or not +# (HAS_SPEC is true or not). +################################################################################ + +ifndef _INITSUPPORT_GMK +_INITSUPPORT_GMK := 1 + +ifeq ($(HAS_SPEC),) + ############################################################################## + # Helper functions for the initial part of Init.gmk, before the spec file is + # loaded. Most of these functions provide parsing and setting up make options + # from the command-line. + ############################################################################## + + # Make control variables, handled by Init.gmk + INIT_CONTROL_VARIABLES := LOG CONF SPEC JOBS CONF_CHECK + + # All known make control variables + MAKE_CONTROL_VARIABLES := $(INIT_CONTROL_VARIABLES) TEST JDK_FILTER + + # Define a simple reverse function. + # Should maybe move to MakeBase.gmk, but we can't include that file now. + reverse = \ + $(if $(strip $(1)), $(call reverse, $(wordlist 2, $(words $(1)), $(1)))) \ + $(firstword $(1)) + + # The variable MAKEOVERRIDES contains variable assignments from the command + # line, but in reverse order to what the user entered. + COMMAND_LINE_VARIABLES := $(subst \#,\ , $(call reverse, $(subst \ ,\#,$(MAKEOVERRIDES)))) + + # A list like FOO="val1" BAR="val2" containing all user-supplied make + # variables that we should propagate. + USER_MAKE_VARS := $(filter-out $(addsuffix =%, $(INIT_CONTROL_VARIABLES)), \ + $(MAKEOVERRIDES)) + + # Setup information about available configurations, if any. + build_dir=$(topdir)/build + all_spec_files=$(wildcard $(build_dir)/*/spec.gmk) + # Extract the configuration names from the path + all_confs=$(patsubst %/spec.gmk, %, $(patsubst $(build_dir)/%, %, $(all_spec_files))) + + # Check for unknown command-line variables + define CheckControlVariables + command_line_variables := $$(strip $$(foreach var, \ + $$(subst \ ,_,$$(MAKEOVERRIDES)), \ + $$(firstword $$(subst =, , $$(var))))) + unknown_command_line_variables := $$(strip \ + $$(filter-out $$(MAKE_CONTROL_VARIABLES), $$(command_line_variables))) + ifneq ($$(unknown_command_line_variables), ) + $$(info Note: Command line contains non-control variables:) + $$(foreach var, $$(unknown_command_line_variables), $$(info * $$(var)=$$($$(var)))) + $$(info Make sure it is not mistyped, and that you intend to override this variable.) + $$(info 'make help' will list known control variables.) + $$(info ) + endif + endef + + # Check for deprecated ALT_ variables + define CheckDeprecatedEnvironment + defined_alt_variables := $$(filter ALT_%, $$(.VARIABLES)) + ifneq ($$(defined_alt_variables), ) + $$(info Warning: You have the following ALT_ variables set:) + $$(foreach var, $$(defined_alt_variables), $$(info * $$(var)=$$($$(var)))) + $$(info ALT_ variables are deprecated, and may result in a failed build.) + $$(info Please clean your environment.) + $$(info ) + endif + endef + + # Check for invalid make flags like -j + define CheckInvalidMakeFlags + # This is a trick to get this rule to execute before any other rules + # MAKEFLAGS only indicate -j if read in a recipe (!) + $$(topdir)/make/Init.gmk: .FORCE + $$(if $$(findstring --jobserver, $$(MAKEFLAGS)), \ + $$(info Error: 'make -jN' is not supported, use 'make JOBS=N') \ + $$(error Cannot continue) \ + ) + .FORCE: + .PHONY: .FORCE + endef + + # Check that the CONF_CHECK option is valid and set up handling + define ParseConfCheckOption + ifeq ($$(CONF_CHECK), ) + # Default behavior is fail + CONF_CHECK := fail + else ifneq ($$(filter-out auto fail ignore, $$(CONF_CHECK)),) + $$(info Error: CONF_CHECK must be one of: auto, fail or ignore.) + $$(error Cannot continue) + endif + endef + + define ParseLogLevel + # Catch old-style VERBOSE= command lines. + ifneq ($$(origin VERBOSE), undefined) + $$(info Error: VERBOSE is deprecated. Use LOG= instead.) + $$(error Cannot continue) + endif + + # Setup logging according to LOG + + # If the "nofile" argument is given, act on it and strip it away + ifneq ($$(findstring nofile, $$(LOG)),) + LOG_NOFILE := true + # COMMA is defined in spec.gmk, but that is not included yet + COMMA := , + # First try to remove ",nofile" if it exists, otherwise just remove "nofile" + LOG_STRIPPED := $$(subst nofile,, $$(subst $$(COMMA)nofile,, $$(LOG))) + # We might have ended up with a leading comma. Remove it + LOG_LEVEL := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED))) + else + LOG_LEVEL := $$(LOG) + endif + + ifeq ($$(LOG_LEVEL),) + # Set LOG to "warn" as default if not set + LOG_LEVEL := warn + endif + + ifeq ($$(LOG_LEVEL), warn) + MAKE_LOG_FLAGS := -s + else ifeq ($$(LOG_LEVEL), info) + MAKE_LOG_FLAGS := -s + else ifeq ($$(LOG_LEVEL), debug) + MAKE_LOG_FLAGS := + else ifeq ($$(LOG_LEVEL), trace) + MAKE_LOG_FLAGS := -d + else + $$(info Error: LOG must be one of: warn, info, debug or trace.) + $$(error Cannot continue) + endif + endef + + define ParseConfAndSpec + ifneq ($$(origin SPEC), undefined) + # We have been given a SPEC, check that it works out properly + ifneq ($$(origin CONF), undefined) + # We also have a CONF argument. We can't have both. + $$(info Error: Cannot use CONF=$$(CONF) and SPEC=$$(SPEC) at the same time. Choose one.) + $$(error Cannot continue) + endif + ifeq ($$(wildcard $$(SPEC)),) + $$(info Error: Cannot locate spec.gmk, given by SPEC=$$(SPEC).) + $$(error Cannot continue) + endif + ifeq ($$(filter /%, $$(SPEC)),) + # If given with relative path, make it absolute + SPECS := $$(CURDIR)/$$(strip $$(SPEC)) + else + SPECS := $$(SPEC) + endif + + # For now, unset this SPEC variable. + override SPEC := + else + # Use spec.gmk files in the build output directory + ifeq ($$(all_spec_files),) + $$(info Error: No configurations found for $$(topdir).) + $$(info Please run 'bash configure' to create a configuration.) + $$(info ) + $$(error Cannot continue) + endif + + ifneq ($$(origin CONF), undefined) + # User have given a CONF= argument. + ifeq ($$(CONF),) + # If given CONF=, match all configurations + matching_confs := $$(strip $$(all_confs)) + else + # Otherwise select those that contain the given CONF string + matching_confs := $$(strip $$(foreach var, $$(all_confs), \ + $$(if $$(findstring $$(CONF), $$(var)), $$(var)))) + endif + ifeq ($$(matching_confs),) + $$(info Error: No configurations found matching CONF=$$(CONF).) + $$(info Available configurations in $$(build_dir):) + $$(foreach var, $$(all_confs), $$(info * $$(var))) + $$(error Cannot continue) + else + ifeq ($$(words $$(matching_confs)), 1) + $$(info Building configuration '$$(matching_confs)' (matching CONF=$$(CONF))) + else + $$(info Building these configurations (matching CONF=$$(CONF)):) + $$(foreach var, $$(matching_confs), $$(info * $$(var))) + endif + endif + + # Create a SPEC definition. This will contain the path to one or more spec.gmk files. + SPECS := $$(addsuffix /spec.gmk, $$(addprefix $$(build_dir)/, $$(matching_confs))) + else + # No CONF or SPEC given, check the available configurations + ifneq ($$(words $$(all_spec_files)), 1) + $$(info Error: No CONF given, but more than one configuration found.) + $$(info Available configurations in $$(build_dir):) + $$(foreach var, $$(all_confs), $$(info * $$(var))) + $$(info Please retry building with CONF= (or SPEC=).) + $$(info ) + $$(error Cannot continue) + endif + + # We found exactly one configuration, use it + SPECS := $$(strip $$(all_spec_files)) + endif + endif + endef + + # Extract main targets from Main.gmk using the spec provided in $2. + # + # Param 1: FORCE = force generation of main-targets.gmk or LAZY = do not force. + # Param 2: The SPEC file to use. + define DefineMainTargets + + # We will start by making sure the main-targets.gmk file is removed, if + # make has not been restarted. By the -include, we will trigger the + # rule for generating the file (which is never there since we removed it), + # thus generating it fresh, and make will restart, incrementing the restart + # count. + main_targets_file := $$(dir $(strip $2))make-support/main-targets.gmk + + ifeq ($$(MAKE_RESTARTS),) + # Only do this if make has not been restarted, and if we do not force it. + ifeq ($(strip $1), FORCE) + $$(shell rm -f $$(main_targets_file)) + endif + endif + + $$(main_targets_file): + @( cd $$(topdir) && \ + $$(MAKE) $$(MAKE_LOG_FLAGS) -r -R -f $$(topdir)/make/Main.gmk \ + -I $$(topdir)/make/common SPEC=$(strip $2) NO_RECIPES=true \ + LOG_LEVEL=$$(LOG_LEVEL) \ + create-main-targets-include ) + + # Now include main-targets.gmk. This will define ALL_MAIN_TARGETS. + -include $$(main_targets_file) + endef + + define PrintConfCheckFailed + @echo ' ' + @echo "Please rerun configure! Easiest way to do this is by running" + @echo "'make reconfigure'." + @echo "This behavior may also be changed using CONF_CHECK=." + @echo ' ' + endef + +else # $(HAS_SPEC)=true + ############################################################################## + # Helper functions for the 'main' target. These functions assume a single, + # proper and existing SPEC is included. + ############################################################################## + + include $(SRC_ROOT)/make/common/MakeBase.gmk + + # Define basic logging setup + BUILD_LOG := $(OUTPUT_ROOT)/build.log + BUILD_TRACE_LOG := $(OUTPUT_ROOT)/build-trace-time.log + + BUILD_LOG_WRAPPER := $(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG) + + # Disable the build log wrapper on sjavac+windows until + # we have solved how to prevent the log wrapper to wait + # for the background sjavac server process. + ifeq ($(ENABLE_SJAVAC)X$(OPENJDK_BUILD_OS),yesXwindows) + LOG_NOFILE := true + endif + + # Sanity check the spec file, so it matches this source code + define CheckSpecSanity + ifneq ($$(ACTUAL_TOPDIR), $$(TOPDIR)) + ifneq ($$(ACTUAL_TOPDIR), $$(ORIGINAL_TOPDIR)) + ifneq ($$(ACTUAL_TOPDIR), $$(CANONICAL_TOPDIR)) + $$(info Error: SPEC mismatch! Current working directory) + $$(info $$(ACTUAL_TOPDIR)) + $$(info does not match either TOPDIR, ORIGINAL_TOPDIR or CANONICAL_TOPDIR) + $$(info $$(TOPDIR)) + $$(info $$(ORIGINAL_TOPDIR)) + $$(info $$(CANONICAL_TOPDIR)) + $$(error Cannot continue) + endif + endif + endif + endef + + define RotateLogFiles + $(RM) $(BUILD_LOG).old 2> /dev/null + $(MV) $(BUILD_LOG) $(BUILD_LOG).old 2> /dev/null || true + $(if $(findstring trace, $(LOG_LEVEL)), \ + $(RM) $(BUILD_TRACE_LOG).old 2> /dev/null && \ + $(MV) $(BUILD_TRACE_LOG) $(BUILD_TRACE_LOG).old 2> /dev/null || true \ + ) + endef + + # Remove any javac server logs and port files. This + # prevents a new make run to reuse the previous servers. + define PrepareSmartJavac + $(if $(SJAVAC_SERVER_DIR), \ + $(RM) -r $(SJAVAC_SERVER_DIR) 2> /dev/null && \ + $(MKDIR) -p $(SJAVAC_SERVER_DIR) \ + ) + endef + + define CleanupSmartJavac + [ -f $(SJAVAC_SERVER_DIR)/server.port ] && $(ECHO) Stopping sjavac server && \ + $(TOUCH) $(SJAVAC_SERVER_DIR)/server.port.stop; true + endef + + define StartGlobalTimer + $(RM) -r $(BUILDTIMESDIR) 2> /dev/null + $(MKDIR) -p $(BUILDTIMESDIR) + $(call RecordStartTime,TOTAL) + endef + + define StopGlobalTimer + $(call RecordEndTime,TOTAL) + endef + + # Find all build_time_* files and print their contents in a list sorted + # on the name of the sub repository. + define ReportBuildTimes + $(BUILD_LOG_WRAPPER) $(PRINTF) $(LOG_INFO) -- \ + "----- Build times -------\nStart %s\nEnd %s\n%s\n%s\n-------------------------\n" \ + "`$(CAT) $(BUILDTIMESDIR)/build_time_start_TOTAL_human_readable`" \ + "`$(CAT) $(BUILDTIMESDIR)/build_time_end_TOTAL_human_readable`" \ + "`$(LS) $(BUILDTIMESDIR)/build_time_diff_* | $(GREP) -v _TOTAL | \ + $(XARGS) $(CAT) | $(SORT) -k 2`" \ + "`$(CAT) $(BUILDTIMESDIR)/build_time_diff_TOTAL`" + endef + +endif # HAS_SPEC + +endif # _INITSUPPORT_GMK diff --git a/make/Jprt.gmk b/make/Jprt.gmk index f3f8726c23f..57a7c67b1ca 100644 --- a/make/Jprt.gmk +++ b/make/Jprt.gmk @@ -130,7 +130,4 @@ final-images: all endif @$(call TargetExit) - -########################################################################### -# Phony targets -.PHONY: jprt_bundle bundles final-images +ALL_TARGETS += jprt_bundle bundles final-images diff --git a/make/Main.gmk b/make/Main.gmk index 5a4e0d5c23a..221a0ca37bc 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -26,14 +26,19 @@ ################################################################################ # This is the main makefile containing most actual top level targets. It needs # to be called with a SPEC file defined. +################################################################################ # Declare default target default: +ifeq ($(wildcard $(SPEC)),) + $(error Main.gmk needs SPEC set to a proper spec.gmk) +endif + # Now load the spec include $(SPEC) -include $(SRC_ROOT)/make/MakeHelpers.gmk +include $(SRC_ROOT)/make/MainSupport.gmk # Load the vital tools for all the makefiles. include $(SRC_ROOT)/make/common/MakeBase.gmk @@ -215,7 +220,8 @@ $(SUPPORT_OUTPUTDIR)/source_tips: FRC BOOTCYCLE_TARGET := product-images bootcycle-images: @$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image - +$(MAKE) $(MAKE_ARGS) -f Main.gmk SPEC=$(dir $(SPEC))bootcycle-spec.gmk $(BOOTCYCLE_TARGET) + +$(MAKE) $(MAKE_ARGS) -f $(SRC_ROOT)/make/Main.gmk \ + SPEC=$(dir $(SPEC))bootcycle-spec.gmk $(BOOTCYCLE_TARGET) zip-security: +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSecurity.gmk) @@ -535,7 +541,7 @@ CLEAN_DIRS += hotspot jdk bootcycle-build test buildtools support \ CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS)) CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS)) -CLEAN_PHASES := gensrc java native include +CLEAN_PHASES := gensrc java native include docs CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES)) CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES)) # Construct targets of the form clean-$module-$phase @@ -544,7 +550,7 @@ CLEAN_MODULE_PHASE_TARGETS := $(addprefix clean-, $(foreach m, $(ALL_MODULES), \ # Remove everything, except the output from configure. clean: $(CLEAN_DIR_TARGETS) - ($(CD) $(OUTPUT_ROOT) && $(RM) -r source_tips build.log* build-trace*.log*) + ($(CD) $(OUTPUT_ROOT) && $(RM) -r build*.log*) $(ECHO) Cleaned all build artifacts. $(CLEAN_DIR_TARGETS): @@ -568,13 +574,11 @@ $(CLEAN_MODULE_PHASE_TARGETS): # while classes and touch files end up in jdk. clean-support: clean-jdk -clean-docs: clean-docstemp - -# Remove everything, including configure configuration. -# If the output directory was created by configure and now becomes empty, remove it as well. +# Remove everything, including configure configuration. If the output +# directory was created by configure and now becomes empty, remove it as well. dist-clean: clean - ($(CD) $(OUTPUT_ROOT) && $(RM) -r *spec.gmk config.* configure-arguments \ - Makefile compare.sh tmp javacservers) + ($(CD) $(OUTPUT_ROOT) && \ + $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide) $(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \ if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \ $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \ @@ -588,43 +592,35 @@ dist-clean: clean ALL_TARGETS += clean dist-clean $(CLEAN_DIR_TARGETS) $(CLEAN_TEST_TARGETS) \ $(CLEAN_PHASE_TARGETS) $(CLEAN_MODULE_TARGETS) $(CLEAN_MODULE_PHASE_TARGETS) -################################################################################ - -# Setup a rule for SPEC file that fails if executed. This check makes sure the -# configuration is up to date after changes to configure. -ifeq ($(findstring reconfigure, $(MAKECMDGOALS)), ) - $(SPEC): $(wildcard $(SRC_ROOT)/common/autoconf/*) - @$(ECHO) "ERROR: $(SPEC) is not up to date." - @$(ECHO) "Please rerun configure! Easiest way to do this is by running" - @$(ECHO) "'make reconfigure'." - @$(ECHO) "It may also be ignored by setting IGNORE_OLD_CONFIG=true" - @if test "x$(IGNORE_OLD_CONFIG)" != "xtrue"; then exit 1; fi -endif - -# The reconfigure target is automatically run serially from everything else -# by the Makefile calling this file. - -reconfigure: - ifneq ($(CONFIGURE_COMMAND_LINE), ) - @$(ECHO) "Re-running configure using arguments '$(CONFIGURE_COMMAND_LINE)'" - else - @$(ECHO) "Re-running configure using default settings" - endif - @( cd $(OUTPUT_ROOT) && PATH="$(ORIGINAL_PATH)" \ - $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) ) - -ALL_TARGETS += reconfigure - ################################################################################ # Declare *-only targets for each normal target $(foreach t, $(ALL_TARGETS), $(eval $(t)-only: $(t))) -ALL_TARGETS += $(addsuffix -only, $(filter-out clean%, $(ALL_TARGETS))) +ALL_TARGETS += $(addsuffix -only, $(filter-out dist-clean clean%, $(ALL_TARGETS))) + +################################################################################ + +# Include JPRT targets +include $(SRC_ROOT)/make/Jprt.gmk + +################################################################################ + +# The following targets are intentionally not added to ALL_TARGETS since they +# are internal only, to support Init.gmk. + +print-targets: + @$(ECHO) $(sort $(ALL_TARGETS)) + +print-modules: + @$(ECHO) $(sort $(ALL_MODULES)) + +create-main-targets-include: + @$(ECHO) $(LOG_INFO) Generating main target list + @$(ECHO) ALL_MAIN_TARGETS := $(sort $(ALL_TARGETS)) > \ + $(MAKESUPPORT_OUTPUTDIR)/main-targets.gmk ################################################################################ .PHONY: $(ALL_TARGETS) -include $(SRC_ROOT)/make/Jprt.gmk - FRC: # Force target diff --git a/make/MainSupport.gmk b/make/MainSupport.gmk new file mode 100644 index 00000000000..bbd7b817df8 --- /dev/null +++ b/make/MainSupport.gmk @@ -0,0 +1,200 @@ +# +# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# This file contains helper functions for Main.gmk. +################################################################################ + +ifndef _MAINSUPPORT_GMK +_MAINSUPPORT_GMK := 1 + +# Run the tests specified by $1. +define RunTests + ($(CD) $(SRC_ROOT)/test && $(MAKE) $(MAKE_ARGS) -j1 -k MAKEFLAGS= \ + JT_HOME=$(JT_HOME) PRODUCT_HOME=$(JDK_IMAGE_DIR) \ + TEST_IMAGE_DIR=$(TEST_IMAGE_DIR) \ + ALT_OUTPUTDIR=$(OUTPUT_ROOT) CONCURRENCY=$(JOBS) $1) || true +endef + +# Cleans the dir given as $1 +define CleanDir + @$(PRINTF) "Cleaning $(strip $1) build artifacts ..." + @$(PRINTF) "\n" $(LOG_DEBUG) + ($(CD) $(OUTPUT_ROOT) && $(RM) -r $1) + @$(PRINTF) " done\n" +endef + +define CleanTest + @$(PRINTF) "Cleaning test $(strip $1) ..." + @$(PRINTF) "\n" $(LOG_DEBUG) + $(RM) -r $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1)) + @$(PRINTF) " done\n" +endef + +define Clean-gensrc + @$(PRINTF) "Cleaning gensrc $(if $1,for $(strip $1) )..." + @$(PRINTF) "\n" $(LOG_DEBUG) + $(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1) + $(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc_no_docs/$(strip $1) + @$(PRINTF) " done\n" +endef + +define Clean-java + @$(PRINTF) "Cleaning java $(if $1,for $(strip $1) )..." + @$(PRINTF) "\n" $(LOG_DEBUG) + $(RM) -r $(JDK_OUTPUTDIR)/modules/$(strip $1) + $(RM) -r $(SUPPORT_OUTPUTDIR)/misc/$(strip $1) + $(PRINTF) " done\n" + $(PRINTF) "Cleaning headers $(if $1,for $(strip $1)) ..." + $(RM) -r $(SUPPORT_OUTPUTDIR)/headers/$(strip $1) + @$(PRINTF) " done\n" +endef + +define Clean-native + @$(PRINTF) "Cleaning native $(if $1,for $(strip $1) )..." + @$(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 + +define Clean-include + @$(PRINTF) "Cleaning include $(if $1,for $(strip $1) )..." + @$(PRINTF) "\n" $(LOG_DEBUG) + $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_include/$(strip $1) + @$(PRINTF) " done\n" +endef + +define Clean-docs + @$(PRINTF) "Cleaning docs ..." + @$(PRINTF) "\n" $(LOG_DEBUG) + $(RM) -r $(SUPPORT_OUTPUTDIR)/docs + $(RM) -r $(IMAGES_OUTPUTDIR)/docs + @$(PRINTF) " done\n" +endef + +define CleanModule + $(call Clean-gensrc, $1) + $(call Clean-java, $1) + $(call Clean-native, $1) + $(call Clean-include, $1) +endef + + +################################################################################ + +MAKE_TOPDIR_LIST := $(JDK_TOPDIR) $(CORBA_TOPDIR) $(LANGTOOLS_TOPDIR) +MAKE_MAKEDIR_LIST := make + +# Helper macro for DeclareRecipesForPhase +# Declare a recipe for calling the module and phase specific makefile. +# If there are multiple makefiles to call, create a rule for each topdir +# that contains a makefile with the target $module-$suffix-$repodir, +# (i.e: java.base-gensrc-jdk) +# Normally there is only one makefile, and the target will just be +# $module-$suffix +# Param 1: Name of list to add targets to +# Param 2: Module name +# Param 3: Topdir +define DeclareRecipeForModuleMakefile + ifeq ($$($1_MULTIPLE_MAKEFILES), true) + $2-$$($1_TARGET_SUFFIX): $2-$$($1_TARGET_SUFFIX)-$$(notdir $3) + $1 += $2-$$($1_TARGET_SUFFIX)-$$(notdir $3) + + $2-$$($1_TARGET_SUFFIX)-$$(notdir $3): + else + $2-$$($1_TARGET_SUFFIX): + endif + $(ECHO) $(LOG_INFO) "Building $$@" + ifeq ($$($1_USE_WRAPPER), true) + +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \ + -f ModuleWrapper.gmk \ + $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ + $$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ + MODULE=$2 MAKEFILE_PREFIX=$$($1_FILE_PREFIX)) + else + +($(CD) $$(dir $$(firstword $$(wildcard $$(patsubst %, \ + $3/%/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, $(MAKE_MAKEDIR_LIST))))) \ + && $(MAKE) $(MAKE_ARGS) \ + -f $$($1_FILE_PREFIX)-$2.gmk \ + $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ + $$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ + MODULE=$2) + endif + +endef + +# Helper macro for DeclareRecipesForPhase +# Param 1: Name of list to add targets to +# Param 2: Module name +define DeclareRecipesForPhaseAndModule + $1_$2_TOPDIRS := $$(strip $$(sort $$(foreach d, $(MAKE_TOPDIR_LIST), \ + $$(patsubst $$d/%, $$d, $$(filter $$d/%, \ + $$(wildcard $$(patsubst %, %/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, \ + $$(foreach s, $(MAKE_MAKEDIR_LIST), \ + $$(addsuffix /$$s, $(MAKE_TOPDIR_LIST)))))))))) + + # Only declare recipes if there are makefiles to call + ifneq ($$($1_$2_TOPDIRS), ) + ifeq ($(NO_RECIPES),) + $$(foreach d, $$($1_$2_TOPDIRS), \ + $$(eval $$(call DeclareRecipeForModuleMakefile,$1,$2,$$d))) + endif + $1 += $2-$$($1_TARGET_SUFFIX) + $1_MODULES += $2 + endif +endef + +# Declare recipes for a specific module and build phase if there are makefiles +# present for the specific combination. +# Param 1: Name of list to add targets to +# Named params: +# TARGET_SUFFIX : Suffix of target to create for recipe +# MAKE_SUBDIR : Subdir for this build phase +# FILE_PREFIX : File prefix for this build phase +# USE_WRAPPER : Set to true to use ModuleWrapper.gmk +# CHECK_MODULES : List of modules to try +# MULTIPLE_MAKEFILES : Set to true to handle makefils for the same module in +# phase in multiple repos +# Exported variables: +# $1_MODULES : All modules that had rules generated +# $1_TARGETS : All targets generated +define DeclareRecipesForPhase + $(foreach i,2 3 4 5 6 7, $(if $($i),$(strip $1)_$(strip $($i)))$(NEWLINE)) + $(if $(8),$(error Internal makefile error: Too many arguments to \ + DeclareRecipesForPhase, please update MakeHelper.gmk)) + + $$(foreach m, $$($(strip $1)_CHECK_MODULES), \ + $$(eval $$(call DeclareRecipesForPhaseAndModule,$(strip $1),$$m))) + + $(strip $1)_TARGETS := $$($(strip $1)) +endef + +################################################################################ + +endif # _MAINSUPPORT_GMK diff --git a/make/MakeHelpers.gmk b/make/MakeHelpers.gmk deleted file mode 100644 index 2de3b9cb03c..00000000000 --- a/make/MakeHelpers.gmk +++ /dev/null @@ -1,451 +0,0 @@ -# -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -################################################################ -# -# This file contains helper functions for the top-level Makefile that does -# not depend on the spec.gmk file having been read. (The purpose of this -# file is ju to avoid cluttering the top-level Makefile.) -# -################################################################ - -ifndef _MAKEHELPERS_GMK -_MAKEHELPERS_GMK := 1 - -############################## -# Stuff to run at include time -############################## - -# Find out which variables were passed explicitely on the make command line. These -# will be passed on to sub-makes, overriding spec.gmk settings. -MAKE_ARGS=$(foreach var,$(subst =command,,$(filter %=command,$(foreach var,$(.VARIABLES),$(var)=$(firstword $(origin $(var)))))),$(var)="$($(var))") - -list_alt_overrides_with_origins=$(filter ALT_%=environment ALT_%=command,$(foreach var,$(.VARIABLES),$(var)=$(firstword $(origin $(var))))) -list_alt_overrides=$(subst =command,,$(subst =environment,,$(list_alt_overrides_with_origins))) - -# Store the build times in this directory. -BUILDTIMESDIR=$(OUTPUT_ROOT)/make-support/build-times - -# Global targets are possible to run either with or without a SPEC. The prototypical -# global target is "help". -global_targets=help - -############################## -# Functions -############################## - -define CheckEnvironment - # Find all environment or command line variables that begin with ALT. - $(if $(list_alt_overrides), - @$(PRINTF) "\nWARNING: You have the following ALT_ variables set:\n" - @$(PRINTF) "$(foreach var,$(list_alt_overrides),$(var)=$$$(var))\n" - @$(PRINTF) "ALT_ variables are deprecated and will be ignored. Please clean your environment.\n\n" - ) -endef - -### Functions for timers - -# Record starting time for build of a sub repository. -define RecordStartTime - $(MKDIR) -p $(BUILDTIMESDIR) - $(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$1 - $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$1_human_readable -endef - -# Record ending time and calculate the difference and store it in a -# easy to read format. Handles builds that cross midnight. Expects -# that a build will never take 24 hours or more. -define RecordEndTime - $(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$1 - $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$1_human_readable - $(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$1` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$1` $1 | \ - $(NAWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \ - M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \ - > $(BUILDTIMESDIR)/build_time_diff_$1 -endef - -# Find all build_time_* files and print their contents in a list sorted -# on the name of the sub repository. -define ReportBuildTimes - $(BUILD_LOG_WRAPPER) $(PRINTF) -- "----- Build times -------\nStart %s\nEnd %s\n%s\n%s\n-------------------------\n" \ - "`$(CAT) $(BUILDTIMESDIR)/build_time_start_TOTAL_human_readable`" \ - "`$(CAT) $(BUILDTIMESDIR)/build_time_end_TOTAL_human_readable`" \ - "`$(LS) $(BUILDTIMESDIR)/build_time_diff_* | $(GREP) -v _TOTAL | $(XARGS) $(CAT) | $(SORT) -k 2`" \ - "`$(CAT) $(BUILDTIMESDIR)/build_time_diff_TOTAL`" -endef - -define ResetAllTimers - $$(shell $(MKDIR) -p $(BUILDTIMESDIR) && $(RM) $(BUILDTIMESDIR)/build_time_*) -endef - -define StartGlobalTimer - $(call RecordStartTime,TOTAL) -endef - -define StopGlobalTimer - $(call RecordEndTime,TOTAL) -endef - -### Functions for managing makefile structure (start/end of makefile and individual targets) - -# Do not indent this function, this will add whitespace at the start which the caller won't handle -define GetRealTarget -$(strip $(if $(findstring main-wrapper, $(MAKECMDGOALS)), $(MAIN_TARGETS), \ - $(if $(MAKECMDGOALS),$(MAKECMDGOALS),default))) -endef - -# Do not indent this function, this will add whitespace at the start which the caller won't handle -define LastGoal -$(strip $(lastword $(call GetRealTarget))) -endef - -# Check if the current target is the final target, as specified by -# the user on the command line. If so, call AtRootMakeEnd. -define CheckIfMakeAtEnd - # Check if the current target is the last goal - $(if $(filter $@,$(call LastGoal)),$(call AtMakeEnd)) - # If the target is 'foo-only', check if our goal was stated as 'foo' - $(if $(filter $@,$(call LastGoal)-only),$(call AtMakeEnd)) -endef - -# Hook to be called when starting to execute a top-level target -define TargetEnter - $(PRINTF) "## Starting $(patsubst %-only,%,$@)\n" - $(call RecordStartTime,$(patsubst %-only,%,$@)) -endef - -# Hook to be called when finish executing a top-level target -define TargetExit - $(call RecordEndTime,$(patsubst %-only,%,$@)) - $(PRINTF) "## Finished $(patsubst %-only,%,$@) (build time %s)\n\n" \ - "`$(CAT) $(BUILDTIMESDIR)/build_time_diff_$(patsubst %-only,%,$@) | $(CUT) -f 1 -d ' '`" -endef - -# Hook to be called as the very first thing when running a normal build -define AtMakeStart - $(if $(findstring --jobserver,$(MAKEFLAGS)),$(error make -j is not supported, use make JOBS=n)) - $(call CheckEnvironment) - $(BUILD_LOG_WRAPPER) $(PRINTF) $(LOG_INFO) "Running make as '$(MAKE) $(MFLAGS) $(MAKE_ARGS)'\n" - $(BUILD_LOG_WRAPPER) $(PRINTF) "Building $(PRODUCT_NAME) for target '$(call GetRealTarget)' in configuration '$(CONF_NAME)'\n\n" - $(call StartGlobalTimer) -endef - -# Hook to be called as the very last thing for targets that are "top level" targets -define AtMakeEnd - [ -f $(SJAVAC_SERVER_DIR)/server.port ] && echo Stopping sjavac server && $(TOUCH) $(SJAVAC_SERVER_DIR)/server.port.stop; true - $(call StopGlobalTimer) - $(call ReportBuildTimes) - @$(PRINTF) "\nFinished building $(PRODUCT_NAME) for target '$(call GetRealTarget)'\n" - $(call CheckEnvironment) -endef - -### Functions for parsing and setting up make options from command-line - -define FatalError - # If the user specificed a "global" target (e.g. 'help'), do not exit but continue running - $$(if $$(filter-out $(global_targets),$$(call GetRealTarget)),$$(error Cannot continue)) -endef - -define ParseLogLevel - ifeq ($$(origin VERBOSE),undefined) - # Setup logging according to LOG (but only if VERBOSE is not given) - - # If the "nofile" argument is given, act on it and strip it away - ifneq ($$(findstring nofile,$$(LOG)),) - # Reset the build log wrapper, regardless of other values - override BUILD_LOG_WRAPPER= - # COMMA is defined in spec.gmk, but that is not included yet - COMMA=, - # First try to remove ",nofile" if it exists - LOG_STRIPPED1=$$(subst $$(COMMA)nofile,,$$(LOG)) - # Otherwise just remove "nofile" - LOG_STRIPPED2=$$(subst nofile,,$$(LOG_STRIPPED1)) - # We might have ended up with a leading comma. Remove it - LOG_STRIPPED3=$$(strip $$(patsubst $$(COMMA)%,%,$$(LOG_STRIPPED2))) - LOG_LEVEL:=$$(LOG_STRIPPED3) - else - LOG_LEVEL:=$$(LOG) - endif - - ifeq ($$(LOG_LEVEL),) - # Set LOG to "warn" as default if not set (and no VERBOSE given) - override LOG_LEVEL=warn - endif - ifeq ($$(LOG_LEVEL),warn) - VERBOSE=-s - else ifeq ($$(LOG_LEVEL),info) - VERBOSE=-s - else ifeq ($$(LOG_LEVEL),debug) - VERBOSE= - else ifeq ($$(LOG_LEVEL),trace) - VERBOSE= - else - $$(info Error: LOG must be one of: warn, info, debug or trace.) - $$(eval $$(call FatalError)) - endif - else - # Provide resonable interpretations of LOG_LEVEL if VERBOSE is given. - ifeq ($(VERBOSE),) - LOG_LEVEL:=debug - else - LOG_LEVEL:=warn - endif - ifneq ($$(LOG),) - # We have both a VERBOSE and a LOG argument. This is OK only if this is a repeated call by ourselves, - # but complain if this is the top-level make call. - ifeq ($$(MAKELEVEL),0) - $$(info Cannot use LOG=$$(LOG) and VERBOSE=$$(VERBOSE) at the same time. Choose one.) - $$(eval $$(call FatalError)) - endif - endif - endif -endef - -define ParseConfAndSpec - ifneq ($$(filter-out $(global_targets),$$(call GetRealTarget)),) - # If we only have global targets, no need to bother with SPEC or CONF - ifneq ($$(origin SPEC),undefined) - # We have been given a SPEC, check that it works out properly - ifneq ($$(origin CONF),undefined) - # We also have a CONF argument. This is OK only if this is a repeated call by ourselves, - # but complain if this is the top-level make call. - ifeq ($$(MAKELEVEL),0) - $$(info Error: Cannot use CONF=$$(CONF) and SPEC=$$(SPEC) at the same time. Choose one.) - $$(eval $$(call FatalError)) - endif - endif - ifeq ($$(wildcard $$(SPEC)),) - $$(info Error: Cannot locate spec.gmk, given by SPEC=$$(SPEC).) - $$(eval $$(call FatalError)) - endif - # ... OK, we're satisfied, we'll use this SPEC later on - else - # Find all spec.gmk files in the build output directory - output_dir=$$(root_dir)/build - all_spec_files=$$(wildcard $$(output_dir)/*/spec.gmk) - ifeq ($$(all_spec_files),) - $$(info Error: No configurations found for $$(root_dir).) - $$(info Please run 'bash configure' to create a configuration.) - $$(eval $$(call FatalError)) - endif - # Extract the configuration names from the path - all_confs=$$(patsubst %/spec.gmk,%,$$(patsubst $$(output_dir)/%,%,$$(all_spec_files))) - - ifneq ($$(origin CONF),undefined) - # User have given a CONF= argument. - ifeq ($$(CONF),) - # If given CONF=, match all configurations - matching_confs=$$(strip $$(all_confs)) - else - # Otherwise select those that contain the given CONF string - matching_confs=$$(strip $$(foreach var,$$(all_confs),$$(if $$(findstring $$(CONF),$$(var)),$$(var)))) - endif - ifeq ($$(matching_confs),) - $$(info Error: No configurations found matching CONF=$$(CONF).) - $$(info Available configurations in $$(output_dir):) - $$(foreach var,$$(all_confs),$$(info * $$(var))) - $$(eval $$(call FatalError)) - else - ifeq ($$(words $$(matching_confs)),1) - $$(info Building '$$(matching_confs)' (matching CONF=$$(CONF))) - else - $$(info Building target '$(call GetRealTarget)' in these configurations (matching CONF=$$(CONF)):) - $$(foreach var,$$(matching_confs),$$(info * $$(var))) - endif - endif - - # Create a SPEC definition. This will contain the path to one or more spec.gmk files. - SPEC=$$(addsuffix /spec.gmk,$$(addprefix $$(output_dir)/,$$(matching_confs))) - else - # No CONF or SPEC given, check the available configurations - ifneq ($$(words $$(all_spec_files)),1) - $$(info Error: No CONF given, but more than one configuration found.) - $$(info Available configurations in $$(output_dir):) - $$(foreach var,$$(all_confs),$$(info * $$(var))) - $$(info Please retry building with CONF= (or SPEC=).) - $$(eval $$(call FatalError)) - endif - - # We found exactly one configuration, use it - SPEC=$$(strip $$(all_spec_files)) - endif - endif - endif -endef - -### Convenience functions from Main.gmk - -# Run the tests specified by $1. -define RunTests - ($(CD) $(SRC_ROOT)/test && $(MAKE) $(MAKE_ARGS) -j1 -k MAKEFLAGS= \ - JT_HOME=$(JT_HOME) PRODUCT_HOME=$(JDK_IMAGE_DIR) \ - TEST_IMAGE_DIR=$(TEST_IMAGE_DIR) \ - ALT_OUTPUTDIR=$(OUTPUT_ROOT) CONCURRENCY=$(JOBS) $1) || true -endef - -# Cleans the dir given as $1 -define CleanDir - @$(PRINTF) "Cleaning $(strip $1) build artifacts ..." - @($(CD) $(OUTPUT_ROOT) && $(RM) -r $1) - @$(PRINTF) " done\n" -endef - -define CleanTest - @$(PRINTF) "Cleaning test $(strip $1) ..." - @$(RM) -r $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1)) - @$(PRINTF) " done\n" -endef - -define Clean-gensrc - @$(PRINTF) "Cleaning gensrc $(if $1,for $(strip $1) )..." - @$(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1) - @$(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc_no_docs/$(strip $1) - @$(PRINTF) " done\n" -endef - -define Clean-java - @$(PRINTF) "Cleaning java $(if $1,for $(strip $1) )..." - @$(RM) -r $(JDK_OUTPUTDIR)/modules/$(strip $1) - @$(RM) -r $(SUPPORT_OUTPUTDIR)/misc/$(strip $1) - @$(PRINTF) " done\n" - @$(PRINTF) "Cleaning headers $(if $1,for $(strip $1)) ..." - @$(RM) -r $(SUPPORT_OUTPUTDIR)/headers/$(strip $1) - @$(PRINTF) " done\n" -endef - -define Clean-native - @$(PRINTF) "Cleaning native $(if $1,for $(strip $1) )..." - @$(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 - -define Clean-include - @$(PRINTF) "Cleaning include $(if $1,for $(strip $1) )..." - @$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_include/$(strip $1) - @$(PRINTF) " done\n" -endef - -define CleanModule - $(call Clean-gensrc, $1) - $(call Clean-java, $1) - $(call Clean-native, $1) - $(call Clean-include, $1) -endef - - -################################################################################ - -MAKE_TOPDIR_LIST := $(JDK_TOPDIR) $(CORBA_TOPDIR) $(LANGTOOLS_TOPDIR) -MAKE_MAKEDIR_LIST := make - -# Helper macro for DeclareRecipesForPhase -# Declare a recipe for calling the module and phase specific makefile. -# If there are multiple makefiles to call, create a rule for each topdir -# that contains a makefile with the target $module-$suffix-$repodir, -# (i.e: java.base-gensrc-jdk) -# Normally there is only one makefile, and the target will just be -# $module-$suffix -# Param 1: Name of list to add targets to -# Param 2: Module name -# Param 3: Topdir -define DeclareRecipeForModuleMakefile - ifeq ($$($1_MULTIPLE_MAKEFILES), true) - $2-$$($1_TARGET_SUFFIX): $2-$$($1_TARGET_SUFFIX)-$$(notdir $3) - $1 += $2-$$($1_TARGET_SUFFIX)-$$(notdir $3) - - $2-$$($1_TARGET_SUFFIX)-$$(notdir $3): - else - $2-$$($1_TARGET_SUFFIX): - endif - $(ECHO) $(LOG_INFO) "Building $$@" - ifeq ($$($1_USE_WRAPPER), true) - +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \ - -f ModuleWrapper.gmk \ - $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ - $$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ - MODULE=$2 MAKEFILE_PREFIX=$$($1_FILE_PREFIX)) - else - +($(CD) $$(dir $$(firstword $$(wildcard $$(patsubst %, \ - $3/%/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, $(MAKE_MAKEDIR_LIST))))) \ - && $(MAKE) $(MAKE_ARGS) \ - -f $$($1_FILE_PREFIX)-$2.gmk \ - $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ - $$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ - MODULE=$2) - endif - -endef - -# Helper macro for DeclareRecipesForPhase -# Param 1: Name of list to add targets to -# Param 2: Module name -define DeclareRecipesForPhaseAndModule - $1_$2_TOPDIRS := $$(strip $$(sort $$(foreach d, $(MAKE_TOPDIR_LIST), \ - $$(patsubst $$d/%, $$d, $$(filter $$d/%, \ - $$(wildcard $$(patsubst %, %/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, \ - $$(foreach s, $(MAKE_MAKEDIR_LIST), \ - $$(addsuffix /$$s, $(MAKE_TOPDIR_LIST)))))))))) - - # Only declare recipes if there are makefiles to call - ifneq ($$($1_$2_TOPDIRS), ) - $$(foreach d, $$($1_$2_TOPDIRS), \ - $$(eval $$(call DeclareRecipeForModuleMakefile,$1,$2,$$d))) - $1 += $2-$$($1_TARGET_SUFFIX) - $1_MODULES += $2 - endif -endef - -# Declare recipes for a specific module and build phase if there are makefiles -# present for the specific combination. -# Param 1: Name of list to add targets to -# Named params: -# TARGET_SUFFIX : Suffix of target to create for recipe -# MAKE_SUBDIR : Subdir for this build phase -# FILE_PREFIX : File prefix for this build phase -# USE_WRAPPER : Set to true to use ModuleWrapper.gmk -# CHECK_MODULES : List of modules to try -# MULTIPLE_MAKEFILES : Set to true to handle makefils for the same module in -# phase in multiple repos -# Exported variables: -# $1_MODULES : All modules that had rules generated -# $1_TARGETS : All targets generated -define DeclareRecipesForPhase - $(foreach i,2 3 4 5 6 7, $(if $($i),$(strip $1)_$(strip $($i)))$(NEWLINE)) - $(if $(8),$(error Internal makefile error: Too many arguments to \ - DeclareRecipesForPhase, please update MakeHelper.gmk)) - - $$(foreach m, $$($(strip $1)_CHECK_MODULES), \ - $$(eval $$(call DeclareRecipesForPhaseAndModule,$(strip $1),$$m))) - - $(strip $1)_TARGETS := $$($(strip $1)) -endef - -################################################################################ - -endif # _MAKEHELPERS_GMK diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index 8e789a89319..b144dd7426d 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -32,6 +32,53 @@ ifndef _MAKEBASE_GMK _MAKEBASE_GMK := 1 +ifeq ($(wildcard $(SPEC)),) + $(error MakeBase.gmk needs SPEC set to a proper spec.gmk) +endif + + +############################## +# Functions +############################## + + +### Functions for timers + +# Store the build times in this directory. +BUILDTIMESDIR=$(OUTPUT_ROOT)/make-support/build-times + +# Record starting time for build of a sub repository. +define RecordStartTime + $(MKDIR) -p $(BUILDTIMESDIR) + $(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$(strip $1) + $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable +endef + +# Record ending time and calculate the difference and store it in a +# easy to read format. Handles builds that cross midnight. Expects +# that a build will never take 24 hours or more. +define RecordEndTime + $(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$(strip $1) + $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)_human_readable + $(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$(strip $1)` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$(strip $1)` $1 | \ + $(NAWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \ + M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \ + > $(BUILDTIMESDIR)/build_time_diff_$(strip $1) +endef + +# Hook to be called when starting to execute a top-level target +define TargetEnter + $(PRINTF) "## Starting $(patsubst %-only,%,$@)\n" + $(call RecordStartTime,$(patsubst %-only,%,$@)) +endef + +# Hook to be called when finish executing a top-level target +define TargetExit + $(call RecordEndTime,$(patsubst %-only,%,$@)) + $(PRINTF) "## Finished $(patsubst %-only,%,$@) (build time %s)\n\n" \ + "`$(CAT) $(BUILDTIMESDIR)/build_time_diff_$(patsubst %-only,%,$@) | $(CUT) -f 1 -d ' '`" +endef + ################################################################################ # This macro translates $ into \$ to protect the $ from expansion in the shell. # To make this macro resilient against already escaped strings, first remove @@ -341,7 +388,7 @@ define CreateHgTip endef define SetupLogging - ifeq ($$(LOG_LEVEL),trace) + ifeq ($$(LOG_LEVEL), trace) # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make # For each target executed, will print # Building (from ) ( newer) @@ -349,25 +396,25 @@ define SetupLogging # (and causing a crash on Cygwin). # Default shell seems to always be /bin/sh. Must override with bash to get this to work on Solaris. # Only use time if it's GNU time which supports format and output file. - WRAPPER_SHELL:=$$(BASH) $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(findstring yes,$$(IS_GNU_TIME)),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log $$(SHELL) - SHELL=$$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(WRAPPER_SHELL) + WRAPPER_SHELL := $$(BASH) $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(findstring yes,$$(IS_GNU_TIME)),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log $$(SHELL) + SHELL := $$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(WRAPPER_SHELL) endif # Never remove warning messages; this is just for completeness - LOG_WARN= - ifneq ($$(findstring $$(LOG_LEVEL),info debug trace),) - LOG_INFO= + LOG_WARN := + ifneq ($$(findstring $$(LOG_LEVEL), info debug trace),) + LOG_INFO := else - LOG_INFO=> /dev/null + LOG_INFO := > /dev/null endif - ifneq ($$(findstring $$(LOG_LEVEL),debug trace),) - LOG_DEBUG= + ifneq ($$(findstring $$(LOG_LEVEL), debug trace),) + LOG_DEBUG := else - LOG_DEBUG=> /dev/null + LOG_DEBUG := > /dev/null endif - ifneq ($$(findstring $$(LOG_LEVEL),trace),) - LOG_TRACE= + ifneq ($$(findstring $$(LOG_LEVEL), trace),) + LOG_TRACE := else - LOG_TRACE=> /dev/null + LOG_TRACE := > /dev/null endif endef diff --git a/nashorn/.hgtags b/nashorn/.hgtags index 1fc98ef58fd..2b228db21f4 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -291,3 +291,5 @@ fada76c29db9c792ad7127e674ef5337e15d2225 jdk9-b52 b2b332e64b7b2e06e25bccae9c0c0b585a03b4b5 jdk9-b55 2e640036000dfadcadaf6638b5fd61db9c71a25c jdk9-b56 3bcfcb13c23402cf435079766eb2f9a3c4f890e8 jdk9-b57 +5096a7cca5f0fda814832ac777966bea893f837e jdk9-b58 +ea4e794c3927df4e03f53202e15a3248375b7902 jdk9-b59 diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java index 8eb19b7d112..115e4b19f4e 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java @@ -124,8 +124,6 @@ public class PrototypeGenerator extends ClassGenerator { if (memberCount > 0) { // call "super(map$)" mi.getStatic(className, PROPERTYMAP_FIELD_NAME, PROPERTYMAP_DESC); - // make sure we use duplicated PropertyMap so that original map - // stays intact and so can be used for many global. mi.invokeSpecial(PROTOTYPEOBJECT_TYPE, INIT, SCRIPTOBJECT_INIT_DESC); // initialize Function type fields initFunctionFields(mi); diff --git a/nashorn/docs/DEVELOPER_README b/nashorn/docs/DEVELOPER_README index 5550b903b1d..faff28c0bac 100644 --- a/nashorn/docs/DEVELOPER_README +++ b/nashorn/docs/DEVELOPER_README @@ -63,16 +63,19 @@ SYSTEM PROPERTY: -Dnashorn.codegen.debug.trace= See the description of the codegen logger below. -SYSTEM PROPERTY: -Dnashorn.fields.objects +SYSTEM PROPERTY: -Dnashorn.fields.objects, -Dnashorn.fields.dual -When this property is true, Nashorn will only use object fields for -AccessorProperties. This means that primitive values must be boxed -when stored in a field, which is significantly slower than using -primitive fields. +When the nashorn.fields.objects property is true, Nashorn will always +use object fields for AccessorProperties, requiring boxing for all +primitive property values. When nashorn.fields.dual is set, Nashorn +will always use dual long/object fields, which allows primitives to be +stored without boxing. When neither system property is set, Nashorn +chooses a setting depending on the optimistic types setting (dual +fields when optimistic types are enabled, object-only fields otherwise). -By default, Nashorn uses dual object and long fields. Ints are -represented as the 32 low bits of the long fields. Doubles are -represented as the doubleToLongBits of their value. This way a +With dual fields, Nashorn uses long fields to store primitive values. +Ints are represented as the 32 low bits of the long fields. Doubles +are represented as the doubleToLongBits of their value. This way a single field can be used for all primitive types. Packing and unpacking doubles to their bit representation is intrinsified by the JVM and extremely fast. diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index bd85a06aba9..df478ee1fb5 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -281,12 +281,12 @@ - - + + - - + + @@ -402,14 +402,14 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" { - - - - - - - - + + + + + + + + diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java index fd627a6f1fb..81daa4f228f 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -43,7 +43,6 @@ import static jdk.nashorn.internal.codegen.CompilerConstants.methodDescriptor; import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup; import static jdk.nashorn.internal.codegen.CompilerConstants.typeDescriptor; import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup; -import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY; import static jdk.nashorn.internal.ir.Symbol.HAS_SLOT; import static jdk.nashorn.internal.ir.Symbol.IS_INTERNAL; import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT; @@ -305,6 +304,14 @@ final class CodeGenerator extends NodeOperatorVisitor getValueType() { - if (OBJECT_FIELDS_ONLY || value == null || paramType == null) { + if (!useDualFields() || value == null || paramType == null || paramType.isBoolean()) { return Object.class; } - return paramType.isBoolean() ? Object.class : paramType.getTypeClass(); + return paramType.getTypeClass(); } }); } @@ -2555,7 +2562,7 @@ final class CodeGenerator extends NodeOperatorVisitor valueType = (OBJECT_FIELDS_ONLY || value == null || value.getType().isBoolean()) ? Object.class : value.getType().getTypeClass(); + final Class valueType = (!useDualFields() || value == null || value.getType().isBoolean()) ? Object.class : value.getType().getTypeClass(); tuples.add(new MapTuple(key, symbol, Type.typeFor(valueType), value) { @Override public Class getValueType() { diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CompilerConstants.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CompilerConstants.java index e84c9f0477d..a7f31d50406 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CompilerConstants.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CompilerConstants.java @@ -149,8 +149,11 @@ public enum CompilerConstants { /** Arguments parameter in scope object constructors; in slot 3 when present */ INIT_ARGUMENTS(null, 3), - /** prefix for all ScriptObject subclasses with fields, @see ObjectGenerator */ - JS_OBJECT_PREFIX("JO"), + /** prefix for all ScriptObject subclasses with dual object/primitive fields, see {@link ObjectClassGenerator} */ + JS_OBJECT_DUAL_FIELD_PREFIX("JD"), + + /** prefix for all ScriptObject subclasses with object fields only, see {@link ObjectClassGenerator} */ + JS_OBJECT_SINGLE_FIELD_PREFIX("JO"), /** name for allocate method in JO objects */ ALLOCATE("allocate"), diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java index 491af86f63f..25baea0ce28 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java @@ -151,7 +151,7 @@ public abstract class FieldObjectCreator extends ObjectCreator { @Override protected PropertyMap makeMap() { assert propertyMap == null : "property map already initialized"; - propertyMap = newMapCreator(fieldObjectClass).makeFieldMap(hasArguments(), fieldCount, paddedFieldCount, evalCode); + propertyMap = newMapCreator(fieldObjectClass).makeFieldMap(hasArguments(), codegen.useDualFields(), fieldCount, paddedFieldCount, evalCode); return propertyMap; } @@ -166,7 +166,7 @@ public abstract class FieldObjectCreator extends ObjectCreator { private void putField(final MethodEmitter method, final String key, final int fieldIndex, final MapTuple tuple) { method.dup(); - final Type fieldType = tuple.isPrimitive() ? PRIMITIVE_FIELD_TYPE : Type.OBJECT; + final Type fieldType = codegen.useDualFields() && tuple.isPrimitive() ? PRIMITIVE_FIELD_TYPE : Type.OBJECT; final String fieldClass = getClassName(); final String fieldName = getFieldName(fieldIndex, fieldType); final String fieldDesc = typeDescriptor(fieldType.getTypeClass()); @@ -202,8 +202,8 @@ public abstract class FieldObjectCreator extends ObjectCreator { */ private void findClass() { fieldObjectClassName = isScope() ? - ObjectClassGenerator.getClassName(fieldCount, paramCount) : - ObjectClassGenerator.getClassName(paddedFieldCount); + ObjectClassGenerator.getClassName(fieldCount, paramCount, codegen.useDualFields()) : + ObjectClassGenerator.getClassName(paddedFieldCount, codegen.useDualFields()); try { this.fieldObjectClass = Context.forStructureClass(Compiler.binaryName(fieldObjectClassName)); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FindScopeDepths.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FindScopeDepths.java index b45b9867116..9f9abf9c0c9 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FindScopeDepths.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FindScopeDepths.java @@ -207,7 +207,7 @@ final class FindScopeDepths extends NodeVisitor implements Logga final RecompilableScriptFunctionData data = new RecompilableScriptFunctionData( newFunctionNode, compiler.getCodeInstaller(), - ObjectClassGenerator.createAllocationStrategy(newFunctionNode.getThisProperties()), + ObjectClassGenerator.createAllocationStrategy(newFunctionNode.getThisProperties(), compiler.getContext().useDualFields()), nestedFunctions, externalSymbolDepths.get(fnId), internalSymbols.get(fnId), diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapCreator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapCreator.java index ae96dc46607..be99db99c7f 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapCreator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapCreator.java @@ -68,17 +68,17 @@ public class MapCreator { * @param evalCode is this property map created for 'eval' code? * @return New map populated with accessor properties. */ - PropertyMap makeFieldMap(final boolean hasArguments, final int fieldCount, final int fieldMaximum, final boolean evalCode) { + PropertyMap makeFieldMap(final boolean hasArguments, final boolean dualFields, final int fieldCount, final int fieldMaximum, final boolean evalCode) { final List properties = new ArrayList<>(); assert tuples != null; for (final MapTuple tuple : tuples) { final String key = tuple.key; final Symbol symbol = tuple.symbol; - final Class initialType = tuple.getValueType(); + final Class initialType = dualFields ? tuple.getValueType() : Object.class; if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) { - final int flags = getPropertyFlags(symbol, hasArguments, evalCode); + final int flags = getPropertyFlags(symbol, hasArguments, evalCode, dualFields); final Property property = new AccessorProperty( key, flags, @@ -92,7 +92,7 @@ public class MapCreator { return PropertyMap.newMap(properties, structure.getName(), fieldCount, fieldMaximum, 0); } - PropertyMap makeSpillMap(final boolean hasArguments) { + PropertyMap makeSpillMap(final boolean hasArguments, final boolean dualFields) { final List properties = new ArrayList<>(); int spillIndex = 0; assert tuples != null; @@ -100,10 +100,10 @@ public class MapCreator { for (final MapTuple tuple : tuples) { final String key = tuple.key; final Symbol symbol = tuple.symbol; - final Class initialType = tuple.getValueType(); + final Class initialType = dualFields ? tuple.getValueType() : Object.class; if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) { - final int flags = getPropertyFlags(symbol, hasArguments, false); + final int flags = getPropertyFlags(symbol, hasArguments, false, dualFields); properties.add( new SpillProperty( key, @@ -124,7 +124,7 @@ public class MapCreator { * * @return flags to use for fields */ - static int getPropertyFlags(final Symbol symbol, final boolean hasArguments, final boolean evalCode) { + static int getPropertyFlags(final Symbol symbol, final boolean hasArguments, final boolean evalCode, final boolean dualFields) { int flags = 0; if (symbol.isParam()) { @@ -162,6 +162,10 @@ public class MapCreator { flags |= Property.NEEDS_DECLARATION; } + if (dualFields) { + flags |= Property.DUAL_FIELDS; + } + return flags; } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapTuple.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapTuple.java index 024c3d6745e..44cdc8b2c88 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapTuple.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapTuple.java @@ -25,8 +25,6 @@ package jdk.nashorn.internal.codegen; -import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY; - import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.Symbol; @@ -52,11 +50,11 @@ class MapTuple { } public Class getValueType() { - return OBJECT_FIELDS_ONLY ? Object.class : null; //until proven otherwise we are undefined, see NASHORN-592 int.class; + return null; //until proven otherwise we are undefined, see NASHORN-592 int.class; } boolean isPrimitive() { - return !OBJECT_FIELDS_ONLY && getValueType().isPrimitive() && getValueType() != boolean.class; + return getValueType() != null && getValueType().isPrimitive() && getValueType() != boolean.class; } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectClassGenerator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectClassGenerator.java index 2205044c9e5..383d2f130d4 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectClassGenerator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectClassGenerator.java @@ -31,7 +31,8 @@ import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_ARGUMENTS; import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_MAP; import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_SCOPE; import static jdk.nashorn.internal.codegen.CompilerConstants.JAVA_THIS; -import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_PREFIX; +import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_DUAL_FIELD_PREFIX; +import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_SINGLE_FIELD_PREFIX; import static jdk.nashorn.internal.codegen.CompilerConstants.className; import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup; import static jdk.nashorn.internal.lookup.Lookup.MH; @@ -99,18 +100,10 @@ public final class ObjectClassGenerator implements Loggable { */ private final DebugLogger log; - /** - * Should the runtime only use java.lang.Object slots for fields? If this is false, the representation - * will be a primitive 64-bit long value used for all primitives and a java.lang.Object for references. - * This introduces a larger number of method handles in the system, as we need to have different getters - * and setters for the different fields. - * - * This is engineered to plug into the TaggedArray implementation, when it's done. - */ - public static final boolean OBJECT_FIELDS_ONLY = Options.getBooleanProperty("nashorn.fields.objects"); - - /** The field types in the system */ - private static final List FIELD_TYPES = new LinkedList<>(); + /** Field types for object-only fields */ + private static final Type[] FIELD_TYPES_OBJECT = new Type[] { Type.OBJECT }; + /** Field types for dual primitive/object fields */ + private static final Type[] FIELD_TYPES_DUAL = new Type[] { Type.LONG, Type.OBJECT }; /** What type is the primitive type in dual representation */ public static final Type PRIMITIVE_FIELD_TYPE = Type.LONG; @@ -118,33 +111,27 @@ public final class ObjectClassGenerator implements Loggable { private static final MethodHandle GET_DIFFERENT = findOwnMH("getDifferent", Object.class, Object.class, Class.class, MethodHandle.class, MethodHandle.class, int.class); private static final MethodHandle GET_DIFFERENT_UNDEFINED = findOwnMH("getDifferentUndefined", Object.class, int.class); - /** - * The list of field types that we support - one type creates one field. This is currently either - * LONG + OBJECT or just OBJECT for classic mode. - */ - static { - if (!OBJECT_FIELDS_ONLY) { - FIELD_TYPES.add(PRIMITIVE_FIELD_TYPE); - } - FIELD_TYPES.add(Type.OBJECT); - } private static boolean initialized = false; /** The context */ private final Context context; + private final boolean dualFields; + /** * Constructor * * @param context a context + * @param dualFields whether to use dual fields representation */ - public ObjectClassGenerator(final Context context) { + public ObjectClassGenerator(final Context context, final boolean dualFields) { this.context = context; + this.dualFields = dualFields; assert context != null; this.log = initLogger(context); if (!initialized) { initialized = true; - if (OBJECT_FIELDS_ONLY) { + if (!dualFields) { log.warning("Running with object fields only - this is a deprecated configuration."); } } @@ -176,16 +163,30 @@ public final class ObjectClassGenerator implements Loggable { throw new AssertionError("cannot pack" + n); } + private static String getPrefixName(final boolean dualFields) { + return dualFields ? JS_OBJECT_DUAL_FIELD_PREFIX.symbolName() : JS_OBJECT_SINGLE_FIELD_PREFIX.symbolName(); + } + + private static String getPrefixName(final String className) { + if (className.startsWith(JS_OBJECT_DUAL_FIELD_PREFIX.symbolName())) { + return getPrefixName(true); + } else if (className.startsWith(JS_OBJECT_SINGLE_FIELD_PREFIX.symbolName())) { + return getPrefixName(false); + } + throw new AssertionError("Not a structure class: " + className); + } + /** * Returns the class name for JavaScript objects with fieldCount fields. * * @param fieldCount Number of fields to allocate. - * + * @param dualFields whether to use dual fields representation * @return The class name. */ - public static String getClassName(final int fieldCount) { - return fieldCount != 0 ? SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.symbolName() + fieldCount : - SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.symbolName(); + public static String getClassName(final int fieldCount, final boolean dualFields) { + final String prefix = getPrefixName(dualFields); + return fieldCount != 0 ? SCRIPTS_PACKAGE + '/' + prefix + fieldCount : + SCRIPTS_PACKAGE + '/' + prefix; } /** @@ -194,22 +195,23 @@ public final class ObjectClassGenerator implements Loggable { * * @param fieldCount Number of fields to allocate. * @param paramCount Number of parameters to allocate - * + * @param dualFields whether to use dual fields representation * @return The class name. */ - public static String getClassName(final int fieldCount, final int paramCount) { - return SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.symbolName() + fieldCount + SCOPE_MARKER + paramCount; + public static String getClassName(final int fieldCount, final int paramCount, final boolean dualFields) { + return SCRIPTS_PACKAGE + '/' + getPrefixName(dualFields) + fieldCount + SCOPE_MARKER + paramCount; } /** * Returns the number of fields in the JavaScript scope class. Its name had to be generated using either - * {@link #getClassName(int)} or {@link #getClassName(int, int)}. + * {@link #getClassName(int, boolean)} or {@link #getClassName(int, int, boolean)}. * @param clazz the JavaScript scope class. * @return the number of fields in the scope class. */ public static int getFieldCount(final Class clazz) { final String name = clazz.getSimpleName(); - final String prefix = JS_OBJECT_PREFIX.symbolName(); + final String prefix = getPrefixName(name); + if (prefix.equals(name)) { return 0; } @@ -238,8 +240,8 @@ public final class ObjectClassGenerator implements Loggable { * @param className name of class * @param fieldNames fields to initialize to undefined, where applicable */ - private static void initializeToUndefined(final MethodEmitter init, final String className, final List fieldNames) { - if (!OBJECT_FIELDS_ONLY) { + private void initializeToUndefined(final MethodEmitter init, final String className, final List fieldNames) { + if (dualFields) { // no need to initialize anything to undefined in the dual field world // - then we have a constant getter for undefined for any unknown type return; @@ -292,7 +294,7 @@ public final class ObjectClassGenerator implements Loggable { * @return Byte codes for generated class. */ public byte[] generate(final int fieldCount) { - final String className = getClassName(fieldCount); + final String className = getClassName(fieldCount, dualFields); final String superName = className(ScriptObject.class); final ClassEmitter classEmitter = newClassEmitter(className, superName); @@ -322,7 +324,7 @@ public final class ObjectClassGenerator implements Loggable { * @return Byte codes for generated class. */ public byte[] generate(final int fieldCount, final int paramCount) { - final String className = getClassName(fieldCount, paramCount); + final String className = getClassName(fieldCount, paramCount, dualFields); final String superName = className(FunctionScope.class); final ClassEmitter classEmitter = newClassEmitter(className, superName); final List initFields = addFields(classEmitter, fieldCount); @@ -353,11 +355,11 @@ public final class ObjectClassGenerator implements Loggable { * * @return List fields that need to be initialized. */ - private static List addFields(final ClassEmitter classEmitter, final int fieldCount) { + private List addFields(final ClassEmitter classEmitter, final int fieldCount) { final List initFields = new LinkedList<>(); - + final Type[] fieldTypes = dualFields ? FIELD_TYPES_DUAL : FIELD_TYPES_OBJECT; for (int i = 0; i < fieldCount; i++) { - for (final Type type : FIELD_TYPES) { + for (final Type type : fieldTypes) { final String fieldName = getFieldName(i, type); classEmitter.field(fieldName, type.getTypeClass()); @@ -533,13 +535,10 @@ public final class ObjectClassGenerator implements Loggable { private static MethodHandle getterForType(final Class forType, final MethodHandle primitiveGetter, final MethodHandle objectGetter) { switch (getAccessorTypeIndex(forType)) { case TYPE_INT_INDEX: - assert !OBJECT_FIELDS_ONLY : "this can only happen with dual fields"; return MH.explicitCastArguments(primitiveGetter, primitiveGetter.type().changeReturnType(int.class)); case TYPE_LONG_INDEX: - assert !OBJECT_FIELDS_ONLY : "this can only happen with dual fields"; return primitiveGetter; case TYPE_DOUBLE_INDEX: - assert !OBJECT_FIELDS_ONLY : "this can only happen with dual fields"; return MH.filterReturnValue(primitiveGetter, UNPACK_DOUBLE); case TYPE_OBJECT_INDEX: return objectGetter; @@ -557,7 +556,7 @@ public final class ObjectClassGenerator implements Loggable { final boolean isPrimitiveStorage = forType != null && forType.isPrimitive(); //which is the primordial getter - final MethodHandle getter = OBJECT_FIELDS_ONLY ? objectGetter : isPrimitiveStorage ? primitiveGetter : objectGetter; + final MethodHandle getter = primitiveGetter == null ? objectGetter : isPrimitiveStorage ? primitiveGetter : objectGetter; if (forType == null) { if (isOptimistic) { @@ -580,8 +579,7 @@ public final class ObjectClassGenerator implements Loggable { return MH.dropArguments(GET_UNDEFINED.get(ti), 0, Object.class); } - assert forType != null; - assert !OBJECT_FIELDS_ONLY || forType == Object.class : forType; + assert primitiveGetter != null || forType == Object.class : forType; if (isOptimistic) { if (fti < ti) { @@ -635,8 +633,6 @@ public final class ObjectClassGenerator implements Loggable { return tgetter; } - assert !OBJECT_FIELDS_ONLY; - //final MethodType pmt = primitiveGetter.type(); assert primitiveGetter != null; final MethodType tgetterType = tgetter.type(); switch (fti) { @@ -727,7 +723,7 @@ public final class ObjectClassGenerator implements Loggable { final int fti = getAccessorTypeIndex(forType); final int ti = getAccessorTypeIndex(type); - if (fti == TYPE_OBJECT_INDEX || OBJECT_FIELDS_ONLY) { + if (fti == TYPE_OBJECT_INDEX || primitiveSetter == null) { if (ti == TYPE_OBJECT_INDEX) { return objectSetter; } @@ -735,8 +731,6 @@ public final class ObjectClassGenerator implements Loggable { return MH.asType(objectSetter, objectSetter.type().changeParameterType(1, type)); } - assert !OBJECT_FIELDS_ONLY; - final MethodType pmt = primitiveSetter.type(); switch (fti) { @@ -832,8 +826,8 @@ public final class ObjectClassGenerator implements Loggable { * @param thisProperties number of properties assigned to "this" * @return the allocation strategy */ - static AllocationStrategy createAllocationStrategy(final int thisProperties) { + static AllocationStrategy createAllocationStrategy(final int thisProperties, final boolean dualFields) { final int paddedFieldCount = getPaddedFieldCount(thisProperties); - return new AllocationStrategy(paddedFieldCount); + return new AllocationStrategy(paddedFieldCount, dualFields); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectCreator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectCreator.java index 1a09ca62df7..782e3d27464 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectCreator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectCreator.java @@ -134,7 +134,7 @@ public abstract class ObjectCreator { MethodEmitter loadTuple(final MethodEmitter method, final MapTuple tuple, final boolean pack) { loadValue(tuple.value, tuple.type); - if (pack && tuple.isPrimitive()) { + if (pack && codegen.useDualFields() && tuple.isPrimitive()) { method.pack(); } else { method.convert(Type.OBJECT); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SpillObjectCreator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SpillObjectCreator.java index 40d12dfbdc2..567edba405b 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SpillObjectCreator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SpillObjectCreator.java @@ -27,7 +27,6 @@ package jdk.nashorn.internal.codegen; import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup; import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup; -import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY; import java.util.LinkedHashSet; import java.util.List; @@ -42,6 +41,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayIndex; +import jdk.nashorn.internal.scripts.JD; import jdk.nashorn.internal.scripts.JO; /** @@ -65,10 +65,13 @@ public final class SpillObjectCreator extends ObjectCreator { assert !isScope() : "spill scope objects are not currently supported"; final int length = tuples.size(); - final long[] jpresetValues = new long[ScriptObject.spillAllocationLength(length)]; - final Object[] opresetValues = new Object[ScriptObject.spillAllocationLength(length)]; + final boolean dualFields = codegen.useDualFields(); + final int spillLength = ScriptObject.spillAllocationLength(length); + final long[] jpresetValues = dualFields ? new long[spillLength] : null; + final Object[] opresetValues = new Object[spillLength]; final Set postsetValues = new LinkedHashSet<>(); final int callSiteFlags = codegen.getCallSiteFlags(); + final Class objectClass = dualFields ? JD.class : JO.class; ArrayData arrayData = ArrayData.allocate(ScriptRuntime.EMPTY_ARRAY); // Compute constant property values @@ -88,9 +91,9 @@ public final class SpillObjectCreator extends ObjectCreator { final Property property = propertyMap.findProperty(key); if (property != null) { // normal property key - property.setType(JSType.unboxedFieldType(constantValue)); + property.setType(dualFields ? JSType.unboxedFieldType(constantValue) : Object.class); final int slot = property.getSlot(); - if (!OBJECT_FIELDS_ONLY && constantValue instanceof Number) { + if (dualFields && constantValue instanceof Number) { jpresetValues[slot] = ObjectClassGenerator.pack((Number)constantValue); } else { opresetValues[slot] = constantValue; @@ -130,28 +133,32 @@ public final class SpillObjectCreator extends ObjectCreator { //assert postsetValues.isEmpty() : "test me " + postsetValues; // create object and invoke constructor - method._new(JO.class).dup(); + method._new(objectClass).dup(); codegen.loadConstant(propertyMap); //load primitive values to j spill array - codegen.loadConstant(jpresetValues); - for (final int i : postsetValues) { - final MapTuple tuple = tuples.get(i); - final Property property = propertyMap.findProperty(tuple.key); - if (property != null && tuple.isPrimitive()) { - method.dup(); - method.load(property.getSlot()); - loadTuple(method, tuple); - method.arraystore(); + if (dualFields) { + codegen.loadConstant(jpresetValues); + for (final int i : postsetValues) { + final MapTuple tuple = tuples.get(i); + final Property property = propertyMap.findProperty(tuple.key); + if (property != null && tuple.isPrimitive()) { + method.dup(); + method.load(property.getSlot()); + loadTuple(method, tuple); + method.arraystore(); + } } + } else { + method.loadNull(); } //load object values to o spill array codegen.loadConstant(opresetValues); for (final int i : postsetValues) { - final MapTuple tuple = tuples.get(i); - final Property property = propertyMap.findProperty(tuple.key); - if (property != null && !tuple.isPrimitive()) { + final MapTuple tuple = tuples.get(i); + final Property property = propertyMap.findProperty(tuple.key); + if (property != null && (!dualFields || !tuple.isPrimitive())) { method.dup(); method.load(property.getSlot()); loadTuple(method, tuple); @@ -160,7 +167,7 @@ public final class SpillObjectCreator extends ObjectCreator { } //instantiate the script object with spill objects - method.invoke(constructorNoLookup(JO.class, PropertyMap.class, long[].class, Object[].class)); + method.invoke(constructorNoLookup(objectClass, PropertyMap.class, long[].class, Object[].class)); // Set prefix array data if any if (arrayData.length() > 0) { @@ -171,8 +178,8 @@ public final class SpillObjectCreator extends ObjectCreator { // set postfix for (final int i : postsetValues) { - final MapTuple tuple = tuples.get(i); - final Property property = propertyMap.findProperty(tuple.key); + final MapTuple tuple = tuples.get(i); + final Property property = propertyMap.findProperty(tuple.key); if (property == null) { final int index = ArrayIndex.getArrayIndex(tuple.key); assert ArrayIndex.isValidArrayIndex(index); @@ -188,7 +195,9 @@ public final class SpillObjectCreator extends ObjectCreator { @Override protected PropertyMap makeMap() { assert propertyMap == null : "property map already initialized"; - propertyMap = new MapCreator<>(JO.class, tuples).makeSpillMap(false); + final boolean dualFields = codegen.useDualFields(); + final Class clazz = dualFields ? JD.class : JO.class; + propertyMap = new MapCreator<>(clazz, tuples).makeSpillMap(false, codegen.useDualFields()); return propertyMap; } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java index 76a787fa922..16ec29e1dca 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java @@ -60,6 +60,7 @@ import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.Setter; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.ECMAErrors; +import jdk.nashorn.internal.runtime.FindProperty; import jdk.nashorn.internal.runtime.GlobalConstants; import jdk.nashorn.internal.runtime.GlobalFunctions; import jdk.nashorn.internal.runtime.JSType; @@ -78,6 +79,7 @@ import jdk.nashorn.internal.runtime.linker.Bootstrap; import jdk.nashorn.internal.runtime.linker.InvokeByName; import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor; import jdk.nashorn.internal.runtime.regexp.RegExpResult; +import jdk.nashorn.internal.scripts.JD; import jdk.nashorn.internal.scripts.JO; import jdk.nashorn.tools.ShellFunctions; @@ -717,7 +719,7 @@ public final class Global extends ScriptObject implements Scope { private static final MethodHandle LOAD = findOwnMH_S("load", Object.class, Object.class, Object.class); private static final MethodHandle LOAD_WITH_NEW_GLOBAL = findOwnMH_S("loadWithNewGlobal", Object.class, Object.class, Object[].class); private static final MethodHandle EXIT = findOwnMH_S("exit", Object.class, Object.class, Object.class); - private static final MethodHandle LEXICAL_SCOPE_FILTER = findOwnMH_S("lexicalScopeFilter", Object.class, Object.class); + private static final MethodHandle LEXICAL_SCOPE_FILTER = findOwnMH_S("lexicalScopeFilter", Object.class, Object.class); // initialized by nasgen private static PropertyMap $nasgenmap$; @@ -749,6 +751,11 @@ public final class Global extends ScriptObject implements Scope { return context; } + @Override + protected boolean useDualFields() { + return context.useDualFields(); + } + // performs initialization checks for Global constructor and returns the // PropertyMap, if everything is fine. private static PropertyMap checkAndGetMap(final Context context) { @@ -932,7 +939,7 @@ public final class Global extends ScriptObject implements Scope { * @return the new ScriptObject */ public ScriptObject newObject() { - return new JO(getObjectPrototype(), JO.getInitialMap()); + return useDualFields() ? new JD(getObjectPrototype()) : new JO(getObjectPrototype()); } /** @@ -2203,6 +2210,17 @@ public final class Global extends ScriptObject implements Scope { return invocation; } + @Override + protected FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) { + if (lexicalScope != null && start != this && start.isScope()) { + final FindProperty find = lexicalScope.findProperty(key, false); + if (find != null) { + return find; + } + } + return super.findProperty(key, deep, start); + } + @Override public GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final boolean isScope = NashornCallSiteDescriptor.isScope(desc); @@ -2732,8 +2750,8 @@ public final class Global extends ScriptObject implements Scope { */ private static class LexicalScope extends ScriptObject { - LexicalScope(final ScriptObject proto) { - super(proto, PropertyMap.newMap()); + LexicalScope(final Global global) { + super(global, PropertyMap.newMap()); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java index ef7a1ff8396..b75d50690e2 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java @@ -114,12 +114,11 @@ public final class NativeFloat32Array extends ArrayBufferView { private void setElem(final int index, final double elem) { try { - nb.put(index, (float)elem); - } catch (final IndexOutOfBoundsException e) { - //swallow valid array indexes. it's ok. - if (index < 0) { - throw new ClassCastException(); + if (index < nb.limit()) { + nb.put(index, (float) elem); } + } catch (final IndexOutOfBoundsException e) { + throw new ClassCastException(); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java index d0413d08b9f..9a2e319ba86 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java @@ -114,12 +114,11 @@ public final class NativeFloat64Array extends ArrayBufferView { private void setElem(final int index, final double elem) { try { - nb.put(index, elem); - } catch (final IndexOutOfBoundsException e) { - //swallow valid array indexes. it's ok. - if (index < 0) { - throw new ClassCastException(); + if (index < nb.limit()) { + nb.put(index, elem); } + } catch (final IndexOutOfBoundsException e) { + throw new ClassCastException(); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java index e4cdce51469..c2eb5556251 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java @@ -115,12 +115,11 @@ public final class NativeInt16Array extends ArrayBufferView { private void setElem(final int index, final int elem) { try { - nb.put(index, (short)elem); - } catch (final IndexOutOfBoundsException e) { - //swallow valid array indexes. it's ok. - if (index < 0) { - throw new ClassCastException(); + if (index < nb.limit()) { + nb.put(index, (short) elem); } + } catch (final IndexOutOfBoundsException e) { + throw new ClassCastException(); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java index 9e664ed78ca..a266fc519bd 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java @@ -104,11 +104,11 @@ public final class NativeInt32Array extends ArrayBufferView { private void setElem(final int index, final int elem) { try { - nb.put(index, elem); - } catch (final IndexOutOfBoundsException e) { - if (index < 0) { - throw new ClassCastException(); - } + if (index < nb.limit()) { + nb.put(index, elem); + } + } catch (final IndexOutOfBoundsException e) { + throw new ClassCastException(); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java index c336d2745ed..be9bacf987c 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java @@ -113,12 +113,11 @@ public final class NativeInt8Array extends ArrayBufferView { private void setElem(final int index, final int elem) { try { - nb.put(index, (byte)elem); - } catch (final IndexOutOfBoundsException e) { - //swallow valid array indexes. it's ok. - if (index < 0) { - throw new ClassCastException(); + if (index < nb.limit()) { + nb.put(index, (byte) elem); } + } catch (final IndexOutOfBoundsException e) { + throw new ClassCastException(); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSAdapter.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSAdapter.java index c5ca91010fa..c5ece8cd007 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSAdapter.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSAdapter.java @@ -160,7 +160,7 @@ public final class NativeJSAdapter extends ScriptObject { } private static ScriptObject wrapAdaptee(final ScriptObject adaptee) { - return new JO(adaptee, JO.getInitialMap()); + return new JO(adaptee); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java index 2fc2c51a380..30dc68140f4 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java @@ -104,12 +104,11 @@ public final class NativeUint16Array extends ArrayBufferView { private void setElem(final int index, final int elem) { try { - nb.put(index, (char)elem); - } catch (final IndexOutOfBoundsException e) { - //swallow valid array indexes. it's ok. - if (index < 0) { - throw new ClassCastException(); + if (index < nb.limit()) { + nb.put(index, (char) elem); } + } catch (final IndexOutOfBoundsException e) { + throw new ClassCastException(); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java index 4c83cc01701..85035175696 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java @@ -113,12 +113,11 @@ public final class NativeUint32Array extends ArrayBufferView { private void setElem(final int index, final int elem) { try { - nb.put(index, elem); - } catch (final IndexOutOfBoundsException e) { - //swallow valid array indexes. it's ok. - if (index < 0) { - throw new ClassCastException(); + if (index < nb.limit()) { + nb.put(index, elem); } + } catch (final IndexOutOfBoundsException e) { + throw new ClassCastException(); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java index 6e69ebadb1e..f5ccce64b6e 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java @@ -104,12 +104,11 @@ public final class NativeUint8Array extends ArrayBufferView { private void setElem(final int index, final int elem) { try { - nb.put(index, (byte)elem); - } catch (final IndexOutOfBoundsException e) { - //swallow valid array indexes. it's ok. - if (index < 0) { - throw new ClassCastException(); + if (index < nb.limit()) { + nb.put(index, (byte) elem); } + } catch (final IndexOutOfBoundsException e) { + throw new ClassCastException(); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java index 2dff261292b..28d72d1701a 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java @@ -133,18 +133,17 @@ public final class NativeUint8ClampedArray extends ArrayBufferView { private void setElem(final int index, final int elem) { try { - final byte clamped; - if ((elem & 0xffff_ff00) == 0) { - clamped = (byte)elem; - } else { - clamped = elem < 0 ? 0 : (byte)0xff; + if (index < nb.limit()) { + final byte clamped; + if ((elem & 0xffff_ff00) == 0) { + clamped = (byte) elem; + } else { + clamped = elem < 0 ? 0 : (byte) 0xff; + } + nb.put(index, clamped); } - nb.put(index, clamped); } catch (final IndexOutOfBoundsException e) { - //swallow valid array indexes. it's ok. - if (index < 0) { - throw new ClassCastException(); - } + throw new ClassCastException(); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/JSONParser.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/JSONParser.java index 524381873fb..5360226a39a 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/JSONParser.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/JSONParser.java @@ -41,6 +41,7 @@ import jdk.nashorn.internal.runtime.Source; import jdk.nashorn.internal.runtime.SpillProperty; import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayIndex; +import jdk.nashorn.internal.scripts.JD; import jdk.nashorn.internal.scripts.JO; import static jdk.nashorn.internal.parser.TokenType.STRING; @@ -54,11 +55,10 @@ public class JSONParser { final private String source; final private Global global; + final private boolean dualFields; final int length; int pos = 0; - private static PropertyMap EMPTY_MAP = PropertyMap.newMap(); - private static final int EOF = -1; private static final String TRUE = "true"; @@ -74,10 +74,11 @@ public class JSONParser { * @param source the source * @param global the global object */ - public JSONParser(final String source, final Global global ) { + public JSONParser(final String source, final Global global, final boolean dualFields) { this.source = source; this.global = global; this.length = source.length(); + this.dualFields = dualFields; } /** @@ -180,7 +181,7 @@ public class JSONParser { } private Object parseObject() { - PropertyMap propertyMap = EMPTY_MAP; + PropertyMap propertyMap = dualFields ? JD.getInitialMap() : JO.getInitialMap(); ArrayData arrayData = ArrayData.EMPTY_ARRAY; final ArrayList values = new ArrayList<>(); int state = STATE_EMPTY; @@ -241,36 +242,45 @@ public class JSONParser { return newArrayData.set(index, value, false); } - private static PropertyMap addObjectProperty(final PropertyMap propertyMap, final List values, + private PropertyMap addObjectProperty(final PropertyMap propertyMap, final List values, final String id, final Object value) { final Property oldProperty = propertyMap.findProperty(id); final PropertyMap newMap; - final Class type = ObjectClassGenerator.OBJECT_FIELDS_ONLY ? Object.class : getType(value); + final Class type; + final int flags; + if (dualFields) { + type = getType(value); + flags = Property.DUAL_FIELDS; + } else { + type = Object.class; + flags = 0; + } if (oldProperty != null) { values.set(oldProperty.getSlot(), value); - newMap = propertyMap.replaceProperty(oldProperty, new SpillProperty(id, 0, oldProperty.getSlot(), type));; + newMap = propertyMap.replaceProperty(oldProperty, new SpillProperty(id, flags, oldProperty.getSlot(), type));; } else { values.add(value); - newMap = propertyMap.addProperty(new SpillProperty(id, 0, propertyMap.size(), type)); + newMap = propertyMap.addProperty(new SpillProperty(id, flags, propertyMap.size(), type)); } return newMap; } private Object createObject(final PropertyMap propertyMap, final List values, final ArrayData arrayData) { - final long[] primitiveSpill = new long[values.size()]; + final long[] primitiveSpill = dualFields ? new long[values.size()] : null; final Object[] objectSpill = new Object[values.size()]; for (final Property property : propertyMap.getProperties()) { - if (property.getType() == Object.class) { + if (!dualFields || property.getType() == Object.class) { objectSpill[property.getSlot()] = values.get(property.getSlot()); } else { primitiveSpill[property.getSlot()] = ObjectClassGenerator.pack((Number) values.get(property.getSlot())); } } - final ScriptObject object = new JO(propertyMap, primitiveSpill, objectSpill); + final ScriptObject object = dualFields ? + new JD(propertyMap, primitiveSpill, objectSpill) : new JO(propertyMap, null, objectSpill); object.setInitialProto(global.getObjectPrototype()); object.setArray(arrayData); return object; diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java index a9afeb93abf..6fde66b45f2 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java @@ -25,7 +25,6 @@ package jdk.nashorn.internal.runtime; -import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY; import static jdk.nashorn.internal.codegen.ObjectClassGenerator.PRIMITIVE_FIELD_TYPE; import static jdk.nashorn.internal.codegen.ObjectClassGenerator.createGetter; import static jdk.nashorn.internal.codegen.ObjectClassGenerator.createSetter; @@ -98,7 +97,7 @@ public class AccessorProperty extends Property { objectSetters[i] = MH.asType(MH.setter(LOOKUP, structure, fieldName, typeClass), Lookup.SET_OBJECT_TYPE); } - if (!OBJECT_FIELDS_ONLY) { + if (!StructureLoader.isSingleFieldStructure(structure.getName())) { for (int i = 0; i < fieldCount; i++) { final String fieldNamePrimitive = getFieldName(i, PRIMITIVE_FIELD_TYPE); final Class typeClass = PRIMITIVE_FIELD_TYPE.getTypeClass(); @@ -211,7 +210,7 @@ public class AccessorProperty extends Property { * @param setter the property setter or null if non writable, non configurable */ private AccessorProperty(final String key, final int flags, final int slot, final MethodHandle getter, final MethodHandle setter) { - super(key, flags | IS_BUILTIN | (getter.type().returnType().isPrimitive() ? IS_NASGEN_PRIMITIVE : 0), slot); + super(key, flags | IS_BUILTIN | DUAL_FIELDS | (getter.type().returnType().isPrimitive() ? IS_NASGEN_PRIMITIVE : 0), slot); assert !isSpill(); // we don't need to prep the setters these will never be invalidated as this is a nasgen @@ -221,18 +220,15 @@ public class AccessorProperty extends Property { final Class setterType = setter == null ? null : setter.type().parameterType(1); assert setterType == null || setterType == getterType; - if (OBJECT_FIELDS_ONLY) { - primitiveGetter = primitiveSetter = null; + + if (getterType == int.class || getterType == long.class) { + primitiveGetter = MH.asType(getter, Lookup.GET_PRIMITIVE_TYPE); + primitiveSetter = setter == null ? null : MH.asType(setter, Lookup.SET_PRIMITIVE_TYPE); + } else if (getterType == double.class) { + primitiveGetter = MH.asType(MH.filterReturnValue(getter, ObjectClassGenerator.PACK_DOUBLE), Lookup.GET_PRIMITIVE_TYPE); + primitiveSetter = setter == null ? null : MH.asType(MH.filterArguments(setter, 1, ObjectClassGenerator.UNPACK_DOUBLE), Lookup.SET_PRIMITIVE_TYPE); } else { - if (getterType == int.class || getterType == long.class) { - primitiveGetter = MH.asType(getter, Lookup.GET_PRIMITIVE_TYPE); - primitiveSetter = setter == null ? null : MH.asType(setter, Lookup.SET_PRIMITIVE_TYPE); - } else if (getterType == double.class) { - primitiveGetter = MH.asType(MH.filterReturnValue(getter, ObjectClassGenerator.PACK_DOUBLE), Lookup.GET_PRIMITIVE_TYPE); - primitiveSetter = setter == null ? null : MH.asType(MH.filterArguments(setter, 1, ObjectClassGenerator.UNPACK_DOUBLE), Lookup.SET_PRIMITIVE_TYPE); - } else { - primitiveGetter = primitiveSetter = null; - } + primitiveGetter = primitiveSetter = null; } assert primitiveGetter == null || primitiveGetter.type() == Lookup.GET_PRIMITIVE_TYPE : primitiveGetter + "!=" + Lookup.GET_PRIMITIVE_TYPE; @@ -241,7 +237,7 @@ public class AccessorProperty extends Property { objectGetter = getter.type() != Lookup.GET_OBJECT_TYPE ? MH.asType(getter, Lookup.GET_OBJECT_TYPE) : getter; objectSetter = setter != null && setter.type() != Lookup.SET_OBJECT_TYPE ? MH.asType(setter, Lookup.SET_OBJECT_TYPE) : setter; - setType(OBJECT_FIELDS_ONLY ? Object.class : getterType); + setType(getterType); } /** @@ -282,6 +278,9 @@ public class AccessorProperty extends Property { objectSetter = gs.objectSetters[slot]; primitiveSetter = gs.primitiveSetters[slot]; } + + // Always use dual fields except for single field structures + assert hasDualFields() != StructureLoader.isSingleFieldStructure(structure.getName()); } /** @@ -310,7 +309,7 @@ public class AccessorProperty extends Property { */ public AccessorProperty(final String key, final int flags, final Class structure, final int slot, final Class initialType) { this(key, flags, structure, slot); - setType(OBJECT_FIELDS_ONLY ? Object.class : initialType); + setType(hasDualFields() ? initialType : Object.class); } /** @@ -347,7 +346,7 @@ public class AccessorProperty extends Property { * @param initialValue initial value */ protected final void setInitialValue(final ScriptObject owner, final Object initialValue) { - setType(JSType.unboxedFieldType(initialValue)); + setType(hasDualFields() ? JSType.unboxedFieldType(initialValue) : Object.class); if (initialValue instanceof Integer) { invokeSetter(owner, ((Integer)initialValue).intValue()); } else if (initialValue instanceof Long) { @@ -363,7 +362,7 @@ public class AccessorProperty extends Property { * Initialize the type of a property */ protected final void initializeType() { - setType(OBJECT_FIELDS_ONLY ? Object.class : null); + setType(!hasDualFields() ? Object.class : null); } private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException { @@ -670,7 +669,7 @@ public class AccessorProperty extends Property { @Override public final boolean canChangeType() { - if (OBJECT_FIELDS_ONLY) { + if (!hasDualFields()) { return false; } // Return true for currently undefined even if non-writable/configurable to allow initialization of ES6 CONST. diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AllocationStrategy.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AllocationStrategy.java index 395aee5ce4a..f25b588448a 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AllocationStrategy.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AllocationStrategy.java @@ -44,6 +44,9 @@ final public class AllocationStrategy implements Serializable { /** Number of fields in the allocated object */ private final int fieldCount; + /** Whether to use dual field representation */ + private final boolean dualFields; + /** Name of class where allocator function resides */ private transient String allocatorClassName; @@ -53,15 +56,17 @@ final public class AllocationStrategy implements Serializable { /** * Construct an allocation strategy with the given map and class name. * @param fieldCount number of fields in the allocated object + * @param dualFields whether to use dual field representation */ - public AllocationStrategy(final int fieldCount) { + public AllocationStrategy(final int fieldCount, final boolean dualFields) { this.fieldCount = fieldCount; + this.dualFields = dualFields; } private String getAllocatorClassName() { if (allocatorClassName == null) { // These classes get loaded, so an interned variant of their name is most likely around anyway. - allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount)).intern(); + allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount, dualFields)).intern(); } return allocatorClassName; } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java index 8c265c8a7ff..5c4bbd662f5 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java @@ -130,6 +130,23 @@ public final class Context { private static MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); private static MethodType CREATE_PROGRAM_FUNCTION_TYPE = MethodType.methodType(ScriptFunction.class, ScriptObject.class); + /** + * Should scripts use only object slots for fields, or dual long/object slots? The default + * behaviour is to couple this to optimistic types, using dual representation if optimistic types are enabled + * and single field representation otherwise. This can be overridden by setting either the "nashorn.fields.objects" + * or "nashorn.fields.dual" system property. + */ + private final FieldMode fieldMode; + + private static enum FieldMode { + /** Value for automatic field representation depending on optimistic types setting */ + AUTO, + /** Value for object field representation regardless of optimistic types setting */ + OBJECTS, + /** Value for dual primitive/object field representation regardless of optimistic types setting */ + DUAL + } + /** * Keeps track of which builtin prototypes and properties have been relinked * Currently we are conservative and associate the name of a builtin class with all @@ -434,7 +451,7 @@ public final class Context { * @param appLoader application class loader */ public Context(final Options options, final ErrorManager errors, final ClassLoader appLoader) { - this(options, errors, appLoader, (ClassFilter)null); + this(options, errors, appLoader, null); } /** @@ -522,6 +539,14 @@ public final class Context { getErr().println("nashorn full version " + Version.fullVersion()); } + if (Options.getBooleanProperty("nashorn.fields.dual")) { + fieldMode = FieldMode.DUAL; + } else if (Options.getBooleanProperty("nashorn.fields.objects")) { + fieldMode = FieldMode.OBJECTS; + } else { + fieldMode = FieldMode.AUTO; + } + initLoggers(); } @@ -575,6 +600,14 @@ public final class Context { return env.getErr(); } + /** + * Should scripts compiled by this context use dual field representation? + * @return true if using dual fields, false for object-only fields + */ + public boolean useDualFields() { + return fieldMode == FieldMode.DUAL || (fieldMode == FieldMode.AUTO && env._optimistic_types); + } + /** * Get the PropertyMap of the current global scope * @return the property map of the current global scope diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONFunctions.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONFunctions.java index 9622b59a17c..d5f3af77e09 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONFunctions.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONFunctions.java @@ -72,7 +72,8 @@ public final class JSONFunctions { public static Object parse(final Object text, final Object reviver) { final String str = JSType.toString(text); final Global global = Context.getGlobal(); - final JSONParser parser = new JSONParser(str, global); + final boolean dualFields = ((ScriptObject) global).useDualFields(); + final JSONParser parser = new JSONParser(str, global, dualFields); final Object value; try { diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java index c7eae4f5c30..31be7d28b91 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java @@ -26,7 +26,6 @@ package jdk.nashorn.internal.runtime; import static jdk.nashorn.internal.codegen.CompilerConstants.staticCall; -import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY; import static jdk.nashorn.internal.lookup.Lookup.MH; import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; @@ -1972,10 +1971,6 @@ public enum JSType { * @return primive type or Object.class if not primitive */ public static Class unboxedFieldType(final Object o) { - if (OBJECT_FIELDS_ONLY) { - return Object.class; - } - if (o == null) { return Object.class; } else if (o.getClass() == Integer.class) { diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java index 4225c251246..7d5442088cb 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java @@ -96,6 +96,9 @@ public abstract class Property implements Serializable { /** Is this property an ES6 lexical binding? */ public static final int IS_LEXICAL_BINDING = 1 << 10; + /** Does this property support dual field representation? */ + public static final int DUAL_FIELDS = 1 << 11; + /** Property key. */ private final String key; @@ -286,7 +289,7 @@ public abstract class Property implements Serializable { * @return true if parameter */ public boolean isParameter() { - return (flags & IS_PARAMETER) == IS_PARAMETER; + return (flags & IS_PARAMETER) != 0; } /** @@ -294,7 +297,7 @@ public abstract class Property implements Serializable { * @return true if has arguments */ public boolean hasArguments() { - return (flags & HAS_ARGUMENTS) == HAS_ARGUMENTS; + return (flags & HAS_ARGUMENTS) != 0; } /** @@ -316,7 +319,7 @@ public abstract class Property implements Serializable { * @return true if this is a bound property */ public boolean isBound() { - return (flags & IS_BOUND) == IS_BOUND; + return (flags & IS_BOUND) != 0; } /** @@ -325,7 +328,7 @@ public abstract class Property implements Serializable { * @return true if this is a block-scoped variable */ public boolean needsDeclaration() { - return (flags & NEEDS_DECLARATION) == NEEDS_DECLARATION; + return (flags & NEEDS_DECLARATION) != 0; } /** @@ -345,16 +348,6 @@ public abstract class Property implements Serializable { return this; } - /** - * Check if a flag is set for a property - * @param property property - * @param flag flag to check - * @return true if flag is set - */ - public static boolean checkFlag(final Property property, final int flag) { - return (property.getFlags() & flag) == flag; - } - /** * Get the flags for this property * @return property flags @@ -363,16 +356,6 @@ public abstract class Property implements Serializable { return flags; } - /** - * Get the modify flags for this property. The modify flags are the ECMA 8.6.1 - * flags that decide if the Property is writable, configurable and/or enumerable. - * - * @return modify flags for property - */ - public int getModifyFlags() { - return flags & MODIFY_MASK; - } - /** * Remove property flags from the property. Properties are immutable here, * so any property change that results in a smaller flag set results in the @@ -715,7 +698,7 @@ public abstract class Property implements Serializable { * @return whether this property is a function declaration or not. */ public boolean isFunctionDeclaration() { - return (flags & IS_FUNCTION_DECLARATION) == IS_FUNCTION_DECLARATION; + return (flags & IS_FUNCTION_DECLARATION) != 0; } /** @@ -723,6 +706,14 @@ public abstract class Property implements Serializable { * @return true if this property represents a lexical binding. */ public boolean isLexicalBinding() { - return (flags & IS_LEXICAL_BINDING) == IS_LEXICAL_BINDING; + return (flags & IS_LEXICAL_BINDING) != 0; + } + + /** + * Does this property support dual fields for both primitive and object values? + * @return true if supports dual fields + */ + public boolean hasDualFields() { + return (flags & DUAL_FIELDS) != 0; } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java index db7c5c992ce..fbc0dbbf47d 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java @@ -198,13 +198,22 @@ public final class PropertyMap implements Iterable, Serializable { return properties == null || properties.isEmpty()? newMap() : newMap(properties, JO.class.getName(), 0, 0, 0); } + /** + * Return a sharable empty map for the given object class. + * @param clazz the base object class + * @return New empty {@link PropertyMap}. + */ + public static PropertyMap newMap(final Class clazz) { + return new PropertyMap(EMPTY_HASHMAP, clazz.getName(), 0, 0, 0, false); + } + /** * Return a sharable empty map. * * @return New empty {@link PropertyMap}. */ public static PropertyMap newMap() { - return new PropertyMap(EMPTY_HASHMAP, JO.class.getName(), 0, 0, 0, false); + return newMap(JO.class); } /** diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java index 358cc05c960..daf65c23647 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java @@ -28,7 +28,6 @@ package jdk.nashorn.internal.runtime; import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup; import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCall; import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup; -import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY; import static jdk.nashorn.internal.lookup.Lookup.MH; import static jdk.nashorn.internal.runtime.ECMAErrors.referenceError; import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; @@ -146,12 +145,6 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { /** Area for reference properties added to object after instantiation, see {@link AccessorProperty} */ protected Object[] objectSpill; - /** - * Number of elements in the spill. This may be less than the spill array lengths, if not all of - * the allocated memory is in use - */ - private int spillLength; - /** Indexed array data. */ private ArrayData arrayData; @@ -171,12 +164,6 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { /** Method handle for getting the array data */ public static final Call GET_ARRAY = virtualCall(MethodHandles.lookup(), ScriptObject.class, "getArray", ArrayData.class); - /** Method handle for getting the property map - debugging purposes */ - public static final Call GET_MAP = virtualCall(MethodHandles.lookup(), ScriptObject.class, "getMap", PropertyMap.class); - - /** Method handle for setting the array data */ - public static final Call SET_ARRAY = virtualCall(MethodHandles.lookup(), ScriptObject.class, "setArray", void.class, ArrayData.class); - /** Method handle for getting a function argument at a given index. Used from MapCreator */ public static final Call GET_ARGUMENT = virtualCall(MethodHandles.lookup(), ScriptObject.class, "getArgument", Object.class, int.class); @@ -259,8 +246,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { this(map); this.primitiveSpill = primitiveSpill; this.objectSpill = objectSpill; - assert primitiveSpill.length == objectSpill.length : " primitive spill pool size is not the same length as object spill pool size"; - this.spillLength = spillAllocationLength(primitiveSpill.length); + assert primitiveSpill == null || primitiveSpill.length == objectSpill.length : " primitive spill pool size is not the same length as object spill pool size"; } /** @@ -727,7 +713,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { setArray(getArray().ensure(longIndex)); doesNotHaveEnsureDelete(longIndex, oldLength, false); } - setArray(getArray().set(index,value, false)); + setArray(getArray().set(index, value, false)); } private void checkIntegerKey(final String key) { @@ -812,7 +798,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { * * @return FindPropertyData or null if not found. */ - FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) { + protected FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) { final PropertyMap selfMap = getMap(); final Property property = selfMap.findProperty(key); @@ -976,10 +962,10 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { * @param setter setter for {@link UserAccessorProperty}, null if not present or N/A */ protected final void initUserAccessors(final String key, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) { - final int slot = spillLength; - ensureSpillSize(spillLength); //arguments=slot0, caller=slot0 - objectSpill[slot] = new UserAccessorProperty.Accessors(getter, setter); final PropertyMap oldMap = getMap(); + final int slot = oldMap.getFreeSpillSlot(); + ensureSpillSize(slot); + objectSpill[slot] = new UserAccessorProperty.Accessors(getter, setter); Property newProperty; PropertyMap newMap; do { @@ -1006,19 +992,12 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { final int slot = uc.getSlot(); assert uc.getLocalType() == Object.class; - if (slot >= spillLength) { - uc.setAccessors(this, getMap(), new UserAccessorProperty.Accessors(getter, setter)); - } else { - final UserAccessorProperty.Accessors gs = uc.getAccessors(this); //this crashes - if (gs == null) { - uc.setAccessors(this, getMap(), new UserAccessorProperty.Accessors(getter, setter)); - } else { - //reuse existing getter setter for speed - gs.set(getter, setter); - if (uc.getFlags() == propertyFlags) { - return oldProperty; - } - } + final UserAccessorProperty.Accessors gs = uc.getAccessors(this); //this crashes + assert gs != null; + //reuse existing getter setter for speed + gs.set(getter, setter); + if (uc.getFlags() == propertyFlags) { + return oldProperty; } newProperty = new UserAccessorProperty(uc.getKey(), propertyFlags, slot); } else { @@ -2053,8 +2032,6 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { protoSwitchPoint = null; } - assert OBJECT_FIELDS_ONLY || guard != null : "we always need a map guard here"; - final GuardedInvocation inv = new GuardedInvocation(mh, guard, protoSwitchPoint, exception); return inv.addSwitchPoint(findBuiltinSwitchPoint(name)); } @@ -2531,13 +2508,14 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { /** * Add a spill property for the given key. - * @param key Property key. - * @param propertyFlags Property flags. + * @param key Property key. + * @param flags Property flags. * @return Added property. */ - private Property addSpillProperty(final String key, final int propertyFlags, final Object value, final boolean hasInitialValue) { + private Property addSpillProperty(final String key, final int flags, final Object value, final boolean hasInitialValue) { final PropertyMap propertyMap = getMap(); final int fieldSlot = propertyMap.getFreeFieldSlot(); + final int propertyFlags = flags | (useDualFields() ? Property.DUAL_FIELDS : 0); Property property; if (fieldSlot > -1) { @@ -2562,7 +2540,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { * @return Setter method handle. */ MethodHandle addSpill(final Class type, final String key) { - return addSpillProperty(key, 0, null, false).getSetter(OBJECT_FIELDS_ONLY ? Object.class : type, getMap()); + return addSpillProperty(key, 0, null, false).getSetter(type, getMap()); } /** @@ -2649,9 +2627,9 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { final int spreadArgs = mh.type().parameterCount() - callSiteParamCount + 1; return MH.filterArguments( MH.asSpreader( - mh, - Object[].class, - spreadArgs), + mh, + Object[].class, + spreadArgs), callSiteParamCount - 1, MH.insertArguments( TRUNCATINGFILTER, @@ -3739,24 +3717,32 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { return uc; } + /** + * Returns {@code true} if properties for this object should use dual field mode, {@code false} otherwise. + * @return {@code true} if dual fields should be used. + */ + protected boolean useDualFields() { + return !StructureLoader.isSingleFieldStructure(getClass().getName()); + } + Object ensureSpillSize(final int slot) { - if (slot < spillLength) { + final int oldLength = objectSpill == null ? 0 : objectSpill.length; + if (slot < oldLength) { return this; } final int newLength = alignUp(slot + 1, SPILL_RATE); final Object[] newObjectSpill = new Object[newLength]; - final long[] newPrimitiveSpill = OBJECT_FIELDS_ONLY ? null : new long[newLength]; + final long[] newPrimitiveSpill = useDualFields() ? new long[newLength] : null; if (objectSpill != null) { - System.arraycopy(objectSpill, 0, newObjectSpill, 0, spillLength); - if (!OBJECT_FIELDS_ONLY) { - System.arraycopy(primitiveSpill, 0, newPrimitiveSpill, 0, spillLength); + System.arraycopy(objectSpill, 0, newObjectSpill, 0, oldLength); + if (primitiveSpill != null && newPrimitiveSpill != null) { + System.arraycopy(primitiveSpill, 0, newPrimitiveSpill, 0, oldLength); } } this.primitiveSpill = newPrimitiveSpill; this.objectSpill = newObjectSpill; - this.spillLength = newLength; return this; } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SetMethodCreator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SetMethodCreator.java index 90bbf43c8a6..4fe1b4f5485 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SetMethodCreator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SetMethodCreator.java @@ -232,14 +232,18 @@ final class SetMethodCreator { } private SetMethod createNewFieldSetter(final SwitchPoint builtinSwitchPoint) { - return createNewSetter(new AccessorProperty(getName(), 0, sobj.getClass(), getMap().getFreeFieldSlot(), type), builtinSwitchPoint); + return createNewSetter(new AccessorProperty(getName(), getFlags(sobj), sobj.getClass(), getMap().getFreeFieldSlot(), type), builtinSwitchPoint); } private SetMethod createNewSpillPropertySetter(final SwitchPoint builtinSwitchPoint) { - return createNewSetter(new SpillProperty(getName(), 0, getMap().getFreeSpillSlot(), type), builtinSwitchPoint); + return createNewSetter(new SpillProperty(getName(), getFlags(sobj), getMap().getFreeSpillSlot(), type), builtinSwitchPoint); } private PropertyMap getNewMap(final Property property) { return getMap().addProperty(property); } + + private static int getFlags(final ScriptObject scriptObject) { + return scriptObject.useDualFields() ? Property.DUAL_FIELDS : 0; + } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SpillProperty.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SpillProperty.java index 856504a3b0d..9019b5609f1 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SpillProperty.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SpillProperty.java @@ -25,7 +25,6 @@ package jdk.nashorn.internal.runtime; -import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY; import static jdk.nashorn.internal.lookup.Lookup.MH; import java.lang.invoke.MethodHandle; @@ -139,11 +138,11 @@ public class SpillProperty extends AccessorProperty { } } - private static MethodHandle primitiveGetter(final int slot) { - return OBJECT_FIELDS_ONLY ? null : Accessors.getCached(slot, true, true); + private static MethodHandle primitiveGetter(final int slot, final int flags) { + return (flags & DUAL_FIELDS) == DUAL_FIELDS ? Accessors.getCached(slot, true, true) : null; } - private static MethodHandle primitiveSetter(final int slot) { - return OBJECT_FIELDS_ONLY ? null : Accessors.getCached(slot, true, false); + private static MethodHandle primitiveSetter(final int slot, final int flags) { + return (flags & DUAL_FIELDS) == DUAL_FIELDS ? Accessors.getCached(slot, true, false) : null; } private static MethodHandle objectGetter(final int slot) { return Accessors.getCached(slot, false, true); @@ -160,8 +159,7 @@ public class SpillProperty extends AccessorProperty { * @param slot spill slot */ public SpillProperty(final String key, final int flags, final int slot) { - super(key, flags, slot, primitiveGetter(slot), primitiveSetter(slot), objectGetter(slot), objectSetter(slot)); - assert !OBJECT_FIELDS_ONLY || getLocalType() == Object.class; + super(key, flags, slot, primitiveGetter(slot, flags), primitiveSetter(slot, flags), objectGetter(slot), objectSetter(slot)); } /** @@ -173,7 +171,7 @@ public class SpillProperty extends AccessorProperty { */ public SpillProperty(final String key, final int flags, final int slot, final Class initialType) { this(key, flags, slot); - setType(OBJECT_FIELDS_ONLY ? Object.class : initialType); + setType(hasDualFields() ? initialType : Object.class); } SpillProperty(final String key, final int flags, final int slot, final ScriptObject owner, final Object initialValue) { @@ -216,8 +214,8 @@ public class SpillProperty extends AccessorProperty { @Override void initMethodHandles(final Class structure) { final int slot = getSlot(); - primitiveGetter = primitiveGetter(slot); - primitiveSetter = primitiveSetter(slot); + primitiveGetter = primitiveGetter(slot, getFlags()); + primitiveSetter = primitiveSetter(slot, getFlags()); objectGetter = objectGetter(slot); objectSetter = objectSetter(slot); } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java index 41201cde847..8324730a264 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java @@ -27,7 +27,8 @@ package jdk.nashorn.internal.runtime; import static jdk.nashorn.internal.codegen.Compiler.SCRIPTS_PACKAGE; import static jdk.nashorn.internal.codegen.Compiler.binaryName; -import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_PREFIX; +import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_DUAL_FIELD_PREFIX; +import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_SINGLE_FIELD_PREFIX; import java.security.ProtectionDomain; import jdk.nashorn.internal.codegen.ObjectClassGenerator; @@ -36,7 +37,8 @@ import jdk.nashorn.internal.codegen.ObjectClassGenerator; * Responsible for on the fly construction of structure classes. */ final class StructureLoader extends NashornLoader { - private static final String JS_OBJECT_PREFIX_EXTERNAL = binaryName(SCRIPTS_PACKAGE) + '.' + JS_OBJECT_PREFIX.symbolName(); + private static final String SINGLE_FIELD_PREFIX = binaryName(SCRIPTS_PACKAGE) + '.' + JS_OBJECT_SINGLE_FIELD_PREFIX.symbolName(); + private static final String DUAL_FIELD_PREFIX = binaryName(SCRIPTS_PACKAGE) + '.' + JS_OBJECT_DUAL_FIELD_PREFIX.symbolName(); /** * Constructor. @@ -45,14 +47,39 @@ final class StructureLoader extends NashornLoader { super(parent); } + /** + * Returns true if the class name represents a structure object with dual primitive/object fields. + * @param name a class name + * @return true if a dual field structure class + */ + private static boolean isDualFieldStructure(final String name) { + return name.startsWith(DUAL_FIELD_PREFIX); + } + + /** + * Returns true if the class name represents a structure object with single object-only fields. + * @param name a class name + * @return true if a single field structure class + */ + static boolean isSingleFieldStructure(final String name) { + return name.startsWith(SINGLE_FIELD_PREFIX); + } + + /** + * Returns true if the class name represents a Nashorn structure object. + * @param name a class name + * @return true if a structure class + */ static boolean isStructureClass(final String name) { - return name.startsWith(JS_OBJECT_PREFIX_EXTERNAL); + return isDualFieldStructure(name) || isSingleFieldStructure(name); } @Override protected Class findClass(final String name) throws ClassNotFoundException { - if (isStructureClass(name)) { - return generateClass(name, name.substring(JS_OBJECT_PREFIX_EXTERNAL.length())); + if (isDualFieldStructure(name)) { + return generateClass(name, name.substring(DUAL_FIELD_PREFIX.length()), true); + } else if (isSingleFieldStructure(name)) { + return generateClass(name, name.substring(SINGLE_FIELD_PREFIX.length()), false); } return super.findClass(name); } @@ -63,10 +90,10 @@ final class StructureLoader extends NashornLoader { * @param descriptor Layout descriptor. * @return Generated class. */ - private Class generateClass(final String name, final String descriptor) { + private Class generateClass(final String name, final String descriptor, final boolean dualFields) { final Context context = Context.getContextTrusted(); - final byte[] code = new ObjectClassGenerator(context).generate(descriptor); + final byte[] code = new ObjectClassGenerator(context, dualFields).generate(descriptor); return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null))); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java index 20510dfd36b..a717a21852a 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java @@ -198,7 +198,7 @@ public final class WithObject extends ScriptObject implements Scope { * @return FindPropertyData or null if not found. */ @Override - FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) { + protected FindProperty findProperty(final String key, final boolean deep, 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). diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java index b00d3ec1f87..9cdf6d5c352 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java @@ -74,17 +74,16 @@ public final class Bootstrap { * of object fields only, it is fine. However, with dual fields, in order to get * performance on benchmarks with a lot of object instantiation and then field * reassignment, it can take slightly more relinks to become stable with type - * changes swapping out an entire proprety map and making a map guard fail. - * Therefore the relink threshold is set to 16 for dual fields (now the default). - * This doesn't seem to have any other negative performance implication. + * changes swapping out an entire property map and making a map guard fail. + * Since we need to set this value statically it must work with possibly changing + * optimistic types and dual fields settings. A higher value does not seem to have + * any other negative performance implication when running with object-only fields, + * so we choose a higher value here. * * See for example octane.gbemu, run with --log=fields:warning to study * megamorphic behavior */ - private static final int NASHORN_DEFAULT_UNSTABLE_RELINK_THRESHOLD = - ObjectClassGenerator.OBJECT_FIELDS_ONLY ? - 8 : - 16; + private static final int NASHORN_DEFAULT_UNSTABLE_RELINK_THRESHOLD = 16; // do not create me!! private Bootstrap() { diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornGuards.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornGuards.java index dac36d4afb7..ca7034d139c 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornGuards.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornGuards.java @@ -33,7 +33,6 @@ import java.lang.ref.WeakReference; import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.LinkRequest; import jdk.nashorn.api.scripting.JSObject; -import jdk.nashorn.internal.codegen.ObjectClassGenerator; import jdk.nashorn.internal.objects.Global; import jdk.nashorn.internal.runtime.Property; import jdk.nashorn.internal.runtime.PropertyMap; @@ -123,7 +122,7 @@ public final class NashornGuards { */ static boolean needsGuard(final Property property, final CallSiteDescriptor desc) { return property == null || property.isConfigurable() - || property.isBound() || !ObjectClassGenerator.OBJECT_FIELDS_ONLY + || property.isBound() || property.hasDualFields() || !NashornCallSiteDescriptor.isFastScope(desc) || property.canChangeType(); } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java index 0e789333bb7..b343d775297 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java @@ -145,9 +145,6 @@ final class ArrayCompiler extends Compiler { case TargetInfo.IS_EMPTY_MEM: addOpcode(OPCode.NULL_CHECK_END_MEMST); break; - case TargetInfo.IS_EMPTY_REC: - addOpcode(OPCode.NULL_CHECK_END_MEMST_PUSH); - break; default: break; } // switch diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java index 30cfe907af5..dbed5d18285 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java @@ -183,7 +183,6 @@ class ByteCodeMachine extends StackMachine { case OPCode.NULL_CHECK_START: opNullCheckStart(); continue; case OPCode.NULL_CHECK_END: opNullCheckEnd(); continue; case OPCode.NULL_CHECK_END_MEMST: opNullCheckEndMemST(); continue; - case OPCode.NULL_CHECK_END_MEMST_PUSH: opNullCheckEndMemSTPush(); continue; case OPCode.JUMP: opJump(); continue; case OPCode.PUSH: opPush(); continue; @@ -1025,29 +1024,6 @@ class ByteCodeMachine extends StackMachine { } } - // USE_SUBEXP_CALL - private void opNullCheckEndMemSTPush() { - final int mem = code[ip++]; /* mem: null check id */ - - int isNull; - if (Config.USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT) { - isNull = nullCheckMemStRec(mem, s); - } else { - isNull = nullCheckRec(mem, s); - } - - if (isNull != 0) { - if (Config.DEBUG_MATCH) { - Config.log.println("NULL_CHECK_END_MEMST_PUSH: skip id:" + mem + ", s:" + s); - } - - if (isNull == -1) {opFail(); return;} - nullCheckFound(); - } else { - pushNullCheckEnd(mem); - } - } - private void opJump() { ip += code[ip] + 1; } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java index fc498c454e8..4cc33baf9bc 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java @@ -19,7 +19,6 @@ */ package jdk.nashorn.internal.runtime.regexp.joni; -import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsAt; import java.lang.ref.WeakReference; import jdk.nashorn.internal.runtime.regexp.joni.constants.StackPopLevel; import jdk.nashorn.internal.runtime.regexp.joni.constants.StackType; @@ -369,118 +368,9 @@ abstract class StackMachine extends Matcher implements StackType { } } - protected final int nullCheckRec(final int id, final int s) { - int level = 0; - int k = stk; - while (true) { - k--; - final StackEntry e = stack[k]; - - if (e.type == NULL_CHECK_START) { - if (e.getNullCheckNum() == id) { - if (level == 0) { - return e.getNullCheckPStr() == s ? 1 : 0; - } - level--; - } - } else if (e.type == NULL_CHECK_END) { - level++; - } - } - } - protected final int nullCheckMemSt(final int id, final int s) { - int k = stk; - int isNull; - while (true) { - k--; - StackEntry e = stack[k]; - - if (e.type == NULL_CHECK_START) { - if (e.getNullCheckNum() == id) { - if (e.getNullCheckPStr() != s) { - isNull = 0; - break; - } - int endp; - isNull = 1; - while (k < stk) { - if (e.type == MEM_START) { - if (e.getMemEnd() == INVALID_INDEX) { - isNull = 0; - break; - } - if (bsAt(regex.btMemEnd, e.getMemNum())) { - endp = stack[e.getMemEnd()].getMemPStr(); - } else { - endp = e.getMemEnd(); - } - if (stack[e.getMemStart()].getMemPStr() != endp) { - isNull = 0; - break; - } else if (endp != s) { - isNull = -1; /* empty, but position changed */ - } - } - k++; - e = stack[k]; // !! - } - break; - } - } - } - return isNull; - } - - protected final int nullCheckMemStRec(final int id, final int s) { - int level = 0; - int k = stk; - int isNull; - while (true) { - k--; - StackEntry e = stack[k]; - - if (e.type == NULL_CHECK_START) { - if (e.getNullCheckNum() == id) { - if (level == 0) { - if (e.getNullCheckPStr() != s) { - isNull = 0; - break; - } - int endp; - isNull = 1; - while (k < stk) { - if (e.type == MEM_START) { - if (e.getMemEnd() == INVALID_INDEX) { - isNull = 0; - break; - } - if (bsAt(regex.btMemEnd, e.getMemNum())) { - endp = stack[e.getMemEnd()].getMemPStr(); - } else { - endp = e.getMemEnd(); - } - if (stack[e.getMemStart()].getMemPStr() != endp) { - isNull = 0; - break; - } else if (endp != s) { - isNull = -1; /* empty, but position changed */ - } - } - k++; - e = stack[k]; - } - break; - } - level--; - } - } else if (e.type == NULL_CHECK_END) { - if (e.getNullCheckNum() == id) { - level++; - } - } - } - return isNull; + // Return -1 here to cause operation to fail + return -nullCheck(id, s); } protected final int getRepeat(final int id) { diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/constants/TargetInfo.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/constants/TargetInfo.java index 8dfb92bd611..5708a397fdc 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/constants/TargetInfo.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/constants/TargetInfo.java @@ -24,5 +24,4 @@ public interface TargetInfo { final int ISNOT_EMPTY = 0; final int IS_EMPTY = 1; final int IS_EMPTY_MEM = 2; - final int IS_EMPTY_REC = 3; } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JD.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JD.java new file mode 100644 index 00000000000..11d6cacc4bc --- /dev/null +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JD.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.internal.scripts; + +import jdk.nashorn.internal.runtime.PropertyMap; +import jdk.nashorn.internal.runtime.ScriptObject; + +/** + * Empty object class for dual primitive-object fields. + */ +public class JD extends ScriptObject { + + private static final PropertyMap map$ = PropertyMap.newMap(JD.class); + + /** + * Returns the initial property map to be used. + * @return the initial property map. + */ + public static PropertyMap getInitialMap() { + return map$; + } + + /** + * Constructor given an initial property map + * + * @param map the property map + */ + public JD(final PropertyMap map) { + super(map); + } + + /** + * Constructor given an initial prototype and the default initial property map. + * + * @param proto the prototype object + */ + public JD(final ScriptObject proto) { + super(proto, getInitialMap()); + } + + /** + * Constructor that takes a pre-initialized spill pool. Used by + * {@link jdk.nashorn.internal.codegen.SpillObjectCreator} and + * {@link jdk.nashorn.internal.parser.JSONParser} for initializing object literals + * + * @param map property map + * @param primitiveSpill primitive spill pool + * @param objectSpill reference spill pool + */ + public JD(final PropertyMap map, final long[] primitiveSpill, final Object[] objectSpill) { + super(map, primitiveSpill, objectSpill); + } + + /** + * A method handle of this method is passed to the ScriptFunction constructor. + * + * @param map the property map to use for allocatorMap + * + * @return newly allocated ScriptObject + */ + public static ScriptObject allocate(final PropertyMap map) { + return new JD(map); + } +} + diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JO.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JO.java index 2388a9781bd..1f9aa7ca127 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JO.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,11 +29,11 @@ import jdk.nashorn.internal.runtime.PropertyMap; import jdk.nashorn.internal.runtime.ScriptObject; /** - * Empty object class. + * Empty object class for object-only fields. */ public class JO extends ScriptObject { - private static final PropertyMap map$ = PropertyMap.newMap(); + private static final PropertyMap map$ = PropertyMap.newMap(JO.class); /** * Returns the initial property map to be used. @@ -53,13 +53,12 @@ public class JO extends ScriptObject { } /** - * Constructor given an initial prototype and an initial property map. + * Constructor given an initial prototype and the default initial property map. * * @param proto the prototype object - * @param map the property map */ - public JO(final ScriptObject proto, final PropertyMap map) { - super(proto, map); + public JO(final ScriptObject proto) { + super(proto, getInitialMap()); } /** @@ -86,3 +85,4 @@ public class JO extends ScriptObject { return new JO(map); } } + diff --git a/nashorn/test/script/basic/JDK-8073868.js b/nashorn/test/script/basic/JDK-8073868.js new file mode 100644 index 00000000000..f35fb161eeb --- /dev/null +++ b/nashorn/test/script/basic/JDK-8073868.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8073868: Regex matching causes java.lang.ArrayIndexOutOfBoundsException: 64 + * + * @test + * @run + */ + +function test(input) { + var comma = input.indexOf(","); + Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[0], input.trimLeft()); + Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[1], input.substring(0, comma).trimLeft()); + Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[2], input.substring(comma + 1)); + Assert.assertEquals(/(.*)+/.exec(input)[0], input); + Assert.assertEquals(/(.*)+/.exec(input)[1], input); +} + +test(" xxxx, xxx xxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx "); +test(" xxxx, xxx xxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx "); +test("x, xxxxxxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx "); + +Assert.assertEquals(/(?:\1a|())*/.exec("a")[0], "a"); +Assert.assertEquals(/(?:\1a|())*/.exec("a")[1], undefined); diff --git a/nashorn/test/script/basic/es6/let-eval.js b/nashorn/test/script/basic/es6/let-eval.js index b08fa98ad84..d1855dc9513 100644 --- a/nashorn/test/script/basic/es6/let-eval.js +++ b/nashorn/test/script/basic/es6/let-eval.js @@ -96,3 +96,9 @@ function f() { f(); print(typeof a, typeof b, typeof c, typeof x, typeof z); + +let v = 1; +eval("print('v: ' + v); v = 2; print ('v: ' + v);"); +print("this.v: " + this.v); +print("v: " + v); + diff --git a/nashorn/test/script/basic/es6/let-eval.js.EXPECTED b/nashorn/test/script/basic/es6/let-eval.js.EXPECTED index 96f9a6d04bc..d6ccc59756e 100644 --- a/nashorn/test/script/basic/es6/let-eval.js.EXPECTED +++ b/nashorn/test/script/basic/es6/let-eval.js.EXPECTED @@ -14,3 +14,7 @@ c: 0 2 1 0 2 1 0 undefined undefined undefined undefined undefined undefined +v: 1 +v: 2 +this.v: undefined +v: 2 diff --git a/nashorn/test/script/nosecurity/JDK-8067215.js b/nashorn/test/script/nosecurity/JDK-8067215.js new file mode 100644 index 00000000000..12877acbf43 --- /dev/null +++ b/nashorn/test/script/nosecurity/JDK-8067215.js @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8067215: Disable dual fields when not using optimistic types + * + * @test + * @run + * @option -Dnashorn.debug=true + * @fork + */ + +var intType = Java.type("int"); +var doubleType = Java.type("double"); +var longType = Java.type("long"); +var objectType = Java.type("java.lang.Object"); + +var Context = Java.type("jdk.nashorn.internal.runtime.Context"); +var JSType = Java.type("jdk.nashorn.internal.runtime.JSType"); + +var context = Context.getContext(); +var dualFields = context.useDualFields(); +var optimisticTypes = context.getEnv()._optimistic_types; + +if (dualFields != optimisticTypes) { + throw new Error("Wrong dual fields setting"); +} + +function testMap(obj) { + obj.x = "foo"; + obj["y"] = 0; + Object.defineProperty(obj, "z", {value: 0.5}); + var map = Debug.map(obj); + for (var key in obj) { + var prop = map.findProperty(key); + if (prop.hasDualFields() !== dualFields) { + throw new Error("Wrong property flags: " + prop); + } + if (prop.getType() != getExpectedType(obj[key])) { + throw new Error("Wrong property type: " + prop.getType() + " // " + getExpectedType(obj[key])); + + } + } +} + +function getExpectedType(value) { + if (!dualFields) { + return objectType.class; + } + if (JSType.isRepresentableAsInt(value)) { + return intType.class; + } + if (JSType.isRepresentableAsLong(value)) { + return longType.class; + } + if (JSType.isNumber(value)) { + return doubleType.class; + } + return objectType.class; +} + +var o = { + a: 1, + b: 2.5, + c: 0x10000000000, + d: true +}; + +function C() { + this.a = 1; + this.b = 2.5; + this.c = 0x10000000000; + this.d = true; +} + +var a = 1; +var b = 2.5; +var c = 0x10000000000; +var d = true; + +testMap(o); +testMap(new C()); +testMap(JSON.parse('{ "a": 1, "b": 2.5, "c": 1099511627776, "d": true }')); +testMap(this); diff --git a/nashorn/test/script/sandbox/interfaceimpl.js b/nashorn/test/script/sandbox/interfaceimpl.js index 0745318c816..17745fc9bb9 100644 --- a/nashorn/test/script/sandbox/interfaceimpl.js +++ b/nashorn/test/script/sandbox/interfaceimpl.js @@ -29,8 +29,8 @@ * @security */ -var Window = Java.type("jdk.nashorn.api.scripting.Window"); -var WindowEventHandler = Java.type("jdk.nashorn.api.scripting.WindowEventHandler"); +var Window = Java.type("jdk.nashorn.api.scripting.test.Window"); +var WindowEventHandler = Java.type("jdk.nashorn.api.scripting.test.WindowEventHandler"); var w = new Window(); diff --git a/nashorn/test/script/trusted/JDK-8025629.js b/nashorn/test/script/trusted/JDK-8025629.js index 609cfe8b84a..f3f4cbad42b 100644 --- a/nashorn/test/script/trusted/JDK-8025629.js +++ b/nashorn/test/script/trusted/JDK-8025629.js @@ -28,6 +28,6 @@ * @run */ -load("classpath:jdk/nashorn/internal/runtime/resources/load_test.js") +load("classpath:jdk/nashorn/internal/runtime/test/resources/load_test.js") Assert.assertEquals(loadedFunc("hello"), "HELLO"); diff --git a/nashorn/test/src/META-INF/services/java.sql.Driver b/nashorn/test/src/META-INF/services/java.sql.Driver index 295fe48075f..d1bb7d3328d 100644 --- a/nashorn/test/src/META-INF/services/java.sql.Driver +++ b/nashorn/test/src/META-INF/services/java.sql.Driver @@ -1 +1 @@ -jdk.nashorn.api.NashornSQLDriver +jdk.nashorn.api.test.NashornSQLDriver diff --git a/nashorn/test/src/jdk/internal/dynalink/beans/CallerSensitiveTest.java b/nashorn/test/src/jdk/internal/dynalink/beans/test/CallerSensitiveTest.java similarity index 94% rename from nashorn/test/src/jdk/internal/dynalink/beans/CallerSensitiveTest.java rename to nashorn/test/src/jdk/internal/dynalink/beans/test/CallerSensitiveTest.java index d9a44551741..2a6b746e485 100644 --- a/nashorn/test/src/jdk/internal/dynalink/beans/CallerSensitiveTest.java +++ b/nashorn/test/src/jdk/internal/dynalink/beans/test/CallerSensitiveTest.java @@ -23,8 +23,9 @@ * questions. */ -package jdk.internal.dynalink.beans; +package jdk.internal.dynalink.beans.test; +import jdk.internal.dynalink.beans.BeansLinker; import jdk.nashorn.test.models.ClassLoaderAware; import org.testng.annotations.Test; diff --git a/nashorn/test/src/jdk/nashorn/api/javaaccess/ArrayConversionTest.java b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/ArrayConversionTest.java similarity index 99% rename from nashorn/test/src/jdk/nashorn/api/javaaccess/ArrayConversionTest.java rename to nashorn/test/src/jdk/nashorn/api/javaaccess/test/ArrayConversionTest.java index 1da767b77e5..a7a17a2c224 100644 --- a/nashorn/test/src/jdk/nashorn/api/javaaccess/ArrayConversionTest.java +++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/ArrayConversionTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.javaaccess; +package jdk.nashorn.api.javaaccess.test; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; diff --git a/nashorn/test/src/jdk/nashorn/api/javaaccess/BooleanAccessTest.java b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/BooleanAccessTest.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/api/javaaccess/BooleanAccessTest.java rename to nashorn/test/src/jdk/nashorn/api/javaaccess/test/BooleanAccessTest.java index 234484f720f..80304198700 100644 --- a/nashorn/test/src/jdk/nashorn/api/javaaccess/BooleanAccessTest.java +++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/BooleanAccessTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.javaaccess; +package jdk.nashorn.api.javaaccess.test; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; @@ -38,8 +38,8 @@ import org.testng.annotations.Test; /** * @test - * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.BooleanAccessTest - * @run testng/othervm jdk.nashorn.api.javaaccess.BooleanAccessTest + * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.BooleanAccessTest + * @run testng/othervm jdk.nashorn.api.javaaccess.test.BooleanAccessTest */ @SuppressWarnings("javadoc") public class BooleanAccessTest { @@ -57,7 +57,7 @@ public class BooleanAccessTest { e = m.getEngineByName("nashorn"); o = new SharedObject(); e.put("o", o); - e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;"); + e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;"); } @AfterClass diff --git a/nashorn/test/src/jdk/nashorn/api/javaaccess/ConsStringTest.java b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/ConsStringTest.java similarity index 98% rename from nashorn/test/src/jdk/nashorn/api/javaaccess/ConsStringTest.java rename to nashorn/test/src/jdk/nashorn/api/javaaccess/test/ConsStringTest.java index 2b12b04628c..db8794b19d8 100644 --- a/nashorn/test/src/jdk/nashorn/api/javaaccess/ConsStringTest.java +++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/ConsStringTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.javaaccess; +package jdk.nashorn.api.javaaccess.test; import static org.testng.AssertJUnit.assertEquals; import java.util.HashMap; diff --git a/nashorn/test/src/jdk/nashorn/api/javaaccess/MethodAccessTest.java b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/MethodAccessTest.java similarity index 98% rename from nashorn/test/src/jdk/nashorn/api/javaaccess/MethodAccessTest.java rename to nashorn/test/src/jdk/nashorn/api/javaaccess/test/MethodAccessTest.java index 8bac7e6a864..ba3460da6cc 100644 --- a/nashorn/test/src/jdk/nashorn/api/javaaccess/MethodAccessTest.java +++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/MethodAccessTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.javaaccess; +package jdk.nashorn.api.javaaccess.test; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; @@ -41,8 +41,8 @@ import org.testng.annotations.Test; /** * @test - * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.MethodAccessTest - * @run testng/othervm jdk.nashorn.api.javaaccess.MethodAccessTest + * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.MethodAccessTest + * @run testng/othervm jdk.nashorn.api.javaaccess.test.MethodAccessTest */ @SuppressWarnings("javadoc") public class MethodAccessTest { @@ -61,8 +61,8 @@ public class MethodAccessTest { o = new SharedObject(); o.setEngine(e); e.put("o", o); - e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;"); - e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.Person;"); + e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;"); + e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.test.Person;"); } @AfterClass @@ -338,13 +338,13 @@ public class MethodAccessTest { @Test public void accessDefaultConstructor() throws ScriptException { - e.eval("var dc = new Packages.jdk.nashorn.api.javaaccess.Person()"); + e.eval("var dc = new Packages.jdk.nashorn.api.javaaccess.test.Person()"); assertEquals(new Person(), e.get("dc")); } @Test public void accessCustomConstructor() throws ScriptException { - e.eval("var cc = new Packages.jdk.nashorn.api.javaaccess.Person(17)"); + e.eval("var cc = new Packages.jdk.nashorn.api.javaaccess.test.Person(17)"); assertEquals(new Person(17), e.get("cc")); } diff --git a/nashorn/test/src/jdk/nashorn/api/javaaccess/NumberAccessTest.java b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/NumberAccessTest.java similarity index 99% rename from nashorn/test/src/jdk/nashorn/api/javaaccess/NumberAccessTest.java rename to nashorn/test/src/jdk/nashorn/api/javaaccess/test/NumberAccessTest.java index fd4ab9da4e3..882ed069421 100644 --- a/nashorn/test/src/jdk/nashorn/api/javaaccess/NumberAccessTest.java +++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/NumberAccessTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.javaaccess; +package jdk.nashorn.api.javaaccess.test; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; @@ -38,8 +38,8 @@ import org.testng.annotations.Test; /** * @test - * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.NumberAccessTest - * @run testng/othervm jdk.nashorn.api.javaaccess.NumberAccessTest + * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.NumberAccessTest + * @run testng/othervm jdk.nashorn.api.javaaccess.test.NumberAccessTest */ @SuppressWarnings("javadoc") public class NumberAccessTest { @@ -57,7 +57,7 @@ public class NumberAccessTest { e = m.getEngineByName("nashorn"); o = new SharedObject(); e.put("o", o); - e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;"); + e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;"); } @AfterClass diff --git a/nashorn/test/src/jdk/nashorn/api/javaaccess/NumberBoxingTest.java b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/NumberBoxingTest.java similarity index 98% rename from nashorn/test/src/jdk/nashorn/api/javaaccess/NumberBoxingTest.java rename to nashorn/test/src/jdk/nashorn/api/javaaccess/test/NumberBoxingTest.java index 40db6845fa9..9d5a2f7a2d6 100644 --- a/nashorn/test/src/jdk/nashorn/api/javaaccess/NumberBoxingTest.java +++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/NumberBoxingTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.javaaccess; +package jdk.nashorn.api.javaaccess.test; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; @@ -37,8 +37,8 @@ import org.testng.annotations.Test; /** * @test - * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.NumberBoxingTest - * @run testng/othervm jdk.nashorn.api.javaaccess.NumberBoxingTest + * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.NumberBoxingTest + * @run testng/othervm jdk.nashorn.api.javaaccess.test.NumberBoxingTest */ @SuppressWarnings("javadoc") public class NumberBoxingTest { @@ -56,7 +56,7 @@ public class NumberBoxingTest { e = m.getEngineByName("nashorn"); o = new SharedObject(); e.put("o", o); - e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;"); + e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;"); } @AfterClass diff --git a/nashorn/test/src/jdk/nashorn/api/javaaccess/ObjectAccessTest.java b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/ObjectAccessTest.java similarity index 94% rename from nashorn/test/src/jdk/nashorn/api/javaaccess/ObjectAccessTest.java rename to nashorn/test/src/jdk/nashorn/api/javaaccess/test/ObjectAccessTest.java index 00798a4efa3..80a325e4ce0 100644 --- a/nashorn/test/src/jdk/nashorn/api/javaaccess/ObjectAccessTest.java +++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/ObjectAccessTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.javaaccess; +package jdk.nashorn.api.javaaccess.test; import static org.testng.AssertJUnit.assertEquals; import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; @@ -37,8 +37,8 @@ import org.testng.annotations.Test; /** * @test - * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.ObjectAccessTest - * @run testng/othervm jdk.nashorn.api.javaaccess.ObjectAccessTest + * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.ObjectAccessTest + * @run testng/othervm jdk.nashorn.api.javaaccess.test.ObjectAccessTest */ @SuppressWarnings("javadoc") public class ObjectAccessTest { @@ -56,8 +56,8 @@ public class ObjectAccessTest { e = m.getEngineByName("nashorn"); o = new SharedObject(); e.put("o", o); - e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;"); - e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.Person;"); + e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;"); + e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.test.Person;"); } @AfterClass @@ -80,7 +80,7 @@ public class ObjectAccessTest { e.eval("var p_object_array = o.publicObjectArray;"); assertEquals(o.publicObjectArray[0], e.eval("o.publicObjectArray[0]")); assertArrayEquals(o.publicObjectArray, (Object[])e.get("p_object_array")); - e.eval("var t_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" + + e.eval("var t_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" + "t_object_arr[0] = new Person(100);" + "t_object_arr[1] = new Person(120);" + "t_object_arr[2] = new Person(140);" + @@ -104,7 +104,7 @@ public class ObjectAccessTest { e.eval("var ps_object_array = SharedObject.publicStaticObjectArray;"); assertEquals(SharedObject.publicStaticObjectArray[0], e.eval("SharedObject.publicStaticObjectArray[0]")); assertArrayEquals(SharedObject.publicStaticObjectArray, (Object[])e.get("ps_object_array")); - e.eval("var ts_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" + + e.eval("var ts_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" + "ts_object_arr[0] = new Person(100);" + "ts_object_arr[1] = new Person(120);" + "ts_object_arr[2] = new Person(140);" + @@ -128,7 +128,7 @@ public class ObjectAccessTest { e.eval("var pf_object_array = o.publicFinalObjectArray;"); assertEquals(o.publicFinalObjectArray[0], e.eval("o.publicFinalObjectArray[0]")); assertArrayEquals(o.publicFinalObjectArray, (Object[])e.get("pf_object_array")); - e.eval("var tf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" + + e.eval("var tf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" + "tf_object_arr[0] = new Person(100);" + "tf_object_arr[1] = new Person(120);" + "tf_object_arr[2] = new Person(140);" + @@ -152,7 +152,7 @@ public class ObjectAccessTest { e.eval("var psf_object_array = SharedObject.publicStaticFinalObjectArray;"); assertEquals(SharedObject.publicStaticFinalObjectArray[0], e.eval("SharedObject.publicStaticFinalObjectArray[0]")); assertArrayEquals(SharedObject.publicStaticFinalObjectArray, (Object[])e.get("psf_object_array")); - e.eval("var tsf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" + + e.eval("var tsf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" + "tsf_object_arr[0] = new Person(100);" + "tsf_object_arr[1] = new Person(120);" + "tsf_object_arr[2] = new Person(140);" + diff --git a/nashorn/test/src/jdk/nashorn/api/javaaccess/Person.java b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/Person.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/api/javaaccess/Person.java rename to nashorn/test/src/jdk/nashorn/api/javaaccess/test/Person.java index 32b1c9b795b..3e563b1113a 100644 --- a/nashorn/test/src/jdk/nashorn/api/javaaccess/Person.java +++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/Person.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.javaaccess; +package jdk.nashorn.api.javaaccess.test; @SuppressWarnings("javadoc") public class Person { diff --git a/nashorn/test/src/jdk/nashorn/api/javaaccess/SharedObject.java b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/SharedObject.java similarity index 99% rename from nashorn/test/src/jdk/nashorn/api/javaaccess/SharedObject.java rename to nashorn/test/src/jdk/nashorn/api/javaaccess/test/SharedObject.java index 93c93e19f70..3c41ac101b2 100644 --- a/nashorn/test/src/jdk/nashorn/api/javaaccess/SharedObject.java +++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/SharedObject.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.javaaccess; +package jdk.nashorn.api.javaaccess.test; import javax.script.Invocable; import javax.script.ScriptEngine; diff --git a/nashorn/test/src/jdk/nashorn/api/javaaccess/StringAccessTest.java b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/StringAccessTest.java similarity index 96% rename from nashorn/test/src/jdk/nashorn/api/javaaccess/StringAccessTest.java rename to nashorn/test/src/jdk/nashorn/api/javaaccess/test/StringAccessTest.java index 1e0a96aaf9c..909ddb48a4b 100644 --- a/nashorn/test/src/jdk/nashorn/api/javaaccess/StringAccessTest.java +++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/StringAccessTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.javaaccess; +package jdk.nashorn.api.javaaccess.test; import static org.testng.AssertJUnit.assertEquals; import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; @@ -37,8 +37,8 @@ import org.testng.annotations.Test; /** * @test - * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.StringAccessTest - * @run testng/othervm jdk.nashorn.api.javaaccess.StringAccessTest + * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.StringAccessTest + * @run testng/othervm jdk.nashorn.api.javaaccess.test.StringAccessTest */ @SuppressWarnings("javadoc") public class StringAccessTest { @@ -56,7 +56,7 @@ public class StringAccessTest { e = m.getEngineByName("nashorn"); o = new SharedObject(); e.put("o", o); - e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;"); + e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;"); } @AfterClass diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/InvocableTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/InvocableTest.java similarity index 99% rename from nashorn/test/src/jdk/nashorn/api/scripting/InvocableTest.java rename to nashorn/test/src/jdk/nashorn/api/scripting/test/InvocableTest.java index 4e44a296983..bba4ce50240 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/InvocableTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/InvocableTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.scripting; +package jdk.nashorn.api.scripting.test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/MultipleEngineTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/MultipleEngineTest.java similarity index 94% rename from nashorn/test/src/jdk/nashorn/api/scripting/MultipleEngineTest.java rename to nashorn/test/src/jdk/nashorn/api/scripting/test/MultipleEngineTest.java index 218deff1e89..76982faef8a 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/MultipleEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/MultipleEngineTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.scripting; +package jdk.nashorn.api.scripting.test; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; @@ -35,7 +35,7 @@ import org.testng.annotations.Test; * independently. * * @test - * @run testng jdk.nashorn.api.scripting.MultipleEngineTest + * @run testng jdk.nashorn.api.scripting.test.MultipleEngineTest */ @SuppressWarnings("javadoc") public class MultipleEngineTest { diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/PluggableJSObjectTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/PluggableJSObjectTest.java similarity index 99% rename from nashorn/test/src/jdk/nashorn/api/scripting/PluggableJSObjectTest.java rename to nashorn/test/src/jdk/nashorn/api/scripting/test/PluggableJSObjectTest.java index d6b9dcde1e5..0d9dc4d6cff 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/PluggableJSObjectTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/PluggableJSObjectTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.scripting; +package jdk.nashorn.api.scripting.test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -36,6 +36,7 @@ import java.util.LinkedHashMap; import java.util.Set; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; +import jdk.nashorn.api.scripting.AbstractJSObject; import org.testng.annotations.Test; /** diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScopeTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScopeTest.java similarity index 99% rename from nashorn/test/src/jdk/nashorn/api/scripting/ScopeTest.java rename to nashorn/test/src/jdk/nashorn/api/scripting/test/ScopeTest.java index f3e613b4474..6bc0c3bfd1f 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScopeTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScopeTest.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.nashorn.api.scripting; +package jdk.nashorn.api.scripting.test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -35,6 +35,8 @@ import javax.script.ScriptEngineManager; import javax.script.ScriptException; import javax.script.SimpleBindings; import javax.script.SimpleScriptContext; +import jdk.nashorn.api.scripting.ScriptObjectMirror; +import jdk.nashorn.api.scripting.URLReader; import org.testng.Assert; import org.testng.annotations.Test; diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java similarity index 98% rename from nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java rename to nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java index 06b89e83b19..dfebd44d60a 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.scripting; +package jdk.nashorn.api.scripting.test; import static org.testng.Assert.fail; import java.lang.reflect.InvocationHandler; @@ -32,6 +32,8 @@ import java.lang.reflect.Proxy; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; +import jdk.nashorn.api.scripting.ClassFilter; +import jdk.nashorn.api.scripting.NashornScriptEngineFactory; import org.testng.annotations.Test; /** diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineTest.java similarity index 98% rename from nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java rename to nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineTest.java index 1c412c688bc..3b683e2d24b 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.scripting; +package jdk.nashorn.api.scripting.test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -51,14 +51,15 @@ import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import javax.script.SimpleScriptContext; +import jdk.nashorn.api.scripting.ScriptObjectMirror; import org.testng.annotations.Test; /** * Tests for JSR-223 script engine for Nashorn. * * @test - * @build jdk.nashorn.api.scripting.Window jdk.nashorn.api.scripting.WindowEventHandler jdk.nashorn.api.scripting.VariableArityTestInterface jdk.nashorn.api.scripting.ScriptEngineTest - * @run testng/othervm jdk.nashorn.api.scripting.ScriptEngineTest + * @build jdk.nashorn.api.scripting.test.Window jdk.nashorn.api.scripting.test.WindowEventHandler jdk.nashorn.api.scripting.test.VariableArityTestInterface jdk.nashorn.api.scripting.test.ScriptEngineTest + * @run testng/othervm jdk.nashorn.api.scripting.test.ScriptEngineTest */ @SuppressWarnings("javadoc") public class ScriptEngineTest { @@ -541,7 +542,7 @@ public class ScriptEngineTest { final ScriptEngineManager m = new ScriptEngineManager(); final ScriptEngine e = m.getEngineByName("nashorn"); e.eval("obj = { foo: 'hello' }"); - e.put("Window", e.eval("Packages.jdk.nashorn.api.scripting.Window")); + e.put("Window", e.eval("Packages.jdk.nashorn.api.scripting.test.Window")); assertEquals(e.eval("Window.funcJSObject(obj)"), "hello"); assertEquals(e.eval("Window.funcScriptObjectMirror(obj)"), "hello"); assertEquals(e.eval("Window.funcMap(obj)"), "hello"); diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptObjectMirrorTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java similarity index 99% rename from nashorn/test/src/jdk/nashorn/api/scripting/ScriptObjectMirrorTest.java rename to nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java index ce3b421ce50..f9c78fc7abf 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptObjectMirrorTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.scripting; +package jdk.nashorn.api.scripting.test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -41,6 +41,8 @@ import javax.script.ScriptContext; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; +import jdk.nashorn.api.scripting.JSObject; +import jdk.nashorn.api.scripting.ScriptObjectMirror; import org.testng.annotations.Test; /** diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/VariableArityTestInterface.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/VariableArityTestInterface.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/api/scripting/VariableArityTestInterface.java rename to nashorn/test/src/jdk/nashorn/api/scripting/test/VariableArityTestInterface.java index 8ce5e4902af..7761a3d6e4a 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/VariableArityTestInterface.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/VariableArityTestInterface.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.scripting; +package jdk.nashorn.api.scripting.test; @SuppressWarnings("javadoc") public interface VariableArityTestInterface { diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/Window.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/Window.java similarity index 95% rename from nashorn/test/src/jdk/nashorn/api/scripting/Window.java rename to nashorn/test/src/jdk/nashorn/api/scripting/test/Window.java index 7a7476f5e86..6c60b163b7f 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/Window.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/Window.java @@ -23,10 +23,12 @@ * questions. */ -package jdk.nashorn.api.scripting; +package jdk.nashorn.api.scripting.test; import java.util.Map; import javax.script.Bindings; +import jdk.nashorn.api.scripting.JSObject; +import jdk.nashorn.api.scripting.ScriptObjectMirror; @SuppressWarnings("javadoc") public class Window { diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/WindowEventHandler.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/WindowEventHandler.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/api/scripting/WindowEventHandler.java rename to nashorn/test/src/jdk/nashorn/api/scripting/test/WindowEventHandler.java index dfcad5a9ff8..ddc879c89f2 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/WindowEventHandler.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/WindowEventHandler.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api.scripting; +package jdk.nashorn.api.scripting.test; @SuppressWarnings("javadoc") public interface WindowEventHandler { diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/resources/func.js b/nashorn/test/src/jdk/nashorn/api/scripting/test/resources/func.js similarity index 100% rename from nashorn/test/src/jdk/nashorn/api/scripting/resources/func.js rename to nashorn/test/src/jdk/nashorn/api/scripting/test/resources/func.js diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/resources/gettersetter.js b/nashorn/test/src/jdk/nashorn/api/scripting/test/resources/gettersetter.js similarity index 100% rename from nashorn/test/src/jdk/nashorn/api/scripting/resources/gettersetter.js rename to nashorn/test/src/jdk/nashorn/api/scripting/test/resources/gettersetter.js diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/resources/witheval.js b/nashorn/test/src/jdk/nashorn/api/scripting/test/resources/witheval.js similarity index 100% rename from nashorn/test/src/jdk/nashorn/api/scripting/resources/witheval.js rename to nashorn/test/src/jdk/nashorn/api/scripting/test/resources/witheval.js diff --git a/nashorn/test/src/jdk/nashorn/api/NashornSQLDriver.java b/nashorn/test/src/jdk/nashorn/api/test/NashornSQLDriver.java similarity index 98% rename from nashorn/test/src/jdk/nashorn/api/NashornSQLDriver.java rename to nashorn/test/src/jdk/nashorn/api/test/NashornSQLDriver.java index dd624096d37..d1a5377f747 100644 --- a/nashorn/test/src/jdk/nashorn/api/NashornSQLDriver.java +++ b/nashorn/test/src/jdk/nashorn/api/test/NashornSQLDriver.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.api; +package jdk.nashorn.api.test; import java.sql.Connection; import java.sql.Driver; diff --git a/nashorn/test/src/jdk/nashorn/api/tree/ParseAPITest.java b/nashorn/test/src/jdk/nashorn/api/tree/test/ParseAPITest.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/api/tree/ParseAPITest.java rename to nashorn/test/src/jdk/nashorn/api/tree/test/ParseAPITest.java index e198512953a..00504d93cd6 100644 --- a/nashorn/test/src/jdk/nashorn/api/tree/ParseAPITest.java +++ b/nashorn/test/src/jdk/nashorn/api/tree/test/ParseAPITest.java @@ -22,13 +22,16 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.nashorn.api.tree; +package jdk.nashorn.api.tree.test; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import jdk.nashorn.api.tree.Parser; +import jdk.nashorn.api.tree.SimpleTreeVisitorES5_1; +import jdk.nashorn.api.tree.Tree; import org.testng.Assert; import org.testng.annotations.Test; diff --git a/nashorn/test/src/jdk/nashorn/internal/codegen/CompilerTest.java b/nashorn/test/src/jdk/nashorn/internal/codegen/test/CompilerTest.java similarity index 99% rename from nashorn/test/src/jdk/nashorn/internal/codegen/CompilerTest.java rename to nashorn/test/src/jdk/nashorn/internal/codegen/test/CompilerTest.java index 0c67af89192..a6e86feaceb 100644 --- a/nashorn/test/src/jdk/nashorn/internal/codegen/CompilerTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/codegen/test/CompilerTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.codegen; +package jdk.nashorn.internal.codegen.test; import static jdk.nashorn.internal.runtime.Source.readFully; import static jdk.nashorn.internal.runtime.Source.sourceFor; diff --git a/nashorn/test/src/jdk/nashorn/internal/parser/ParserTest.java b/nashorn/test/src/jdk/nashorn/internal/parser/test/ParserTest.java similarity index 98% rename from nashorn/test/src/jdk/nashorn/internal/parser/ParserTest.java rename to nashorn/test/src/jdk/nashorn/internal/parser/test/ParserTest.java index 24d507a786c..17259cc9682 100644 --- a/nashorn/test/src/jdk/nashorn/internal/parser/ParserTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/parser/test/ParserTest.java @@ -23,11 +23,12 @@ * questions. */ -package jdk.nashorn.internal.parser; +package jdk.nashorn.internal.parser.test; import static jdk.nashorn.internal.runtime.Source.readFully; import static jdk.nashorn.internal.runtime.Source.sourceFor; import java.io.File; +import jdk.nashorn.internal.parser.Parser; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.ErrorManager; import jdk.nashorn.internal.runtime.Source; diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/test/JoniTest.java similarity index 91% rename from nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/test/JoniTest.java index 616f769f949..a907f8f1989 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/test/JoniTest.java @@ -23,15 +23,16 @@ * questions. */ -package jdk.nashorn.internal.runtime.regexp.joni; +package jdk.nashorn.internal.runtime.regexp.joni.test; +import jdk.nashorn.internal.runtime.regexp.joni.Regex; import org.testng.annotations.Test; /** * Joni coverage tests * * @test - * @run testng jdk.nashorn.internal.runtime.regexp.joni.JoniTest + * @run testng jdk.nashorn.internal.runtime.regexp.joni.test.JoniTest */ @SuppressWarnings("javadoc") public class JoniTest { diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/JdkRegExpTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/test/JdkRegExpTest.java similarity index 88% rename from nashorn/test/src/jdk/nashorn/internal/runtime/regexp/JdkRegExpTest.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/regexp/test/JdkRegExpTest.java index 8156b7864fa..20cb36722f0 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/JdkRegExpTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/test/JdkRegExpTest.java @@ -23,8 +23,11 @@ * questions. */ -package jdk.nashorn.internal.runtime.regexp; +package jdk.nashorn.internal.runtime.regexp.test; +import jdk.nashorn.internal.runtime.regexp.RegExp; +import jdk.nashorn.internal.runtime.regexp.RegExpFactory; +import jdk.nashorn.internal.runtime.regexp.RegExpMatcher; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; @@ -35,7 +38,7 @@ import org.testng.annotations.Test; * Basic tests for the JDK based RegExp implementation. * * @test - * @run testng jdk.nashorn.internal.runtime.regexp.JdkRegExpTest + * @run testng jdk.nashorn.internal.runtime.regexp.test.JdkRegExpTest */ public class JdkRegExpTest { diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/ClassFilterTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ClassFilterTest.java similarity index 99% rename from nashorn/test/src/jdk/nashorn/internal/runtime/ClassFilterTest.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/test/ClassFilterTest.java index 5c69141dfc1..7f535405663 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/ClassFilterTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ClassFilterTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.runtime; +package jdk.nashorn.internal.runtime.test; import static org.testng.Assert.fail; import java.io.File; diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/CodeStoreAndPathTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java similarity index 98% rename from nashorn/test/src/jdk/nashorn/internal/runtime/CodeStoreAndPathTest.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java index 2ca4820be7b..31342ce292d 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/CodeStoreAndPathTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.nashorn.internal.runtime; +package jdk.nashorn.internal.runtime.test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -38,10 +38,11 @@ import jdk.nashorn.api.scripting.NashornScriptEngineFactory; import org.testng.annotations.Test; /** + * @ignore Fails with jtreg, but passes with ant test run. Ignore for now. * @test * @bug 8039185 8039403 * @summary Test for persistent code cache and path handling - * @run testng jdk.nashorn.internal.runtime.CodeStoreAndPathTest + * @run testng jdk.nashorn.internal.runtime.test.CodeStoreAndPathTest */ @SuppressWarnings("javadoc") public class CodeStoreAndPathTest { diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/ConsStringTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ConsStringTest.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/internal/runtime/ConsStringTest.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/test/ConsStringTest.java index 16c360686bf..f86c5b75d2c 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/ConsStringTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ConsStringTest.java @@ -23,8 +23,9 @@ * questions. */ -package jdk.nashorn.internal.runtime; +package jdk.nashorn.internal.runtime.test; +import jdk.nashorn.internal.runtime.ConsString; import static org.testng.Assert.assertEquals; import org.testng.annotations.Test; @@ -33,7 +34,7 @@ import org.testng.annotations.Test; * Tests for JSType methods. * * @test - * @run testng jdk.nashorn.internal.runtime.ConsStringTest + * @run testng jdk.nashorn.internal.runtime.test.ConsStringTest */ public class ConsStringTest { diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/ContextTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ContextTest.java similarity index 93% rename from nashorn/test/src/jdk/nashorn/internal/runtime/ContextTest.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/test/ContextTest.java index 6770d7ec3e7..b927de2e965 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/ContextTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ContextTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.runtime; +package jdk.nashorn.internal.runtime.test; import static jdk.nashorn.internal.runtime.Source.sourceFor; import static org.testng.Assert.assertEquals; @@ -31,6 +31,12 @@ import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; import java.util.Map; import jdk.nashorn.internal.objects.Global; +import jdk.nashorn.internal.runtime.Context; +import jdk.nashorn.internal.runtime.ErrorManager; +import jdk.nashorn.internal.runtime.ScriptFunction; +import jdk.nashorn.internal.runtime.ScriptObject; +import jdk.nashorn.internal.runtime.ScriptRuntime; +import jdk.nashorn.internal.runtime.Source; import jdk.nashorn.internal.runtime.options.Options; import org.testng.annotations.Test; @@ -38,7 +44,7 @@ import org.testng.annotations.Test; * Basic Context API tests. * * @test - * @run testng jdk.nashorn.internal.runtime.ContextTest + * @run testng jdk.nashorn.internal.runtime.test.ContextTest */ @SuppressWarnings("javadoc") public class ContextTest { diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/ExceptionsNotSerializable.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ExceptionsNotSerializable.java similarity index 92% rename from nashorn/test/src/jdk/nashorn/internal/runtime/ExceptionsNotSerializable.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/test/ExceptionsNotSerializable.java index 3b6d91b25d6..3cb27ad09b1 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/ExceptionsNotSerializable.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ExceptionsNotSerializable.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.runtime; +package jdk.nashorn.internal.runtime.test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; @@ -34,13 +34,15 @@ import java.io.ObjectOutputStream; import javax.script.ScriptEngine; import javax.script.ScriptException; import jdk.nashorn.api.scripting.NashornScriptEngineFactory; +import jdk.nashorn.internal.runtime.RewriteException; +import jdk.nashorn.internal.runtime.UnwarrantedOptimismException; import org.testng.annotations.Test; /** * JDK-8044518: Ensure exceptions related to optimistic recompilation are not serializable * * @test - * @run testng jdk.nashorn.internal.runtime.ExceptionsNotSerializable + * @run testng jdk.nashorn.internal.runtime.test.ExceptionsNotSerializable */ @SuppressWarnings("javadoc") public class ExceptionsNotSerializable { diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/JSTypeTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/JSTypeTest.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/internal/runtime/JSTypeTest.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/test/JSTypeTest.java index 406ce1c3ed3..a91a442adf9 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/JSTypeTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/JSTypeTest.java @@ -23,8 +23,10 @@ * questions. */ -package jdk.nashorn.internal.runtime; +package jdk.nashorn.internal.runtime.test; +import jdk.nashorn.internal.runtime.JSType; +import jdk.nashorn.internal.runtime.ScriptRuntime; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; @@ -35,7 +37,7 @@ import org.testng.annotations.Test; * Tests for JSType methods. * * @test - * @run testng jdk.nashorn.internal.runtime.JSTypeTest + * @run testng jdk.nashorn.internal.runtime.test.JSTypeTest */ public class JSTypeTest { /** diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/LexicalBindingTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/LexicalBindingTest.java similarity index 98% rename from nashorn/test/src/jdk/nashorn/internal/runtime/LexicalBindingTest.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/test/LexicalBindingTest.java index 2cd0bf01ee1..713a33caad9 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/LexicalBindingTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/LexicalBindingTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.runtime; +package jdk.nashorn.internal.runtime.test; import jdk.nashorn.api.scripting.NashornScriptEngineFactory; import org.testng.annotations.Test; @@ -40,7 +40,7 @@ import static org.testng.Assert.assertEquals; * Top-level lexical binding tests. * * @test - * @run testng jdk.nashorn.internal.runtime.LexicalBindingTest + * @run testng jdk.nashorn.internal.runtime.test.LexicalBindingTest */ @SuppressWarnings("javadoc") public class LexicalBindingTest { diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/NoPersistenceCachingTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/NoPersistenceCachingTest.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/internal/runtime/NoPersistenceCachingTest.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/test/NoPersistenceCachingTest.java index 91f19606771..d9643e650bb 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/NoPersistenceCachingTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/NoPersistenceCachingTest.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.nashorn.internal.runtime; +package jdk.nashorn.internal.runtime.test; import static org.testng.Assert.fail; import java.io.ByteArrayOutputStream; @@ -43,7 +43,7 @@ import org.testng.annotations.Test; * @test * @bug 8037378 * @summary Sanity tests for no persistence caching - * @run testng/othervm jdk.nashorn.internal.runtime.NoPersistenceCachingTest + * @run testng/othervm jdk.nashorn.internal.runtime.test.NoPersistenceCachingTest */ @SuppressWarnings("javadoc") public class NoPersistenceCachingTest { diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/SourceTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/SourceTest.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/internal/runtime/SourceTest.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/test/SourceTest.java index 12645c05896..fdf406c54f4 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/SourceTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/SourceTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.runtime; +package jdk.nashorn.internal.runtime.test; import static jdk.nashorn.internal.runtime.Source.sourceFor; import static org.testng.Assert.assertEquals; @@ -36,6 +36,7 @@ import java.io.Reader; import java.net.URL; import java.util.Arrays; import jdk.nashorn.api.scripting.URLReader; +import jdk.nashorn.internal.runtime.Source; import org.testng.annotations.Test; /** @@ -48,7 +49,7 @@ public class SourceTest { final private static String SOURCE_STRING = "var x = 1;"; final private static char[] SOURCE_CHARS = SOURCE_STRING.toCharArray(); final private static String RESOURCE_PATH = "resources/load_test.js"; - final private static File SOURCE_FILE = new File("build/test/classes/jdk/nashorn/internal/runtime/" + RESOURCE_PATH); + final private static File SOURCE_FILE = new File("build/test/classes/jdk/nashorn/internal/runtime/test/" + RESOURCE_PATH); final private static URL SOURCE_URL = SourceTest.class.getResource(RESOURCE_PATH); diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/TrustedScriptEngineTest.java similarity index 99% rename from nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java rename to nashorn/test/src/jdk/nashorn/internal/runtime/test/TrustedScriptEngineTest.java index 09c90dc6f8c..416a204bdc3 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/TrustedScriptEngineTest.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.runtime; +package jdk.nashorn.internal.runtime.test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -36,6 +36,7 @@ import javax.script.ScriptException; import javax.script.SimpleScriptContext; import jdk.nashorn.api.scripting.ClassFilter; import jdk.nashorn.api.scripting.NashornScriptEngineFactory; +import jdk.nashorn.internal.runtime.Version; import org.testng.annotations.Test; /** diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/resources/load_test.js b/nashorn/test/src/jdk/nashorn/internal/runtime/test/resources/load_test.js similarity index 100% rename from nashorn/test/src/jdk/nashorn/internal/runtime/resources/load_test.js rename to nashorn/test/src/jdk/nashorn/internal/runtime/test/resources/load_test.js diff --git a/test/lib/sun/hotspot/WhiteBox.java b/test/lib/sun/hotspot/WhiteBox.java index 283d8adf604..b14626ce3e2 100644 --- a/test/lib/sun/hotspot/WhiteBox.java +++ b/test/lib/sun/hotspot/WhiteBox.java @@ -24,6 +24,7 @@ package sun.hotspot; +import java.lang.management.MemoryUsage; import java.lang.reflect.Executable; import java.util.Arrays; import java.util.List; @@ -95,8 +96,10 @@ public class WhiteBox { // G1 public native boolean g1InConcurrentMark(); public native boolean g1IsHumongous(Object o); + public native long g1NumMaxRegions(); public native long g1NumFreeRegions(); public native int g1RegionSize(); + public native MemoryUsage g1AuxiliaryMemoryUsage(); public native Object[] parseCommandLine(String commandline, char delim, DiagnosticCommand[] args); // NMT