# HG changeset patch # User asaha # Date 1288125925 25200 # Node ID e0bc5b441d60679accc01c245d13619edd1f7e29 # Parent 79caba0caf4faa2a2adfb6eb23b5d981be1be6e3# Parent 750c1ccb2f2d1ddfa95ab6c7f897fdab2f87f7e9 Merge diff -r 79caba0caf4f -r e0bc5b441d60 .hgtags --- a/.hgtags Fri Sep 24 22:42:14 2010 -0700 +++ b/.hgtags Tue Oct 26 13:45:25 2010 -0700 @@ -86,3 +86,5 @@ e02b4d709e177d08d56130a4bc68061e4bbacc7d jdk7-b109 a6442d6bc38a44152e0662688213ce4d2701f42a jdk7-b110 69f3edf083477955b5bd2f754252c7504167d8e1 jdk7-b111 +f960f117f1623629f64203e2b09a92a8f6f14ff5 jdk7-b112 +1fee41c7ed2b3388970a756a85aa693c0de8407a jdk7-b113 diff -r 79caba0caf4f -r e0bc5b441d60 .hgtags-top-repo --- a/.hgtags-top-repo Fri Sep 24 22:42:14 2010 -0700 +++ b/.hgtags-top-repo Tue Oct 26 13:45:25 2010 -0700 @@ -86,3 +86,5 @@ 81dfc728d7bb7e1fff4a4dc6d0f7cea5a3315667 jdk7-b109 2a02d4a6955c7c078aee9a604cb3be409800d82c jdk7-b110 9702d6fef68e17533ee7fcf5923b11ead3e912ce jdk7-b111 +b852103caf73da70068473777ae867a457bb3ae1 jdk7-b112 +c1df968c4527bfab5f97662a89245f15d12d378b jdk7-b113 diff -r 79caba0caf4f -r e0bc5b441d60 Makefile --- a/Makefile Fri Sep 24 22:42:14 2010 -0700 +++ b/Makefile Tue Oct 26 13:45:25 2010 -0700 @@ -558,9 +558,12 @@ # rule to test ################################################################ -.NOTPARALLEL: test +.NOTPARALLEL: test_run -test: test_clean test_start test_summary +test: + $(MAKE) test_run + +test_run: test_clean test_start test_summary test_start: @$(ECHO) "Tests started at `$(DATE)`" @@ -586,7 +589,7 @@ # Get failure list from log $(OUTPUTDIR)/test_failures.txt: $(OUTPUTDIR)/test_log.txt @$(RM) $@ - @( $(EGREP) '^FAILED:' $< || $(ECHO) "" ) > $@ + @( $(EGREP) '^FAILED:' $< || $(ECHO) "" ) | $(NAWK) 'length>0' > $@ # Get log file of all tests run JDK_TO_TEST := $(shell \ @@ -598,10 +601,11 @@ $(ECHO) "$(PRODUCT_HOME)"; \ fi \ ) +TEST_TARGETS=all $(OUTPUTDIR)/test_log.txt: $(RM) $@ - ( $(CD) test && \ - $(MAKE) NO_STOPPING=- PRODUCT_HOME=$(JDK_TO_TEST) \ + ( $(CD) test && \ + $(MAKE) NO_STOPPING=- PRODUCT_HOME=$(JDK_TO_TEST) $(TEST_TARGETS) \ ) | tee $@ ################################################################ @@ -614,7 +618,7 @@ # PHONY ################################################################ -.PHONY: all test test_start test_summary test_clean \ +.PHONY: all test test_run test_start test_summary test_clean \ generic_build_repo_series \ what clobber insane \ dev dev-build dev-sanity dev-clobber \ diff -r 79caba0caf4f -r e0bc5b441d60 corba/.hgtags --- a/corba/.hgtags Fri Sep 24 22:42:14 2010 -0700 +++ b/corba/.hgtags Tue Oct 26 13:45:25 2010 -0700 @@ -86,3 +86,5 @@ c3dd858e09b20206459d9e7b0ead99d27ab00eab jdk7-b109 0e1f80fda2271f53d4bbb59ec3f301dfbcef6a0a jdk7-b110 640fa4d4e2ad4c2d7e4815c955026740d8c52b7a jdk7-b111 +cc67fdc4fee9a5b25caee4e71b51a8ff24ae7d1a jdk7-b112 +a89a6c5be9d1a754868d3d359cbf7ad36aa95631 jdk7-b113 diff -r 79caba0caf4f -r e0bc5b441d60 hotspot/.hgtags --- a/hotspot/.hgtags Fri Sep 24 22:42:14 2010 -0700 +++ b/hotspot/.hgtags Tue Oct 26 13:45:25 2010 -0700 @@ -121,3 +121,5 @@ cc4bb3022b3144dc5db0805b9ef6c7eff2aa3b81 jdk7-b109 2f25f2b8de2700a1822463b1bd3d02b5e218018f jdk7-b110 07b042e13dde4f3479ba9ec55120fcd5e8623323 jdk7-b111 +5511edd5d719f3fc9fdd04879482026a3d2c8652 jdk7-b112 +beef35b96b81129c375d572357fb9548d9020db1 jdk7-b113 diff -r 79caba0caf4f -r e0bc5b441d60 jaxp/.hgtags --- a/jaxp/.hgtags Fri Sep 24 22:42:14 2010 -0700 +++ b/jaxp/.hgtags Tue Oct 26 13:45:25 2010 -0700 @@ -86,3 +86,5 @@ 0f382d6120fc07aed2209484a42458cabf405916 jdk7-b109 d422dbdd09766269344b796b3a46a5b3f74557e1 jdk7-b110 8106c747067c905d814a737a57fea0e29057b33f jdk7-b111 +1b05254242881527b4d5d711295c0fe708c8823a jdk7-b112 +bc0c84ce54c34d3e8b0604b94da0d7c75c26755e jdk7-b113 diff -r 79caba0caf4f -r e0bc5b441d60 jaxws/.hgtags --- a/jaxws/.hgtags Fri Sep 24 22:42:14 2010 -0700 +++ b/jaxws/.hgtags Tue Oct 26 13:45:25 2010 -0700 @@ -86,3 +86,5 @@ 4f626e0d70bda68c76bbd0e89d2bc2407f979736 jdk7-b109 95ecac35fb11530752bd0404c9bf02bcfb30990e jdk7-b110 2575ebca96c7fb1b78f6ae025a97321210aba309 jdk7-b111 +8e0f0054817f0f73fb33e80fb1333fb45b1d513d jdk7-b112 +d35c94fd22362f478f75b4bfcd2bef6a83cb9b3f jdk7-b113 diff -r 79caba0caf4f -r e0bc5b441d60 jdk/.hgtags --- a/jdk/.hgtags Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/.hgtags Tue Oct 26 13:45:25 2010 -0700 @@ -86,3 +86,5 @@ ab0d3f54a63f2aadfcdd2e14b81f79362ce454e2 jdk7-b109 176586cd040e4dd17a5ff6e91f72df10d7442453 jdk7-b110 fb63a2688db807a73e2a3de7d9bab298f1bff0e8 jdk7-b111 +b53f226b1d91473ac54184afa827be07b87e0319 jdk7-b112 +61d3b9fbb26bdef56cfa41b9af5bc312a22cbeb8 jdk7-b113 diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/Makefile --- a/jdk/make/Makefile Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/make/Makefile Tue Oct 26 13:45:25 2010 -0700 @@ -75,7 +75,6 @@ import_fastdebug -- copy in the fastdebug components \n\ import_debug -- copy in the debug components \n\ modules -- build the jdk and jre module images (experimental) \n\ -sccs_get -- make sure all SCCS files are up-to-date (need SCCS) \n\ create_links -- create softlinks in Solaris 32bit build to 64bit dirs \n\ " @@ -278,21 +277,6 @@ $(OUTPUTDIR) $(TEMPDIR): $(MKDIR) -p $@ -# cleanup everything. If the workspace is not being built by the control -# workspace, and if it is a Teamware workspace, then see if there are -# any files which are not under SCCS control. -clean clobber:: -ifndef EXTERNALSANITYCONTROL - @if [ -d $(TOPDIR)/Codemgr_wsdata ]; then \ - $(ECHO) '\nPerforming workspace scan for remnant files.\n' \ - ' Any files listed below are not under SCCS control in the workspace\n' \ - ' and you should review them and possibly remove them manually:' ; \ - $(FIND) $(TOPDIR)/make $(TOPDIR)/src -type f | \ - $(SED) 's+SCCS/[ps]\.++' | $(SORT) | $(UNIQ) -c | $(NAWK) '$$1<2 {print $$2;}' ; \ - $(ECHO) 'End of workspace scan.' ; \ - fi -endif - # this should be the last rule in this file: all:: @if [ -r $(WARNING_FILE) ]; then \ @@ -341,16 +325,70 @@ include $(BUILDDIR)/common/internal/BinaryPlugs.gmk # -# Get top level sccs_get rule +# Test rule # -include $(BUILDDIR)/common/Rules-SCCS.gmk + +.NOTPARALLEL: test_run + +test: + $(MAKE) test_run + +test_run: test_clean test_start test_summary + +test_start: + @$(ECHO) "Tests started at `$(DATE)`" + +test_clean: + $(RM) $(OUTPUTDIR)/test_failures.txt $(OUTPUTDIR)/test_log.txt +test_summary: $(OUTPUTDIR)/test_failures.txt + @$(ECHO) "#################################################" + @$(ECHO) "Tests completed at `$(DATE)`" + @( $(EGREP) '^TEST STATS:' $(OUTPUTDIR)/test_log.txt \ + || $(ECHO) "No TEST STATS seen in log" ) + @$(ECHO) "For complete details see: $(OUTPUTDIR)/test_log.txt" + @$(ECHO) "#################################################" + @if [ -s $< ] ; then \ + $(ECHO) "ERROR: Test failure count: `$(CAT) $< | $(WC) -l`"; \ + $(CAT) $<; \ + exit 1; \ + else \ + $(ECHO) "Success! No failures detected"; \ + fi + +# Get failure list from log +$(OUTPUTDIR)/test_failures.txt: $(OUTPUTDIR)/test_log.txt + @$(RM) $@ + @( $(EGREP) '^FAILED:' $< || $(ECHO) "" ) | $(NAWK) 'length>0' > $@ + +# Get log file of all tests run +JDK_TO_TEST := $(shell \ + if [ -d "$(ABS_OUTPUTDIR)/j2sdk-image" ] ; then \ + $(ECHO) "$(ABS_OUTPUTDIR)/j2sdk-image"; \ + elif [ -d "$(ABS_OUTPUTDIR)/bin" ] ; then \ + $(ECHO) "$(ABS_OUTPUTDIR)"; \ + elif [ "$(PRODUCT_HOME)" != "" -a -d "$(PRODUCT_HOME)/bin" ] ; then \ + $(ECHO) "$(PRODUCT_HOME)"; \ + fi \ +) + +TEST_TARGETS=jdk_all +$(OUTPUTDIR)/test_log.txt: + $(RM) $@ + ( $(CD) ../test && \ + $(MAKE) NO_STOPPING=- PRODUCT_HOME=$(JDK_TO_TEST) $(TEST_TARGETS) \ + ) | tee $@ + +# # JPRT rules +# + include jprt.gmk # # Phonies to avoid accidents. # .PHONY: all build clean clobber optimized debug fastdebug create_links \ - import import_product import_fastdebug import_debug + import import_product import_fastdebug import_debug \ + test test_run test_start test_clean test_summary diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/common/Cscope.gmk --- a/jdk/make/common/Cscope.gmk Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/make/common/Cscope.gmk Tue Oct 26 13:45:25 2010 -0700 @@ -76,7 +76,7 @@ # What files should we include? A simple rule might be just those files under # SCM control, however this would miss files we create like the opcodes and # CClassHeaders. The following attempts to find everything that is *useful*. -# (.del files are created by sccsrm, demo directories contain many .java files +# (demo directories contain many .java files # that probably aren't useful for development, and the pkgarchive may contain # duplicates of files within the source hierarchy). The ordering of the .raw # file is an attempt to make cscope display the most relevant files first. diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/common/Defs.gmk --- a/jdk/make/common/Defs.gmk Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/make/common/Defs.gmk Tue Oct 26 13:45:25 2010 -0700 @@ -334,7 +334,7 @@ DOCSDIRSUFFIX = # The MESSAGE, WARNING and ERROR files are used to store sanityck and -# SCCS check messages, warnings and errors. +# warnings and errors. ifndef ERROR_FILE ERROR_FILE = $(OUTPUTDIR)/sanityCheckErrors.txt endif @@ -634,38 +634,6 @@ VERSION_DEFINES = -DRELEASE='"$(RELEASE)"' -# Note: As a rule, GNU Make rules should not appear in any of the -# Defs*.gmk files. These were added for Kestrel-Solaris and do address -# a TeamWare bug. They should be moved elsewhere for Merlin. -# -# Override gnumake built-in rules which do sccs get operations badly. -# (They put the checked out code in the current directory, not in the -# directory of the original file.) -# Since this is a symptom of a teamware failure, complain and die on the spot. - -# This message immediately goes to stdout and the build terminates. -define SCCS-trouble -$(error \ -"ERROR: File $@ referenced while building in $(CURRENT_DIRECTORY) \ - is out of date with respect to its SCCS file $<. \ - This can happen from an unresolved Teamware conflict, a file movement, or \ - a failure in which SCCS files are updated but the 'sccs get' was not done. \ - You should double check for other out of date files in your workspace. \ - Or run: cd $(TOPDIR) && $(MAKE) sccs_get") -endef - -%:: s.% - @$(SCCS-trouble) -%:: SCCS/s.% - @$(SCCS-trouble) - @$(ECHO) " is out of date with respect to its SCCS file." >> $(WARNING_FILE) - @$(ECHO) " This file may be from an unresolved Teamware conflict." >> $(WARNING_FILE) - @$(ECHO) " This is also a symptom of a Teamware bringover/putback failure" >> $(WARNING_FILE) - @$(ECHO) " in which SCCS files are updated but not checked out." >> $(WARNING_FILE) - @$(ECHO) " Check for other out of date files in your workspace." >> $(WARNING_FILE) - @$(ECHO) "" >> $(WARNING_FILE) - @#exit 666 - ifdef INSANE export INSANE endif diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/common/Rules-SCCS.gmk --- a/jdk/make/common/Rules-SCCS.gmk Fri Sep 24 22:42:14 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -# -# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# Only get these rules if SCCS is available -# - -ifdef SCCS - -# SCCS command to extract out latest source -SCCS_GET=$(SCCS) get -s - -# -# Make sure all files in workspace are fresh -# -TEMP_ALL_FILES=$(JDK_TOPDIR)/temp_filelist -$(TEMP_ALL_FILES): $(JDK_TOPDIR)/Codemgr_wsdata/nametable - $(prep-target) - @$(CUT) -d' ' -f1 $< \ - | $(GREP) -v '^VERSION' \ - | $(GREP) -v '^deleted_files' \ - | $(GREP) -v '^Codemgr_wsdata' > $@ - -sccs_get: $(TEMP_ALL_FILES) - @$(PRINTF) "Workspace has %d files\n" `$(CAT) $< | $(WC) -l` - @count=0; \ - for i in `$(CAT) $<` ; do \ - f=$(JDK_TOPDIR)/$$i; \ - count=`$(EXPR) $$count '+' 1`; \ - if [ `$(EXPR) $$count '%' 100` = 0 ] ; then \ - $(PRINTF) "\rChecked $$count files"; \ - fi; \ - if [ ! -f $$f ] ; then \ - $(PRINTF) "\r$(SCCS_GET) $$f\n"; \ - (cd `$(DIRNAME) $$f` && $(SCCS_GET) `$(BASENAME) $$f`); \ - elif /usr/bin/test $$f -ot `$(DIRNAME) $$f`/SCCS/s.`$(BASENAME) $$f` ; then \ - $(PRINTF) "\r$(SCCS_GET) $$f\n"; \ - (cd `$(DIRNAME) $$f` && $(SCCS_GET) `$(BASENAME) $$f`); \ - fi; \ - done; \ - $(PRINTF) "\rChecked $$count files\n" - -# -# Phonies to avoid accidents. -# -.PHONY: sccs_get - -endif diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/common/shared/Defs-utils.gmk --- a/jdk/make/common/shared/Defs-utils.gmk Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/make/common/shared/Defs-utils.gmk Tue Oct 26 13:45:25 2010 -0700 @@ -33,7 +33,7 @@ # UTILS_COMMAND_PATH # /usr/bin/ # UTILS_USR_BIN_PATH -# /usr/ccs/bin/ (sccs, m4, lex, yacc, as, ar, strip, mcs) +# /usr/ccs/bin/ (m4, lex, yacc, as, ar, strip, mcs) # UTILS_CCS_BIN_PATH # Dev Tools: zip, unzip, etc that we may have special versions of # UTILS_DEVTOOL_PATH @@ -117,7 +117,6 @@ RMDIR = $(UTILS_COMMAND_PATH)rmdir RPM = $(UTILS_COMMAND_PATH)rpm RPMBUILD = $(UTILS_COMMAND_PATH)rpmbuild -SCCS = $(UTILS_CCS_BIN_PATH)sccs SED = $(UTILS_COMMAND_PATH)sed SH = $(UTILS_COMMAND_PATH)sh SHOWREV = $(UTILS_USR_BIN_PATH)showrev @@ -183,7 +182,7 @@ NAWK = $(USRBIN_PATH)gawk # Intrinsic unix command, with backslash-escaped character interpretation ECHO = /bin/echo -e - # These are really in UTILS_USR_BIN_PATH on Linux (only sccs is not) + # These are really in UTILS_USR_BIN_PATH on Linux AR = $(UTILS_USR_BIN_PATH)ar AS = $(UTILS_USR_BIN_PATH)as LD = $(UTILS_USR_BIN_PATH)ld diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/common/shared/Defs.gmk --- a/jdk/make/common/shared/Defs.gmk Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/make/common/shared/Defs.gmk Tue Oct 26 13:45:25 2010 -0700 @@ -219,7 +219,7 @@ PRODUCT_NAME = Java(TM) PRODUCT_SUFFIX = SE Runtime Environment JDK_RC_PLATFORM_NAME = Platform SE - COMPANY_NAME = Oracle + COMPANY_NAME = Oracle Corporation endif RUNTIME_NAME = $(PRODUCT_NAME) $(PRODUCT_SUFFIX) diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/java/java/FILES_java.gmk --- a/jdk/make/java/java/FILES_java.gmk Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/make/java/java/FILES_java.gmk Tue Oct 26 13:45:25 2010 -0700 @@ -284,6 +284,7 @@ java/util/concurrent/CancellationException.java \ java/util/concurrent/CompletionService.java \ java/util/concurrent/ConcurrentHashMap.java \ + java/util/concurrent/ConcurrentLinkedDeque.java \ java/util/concurrent/ConcurrentLinkedQueue.java \ java/util/concurrent/ConcurrentMap.java \ java/util/concurrent/ConcurrentNavigableMap.java \ diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/jprt.properties --- a/jdk/make/jprt.properties Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/make/jprt.properties Tue Oct 26 13:45:25 2010 -0700 @@ -25,43 +25,265 @@ # Properties for jprt -# Use whatever release that the submitted job requests +# At submit time, the release supplied will be in jprt.submit.release +# and will be one of the official release names defined in jprt. +# jprt supports property value expansion using ${property.name} syntax. + +# This tells jprt what default release we want to build jprt.tools.default.release=${jprt.submit.release} # The different build flavors we want, we override here so we just get these 2 jprt.build.flavors=product,fastdebug -# Standard test target for everybody -jprt.test.targets=*-*-*-jvm98 +# Define the Windows we want (temporary) +jprt.my.windows.i586.jdk7b107=windows_i586_5.0 +jprt.my.windows.i586.jdk7temp=windows_i586_5.0 +jprt.my.windows.i586.jdk7=windows_i586_5.1 +jprt.my.windows.i586=${jprt.my.windows.i586.${jprt.tools.default.release}} + +# Standard list of jprt build targets for this source tree +jprt.build.targets= \ + solaris_sparc_5.10-{product|fastdebug}, \ + solaris_sparcv9_5.10-{product|fastdebug}, \ + solaris_i586_5.10-{product|fastdebug}, \ + solaris_x64_5.10-{product|fastdebug}, \ + linux_i586_2.6-{product|fastdebug}, \ + linux_x64_2.6-{product|fastdebug}, \ + ${jprt.my.windows.i586}-{product|fastdebug}, \ + windows_x64_5.2-{product|fastdebug} + +# Standard vm test target +jprt.test.targets= \ + solaris_sparc_5.10-product-c1-jvm98, \ + solaris_sparcv9_5.10-product-c2-jvm98, \ + solaris_i586_5.10-product-c1-jvm98, \ + solaris_x64_5.10-product-c2-jvm98, \ + linux_i586_2.6-product-{c1|c2}-jvm98, \ + linux_x64_2.6-product-c2-jvm98, \ + ${jprt.my.windows.i586}-product-c1-jvm98, \ + windows_x64_5.2-product-c2-jvm98 + +# User can select the test set with jprt submit "-testset name" option +jprt.my.test.set=${jprt.test.set} -# Test targets in test/Makefile (some longer running tests only test c2) -jprt.make.rule.test.targets= \ - *-product-*-jdk_beans1, \ - *-product-*-jdk_beans2, \ - *-product-*-jdk_beans3, \ - *-product-*-jdk_io, \ - *-product-*-jdk_lang, \ - *-product-*-jdk_management1, \ - *-product-*-jdk_management2, \ - *-product-*-jdk_math, \ - *-product-*-jdk_misc, \ - *-product-*-jdk_net, \ - *-product-*-jdk_nio1, \ - *-product-*-jdk_nio2, \ - *-product-*-jdk_nio3, \ - *-product-*-jdk_security1, \ - *-product-*-jdk_security2, \ - *-product-*-jdk_security3, \ - *-product-*-jdk_text, \ - *-product-*-jdk_tools1, \ - *-product-*-jdk_tools2, \ - *-product-*-jdk_util +# Default jdk test targets in test/Makefile (no fastdebug & limited c2) +jprt.make.rule.default.test.targets= \ + \ + solaris_sparc_5.10-product-c1-jdk_beans1, \ + solaris_sparcv9_5.10-product-c2-jdk_beans1, \ + solaris_i586_5.10-product-c1-jdk_beans1, \ + solaris_x64_5.10-product-c2-jdk_beans1, \ + linux_i586_2.6-product-{c1|c2}-jdk_beans1, \ + linux_x64_2.6-product-c2-jdk_beans1, \ + ${jprt.my.windows.i586}-product-c1-jdk_beans1, \ + windows_x64_5.2-product-c2-jdk_beans1, \ + \ + solaris_sparc_5.10-product-c1-jdk_io, \ + solaris_sparcv9_5.10-product-c2-jdk_io, \ + solaris_i586_5.10-product-c1-jdk_io, \ + solaris_x64_5.10-product-c2-jdk_io, \ + linux_i586_2.6-product-{c1|c2}-jdk_io, \ + linux_x64_2.6-product-c2-jdk_io, \ + ${jprt.my.windows.i586}-product-c1-jdk_io, \ + windows_x64_5.2-product-c2-jdk_io, \ + \ + solaris_sparc_5.10-product-c1-jdk_lang, \ + solaris_sparcv9_5.10-product-c2-jdk_lang, \ + solaris_i586_5.10-product-c1-jdk_lang, \ + solaris_x64_5.10-product-c2-jdk_lang, \ + linux_i586_2.6-product-{c1|c2}-jdk_lang, \ + linux_x64_2.6-product-c2-jdk_lang, \ + ${jprt.my.windows.i586}-product-c1-jdk_lang, \ + windows_x64_5.2-product-c2-jdk_lang, \ + \ + solaris_sparc_5.10-product-c1-jdk_math, \ + solaris_sparcv9_5.10-product-c2-jdk_math, \ + solaris_i586_5.10-product-c1-jdk_math, \ + solaris_x64_5.10-product-c2-jdk_math, \ + linux_i586_2.6-product-{c1|c2}-jdk_math, \ + linux_x64_2.6-product-c2-jdk_math, \ + ${jprt.my.windows.i586}-product-c1-jdk_math, \ + windows_x64_5.2-product-c2-jdk_math, \ + \ + solaris_sparc_5.10-product-c1-jdk_misc, \ + solaris_sparcv9_5.10-product-c2-jdk_misc, \ + solaris_i586_5.10-product-c1-jdk_misc, \ + solaris_x64_5.10-product-c2-jdk_misc, \ + linux_i586_2.6-product-{c1|c2}-jdk_misc, \ + linux_x64_2.6-product-c2-jdk_misc, \ + ${jprt.my.windows.i586}-product-c1-jdk_misc, \ + windows_x64_5.2-product-c2-jdk_misc, \ + \ + solaris_sparc_5.10-product-c1-jdk_net, \ + solaris_sparcv9_5.10-product-c2-jdk_net, \ + solaris_i586_5.10-product-c1-jdk_net, \ + solaris_x64_5.10-product-c2-jdk_net, \ + linux_i586_2.6-product-{c1|c2}-jdk_net, \ + linux_x64_2.6-product-c2-jdk_net, \ + ${jprt.my.windows.i586}-product-c1-jdk_net, \ + windows_x64_5.2-product-c2-jdk_net, \ + \ + solaris_sparc_5.10-product-c1-jdk_nio1, \ + solaris_sparcv9_5.10-product-c2-jdk_nio1, \ + solaris_i586_5.10-product-c1-jdk_nio1, \ + solaris_x64_5.10-product-c2-jdk_nio1, \ + linux_i586_2.6-product-{c1|c2}-jdk_nio1, \ + linux_x64_2.6-product-c2-jdk_nio1, \ + ${jprt.my.windows.i586}-product-c1-jdk_nio1, \ + windows_x64_5.2-product-c2-jdk_nio1, \ + \ + solaris_sparc_5.10-product-c1-jdk_nio2, \ + solaris_sparcv9_5.10-product-c2-jdk_nio2, \ + solaris_i586_5.10-product-c1-jdk_nio2, \ + solaris_x64_5.10-product-c2-jdk_nio2, \ + linux_i586_2.6-product-{c1|c2}-jdk_nio2, \ + linux_x64_2.6-product-c2-jdk_nio2, \ + ${jprt.my.windows.i586}-product-c1-jdk_nio2, \ + windows_x64_5.2-product-c2-jdk_nio2, \ + \ + solaris_sparc_5.10-product-c1-jdk_nio3, \ + solaris_sparcv9_5.10-product-c2-jdk_nio3, \ + solaris_i586_5.10-product-c1-jdk_nio3, \ + solaris_x64_5.10-product-c2-jdk_nio3, \ + linux_i586_2.6-product-{c1|c2}-jdk_nio3, \ + linux_x64_2.6-product-c2-jdk_nio3, \ + ${jprt.my.windows.i586}-product-c1-jdk_nio3, \ + windows_x64_5.2-product-c2-jdk_nio3, \ + \ + solaris_sparc_5.10-product-c1-jdk_security1, \ + solaris_sparcv9_5.10-product-c2-jdk_security1, \ + solaris_i586_5.10-product-c1-jdk_security1, \ + solaris_x64_5.10-product-c2-jdk_security1, \ + linux_i586_2.6-product-{c1|c2}-jdk_security1, \ + linux_x64_2.6-product-c2-jdk_security1, \ + ${jprt.my.windows.i586}-product-c1-jdk_security1, \ + windows_x64_5.2-product-c2-jdk_security1, \ + \ + solaris_sparc_5.10-product-c1-jdk_text, \ + solaris_sparcv9_5.10-product-c2-jdk_text, \ + solaris_i586_5.10-product-c1-jdk_text, \ + solaris_x64_5.10-product-c2-jdk_text, \ + linux_i586_2.6-product-{c1|c2}-jdk_text, \ + linux_x64_2.6-product-c2-jdk_text, \ + ${jprt.my.windows.i586}-product-c1-jdk_text, \ + windows_x64_5.2-product-c2-jdk_text, \ + \ + solaris_sparc_5.10-product-c1-jdk_tools1, \ + solaris_sparcv9_5.10-product-c2-jdk_tools1, \ + solaris_i586_5.10-product-c1-jdk_tools1, \ + solaris_x64_5.10-product-c2-jdk_tools1, \ + linux_i586_2.6-product-{c1|c2}-jdk_tools1, \ + linux_x64_2.6-product-c2-jdk_tools1, \ + ${jprt.my.windows.i586}-product-c1-jdk_tools1, \ + windows_x64_5.2-product-c2-jdk_tools1, \ + \ + solaris_sparc_5.10-product-c1-jdk_util, \ + solaris_sparcv9_5.10-product-c2-jdk_util, \ + solaris_i586_5.10-product-c1-jdk_util, \ + solaris_x64_5.10-product-c2-jdk_util, \ + linux_i586_2.6-product-{c1|c2}-jdk_util, \ + linux_x64_2.6-product-c2-jdk_util, \ + ${jprt.my.windows.i586}-product-c1-jdk_util, \ + windows_x64_5.2-product-c2-jdk_util -# Some of these are crashing Xvfb or windows manager, need dedicated DISPLAY per test batch -jprt2.make.rule.test.targets= \ - *-product-*-jdk_awt, \ - *-product-*-jdk_rmi, \ - *-product-*-jdk_swing, \ +# All jdk test targets in test/Makefile (still no fastdebug & limited c2) +jprt.make.rule.all.test.targets= \ + \ + ${jprt.make.rule.default.test.targets}, \ + \ + solaris_sparc_5.10-product-c1-jdk_awt, \ + solaris_sparcv9_5.10-product-c2-jdk_awt, \ + solaris_i586_5.10-product-c1-jdk_awt, \ + solaris_x64_5.10-product-c2-jdk_awt, \ + linux_i586_2.6-product-{c1|c2}-jdk_awt, \ + linux_x64_2.6-product-c2-jdk_awt, \ + ${jprt.my.windows.i586}-product-c1-jdk_awt, \ + windows_x64_5.2-product-c2-jdk_awt, \ + \ + solaris_sparc_5.10-product-c1-jdk_beans2, \ + solaris_sparcv9_5.10-product-c2-jdk_beans2, \ + solaris_i586_5.10-product-c1-jdk_beans2, \ + solaris_x64_5.10-product-c2-jdk_beans2, \ + linux_i586_2.6-product-{c1|c2}-jdk_beans2, \ + linux_x64_2.6-product-c2-jdk_beans2, \ + ${jprt.my.windows.i586}-product-c1-jdk_beans2, \ + windows_x64_5.2-product-c2-jdk_beans2, \ + \ + solaris_sparc_5.10-product-c1-jdk_beans3, \ + solaris_sparcv9_5.10-product-c2-jdk_beans3, \ + solaris_i586_5.10-product-c1-jdk_beans3, \ + solaris_x64_5.10-product-c2-jdk_beans3, \ + linux_i586_2.6-product-{c1|c2}-jdk_beans3, \ + linux_x64_2.6-product-c2-jdk_beans3, \ + ${jprt.my.windows.i586}-product-c1-jdk_beans3, \ + windows_x64_5.2-product-c2-jdk_beans3, \ + \ + solaris_sparc_5.10-product-c1-jdk_management1, \ + solaris_sparcv9_5.10-product-c2-jdk_management1, \ + solaris_i586_5.10-product-c1-jdk_management1, \ + solaris_x64_5.10-product-c2-jdk_management1, \ + linux_i586_2.6-product-{c1|c2}-jdk_management1, \ + linux_x64_2.6-product-c2-jdk_management1, \ + ${jprt.my.windows.i586}-product-c1-jdk_management1, \ + windows_x64_5.2-product-c2-jdk_management1, \ + \ + solaris_sparc_5.10-product-c1-jdk_management2, \ + solaris_sparcv9_5.10-product-c2-jdk_management2, \ + solaris_i586_5.10-product-c1-jdk_management2, \ + solaris_x64_5.10-product-c2-jdk_management2, \ + linux_i586_2.6-product-{c1|c2}-jdk_management2, \ + linux_x64_2.6-product-c2-jdk_management2, \ + ${jprt.my.windows.i586}-product-c1-jdk_management2, \ + windows_x64_5.2-product-c2-jdk_management2, \ + \ + solaris_sparc_5.10-product-c1-jdk_rmi, \ + solaris_sparcv9_5.10-product-c2-jdk_rmi, \ + solaris_i586_5.10-product-c1-jdk_rmi, \ + solaris_x64_5.10-product-c2-jdk_rmi, \ + linux_i586_2.6-product-{c1|c2}-jdk_rmi, \ + linux_x64_2.6-product-c2-jdk_rmi, \ + ${jprt.my.windows.i586}-product-c1-jdk_rmi, \ + windows_x64_5.2-product-c2-jdk_rmi, \ + \ + solaris_sparc_5.10-product-c1-jdk_security2, \ + solaris_sparcv9_5.10-product-c2-jdk_security2, \ + solaris_i586_5.10-product-c1-jdk_security2, \ + solaris_x64_5.10-product-c2-jdk_security2, \ + linux_i586_2.6-product-{c1|c2}-jdk_security2, \ + linux_x64_2.6-product-c2-jdk_security2, \ + ${jprt.my.windows.i586}-product-c1-jdk_security2, \ + windows_x64_5.2-product-c2-jdk_security2, \ + \ + solaris_sparc_5.10-product-c1-jdk_security3, \ + solaris_sparcv9_5.10-product-c2-jdk_security3, \ + solaris_i586_5.10-product-c1-jdk_security3, \ + solaris_x64_5.10-product-c2-jdk_security3, \ + linux_i586_2.6-product-{c1|c2}-jdk_security3, \ + linux_x64_2.6-product-c2-jdk_security3, \ + ${jprt.my.windows.i586}-product-c1-jdk_security3, \ + windows_x64_5.2-product-c2-jdk_security3, \ + \ + solaris_sparc_5.10-product-c1-jdk_swing, \ + solaris_sparcv9_5.10-product-c2-jdk_swing, \ + solaris_i586_5.10-product-c1-jdk_swing, \ + solaris_x64_5.10-product-c2-jdk_swing, \ + linux_i586_2.6-product-{c1|c2}-jdk_swing, \ + linux_x64_2.6-product-c2-jdk_swing, \ + ${jprt.my.windows.i586}-product-c1-jdk_swing, \ + windows_x64_5.2-product-c2-jdk_swing, \ + \ + solaris_sparc_5.10-product-c1-jdk_tools2, \ + solaris_sparcv9_5.10-product-c2-jdk_tools2, \ + solaris_i586_5.10-product-c1-jdk_tools2, \ + solaris_x64_5.10-product-c2-jdk_tools2, \ + linux_i586_2.6-product-{c1|c2}-jdk_tools2, \ + linux_x64_2.6-product-c2-jdk_tools2, \ + ${jprt.my.windows.i586}-product-c1-jdk_tools2, \ + windows_x64_5.2-product-c2-jdk_tools2 + +# Select list to use (allow for testset to be empty too) +jprt.make.rule..test.targets=${jprt.make.rule.default.test.targets} +jprt.make.rule.test.targets=${jprt.make.rule.${jprt.my.test.set}.test.targets} # Directories to be excluded from the source bundles jprt.bundle.exclude.src.dirs=build dist webrev diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/mkdemo/Makefile --- a/jdk/make/mkdemo/Makefile Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/make/mkdemo/Makefile Tue Oct 26 13:45:25 2010 -0700 @@ -31,7 +31,7 @@ PRODUCT = demos include $(BUILDDIR)/common/Defs.gmk -SUBDIRS = jni +SUBDIRS = jni nio SUBDIRS_desktop = applets jfc SUBDIRS_management = management SUBDIRS_misc = scripting diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/mkdemo/nio/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/make/mkdemo/nio/Makefile Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,39 @@ +# +# Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute 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. +# + +# +# Makefile for building the jfc demos +# + +BUILDDIR = ../.. +PRODUCT = demos +include $(BUILDDIR)/common/Defs.gmk + +SUBDIRS = zipfs +include $(BUILDDIR)/common/Subdirs.gmk + +all build clean clobber:: + $(SUBDIRS-loop) + diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/mkdemo/nio/zipfs/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/make/mkdemo/nio/zipfs/Makefile Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,44 @@ +# +# Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute 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. +# + +# +# Makefile to build the ZipFileSystem demo. +# + +BUILDDIR = ../../.. +PRODUCT = demo/zipfs +DEMONAME = zipfs +include $(BUILDDIR)/common/Defs.gmk + +DEMO_ROOT = $(SHARE_SRC)/demo/nio/$(DEMONAME) +DEMO_TOPFILES = ./README.txt +DEMO_SRCDIR = $(DEMO_ROOT) +DEMO_DESTDIR = $(DEMODIR)/nio/$(DEMONAME) + +# +# Demo jar building rules. +# +include $(BUILDDIR)/common/Demo.gmk + diff -r 79caba0caf4f -r e0bc5b441d60 jdk/make/sun/cmm/lcms/Makefile --- a/jdk/make/sun/cmm/lcms/Makefile Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/make/sun/cmm/lcms/Makefile Tue Oct 26 13:45:25 2010 -0700 @@ -80,7 +80,12 @@ vpath %.c $(SHARE_SRC)/native/sun/java2d ifeq ($(PLATFORM), windows) -OTHER_CFLAGS += -DCMS_IS_WINDOWS_ -Dsqrtf=sqrt +OTHER_CFLAGS += -DCMS_IS_WINDOWS_ + +ifeq ($(COMPILER_VERSION), VS2003) +OTHER_CFLAGS += -Dsqrtf=sqrt +endif + OTHER_LDLIBS = $(OBJDIR)/../../../sun.awt/awt/$(OBJDIRNAME)/awt.lib OTHER_INCLUDES += -I$(SHARE_SRC)/native/sun/java2d \ -I$(SHARE_SRC)/native/sun/awt/debug diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java --- a/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java Tue Oct 26 13:45:25 2010 -0700 @@ -525,7 +525,7 @@ iMatchColumns = new Vector(10); for(int i = 0; i < 10 ; i++) { - iMatchColumns.add(i,new Integer(-1)); + iMatchColumns.add(i,Integer.valueOf(-1)); } strMatchColumns = new Vector(10); @@ -889,7 +889,12 @@ success = false; } else { tWriter = (TransactionalWriter)rowSetWriter; - ((CachedRowSetWriter)tWriter).commit(this, updateOnInsert); + if (tWriter instanceof CachedRowSetWriter) { + ((CachedRowSetWriter)tWriter).commit(this, updateOnInsert); + } else { + tWriter.commit(); + } + success = true; } } @@ -1294,7 +1299,7 @@ tMap = new TreeMap(); for (int i = 0; iJoinRowSet @@ -550,7 +552,7 @@ // This 'if' will be removed after all joins are implemented. throw new SQLException(resBundle.handleGetObject("joinrowsetimpl.notsupported").toString()); } else { - Integer Intgr = new Integer(JoinRowSet.INNER_JOIN); + Integer Intgr = Integer.valueOf(JoinRowSet.INNER_JOIN); vecJoinType.add(Intgr); } } else { @@ -874,8 +876,8 @@ String strWhereClause = "Select "; String whereClause; - String tabName= null; - String strTabName = null; + String tabName= ""; + String strTabName = ""; int sz,cols; int j; CachedRowSetImpl crs; @@ -889,8 +891,6 @@ // tableNameX.(rowsetX.getMatchColumnName()) == // tableNameZ.(rowsetZ.getMatchColumnName())); - tabName = new String(); - strTabName = new String(); sz = vecRowSetsInJOIN.size(); for(int i=0;iString detailing the vendor name of this * SyncProvider diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/com/sun/rowset/providers/RIXMLProvider.java --- a/jdk/src/share/classes/com/sun/rowset/providers/RIXMLProvider.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/providers/RIXMLProvider.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,7 +85,7 @@ /** * The vendor name of this SyncProvider implementation. */ - private String vendorName = "Sun Microsystems Inc."; + private String vendorName = "Oracle Corporation"; /** * The version number of this SyncProvider implementation. diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/com/sun/servicetag/Installer.java --- a/jdk/src/share/classes/com/sun/servicetag/Installer.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/com/sun/servicetag/Installer.java Tue Oct 26 13:45:25 2010 -0700 @@ -43,7 +43,8 @@ "servicetag.dir.path"; private static String SVCTAG_ENABLE_REGISTRATION = "servicetag.registration.enabled"; - private final static String SUN_VENDOR = "Sun Microsystems"; + private final static String ORACLE = "Oracle"; + private final static String SUN = "Sun Microsystems"; private final static String REGISTRATION_XML = "registration.xml"; private final static String SERVICE_TAG_FILE = "servicetag"; private final static String REGISTRATION_HTML_NAME = "register"; @@ -84,9 +85,10 @@ // Implementation of ServiceTag.getJavaServiceTag(String) method static ServiceTag getJavaServiceTag(String source) throws IOException { - if (!System.getProperty("java.vendor").startsWith(SUN_VENDOR)) { + String vendor = System.getProperty("java.vendor", ""); + if (!vendor.startsWith(SUN) && !vendor.startsWith(ORACLE)) { // Products bundling this implementation may run on - // Mac OS which is not a Sun JDK + // Mac OS which is not a Sun/Oracle JDK return null; } boolean cleanup = false; @@ -365,7 +367,7 @@ props.getProperty("servicetag.parent.name"), props.getProperty("servicetag.parent.urn"), getProductDefinedId(), - SUN_VENDOR, + System.getProperty("java.vendor"), System.getProperty("os.arch"), getZoneName(), svcTagSource); diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/com/sun/servicetag/RegistrationData.java --- a/jdk/src/share/classes/com/sun/servicetag/RegistrationData.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/com/sun/servicetag/RegistrationData.java Tue Oct 26 13:45:25 2010 -0700 @@ -80,12 +80,12 @@ * * systemManufacturer * System manufacturer - * e.g. Sun Microsystems + * e.g. Oracle Corporation * * * cpuManufacturer * CPU manufacturer - * e.g. Sun Microsystems + * e.g. Oracle Corporation * * * serialNumber diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/com/sun/servicetag/Registry.java --- a/jdk/src/share/classes/com/sun/servicetag/Registry.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/com/sun/servicetag/Registry.java Tue Oct 26 13:45:25 2010 -0700 @@ -90,7 +90,7 @@ stclient = getWindowsStClientFile(); } else { if (isVerbose()) { - System.out.println("Running on non-Sun JDK"); + System.out.println("Running on unsupported platform"); } } initialized = true; diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java --- a/jdk/src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java Tue Oct 26 13:45:25 2010 -0700 @@ -44,6 +44,7 @@ * Solaris implementation of the SystemEnvironment class. */ class SolarisSystemEnvironment extends SystemEnvironment { + private static final String ORACLE = "Oracle Corporation"; SolarisSystemEnvironment() { setHostId(getCommandOutput("/usr/bin/hostid")); setSystemModel(getCommandOutput("/usr/bin/uname", "-i")); @@ -59,7 +60,7 @@ private String getSolarisCpuManufacturer() { // not fully accurate, this could be another manufacturer (fujitsu for example) if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) { - return "Sun Microsystems, Inc"; + return ORACLE; } // if we're here, then we'll try smbios (type 4) @@ -73,7 +74,7 @@ private String getSolarisSystemManufacturer() { // not fully accurate, this could be another manufacturer (fujitsu for example) if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) { - return "Sun Microsystems, Inc"; + return ORACLE; } // if we're here, then we'll try smbios (type 1) @@ -117,7 +118,7 @@ // ID SIZE TYPE // 1 150 SMB_TYPE_SYSTEM (system information) // - // Manufacturer: Sun Microsystems + // Manufacturer: Oracle Corporation // Product: Sun Fire X4600 // Version: To Be Filled By O.E.M. // Serial Number: 00:14:4F:45:0C:2A diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/awt/Dialog.java --- a/jdk/src/share/classes/java/awt/Dialog.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/awt/Dialog.java Tue Oct 26 13:45:25 2010 -0700 @@ -1068,7 +1068,7 @@ modalityPushed(); try { EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); - secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 5000); + secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0); if (!secondaryLoop.enter()) { secondaryLoop = null; } diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/awt/KeyboardFocusManager.java --- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Tue Oct 26 13:45:25 2010 -0700 @@ -142,6 +142,9 @@ public void removeLastFocusRequest(Component heavyweight) { KeyboardFocusManager.removeLastFocusRequest(heavyweight); } + public void setMostRecentFocusOwner(Window window, Component component) { + KeyboardFocusManager.setMostRecentFocusOwner(window, component); + } } ); } diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/awt/event/ActionEvent.java --- a/jdk/src/share/classes/java/awt/event/ActionEvent.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/awt/event/ActionEvent.java Tue Oct 26 13:45:25 2010 -0700 @@ -51,7 +51,7 @@ * in the range from {@code ACTION_FIRST} to {@code ACTION_LAST}. * * @see ActionListener - * @see Tutorial: Java 1.1 Event Model + * @see Tutorial: How to Write an Action Listener * * @author Carl Quinn * @since 1.1 diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/awt/image/SampleModel.java --- a/jdk/src/share/classes/java/awt/image/SampleModel.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/awt/image/SampleModel.java Tue Oct 26 13:45:25 2010 -0700 @@ -937,14 +937,22 @@ int iArray[], DataBuffer data) { int pixels[]; int Offset=0; + int x1 = x + w; + int y1 = y + h; + + if (x < 0 || x1 < x || x1 > width || + y < 0 || y1 < y || y1 > height) + { + throw new ArrayIndexOutOfBoundsException("Invalid coordinates."); + } if (iArray != null) pixels = iArray; else pixels = new int[w * h]; - for(int i=y; i<(h+y); i++) { - for (int j=x; j<(w+x); j++) { + for(int i=y; i width || + y < 0 || y1 < y || y1 > height) + { + throw new ArrayIndexOutOfBoundsException("Invalid coordinates"); + } if (fArray != null) pixels = fArray; else pixels = new float[w * h]; - for (int i=y; i<(h+y); i++) { - for (int j=x; j<(w+x); j++) { + for (int i=y; i width || + y < 0 || y1 < y || y1 > height) + { + throw new ArrayIndexOutOfBoundsException("Invalid coordinates"); + } if (dArray != null) pixels = dArray; else pixels = new double[w * h]; - for (int i=y; i<(y+h); i++) { - for (int j=x; j<(x+w); j++) { + for (int i=y; i type, String name, int args) { - for (Method method : type.getMethods()) { - if (method.getName().equals(name) && (args == method.getParameterTypes().length)) { - try { - return MethodFinder.findAccessibleMethod(method); + /** + * Internal support for finding a target methodName with a given + * parameter list on a given class. + */ + private static Method internalFindMethod(Class start, String methodName, + int argCount, Class args[]) { + // For overriden methods we need to find the most derived version. + // So we start with the given class and walk up the superclass chain. + + Method method = null; + + for (Class cl = start; cl != null; cl = cl.getSuperclass()) { + Method methods[] = getPublicDeclaredMethods(cl); + for (int i = 0; i < methods.length; i++) { + method = methods[i]; + if (method == null) { + continue; } - catch (NoSuchMethodException exception) { - // continue search for a method with the specified count of parameters + + // make sure method signature matches. + Class params[] = FeatureDescriptor.getParameterTypes(start, method); + if (method.getName().equals(methodName) && + params.length == argCount) { + if (args != null) { + boolean different = false; + if (argCount > 0) { + for (int j = 0; j < argCount; j++) { + if (params[j] != args[j]) { + different = true; + continue; + } + } + if (different) { + continue; + } + } + } + return method; } } } - return null; + method = null; + + // Now check any inherited interfaces. This is necessary both when + // the argument class is itself an interface, and when the argument + // class is an abstract class. + Class ifcs[] = start.getInterfaces(); + for (int i = 0 ; i < ifcs.length; i++) { + // Note: The original implementation had both methods calling + // the 3 arg method. This is preserved but perhaps it should + // pass the args array instead of null. + method = internalFindMethod(ifcs[i], methodName, argCount, null); + if (method != null) { + break; + } + } + return method; } - static Method findInstanceMethod(Class type, String name, Class... args) { - try { - return MethodFinder.findInstanceMethod(type, name, args); - } - catch (NoSuchMethodException exception) { + /** + * Find a target methodName on a given class. + */ + static Method findMethod(Class cls, String methodName, int argCount) { + return findMethod(cls, methodName, argCount, null); + } + + /** + * Find a target methodName with specific parameter list on a given class. + *

+ * Used in the contructors of the EventSetDescriptor, + * PropertyDescriptor and the IndexedPropertyDescriptor. + *

+ * @param cls The Class object on which to retrieve the method. + * @param methodName Name of the method. + * @param argCount Number of arguments for the desired method. + * @param args Array of argument types for the method. + * @return the method or null if not found + */ + static Method findMethod(Class cls, String methodName, int argCount, + Class args[]) { + if (methodName == null) { return null; } + return internalFindMethod(cls, methodName, argCount, args); } /** diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/beans/MethodDescriptor.java --- a/jdk/src/share/classes/java/beans/MethodDescriptor.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/beans/MethodDescriptor.java Tue Oct 26 13:45:25 2010 -0700 @@ -90,13 +90,13 @@ // Find methods for up to 2 params. We are guessing here. // This block should never execute unless the classloader // that loaded the argument classes disappears. - method = Introspector.findMethod(cls, name, i); + method = Introspector.findMethod(cls, name, i, null); if (method != null) { break; } } } else { - method = Statement.getMethod(cls, name, params); + method = Introspector.findMethod(cls, name, params.length, params); } setMethod(method); } diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/beans/PropertyDescriptor.java --- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java Tue Oct 26 13:45:25 2010 -0700 @@ -112,7 +112,8 @@ // If this class or one of its base classes allow PropertyChangeListener, // then we assume that any properties we discover are "bound". // See Introspector.getTargetPropertyInfo() method. - this.bound = null != Introspector.findInstanceMethod(beanClass, "addPropertyChangeListener", PropertyChangeListener.class); + Class[] args = { PropertyChangeListener.class }; + this.bound = null != Introspector.findMethod(beanClass, "addPropertyChangeListener", args.length, args); } /** @@ -223,10 +224,10 @@ // property type is. For booleans, there can be "is" and "get" // methods. If an "is" method exists, this is the official // reader method so look for this one first. - readMethod = Introspector.findInstanceMethod(cls, readMethodName); + readMethod = Introspector.findMethod(cls, readMethodName, 0); if (readMethod == null) { readMethodName = Introspector.GET_PREFIX + getBaseName(); - readMethod = Introspector.findInstanceMethod(cls, readMethodName); + readMethod = Introspector.findMethod(cls, readMethodName, 0); } try { setReadMethod(readMethod); @@ -291,7 +292,8 @@ writeMethodName = Introspector.SET_PREFIX + getBaseName(); } - writeMethod = Introspector.findInstanceMethod(cls, writeMethodName, type); + Class[] args = (type == null) ? null : new Class[] { type }; + writeMethod = Introspector.findMethod(cls, writeMethodName, 1, args); if (writeMethod != null) { if (!writeMethod.getReturnType().equals(void.class)) { writeMethod = null; diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/lang/System.java --- a/jdk/src/share/classes/java/lang/System.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/lang/System.java Tue Oct 26 13:45:25 2010 -0700 @@ -1101,22 +1101,12 @@ lineSeparator = props.getProperty("line.separator"); sun.misc.Version.init(); - // Workaround until DownloadManager initialization is revisited. - // Make JavaLangAccess available early enough for internal - // Shutdown hooks to be registered - setJavaLangAccess(); - // Gets and removes system properties that configure the Integer // cache used to support the object identity semantics of autoboxing. // At this time, the size of the cache may be controlled by the // vm option -XX:AutoBoxCacheMax=. Integer.getAndRemoveCacheProperties(); - // Load the zip library now in order to keep java.util.zip.ZipFile - // from trying to use itself to load this library later. - loadLibrary("zip"); - - FileInputStream fdIn = new FileInputStream(FileDescriptor.in); FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out); FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err); @@ -1124,6 +1114,10 @@ setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128), true)); setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128), true)); + // Load the zip library now in order to keep java.util.zip.ZipFile + // from trying to use itself to load this library later. + loadLibrary("zip"); + // Setup Java signal handlers for HUP, TERM, and INT (where available). Terminator.setup(); @@ -1153,6 +1147,9 @@ // way as other threads; we must do it ourselves here. Thread current = Thread.currentThread(); current.getThreadGroup().add(current); + + // register shared secrets + setJavaLangAccess(); } private static void setJavaLangAccess() { diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/net/InetAddress.java --- a/jdk/src/share/classes/java/net/InetAddress.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/net/InetAddress.java Tue Oct 26 13:45:25 2010 -0700 @@ -677,19 +677,20 @@ static InetAddressImpl impl; - private static HashMap lookupTable = new HashMap(); + private static HashMap lookupTable + = new HashMap(); /** * Represents a cache entry */ static final class CacheEntry { - CacheEntry(Object address, long expiration) { - this.address = address; + CacheEntry(InetAddress[] addresses, long expiration) { + this.addresses = addresses; this.expiration = expiration; } - Object address; + InetAddress[] addresses; long expiration; } @@ -698,7 +699,7 @@ * at creation time. */ static final class Cache { - private LinkedHashMap cache; + private LinkedHashMap cache; private Type type; enum Type {Positive, Negative}; @@ -708,7 +709,7 @@ */ public Cache(Type type) { this.type = type; - cache = new LinkedHashMap(); + cache = new LinkedHashMap(); } private int getPolicy() { @@ -724,7 +725,7 @@ * entry then for this host then the entry will be * replaced. */ - public Cache put(String host, Object address) { + public Cache put(String host, InetAddress[] addresses) { int policy = getPolicy(); if (policy == InetAddressCachePolicy.NEVER) { return this; @@ -736,12 +737,10 @@ // As we iterate in insertion order we can // terminate when a non-expired entry is found. - LinkedList expired = new LinkedList(); - Iterator i = cache.keySet().iterator(); + LinkedList expired = new LinkedList(); long now = System.currentTimeMillis(); - while (i.hasNext()) { - String key = (String)i.next(); - CacheEntry entry = (CacheEntry)cache.get(key); + for (String key : cache.keySet()) { + CacheEntry entry = cache.get(key); if (entry.expiration >= 0 && entry.expiration < now) { expired.add(key); @@ -750,9 +749,8 @@ } } - i = expired.iterator(); - while (i.hasNext()) { - cache.remove(i.next()); + for (String key : expired) { + cache.remove(key); } } @@ -766,7 +764,7 @@ } else { expiration = System.currentTimeMillis() + (policy * 1000); } - CacheEntry entry = new CacheEntry(address, expiration); + CacheEntry entry = new CacheEntry(addresses, expiration); cache.put(host, entry); return this; } @@ -780,7 +778,7 @@ if (policy == InetAddressCachePolicy.NEVER) { return null; } - CacheEntry entry = (CacheEntry)cache.get(host); + CacheEntry entry = cache.get(host); // check if entry has expired if (entry != null && policy != InetAddressCachePolicy.FOREVER) { @@ -814,42 +812,41 @@ } /* - * Cache the given hostname and address. + * Cache the given hostname and addresses. */ - private static void cacheAddress(String hostname, Object address, - boolean success) { + private static void cacheAddresses(String hostname, + InetAddress[] addresses, + boolean success) { hostname = hostname.toLowerCase(); synchronized (addressCache) { cacheInitIfNeeded(); if (success) { - addressCache.put(hostname, address); + addressCache.put(hostname, addresses); } else { - negativeCache.put(hostname, address); + negativeCache.put(hostname, addresses); } } } /* * Lookup hostname in cache (positive & negative cache). If - * found return address, null if not found. + * found return addresses, null if not found. */ - private static Object getCachedAddress(String hostname) { + private static InetAddress[] getCachedAddresses(String hostname) { hostname = hostname.toLowerCase(); // search both positive & negative caches synchronized (addressCache) { - CacheEntry entry; - cacheInitIfNeeded(); - entry = addressCache.get(hostname); + CacheEntry entry = addressCache.get(hostname); if (entry == null) { entry = negativeCache.get(hostname); } if (entry != null) { - return entry.address; + return entry.addresses; } } @@ -911,7 +908,7 @@ static { // create the impl - impl = (new InetAddressImplFactory()).create(); + impl = InetAddressImplFactory.create(); // get name service if provided and requested String provider = null;; @@ -931,7 +928,7 @@ } // if not designate any name services provider, - // creat a default one + // create a default one if (nameServices.size() == 0) { NameService ns = createNSProvider("default"); nameServices.add(ns); @@ -939,7 +936,7 @@ } /** - * Create an InetAddress based on the provided host name and IP address + * Creates an InetAddress based on the provided host name and IP address. * No name service is checked for the validity of the address. * *

The host name can either be a machine name, such as @@ -1067,13 +1064,13 @@ boolean ipv6Expected = false; if (host.charAt(0) == '[') { - // This is supposed to be an IPv6 litteral + // This is supposed to be an IPv6 literal if (host.length() > 2 && host.charAt(host.length()-1) == ']') { host = host.substring(1, host.length() -1); ipv6Expected = true; } else { // This was supposed to be a IPv6 address, but it's not! - throw new UnknownHostException(host); + throw new UnknownHostException(host + ": invalid IPv6 address"); } } @@ -1180,8 +1177,6 @@ throws UnknownHostException { /* If it gets here it is presumed to be a hostname */ /* Cache.get can return: null, unknownAddress, or InetAddress[] */ - Object obj = null; - Object objcopy = null; /* make sure the connection to the host is allowed, before we * give out a hostname @@ -1193,26 +1188,23 @@ } } - obj = getCachedAddress(host); + InetAddress[] addresses = getCachedAddresses(host); /* If no entry in cache, then do the host lookup */ - if (obj == null) { - obj = getAddressFromNameService(host); + if (addresses == null) { + addresses = getAddressesFromNameService(host); } - if (obj == unknown_array) + if (addresses == unknown_array) throw new UnknownHostException(host); - /* Make a copy of the InetAddress array */ - objcopy = ((InetAddress [])obj).clone(); - - return (InetAddress [])objcopy; + return addresses.clone(); } - private static Object getAddressFromNameService(String host) + private static InetAddress[] getAddressesFromNameService(String host) throws UnknownHostException { - Object obj = null; + InetAddress[] addresses = null; boolean success = false; UnknownHostException ex = null; @@ -1226,16 +1218,16 @@ // would be blocked until the host is removed // from the lookupTable. Then this thread // should try to look up the addressCache. - // i) if it found the address in the + // i) if it found the addresses in the // addressCache, checkLookupTable() would - // return the address. - // ii) if it didn't find the address in the + // return the addresses. + // ii) if it didn't find the addresses in the // addressCache for any reason, // it should add the host in the // lookupTable and return null so the // following code would do a lookup itself. - if ((obj = checkLookupTable(host)) == null) { - // This is the first thread which looks up the address + if ((addresses = checkLookupTable(host)) == null) { + // This is the first thread which looks up the addresses // this host or the cache entry for this host has been // expired so this thread should do the lookup. for (NameService nameService : nameServices) { @@ -1246,26 +1238,26 @@ * allocating space when the lookup fails. */ - obj = nameService.lookupAllHostAddr(host); + addresses = nameService.lookupAllHostAddr(host); success = true; break; } catch (UnknownHostException uhe) { if (host.equalsIgnoreCase("localhost")) { InetAddress[] local = new InetAddress[] { impl.loopbackAddress() }; - obj = local; + addresses = local; success = true; break; } else { - obj = unknown_array; + addresses = unknown_array; success = false; ex = uhe; } } } - // Cache the address. - cacheAddress(host, obj, success); + // Cache the addresses. + cacheAddresses(host, addresses, success); // Delete the host from the lookupTable, and // notify all threads waiting for the monitor // for lookupTable. @@ -1274,13 +1266,13 @@ throw ex; } - return obj; + return addresses; } - private static Object checkLookupTable(String host) { - // make sure obj is null. - Object obj = null; + private static InetAddress[] checkLookupTable(String host) { + // make sure addresses is null. + InetAddress[] addresses = null; synchronized (lookupTable) { // If the host isn't in the lookupTable, add it in the @@ -1288,11 +1280,11 @@ // the lookup. if (lookupTable.containsKey(host) == false) { lookupTable.put(host, null); - return obj; + return addresses; } // If the host is in the lookupTable, it means that another - // thread is trying to look up the address of this host. + // thread is trying to look up the addresses of this host. // This thread should wait. while (lookupTable.containsKey(host)) { try { @@ -1302,18 +1294,18 @@ } } - // The other thread has finished looking up the address of - // the host. This thread should retry to get the address - // from the addressCache. If it doesn't get the address from - // the cache, it will try to look up the address itself. - obj = getCachedAddress(host); - if (obj == null) { + // The other thread has finished looking up the addresses of + // the host. This thread should retry to get the addresses + // from the addressCache. If it doesn't get the addresses from + // the cache, it will try to look up the addresses itself. + addresses = getCachedAddresses(host); + if (addresses == null) { synchronized (lookupTable) { lookupTable.put(host, null); } } - return obj; + return addresses; } private static void updateLookupTable(String host) { @@ -1396,15 +1388,20 @@ cachedLocalHost = null; } - // we are calling getAddressFromNameService directly + // we are calling getAddressesFromNameService directly // to avoid getting localHost from cache if (ret == null) { InetAddress[] localAddrs; try { localAddrs = - (InetAddress[]) InetAddress.getAddressFromNameService(local); + InetAddress.getAddressesFromNameService(local); } catch (UnknownHostException uhe) { - throw new UnknownHostException(local + ": " + uhe.getMessage()); + // Rethrow with a more informative error message. + UnknownHostException uhe2 = + new UnknownHostException(local + ": " + + uhe.getMessage()); + uhe2.initCause(uhe); + throw uhe2; } cachedLocalHost = localAddrs[0]; cacheTime = now; @@ -1434,8 +1431,8 @@ /* * Load and instantiate an underlying impl class */ - static Object loadImpl(String implName) { - Object impl; + static InetAddressImpl loadImpl(String implName) { + Object impl = null; /* * Property "impl.prefix" will be prepended to the classname @@ -1446,7 +1443,6 @@ */ String prefix = AccessController.doPrivileged( new GetPropertyAction("impl.prefix", "")); - impl = null; try { impl = Class.forName("java.net." + prefix + implName).newInstance(); } catch (ClassNotFoundException e) { @@ -1471,7 +1467,7 @@ } } - return impl; + return (InetAddressImpl) impl; } private void readObjectNoData (ObjectInputStream s) throws @@ -1498,13 +1494,8 @@ class InetAddressImplFactory { static InetAddressImpl create() { - Object o; - if (isIPv6Supported()) { - o = InetAddress.loadImpl("Inet6AddressImpl"); - } else { - o = InetAddress.loadImpl("Inet4AddressImpl"); - } - return (InetAddressImpl)o; + return InetAddress.loadImpl(isIPv6Supported() ? + "Inet6AddressImpl" : "Inet4AddressImpl"); } static native boolean isIPv6Supported(); diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/nio/file/FileSystemLoopException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/nio/file/FileSystemLoopException.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 java.nio.file; + +/** + * Checked exception thrown when a file system loop, or cycle, is encountered. + * + * @since 1.7 + * @see Files#walkFileTree + */ + +public class FileSystemLoopException + extends FileSystemException +{ + private static final long serialVersionUID = 4843039591949217617L; + + /** + * Constructs an instance of this class. + * + * @param file + * a string identifying the file causing the cycle or {@code null} if + * not known + */ + public FileSystemLoopException(String file) { + super(file); + } +} diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/nio/file/FileTreeWalker.java --- a/jdk/src/share/classes/java/nio/file/FileTreeWalker.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/nio/file/FileTreeWalker.java Tue Oct 26 13:45:25 2010 -0700 @@ -38,7 +38,6 @@ class FileTreeWalker { private final boolean followLinks; - private final boolean detectCycles; private final LinkOption[] linkOptions; private final FileVisitor visitor; private final int maxDepth; @@ -48,17 +47,15 @@ int maxDepth) { boolean fl = false; - boolean dc = false; for (FileVisitOption option: options) { + // will throw NPE if options contains null switch (option) { - case FOLLOW_LINKS : fl = true; break; - case DETECT_CYCLES : dc = true; break; + case FOLLOW_LINKS : fl = true; break; default: throw new AssertionError("Should not get here"); } } this.followLinks = fl; - this.detectCycles = fl | dc; this.linkOptions = (fl) ? new LinkOption[0] : new LinkOption[] { LinkOption.NOFOLLOW_LINKS }; this.visitor = visitor; @@ -68,13 +65,11 @@ /** * Walk file tree starting at the given file */ - void walk(Path start) { + void walk(Path start) throws IOException { FileVisitResult result = walk(start, 0, new ArrayList()); - if (result == null) { - throw new NullPointerException("Visitor returned 'null'"); - } + Objects.nonNull(result, "FileVisitor returned null"); } /** @@ -88,11 +83,8 @@ private FileVisitResult walk(Path file, int depth, List ancestors) + throws IOException { - // depth check - if (depth > maxDepth) - return FileVisitResult.CONTINUE; - // if attributes are cached then use them if possible BasicFileAttributes attrs = null; if ((depth > 0) && @@ -137,13 +129,13 @@ return visitor.visitFileFailed(file, exc); } - // file is not a directory so invoke visitFile method - if (!attrs.isDirectory()) { + // at maximum depth or file is not a directory + if (depth >= maxDepth || !attrs.isDirectory()) { return visitor.visitFile(file, attrs); } - // check for cycles - if (detectCycles) { + // check for cycles when following links + if (followLinks) { Object key = attrs.fileKey(); // if this directory and ancestor has a file key then we compare @@ -153,19 +145,23 @@ if (key != null && ancestorKey != null) { if (key.equals(ancestorKey)) { // cycle detected - return visitor.visitFile(file, attrs); + return visitor.visitFileFailed(file, + new FileSystemLoopException(file.toString())); } } else { + boolean isSameFile = false; try { - if (file.isSameFile(ancestor.file())) { - // cycle detected - return visitor.visitFile(file, attrs); - } + isSameFile = file.isSameFile(ancestor.file()); } catch (IOException x) { // ignore } catch (SecurityException x) { // ignore } + if (isSameFile) { + // cycle detected + return visitor.visitFileFailed(file, + new FileSystemLoopException(file.toString())); + } } } @@ -181,7 +177,7 @@ try { stream = file.newDirectoryStream(); } catch (IOException x) { - return visitor.preVisitDirectoryFailed(file, x); + return visitor.visitFileFailed(file, x); } catch (SecurityException x) { // ignore, as per spec return FileVisitResult.CONTINUE; @@ -192,20 +188,14 @@ // invoke preVisitDirectory and then visit each entry try { - result = visitor.preVisitDirectory(file); + result = visitor.preVisitDirectory(file, attrs); if (result != FileVisitResult.CONTINUE) { return result; } - // if an I/O occurs during iteration then a CME is thrown. We - // need to distinguish this from a CME thrown by the visitor. - boolean inAction = false; - try { for (Path entry: stream) { - inAction = true; result = walk(entry, depth+1, ancestors); - inAction = false; // returning null will cause NPE to be thrown if (result == null || result == FileVisitResult.TERMINATE) @@ -215,17 +205,9 @@ if (result == FileVisitResult.SKIP_SIBLINGS) break; } - } catch (ConcurrentModificationException x) { - // if CME thrown because the iteration failed then remember - // the IOException so that it is notified to postVisitDirectory - if (!inAction) { - // iteration failed - Throwable t = x.getCause(); - if (t instanceof IOException) - ioe = (IOException)t; - } - if (ioe == null) - throw x; + } catch (DirectoryIteratorException e) { + // IOException will be notified to postVisitDirectory + ioe = e.getCause(); } } finally { try { @@ -238,7 +220,7 @@ } finally { // remove key from trail if doing cycle detection - if (detectCycles) { + if (followLinks) { ancestors.remove(ancestors.size()-1); } } diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/nio/file/FileVisitOption.java --- a/jdk/src/share/classes/java/nio/file/FileVisitOption.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/nio/file/FileVisitOption.java Tue Oct 26 13:45:25 2010 -0700 @@ -37,9 +37,5 @@ /** * Follow symbolic links. */ - FOLLOW_LINKS, - /** - * Detect cycles in the file tree. - */ - DETECT_CYCLES; + FOLLOW_LINKS; } diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/nio/file/FileVisitor.java --- a/jdk/src/share/classes/java/nio/file/FileVisitor.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/nio/file/FileVisitor.java Tue Oct 26 13:45:25 2010 -0700 @@ -40,33 +40,28 @@ * Path start = ... * Files.walkFileTree(start, new SimpleFileVisitor<Path>() { * @Override - * public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { - * try { - * file.delete(); - * } catch (IOException exc) { - * // failed to delete, do error handling here - * } + * public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) + * throws IOException + * { + * file.delete(); * return FileVisitResult.CONTINUE; * } * @Override - * public FileVisitResult postVisitDirectory(Path dir, IOException e) { - * if (e == null) { - * try { - * dir.delete(); - * } catch (IOException exc) { - * // failed to delete, do error handling here - * } - * } else { + * public FileVisitResult postVisitDirectory(Path dir, IOException e) + * throws IOException + * { + * if (e != null) { * // directory iteration failed + * throw e; * } + * dir.delete(); * return FileVisitResult.CONTINUE; * } * }); * - *

Furthermore, suppose we want to copy a file tree rooted at a source - * directory to a target location. In that case, symbolic links should be - * followed and the target directory should be created before the entries in - * the directory are copied. + *

Furthermore, suppose we want to copy a file tree to a target location. + * In that case, symbolic links should be followed and the target directory + * should be created before the entries in the directory are copied. *

  *     final Path source = ...
  *     final Path target = ...
@@ -74,25 +69,21 @@
  *     Files.walkFileTree(source, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
  *         new SimpleFileVisitor<Path>() {
  *             @Override
- *             public FileVisitResult preVisitDirectory(Path dir) {
+ *             public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
+ *                 throws IOException
+ *             {
  *                 try {
  *                     dir.copyTo(target.resolve(source.relativize(dir)));
  *                 } catch (FileAlreadyExistsException e) {
  *                      // ignore
- *                 } catch (IOException e) {
- *                     // copy failed, do error handling here
- *                     // skip rest of directory and descendants
- *                     return SKIP_SUBTREE;
  *                 }
  *                 return CONTINUE;
  *             }
  *             @Override
- *             public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
- *                 try {
- *                     file.copyTo(target.resolve(source.relativize(file)));
- *                 } catch (IOException e) {
- *                     // copy failed, do error handling here
- *                 }
+ *             public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+ *                 throws IOException
+ *             {
+ *                 file.copyTo(target.resolve(source.relativize(file)));
  *                 return CONTINUE;
  *             }
  *         });
@@ -114,22 +105,16 @@
      *
      * @param   dir
      *          a reference to the directory
+     * @param   attrs
+     *          the directory's basic attributes
      *
      * @return  the visit result
+     *
+     * @throws  IOException
+     *          if an I/O error occurs
      */
-    FileVisitResult preVisitDirectory(T dir);
-
-    /**
-     * Invoked for a directory that could not be opened.
-     *
-     * @param   dir
-     *          a reference to the directory
-     * @param   exc
-     *          the I/O exception thrown from the attempt to open the directory
-     *
-     * @return  the visit result
-     */
-    FileVisitResult preVisitDirectoryFailed(T dir, IOException exc);
+    FileVisitResult preVisitDirectory(T dir, BasicFileAttributes attrs)
+        throws IOException;
 
     /**
      * Invoked for a file in a directory.
@@ -140,21 +125,30 @@
      *          the file's basic attributes
      *
      * @return  the visit result
+     *
+     * @throws  IOException
+     *          if an I/O error occurs
      */
-    FileVisitResult visitFile(T file, BasicFileAttributes attrs);
+    FileVisitResult visitFile(T file, BasicFileAttributes attrs)
+        throws IOException;
 
     /**
-     * Invoked for a file when its basic file attributes could not be read.
+     * Invoked for a file that could not be visited. This method is invoked
+     * if the file's attributes could not be read, the file is a directory
+     * that could not be opened, and other reasons.
      *
      * @param   file
      *          a reference to the file
      * @param   exc
-     *          the I/O exception thrown from the attempt to read the file
-     *          attributes
+     *          the I/O exception that prevented the file from being visited
      *
      * @return  the visit result
+     *
+     * @throws  IOException
+     *          if an I/O error occurs
      */
-    FileVisitResult visitFileFailed(T file, IOException exc);
+    FileVisitResult visitFileFailed(T file, IOException exc)
+        throws IOException;
 
     /**
      * Invoked for a directory after entries in the directory, and all of their
@@ -171,6 +165,10 @@
      *          of the directory to complete prematurely
      *
      * @return  the visit result
+     *
+     * @throws  IOException
+     *          if an I/O error occurs
      */
-    FileVisitResult postVisitDirectory(T dir, IOException exc);
+    FileVisitResult postVisitDirectory(T dir, IOException exc)
+        throws IOException;
 }
diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/nio/file/Files.java
--- a/jdk/src/share/classes/java/nio/file/Files.java	Fri Sep 24 22:42:14 2010 -0700
+++ b/jdk/src/share/classes/java/nio/file/Files.java	Tue Oct 26 13:45:25 2010 -0700
@@ -135,9 +135,9 @@
      * FileVisitor} invoked for each file encountered. File tree traversal
      * completes when all accessible files in the tree have been visited, or a
      * visit method returns a result of {@link FileVisitResult#TERMINATE
-     * TERMINATE}. Where a visit method terminates due an uncaught error or
-     * runtime exception then the traversal is terminated and the error or
-     * exception is propagated to the caller of this method.
+     * TERMINATE}. Where a visit method terminates due an {@code IOException},
+     * an uncaught error, or runtime exception, then the traversal is terminated
+     * and the error or exception is propagated to the caller of this method.
      *
      * 

For each file encountered this method attempts to gets its {@link * java.nio.file.attribute.BasicFileAttributes}. If the file is not a @@ -146,12 +146,10 @@ * due to an I/O exception, then the {@link FileVisitor#visitFileFailed * visitFileFailed} method is invoked with the I/O exception. * - *

Where the file is a directory, this method attempts to open it by - * invoking its {@link Path#newDirectoryStream newDirectoryStream} method. - * Where the directory could not be opened, due to an {@code IOException}, - * then the {@link FileVisitor#preVisitDirectoryFailed preVisitDirectoryFailed} - * method is invoked with the I/O exception, after which, the file tree walk - * continues, by default, at the next sibling of the directory. + *

Where the file is a directory, and the directory could not be opened, + * then the {@code visitFileFailed} method is invoked with the I/O exception, + * after which, the file tree walk continues, by default, at the next + * sibling of the directory. * *

Where the directory is opened successfully, then the entries in the * directory, and their descendants are visited. When all entries @@ -171,26 +169,25 @@ * method is invoked as specified above). * *

If the {@code options} parameter contains the {@link - * FileVisitOption#DETECT_CYCLES DETECT_CYCLES} or {@link - * FileVisitOption#FOLLOW_LINKS FOLLOW_LINKS} options then this method keeps + * FileVisitOption#FOLLOW_LINKS FOLLOW_LINKS} option then this method keeps * track of directories visited so that cycles can be detected. A cycle * arises when there is an entry in a directory that is an ancestor of the * directory. Cycle detection is done by recording the {@link * java.nio.file.attribute.BasicFileAttributes#fileKey file-key} of directories, * or if file keys are not available, by invoking the {@link Path#isSameFile * isSameFile} method to test if a directory is the same file as an - * ancestor. When a cycle is detected the {@link FileVisitor#visitFile - * visitFile} is invoked with the attributes of the directory. The {@link - * java.nio.file.attribute.BasicFileAttributes#isDirectory isDirectory} - * method may be used to test if the file is a directory and that a cycle is - * detected. The {@code preVisitDirectory} and {@code postVisitDirectory} - * methods are not invoked. + * ancestor. When a cycle is detected it is treated as an I/O error, and the + * {@link FileVisitor#visitFileFailed visitFileFailed} method is invoked with + * an instance of {@link FileSystemLoopException}. * *

The {@code maxDepth} parameter is the maximum number of levels of * directories to visit. A value of {@code 0} means that only the starting * file is visited, unless denied by the security manager. A value of * {@link Integer#MAX_VALUE MAX_VALUE} may be used to indicate that all - * levels should be visited. + * levels should be visited. The {@code visitFile} method is invoked for all + * files, including directories, encountered at {@code maxDepth}, unless the + * basic file attributes cannot be read, in which case the {@code + * visitFileFailed} method is invoked. * *

If a visitor returns a result of {@code null} then {@code * NullPointerException} is thrown. @@ -215,11 +212,14 @@ * In the case of the default provider, the {@link * SecurityManager#checkRead(String) checkRead} method is invoked * to check read access to the directory. + * @throws IOException + * If an I/O error is thrown by a visitor method */ public static void walkFileTree(Path start, Set options, int maxDepth, FileVisitor visitor) + throws IOException { if (maxDepth < 0) throw new IllegalArgumentException("'maxDepth' is negative"); @@ -245,8 +245,12 @@ * In the case of the default provider, the {@link * SecurityManager#checkRead(String) checkRead} method is invoked * to check read access to the directory. + * @throws IOException + * If an I/O error is thrown by a visitor method */ - public static void walkFileTree(Path start, FileVisitor visitor) { + public static void walkFileTree(Path start, FileVisitor visitor) + throws IOException + { walkFileTree(start, EnumSet.noneOf(FileVisitOption.class), Integer.MAX_VALUE, diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java --- a/jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java Tue Oct 26 13:45:25 2010 -0700 @@ -27,7 +27,7 @@ import java.nio.file.attribute.BasicFileAttributes; import java.io.IOException; -import java.io.IOError; +import java.util.Objects; /** * A simple visitor of files with default behavior to visit all files and to @@ -48,70 +48,47 @@ } /** - * Throws NullPointerException if obj is null. - */ - private static void checkNotNull(Object obj) { - if (obj == null) - throw new NullPointerException(); - } - - /** * Invoked for a directory before entries in the directory are visited. * *

Unless overridden, this method returns {@link FileVisitResult#CONTINUE * CONTINUE}. */ @Override - public FileVisitResult preVisitDirectory(T dir) { - checkNotNull(dir); + public FileVisitResult preVisitDirectory(T dir, BasicFileAttributes attrs) + throws IOException + { + Objects.nonNull(dir); + Objects.nonNull(attrs); return FileVisitResult.CONTINUE; } /** - * Invoked for a directory that could not be opened. - * - *

Unless overridden, this method throws {@link IOError} with the I/O - * exception as cause. - * - * @throws IOError - * with the I/O exception thrown when the attempt to open the - * directory failed - */ - @Override - public FileVisitResult preVisitDirectoryFailed(T dir, IOException exc) { - checkNotNull(dir); - checkNotNull(exc); - throw new IOError(exc); - } - - /** * Invoked for a file in a directory. * *

Unless overridden, this method returns {@link FileVisitResult#CONTINUE * CONTINUE}. */ @Override - public FileVisitResult visitFile(T file, BasicFileAttributes attrs) { - checkNotNull(file); - checkNotNull(attrs); + public FileVisitResult visitFile(T file, BasicFileAttributes attrs) + throws IOException + { + Objects.nonNull(file); + Objects.nonNull(attrs); return FileVisitResult.CONTINUE; } /** - * Invoked for a file when its basic file attributes could not be read. + * Invoked for a file that could not be visited. * - *

Unless overridden, this method throws {@link IOError} with the I/O - * exception as cause. - * - * @throws IOError - * with the I/O exception thrown when the attempt to read the file - * attributes failed + *

Unless overridden, this method re-throws the I/O exception that prevented + * the file from being visited. */ @Override - public FileVisitResult visitFileFailed(T file, IOException exc) { - checkNotNull(file); - checkNotNull(exc); - throw new IOError(exc); + public FileVisitResult visitFileFailed(T file, IOException exc) + throws IOException + { + Objects.nonNull(file); + throw exc; } /** @@ -120,18 +97,16 @@ * *

Unless overridden, this method returns {@link FileVisitResult#CONTINUE * CONTINUE} if the directory iteration completes without an I/O exception; - * otherwise this method throws {@link IOError} with the I/O exception as - * cause. - * - * @throws IOError - * with the I/O exception thrown when iteration of the directory - * completed prematurely due to an I/O error + * otherwise this method re-throws the I/O exception that caused the iteration + * of the directory to terminate prematurely. */ @Override - public FileVisitResult postVisitDirectory(T dir, IOException exc) { - checkNotNull(dir); + public FileVisitResult postVisitDirectory(T dir, IOException exc) + throws IOException + { + Objects.nonNull(dir); if (exc != null) - throw new IOError(exc); + throw exc; return FileVisitResult.CONTINUE; } } diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/sql/DatabaseMetaData.java --- a/jdk/src/share/classes/java/sql/DatabaseMetaData.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/sql/DatabaseMetaData.java Tue Oct 26 13:45:25 2010 -0700 @@ -3643,7 +3643,7 @@ /** * Retrieves whether a generated key will always be returned if the column - * name(s) or indexe(s) specified for the auto generated key column(s) + * name(s) or index(es) specified for the auto generated key column(s) * are valid and the statement succeeds. The key that is returned may or * may not be based on the column(s) for the auto generated key. * Consult your JDBC driver documentation for additional details. diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/sql/Statement.java --- a/jdk/src/share/classes/java/sql/Statement.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/sql/Statement.java Tue Oct 26 13:45:25 2010 -0700 @@ -1051,9 +1051,9 @@ /** * Returns a value indicating whether this {@code Statement} will be - * closed when all dependent objects such as resultsets are closed. + * closed when all its dependent result sets are closed. * @return {@code true} if the {@code Statement} will be closed when all - * of its dependent objects are closed; {@code false} otherwise + * of its dependent result sets are closed; {@code false} otherwise * @throws SQLException if this method is called on a closed * {@code Statement} * @since 1.7 diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/util/Locale.java --- a/jdk/src/share/classes/java/util/Locale.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/util/Locale.java Tue Oct 26 13:45:25 2010 -0700 @@ -569,6 +569,9 @@ * @exception NullPointerException thrown if any argument is null. */ public Locale(String language, String country, String variant) { + if (language== null || country == null || variant == null) { + throw new NullPointerException(); + } _baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant); _extensions = getCompatibilityExtensions(language, "", country, variant); } diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/util/ResourceBundle.java --- a/jdk/src/share/classes/java/util/ResourceBundle.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/util/ResourceBundle.java Tue Oct 26 13:45:25 2010 -0700 @@ -293,16 +293,6 @@ = new ConcurrentHashMap(INITIAL_CACHE_SIZE); /** - * This ConcurrentMap is used to keep multiple threads from loading the - * same bundle concurrently. The table entries are - * where CacheKey is the key for the bundle that is under construction - * and Thread is the thread that is constructing the bundle. - * This list is manipulated in findBundleInCache and putBundleInCache. - */ - private static final ConcurrentMap underConstruction - = new ConcurrentHashMap(); - - /** * Queue for reference objects referring to class loaders or bundles. */ private static final ReferenceQueue referenceQueue = new ReferenceQueue(); @@ -1381,7 +1371,7 @@ boolean expiredBundle = false; // First, look up the cache to see if it's in the cache, without - // declaring beginLoading. + // attempting to load bundle. cacheKey.setLocale(targetLocale); ResourceBundle bundle = findBundleInCache(cacheKey, control); if (isValidBundle(bundle)) { @@ -1408,56 +1398,25 @@ CacheKey constKey = (CacheKey) cacheKey.clone(); try { - // Try declaring loading. If beginLoading() returns true, - // then we can proceed. Otherwise, we need to take a look - // at the cache again to see if someone else has loaded - // the bundle and put it in the cache while we've been - // waiting for other loading work to complete. - while (!beginLoading(constKey)) { - bundle = findBundleInCache(cacheKey, control); - if (bundle == null) { - continue; + bundle = loadBundle(cacheKey, formats, control, expiredBundle); + if (bundle != null) { + if (bundle.parent == null) { + bundle.setParent(parent); } - if (bundle == NONEXISTENT_BUNDLE) { - // If the bundle is NONEXISTENT_BUNDLE, the bundle doesn't exist. - return parent; - } - expiredBundle = bundle.expired; - if (!expiredBundle) { - if (bundle.parent == parent) { - return bundle; - } - BundleReference bundleRef = cacheList.get(cacheKey); - if (bundleRef != null && bundleRef.get() == bundle) { - cacheList.remove(cacheKey, bundleRef); - } - } + bundle.locale = targetLocale; + bundle = putBundleInCache(cacheKey, bundle, control); + return bundle; } - try { - bundle = loadBundle(cacheKey, formats, control, expiredBundle); - if (bundle != null) { - if (bundle.parent == null) { - bundle.setParent(parent); - } - bundle.locale = targetLocale; - bundle = putBundleInCache(cacheKey, bundle, control); - return bundle; - } - - // Put NONEXISTENT_BUNDLE in the cache as a mark that there's no bundle - // instance for the locale. - putBundleInCache(cacheKey, NONEXISTENT_BUNDLE, control); - } finally { - endLoading(constKey); - } + // Put NONEXISTENT_BUNDLE in the cache as a mark that there's no bundle + // instance for the locale. + putBundleInCache(cacheKey, NONEXISTENT_BUNDLE, control); } finally { if (constKey.getCause() instanceof InterruptedException) { Thread.currentThread().interrupt(); } } } - assert underConstruction.get(cacheKey) != Thread.currentThread(); return parent; } @@ -1465,7 +1424,6 @@ List formats, Control control, boolean reload) { - assert underConstruction.get(cacheKey) == Thread.currentThread(); // Here we actually load the bundle in the order of formats // specified by the getFormats() value. @@ -1498,7 +1456,6 @@ break; } } - assert underConstruction.get(cacheKey) == Thread.currentThread(); return bundle; } @@ -1530,57 +1487,6 @@ } /** - * Declares the beginning of actual resource bundle loading. This method - * returns true if the declaration is successful and the current thread has - * been put in underConstruction. If someone else has already begun - * loading, this method waits until that loading work is complete and - * returns false. - */ - private static final boolean beginLoading(CacheKey constKey) { - Thread me = Thread.currentThread(); - Thread worker; - // We need to declare by putting the current Thread (me) to - // underConstruction that we are working on loading the specified - // resource bundle. If we are already working the loading, it means - // that the resource loading requires a recursive call. In that case, - // we have to proceed. (4300693) - if (((worker = underConstruction.putIfAbsent(constKey, me)) == null) - || worker == me) { - return true; - } - - // If someone else is working on the loading, wait until - // the Thread finishes the bundle loading. - synchronized (worker) { - while (underConstruction.get(constKey) == worker) { - try { - worker.wait(); - } catch (InterruptedException e) { - // record the interruption - constKey.setCause(e); - } - } - } - return false; - } - - /** - * Declares the end of the bundle loading. This method calls notifyAll - * for those who are waiting for this completion. - */ - private static final void endLoading(CacheKey constKey) { - // Remove this Thread from the underConstruction map and wake up - // those who have been waiting for me to complete this bundle - // loading. - Thread me = Thread.currentThread(); - assert (underConstruction.get(constKey) == me); - underConstruction.remove(constKey); - synchronized (me) { - me.notifyAll(); - } - } - - /** * Throw a MissingResourceException with proper message */ private static final void throwMissingResourceException(String baseName, diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,1445 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Written by Doug Lea and Martin Buchholz with assistance from members of + * JCP JSR-166 Expert Group and released to the public domain, as explained + * at http://creativecommons.org/licenses/publicdomain + */ + +package java.util.concurrent; + +import java.util.AbstractCollection; +import java.util.ArrayList; +import java.util.Collection; +import java.util.ConcurrentModificationException; +import java.util.Deque; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Queue; + +/** + * An unbounded concurrent {@linkplain Deque deque} based on linked nodes. + * Concurrent insertion, removal, and access operations execute safely + * across multiple threads. + * A {@code ConcurrentLinkedDeque} is an appropriate choice when + * many threads will share access to a common collection. + * Like most other concurrent collection implementations, this class + * does not permit the use of {@code null} elements. + * + *

Iterators are weakly consistent, returning elements + * reflecting the state of the deque at some point at or since the + * creation of the iterator. They do not throw {@link + * java.util.ConcurrentModificationException + * ConcurrentModificationException}, and may proceed concurrently with + * other operations. + * + *

Beware that, unlike in most collections, the {@code size} + * method is NOT a constant-time operation. Because of the + * asynchronous nature of these deques, determining the current number + * of elements requires a traversal of the elements. + * + *

This class and its iterator implement all of the optional + * methods of the {@link Deque} and {@link Iterator} interfaces. + * + *

Memory consistency effects: As with other concurrent collections, + * actions in a thread prior to placing an object into a + * {@code ConcurrentLinkedDeque} + * happen-before + * actions subsequent to the access or removal of that element from + * the {@code ConcurrentLinkedDeque} in another thread. + * + *

This class is a member of the + * + * Java Collections Framework. + * + * @since 1.7 + * @author Doug Lea + * @author Martin Buchholz + * @param the type of elements held in this collection + */ + +public class ConcurrentLinkedDeque + extends AbstractCollection + implements Deque, java.io.Serializable { + + /* + * This is an implementation of a concurrent lock-free deque + * supporting interior removes but not interior insertions, as + * required to support the entire Deque interface. + * + * We extend the techniques developed for ConcurrentLinkedQueue and + * LinkedTransferQueue (see the internal docs for those classes). + * Understanding the ConcurrentLinkedQueue implementation is a + * prerequisite for understanding the implementation of this class. + * + * The data structure is a symmetrical doubly-linked "GC-robust" + * linked list of nodes. We minimize the number of volatile writes + * using two techniques: advancing multiple hops with a single CAS + * and mixing volatile and non-volatile writes of the same memory + * locations. + * + * A node contains the expected E ("item") and links to predecessor + * ("prev") and successor ("next") nodes: + * + * class Node { volatile Node prev, next; volatile E item; } + * + * A node p is considered "live" if it contains a non-null item + * (p.item != null). When an item is CASed to null, the item is + * atomically logically deleted from the collection. + * + * At any time, there is precisely one "first" node with a null + * prev reference that terminates any chain of prev references + * starting at a live node. Similarly there is precisely one + * "last" node terminating any chain of next references starting at + * a live node. The "first" and "last" nodes may or may not be live. + * The "first" and "last" nodes are always mutually reachable. + * + * A new element is added atomically by CASing the null prev or + * next reference in the first or last node to a fresh node + * containing the element. The element's node atomically becomes + * "live" at that point. + * + * A node is considered "active" if it is a live node, or the + * first or last node. Active nodes cannot be unlinked. + * + * A "self-link" is a next or prev reference that is the same node: + * p.prev == p or p.next == p + * Self-links are used in the node unlinking process. Active nodes + * never have self-links. + * + * A node p is active if and only if: + * + * p.item != null || + * (p.prev == null && p.next != p) || + * (p.next == null && p.prev != p) + * + * The deque object has two node references, "head" and "tail". + * The head and tail are only approximations to the first and last + * nodes of the deque. The first node can always be found by + * following prev pointers from head; likewise for tail. However, + * it is permissible for head and tail to be referring to deleted + * nodes that have been unlinked and so may not be reachable from + * any live node. + * + * There are 3 stages of node deletion; + * "logical deletion", "unlinking", and "gc-unlinking". + * + * 1. "logical deletion" by CASing item to null atomically removes + * the element from the collection, and makes the containing node + * eligible for unlinking. + * + * 2. "unlinking" makes a deleted node unreachable from active + * nodes, and thus eventually reclaimable by GC. Unlinked nodes + * may remain reachable indefinitely from an iterator. + * + * Physical node unlinking is merely an optimization (albeit a + * critical one), and so can be performed at our convenience. At + * any time, the set of live nodes maintained by prev and next + * links are identical, that is, the live nodes found via next + * links from the first node is equal to the elements found via + * prev links from the last node. However, this is not true for + * nodes that have already been logically deleted - such nodes may + * be reachable in one direction only. + * + * 3. "gc-unlinking" takes unlinking further by making active + * nodes unreachable from deleted nodes, making it easier for the + * GC to reclaim future deleted nodes. This step makes the data + * structure "gc-robust", as first described in detail by Boehm + * (http://portal.acm.org/citation.cfm?doid=503272.503282). + * + * GC-unlinked nodes may remain reachable indefinitely from an + * iterator, but unlike unlinked nodes, are never reachable from + * head or tail. + * + * Making the data structure GC-robust will eliminate the risk of + * unbounded memory retention with conservative GCs and is likely + * to improve performance with generational GCs. + * + * When a node is dequeued at either end, e.g. via poll(), we would + * like to break any references from the node to active nodes. We + * develop further the use of self-links that was very effective in + * other concurrent collection classes. The idea is to replace + * prev and next pointers with special values that are interpreted + * to mean off-the-list-at-one-end. These are approximations, but + * good enough to preserve the properties we want in our + * traversals, e.g. we guarantee that a traversal will never visit + * the same element twice, but we don't guarantee whether a + * traversal that runs out of elements will be able to see more + * elements later after enqueues at that end. Doing gc-unlinking + * safely is particularly tricky, since any node can be in use + * indefinitely (for example by an iterator). We must ensure that + * the nodes pointed at by head/tail never get gc-unlinked, since + * head/tail are needed to get "back on track" by other nodes that + * are gc-unlinked. gc-unlinking accounts for much of the + * implementation complexity. + * + * Since neither unlinking nor gc-unlinking are necessary for + * correctness, there are many implementation choices regarding + * frequency (eagerness) of these operations. Since volatile + * reads are likely to be much cheaper than CASes, saving CASes by + * unlinking multiple adjacent nodes at a time may be a win. + * gc-unlinking can be performed rarely and still be effective, + * since it is most important that long chains of deleted nodes + * are occasionally broken. + * + * The actual representation we use is that p.next == p means to + * goto the first node (which in turn is reached by following prev + * pointers from head), and p.next == null && p.prev == p means + * that the iteration is at an end and that p is a (final static) + * dummy node, NEXT_TERMINATOR, and not the last active node. + * Finishing the iteration when encountering such a TERMINATOR is + * good enough for read-only traversals, so such traversals can use + * p.next == null as the termination condition. When we need to + * find the last (active) node, for enqueueing a new node, we need + * to check whether we have reached a TERMINATOR node; if so, + * restart traversal from tail. + * + * The implementation is completely directionally symmetrical, + * except that most public methods that iterate through the list + * follow next pointers ("forward" direction). + * + * We believe (without full proof) that all single-element deque + * operations (e.g., addFirst, peekLast, pollLast) are linearizable + * (see Herlihy and Shavit's book). However, some combinations of + * operations are known not to be linearizable. In particular, + * when an addFirst(A) is racing with pollFirst() removing B, it is + * possible for an observer iterating over the elements to observe + * A B C and subsequently observe A C, even though no interior + * removes are ever performed. Nevertheless, iterators behave + * reasonably, providing the "weakly consistent" guarantees. + * + * Empirically, microbenchmarks suggest that this class adds about + * 40% overhead relative to ConcurrentLinkedQueue, which feels as + * good as we can hope for. + */ + + private static final long serialVersionUID = 876323262645176354L; + + /** + * A node from which the first node on list (that is, the unique node p + * with p.prev == null && p.next != p) can be reached in O(1) time. + * Invariants: + * - the first node is always O(1) reachable from head via prev links + * - all live nodes are reachable from the first node via succ() + * - head != null + * - (tmp = head).next != tmp || tmp != head + * - head is never gc-unlinked (but may be unlinked) + * Non-invariants: + * - head.item may or may not be null + * - head may not be reachable from the first or last node, or from tail + */ + private transient volatile Node head; + + /** + * A node from which the last node on list (that is, the unique node p + * with p.next == null && p.prev != p) can be reached in O(1) time. + * Invariants: + * - the last node is always O(1) reachable from tail via next links + * - all live nodes are reachable from the last node via pred() + * - tail != null + * - tail is never gc-unlinked (but may be unlinked) + * Non-invariants: + * - tail.item may or may not be null + * - tail may not be reachable from the first or last node, or from head + */ + private transient volatile Node tail; + + private final static Node PREV_TERMINATOR, NEXT_TERMINATOR; + + static { + PREV_TERMINATOR = new Node(null); + PREV_TERMINATOR.next = PREV_TERMINATOR; + NEXT_TERMINATOR = new Node(null); + NEXT_TERMINATOR.prev = NEXT_TERMINATOR; + } + + @SuppressWarnings("unchecked") + Node prevTerminator() { + return (Node) PREV_TERMINATOR; + } + + @SuppressWarnings("unchecked") + Node nextTerminator() { + return (Node) NEXT_TERMINATOR; + } + + static final class Node { + volatile Node prev; + volatile E item; + volatile Node next; + + /** + * Constructs a new node. Uses relaxed write because item can + * only be seen after publication via casNext or casPrev. + */ + Node(E item) { + UNSAFE.putObject(this, itemOffset, item); + } + + boolean casItem(E cmp, E val) { + return UNSAFE.compareAndSwapObject(this, itemOffset, cmp, val); + } + + void lazySetNext(Node val) { + UNSAFE.putOrderedObject(this, nextOffset, val); + } + + boolean casNext(Node cmp, Node val) { + return UNSAFE.compareAndSwapObject(this, nextOffset, cmp, val); + } + + void lazySetPrev(Node val) { + UNSAFE.putOrderedObject(this, prevOffset, val); + } + + boolean casPrev(Node cmp, Node val) { + return UNSAFE.compareAndSwapObject(this, prevOffset, cmp, val); + } + + // Unsafe mechanics + + private static final sun.misc.Unsafe UNSAFE = + sun.misc.Unsafe.getUnsafe(); + private static final long prevOffset = + objectFieldOffset(UNSAFE, "prev", Node.class); + private static final long itemOffset = + objectFieldOffset(UNSAFE, "item", Node.class); + private static final long nextOffset = + objectFieldOffset(UNSAFE, "next", Node.class); + } + + /** + * Links e as first element. + */ + private void linkFirst(E e) { + checkNotNull(e); + final Node newNode = new Node(e); + + restartFromHead: + for (;;) + for (Node h = head, p = h, q;;) { + if ((q = p.prev) != null && + (q = (p = q).prev) != null) + // Check for head updates every other hop. + // If p == q, we are sure to follow head instead. + p = (h != (h = head)) ? h : q; + else if (p.next == p) // PREV_TERMINATOR + continue restartFromHead; + else { + // p is first node + newNode.lazySetNext(p); // CAS piggyback + if (p.casPrev(null, newNode)) { + // Successful CAS is the linearization point + // for e to become an element of this deque, + // and for newNode to become "live". + if (p != h) // hop two nodes at a time + casHead(h, newNode); // Failure is OK. + return; + } + // Lost CAS race to another thread; re-read prev + } + } + } + + /** + * Links e as last element. + */ + private void linkLast(E e) { + checkNotNull(e); + final Node newNode = new Node(e); + + restartFromTail: + for (;;) + for (Node t = tail, p = t, q;;) { + if ((q = p.next) != null && + (q = (p = q).next) != null) + // Check for tail updates every other hop. + // If p == q, we are sure to follow tail instead. + p = (t != (t = tail)) ? t : q; + else if (p.prev == p) // NEXT_TERMINATOR + continue restartFromTail; + else { + // p is last node + newNode.lazySetPrev(p); // CAS piggyback + if (p.casNext(null, newNode)) { + // Successful CAS is the linearization point + // for e to become an element of this deque, + // and for newNode to become "live". + if (p != t) // hop two nodes at a time + casTail(t, newNode); // Failure is OK. + return; + } + // Lost CAS race to another thread; re-read next + } + } + } + + private final static int HOPS = 2; + + /** + * Unlinks non-null node x. + */ + void unlink(Node x) { + // assert x != null; + // assert x.item == null; + // assert x != PREV_TERMINATOR; + // assert x != NEXT_TERMINATOR; + + final Node prev = x.prev; + final Node next = x.next; + if (prev == null) { + unlinkFirst(x, next); + } else if (next == null) { + unlinkLast(x, prev); + } else { + // Unlink interior node. + // + // This is the common case, since a series of polls at the + // same end will be "interior" removes, except perhaps for + // the first one, since end nodes cannot be unlinked. + // + // At any time, all active nodes are mutually reachable by + // following a sequence of either next or prev pointers. + // + // Our strategy is to find the unique active predecessor + // and successor of x. Try to fix up their links so that + // they point to each other, leaving x unreachable from + // active nodes. If successful, and if x has no live + // predecessor/successor, we additionally try to gc-unlink, + // leaving active nodes unreachable from x, by rechecking + // that the status of predecessor and successor are + // unchanged and ensuring that x is not reachable from + // tail/head, before setting x's prev/next links to their + // logical approximate replacements, self/TERMINATOR. + Node activePred, activeSucc; + boolean isFirst, isLast; + int hops = 1; + + // Find active predecessor + for (Node p = prev; ; ++hops) { + if (p.item != null) { + activePred = p; + isFirst = false; + break; + } + Node q = p.prev; + if (q == null) { + if (p.next == p) + return; + activePred = p; + isFirst = true; + break; + } + else if (p == q) + return; + else + p = q; + } + + // Find active successor + for (Node p = next; ; ++hops) { + if (p.item != null) { + activeSucc = p; + isLast = false; + break; + } + Node q = p.next; + if (q == null) { + if (p.prev == p) + return; + activeSucc = p; + isLast = true; + break; + } + else if (p == q) + return; + else + p = q; + } + + // TODO: better HOP heuristics + if (hops < HOPS + // always squeeze out interior deleted nodes + && (isFirst | isLast)) + return; + + // Squeeze out deleted nodes between activePred and + // activeSucc, including x. + skipDeletedSuccessors(activePred); + skipDeletedPredecessors(activeSucc); + + // Try to gc-unlink, if possible + if ((isFirst | isLast) && + + // Recheck expected state of predecessor and successor + (activePred.next == activeSucc) && + (activeSucc.prev == activePred) && + (isFirst ? activePred.prev == null : activePred.item != null) && + (isLast ? activeSucc.next == null : activeSucc.item != null)) { + + updateHead(); // Ensure x is not reachable from head + updateTail(); // Ensure x is not reachable from tail + + // Finally, actually gc-unlink + x.lazySetPrev(isFirst ? prevTerminator() : x); + x.lazySetNext(isLast ? nextTerminator() : x); + } + } + } + + /** + * Unlinks non-null first node. + */ + private void unlinkFirst(Node first, Node next) { + // assert first != null; + // assert next != null; + // assert first.item == null; + for (Node o = null, p = next, q;;) { + if (p.item != null || (q = p.next) == null) { + if (o != null && p.prev != p && first.casNext(next, p)) { + skipDeletedPredecessors(p); + if (first.prev == null && + (p.next == null || p.item != null) && + p.prev == first) { + + updateHead(); // Ensure o is not reachable from head + updateTail(); // Ensure o is not reachable from tail + + // Finally, actually gc-unlink + o.lazySetNext(o); + o.lazySetPrev(prevTerminator()); + } + } + return; + } + else if (p == q) + return; + else { + o = p; + p = q; + } + } + } + + /** + * Unlinks non-null last node. + */ + private void unlinkLast(Node last, Node prev) { + // assert last != null; + // assert prev != null; + // assert last.item == null; + for (Node o = null, p = prev, q;;) { + if (p.item != null || (q = p.prev) == null) { + if (o != null && p.next != p && last.casPrev(prev, p)) { + skipDeletedSuccessors(p); + if (last.next == null && + (p.prev == null || p.item != null) && + p.next == last) { + + updateHead(); // Ensure o is not reachable from head + updateTail(); // Ensure o is not reachable from tail + + // Finally, actually gc-unlink + o.lazySetPrev(o); + o.lazySetNext(nextTerminator()); + } + } + return; + } + else if (p == q) + return; + else { + o = p; + p = q; + } + } + } + + /** + * Guarantees that any node which was unlinked before a call to + * this method will be unreachable from head after it returns. + * Does not guarantee to eliminate slack, only that head will + * point to a node that was active while this method was running. + */ + private final void updateHead() { + // Either head already points to an active node, or we keep + // trying to cas it to the first node until it does. + Node h, p, q; + restartFromHead: + while ((h = head).item == null && (p = h.prev) != null) { + for (;;) { + if ((q = p.prev) == null || + (q = (p = q).prev) == null) { + // It is possible that p is PREV_TERMINATOR, + // but if so, the CAS is guaranteed to fail. + if (casHead(h, p)) + return; + else + continue restartFromHead; + } + else if (h != head) + continue restartFromHead; + else + p = q; + } + } + } + + /** + * Guarantees that any node which was unlinked before a call to + * this method will be unreachable from tail after it returns. + * Does not guarantee to eliminate slack, only that tail will + * point to a node that was active while this method was running. + */ + private final void updateTail() { + // Either tail already points to an active node, or we keep + // trying to cas it to the last node until it does. + Node t, p, q; + restartFromTail: + while ((t = tail).item == null && (p = t.next) != null) { + for (;;) { + if ((q = p.next) == null || + (q = (p = q).next) == null) { + // It is possible that p is NEXT_TERMINATOR, + // but if so, the CAS is guaranteed to fail. + if (casTail(t, p)) + return; + else + continue restartFromTail; + } + else if (t != tail) + continue restartFromTail; + else + p = q; + } + } + } + + private void skipDeletedPredecessors(Node x) { + whileActive: + do { + Node prev = x.prev; + // assert prev != null; + // assert x != NEXT_TERMINATOR; + // assert x != PREV_TERMINATOR; + Node p = prev; + findActive: + for (;;) { + if (p.item != null) + break findActive; + Node q = p.prev; + if (q == null) { + if (p.next == p) + continue whileActive; + break findActive; + } + else if (p == q) + continue whileActive; + else + p = q; + } + + // found active CAS target + if (prev == p || x.casPrev(prev, p)) + return; + + } while (x.item != null || x.next == null); + } + + private void skipDeletedSuccessors(Node x) { + whileActive: + do { + Node next = x.next; + // assert next != null; + // assert x != NEXT_TERMINATOR; + // assert x != PREV_TERMINATOR; + Node p = next; + findActive: + for (;;) { + if (p.item != null) + break findActive; + Node q = p.next; + if (q == null) { + if (p.prev == p) + continue whileActive; + break findActive; + } + else if (p == q) + continue whileActive; + else + p = q; + } + + // found active CAS target + if (next == p || x.casNext(next, p)) + return; + + } while (x.item != null || x.prev == null); + } + + /** + * Returns the successor of p, or the first node if p.next has been + * linked to self, which will only be true if traversing with a + * stale pointer that is now off the list. + */ + final Node succ(Node p) { + // TODO: should we skip deleted nodes here? + Node q = p.next; + return (p == q) ? first() : q; + } + + /** + * Returns the predecessor of p, or the last node if p.prev has been + * linked to self, which will only be true if traversing with a + * stale pointer that is now off the list. + */ + final Node pred(Node p) { + Node q = p.prev; + return (p == q) ? last() : q; + } + + /** + * Returns the first node, the unique node p for which: + * p.prev == null && p.next != p + * The returned node may or may not be logically deleted. + * Guarantees that head is set to the returned node. + */ + Node first() { + restartFromHead: + for (;;) + for (Node h = head, p = h, q;;) { + if ((q = p.prev) != null && + (q = (p = q).prev) != null) + // Check for head updates every other hop. + // If p == q, we are sure to follow head instead. + p = (h != (h = head)) ? h : q; + else if (p == h + // It is possible that p is PREV_TERMINATOR, + // but if so, the CAS is guaranteed to fail. + || casHead(h, p)) + return p; + else + continue restartFromHead; + } + } + + /** + * Returns the last node, the unique node p for which: + * p.next == null && p.prev != p + * The returned node may or may not be logically deleted. + * Guarantees that tail is set to the returned node. + */ + Node last() { + restartFromTail: + for (;;) + for (Node t = tail, p = t, q;;) { + if ((q = p.next) != null && + (q = (p = q).next) != null) + // Check for tail updates every other hop. + // If p == q, we are sure to follow tail instead. + p = (t != (t = tail)) ? t : q; + else if (p == t + // It is possible that p is NEXT_TERMINATOR, + // but if so, the CAS is guaranteed to fail. + || casTail(t, p)) + return p; + else + continue restartFromTail; + } + } + + // Minor convenience utilities + + /** + * Throws NullPointerException if argument is null. + * + * @param v the element + */ + private static void checkNotNull(Object v) { + if (v == null) + throw new NullPointerException(); + } + + /** + * Returns element unless it is null, in which case throws + * NoSuchElementException. + * + * @param v the element + * @return the element + */ + private E screenNullResult(E v) { + if (v == null) + throw new NoSuchElementException(); + return v; + } + + /** + * Creates an array list and fills it with elements of this list. + * Used by toArray. + * + * @return the arrayList + */ + private ArrayList toArrayList() { + ArrayList list = new ArrayList(); + for (Node p = first(); p != null; p = succ(p)) { + E item = p.item; + if (item != null) + list.add(item); + } + return list; + } + + /** + * Constructs an empty deque. + */ + public ConcurrentLinkedDeque() { + head = tail = new Node(null); + } + + /** + * Constructs a deque initially containing the elements of + * the given collection, added in traversal order of the + * collection's iterator. + * + * @param c the collection of elements to initially contain + * @throws NullPointerException if the specified collection or any + * of its elements are null + */ + public ConcurrentLinkedDeque(Collection c) { + // Copy c into a private chain of Nodes + Node h = null, t = null; + for (E e : c) { + checkNotNull(e); + Node newNode = new Node(e); + if (h == null) + h = t = newNode; + else { + t.lazySetNext(newNode); + newNode.lazySetPrev(t); + t = newNode; + } + } + initHeadTail(h, t); + } + + /** + * Initializes head and tail, ensuring invariants hold. + */ + private void initHeadTail(Node h, Node t) { + if (h == t) { + if (h == null) + h = t = new Node(null); + else { + // Avoid edge case of a single Node with non-null item. + Node newNode = new Node(null); + t.lazySetNext(newNode); + newNode.lazySetPrev(t); + t = newNode; + } + } + head = h; + tail = t; + } + + /** + * Inserts the specified element at the front of this deque. + * + * @throws NullPointerException {@inheritDoc} + */ + public void addFirst(E e) { + linkFirst(e); + } + + /** + * Inserts the specified element at the end of this deque. + * + *

This method is equivalent to {@link #add}. + * + * @throws NullPointerException {@inheritDoc} + */ + public void addLast(E e) { + linkLast(e); + } + + /** + * Inserts the specified element at the front of this deque. + * + * @return {@code true} always + * @throws NullPointerException {@inheritDoc} + */ + public boolean offerFirst(E e) { + linkFirst(e); + return true; + } + + /** + * Inserts the specified element at the end of this deque. + * + *

This method is equivalent to {@link #add}. + * + * @return {@code true} always + * @throws NullPointerException {@inheritDoc} + */ + public boolean offerLast(E e) { + linkLast(e); + return true; + } + + public E peekFirst() { + for (Node p = first(); p != null; p = succ(p)) { + E item = p.item; + if (item != null) + return item; + } + return null; + } + + public E peekLast() { + for (Node p = last(); p != null; p = pred(p)) { + E item = p.item; + if (item != null) + return item; + } + return null; + } + + /** + * @throws NoSuchElementException {@inheritDoc} + */ + public E getFirst() { + return screenNullResult(peekFirst()); + } + + /** + * @throws NoSuchElementException {@inheritDoc} + */ + public E getLast() { + return screenNullResult(peekLast()); + } + + public E pollFirst() { + for (Node p = first(); p != null; p = succ(p)) { + E item = p.item; + if (item != null && p.casItem(item, null)) { + unlink(p); + return item; + } + } + return null; + } + + public E pollLast() { + for (Node p = last(); p != null; p = pred(p)) { + E item = p.item; + if (item != null && p.casItem(item, null)) { + unlink(p); + return item; + } + } + return null; + } + + /** + * @throws NoSuchElementException {@inheritDoc} + */ + public E removeFirst() { + return screenNullResult(pollFirst()); + } + + /** + * @throws NoSuchElementException {@inheritDoc} + */ + public E removeLast() { + return screenNullResult(pollLast()); + } + + // *** Queue and stack methods *** + + /** + * Inserts the specified element at the tail of this deque. + * + * @return {@code true} (as specified by {@link Queue#offer}) + * @throws NullPointerException if the specified element is null + */ + public boolean offer(E e) { + return offerLast(e); + } + + /** + * Inserts the specified element at the tail of this deque. + * + * @return {@code true} (as specified by {@link Collection#add}) + * @throws NullPointerException if the specified element is null + */ + public boolean add(E e) { + return offerLast(e); + } + + public E poll() { return pollFirst(); } + public E remove() { return removeFirst(); } + public E peek() { return peekFirst(); } + public E element() { return getFirst(); } + public void push(E e) { addFirst(e); } + public E pop() { return removeFirst(); } + + /** + * Removes the first element {@code e} such that + * {@code o.equals(e)}, if such an element exists in this deque. + * If the deque does not contain the element, it is unchanged. + * + * @param o element to be removed from this deque, if present + * @return {@code true} if the deque contained the specified element + * @throws NullPointerException if the specified element is {@code null} + */ + public boolean removeFirstOccurrence(Object o) { + checkNotNull(o); + for (Node p = first(); p != null; p = succ(p)) { + E item = p.item; + if (item != null && o.equals(item) && p.casItem(item, null)) { + unlink(p); + return true; + } + } + return false; + } + + /** + * Removes the last element {@code e} such that + * {@code o.equals(e)}, if such an element exists in this deque. + * If the deque does not contain the element, it is unchanged. + * + * @param o element to be removed from this deque, if present + * @return {@code true} if the deque contained the specified element + * @throws NullPointerException if the specified element is {@code null} + */ + public boolean removeLastOccurrence(Object o) { + checkNotNull(o); + for (Node p = last(); p != null; p = pred(p)) { + E item = p.item; + if (item != null && o.equals(item) && p.casItem(item, null)) { + unlink(p); + return true; + } + } + return false; + } + + /** + * Returns {@code true} if this deque contains at least one + * element {@code e} such that {@code o.equals(e)}. + * + * @param o element whose presence in this deque is to be tested + * @return {@code true} if this deque contains the specified element + */ + public boolean contains(Object o) { + if (o == null) return false; + for (Node p = first(); p != null; p = succ(p)) { + E item = p.item; + if (item != null && o.equals(item)) + return true; + } + return false; + } + + /** + * Returns {@code true} if this collection contains no elements. + * + * @return {@code true} if this collection contains no elements + */ + public boolean isEmpty() { + return peekFirst() == null; + } + + /** + * Returns the number of elements in this deque. If this deque + * contains more than {@code Integer.MAX_VALUE} elements, it + * returns {@code Integer.MAX_VALUE}. + * + *

Beware that, unlike in most collections, this method is + * NOT a constant-time operation. Because of the + * asynchronous nature of these deques, determining the current + * number of elements requires traversing them all to count them. + * Additionally, it is possible for the size to change during + * execution of this method, in which case the returned result + * will be inaccurate. Thus, this method is typically not very + * useful in concurrent applications. + * + * @return the number of elements in this deque + */ + public int size() { + int count = 0; + for (Node p = first(); p != null; p = succ(p)) + if (p.item != null) + // Collection.size() spec says to max out + if (++count == Integer.MAX_VALUE) + break; + return count; + } + + /** + * Removes the first element {@code e} such that + * {@code o.equals(e)}, if such an element exists in this deque. + * If the deque does not contain the element, it is unchanged. + * + * @param o element to be removed from this deque, if present + * @return {@code true} if the deque contained the specified element + * @throws NullPointerException if the specified element is {@code null} + */ + public boolean remove(Object o) { + return removeFirstOccurrence(o); + } + + /** + * Appends all of the elements in the specified collection to the end of + * this deque, in the order that they are returned by the specified + * collection's iterator. Attempts to {@code addAll} of a deque to + * itself result in {@code IllegalArgumentException}. + * + * @param c the elements to be inserted into this deque + * @return {@code true} if this deque changed as a result of the call + * @throws NullPointerException if the specified collection or any + * of its elements are null + * @throws IllegalArgumentException if the collection is this deque + */ + public boolean addAll(Collection c) { + if (c == this) + // As historically specified in AbstractQueue#addAll + throw new IllegalArgumentException(); + + // Copy c into a private chain of Nodes + Node beginningOfTheEnd = null, last = null; + for (E e : c) { + checkNotNull(e); + Node newNode = new Node(e); + if (beginningOfTheEnd == null) + beginningOfTheEnd = last = newNode; + else { + last.lazySetNext(newNode); + newNode.lazySetPrev(last); + last = newNode; + } + } + if (beginningOfTheEnd == null) + return false; + + // Atomically append the chain at the tail of this collection + restartFromTail: + for (;;) + for (Node t = tail, p = t, q;;) { + if ((q = p.next) != null && + (q = (p = q).next) != null) + // Check for tail updates every other hop. + // If p == q, we are sure to follow tail instead. + p = (t != (t = tail)) ? t : q; + else if (p.prev == p) // NEXT_TERMINATOR + continue restartFromTail; + else { + // p is last node + beginningOfTheEnd.lazySetPrev(p); // CAS piggyback + if (p.casNext(null, beginningOfTheEnd)) { + // Successful CAS is the linearization point + // for all elements to be added to this queue. + if (!casTail(t, last)) { + // Try a little harder to update tail, + // since we may be adding many elements. + t = tail; + if (last.next == null) + casTail(t, last); + } + return true; + } + // Lost CAS race to another thread; re-read next + } + } + } + + /** + * Removes all of the elements from this deque. + */ + public void clear() { + while (pollFirst() != null) + ; + } + + /** + * Returns an array containing all of the elements in this deque, in + * proper sequence (from first to last element). + * + *

The returned array will be "safe" in that no references to it are + * maintained by this deque. (In other words, this method must allocate + * a new array). The caller is thus free to modify the returned array. + * + *

This method acts as bridge between array-based and collection-based + * APIs. + * + * @return an array containing all of the elements in this deque + */ + public Object[] toArray() { + return toArrayList().toArray(); + } + + /** + * Returns an array containing all of the elements in this deque, + * in proper sequence (from first to last element); the runtime + * type of the returned array is that of the specified array. If + * the deque fits in the specified array, it is returned therein. + * Otherwise, a new array is allocated with the runtime type of + * the specified array and the size of this deque. + * + *

If this deque fits in the specified array with room to spare + * (i.e., the array has more elements than this deque), the element in + * the array immediately following the end of the deque is set to + * {@code null}. + * + *

Like the {@link #toArray()} method, this method acts as + * bridge between array-based and collection-based APIs. Further, + * this method allows precise control over the runtime type of the + * output array, and may, under certain circumstances, be used to + * save allocation costs. + * + *

Suppose {@code x} is a deque known to contain only strings. + * The following code can be used to dump the deque into a newly + * allocated array of {@code String}: + * + *

+     *     String[] y = x.toArray(new String[0]);
+ * + * Note that {@code toArray(new Object[0])} is identical in function to + * {@code toArray()}. + * + * @param a the array into which the elements of the deque are to + * be stored, if it is big enough; otherwise, a new array of the + * same runtime type is allocated for this purpose + * @return an array containing all of the elements in this deque + * @throws ArrayStoreException if the runtime type of the specified array + * is not a supertype of the runtime type of every element in + * this deque + * @throws NullPointerException if the specified array is null + */ + public T[] toArray(T[] a) { + return toArrayList().toArray(a); + } + + /** + * Returns an iterator over the elements in this deque in proper sequence. + * The elements will be returned in order from first (head) to last (tail). + * + *

The returned {@code Iterator} is a "weakly consistent" iterator that + * will never throw {@link java.util.ConcurrentModificationException + * ConcurrentModificationException}, + * and guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not guaranteed to) + * reflect any modifications subsequent to construction. + * + * @return an iterator over the elements in this deque in proper sequence + */ + public Iterator iterator() { + return new Itr(); + } + + /** + * Returns an iterator over the elements in this deque in reverse + * sequential order. The elements will be returned in order from + * last (tail) to first (head). + * + *

The returned {@code Iterator} is a "weakly consistent" iterator that + * will never throw {@link java.util.ConcurrentModificationException + * ConcurrentModificationException}, + * and guarantees to traverse elements as they existed upon + * construction of the iterator, and may (but is not guaranteed to) + * reflect any modifications subsequent to construction. + * + * @return an iterator over the elements in this deque in reverse order + */ + public Iterator descendingIterator() { + return new DescendingItr(); + } + + private abstract class AbstractItr implements Iterator { + /** + * Next node to return item for. + */ + private Node nextNode; + + /** + * nextItem holds on to item fields because once we claim + * that an element exists in hasNext(), we must return it in + * the following next() call even if it was in the process of + * being removed when hasNext() was called. + */ + private E nextItem; + + /** + * Node returned by most recent call to next. Needed by remove. + * Reset to null if this element is deleted by a call to remove. + */ + private Node lastRet; + + abstract Node startNode(); + abstract Node nextNode(Node p); + + AbstractItr() { + advance(); + } + + /** + * Sets nextNode and nextItem to next valid node, or to null + * if no such. + */ + private void advance() { + lastRet = nextNode; + + Node p = (nextNode == null) ? startNode() : nextNode(nextNode); + for (;; p = nextNode(p)) { + if (p == null) { + // p might be active end or TERMINATOR node; both are OK + nextNode = null; + nextItem = null; + break; + } + E item = p.item; + if (item != null) { + nextNode = p; + nextItem = item; + break; + } + } + } + + public boolean hasNext() { + return nextItem != null; + } + + public E next() { + E item = nextItem; + if (item == null) throw new NoSuchElementException(); + advance(); + return item; + } + + public void remove() { + Node l = lastRet; + if (l == null) throw new IllegalStateException(); + l.item = null; + unlink(l); + lastRet = null; + } + } + + /** Forward iterator */ + private class Itr extends AbstractItr { + Node startNode() { return first(); } + Node nextNode(Node p) { return succ(p); } + } + + /** Descending iterator */ + private class DescendingItr extends AbstractItr { + Node startNode() { return last(); } + Node nextNode(Node p) { return pred(p); } + } + + /** + * Saves the state to a stream (that is, serializes it). + * + * @serialData All of the elements (each an {@code E}) in + * the proper order, followed by a null + * @param s the stream + */ + private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException { + + // Write out any hidden stuff + s.defaultWriteObject(); + + // Write out all elements in the proper order. + for (Node p = first(); p != null; p = succ(p)) { + E item = p.item; + if (item != null) + s.writeObject(item); + } + + // Use trailing null as sentinel + s.writeObject(null); + } + + /** + * Reconstitutes the instance from a stream (that is, deserializes it). + * @param s the stream + */ + private void readObject(java.io.ObjectInputStream s) + throws java.io.IOException, ClassNotFoundException { + s.defaultReadObject(); + + // Read in elements until trailing null sentinel found + Node h = null, t = null; + Object item; + while ((item = s.readObject()) != null) { + @SuppressWarnings("unchecked") + Node newNode = new Node((E) item); + if (h == null) + h = t = newNode; + else { + t.lazySetNext(newNode); + newNode.lazySetPrev(t); + t = newNode; + } + } + initHeadTail(h, t); + } + + // Unsafe mechanics + + private static final sun.misc.Unsafe UNSAFE = + sun.misc.Unsafe.getUnsafe(); + private static final long headOffset = + objectFieldOffset(UNSAFE, "head", ConcurrentLinkedDeque.class); + private static final long tailOffset = + objectFieldOffset(UNSAFE, "tail", ConcurrentLinkedDeque.class); + + private boolean casHead(Node cmp, Node val) { + return UNSAFE.compareAndSwapObject(this, headOffset, cmp, val); + } + + private boolean casTail(Node cmp, Node val) { + return UNSAFE.compareAndSwapObject(this, tailOffset, cmp, val); + } + + static long objectFieldOffset(sun.misc.Unsafe UNSAFE, + String field, Class klazz) { + try { + return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field)); + } catch (NoSuchFieldException e) { + // Convert Exception to corresponding Error + NoSuchFieldError error = new NoSuchFieldError(field); + error.initCause(e); + throw error; + } + } +} diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java --- a/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java Tue Oct 26 13:45:25 2010 -0700 @@ -28,9 +28,9 @@ * However, the following notice accompanied the original version of this * file: * - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * Written by Doug Lea and Martin Buchholz with assistance from members of + * JCP JSR-166 Expert Group and released to the public domain, as explained + * at http://creativecommons.org/licenses/publicdomain */ package java.util.concurrent; @@ -53,7 +53,8 @@ * operations obtain elements at the head of the queue. * A {@code ConcurrentLinkedQueue} is an appropriate choice when * many threads will share access to a common collection. - * This queue does not permit {@code null} elements. + * Like most other concurrent collection implementations, this class + * does not permit the use of {@code null} elements. * *

This implementation employs an efficient "wait-free" * algorithm based on one described in by Maged M. Michael and Michael L. Scott. * + *

Iterators are weakly consistent, returning elements + * reflecting the state of the queue at some point at or since the + * creation of the iterator. They do not throw {@link + * ConcurrentModificationException}, and may proceed concurrently with + * other operations. Elements contained in the queue since the creation + * of the iterator will be returned exactly once. + * *

Beware that, unlike in most collections, the {@code size} method * is NOT a constant-time operation. Because of the * asynchronous nature of these queues, determining the current number * of elements requires a traversal of the elements. * - *

This class and its iterator implement all of the - * optional methods of the {@link Collection} and {@link - * Iterator} interfaces. + *

This class and its iterator implement all of the optional + * methods of the {@link Queue} and {@link Iterator} interfaces. * *

Memory consistency effects: As with other concurrent * collections, actions in a thread prior to placing an object into a @@ -132,9 +139,10 @@ * * Both head and tail are permitted to lag. In fact, failing to * update them every time one could is a significant optimization - * (fewer CASes). This is controlled by local "hops" variables - * that only trigger helping-CASes after experiencing multiple - * lags. + * (fewer CASes). As with LinkedTransferQueue (see the internal + * documentation for that class), we use a slack threshold of two; + * that is, we update head/tail when the current pointer appears + * to be two or more steps away from the first/last node. * * Since head and tail are updated concurrently and independently, * it is possible for tail to lag behind head (why not)? @@ -148,8 +156,8 @@ * this is merely an optimization. * * When constructing a Node (before enqueuing it) we avoid paying - * for a volatile write to item by using lazySet instead of a - * normal write. This allows the cost of enqueue to be + * for a volatile write to item by using Unsafe.putObject instead + * of a normal write. This allows the cost of enqueue to be * "one-and-a-half" CASes. * * Both head and tail may or may not point to a Node with a @@ -161,38 +169,25 @@ */ private static class Node { - private volatile E item; - private volatile Node next; + volatile E item; + volatile Node next; + /** + * Constructs a new node. Uses relaxed write because item can + * only be seen after publication via casNext. + */ Node(E item) { - // Piggyback on imminent casNext() - lazySetItem(item); - } - - E getItem() { - return item; + UNSAFE.putObject(this, itemOffset, item); } boolean casItem(E cmp, E val) { return UNSAFE.compareAndSwapObject(this, itemOffset, cmp, val); } - void setItem(E val) { - item = val; - } - - void lazySetItem(E val) { - UNSAFE.putOrderedObject(this, itemOffset, val); - } - void lazySetNext(Node val) { UNSAFE.putOrderedObject(this, nextOffset, val); } - Node getNext() { - return next; - } - boolean casNext(Node cmp, Node val) { return UNSAFE.compareAndSwapObject(this, nextOffset, cmp, val); } @@ -219,7 +214,7 @@ * - it is permitted for tail to lag behind head, that is, for tail * to not be reachable from head! */ - private transient volatile Node head = new Node(null); + private transient volatile Node head; /** * A node from which the last node on list (that is, the unique @@ -233,25 +228,41 @@ * to not be reachable from head! * - tail.next may or may not be self-pointing to tail. */ - private transient volatile Node tail = head; + private transient volatile Node tail; /** * Creates a {@code ConcurrentLinkedQueue} that is initially empty. */ - public ConcurrentLinkedQueue() {} + public ConcurrentLinkedQueue() { + head = tail = new Node(null); + } /** * Creates a {@code ConcurrentLinkedQueue} * initially containing the elements of the given collection, * added in traversal order of the collection's iterator. + * * @param c the collection of elements to initially contain * @throws NullPointerException if the specified collection or any * of its elements are null */ public ConcurrentLinkedQueue(Collection c) { - for (E e : c) - add(e); + Node h = null, t = null; + for (E e : c) { + checkNotNull(e); + Node newNode = new Node(e); + if (h == null) + h = t = newNode; + else { + t.lazySetNext(newNode); + t = newNode; + } + } + if (h == null) + h = t = new Node(null); + head = h; + tail = t; } // Have to override just to update the javadoc @@ -267,13 +278,6 @@ } /** - * We don't bother to update head or tail pointers if fewer than - * HOPS links from "true" location. We assume that volatile - * writes are significantly more expensive than volatile reads. - */ - private static final int HOPS = 1; - - /** * Try to CAS head to p. If successful, repoint old head to itself * as sentinel for succ(), below. */ @@ -288,7 +292,7 @@ * stale pointer that is now off the list. */ final Node succ(Node p) { - Node next = p.getNext(); + Node next = p.next; return (p == next) ? head : next; } @@ -299,68 +303,75 @@ * @throws NullPointerException if the specified element is null */ public boolean offer(E e) { - if (e == null) throw new NullPointerException(); - Node n = new Node(e); - retry: - for (;;) { - Node t = tail; - Node p = t; - for (int hops = 0; ; hops++) { - Node next = succ(p); - if (next != null) { - if (hops > HOPS && t != tail) - continue retry; - p = next; - } else if (p.casNext(null, n)) { - if (hops >= HOPS) - casTail(t, n); // Failure is OK. + checkNotNull(e); + final Node newNode = new Node(e); + + for (Node t = tail, p = t;;) { + Node q = p.next; + if (q == null) { + // p is last node + if (p.casNext(null, newNode)) { + // Successful CAS is the linearization point + // for e to become an element of this queue, + // and for newNode to become "live". + if (p != t) // hop two nodes at a time + casTail(t, newNode); // Failure is OK. return true; - } else { - p = succ(p); } + // Lost CAS race to another thread; re-read next } + else if (p == q) + // We have fallen off list. If tail is unchanged, it + // will also be off-list, in which case we need to + // jump to head, from which all live nodes are always + // reachable. Else the new tail is a better bet. + p = (t != (t = tail)) ? t : head; + else + // Check for tail updates after two hops. + p = (p != t && t != (t = tail)) ? t : q; } } public E poll() { - Node h = head; - Node p = h; - for (int hops = 0; ; hops++) { - E item = p.getItem(); + restartFromHead: + for (;;) { + for (Node h = head, p = h, q;;) { + E item = p.item; - if (item != null && p.casItem(item, null)) { - if (hops >= HOPS) { - Node q = p.getNext(); - updateHead(h, (q != null) ? q : p); + if (item != null && p.casItem(item, null)) { + // Successful CAS is the linearization point + // for item to be removed from this queue. + if (p != h) // hop two nodes at a time + updateHead(h, ((q = p.next) != null) ? q : p); + return item; } - return item; + else if ((q = p.next) == null) { + updateHead(h, p); + return null; + } + else if (p == q) + continue restartFromHead; + else + p = q; } - Node next = succ(p); - if (next == null) { - updateHead(h, p); - break; - } - p = next; } - return null; } public E peek() { - Node h = head; - Node p = h; - E item; + restartFromHead: for (;;) { - item = p.getItem(); - if (item != null) - break; - Node next = succ(p); - if (next == null) { - break; + for (Node h = head, p = h, q;;) { + E item = p.item; + if (item != null || (q = p.next) == null) { + updateHead(h, p); + return item; + } + else if (p == q) + continue restartFromHead; + else + p = q; } - p = next; } - updateHead(h, p); - return item; } /** @@ -372,24 +383,20 @@ * of losing a race to a concurrent poll(). */ Node first() { - Node h = head; - Node p = h; - Node result; + restartFromHead: for (;;) { - E item = p.getItem(); - if (item != null) { - result = p; - break; + for (Node h = head, p = h, q;;) { + boolean hasItem = (p.item != null); + if (hasItem || (q = p.next) == null) { + updateHead(h, p); + return hasItem ? p : null; + } + else if (p == q) + continue restartFromHead; + else + p = q; } - Node next = succ(p); - if (next == null) { - result = null; - break; - } - p = next; } - updateHead(h, p); - return result; } /** @@ -410,18 +417,20 @@ * NOT a constant-time operation. Because of the * asynchronous nature of these queues, determining the current * number of elements requires an O(n) traversal. + * Additionally, if elements are added or removed during execution + * of this method, the returned result may be inaccurate. Thus, + * this method is typically not very useful in concurrent + * applications. * * @return the number of elements in this queue */ public int size() { int count = 0; - for (Node p = first(); p != null; p = succ(p)) { - if (p.getItem() != null) { - // Collections.size() spec says to max out + for (Node p = first(); p != null; p = succ(p)) + if (p.item != null) + // Collection.size() spec says to max out if (++count == Integer.MAX_VALUE) break; - } - } return count; } @@ -436,9 +445,8 @@ public boolean contains(Object o) { if (o == null) return false; for (Node p = first(); p != null; p = succ(p)) { - E item = p.getItem(); - if (item != null && - o.equals(item)) + E item = p.item; + if (item != null && o.equals(item)) return true; } return false; @@ -459,7 +467,7 @@ if (o == null) return false; Node pred = null; for (Node p = first(); p != null; p = succ(p)) { - E item = p.getItem(); + E item = p.item; if (item != null && o.equals(item) && p.casItem(item, null)) { @@ -474,6 +482,69 @@ } /** + * Appends all of the elements in the specified collection to the end of + * this queue, in the order that they are returned by the specified + * collection's iterator. Attempts to {@code addAll} of a queue to + * itself result in {@code IllegalArgumentException}. + * + * @param c the elements to be inserted into this queue + * @return {@code true} if this queue changed as a result of the call + * @throws NullPointerException if the specified collection or any + * of its elements are null + * @throws IllegalArgumentException if the collection is this queue + */ + public boolean addAll(Collection c) { + if (c == this) + // As historically specified in AbstractQueue#addAll + throw new IllegalArgumentException(); + + // Copy c into a private chain of Nodes + Node beginningOfTheEnd = null, last = null; + for (E e : c) { + checkNotNull(e); + Node newNode = new Node(e); + if (beginningOfTheEnd == null) + beginningOfTheEnd = last = newNode; + else { + last.lazySetNext(newNode); + last = newNode; + } + } + if (beginningOfTheEnd == null) + return false; + + // Atomically append the chain at the tail of this collection + for (Node t = tail, p = t;;) { + Node q = p.next; + if (q == null) { + // p is last node + if (p.casNext(null, beginningOfTheEnd)) { + // Successful CAS is the linearization point + // for all elements to be added to this queue. + if (!casTail(t, last)) { + // Try a little harder to update tail, + // since we may be adding many elements. + t = tail; + if (last.next == null) + casTail(t, last); + } + return true; + } + // Lost CAS race to another thread; re-read next + } + else if (p == q) + // We have fallen off list. If tail is unchanged, it + // will also be off-list, in which case we need to + // jump to head, from which all live nodes are always + // reachable. Else the new tail is a better bet. + p = (t != (t = tail)) ? t : head; + else + // Check for tail updates after two hops. + p = (p != t && t != (t = tail)) ? t : q; + } + } + + /** * Returns an array containing all of the elements in this queue, in * proper sequence. * @@ -490,7 +561,7 @@ // Use ArrayList to deal with resizing. ArrayList al = new ArrayList(); for (Node p = first(); p != null; p = succ(p)) { - E item = p.getItem(); + E item = p.item; if (item != null) al.add(item); } @@ -539,7 +610,7 @@ int k = 0; Node p; for (p = first(); p != null && k < a.length; p = succ(p)) { - E item = p.getItem(); + E item = p.item; if (item != null) a[k++] = (T)item; } @@ -552,7 +623,7 @@ // If won't fit, use ArrayList version ArrayList al = new ArrayList(); for (Node q = first(); q != null; q = succ(q)) { - E item = q.getItem(); + E item = q.item; if (item != null) al.add(item); } @@ -561,7 +632,9 @@ /** * Returns an iterator over the elements in this queue in proper sequence. - * The returned iterator is a "weakly consistent" iterator that + * The elements will be returned in order from first (head) to last (tail). + * + *

The returned {@code Iterator} is a "weakly consistent" iterator that * will never throw {@link java.util.ConcurrentModificationException * ConcurrentModificationException}, * and guarantees to traverse elements as they existed upon @@ -620,7 +693,7 @@ nextItem = null; return x; } - E item = p.getItem(); + E item = p.item; if (item != null) { nextNode = p; nextItem = item; @@ -648,13 +721,13 @@ Node l = lastRet; if (l == null) throw new IllegalStateException(); // rely on a future traversal to relink. - l.setItem(null); + l.item = null; lastRet = null; } } /** - * Save the state to a stream (that is, serialize it). + * Saves the state to a stream (that is, serializes it). * * @serialData All of the elements (each an {@code E}) in * the proper order, followed by a null @@ -668,7 +741,7 @@ // Write out all elements in the proper order. for (Node p = first(); p != null; p = succ(p)) { - Object item = p.getItem(); + Object item = p.item; if (item != null) s.writeObject(item); } @@ -678,25 +751,40 @@ } /** - * Reconstitute the Queue instance from a stream (that is, - * deserialize it). + * Reconstitutes the instance from a stream (that is, deserializes it). * @param s the stream */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { - // Read in capacity, and any hidden stuff s.defaultReadObject(); - head = new Node(null); - tail = head; - // Read in all elements and place in queue - for (;;) { + + // Read in elements until trailing null sentinel found + Node h = null, t = null; + Object item; + while ((item = s.readObject()) != null) { @SuppressWarnings("unchecked") - E item = (E)s.readObject(); - if (item == null) - break; - else - offer(item); + Node newNode = new Node((E) item); + if (h == null) + h = t = newNode; + else { + t.lazySetNext(newNode); + t = newNode; + } } + if (h == null) + h = t = new Node(null); + head = h; + tail = t; + } + + /** + * Throws NullPointerException if argument is null. + * + * @param v the element + */ + private static void checkNotNull(Object v) { + if (v == null) + throw new NullPointerException(); } // Unsafe mechanics @@ -715,10 +803,6 @@ return UNSAFE.compareAndSwapObject(this, headOffset, cmp, val); } - private void lazySetHead(Node val) { - UNSAFE.putOrderedObject(this, headOffset, val); - } - static long objectFieldOffset(sun.misc.Unsafe UNSAFE, String field, Class klazz) { try { diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/util/concurrent/ForkJoinPool.java --- a/jdk/src/share/classes/java/util/concurrent/ForkJoinPool.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/util/concurrent/ForkJoinPool.java Tue Oct 26 13:45:25 2010 -0700 @@ -42,7 +42,6 @@ import java.util.List; import java.util.concurrent.AbstractExecutorService; import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; @@ -823,15 +822,13 @@ (workerCounts & RUNNING_COUNT_MASK) <= 1); long startTime = untimed? 0 : System.nanoTime(); Thread.interrupted(); // clear/ignore interrupt - if (eventCount != ec || w.runState != 0 || - runState >= TERMINATING) // recheck after clear - break; + if (eventCount != ec || w.isTerminating()) + break; // recheck after clear if (untimed) LockSupport.park(w); else { LockSupport.parkNanos(w, SHRINK_RATE_NANOS); - if (eventCount != ec || w.runState != 0 || - runState >= TERMINATING) + if (eventCount != ec || w.isTerminating()) break; if (System.nanoTime() - startTime >= SHRINK_RATE_NANOS) tryShutdownUnusedWorker(ec); @@ -899,16 +896,23 @@ UNSAFE.compareAndSwapInt(this, workerCountsOffset, wc, wc + (ONE_RUNNING|ONE_TOTAL))) { ForkJoinWorkerThread w = null; + Throwable fail = null; try { w = factory.newThread(this); - } finally { // adjust on null or exceptional factory return - if (w == null) { - decrementWorkerCounts(ONE_RUNNING, ONE_TOTAL); - tryTerminate(false); // handle failure during shutdown - } + } catch (Throwable ex) { + fail = ex; } - if (w == null) + if (w == null) { // null or exceptional factory return + decrementWorkerCounts(ONE_RUNNING, ONE_TOTAL); + tryTerminate(false); // handle failure during shutdown + // If originating from an external caller, + // propagate exception, else ignore + if (fail != null && runState < TERMINATING && + !(Thread.currentThread() instanceof + ForkJoinWorkerThread)) + UNSAFE.throwException(fail); break; + } w.start(recordWorker(w), ueh); if ((workerCounts >>> TOTAL_COUNT_SHIFT) >= pc) { int c; // advance event count @@ -997,8 +1001,12 @@ boolean active = w.active; boolean inactivate = false; int pc = parallelism; - int rs; - while (w.runState == 0 && (rs = runState) < TERMINATING) { + while (w.runState == 0) { + int rs = runState; + if (rs >= TERMINATING) { // propagate shutdown + w.shutdown(); + break; + } if ((inactivate || (active && (rs & ACTIVE_COUNT_MASK) >= pc)) && UNSAFE.compareAndSwapInt(this, runStateOffset, rs, rs - 1)) inactivate = active = w.active = false; @@ -1126,6 +1134,7 @@ return true; } + /** * Actions on transition to TERMINATING * @@ -1149,7 +1158,7 @@ if (passes > 0 && !w.isTerminated()) { w.cancelTasks(); LockSupport.unpark(w); - if (passes > 1) { + if (passes > 1 && !w.isInterrupted()) { try { w.interrupt(); } catch (SecurityException ignore) { @@ -1726,6 +1735,13 @@ } /** + * Returns true if terminating or terminated. Used by ForkJoinWorkerThread. + */ + final boolean isAtLeastTerminating() { + return runState >= TERMINATING; + } + + /** * Returns {@code true} if this pool has been shut down. * * @return {@code true} if this pool has been shut down diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/util/concurrent/ForkJoinTask.java --- a/jdk/src/share/classes/java/util/concurrent/ForkJoinTask.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/util/concurrent/ForkJoinTask.java Tue Oct 26 13:45:25 2010 -0700 @@ -55,10 +55,10 @@ * start other subtasks. As indicated by the name of this class, * many programs using {@code ForkJoinTask} employ only methods * {@link #fork} and {@link #join}, or derivatives such as {@link - * #invokeAll}. However, this class also provides a number of other - * methods that can come into play in advanced usages, as well as - * extension mechanics that allow support of new forms of fork/join - * processing. + * #invokeAll(ForkJoinTask...) invokeAll}. However, this class also + * provides a number of other methods that can come into play in + * advanced usages, as well as extension mechanics that allow + * support of new forms of fork/join processing. * *

A {@code ForkJoinTask} is a lightweight form of {@link Future}. * The efficiency of {@code ForkJoinTask}s stems from a set of @@ -250,7 +250,7 @@ int s; // the odd construction reduces lock bias effects while ((s = status) >= 0) { try { - synchronized(this) { + synchronized (this) { if (UNSAFE.compareAndSwapInt(this, statusOffset, s,SIGNAL)) wait(); } @@ -270,7 +270,7 @@ int s; if ((s = status) >= 0) { try { - synchronized(this) { + synchronized (this) { if (UNSAFE.compareAndSwapInt(this, statusOffset, s,SIGNAL)) wait(millis, 0); } @@ -288,7 +288,7 @@ private void externalAwaitDone() { int s; while ((s = status) >= 0) { - synchronized(this) { + synchronized (this) { if (UNSAFE.compareAndSwapInt(this, statusOffset, s, SIGNAL)){ boolean interrupted = false; while (status >= 0) { @@ -669,11 +669,34 @@ setCompletion(NORMAL); } + /** + * Waits if necessary for the computation to complete, and then + * retrieves its result. + * + * @return the computed result + * @throws CancellationException if the computation was cancelled + * @throws ExecutionException if the computation threw an + * exception + * @throws InterruptedException if the current thread is not a + * member of a ForkJoinPool and was interrupted while waiting + */ public final V get() throws InterruptedException, ExecutionException { - quietlyJoin(); - if (Thread.interrupted()) - throw new InterruptedException(); - int s = status; + int s; + if (Thread.currentThread() instanceof ForkJoinWorkerThread) { + quietlyJoin(); + s = status; + } + else { + while ((s = status) >= 0) { + synchronized (this) { // interruptible form of awaitDone + if (UNSAFE.compareAndSwapInt(this, statusOffset, + s, SIGNAL)) { + while (status >= 0) + wait(); + } + } + } + } if (s < NORMAL) { Throwable ex; if (s == CANCELLED) @@ -684,6 +707,20 @@ return getRawResult(); } + /** + * Waits if necessary for at most the given time for the computation + * to complete, and then retrieves its result, if available. + * + * @param timeout the maximum time to wait + * @param unit the time unit of the timeout argument + * @return the computed result + * @throws CancellationException if the computation was cancelled + * @throws ExecutionException if the computation threw an + * exception + * @throws InterruptedException if the current thread is not a + * member of a ForkJoinPool and was interrupted while waiting + * @throws TimeoutException if the wait timed out + */ public final V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { Thread t = Thread.currentThread(); @@ -725,7 +762,7 @@ long ms = nt / 1000000; int ns = (int) (nt % 1000000); try { - synchronized(this) { + synchronized (this) { if (status >= 0) wait(ms, ns); } diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java --- a/jdk/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java Tue Oct 26 13:45:25 2010 -0700 @@ -778,11 +778,20 @@ // status check methods used mainly by ForkJoinPool final boolean isRunning() { return runState == 0; } - final boolean isTerminating() { return (runState & TERMINATING) != 0; } final boolean isTerminated() { return (runState & TERMINATED) != 0; } final boolean isSuspended() { return (runState & SUSPENDED) != 0; } final boolean isTrimmed() { return (runState & TRIMMED) != 0; } + final boolean isTerminating() { + if ((runState & TERMINATING) != 0) + return true; + if (pool.isAtLeastTerminating()) { // propagate pool state + shutdown(); + return true; + } + return false; + } + /** * Sets state to TERMINATING. Does NOT unpark or interrupt * to wake up if currently blocked. Callers must do so if desired. diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/util/concurrent/RecursiveAction.java --- a/jdk/src/share/classes/java/util/concurrent/RecursiveAction.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/util/concurrent/RecursiveAction.java Tue Oct 26 13:45:25 2010 -0700 @@ -138,7 +138,7 @@ * if (right.tryUnfork()) // directly calculate if not stolen * sum += right.atLeaf(right.lo, right.hi); * else { - * right.helpJoin(); + * right.join(); * sum += right.result; * } * right = right.next; diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/util/logging/LogManager.java --- a/jdk/src/share/classes/java/util/logging/LogManager.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/util/logging/LogManager.java Tue Oct 26 13:45:25 2010 -0700 @@ -690,6 +690,11 @@ * Note that since untrusted code may create loggers with * arbitrary names this method should not be relied on to * find Loggers for security sensitive logging. + * It is also important to note that the Logger associated with the + * String {@code name} may be garbage collected at any time if there + * is no strong reference to the Logger. The caller of this method + * must check the return value for null in order to properly handle + * the case where the Logger has been garbage collected. *

* @param name name of the logger * @return matching logger or null if none is found @@ -713,6 +718,14 @@ *

* Note: Loggers may be added dynamically as new classes are loaded. * This method only reports on the loggers that are currently registered. + * It is also important to note that this method only returns the name + * of a Logger, not a strong reference to the Logger itself. + * The returned String does nothing to prevent the Logger from being + * garbage collected. In particular, if the returned name is passed + * to {@code LogManager.getLogger()}, then the caller must check the + * return value from {@code LogManager.getLogger()} for null to properly + * handle the case where the Logger has been garbage collected in the + * time since its name was returned by this method. *

* @return enumeration of logger name strings */ diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/java/util/logging/Logger.java --- a/jdk/src/share/classes/java/util/logging/Logger.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/java/util/logging/Logger.java Tue Oct 26 13:45:25 2010 -0700 @@ -42,7 +42,10 @@ *

* Logger objects may be obtained by calls on one of the getLogger * factory methods. These will either create a new Logger or - * return a suitable existing Logger. + * return a suitable existing Logger. It is important to note that + * the Logger returned by one of the {@code getLogger} factory methods + * may be garbage collected at any time if a strong reference to the + * Logger is not kept. *

* Logging messages will be forwarded to registered Handler * objects, which can forward the messages to a variety of @@ -210,7 +213,9 @@ * who are making serious use of the logging package (for example * in products) should create and use their own Logger objects, * with appropriate names, so that logging can be controlled on a - * suitable per-Logger granularity. + * suitable per-Logger granularity. Developers also need to keep a + * strong reference to their Logger objects to prevent them from + * being garbage collected. *

* @deprecated Initialization of this field is prone to deadlocks. * The field must be initialized by the Logger class initialization @@ -287,6 +292,15 @@ * based on the LogManager configuration and it will configured * to also send logging output to its parent's Handlers. It will * be registered in the LogManager global namespace. + *

+ * Note: The LogManager may only retain a weak reference to the newly + * created Logger. It is important to understand that a previously + * created Logger with the given name may be garbage collected at any + * time if there is no strong reference to the Logger. In particular, + * this means that two back-to-back calls like + * {@code getLogger("MyLogger").log(...)} may use different Logger + * objects named "MyLogger" if there is no strong reference to the + * Logger named "MyLogger" elsewhere in the program. * * @param name A name for the logger. This should * be a dot-separated name and should normally @@ -311,6 +325,15 @@ * output to its parent's Handlers. It will be registered in * the LogManager global namespace. *

+ * Note: The LogManager may only retain a weak reference to the newly + * created Logger. It is important to understand that a previously + * created Logger with the given name may be garbage collected at any + * time if there is no strong reference to the Logger. In particular, + * this means that two back-to-back calls like + * {@code getLogger("MyLogger", ...).log(...)} may use different Logger + * objects named "MyLogger" if there is no strong reference to the + * Logger named "MyLogger" elsewhere in the program. + *

* If the named Logger already exists and does not yet have a * localization resource bundle then the given resource bundle * name is used. If the named Logger already exists and has diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java --- a/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -734,7 +734,7 @@ throw new SQLException("Set initParams() before setCommand"); } params.clear(); - command = new String(cmd); + command = cmd; } } @@ -797,7 +797,7 @@ throw new SQLException("Invalid url string detected. " + "Cannot be of length less than 1"); } else { - URL = new String(url); + URL = url; } dataSource = null; @@ -854,7 +854,7 @@ } else if (name.equals("")) { throw new SQLException("DataSource name cannot be empty string"); } else { - dataSource = new String(name); + dataSource = name; } URL = null; @@ -889,7 +889,7 @@ { username = null; } else { - username = new String(name); + username = name; } } @@ -924,7 +924,7 @@ { password = null; } else { - password = new String(pass); + password = pass; } } @@ -1563,13 +1563,13 @@ nullVal = new Object[2]; nullVal[0] = null; - nullVal[1] = new Integer(sqlType); + nullVal[1] = Integer.valueOf(sqlType); if (params == null){ throw new SQLException("Set initParams() before setNull"); } - params.put(new Integer(parameterIndex - 1), nullVal); + params.put(Integer.valueOf(parameterIndex - 1), nullVal); } /** @@ -1644,14 +1644,14 @@ nullVal = new Object[3]; nullVal[0] = null; - nullVal[1] = new Integer(sqlType); - nullVal[2] = new String(typeName); + nullVal[1] = Integer.valueOf(sqlType); + nullVal[2] = typeName; if(params == null){ throw new SQLException("Set initParams() before setNull"); } - params.put(new Integer(parameterIndex - 1), nullVal); + params.put(Integer.valueOf(parameterIndex - 1), nullVal); } @@ -1686,7 +1686,7 @@ throw new SQLException("Set initParams() before setNull"); } - params.put(new Integer(parameterIndex - 1), new Boolean(x)); + params.put(Integer.valueOf(parameterIndex - 1), Boolean.valueOf(x)); } /** @@ -1720,7 +1720,7 @@ throw new SQLException("Set initParams() before setByte"); } - params.put(new Integer(parameterIndex - 1), new Byte(x)); + params.put(Integer.valueOf(parameterIndex - 1), Byte.valueOf(x)); } /** @@ -1754,7 +1754,7 @@ throw new SQLException("Set initParams() before setShort"); } - params.put(new Integer(parameterIndex - 1), new Short(x)); + params.put(Integer.valueOf(parameterIndex - 1), Short.valueOf(x)); } /** @@ -1786,7 +1786,7 @@ if(params == null){ throw new SQLException("Set initParams() before setInt"); } - params.put(new Integer(parameterIndex - 1), new Integer(x)); + params.put(Integer.valueOf(parameterIndex - 1), Integer.valueOf(x)); } /** @@ -1818,7 +1818,7 @@ if(params == null){ throw new SQLException("Set initParams() before setLong"); } - params.put(new Integer(parameterIndex - 1), new Long(x)); + params.put(Integer.valueOf(parameterIndex - 1), Long.valueOf(x)); } /** @@ -1850,7 +1850,7 @@ if(params == null){ throw new SQLException("Set initParams() before setFloat"); } - params.put(new Integer(parameterIndex - 1), new Float(x)); + params.put(Integer.valueOf(parameterIndex - 1), new Float(x)); } /** @@ -1882,7 +1882,7 @@ if(params == null){ throw new SQLException("Set initParams() before setDouble"); } - params.put(new Integer(parameterIndex - 1), new Double(x)); + params.put(Integer.valueOf(parameterIndex - 1), new Double(x)); } /** @@ -1914,7 +1914,7 @@ if(params == null){ throw new SQLException("Set initParams() before setBigDecimal"); } - params.put(new Integer(parameterIndex - 1), x); + params.put(Integer.valueOf(parameterIndex - 1), x); } /** @@ -1948,7 +1948,7 @@ if(params == null){ throw new SQLException("Set initParams() before setString"); } - params.put(new Integer(parameterIndex - 1), x); + params.put(Integer.valueOf(parameterIndex - 1), x); } /** @@ -1982,7 +1982,7 @@ if(params == null){ throw new SQLException("Set initParams() before setBytes"); } - params.put(new Integer(parameterIndex - 1), x); + params.put(Integer.valueOf(parameterIndex - 1), x); } /** @@ -2024,7 +2024,7 @@ if(params == null){ throw new SQLException("Set initParams() before setDate"); } - params.put(new Integer(parameterIndex - 1), x); + params.put(Integer.valueOf(parameterIndex - 1), x); } /** @@ -2069,7 +2069,7 @@ throw new SQLException("Set initParams() before setTime"); } - params.put(new Integer(parameterIndex - 1), x); + params.put(Integer.valueOf(parameterIndex - 1), x); } /** @@ -2112,7 +2112,7 @@ throw new SQLException("Set initParams() before setTimestamp"); } - params.put(new Integer(parameterIndex - 1), x); + params.put(Integer.valueOf(parameterIndex - 1), x); } /** @@ -2185,14 +2185,14 @@ asciiStream = new Object[3]; asciiStream[0] = x; - asciiStream[1] = new Integer(length); - asciiStream[2] = new Integer(ASCII_STREAM_PARAM); + asciiStream[1] = Integer.valueOf(length); + asciiStream[2] = Integer.valueOf(ASCII_STREAM_PARAM); if(params == null){ throw new SQLException("Set initParams() before setAsciiStream"); } - params.put(new Integer(parameterIndex - 1), asciiStream); + params.put(Integer.valueOf(parameterIndex - 1), asciiStream); } /** @@ -2290,13 +2290,13 @@ binaryStream = new Object[3]; binaryStream[0] = x; - binaryStream[1] = new Integer(length); - binaryStream[2] = new Integer(BINARY_STREAM_PARAM); + binaryStream[1] = Integer.valueOf(length); + binaryStream[2] = Integer.valueOf(BINARY_STREAM_PARAM); if(params == null){ throw new SQLException("Set initParams() before setBinaryStream"); } - params.put(new Integer(parameterIndex - 1), binaryStream); + params.put(Integer.valueOf(parameterIndex - 1), binaryStream); } @@ -2396,12 +2396,12 @@ unicodeStream = new Object[3]; unicodeStream[0] = x; - unicodeStream[1] = new Integer(length); - unicodeStream[2] = new Integer(UNICODE_STREAM_PARAM); + unicodeStream[1] = Integer.valueOf(length); + unicodeStream[2] = Integer.valueOf(UNICODE_STREAM_PARAM); if(params == null){ throw new SQLException("Set initParams() before setUnicodeStream"); } - params.put(new Integer(parameterIndex - 1), unicodeStream); + params.put(Integer.valueOf(parameterIndex - 1), unicodeStream); } /** @@ -2475,11 +2475,11 @@ charStream = new Object[2]; charStream[0] = reader; - charStream[1] = new Integer(length); + charStream[1] = Integer.valueOf(length); if(params == null){ throw new SQLException("Set initParams() before setCharacterStream"); } - params.put(new Integer(parameterIndex - 1), charStream); + params.put(Integer.valueOf(parameterIndex - 1), charStream); } /** @@ -2591,12 +2591,12 @@ obj = new Object[3]; obj[0] = x; - obj[1] = new Integer(targetSqlType); - obj[2] = new Integer(scale); + obj[1] = Integer.valueOf(targetSqlType); + obj[2] = Integer.valueOf(scale); if(params == null){ throw new SQLException("Set initParams() before setObject"); } - params.put(new Integer(parameterIndex - 1), obj); + params.put(Integer.valueOf(parameterIndex - 1), obj); } /** @@ -2654,11 +2654,11 @@ obj = new Object[2]; obj[0] = x; - obj[1] = new Integer(targetSqlType); + obj[1] = Integer.valueOf(targetSqlType); if (params == null){ throw new SQLException("Set initParams() before setObject"); } - params.put(new Integer(parameterIndex - 1), obj); + params.put(Integer.valueOf(parameterIndex - 1), obj); } /** @@ -2726,7 +2726,7 @@ if (params == null) { throw new SQLException("Set initParams() before setObject"); } - params.put(new Integer(parameterIndex - 1), x); + params.put(Integer.valueOf(parameterIndex - 1), x); } /** @@ -2773,7 +2773,7 @@ if (params == null) { throw new SQLException("Set initParams() before setRef"); } - params.put(new Integer(parameterIndex - 1), new SerialRef(ref)); + params.put(Integer.valueOf(parameterIndex - 1), new SerialRef(ref)); } /** @@ -2817,7 +2817,7 @@ if(params == null){ throw new SQLException("Set initParams() before setBlob"); } - params.put(new Integer(parameterIndex - 1), new SerialBlob(x)); + params.put(Integer.valueOf(parameterIndex - 1), new SerialBlob(x)); } /** @@ -2862,7 +2862,7 @@ if(params == null){ throw new SQLException("Set initParams() before setClob"); } - params.put(new Integer(parameterIndex - 1), new SerialClob(x)); + params.put(Integer.valueOf(parameterIndex - 1), new SerialClob(x)); } /** @@ -2910,7 +2910,7 @@ if (params == null){ throw new SQLException("Set initParams() before setArray"); } - params.put(new Integer(parameterIndex - 1), new SerialArray(array)); + params.put(Integer.valueOf(parameterIndex - 1), new SerialArray(array)); } /** @@ -2975,7 +2975,7 @@ if(params == null){ throw new SQLException("Set initParams() before setDate"); } - params.put(new Integer(parameterIndex - 1), date); + params.put(Integer.valueOf(parameterIndex - 1), date); } /** @@ -3041,7 +3041,7 @@ if(params == null){ throw new SQLException("Set initParams() before setTime"); } - params.put(new Integer(parameterIndex - 1), time); + params.put(Integer.valueOf(parameterIndex - 1), time); } /** @@ -3107,7 +3107,7 @@ if(params == null){ throw new SQLException("Set initParams() before setTimestamp"); } - params.put(new Integer(parameterIndex - 1), timestamp); + params.put(Integer.valueOf(parameterIndex - 1), timestamp); } /** @@ -3181,7 +3181,7 @@ Object[] paramsArray = new Object[params.size()]; for (int i = 0; i < params.size(); i++) { - paramsArray[i] = params.get(new Integer(i)); + paramsArray[i] = params.get(Integer.valueOf(i)); if (paramsArray[i] == null) { throw new SQLException("missing parameter: " + (i + 1)); } //end if diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/CachedRowSet.java --- a/jdk/src/share/classes/javax/sql/rowset/CachedRowSet.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/CachedRowSet.java Tue Oct 26 13:45:25 2010 -0700 @@ -39,7 +39,7 @@ * CachedRowSet must implement. *

* The reference implementation of the CachedRowSet interface provided - * by Sun Microsystems is a standard implementation. Developers may use this implementation + * by Oracle Corporation is a standard implementation. Developers may use this implementation * just as it is, they may extend it, or they may choose to write their own implementations * of this interface. *

@@ -1623,4 +1623,3 @@ public boolean previousPage() throws SQLException; } - diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java --- a/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -306,9 +306,9 @@ public void setColumnLabel(int columnIndex, String label) throws SQLException { checkColRange(columnIndex); if (label != null) { - colInfo[columnIndex].columnLabel = new String(label); + colInfo[columnIndex].columnLabel = label; } else { - colInfo[columnIndex].columnLabel = new String(""); + colInfo[columnIndex].columnLabel = ""; } } @@ -326,9 +326,9 @@ public void setColumnName(int columnIndex, String columnName) throws SQLException { checkColRange(columnIndex); if (columnName != null) { - colInfo[columnIndex].columnName = new String(columnName); + colInfo[columnIndex].columnName = columnName; } else { - colInfo[columnIndex].columnName = new String(""); + colInfo[columnIndex].columnName = ""; } } @@ -348,9 +348,9 @@ public void setSchemaName(int columnIndex, String schemaName) throws SQLException { checkColRange(columnIndex); if (schemaName != null ) { - colInfo[columnIndex].schemaName = new String(schemaName); + colInfo[columnIndex].schemaName = schemaName; } else { - colInfo[columnIndex].schemaName = new String(""); + colInfo[columnIndex].schemaName = ""; } } @@ -411,9 +411,9 @@ public void setTableName(int columnIndex, String tableName) throws SQLException { checkColRange(columnIndex); if (tableName != null) { - colInfo[columnIndex].tableName = new String(tableName); + colInfo[columnIndex].tableName = tableName; } else { - colInfo[columnIndex].tableName = new String(""); + colInfo[columnIndex].tableName = ""; } } @@ -432,9 +432,9 @@ public void setCatalogName(int columnIndex, String catalogName) throws SQLException { checkColRange(columnIndex); if (catalogName != null) - colInfo[columnIndex].catName = new String(catalogName); + colInfo[columnIndex].catName = catalogName; else - colInfo[columnIndex].catName = new String(""); + colInfo[columnIndex].catName = ""; } /** @@ -474,9 +474,9 @@ throws SQLException { checkColRange(columnIndex); if (typeName != null) { - colInfo[columnIndex].colTypeName = new String(typeName); + colInfo[columnIndex].colTypeName = typeName; } else { - colInfo[columnIndex].colTypeName = new String(""); + colInfo[columnIndex].colTypeName = ""; } } @@ -827,7 +827,7 @@ * or the given column number is out of bounds */ public String getColumnClassName(int columnIndex) throws SQLException { - String className = (new String()).getClass().getName(); + String className = String.class.getName(); int sqlType = getColumnType(columnIndex); @@ -835,65 +835,62 @@ case Types.NUMERIC: case Types.DECIMAL: - className = (new java.math.BigDecimal(0)).getClass().getName (); + className = java.math.BigDecimal.class.getName(); break; case Types.BIT: - className = (new Boolean(false)).getClass().getName (); + className = java.lang.Boolean.class.getName(); break; case Types.TINYINT: - className = (new Byte("0")).getClass().getName (); + className = java.lang.Byte.class.getName(); break; case Types.SMALLINT: - className = (new Short("0")).getClass().getName (); + className = java.lang.Short.class.getName(); break; case Types.INTEGER: - className = (new Integer(0)).getClass().getName (); + className = java.lang.Integer.class.getName(); break; case Types.BIGINT: - className = (new Long(0)).getClass().getName (); + className = java.lang.Long.class.getName(); break; case Types.REAL: - className = (new Float(0)).getClass().getName (); + className = java.lang.Float.class.getName(); break; case Types.FLOAT: case Types.DOUBLE: - className = (new Double(0)).getClass().getName(); + className = java.lang.Double.class.getName(); break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: - byte[] b = {}; - className = (b.getClass()).getName(); + className = "byte[]"; break; case Types.DATE: - className = (new java.sql.Date(123456)).getClass().getName (); + className = java.sql.Date.class.getName(); break; case Types.TIME: - className = (new java.sql.Time(123456)).getClass().getName (); + className = java.sql.Time.class.getName(); break; case Types.TIMESTAMP: - className = (new java.sql.Timestamp(123456)).getClass().getName (); + className = java.sql.Timestamp.class.getName(); break; case Types.BLOB: - byte[] blob = {}; - className = (blob.getClass()).getName(); + className = java.sql.Blob.class.getName(); break; case Types.CLOB: - char[] c = {}; - className = (c.getClass()).getName(); + className = java.sql.Clob.class.getName(); break; } diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java --- a/jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java Tue Oct 26 13:45:25 2010 -0700 @@ -29,7 +29,6 @@ import java.security.PrivilegedAction; import java.sql.SQLException; import java.util.ServiceLoader; -import javax.sql.rowset.RowSetFactory; /** * A factory API that enables applications to obtain a @@ -82,15 +81,15 @@ * the RowSetFactory implementation class to load:

*
    *
  • - * The System property {@code javax.sql.rowset.RowsetFactory}. For example: + * The System property {@code javax.sql.rowset.RowSetFactory}. For example: *
      *
    • - * -Djavax.sql.rowset.RowsetFactory=com.sun.rowset.RowSetFactoryImpl + * -Djavax.sql.rowset.RowSetFactory=com.sun.rowset.RowSetFactoryImpl *
    • *
    *
  • - * The ServiceLocator API. The ServiceLocator API will look - * for a classname in the file + * The {@link ServiceLoader} API. The {@code ServiceLoader} API will look + * for a class name in the file * {@code META-INF/services/javax.sql.rowset.RowSetFactory} * in jars available to the runtime. For example, to have the the RowSetFactory * implementation {@code com.sun.rowset.RowSetFactoryImpl } loaded, the @@ -271,7 +270,7 @@ /** * Returns the requested System Property. If a {@code SecurityException} * occurs, just return NULL - * @param propName - System property to retreive + * @param propName - System property to retrieve * @return The System property value or NULL if the property does not exist * or a {@code SecurityException} occurs. */ diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/WebRowSet.java --- a/jdk/src/share/classes/javax/sql/rowset/WebRowSet.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/WebRowSet.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -115,7 +115,7 @@ * <url>jdbc:thin:oracle</url> * <sync-provider> * <sync-provider-name>.com.rowset.provider.RIOptimisticProvider</sync-provider-name> - * <sync-provider-vendor>Sun Microsystems</sync-provider-vendor> + * <sync-provider-vendor>Oracle Corporation</sync-provider-vendor> * <sync-provider-version>1.0</sync-provider-name> * <sync-provider-grade>LOW</sync-provider-grade> * <data-source-lock>NONE</data-source-lock> @@ -489,7 +489,7 @@ * tags and their valid values for a WebRowSet implementation. */ public static String PUBLIC_XML_SCHEMA = - "--//Sun Microsystems, Inc.//XSD Schema//EN"; + "--//Oracle Corporation//XSD Schema//EN"; /** * The URL for the XML Schema definition file that defines the XML tags and diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/rowset.properties --- a/jdk/src/share/classes/javax/sql/rowset/rowset.properties Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/rowset.properties Tue Oct 26 13:45:25 2010 -0700 @@ -3,10 +3,10 @@ # Optimistic synchonriztaion provider rowset.provider.classname.0=com.sun.rowset.providers.RIOptimisticProvider -rowset.provider.vendor.0=Sun Microsystems Inc +rowset.provider.vendor.0=Oracle Corporation rowset.provider.version.0=1.0 # XML Provider using standard XML schema rowset.provider.classname.1=com.sun.rowset.providers.RIXMLProvider -rowset.provider.vendor.1=Sun Microsystems Inc. +rowset.provider.vendor.1=Oracle Corporation rowset.provider.version.1=1.0 diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java --- a/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -137,7 +137,7 @@ * values of a UDT to the database. */ public void writeBoolean(boolean x) throws SQLException { - attribs.add(new Boolean(x)); + attribs.add(Boolean.valueOf(x)); } /** @@ -151,7 +151,7 @@ * values of a UDT to the database. */ public void writeByte(byte x) throws SQLException { - attribs.add(new Byte(x)); + attribs.add(Byte.valueOf(x)); } /** @@ -165,7 +165,7 @@ * values of a UDT to the database. */ public void writeShort(short x) throws SQLException { - attribs.add(new Short(x)); + attribs.add(Short.valueOf(x)); } /** @@ -179,7 +179,7 @@ * values of a UDT to the database. */ public void writeInt(int x) throws SQLException { - attribs.add(new Integer(x)); + attribs.add(Integer.valueOf(x)); } /** @@ -193,7 +193,7 @@ * values of a UDT to the database. */ public void writeLong(long x) throws SQLException { - attribs.add(new Long(x)); + attribs.add(Long.valueOf(x)); } /** diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,7 +77,7 @@ throw new SQLException("Cannot instantiate a SerialRef object " + "that returns a null base type name"); } else { - baseTypeName = new String(ref.getBaseTypeName()); + baseTypeName = ref.getBaseTypeName(); } } @@ -110,7 +110,7 @@ throws SerialException { map = new Hashtable(map); - if (!object.equals(null)) { + if (object != null) { return map.get(object); } else { throw new SerialException("The object is not set"); diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -94,7 +94,7 @@ try { // get the type name - SQLTypeName = new String(in.getSQLTypeName()); + SQLTypeName = in.getSQLTypeName(); System.out.println("SQLTypeName: " + SQLTypeName); // get the attributes of the struct @@ -137,7 +137,7 @@ try { //set the type name - SQLTypeName = new String(in.getSQLTypeName()); + SQLTypeName = in.getSQLTypeName(); Vector tmp = new Vector(); in.writeSQL(new SQLOutputImpl(tmp, map)); @@ -247,7 +247,7 @@ } /** - * The identifier that assists in the serialization of this + * The identifier that assists in the serialization of this * SerialStruct object. */ static final long serialVersionUID = -8322445504027483372L; diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java --- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java Tue Oct 26 13:45:25 2010 -0700 @@ -125,12 +125,12 @@ * * # Optimistic synchronization provider * rowset.provider.classname.0=com.sun.rowset.providers.RIOptimisticProvider - * rowset.provider.vendor.0=Sun Microsystems Inc + * rowset.provider.vendor.0=Oracle Corporation * rowset.provider.version.0=1.0 * * # XML Provider using standard XML schema * rowset.provider.classname.1=com.sun.rowset.providers.RIXMLProvider - * rowset.provider.vendor.1=Sun Microsystems Inc. + * rowset.provider.vendor.1=Oracle Corporation * rowset.provider.version.1=1.0 * * The SyncFactory checks this file and registers the @@ -369,7 +369,7 @@ try { // check if user is supplying his Synchronisation Provider - // Implementation if not use Sun's implementation. + // Implementation if not using Oracle's implementation. // properties.load(new FileInputStream(ROWSET_PROPERTIES)); // The rowset.properties needs to be in jdk/jre/lib when diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/spi/SyncProvider.java --- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncProvider.java Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncProvider.java Tue Oct 26 13:45:25 2010 -0700 @@ -91,8 +91,8 @@ * *

    * A vendor can register a SyncProvider implementation class name - * with Sun Microsystems, Inc. by sending email to jdbc@sun.com. - * Sun will maintain a database listing the + * with Oracle Corporation by sending email to jdbc@sun.com. + * Oracle will maintain a database listing the * available SyncProvider implementations for use with compliant * RowSet implementations. This database will be similar to the * one already maintained to list available JDBC drivers. diff -r 79caba0caf4f -r e0bc5b441d60 jdk/src/share/classes/javax/sql/rowset/spi/package.html --- a/jdk/src/share/classes/javax/sql/rowset/spi/package.html Fri Sep 24 22:42:14 2010 -0700 +++ b/jdk/src/share/classes/javax/sql/rowset/spi/package.html Tue Oct 26 13:45:25 2010 -0700 @@ -8,7 +8,7 @@ - - - - - - + + - - - + - + - + - + Must set property 'includes' - - - - - + - + Must set property 'run.classname' - + - - - + @@ -118,7 +118,7 @@ - + @@ -127,36 +127,36 @@ - + Some tests failed; see report for details. - + - + - + Must set property 'debug.classname' - + Must set property 'jtreg.tests' - + - + Must set property 'class' @@ -169,16 +169,16 @@ - + - - - + @@ -187,7 +187,7 @@ - + @@ -196,26 +196,26 @@ - + - + - + - - + - @@ -236,7 +236,7 @@ - + @@ -251,28 +251,29 @@ - - + - + diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java --- a/langtools/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -99,9 +99,6 @@ private static Context preRegister(Context context) { Bark.preRegister(context); - // force the use of the scanner that captures Javadoc comments - DocCommentScanner.Factory.preRegister(context); - if (context.get(JavaFileManager.class) == null) JavacFileManager.preRegister(context); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * 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,9 +96,6 @@ args.getClass(); context.getClass(); fileObjects.getClass(); - - // force the use of the scanner that captures Javadoc comments - com.sun.tools.javac.parser.DocCommentScanner.Factory.preRegister(context); } JavacTaskImpl(JavacTool tool, @@ -337,9 +334,13 @@ ListBuffer elements = new ListBuffer(); for (JCCompilationUnit unit : units) { - for (JCTree node : unit.defs) - if (node.getTag() == JCTree.CLASSDEF) - elements.append(((JCTree.JCClassDecl) node).sym); + for (JCTree node : unit.defs) { + if (node.getTag() == JCTree.CLASSDEF) { + JCClassDecl cdef = (JCClassDecl) node; + if (cdef.sym != null) // maybe null if errors in anno processing + elements.append(cdef.sym); + } + } } return elements.toList(); } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * 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,6 @@ import com.sun.tools.javac.comp.MemberEnter; import com.sun.tools.javac.comp.Resolve; import com.sun.tools.javac.model.JavacElements; -import com.sun.tools.javac.processing.JavacMessager; import com.sun.tools.javac.processing.JavacProcessingEnvironment; import com.sun.tools.javac.tree.JCTree.*; import com.sun.tools.javac.tree.JCTree; @@ -81,14 +80,15 @@ */ public class JavacTrees extends Trees { - private final Resolve resolve; - private final Enter enter; - private final Log log; - private final MemberEnter memberEnter; - private final Attr attr; - private final TreeMaker treeMaker; - private final JavacElements elements; - private final JavacTaskImpl javacTaskImpl; + // in a world of a single context per compilation, these would all be final + private Resolve resolve; + private Enter enter; + private Log log; + private MemberEnter memberEnter; + private Attr attr; + private TreeMaker treeMaker; + private JavacElements elements; + private JavacTaskImpl javacTaskImpl; public static JavacTrees instance(JavaCompiler.CompilationTask task) { if (!(task instanceof JavacTaskImpl)) @@ -111,6 +111,14 @@ private JavacTrees(Context context) { context.put(JavacTrees.class, this); + init(context); + } + + public void updateContext(Context context) { + init(context); + } + + private void init(Context context) { attr = Attr.instance(context); enter = Enter.instance(context); elements = JavacElements.instance(context); @@ -337,6 +345,7 @@ super(M); } + @Override public T copy(T t, JCTree leaf) { T t2 = super.copy(t, leaf); if (t == leaf) diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/code/Scope.java --- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Tue Oct 26 13:45:25 2010 -0700 @@ -70,6 +70,45 @@ */ public int nelems = 0; + /** A timestamp - useful to quickly check whether a scope has changed or not + */ + public ScopeCounter scopeCounter; + + static ScopeCounter dummyCounter = new ScopeCounter() { + @Override + public void inc() { + //do nothing + } + }; + + public static class ScopeCounter { + protected static final Context.Key scopeCounterKey = + new Context.Key(); + + public static ScopeCounter instance(Context context) { + ScopeCounter instance = context.get(scopeCounterKey); + if (instance == null) + instance = new ScopeCounter(context); + return instance; + } + + protected ScopeCounter(Context context) { + context.put(scopeCounterKey, this); + } + + private ScopeCounter() {}; + + private long val = 0; + + public void inc() { + val++; + } + + public long val() { + return val; + } + } + /** Every hash bucket is a list of Entry's which ends in sentinel. */ private static final Entry sentinel = new Entry(null, null, null, null); @@ -80,12 +119,12 @@ /** A value for the empty scope. */ - public static final Scope emptyScope = new Scope(null, null, new Entry[]{}); + public static final Scope emptyScope = new Scope(null, null, new Entry[]{}, dummyCounter); /** Construct a new scope, within scope next, with given owner, using * given table. The table's length must be an exponent of 2. */ - Scope(Scope next, Symbol owner, Entry[] table) { + private Scope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) { this.next = next; assert emptyScope == null || owner != null; this.owner = owner; @@ -94,13 +133,18 @@ this.elems = null; this.nelems = 0; this.shared = 0; + this.scopeCounter = scopeCounter; } /** Construct a new scope, within scope next, with given owner, * using a fresh table of length INITIAL_SIZE. */ public Scope(Symbol owner) { - this(null, owner, new Entry[INITIAL_SIZE]); + this(owner, dummyCounter); + } + + protected Scope(Symbol owner, ScopeCounter scopeCounter) { + this(null, owner, new Entry[INITIAL_SIZE], scopeCounter); for (int i = 0; i < INITIAL_SIZE; i++) table[i] = sentinel; } @@ -110,7 +154,7 @@ * of fresh tables. */ public Scope dup() { - Scope result = new Scope(this, this.owner, this.table); + Scope result = new Scope(this, this.owner, this.table, scopeCounter); shared++; // System.out.println("====> duping scope " + this.hashCode() + " owned by " + this.owner + " to " + result.hashCode()); // new Error().printStackTrace(System.out); @@ -123,7 +167,7 @@ * of fresh tables. */ public Scope dup(Symbol newOwner) { - Scope result = new Scope(this, newOwner, this.table); + Scope result = new Scope(this, newOwner, this.table, scopeCounter); shared++; // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode()); // new Error().printStackTrace(System.out); @@ -135,7 +179,7 @@ * the table of its outer scope. */ public Scope dupUnshared() { - return new Scope(this, this.owner, this.table.clone()); + return new Scope(this, this.owner, this.table.clone(), scopeCounter); } /** Remove all entries of this scope from its table, if shared @@ -211,6 +255,7 @@ table[hash] = e; elems = e; nelems++; + scopeCounter.inc(); } Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) { @@ -226,6 +271,8 @@ while (e.scope == this && e.sym != sym) e = e.next(); if (e.scope == null) return; + scopeCounter.inc(); + // remove e from table and shadowed list; Entry te = table[sym.name.hashCode() & hashMask]; if (te == e) @@ -472,7 +519,7 @@ public static final Entry[] emptyTable = new Entry[0]; public DelegatedScope(Scope outer) { - super(outer, outer.owner, emptyTable); + super(outer, outer.owner, emptyTable, outer.scopeCounter); delegatee = outer; } public Scope dup() { @@ -498,10 +545,22 @@ } } + /** A class scope, for which a scope counter should be provided */ + public static class ClassScope extends Scope { + + ClassScope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) { + super(next, owner, table, scopeCounter); + } + + public ClassScope(Symbol owner, ScopeCounter scopeCounter) { + super(owner, scopeCounter); + } + } + /** An error scope, for which the owner should be an error symbol. */ public static class ErrorScope extends Scope { ErrorScope(Scope next, Symbol errSymbol, Entry[] table) { - super(next, /*owner=*/errSymbol, table); + super(next, /*owner=*/errSymbol, table, dummyCounter); } public ErrorScope(Symbol errSymbol) { super(errSymbol); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/code/Source.java --- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Tue Oct 26 13:45:25 2010 -0700 @@ -25,11 +25,14 @@ package com.sun.tools.javac.code; +import java.util.*; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; + import com.sun.tools.javac.util.*; import com.sun.tools.javac.jvm.Target; -import javax.lang.model.SourceVersion; -import static javax.lang.model.SourceVersion.*; -import java.util.*; + +import static com.sun.tools.javac.main.OptionName.*; /** The source language version accepted. * @@ -71,7 +74,7 @@ Source instance = context.get(sourceKey); if (instance == null) { Options options = Options.instance(context); - String sourceString = options.get("-source"); + String sourceString = options.get(SOURCE); if (sourceString != null) instance = lookup(sourceString); if (instance == null) instance = DEFAULT; context.put(sourceKey, instance); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -960,6 +960,8 @@ return ElementKind.ENUM_CONSTANT; } else if (owner.kind == TYP || owner.kind == ERR) { return ElementKind.FIELD; + } else if (isResourceVariable()) { + return ElementKind.RESOURCE_VARIABLE; } else { return ElementKind.LOCAL_VARIABLE; } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Tue Oct 26 13:45:25 2010 -0700 @@ -74,6 +74,7 @@ public final JCNoType voidType = new JCNoType(TypeTags.VOID); private final Names names; + private final Scope.ScopeCounter scopeCounter; private final ClassReader reader; private final Target target; @@ -340,6 +341,7 @@ context.put(symtabKey, this); names = Names.instance(context); + scopeCounter = Scope.ScopeCounter.instance(context); target = Target.instance(context); // Create the unknown type @@ -386,7 +388,7 @@ // Create class to hold all predefined constants and operations. predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage); - Scope scope = new Scope(predefClass); + Scope scope = new Scope.ClassScope(predefClass, scopeCounter); predefClass.members_field = scope; // Enter symbols for basic types. @@ -476,7 +478,7 @@ proprietarySymbol.completer = null; proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE; proprietarySymbol.erasure_field = proprietaryType; - proprietarySymbol.members_field = new Scope(proprietarySymbol); + proprietarySymbol.members_field = new Scope.ClassScope(proprietarySymbol, scopeCounter); proprietaryType.typarams_field = List.nil(); proprietaryType.allparams_field = List.nil(); proprietaryType.supertype_field = annotationType; @@ -488,7 +490,7 @@ ClassType arrayClassType = (ClassType)arrayClass.type; arrayClassType.supertype_field = objectType; arrayClassType.interfaces_field = List.of(cloneableType, serializableType); - arrayClass.members_field = new Scope(arrayClass); + arrayClass.members_field = new Scope.ClassScope(arrayClass, scopeCounter); lengthVar = new VarSymbol( PUBLIC | FINAL, names.length, diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/code/Types.java --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Tue Oct 26 13:45:25 2010 -0700 @@ -69,6 +69,7 @@ new Context.Key(); final Symtab syms; + final Scope.ScopeCounter scopeCounter; final JavacMessages messages; final Names names; final boolean allowBoxing; @@ -89,6 +90,7 @@ protected Types(Context context) { context.put(typesKey, this); syms = Symtab.instance(context); + scopeCounter = Scope.ScopeCounter.instance(context); names = Names.instance(context); allowBoxing = Source.instance(context).allowBoxing(); reader = ClassReader.instance(context); @@ -1984,22 +1986,26 @@ final MethodSymbol cachedImpl; final Filter implFilter; final boolean checkResult; + final Scope.ScopeCounter scopeCounter; public Entry(MethodSymbol cachedImpl, Filter scopeFilter, - boolean checkResult) { + boolean checkResult, + Scope.ScopeCounter scopeCounter) { this.cachedImpl = cachedImpl; this.implFilter = scopeFilter; this.checkResult = checkResult; + this.scopeCounter = scopeCounter; } - boolean matches(Filter scopeFilter, boolean checkResult) { + boolean matches(Filter scopeFilter, boolean checkResult, Scope.ScopeCounter scopeCounter) { return this.implFilter == scopeFilter && - this.checkResult == checkResult; + this.checkResult == checkResult && + this.scopeCounter.val() >= scopeCounter.val(); } } - MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter implFilter) { + MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter implFilter, Scope.ScopeCounter scopeCounter) { SoftReference> ref_cache = _map.get(ms); Map cache = ref_cache != null ? ref_cache.get() : null; if (cache == null) { @@ -2008,9 +2014,9 @@ } Entry e = cache.get(origin); if (e == null || - !e.matches(implFilter, checkResult)) { + !e.matches(implFilter, checkResult, scopeCounter)) { MethodSymbol impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter); - cache.put(origin, new Entry(impl, implFilter, checkResult)); + cache.put(origin, new Entry(impl, implFilter, checkResult, scopeCounter)); return impl; } else { @@ -2038,7 +2044,7 @@ private ImplementationCache implCache = new ImplementationCache(); public MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult, Filter implFilter) { - return implCache.get(ms, origin, checkResult, implFilter); + return implCache.get(ms, origin, checkResult, implFilter, scopeCounter); } // diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Oct 26 13:45:25 2010 -0700 @@ -119,10 +119,10 @@ allowAnonOuterThis = source.allowAnonOuterThis(); allowStringsInSwitch = source.allowStringsInSwitch(); sourceName = source.name; - relax = (options.get("-retrofit") != null || - options.get("-relax") != null); - useBeforeDeclarationWarning = options.get("useBeforeDeclarationWarning") != null; - enableSunApiLintControl = options.get("enableSunApiLintControl") != null; + relax = (options.isSet("-retrofit") || + options.isSet("-relax")); + useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning"); + enableSunApiLintControl = options.isSet("enableSunApiLintControl"); } /** Switch: relax some constraints for retrofit mode. @@ -1422,7 +1422,8 @@ // Compute the result type. Type restype = mtype.getReturnType(); - assert restype.tag != WILDCARD : mtype; + if (restype.tag == WILDCARD) + throw new AssertionError(mtype); // as a special case, array.clone() has a result that is // the same as static type of the array being cloned diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/comp/Check.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Oct 26 13:45:25 2010 -0700 @@ -25,7 +25,6 @@ package com.sun.tools.javac.comp; -import com.sun.source.tree.AssignmentTree; import java.util.*; import java.util.Set; @@ -46,6 +45,8 @@ import static com.sun.tools.javac.code.Kinds.*; import static com.sun.tools.javac.code.TypeTags.*; +import static com.sun.tools.javac.main.OptionName.*; + /** Type checking helper class for the attribution phase. * *

    This is NOT part of any supported API. @@ -60,6 +61,7 @@ private final Names names; private final Log log; private final Symtab syms; + private final Enter enter; private final Infer infer; private final Types types; private final JCDiagnostic.Factory diags; @@ -86,6 +88,7 @@ names = Names.instance(context); log = Log.instance(context); syms = Symtab.instance(context); + enter = Enter.instance(context); infer = Infer.instance(context); this.types = Types.instance(context); diags = JCDiagnostic.Factory.instance(context); @@ -97,10 +100,10 @@ allowGenerics = source.allowGenerics(); allowAnnotations = source.allowAnnotations(); allowCovariantReturns = source.allowCovariantReturns(); - complexInference = options.get("-complexinference") != null; - skipAnnotations = options.get("skipAnnotations") != null; - warnOnSyntheticConflicts = options.get("warnOnSyntheticConflicts") != null; - suppressAbortOnBadClassFile = options.get("suppressAbortOnBadClassFile") != null; + complexInference = options.isSet(COMPLEXINFERENCE); + skipAnnotations = options.isSet("skipAnnotations"); + warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); + suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); Target target = Target.instance(context); syntheticNameChar = target.syntheticNameChar(); @@ -1727,6 +1730,113 @@ return undef; } + void checkNonCyclicDecl(JCClassDecl tree) { + CycleChecker cc = new CycleChecker(); + cc.scan(tree); + if (!cc.errorFound && !cc.partialCheck) { + tree.sym.flags_field |= ACYCLIC; + } + } + + class CycleChecker extends TreeScanner { + + List seenClasses = List.nil(); + boolean errorFound = false; + boolean partialCheck = false; + + private void checkSymbol(DiagnosticPosition pos, Symbol sym) { + if (sym != null && sym.kind == TYP) { + Env classEnv = enter.getEnv((TypeSymbol)sym); + if (classEnv != null) { + DiagnosticSource prevSource = log.currentSource(); + try { + log.useSource(classEnv.toplevel.sourcefile); + scan(classEnv.tree); + } + finally { + log.useSource(prevSource.getFile()); + } + } else if (sym.kind == TYP) { + checkClass(pos, sym, List.nil()); + } + } else { + //not completed yet + partialCheck = true; + } + } + + @Override + public void visitSelect(JCFieldAccess tree) { + super.visitSelect(tree); + checkSymbol(tree.pos(), tree.sym); + } + + @Override + public void visitIdent(JCIdent tree) { + checkSymbol(tree.pos(), tree.sym); + } + + @Override + public void visitTypeApply(JCTypeApply tree) { + scan(tree.clazz); + } + + @Override + public void visitTypeArray(JCArrayTypeTree tree) { + scan(tree.elemtype); + } + + @Override + public void visitClassDef(JCClassDecl tree) { + List supertypes = List.nil(); + if (tree.getExtendsClause() != null) { + supertypes = supertypes.prepend(tree.getExtendsClause()); + } + if (tree.getImplementsClause() != null) { + for (JCTree intf : tree.getImplementsClause()) { + supertypes = supertypes.prepend(intf); + } + } + checkClass(tree.pos(), tree.sym, supertypes); + } + + void checkClass(DiagnosticPosition pos, Symbol c, List supertypes) { + if ((c.flags_field & ACYCLIC) != 0) + return; + if (seenClasses.contains(c)) { + errorFound = true; + noteCyclic(pos, (ClassSymbol)c); + } else if (!c.type.isErroneous()) { + try { + seenClasses = seenClasses.prepend(c); + if (c.type.tag == CLASS) { + if (supertypes.nonEmpty()) { + scan(supertypes); + } + else { + ClassType ct = (ClassType)c.type; + if (ct.supertype_field == null || + ct.interfaces_field == null) { + //not completed yet + partialCheck = true; + return; + } + checkSymbol(pos, ct.supertype_field.tsym); + for (Type intf : ct.interfaces_field) { + checkSymbol(pos, intf.tsym); + } + } + if (c.owner.kind == TYP) { + checkSymbol(pos, c.owner); + } + } + } finally { + seenClasses = seenClasses.tail; + } + } + } + } + /** Check for cyclic references. Issue an error if the * symbol of the type referred to has a LOCKED flag set. * diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Tue Oct 26 13:45:25 2010 -0700 @@ -94,6 +94,7 @@ Log log; Symtab syms; + Scope.ScopeCounter scopeCounter; Check chk; TreeMaker make; ClassReader reader; @@ -121,6 +122,7 @@ reader = ClassReader.instance(context); make = TreeMaker.instance(context); syms = Symtab.instance(context); + scopeCounter = Scope.ScopeCounter.instance(context); chk = Check.instance(context); memberEnter = MemberEnter.instance(context); types = Types.instance(context); @@ -189,7 +191,7 @@ */ public Env classEnv(JCClassDecl tree, Env env) { Env localEnv = - env.dup(tree, env.info.dup(new Scope(tree.sym))); + env.dup(tree, env.info.dup(new Scope.ClassScope(tree.sym, scopeCounter))); localEnv.enclClass = tree; localEnv.outer = env; localEnv.info.isSelfCall = false; @@ -325,7 +327,7 @@ c.flatname = names.fromString(tree.packge + "." + name); c.sourcefile = tree.sourcefile; c.completer = null; - c.members_field = new Scope(c); + c.members_field = new Scope.ClassScope(c, scopeCounter); tree.packge.package_info = c; } classEnter(tree.defs, topEnv); @@ -393,7 +395,7 @@ c.completer = memberEnter; c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree); c.sourcefile = env.toplevel.sourcefile; - c.members_field = new Scope(c); + c.members_field = new Scope.ClassScope(c, scopeCounter); ClassType ct = (ClassType)c.type; if (owner.kind != PCK && (c.flags_field & STATIC) == 0) { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Oct 26 13:45:25 2010 -0700 @@ -80,25 +80,12 @@ } - public static class InferenceException extends RuntimeException { + public static class InferenceException extends Resolve.InapplicableMethodException { private static final long serialVersionUID = 0; - JCDiagnostic diagnostic; - JCDiagnostic.Factory diags; - InferenceException(JCDiagnostic.Factory diags) { - this.diagnostic = null; - this.diags = diags; + super(diags); } - - InferenceException setMessage(String key, Object... args) { - this.diagnostic = diags.fragment(key, args); - return this; - } - - public JCDiagnostic getDiagnostic() { - return diagnostic; - } } public static class NoInstanceException extends InferenceException { @@ -320,7 +307,7 @@ Type qtype1 = types.subst(that.qtype, that.tvars, undetvars); if (!types.isSubtype(qtype1, to)) { throw unambiguousNoInstanceException - .setMessage("no.conforming.instance.exists", + .setMessage("infer.no.conforming.instance.exists", that.tvars, that.qtype, to); } for (List l = undetvars; l.nonEmpty(); l = l.tail) @@ -378,6 +365,11 @@ // instantiate all polymorphic argument types and // set up lower bounds constraints for undetvars Type varargsFormal = useVarargs ? formals.last() : null; + if (varargsFormal == null && + actuals.size() != formals.size()) { + throw unambiguousNoInstanceException + .setMessage("infer.arg.length.mismatch"); + } while (actuals.nonEmpty() && formals.head != varargsFormal) { Type formal = formals.head; Type actual = actuals.head.baseType(); @@ -390,19 +382,16 @@ : types.isSubtypeUnchecked(actual, undetFormal, warn); if (!works) { throw unambiguousNoInstanceException - .setMessage("no.conforming.assignment.exists", + .setMessage("infer.no.conforming.assignment.exists", tvars, actualNoCapture, formal); } formals = formals.tail; actuals = actuals.tail; actualsNoCapture = actualsNoCapture.tail; } - if (formals.head != varargsFormal || // not enough args - !useVarargs && actuals.nonEmpty()) { // too many args - // argument lists differ in length - throw unambiguousNoInstanceException - .setMessage("arg.length.mismatch"); - } + + if (formals.head != varargsFormal) // not enough args + throw unambiguousNoInstanceException.setMessage("infer.arg.length.mismatch"); // for varargs arguments as well if (useVarargs) { @@ -416,7 +405,7 @@ boolean works = types.isConvertible(actual, elemUndet, warn); if (!works) { throw unambiguousNoInstanceException - .setMessage("no.conforming.assignment.exists", + .setMessage("infer.no.conforming.assignment.exists", tvars, actualNoCapture, elemType); } actuals = actuals.tail; diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Oct 26 13:45:25 2010 -0700 @@ -68,6 +68,7 @@ private Names names; private Log log; private Symtab syms; + private Scope.ScopeCounter scopeCounter; private Resolve rs; private Check chk; private Attr attr; @@ -90,6 +91,7 @@ names = Names.instance(context); log = Log.instance(context); syms = Symtab.instance(context); + scopeCounter = Scope.ScopeCounter.instance(context); rs = Resolve.instance(context); chk = Check.instance(context); attr = Attr.instance(context); @@ -107,7 +109,7 @@ types = Types.instance(context); Options options = Options.instance(context); - debugLower = options.get("debuglower") != null; + debugLower = options.isSet("debuglower"); pkginfoOpt = PkgInfo.get(options); } @@ -569,7 +571,7 @@ c.flatname = chk.localClassName(c); c.sourcefile = owner.sourcefile; c.completer = null; - c.members_field = new Scope(c); + c.members_field = new Scope.ClassScope(c, scopeCounter); c.flags_field = flags; ClassType ctype = (ClassType) c.type; ctype.supertype_field = syms.objectType; @@ -2677,7 +2679,8 @@ } //where private JCTree convert(JCTree tree, Type pt) { - if (tree.type == pt) return tree; + if (tree.type == pt || tree.type.tag == TypeTags.BOT) + return tree; JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree); result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt) : pt; diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Oct 26 13:45:25 2010 -0700 @@ -67,6 +67,7 @@ private final Check chk; private final Attr attr; private final Symtab syms; + private final Scope.ScopeCounter scopeCounter; private final TreeMaker make; private final ClassReader reader; private final Todo todo; @@ -92,6 +93,7 @@ chk = Check.instance(context); attr = Attr.instance(context); syms = Symtab.instance(context); + scopeCounter = Scope.ScopeCounter.instance(context); make = TreeMaker.instance(context); reader = ClassReader.instance(context); todo = Todo.instance(context); @@ -100,7 +102,7 @@ diags = JCDiagnostic.Factory.instance(context); target = Target.instance(context); Options options = Options.instance(context); - skipAnnotations = options.get("skipAnnotations") != null; + skipAnnotations = options.isSet("skipAnnotations"); } /** A queue for classes whose members still need to be entered into the @@ -925,7 +927,7 @@ tp.accept(new TypeAnnotate(baseEnv)); tree.accept(new TypeAnnotate(env)); - chk.checkNonCyclic(tree.pos(), c.type); + chk.checkNonCyclicDecl(tree); attr.attribTypeVariables(tree.typarams, baseEnv); @@ -1087,7 +1089,7 @@ private Env baseEnv(JCClassDecl tree, Env env) { - Scope baseScope = new Scope(tree.sym); + Scope baseScope = new Scope.ClassScope(tree.sym, scopeCounter); //import already entered local classes into base scope for (Scope.Entry e = env.outer.info.scope.elems ; e != null ; e = e.sibling) { if (e.sym.isLocal()) { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Oct 26 13:45:25 2010 -0700 @@ -110,15 +110,17 @@ boxingEnabled = source.allowBoxing(); varargsEnabled = source.allowVarargs(); Options options = Options.instance(context); - debugResolve = options.get("debugresolve") != null; - allowTransitionalJSR292 = options.get("allowTransitionalJSR292") != null; + debugResolve = options.isSet("debugresolve"); + allowTransitionalJSR292 = options.isSet("allowTransitionalJSR292"); Target target = Target.instance(context); allowMethodHandles = allowTransitionalJSR292 || target.hasMethodHandles(); allowInvokeDynamic = (allowTransitionalJSR292 || target.hasInvokedynamic()) && - options.get("invokedynamic") != null; + options.isSet("invokedynamic"); polymorphicSignatureScope = new Scope(syms.noSymbol); + + inapplicableMethodException = new InapplicableMethodException(diags); } /** error symbols, which are returned when resolution fails @@ -318,7 +320,8 @@ throws Infer.InferenceException { boolean polymorphicSignature = (m.isPolymorphicSignatureGeneric() && allowMethodHandles) || isTransitionalDynamicCallSite(site, m); - if (useVarargs && (m.flags() & VARARGS) == 0) return null; + if (useVarargs && (m.flags() & VARARGS) == 0) + throw inapplicableMethodException.setMessage(null); Type mt = types.memberType(site, m); // tvars is the list of formal type variables for which type arguments @@ -334,7 +337,7 @@ } else if (mt.tag == FORALL && typeargtypes.nonEmpty()) { ForAll pmt = (ForAll) mt; if (typeargtypes.length() != pmt.tvars.length()) - return null; + throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args // Check type arguments are within bounds List formals = pmt.tvars; List actuals = typeargtypes; @@ -343,7 +346,7 @@ pmt.tvars, typeargtypes); for (; bounds.nonEmpty(); bounds = bounds.tail) if (!types.isSubtypeUnchecked(actuals.head, bounds.head, warn)) - return null; + throw inapplicableMethodException.setMessage("explicit.param.do.not.conform.to.bounds",actuals.head, bounds); formals = formals.tail; actuals = actuals.tail; } @@ -375,11 +378,10 @@ allowBoxing, useVarargs, warn); - return - argumentsAcceptable(argtypes, mt.getParameterTypes(), - allowBoxing, useVarargs, warn) - ? mt - : null; + + checkRawArgumentsAcceptable(argtypes, mt.getParameterTypes(), + allowBoxing, useVarargs, warn); + return mt; } boolean isTransitionalDynamicCallSite(Type site, Symbol sym) { @@ -403,7 +405,7 @@ try { return rawInstantiate(env, site, m, argtypes, typeargtypes, allowBoxing, useVarargs, warn); - } catch (Infer.InferenceException ex) { + } catch (InapplicableMethodException ex) { return null; } } @@ -415,26 +417,76 @@ boolean allowBoxing, boolean useVarargs, Warner warn) { + try { + checkRawArgumentsAcceptable(argtypes, formals, allowBoxing, useVarargs, warn); + return true; + } catch (InapplicableMethodException ex) { + return false; + } + } + void checkRawArgumentsAcceptable(List argtypes, + List formals, + boolean allowBoxing, + boolean useVarargs, + Warner warn) { Type varargsFormal = useVarargs ? formals.last() : null; + if (varargsFormal == null && + argtypes.size() != formals.size()) { + throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args + } + while (argtypes.nonEmpty() && formals.head != varargsFormal) { boolean works = allowBoxing ? types.isConvertible(argtypes.head, formals.head, warn) : types.isSubtypeUnchecked(argtypes.head, formals.head, warn); - if (!works) return false; + if (!works) + throw inapplicableMethodException.setMessage("no.conforming.assignment.exists", + argtypes.head, + formals.head); argtypes = argtypes.tail; formals = formals.tail; } - if (formals.head != varargsFormal) return false; // not enough args - if (!useVarargs) - return argtypes.isEmpty(); - Type elt = types.elemtype(varargsFormal); - while (argtypes.nonEmpty()) { - if (!types.isConvertible(argtypes.head, elt, warn)) - return false; - argtypes = argtypes.tail; + + if (formals.head != varargsFormal) + throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args + + if (useVarargs) { + Type elt = types.elemtype(varargsFormal); + while (argtypes.nonEmpty()) { + if (!types.isConvertible(argtypes.head, elt, warn)) + throw inapplicableMethodException.setMessage("varargs.argument.mismatch", + argtypes.head, + elt); + argtypes = argtypes.tail; + } } - return true; + return; } + // where + public static class InapplicableMethodException extends RuntimeException { + private static final long serialVersionUID = 0; + + JCDiagnostic diagnostic; + JCDiagnostic.Factory diags; + + InapplicableMethodException(JCDiagnostic.Factory diags) { + this.diagnostic = null; + this.diags = diags; + } + InapplicableMethodException setMessage(String key) { + this.diagnostic = key != null ? diags.fragment(key) : null; + return this; + } + InapplicableMethodException setMessage(String key, Object... args) { + this.diagnostic = key != null ? diags.fragment(key, args) : null; + return this; + } + + public JCDiagnostic getDiagnostic() { + return diagnostic; + } + } + private final InapplicableMethodException inapplicableMethodException; /* *************************************************************************** * Symbol lookup @@ -595,6 +647,7 @@ * @param allowBoxing Allow boxing conversions of arguments. * @param useVarargs Box trailing arguments into an array for varargs. */ + @SuppressWarnings("fallthrough") Symbol selectBest(Env env, Type site, List argtypes, @@ -608,21 +661,16 @@ if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar; assert sym.kind < AMBIGUOUS; try { - if (rawInstantiate(env, site, sym, argtypes, typeargtypes, - allowBoxing, useVarargs, Warner.noWarnings) == null) { - // inapplicable - switch (bestSoFar.kind) { - case ABSENT_MTH: return wrongMethod.setWrongSym(sym); - case WRONG_MTH: return wrongMethods; - default: return bestSoFar; - } - } - } catch (Infer.InferenceException ex) { + rawInstantiate(env, site, sym, argtypes, typeargtypes, + allowBoxing, useVarargs, Warner.noWarnings); + } catch (InapplicableMethodException ex) { switch (bestSoFar.kind) { case ABSENT_MTH: return wrongMethod.setWrongSym(sym, ex.getDiagnostic()); case WRONG_MTH: - return wrongMethods; + wrongMethods.addCandidate(currentStep, wrongMethod.sym, wrongMethod.explanation); + case WRONG_MTHS: + return wrongMethods.addCandidate(currentStep, sym, ex.getDiagnostic()); default: return bestSoFar; } @@ -631,7 +679,7 @@ return (bestSoFar.kind == ABSENT_MTH) ? new AccessError(env, site, sym) : bestSoFar; - } + } return (bestSoFar.kind > AMBIGUOUS) ? sym : mostSpecific(sym, bestSoFar, env, site, @@ -1253,11 +1301,12 @@ Name name, List argtypes, List typeargtypes) { - Symbol sym = methodNotFound; + Symbol sym = startResolution(); List steps = methodResolutionSteps; while (steps.nonEmpty() && steps.head.isApplicable(boxingEnabled, varargsEnabled) && sym.kind >= ERRONEOUS) { + currentStep = steps.head; sym = findFun(env, name, argtypes, typeargtypes, steps.head.isBoxingRequired, env.info.varArgs = steps.head.isVarargsRequired); @@ -1274,6 +1323,12 @@ return sym; } + private Symbol startResolution() { + wrongMethod.clear(); + wrongMethods.clear(); + return methodNotFound; + } + /** Resolve a qualified method identifier * @param pos The position to use for error reporting. * @param env The environment current at the method invocation. @@ -1286,11 +1341,12 @@ Symbol resolveQualifiedMethod(DiagnosticPosition pos, Env env, Type site, Name name, List argtypes, List typeargtypes) { - Symbol sym = methodNotFound; + Symbol sym = startResolution(); List steps = methodResolutionSteps; while (steps.nonEmpty() && steps.head.isApplicable(boxingEnabled, varargsEnabled) && sym.kind >= ERRONEOUS) { + currentStep = steps.head; sym = findMethod(env, site, name, argtypes, typeargtypes, steps.head.isBoxingRequired(), env.info.varArgs = steps.head.isVarargsRequired(), false); @@ -1404,11 +1460,12 @@ Type site, List argtypes, List typeargtypes) { - Symbol sym = methodNotFound; + Symbol sym = startResolution(); List steps = methodResolutionSteps; while (steps.nonEmpty() && steps.head.isApplicable(boxingEnabled, varargsEnabled) && sym.kind >= ERRONEOUS) { + currentStep = steps.head; sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, steps.head.isBoxingRequired(), env.info.varArgs = steps.head.isVarargsRequired()); @@ -1439,26 +1496,22 @@ Type site, List argtypes, List typeargtypes) { - Symbol sym = methodNotFound; - JCDiagnostic explanation = null; + Symbol sym = startResolution(); List steps = methodResolutionSteps; while (steps.nonEmpty() && steps.head.isApplicable(boxingEnabled, varargsEnabled) && sym.kind >= ERRONEOUS) { + currentStep = steps.head; sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, steps.head.isBoxingRequired(), env.info.varArgs = steps.head.isVarargsRequired()); methodResolutionCache.put(steps.head, sym); - if (sym.kind == WRONG_MTH && - ((InapplicableSymbolError)sym).explanation != null) { - //if the symbol is an inapplicable method symbol, then the - //explanation contains the reason for which inference failed - explanation = ((InapplicableSymbolError)sym).explanation; - } steps = steps.tail; } if (sym.kind >= AMBIGUOUS) { - final JCDiagnostic details = explanation; + final JCDiagnostic details = sym.kind == WRONG_MTH ? + ((InapplicableSymbolError)sym).explanation : + null; Symbol errSym = new ResolveError(WRONG_MTH, "diamond error") { @Override JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Type site, Name name, List argtypes, List typeargtypes) { @@ -1860,7 +1913,8 @@ */ InapplicableSymbolError setWrongSym(Symbol sym, JCDiagnostic explanation) { this.sym = sym; - this.explanation = explanation; + if (this.sym == sym && explanation != null) + this.explanation = explanation; //update the details return this; } @@ -1868,7 +1922,6 @@ */ InapplicableSymbolError setWrongSym(Symbol sym) { this.sym = sym; - this.explanation = null; return this; } @@ -1905,6 +1958,10 @@ } } + void clear() { + explanation = null; + } + @Override public Symbol access(Name name, TypeSymbol location) { return types.createErrorType(name, location, syms.errSymbol.type).tsym; @@ -1917,6 +1974,9 @@ * given an actual arguments/type argument list. */ class InapplicableSymbolsError extends ResolveError { + + private List candidates = List.nil(); + InapplicableSymbolsError(Symbol sym) { super(WRONG_MTHS, "inapplicable symbols"); } @@ -1928,8 +1988,85 @@ Name name, List argtypes, List typeargtypes) { - return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos, + if (candidates.nonEmpty()) { + JCDiagnostic err = diags.create(dkind, + log.currentSource(), + pos, + "cant.apply.symbols", + name == names.init ? KindName.CONSTRUCTOR : absentKind(kind), + getName(), + argtypes); + return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(site)); + } else { + return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos, site, name, argtypes, typeargtypes); + } + } + + //where + List candidateDetails(Type site) { + List details = List.nil(); + for (Candidate c : candidates) + details = details.prepend(c.getDiagnostic(site)); + return details.reverse(); + } + + Symbol addCandidate(MethodResolutionPhase currentStep, Symbol sym, JCDiagnostic details) { + Candidate c = new Candidate(currentStep, sym, details); + if (c.isValid() && !candidates.contains(c)) + candidates = candidates.append(c); + return this; + } + + void clear() { + candidates = List.nil(); + } + + private Name getName() { + Symbol sym = candidates.head.sym; + return sym.name == names.init ? + sym.owner.name : + sym.name; + } + + private class Candidate { + + final MethodResolutionPhase step; + final Symbol sym; + final JCDiagnostic details; + + private Candidate(MethodResolutionPhase step, Symbol sym, JCDiagnostic details) { + this.step = step; + this.sym = sym; + this.details = details; + } + + JCDiagnostic getDiagnostic(Type site) { + return diags.fragment("inapplicable.method", + Kinds.kindName(sym), + sym.location(site, types), + sym.asMemberOf(site, types), + details); + } + + @Override + public boolean equals(Object o) { + if (o instanceof Candidate) { + Symbol s1 = this.sym; + Symbol s2 = ((Candidate)o).sym; + if ((s1 != s2 && + (s1.overrides(s2, s1.owner.type.tsym, types, false) || + (s2.overrides(s1, s2.owner.type.tsym, types, false)))) || + ((s1.isConstructor() || s2.isConstructor()) && s1.owner != s2.owner)) + return true; + } + return false; + } + + boolean isValid() { + return (((sym.flags() & VARARGS) != 0 && step == VARARITY) || + (sym.flags() & VARARGS) == 0 && step == (boxingEnabled ? BOX : BASIC)); + } } } @@ -2093,6 +2230,8 @@ final List methodResolutionSteps = List.of(BASIC, BOX, VARARITY); + private MethodResolutionPhase currentStep = null; + private MethodResolutionPhase firstErroneousResolutionPhase() { MethodResolutionPhase bestSoFar = BASIC; Symbol sym = methodNotFound; diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java --- a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -150,8 +150,8 @@ useZipFileIndex = System.getProperty("useJavaUtilZip") == null;// TODO: options.get("useJavaUtilZip") == null; - mmappedIO = options.get("mmappedIO") != null; - ignoreSymbolFile = options.get("ignore.symbol.file") != null; + mmappedIO = options.isSet("mmappedIO"); + ignoreSymbolFile = options.isSet("ignore.symbol.file"); } public JavaFileObject getFileForInput(String name) { @@ -435,7 +435,7 @@ zdir = new ZipFile(zipFileName); } else { - usePreindexedCache = options.get("usezipindex") != null; + usePreindexedCache = options.isSet("usezipindex"); preindexCacheLocation = options.get("java.io.tmpdir"); String optCacheLoc = options.get("cachezipindexdir"); @@ -469,7 +469,7 @@ null, usePreindexedCache, preindexCacheLocation, - options.get("writezipindexfiles") != null)); + options.isSet("writezipindexfiles"))); } } else { @@ -482,7 +482,7 @@ symbolFilePrefix, usePreindexedCache, preindexCacheLocation, - options.get("writezipindexfiles") != null)); + options.isSet("writezipindexfiles"))); } } } catch (FileNotFoundException ex) { @@ -605,7 +605,7 @@ nullCheck(className); nullCheck(kind); if (!sourceOrClass.contains(kind)) - throw new IllegalArgumentException("Invalid kind " + kind); + throw new IllegalArgumentException("Invalid kind: " + kind); return getFileForInput(location, RelativeFile.forClass(className, kind)); } @@ -658,7 +658,7 @@ nullCheck(className); nullCheck(kind); if (!sourceOrClass.contains(kind)) - throw new IllegalArgumentException("Invalid kind " + kind); + throw new IllegalArgumentException("Invalid kind: " + kind); return getFileForOutput(location, RelativeFile.forClass(className, kind), sibling); } @@ -672,7 +672,7 @@ // validatePackageName(packageName); nullCheck(packageName); if (!isRelativeUri(relativeName)) - throw new IllegalArgumentException("relativeName is invalid"); + throw new IllegalArgumentException("Invalid relative name: " + relativeName); RelativeFile name = packageName.length() == 0 ? new RelativeFile(relativeName) : new RelativeFile(RelativeDirectory.forPackage(packageName), relativeName); @@ -806,6 +806,8 @@ String path = uri.normalize().getPath(); if (path.length() == 0 /* isEmpty() is mustang API */) return false; + if (!path.equals(uri.getPath())) // implicitly checks for embedded . and .. + return false; char first = path.charAt(0); return first != '.' && first != '/'; } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Oct 26 13:45:25 2010 -0700 @@ -56,6 +56,8 @@ import static com.sun.tools.javac.jvm.ClassFile.*; import static com.sun.tools.javac.jvm.ClassFile.Version.*; +import static com.sun.tools.javac.main.OptionName.*; + /** This class provides operations to read a classfile into an internal * representation. The internal representation is anchored in a * ClassSymbol which contains in its scope symbol representations @@ -122,6 +124,9 @@ /** The symbol table. */ Symtab syms; + /** The scope counter */ + Scope.ScopeCounter scopeCounter; + Types types; /** The name table. */ @@ -244,6 +249,7 @@ names = Names.instance(context); syms = Symtab.instance(context); + scopeCounter = Scope.ScopeCounter.instance(context); types = Types.instance(context); fileManager = context.get(JavaFileManager.class); if (fileManager == null) @@ -255,23 +261,23 @@ Options options = Options.instance(context); annotate = Annotate.instance(context); - verbose = options.get("-verbose") != null; - checkClassFile = options.get("-checkclassfile") != null; + verbose = options.isSet(VERBOSE); + checkClassFile = options.isSet("-checkclassfile"); Source source = Source.instance(context); allowGenerics = source.allowGenerics(); allowVarargs = source.allowVarargs(); allowAnnotations = source.allowAnnotations(); - saveParameterNames = options.get("save-parameter-names") != null; - cacheCompletionFailure = options.get("dev") == null; + saveParameterNames = options.isSet("save-parameter-names"); + cacheCompletionFailure = options.isUnset("dev"); preferSource = "source".equals(options.get("-Xprefer")); completionFailureName = - (options.get("failcomplete") != null) + options.isSet("failcomplete") ? names.fromString(options.get("failcomplete")) : null; typevars = new Scope(syms.noSymbol); - debugJSR308 = options.get("TA:reader") != null; + debugJSR308 = options.isSet("TA:reader"); initAttributeReaders(); } @@ -1984,7 +1990,7 @@ ClassType ct = (ClassType)c.type; // allocate scope for members - c.members_field = new Scope(c); + c.members_field = new Scope.ClassScope(c, scopeCounter); // prepare type variable table typevars = typevars.dup(currentOwner); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Oct 26 13:45:25 2010 -0700 @@ -45,8 +45,10 @@ import static com.sun.tools.javac.code.Kinds.*; import static com.sun.tools.javac.code.TypeTags.*; import static com.sun.tools.javac.jvm.UninitializedType.*; +import static com.sun.tools.javac.main.OptionName.*; import static javax.tools.StandardLocation.CLASS_OUTPUT; + /** This class provides operations to map an internal symbol table graph * rooted in a ClassSymbol into a classfile. * @@ -178,15 +180,16 @@ types = Types.instance(context); fileManager = context.get(JavaFileManager.class); - debugJSR308 = options.get("TA:writer") != null; - verbose = options.get("-verbose") != null; - scramble = options.get("-scramble") != null; - scrambleAll = options.get("-scrambleAll") != null; - retrofit = options.get("-retrofit") != null; - genCrt = options.get("-Xjcov") != null; - debugstackmap = options.get("debugstackmap") != null; + debugJSR308 = options.isSet("TA:writer"); + verbose = options.isSet(VERBOSE); + scramble = options.isSet("-scramble"); + scrambleAll = options.isSet("-scrambleAll"); + retrofit = options.isSet("-retrofit"); + genCrt = options.isSet(XJCOV); + debugstackmap = options.isSet("debugstackmap"); - emitSourceFile = options.get("-g:")==null || options.get("-g:source")!=null; + emitSourceFile = options.isUnset(G_CUSTOM) || + options.isSet(G_CUSTOM, "source"); String dumpModFlags = options.get("dumpmodifiers"); dumpClassModifiers = diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Oct 26 13:45:25 2010 -0700 @@ -46,6 +46,7 @@ import static com.sun.tools.javac.code.TypeTags.*; import static com.sun.tools.javac.jvm.ByteCodes.*; import static com.sun.tools.javac.jvm.CRTFlags.*; +import static com.sun.tools.javac.main.OptionName.*; /** This pass maps flat Java (i.e. without inner classes) to bytecodes. * @@ -113,19 +114,19 @@ Options options = Options.instance(context); lineDebugInfo = - options.get("-g:") == null || - options.get("-g:lines") != null; + options.isUnset(G_CUSTOM) || + options.isSet(G_CUSTOM, "lines"); varDebugInfo = - options.get("-g:") == null - ? options.get("-g") != null - : options.get("-g:vars") != null; - genCrt = options.get("-Xjcov") != null; - debugCode = options.get("debugcode") != null; - allowInvokedynamic = target.hasInvokedynamic() || options.get("invokedynamic") != null; + options.isUnset(G_CUSTOM) + ? options.isSet(G) + : options.isSet(G_CUSTOM, "vars"); + genCrt = options.isSet(XJCOV); + debugCode = options.isSet("debugcode"); + allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic"); generateIproxies = target.requiresIproxy() || - options.get("miranda") != null; + options.isSet("miranda"); if (target.generateStackMapTable()) { // ignore cldc because we cannot have both stackmap formats diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java Tue Oct 26 13:45:25 2010 -0700 @@ -31,6 +31,8 @@ import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.util.*; +import static com.sun.tools.javac.main.OptionName.*; + /** The classfile version target. * *

    This is NOT part of any supported API. @@ -73,7 +75,7 @@ Target instance = context.get(targetKey); if (instance == null) { Options options = Options.instance(context); - String targetString = options.get("-target"); + String targetString = options.get(TARGET); if (targetString != null) instance = lookup(targetString); if (instance == null) instance = DEFAULT; context.put(targetKey, instance); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. * 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,48 +26,44 @@ package com.sun.tools.javac.main; import java.io.*; +import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.LinkedHashMap; import java.util.Map; import java.util.MissingResourceException; +import java.util.Queue; import java.util.ResourceBundle; import java.util.Set; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.Logger; +import javax.annotation.processing.Processor; +import javax.lang.model.SourceVersion; import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import javax.tools.DiagnosticListener; -import com.sun.tools.javac.file.JavacFileManager; import com.sun.source.util.TaskEvent; import com.sun.source.util.TaskListener; +import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.util.*; 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 com.sun.tools.javac.parser.*; import com.sun.tools.javac.comp.*; import com.sun.tools.javac.jvm.*; - -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.tree.JCTree.*; - import com.sun.tools.javac.processing.*; -import javax.annotation.processing.Processor; import static javax.tools.StandardLocation.CLASS_OUTPUT; +import static com.sun.tools.javac.main.OptionName.*; import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*; import static com.sun.tools.javac.util.ListBuffer.lb; -// TEMP, until we have a more efficient way to save doc comment info -import com.sun.tools.javac.parser.DocCommentScanner; - -import java.util.HashMap; -import java.util.Queue; -import javax.lang.model.SourceVersion; /** This class could be the main entry point for GJC when GJC is used as a * component in a larger software system. It provides operations to @@ -359,22 +355,22 @@ Options options = Options.instance(context); - verbose = options.get("-verbose") != null; - sourceOutput = options.get("-printsource") != null; // used to be -s - stubOutput = options.get("-stubs") != null; - relax = options.get("-relax") != null; - printFlat = options.get("-printflat") != null; - attrParseOnly = options.get("-attrparseonly") != null; - encoding = options.get("-encoding"); - lineDebugInfo = options.get("-g:") == null || - options.get("-g:lines") != null; - genEndPos = options.get("-Xjcov") != null || + verbose = options.isSet(VERBOSE); + sourceOutput = options.isSet(PRINTSOURCE); // used to be -s + stubOutput = options.isSet("-stubs"); + relax = options.isSet("-relax"); + printFlat = options.isSet("-printflat"); + attrParseOnly = options.isSet("-attrparseonly"); + encoding = options.get(ENCODING); + lineDebugInfo = options.isUnset(G_CUSTOM) || + options.isSet(G_CUSTOM, "lines"); + genEndPos = options.isSet(XJCOV) || context.get(DiagnosticListener.class) != null; - devVerbose = options.get("dev") != null; - processPcks = options.get("process.packages") != null; - werror = options.get("-Werror") != null; + devVerbose = options.isSet("dev"); + processPcks = options.isSet("process.packages"); + werror = options.isSet(WERROR); - verboseCompilePolicy = options.get("verboseCompilePolicy") != null; + verboseCompilePolicy = options.isSet("verboseCompilePolicy"); if (attrParseOnly) compilePolicy = CompilePolicy.ATTR_ONLY; @@ -384,15 +380,15 @@ implicitSourcePolicy = ImplicitSourcePolicy.decode(options.get("-implicit")); completionFailureName = - (options.get("failcomplete") != null) + options.isSet("failcomplete") ? names.fromString(options.get("failcomplete")) : null; shouldStopPolicy = - (options.get("shouldStopPolicy") != null) + options.isSet("shouldStopPolicy") ? CompileState.valueOf(options.get("shouldStopPolicy")) : null; - if (options.get("oldDiags") == null) + if (options.isUnset("oldDiags")) log.setDiagnosticFormatter(RichDiagnosticFormatter.instance(context)); } @@ -957,18 +953,17 @@ // Process annotations if processing is not disabled and there // is at least one Processor available. Options options = Options.instance(context); - if (options.get("-proc:none") != null) { + if (options.isSet(PROC, "none")) { processAnnotations = false; } else if (procEnvImpl == null) { procEnvImpl = new JavacProcessingEnvironment(context, processors); processAnnotations = procEnvImpl.atLeastOneProcessor(); if (processAnnotations) { - if (context.get(Scanner.Factory.scannerFactoryKey) == null) - DocCommentScanner.Factory.preRegister(context); options.put("save-parameter-names", "save-parameter-names"); reader.saveParameterNames = true; keepComments = true; + genEndPos = true; if (taskListener != null) taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING)); log.deferDiagnostics = true; @@ -1017,7 +1012,7 @@ // annotation processing is to occur with compilation, // emit a warning. Options options = Options.instance(context); - if (options.get("-proc:only") != null) { + if (options.isSet(PROC, "only")) { log.warning("proc.proc-only.requested.no.procs"); todo.clear(); } @@ -1105,10 +1100,10 @@ Options options = Options.instance(context); return explicitAnnotationProcessingRequested || - options.get("-processor") != null || - options.get("-processorpath") != null || - options.get("-proc:only") != null || - options.get("-Xprint") != null; + options.isSet(PROCESSOR) || + options.isSet(PROCESSORPATH) || + options.isSet(PROC, "only") || + options.isSet(XPRINT); } /** @@ -1587,6 +1582,7 @@ } public void initRound(JavaCompiler prev) { + genEndPos = prev.genEndPos; keepComments = prev.keepComments; start_msec = prev.start_msec; hasBeenUsed = true; diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/main/Main.java --- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java Tue Oct 26 13:45:25 2010 -0700 @@ -32,6 +32,9 @@ import java.security.DigestInputStream; import java.security.MessageDigest; import java.util.MissingResourceException; +import javax.tools.JavaFileManager; +import javax.tools.JavaFileObject; +import javax.annotation.processing.Processor; import com.sun.tools.javac.code.Source; import com.sun.tools.javac.file.CacheFSInfo; @@ -41,9 +44,8 @@ import com.sun.tools.javac.main.RecognizedOptions.OptionHelper; import com.sun.tools.javac.util.*; import com.sun.tools.javac.processing.AnnotationProcessingError; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; -import javax.annotation.processing.Processor; + +import static com.sun.tools.javac.main.OptionName.*; /** This class provides a commandline interface to the GJC compiler. * @@ -239,16 +241,16 @@ } } - if (!checkDirectory("-d")) + if (!checkDirectory(D)) return null; - if (!checkDirectory("-s")) + if (!checkDirectory(S)) return null; - String sourceString = options.get("-source"); + String sourceString = options.get(SOURCE); Source source = (sourceString != null) ? Source.lookup(sourceString) : Source.DEFAULT; - String targetString = options.get("-target"); + String targetString = options.get(TARGET); Target target = (targetString != null) ? Target.lookup(targetString) : Target.DEFAULT; @@ -285,7 +287,7 @@ // phase this out with JSR 292 PFD if ("no".equals(options.get("allowTransitionalJSR292"))) { options.put("allowTransitionalJSR292", null); - } else if (target.hasInvokedynamic() && options.get("allowTransitionalJSR292") == null) { + } else if (target.hasInvokedynamic() && options.isUnset("allowTransitionalJSR292")) { options.put("allowTransitionalJSR292", "allowTransitionalJSR292"); } @@ -300,7 +302,7 @@ return filenames.toList(); } // where - private boolean checkDirectory(String optName) { + private boolean checkDirectory(OptionName optName) { String value = options.get(optName); if (value == null) return true; @@ -367,10 +369,10 @@ return EXIT_CMDERR; } else if (files.isEmpty() && fileObjects.isEmpty() && classnames.isEmpty()) { // it is allowed to compile nothing if just asking for help or version info - if (options.get("-help") != null - || options.get("-X") != null - || options.get("-version") != null - || options.get("-fullversion") != null) + if (options.isSet(HELP) + || options.isSet(X) + || options.isSet(VERSION) + || options.isSet(FULLVERSION)) return EXIT_OK; error("err.no.source.files"); return EXIT_CMDERR; @@ -382,7 +384,7 @@ return EXIT_SYSERR; } - boolean forceStdOut = options.get("stdout") != null; + boolean forceStdOut = options.isSet("stdout"); if (forceStdOut) { out.flush(); out = new PrintWriter(System.out, true); @@ -391,7 +393,7 @@ context.put(Log.outKey, out); // allow System property in following line as a Mustang legacy - boolean batchMode = (options.get("nonBatchMode") == null + boolean batchMode = (options.isUnset("nonBatchMode") && System.getProperty("nonBatchMode") == null); if (batchMode) CacheFSInfo.preRegister(context); @@ -455,7 +457,7 @@ // for buggy compiler error recovery by swallowing thrown // exceptions. if (comp == null || comp.errorCount() == 0 || - options == null || options.get("dev") != null) + options == null || options.isSet("dev")) bugMessage(ex); return EXIT_ABNORMAL; } finally { @@ -478,7 +480,7 @@ */ void feMessage(Throwable ex) { Log.printLines(out, ex.getMessage()); - if (ex.getCause() != null && options.get("dev") != null) { + if (ex.getCause() != null && options.isSet("dev")) { ex.getCause().printStackTrace(out); } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java --- a/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Tue Oct 26 13:45:25 2010 -0700 @@ -366,11 +366,11 @@ // } // } int maxDepth = (recurse ? Integer.MAX_VALUE : 1); - Set opts = EnumSet.of(DETECT_CYCLES, FOLLOW_LINKS); + Set opts = EnumSet.of(FOLLOW_LINKS); Files.walkFileTree(packageDir, opts, maxDepth, new SimpleFileVisitor() { @Override - public FileVisitResult preVisitDirectory(Path dir) { + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { if (SourceVersion.isIdentifier(dir.getName().toString())) // JSR 292? return FileVisitResult.CONTINUE; else diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java --- a/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. * 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,50 +42,17 @@ */ public class DocCommentScanner extends Scanner { - /** A factory for creating scanners. */ - public static class Factory extends Scanner.Factory { - - public static void preRegister(final Context context) { - context.put(scannerFactoryKey, new Context.Factory() { - public Factory make() { - return new Factory(context); - } - }); - } - - /** Create a new scanner factory. */ - protected Factory(Context context) { - super(context); - } - - @Override - public Scanner newScanner(CharSequence input) { - if (input instanceof CharBuffer) { - return new DocCommentScanner(this, (CharBuffer)input); - } else { - char[] array = input.toString().toCharArray(); - return newScanner(array, array.length); - } - } - - @Override - public Scanner newScanner(char[] input, int inputLength) { - return new DocCommentScanner(this, input, inputLength); - } - } - - /** Create a scanner from the input buffer. buffer must implement * array() and compact(), and remaining() must be less than limit(). */ - protected DocCommentScanner(Factory fac, CharBuffer buffer) { + protected DocCommentScanner(ScannerFactory fac, CharBuffer buffer) { super(fac, buffer); } /** Create a scanner from the input array. The array must have at * least a single character of extra space. */ - protected DocCommentScanner(Factory fac, char[] input, int inputLength) { + protected DocCommentScanner(ScannerFactory fac, char[] input, int inputLength) { super(fac, input, inputLength); } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2473,6 +2473,11 @@ defs.append(importDeclaration()); } else { JCTree def = typeDeclaration(mods); + if (keepDocComments && dc != null && docComments.get(def) == dc) { + // If the first type declaration has consumed the first doc + // comment, then don't use it for the top level comment as well. + dc = null; + } if (def instanceof JCExpressionStatement) def = ((JCExpressionStatement)def).expr; defs.append(def); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java --- a/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. * 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 @@ final Source source; final Names names; final Options options; - final Scanner.Factory scannerFactory; + final ScannerFactory scannerFactory; protected ParserFactory(Context context) { super(); @@ -70,11 +70,11 @@ this.keywords = Keywords.instance(context); this.source = Source.instance(context); this.options = Options.instance(context); - this.scannerFactory = Scanner.Factory.instance(context); + this.scannerFactory = ScannerFactory.instance(context); } public Parser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) { - Lexer lexer = scannerFactory.newScanner(input); + Lexer lexer = scannerFactory.newScanner(input, keepDocComments); if (keepEndPos) { return new EndPosParser(this, lexer, keepDocComments, keepLineMap); } else { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java --- a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,48 +47,6 @@ private static boolean scannerDebug = false; - /** A factory for creating scanners. */ - public static class Factory { - /** The context key for the scanner factory. */ - public static final Context.Key scannerFactoryKey = - new Context.Key(); - - /** Get the Factory instance for this context. */ - public static Factory instance(Context context) { - Factory instance = context.get(scannerFactoryKey); - if (instance == null) - instance = new Factory(context); - return instance; - } - - final Log log; - final Names names; - final Source source; - final Keywords keywords; - - /** Create a new scanner factory. */ - protected Factory(Context context) { - context.put(scannerFactoryKey, this); - this.log = Log.instance(context); - this.names = Names.instance(context); - this.source = Source.instance(context); - this.keywords = Keywords.instance(context); - } - - public Scanner newScanner(CharSequence input) { - if (input instanceof CharBuffer) { - return new Scanner(this, (CharBuffer)input); - } else { - char[] array = input.toString().toCharArray(); - return newScanner(array, array.length); - } - } - - public Scanner newScanner(char[] input, int inputLength) { - return new Scanner(this, input, inputLength); - } - } - /* Output variables; set by nextToken(): */ @@ -177,7 +135,7 @@ private final Keywords keywords; /** Common code for constructors. */ - private Scanner(Factory fac) { + private Scanner(ScannerFactory fac) { log = fac.log; names = fac.names; keywords = fac.keywords; @@ -201,7 +159,7 @@ /** Create a scanner from the input buffer. buffer must implement * array() and compact(), and remaining() must be less than limit(). */ - protected Scanner(Factory fac, CharBuffer buffer) { + protected Scanner(ScannerFactory fac, CharBuffer buffer) { this(fac, JavacFileManager.toArray(buffer), buffer.limit()); } @@ -216,7 +174,7 @@ * @param inputLength the size of the input. * Must be positive and less than or equal to input.length. */ - protected Scanner(Factory fac, char[] input, int inputLength) { + protected Scanner(ScannerFactory fac, char[] input, int inputLength) { this(fac); eofPos = inputLength; if (inputLength == input.length) { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/parser/ScannerFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/ScannerFactory.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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.parser; + +import java.nio.CharBuffer; + +import com.sun.tools.javac.code.Source; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.Log; +import com.sun.tools.javac.util.Names; + + +/** + * A factory for creating scanners. + * + *

    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 ScannerFactory { + /** The context key for the scanner factory. */ + public static final Context.Key scannerFactoryKey = + new Context.Key(); + + /** Get the Factory instance for this context. */ + public static ScannerFactory instance(Context context) { + ScannerFactory instance = context.get(scannerFactoryKey); + if (instance == null) + instance = new ScannerFactory(context); + return instance; + } + + final Log log; + final Names names; + final Source source; + final Keywords keywords; + + /** Create a new scanner factory. */ + protected ScannerFactory(Context context) { + context.put(scannerFactoryKey, this); + this.log = Log.instance(context); + this.names = Names.instance(context); + this.source = Source.instance(context); + this.keywords = Keywords.instance(context); + } + + public Scanner newScanner(CharSequence input, boolean keepDocComments) { + if (input instanceof CharBuffer) { + CharBuffer buf = (CharBuffer) input; + if (keepDocComments) + return new DocCommentScanner(this, buf); + else + return new Scanner(this, buf); + } else { + char[] array = input.toString().toCharArray(); + return newScanner(array, array.length, keepDocComments); + } + } + + public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) { + if (keepDocComments) + return new DocCommentScanner(this, input, inputLength); + else + return new Scanner(this, input, inputLength); + } +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java Tue Oct 26 13:45:25 2010 -0700 @@ -25,14 +25,6 @@ package com.sun.tools.javac.processing; -import com.sun.tools.javac.util.*; -import javax.annotation.processing.*; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.NestingKind; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.Element; -import java.util.*; - import java.io.Closeable; import java.io.FileNotFoundException; import java.io.InputStream; @@ -43,14 +35,26 @@ import java.io.FilterWriter; import java.io.PrintWriter; import java.io.IOException; +import java.util.*; -import javax.tools.*; import static java.util.Collections.*; +import javax.annotation.processing.*; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.NestingKind; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.Element; +import javax.tools.*; import javax.tools.JavaFileManager.Location; + import static javax.tools.StandardLocation.SOURCE_OUTPUT; import static javax.tools.StandardLocation.CLASS_OUTPUT; +import com.sun.tools.javac.code.Lint; +import com.sun.tools.javac.util.*; + +import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING; + /** * The FilerImplementation class must maintain a number of * constraints. First, multiple attempts to open the same path within @@ -366,7 +370,7 @@ aggregateGeneratedSourceNames = new LinkedHashSet(); aggregateGeneratedClassNames = new LinkedHashSet(); - lint = (Options.instance(context)).lint("processing"); + lint = (Lint.instance(context)).isEnabled(PROCESSING); } public JavaFileObject createSourceFile(CharSequence name, diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,6 +49,7 @@ import javax.tools.JavaFileObject; import javax.tools.DiagnosticListener; +import com.sun.tools.javac.api.JavacTrees; import com.sun.source.util.AbstractTypeProcessor; import com.sun.source.util.TaskEvent; import com.sun.source.util.TaskListener; @@ -78,6 +79,8 @@ import static javax.tools.StandardLocation.*; import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*; +import static com.sun.tools.javac.main.OptionName.*; +import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING; /** * Objects of this class hold and manage the state needed to support @@ -159,15 +162,14 @@ source = Source.instance(context); diags = JCDiagnostic.Factory.instance(context); options = Options.instance(context); - printProcessorInfo = options.get("-XprintProcessorInfo") != null; - printRounds = options.get("-XprintRounds") != null; - verbose = options.get("-verbose") != null; - lint = options.lint("processing"); - procOnly = options.get("-proc:only") != null || - options.get("-Xprint") != null; - fatalErrors = options.get("fatalEnterError") != null; - showResolveErrors = options.get("showResolveErrors") != null; - werror = options.get("-Werror") != null; + printProcessorInfo = options.isSet(XPRINTPROCESSORINFO); + printRounds = options.isSet(XPRINTROUNDS); + verbose = options.isSet(VERBOSE); + lint = Lint.instance(context).isEnabled(PROCESSING); + procOnly = options.isSet(PROC, "only") || options.isSet(XPRINT); + fatalErrors = options.isSet("fatalEnterError"); + showResolveErrors = options.isSet("showResolveErrors"); + werror = options.isSet(WERROR); platformAnnotations = initPlatformAnnotations(); foundTypeProcessors = false; @@ -199,7 +201,7 @@ Log log = Log.instance(context); Iterator processorIterator; - if (options.get("-Xprint") != null) { + if (options.isSet(XPRINT)) { try { Processor processor = PrintingProcessor.class.newInstance(); processorIterator = List.of(processor).iterator(); @@ -212,7 +214,7 @@ } else if (processors != null) { processorIterator = processors.iterator(); } else { - String processorNames = options.get("-processor"); + String processorNames = options.get(PROCESSOR); JavaFileManager fileManager = context.get(JavaFileManager.class); try { // If processorpath is not explicitly set, use the classpath. @@ -263,7 +265,7 @@ ? standardFileManager.getLocation(ANNOTATION_PROCESSOR_PATH) : standardFileManager.getLocation(CLASS_PATH); - if (needClassLoader(options.get("-processor"), workingPath) ) + if (needClassLoader(options.get(PROCESSOR), workingPath) ) handleException(key, e); } else { @@ -744,7 +746,7 @@ psi.runContributingProcs(renv); // Debugging - if (options.get("displayFilerState") != null) + if (options.isSet("displayFilerState")) filer.displayState(); } @@ -1104,6 +1106,12 @@ task.updateContext(next); } + JavacTrees trees = context.get(JavacTrees.class); + if (trees != null) { + next.put(JavacTrees.class, trees); + trees.updateContext(next); + } + context.clear(); return next; } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Oct 26 13:45:25 2010 -0700 @@ -93,6 +93,8 @@ required: {2}\n\ found: {3}\n\ reason: {6} +compiler.err.cant.apply.symbols=\ + no suitable {0} found for {1}({2}) compiler.err.cant.assign.val.to.final.var=\ cannot assign a value to final variable {0} compiler.err.cant.deref=\ @@ -1075,11 +1077,11 @@ no unique maximal instance exists for type variable {0} with upper bounds {1} compiler.misc.no.unique.minimal.instance.exists=\ no unique minimal instance exists for type variable {0} with lower bounds {1} -compiler.misc.no.conforming.instance.exists=\ +compiler.misc.infer.no.conforming.instance.exists=\ no instance(s) of type variable(s) {0} exist so that {1} conforms to {2} -compiler.misc.no.conforming.assignment.exists=\ +compiler.misc.infer.no.conforming.assignment.exists=\ no instance(s) of type variable(s) {0} exist so that argument type {1} conforms to formal parameter type {2} -compiler.misc.arg.length.mismatch=\ +compiler.misc.infer.arg.length.mismatch=\ cannot instantiate from arguments because actual and formal argument lists differ in length compiler.misc.inferred.do.not.conform.to.bounds=\ inferred type does not conform to declared bound(s)\n\ @@ -1095,6 +1097,16 @@ type argument {0} inferred for {1} is not allowed in this context compiler.misc.diamond.invalid.args=\ type arguments {0} inferred for {1} are not allowed in this context + +compiler.misc.explicit.param.do.not.conform.to.bounds=\ + explicit type argument {0} does not conform to declared bound(s) {1} + +compiler.misc.arg.length.mismatch=\ + actual and formal argument lists differ in length +compiler.misc.no.conforming.assignment.exists=\ + actual argument {0} cannot be converted to {1} by method invocation conversion +compiler.misc.varargs.argument.mismatch=\ + argument type {0} does not conform to vararg element type {1} ##### ## The first argument ({0}) is a "kindname". @@ -1232,6 +1244,10 @@ compiler.misc.non.denotable.type=\ Non-denotable type {0} not allowed here +compiler.misc.inapplicable.method=\ + {0} {1}.{2} is not applicable\n\ + ({3}) + ######################################## # Diagnostics for language feature changes ######################################## diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java --- a/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java Tue Oct 26 13:45:25 2010 -0700 @@ -65,8 +65,6 @@ */ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter { - protected int currentIndentation = 0; - /** * Create a basic formatter based on the supplied options. * @@ -107,33 +105,28 @@ } public String formatMessage(JCDiagnostic d, Locale l) { - int prevIndentation = currentIndentation; - try { - StringBuilder buf = new StringBuilder(); - Collection args = formatArguments(d, l); - String msg = localize(l, d.getCode(), args.toArray()); - String[] lines = msg.split("\n"); - if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) { - currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY); - buf.append(indent(lines[0], currentIndentation)); //summary + int currentIndentation = 0; + StringBuilder buf = new StringBuilder(); + Collection args = formatArguments(d, l); + String msg = localize(l, d.getCode(), args.toArray()); + String[] lines = msg.split("\n"); + if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) { + currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY); + buf.append(indent(lines[0], currentIndentation)); //summary + } + if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) { + currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS); + for (int i = 1;i < lines.length; i++) { + buf.append("\n" + indent(lines[i], currentIndentation)); } - if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) { - currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS); - for (int i = 1;i < lines.length; i++) { - buf.append("\n" + indent(lines[i], currentIndentation)); - } - } - if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) { - currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS); + } + if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) { + currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS); for (String sub : formatSubdiagnostics(d, l)) { - buf.append("\n" + sub); - } + buf.append("\n" + indent(sub, currentIndentation)); } - return buf.toString(); } - finally { - currentIndentation = prevIndentation; - } + return buf.toString(); } protected String addSourceLineIfNeeded(JCDiagnostic d, String msg) { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/util/Log.java --- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java Tue Oct 26 13:45:25 2010 -0700 @@ -35,11 +35,14 @@ import javax.tools.DiagnosticListener; import javax.tools.JavaFileObject; +import com.sun.tools.javac.api.DiagnosticFormatter; +import com.sun.tools.javac.main.OptionName; import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.api.DiagnosticFormatter; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType; +import static com.sun.tools.javac.main.OptionName.*; + /** A class for error logs. Reports errors and warnings, and * keeps track of error numbers and positions. * @@ -129,14 +132,14 @@ this.noticeWriter = noticeWriter; Options options = Options.instance(context); - this.dumpOnError = options.get("-doe") != null; - this.promptOnError = options.get("-prompt") != null; - this.emitWarnings = options.get("-Xlint:none") == null; - this.suppressNotes = options.get("suppressNotes") != null; - this.MaxErrors = getIntOption(options, "-Xmaxerrs", getDefaultMaxErrors()); - this.MaxWarnings = getIntOption(options, "-Xmaxwarns", getDefaultMaxWarnings()); + this.dumpOnError = options.isSet(DOE); + this.promptOnError = options.isSet(PROMPT); + this.emitWarnings = options.isUnset(XLINT_CUSTOM, "none"); + this.suppressNotes = options.isSet("suppressNotes"); + this.MaxErrors = getIntOption(options, XMAXERRS, getDefaultMaxErrors()); + this.MaxWarnings = getIntOption(options, XMAXWARNS, getDefaultMaxWarnings()); - boolean rawDiagnostics = options.get("rawDiagnostics") != null; + boolean rawDiagnostics = options.isSet("rawDiagnostics"); messages = JavacMessages.instance(context); this.diagFormatter = rawDiagnostics ? new RawDiagnosticFormatter(options) : new BasicDiagnosticFormatter(options, messages); @@ -150,7 +153,7 @@ expectDiagKeys = new HashSet(Arrays.asList(ek.split(", *"))); } // where - private int getIntOption(Options options, String optionName, int defaultValue) { + private int getIntOption(Options options, OptionName optionName, int defaultValue) { String s = options.get(optionName); try { if (s != null) { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/util/Names.java --- a/langtools/src/share/classes/com/sun/tools/javac/util/Names.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/util/Names.java Tue Oct 26 13:45:25 2010 -0700 @@ -271,7 +271,7 @@ } protected Name.Table createTable(Options options) { - boolean useUnsharedTable = options.get("useUnsharedTable") != null; + boolean useUnsharedTable = options.isSet("useUnsharedTable"); if (useUnsharedTable) return new UnsharedNameTable(this); else diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javac/util/Options.java --- a/langtools/src/share/classes/com/sun/tools/javac/util/Options.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javac/util/Options.java Tue Oct 26 13:45:25 2010 -0700 @@ -25,8 +25,9 @@ package com.sun.tools.javac.util; +import java.util.*; import com.sun.tools.javac.main.OptionName; -import java.util.*; +import static com.sun.tools.javac.main.OptionName.*; /** A table of all command-line options. * If an option has an argument, the option name is mapped to the argument. @@ -60,14 +61,62 @@ context.put(optionsKey, this); } + /** + * Get the value for an undocumented option. + */ public String get(String name) { return values.get(name); } + /** + * Get the value for an option. + */ public String get(OptionName name) { return values.get(name.optionName); } + /** + * Check if the value for an undocumented option has been set. + */ + public boolean isSet(String name) { + return (values.get(name) != null); + } + + /** + * Check if the value for an option has been set. + */ + public boolean isSet(OptionName name) { + return (values.get(name.optionName) != null); + } + + /** + * Check if the value for a choice option has been set to a specific value. + */ + public boolean isSet(OptionName name, String value) { + return (values.get(name.optionName + value) != null); + } + + /** + * Check if the value for an undocumented option has not been set. + */ + public boolean isUnset(String name) { + return (values.get(name) == null); + } + + /** + * Check if the value for an option has not been set. + */ + public boolean isUnset(OptionName name) { + return (values.get(name.optionName) == null); + } + + /** + * Check if the value for a choice option has not been set to a specific value. + */ + public boolean isUnset(OptionName name, String value) { + return (values.get(name.optionName + value) == null); + } + public void put(String name, String value) { values.put(name, value); } @@ -92,16 +141,14 @@ return values.size(); } - static final String LINT = "-Xlint"; - /** Check for a lint suboption. */ public boolean lint(String s) { // return true if either the specific option is enabled, or // they are all enabled without the specific one being // disabled return - get(LINT + ":" + s)!=null || - (get(LINT)!=null || get(LINT + ":all")!=null) && - get(LINT+":-"+s)==null; + isSet(XLINT_CUSTOM, s) || + (isSet(XLINT) || isSet(XLINT_CUSTOM, "all")) && + isUnset(XLINT_CUSTOM, "-" + s); } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java --- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -107,9 +107,6 @@ // force the use of Messager as a Log messager = Messager.instance0(context); - // force the use of the scanner that captures Javadoc comments - DocCommentScanner.Factory.preRegister(context); - return new JavadocTool(context); } catch (CompletionFailure ex) { messager.error(Position.NOPOS, ex.getMessage()); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javah/JavahTask.java --- a/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -526,15 +526,17 @@ } private void showVersion(boolean full) { - log.println(version(full ? "full" : "release")); + log.println(version(full)); } private static final String versionRBName = "com.sun.tools.javah.resources.version"; private static ResourceBundle versionRB; - private String version(String key) { - // key=version: mm.nn.oo[-milestone] - // key=full: mm.mm.oo[-milestone]-build + private String version(boolean full) { + String msgKey = (full ? "javah.fullVersion" : "javah.version"); + String versionKey = (full ? "full" : "release"); + // versionKey=product: mm.nn.oo[-milestone] + // versionKey=full: mm.mm.oo[-milestone]-build if (versionRB == null) { try { versionRB = ResourceBundle.getBundle(versionRBName); @@ -543,7 +545,7 @@ } } try { - return versionRB.getString(key); + return getMessage(msgKey, "javah", versionRB.getString(versionKey)); } catch (MissingResourceException e) { return getMessage("version.unknown", System.getProperty("java.version")); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javah/resources/l10n.properties --- a/langtools/src/share/classes/com/sun/tools/javah/resources/l10n.properties Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javah/resources/l10n.properties Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -113,7 +113,8 @@ # # Version string. # -javah.version=javah version "{0}" +javah.version={0} version "{1}" +javah.fullVersion={0} full version "{1}" # # These should have better diagnostics. diff -r 79caba0caf4f -r e0bc5b441d60 langtools/src/share/classes/com/sun/tools/javah/resources/version.properties-template --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/src/share/classes/com/sun/tools/javah/resources/version.properties-template Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,28 @@ +# +# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +jdk=$(JDK_VERSION) +full=$(FULL_VERSION) +release=$(RELEASE) diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6302184/T6302184.out --- a/langtools/test/tools/javac/6302184/T6302184.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/6302184/T6302184.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,4 +1,7 @@ +/** + * This is a test that uses ISO 8859 encoding. + */ class T6302184 { T6302184() { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6304921/TestLog.java --- a/langtools/test/tools/javac/6304921/TestLog.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/6304921/TestLog.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,6 @@ import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.parser.Parser; import com.sun.tools.javac.parser.ParserFactory; -import com.sun.tools.javac.parser.Scanner; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.TreeScanner; import com.sun.tools.javac.util.Context; @@ -60,7 +59,6 @@ log.multipleErrors = true; JavacFileManager.preRegister(context); - Scanner.Factory sfac = Scanner.Factory.instance(context); ParserFactory pfac = ParserFactory.instance(context); final String text = diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6758789/T6758789a.out --- a/langtools/test/tools/javac/6758789/T6758789a.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/6758789/T6758789a.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,3 +1,3 @@ -T6758789a.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, null -T6758789a.java:15:9: compiler.err.cant.apply.symbol: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, null +T6758789a.java:14:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch) +T6758789a.java:15:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch) 2 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6840059/T6840059.out --- a/langtools/test/tools/javac/6840059/T6840059.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/6840059/T6840059.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,3 +1,3 @@ -T6840059.java:15:9: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, null -T6840059.java:15:25: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, compiler.misc.no.args, kindname.class, T6840059, null +T6840059.java:15:9: compiler.err.cant.apply.symbol.1: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, (compiler.misc.no.conforming.assignment.exists: java.lang.String, java.lang.Integer) +T6840059.java:15:25: compiler.err.cant.apply.symbol.1: kindname.constructor, T6840059, java.lang.Integer, compiler.misc.no.args, kindname.class, T6840059, (compiler.misc.arg.length.mismatch) 2 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6857948/T6857948.out --- a/langtools/test/tools/javac/6857948/T6857948.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/6857948/T6857948.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,3 +1,3 @@ T6857948.java:16:32: compiler.err.cant.resolve.location.args: kindname.method, nosuchfunction, , , kindname.class, Test -T6857948.java:16:50: compiler.err.cant.apply.symbol: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, null +T6857948.java:16:50: compiler.err.cant.apply.symbol.1: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, (compiler.misc.arg.length.mismatch) 2 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6863465/T6863465a.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6863465/T6863465a.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,14 @@ +/** + * @test /nodynamiccopyright/ + * @bug 6863465 + * @summary javac doesn't detect circular subclass dependencies via qualified names + * @author Maurizio Cimadamore + * @compile/fail/ref=T6863465a.out -XDrawDiagnostics T6863465a.java + */ + +class T6863465a { + static class a { static interface b {} } + static class c extends a implements z.y {} + static class x { static interface y {} } + static class z extends x implements c.b {} +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6863465/T6863465a.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6863465/T6863465a.out Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,2 @@ +T6863465a.java:11:12: compiler.err.cyclic.inheritance: T6863465a.c +1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6863465/T6863465b.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6863465/T6863465b.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,14 @@ +/** + * @test /nodynamiccopyright/ + * @bug 6863465 + * @summary javac doesn't detect circular subclass dependencies via qualified names + * @author Maurizio Cimadamore + * @compile/fail/ref=T6863465b.out -XDrawDiagnostics T6863465b.java + */ + +class T6863465b { + static class a { static interface b { static interface d {} } } + static class c extends a implements z.y, z.d {} + static class x { static interface y {} } + static class z extends x implements c.b {} +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6863465/T6863465b.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6863465/T6863465b.out Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,2 @@ +T6863465b.java:11:12: compiler.err.cyclic.inheritance: T6863465b.c +1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6863465/T6863465c.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6863465/T6863465c.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,14 @@ +/** + * @test /nodynamiccopyright/ + * @bug 6863465 + * @summary javac doesn't detect circular subclass dependencies via qualified names + * @author Maurizio Cimadamore + * @compile/fail/ref=T6863465c.out -XDrawDiagnostics T6863465c.java + */ + +class T6863465c { + static class x { static interface y {} } + static class z extends x implements c.b {} + static class a { static interface b { static interface d {} } } + static class c extends a implements z.y, z.d {} +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6863465/T6863465c.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6863465/T6863465c.out Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,3 @@ +T6863465c.java:13:47: compiler.err.cant.resolve.location: kindname.class, d, , , kindname.class, T6863465c.z +T6863465c.java:11:12: compiler.err.cyclic.inheritance: T6863465c.z +2 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6863465/T6863465d.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6863465/T6863465d.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,14 @@ +/** + * @test /nodynamiccopyright/ + * @bug 6863465 + * @summary javac doesn't detect circular subclass dependencies via qualified names + * @author Maurizio Cimadamore + * @compile/fail/ref=T6863465d.out -XDrawDiagnostics T6863465d.java + */ + +class T6863465d { + static class a { static interface b { static interface d {} } } + static class c extends a implements z.y, z.d {} + static class x { static interface y { static interface w {} } } + static class z extends x implements c.b, c.w {} +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6863465/T6863465d.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6863465/T6863465d.out Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,3 @@ +T6863465d.java:13:47: compiler.err.cant.resolve.location: kindname.class, w, , , kindname.class, T6863465d.c +T6863465d.java:11:12: compiler.err.cyclic.inheritance: T6863465d.c +2 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/6863465/TestCircularClassfile.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6863465/TestCircularClassfile.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 6863465 + * @summary javac doesn't detect circular subclass dependencies via qualified names + * @run main TestCircularClassfile + */ + +import java.io.*; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +import com.sun.source.util.JavacTask; +import java.util.EnumSet; + +public class TestCircularClassfile { + + enum ClassName { + A("A"), + B("B"), + C("C"), + OBJECT("Object"); + + String name; + + ClassName(String name) { + this.name = name; + } + } + + static class JavaSource extends SimpleJavaFileObject { + + final static String sourceStub = "class #C extends #S {}"; + + String source; + + public JavaSource(ClassName clazz, ClassName sup) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = sourceStub.replace("#C", clazz.name).replace("#S", sup.name); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + public static void main(String... args) throws Exception { + int count = 0; + for (ClassName clazz : EnumSet.of(ClassName.A, ClassName.B, ClassName.C)) { + for (ClassName sup : EnumSet.of(ClassName.A, ClassName.B, ClassName.C)) { + if (sup.ordinal() < clazz.ordinal()) continue; + check("sub_"+count++, clazz, sup); + } + } + } + + static JavaSource[] initialSources = new JavaSource[] { + new JavaSource(ClassName.A, ClassName.OBJECT), + new JavaSource(ClassName.B, ClassName.A), + new JavaSource(ClassName.C, ClassName.B) + }; + + static String workDir = System.getProperty("user.dir"); + + static void check(String destPath, ClassName clazz, ClassName sup) throws Exception { + File destDir = new File(workDir, destPath); destDir.mkdir(); + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + JavacTask ct = (JavacTask)tool.getTask(null, null, null, + Arrays.asList("-d", destPath), null, Arrays.asList(initialSources)); + ct.generate(); + File fileToRemove = new File(destPath, clazz.name + ".class"); + fileToRemove.delete(); + JavaSource newSource = new JavaSource(clazz, sup); + DiagnosticChecker checker = new DiagnosticChecker(); + ct = (JavacTask)tool.getTask(null, null, checker, + Arrays.asList("-cp", destPath), null, Arrays.asList(newSource)); + ct.analyze(); + if (!checker.errorFound) { + throw new AssertionError(newSource.source); + } + } + + static class DiagnosticChecker implements DiagnosticListener { + + boolean errorFound = false; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR && + diagnostic.getCode().equals("compiler.err.cyclic.inheritance")) { + errorFound = true; + } + } + } +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/CyclicInheritance.out --- a/langtools/test/tools/javac/CyclicInheritance.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/CyclicInheritance.out Tue Oct 26 13:45:25 2010 -0700 @@ -4,6 +4,6 @@ CyclicInheritance.java:22:1: compiler.err.cyclic.inheritance: I11 CyclicInheritance.java:27:1: compiler.err.cyclic.inheritance: C211 CyclicInheritance.java:31:1: compiler.err.cyclic.inheritance: C212 -CyclicInheritance.java:36:27: compiler.err.report.access: C221.I, private, C221 -CyclicInheritance.java:40:24: compiler.err.report.access: C222.C, private, C222 +CyclicInheritance.java:36:1: compiler.err.cyclic.inheritance: C221 +CyclicInheritance.java:40:1: compiler.err.cyclic.inheritance: C222 8 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/Diagnostics/6722234/T6722234a_1.out --- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234a_1.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234a_1.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,2 +1,2 @@ -T6722234a.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a, null +T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1) 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/Diagnostics/6722234/T6722234a_2.out --- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234a_2.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234a_2.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,3 +1,3 @@ -T6722234a.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a, null +T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1) - compiler.misc.where.description.typevar.1: compiler.misc.type.var: T, 1,compiler.misc.type.var: T, 2,{(compiler.misc.where.typevar: compiler.misc.type.var: T, 1, java.lang.String, kindname.class, T6722234a),(compiler.misc.where.typevar: compiler.misc.type.var: T, 2, java.lang.Integer, kindname.method, test(compiler.misc.type.var: T, 2))} 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/Diagnostics/6722234/T6722234b_1.out --- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234b_1.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234b_1.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,2 +1,2 @@ -T6722234b.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, List,List, List,List, kindname.class, T6722234b, null +T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List,List, List,List, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List, List) 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/Diagnostics/6722234/T6722234b_2.out --- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234b_2.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234b_2.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,4 +1,4 @@ -T6722234b.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, List,List, List,List, kindname.class, T6722234b, null +T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List,List, List,List, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List, List) - compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, Object, kindname.method, m(List,List))} - compiler.misc.where.description.captured.1: compiler.misc.captured.type: 1,compiler.misc.captured.type: 2,{(compiler.misc.where.captured.1: compiler.misc.captured.type: 1, T6722234b, compiler.misc.type.null, ? extends T6722234b),(compiler.misc.where.captured.1: compiler.misc.captured.type: 2, T6722234b, compiler.misc.type.null, ? extends T6722234b)} 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/Diagnostics/6722234/T6722234c.out --- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,2 +1,2 @@ -T6722234c.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, null +T6722234c.java:14:9: compiler.err.cant.apply.symbol.1: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, (compiler.misc.infer.no.conforming.assignment.exists: T, java.lang.String, T6722234c.String) 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/Diagnostics/6799605/T6799605.out --- a/langtools/test/tools/javac/Diagnostics/6799605/T6799605.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/Diagnostics/6799605/T6799605.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,4 +1,4 @@ -T6799605.java:17:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605, kindname.class, T6799605 -T6799605.java:18:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605,T6799605, kindname.class, T6799605 -T6799605.java:19:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605,T6799605,T6799605, kindname.class, T6799605 +T6799605.java:17:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605,{(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605), (compiler.misc.inferred.do.not.conform.to.bounds: compiler.misc.type.captureof: 1, ?, T6799605))} +T6799605.java:18:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605,T6799605,{(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605, T6799605)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605), (compiler.misc.infer.arg.length.mismatch))} +T6799605.java:19:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605,T6799605,T6799605,{(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605,T6799605), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605, T6799605)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605), (compiler.misc.infer.arg.length.mismatch))} 3 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/Diagnostics/6862608/T6862608a.out --- a/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,3 +1,3 @@ -T6862608a.java:19:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, java.util.Comparator, java.util.Comparator)), java.util.Comparator, java.util.Comparator +T6862608a.java:19:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, java.util.Comparator, java.util.Comparator)), java.util.Comparator, java.util.Comparator - compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, java.lang.Object, kindname.method, compound(java.lang.Iterable>))} 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/Diagnostics/6862608/T6862608b.out --- a/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,3 +1,3 @@ -T6862608b.java:11:7: compiler.err.cant.apply.symbol: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b, null +T6862608b.java:11:7: compiler.err.cant.apply.symbol.1: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1) - compiler.misc.where.description.typevar.1: compiler.misc.type.var: T, 1,compiler.misc.type.var: T, 2,compiler.misc.type.var: S, 1,compiler.misc.type.var: S, 2,{(compiler.misc.where.typevar: compiler.misc.type.var: T, 1, java.lang.String, kindname.class, T66862608b),(compiler.misc.where.typevar: compiler.misc.type.var: T, 2, compiler.misc.type.var: S, 1, kindname.method, foo(compiler.misc.type.var: T, 2)),(compiler.misc.where.typevar: compiler.misc.type.var: S, 1, java.lang.Object, kindname.method, foo(compiler.misc.type.var: T, 2)),(compiler.misc.where.typevar: compiler.misc.type.var: S, 2, java.lang.Object, kindname.class, T66862608b)} 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/NameCollision.out --- a/langtools/test/tools/javac/NameCollision.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/NameCollision.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,2 +1,3 @@ NameCollision.java:13:31: compiler.err.intf.expected.here -1 error +NameCollision.java:13:5: compiler.err.cyclic.inheritance: NameCollision.Runnable +2 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/T6326754.out --- a/langtools/test/tools/javac/T6326754.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/T6326754.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,7 +1,7 @@ T6326754.java:44:12: compiler.err.name.clash.same.erasure: TestConstructor(T), TestConstructor(K) T6326754.java:52:17: compiler.err.name.clash.same.erasure: setT(K), setT(T) T6326754.java:64:18: compiler.err.prob.found.req: (compiler.misc.incompatible.types), T, T -T6326754.java:70:11: compiler.err.cant.apply.symbol: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC, null +T6326754.java:70:11: compiler.err.cant.apply.symbol.1: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC, (compiler.misc.arg.length.mismatch) - compiler.note.unchecked.filename: T6326754.java - compiler.note.unchecked.recompile 4 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/T6587674.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/T6587674.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 6587674 + * @summary NoClassdefFound when anonymously extending a class. + */ + +import java.util.Vector; + +public class T6587674 { + private static final Vector list = + true ? null : new Vector() { }; + + public static void main(String[] args) { + System.out.println("T6587674 runs fine!"); + } +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/api/TestJavacTaskScanner.java --- a/langtools/test/tools/javac/api/TestJavacTaskScanner.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 +31,8 @@ */ import com.sun.tools.javac.api.JavacTaskImpl; -import com.sun.tools.javac.parser.*; // XXX -import com.sun.tools.javac.util.*; // XXX +import com.sun.tools.javac.parser.*; +import com.sun.tools.javac.util.*; import java.io.*; import java.net.*; import java.nio.*; @@ -65,7 +65,7 @@ fm.getJavaFileObjects(new File[] {file}); StandardJavaFileManager fm = getLocalFileManager(tool, null, null); task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, compilationUnits); - task.getContext().put(Scanner.Factory.scannerFactoryKey, + task.getContext().put(ScannerFactory.scannerFactoryKey, new MyScanner.Factory(task.getContext(), this)); elements = task.getElements(); types = task.getTypes(); @@ -170,34 +170,36 @@ class MyScanner extends Scanner { - public static class Factory extends Scanner.Factory { + public static class Factory extends ScannerFactory { public Factory(Context context, TestJavacTaskScanner test) { super(context); this.test = test; } @Override - public Scanner newScanner(CharSequence input) { + public Scanner newScanner(CharSequence input, boolean keepDocComments) { + assert !keepDocComments; if (input instanceof CharBuffer) { return new MyScanner(this, (CharBuffer)input, test); } else { char[] array = input.toString().toCharArray(); - return newScanner(array, array.length); + return newScanner(array, array.length, keepDocComments); } } @Override - public Scanner newScanner(char[] input, int inputLength) { + public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) { + assert !keepDocComments; return new MyScanner(this, input, inputLength, test); } private TestJavacTaskScanner test; } - protected MyScanner(Factory fac, CharBuffer buffer, TestJavacTaskScanner test) { + protected MyScanner(ScannerFactory fac, CharBuffer buffer, TestJavacTaskScanner test) { super(fac, buffer); this.test = test; } - protected MyScanner(Factory fac, char[] input, int inputLength, TestJavacTaskScanner test) { + protected MyScanner(ScannerFactory fac, char[] input, int inputLength, TestJavacTaskScanner test) { super(fac, input, inputLength); this.test = test; } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/Example.java --- a/langtools/test/tools/javac/diags/Example.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/diags/Example.java Tue Oct 26 13:45:25 2010 -0700 @@ -401,7 +401,7 @@ } } for (JCDiagnostic sd: d.getSubdiagnostics()) - scanForKeys(d, keys); + scanForKeys(sd, keys); } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/examples.not-yet.txt --- a/langtools/test/tools/javac/diags/examples.not-yet.txt Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/diags/examples.not-yet.txt Tue Oct 26 13:45:25 2010 -0700 @@ -3,7 +3,7 @@ compiler.err.annotation.value.not.allowable.type # cannot happen: precluded by complete type-specific tests compiler.err.assignment.from.super-bound # DEAD compiler.err.assignment.to.extends-bound # DEAD -compiler.err.cant.apply.symbol.1 +compiler.err.cant.apply.symbol compiler.err.cant.read.file # (apt.JavaCompiler?) compiler.err.cant.select.static.class.from.param.type compiler.err.illegal.char.for.encoding @@ -43,7 +43,6 @@ compiler.err.unexpected.type compiler.err.unknown.enum.constant # in bad class file compiler.err.unsupported.cross.fp.lit # Scanner: host system dependent -compiler.misc.arg.length.mismatch compiler.misc.assignment.from.super-bound compiler.misc.assignment.to.extends-bound compiler.misc.bad.class.file.header # bad class file @@ -73,7 +72,6 @@ compiler.misc.kindname.type.variable compiler.misc.kindname.type.variable.bound compiler.misc.kindname.value -compiler.misc.no.conforming.assignment.exists compiler.misc.non.denotable.type compiler.misc.no.unique.minimal.instance.exists compiler.misc.resume.abort # prompt for a response diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/examples/ExplicitParamsDoNotConformToBounds.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/diags/examples/ExplicitParamsDoNotConformToBounds.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.explicit.param.do.not.conform.to.bounds + +class ExplicitParamsDoNotConformToBounds { + void m() {} + { this.m(); } +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/examples/InapplicableSymbols.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/diags/examples/InapplicableSymbols.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.cant.apply.symbols +// key: compiler.misc.arg.length.mismatch +// key: compiler.misc.inapplicable.method + +class ExplicitParamsDoNotConformToBounds { + void m(int i1) {} + void m(int i1, int i2) {} + { this.m(); } +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/examples/IncompatibleTypes1.java --- a/langtools/test/tools/javac/diags/examples/IncompatibleTypes1.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/diags/examples/IncompatibleTypes1.java Tue Oct 26 13:45:25 2010 -0700 @@ -22,7 +22,7 @@ */ // key: compiler.misc.incompatible.types.1 -// key: compiler.misc.no.conforming.instance.exists +// key: compiler.misc.infer.no.conforming.instance.exists // key: compiler.err.prob.found.req class IncompatibleTypes1 { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/examples/InferArgsLengthMismatch.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/diags/examples/InferArgsLengthMismatch.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.infer.arg.length.mismatch + +class InferArgsLengthMismatch { + void m(X x1, X x2) {} + { this.m(1); } +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/examples/KindnameConstructor.java --- a/langtools/test/tools/javac/diags/examples/KindnameConstructor.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/diags/examples/KindnameConstructor.java Tue Oct 26 13:45:25 2010 -0700 @@ -24,7 +24,9 @@ // key: compiler.misc.kindname.constructor // key: compiler.misc.kindname.class // key: compiler.misc.no.args -// key: compiler.err.cant.apply.symbol +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.arg.length.mismatch +// key: compiler.misc.no.conforming.assignment.exists // key: compiler.misc.count.error.plural // run: backdoor diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/examples/NoArgs.java --- a/langtools/test/tools/javac/diags/examples/NoArgs.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/diags/examples/NoArgs.java Tue Oct 26 13:45:25 2010 -0700 @@ -22,7 +22,8 @@ */ // key: compiler.misc.no.args -// key: compiler.err.cant.apply.symbol +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.arg.length.mismatch // run: simple class X { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/examples/VarargsArgumentMismatch.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/diags/examples/VarargsArgumentMismatch.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.varargs.argument.mismatch + +class VarargsArgumentMismatch { + void m(String s, Integer... is) {} + { this.m("1", "2", "3"); } +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/examples/WhereCaptured.java --- a/langtools/test/tools/javac/diags/examples/WhereCaptured.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/diags/examples/WhereCaptured.java Tue Oct 26 13:45:25 2010 -0700 @@ -25,7 +25,8 @@ // key: compiler.misc.where.description.captured.1 // key: compiler.misc.where.description.typevar // key: compiler.misc.where.typevar -// key: compiler.err.cant.apply.symbol +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.infer.no.conforming.assignment.exists // key: compiler.misc.captured.type // options: -XDdiags=where,simpleNames // run: simple diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/examples/WhereCaptured1.java --- a/langtools/test/tools/javac/diags/examples/WhereCaptured1.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/diags/examples/WhereCaptured1.java Tue Oct 26 13:45:25 2010 -0700 @@ -25,7 +25,8 @@ // key: compiler.misc.where.description.captured.1 // key: compiler.misc.where.description.typevar // key: compiler.misc.where.typevar -// key: compiler.err.cant.apply.symbol +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.infer.no.conforming.assignment.exists // key: compiler.misc.captured.type // key: compiler.misc.type.null // options: -XDdiags=where,simpleNames diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/diags/examples/WhereTypeVar.java --- a/langtools/test/tools/javac/diags/examples/WhereTypeVar.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/diags/examples/WhereTypeVar.java Tue Oct 26 13:45:25 2010 -0700 @@ -24,7 +24,8 @@ // key: compiler.misc.where.typevar // key: compiler.misc.where.description.typevar.1 // key: compiler.misc.type.var -// key: compiler.err.cant.apply.symbol +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.no.conforming.assignment.exists // options: -XDdiags=where,disambiguateTvars // run: simple diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/generics/diamond/neg/Neg06.out --- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,4 +1,4 @@ -Neg06.java:18:36: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.IFoo, Neg06.ISuperFoo) -Neg06.java:19:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.CFoo, Neg06.CSuperFoo) -Neg06.java:20:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.CFoo, Neg06.CSuperFoo) +Neg06.java:18:36: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.IFoo, Neg06.ISuperFoo) +Neg06.java:19:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo, Neg06.CSuperFoo) +Neg06.java:20:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo, Neg06.CSuperFoo) 3 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/generics/inference/6315770/T6315770.out --- a/langtools/test/tools/javac/generics/inference/6315770/T6315770.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/generics/inference/6315770/T6315770.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,3 +1,3 @@ T6315770.java:16:42: compiler.err.undetermined.type.1: T6315770, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable) -T6315770.java:17:40: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, T6315770, T6315770)), T6315770, T6315770 +T6315770.java:17:40: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, T6315770, T6315770)), T6315770, T6315770 2 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/generics/inference/6611449/T6611449.out --- a/langtools/test/tools/javac/generics/inference/6611449/T6611449.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/generics/inference/6611449/T6611449.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ -T6611449.java:18:9: compiler.err.cant.resolve.location.args: kindname.constructor, T6611449, , int, kindname.class, T6611449 -T6611449.java:19:9: compiler.err.cant.resolve.location.args: kindname.constructor, T6611449, , int,int, kindname.class, T6611449 -T6611449.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m1, T, int, kindname.class, T6611449, null -T6611449.java:21:9: compiler.err.cant.apply.symbol: kindname.method, m2, T,T, int,int, kindname.class, T6611449, null +T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T,T), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S))} +T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T), (compiler.misc.infer.arg.length.mismatch))} +T6611449.java:20:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, T, int, kindname.class, T6611449, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S) +T6611449.java:21:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, T,T, int,int, kindname.class, T6611449, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S) 4 errors diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/generics/inference/6638712/T6638712a.out --- a/langtools/test/tools/javac/generics/inference/6638712/T6638712a.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712a.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,2 +1,2 @@ -T6638712a.java:16:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, java.util.Comparator, java.util.Comparator)), java.util.Comparator, java.util.Comparator +T6638712a.java:16:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, java.util.Comparator, java.util.Comparator)), java.util.Comparator, java.util.Comparator 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/generics/inference/6638712/T6638712b.out --- a/langtools/test/tools/javac/generics/inference/6638712/T6638712b.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712b.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,2 +1,2 @@ -T6638712b.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, T, java.lang.String)), T, java.lang.String +T6638712b.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, T, java.lang.String)), T, java.lang.String 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/generics/inference/6638712/T6638712c.out --- a/langtools/test/tools/javac/generics/inference/6638712/T6638712c.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712c.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,2 +1,2 @@ -T6638712c.java:16:9: compiler.err.cant.apply.symbol: kindname.method, sort, T[],java.util.Comparator, java.lang.Enum[],java.util.Comparator>, kindname.class, T6638712c, null +T6638712c.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, sort, T[],java.util.Comparator, java.lang.Enum[],java.util.Comparator>, kindname.class, T6638712c, (compiler.misc.inferred.do.not.conform.to.params: java.lang.Enum[],java.util.Comparator, java.lang.Enum[],java.util.Comparator>) 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/generics/inference/6638712/T6638712d.out --- a/langtools/test/tools/javac/generics/inference/6638712/T6638712d.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712d.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,2 +1,2 @@ -T6638712d.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, U,java.util.List>, int,java.util.List>, kindname.class, T6638712d, null +T6638712d.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, U,java.util.List>, int,java.util.List>, kindname.class, T6638712d, (compiler.misc.inferred.do.not.conform.to.params: java.lang.String,java.util.List>, int,java.util.List>) 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/generics/inference/6638712/T6638712e.out --- a/langtools/test/tools/javac/generics/inference/6638712/T6638712e.out Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712e.out Tue Oct 26 13:45:25 2010 -0700 @@ -1,2 +1,2 @@ -T6638712e.java:17:27: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: X, T6638712e.Foo, T6638712e.Foo)), T6638712e.Foo, T6638712e.Foo +T6638712e.java:17:27: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: X, T6638712e.Foo, T6638712e.Foo)), T6638712e.Foo, T6638712e.Foo 1 error diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.*; +import javax.annotation.processing.*; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.element.*; +import javax.lang.model.util.*; + +/** + * An abstract annotation processor tailored to javac regression testing. + */ +public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { + private static final Set allAnnotations; + + static { + Set tmp = new HashSet<>(); + tmp.add("*"); + allAnnotations = Collections.unmodifiableSet(tmp); + } + + protected Elements eltUtils; + protected Elements elements; + protected Types typeUtils; + protected Types types; + protected Filer filer; + protected Messager messager; + protected Map options; + + /** + * Constructor for subclasses to call. + */ + protected JavacTestingAbstractProcessor() { + super(); + } + + /** + * Return the latest source version. Unless this method is + * overridden, an {@code IllegalStateException} will be thrown if a + * subclass has a {@code SupportedSourceVersion} annotation. + */ + @Override + public SourceVersion getSupportedSourceVersion() { + SupportedSourceVersion ssv = this.getClass().getAnnotation(SupportedSourceVersion.class); + if (ssv != null) + throw new IllegalStateException("SupportedSourceVersion annotation not supported here."); + + return SourceVersion.latest(); + } + + /** + * If the processor class is annotated with {@link + * SupportedAnnotationTypes}, return an unmodifiable set with the + * same set of strings as the annotation. If the class is not so + * annotated, a one-element set containing {@code "*"} is returned + * to indicate all annotations are processed. + * + * @return the names of the annotation types supported by this + * processor, or an empty set if none + */ + @Override + public Set getSupportedAnnotationTypes() { + SupportedAnnotationTypes sat = this.getClass().getAnnotation(SupportedAnnotationTypes.class); + if (sat != null) + return super.getSupportedAnnotationTypes(); + else + return allAnnotations; + } + + @Override + public void init(ProcessingEnvironment processingEnv) { + super.init(processingEnv); + elements = eltUtils = processingEnv.getElementUtils(); + types = typeUtils = processingEnv.getTypeUtils(); + filer = processingEnv.getFiler(); + messager = processingEnv.getMessager(); + options = processingEnv.getOptions(); + } +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6348499/A.java --- a/langtools/test/tools/javac/processing/6348499/A.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6348499/A.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,10 +27,8 @@ import javax.lang.model.*; import javax.lang.model.element.*; -@SupportedAnnotationTypes("*") -public class A extends AbstractProcessor { +public class A extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment renv) { - Filer filer = processingEnv.getFiler(); try { OutputStream out = filer.createClassFile(getClass().getName()+"_0").openOutputStream(); out.close(); @@ -39,8 +37,4 @@ } return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6348499/T6348499.java --- a/langtools/test/tools/javac/processing/6348499/T6348499.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6348499/T6348499.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test * @bug 6441871 * @summary javac crashes at com.sun.tools.javac.jvm.ClassReader$BadClassFile - * @build A + * @library ../../lib + * @build JavacTestingAbstractProcessor A * @run main T6348499 */ @@ -54,7 +55,6 @@ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java"))); Iterable opts = Arrays.asList("-proc:only", "-processor", "A", - "-source", "1.6", "-processorpath", testClasses); StringWriter out = new StringWriter(); JavacTask task = tool.getTask(out, fm, dl, opts, null, files); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6359313/T6359313.java --- a/langtools/test/tools/javac/processing/6359313/T6359313.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6359313/T6359313.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6359313 * @summary error compiling annotated package * @author Peter von der Ah\u00e9 + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile T6359313.java * @compile -processor T6359313 package-info.java Foo.java */ @@ -37,7 +39,7 @@ import javax.lang.model.element.TypeElement; @SupportedAnnotationTypes("Foo") -public class T6359313 extends AbstractProcessor { +public class T6359313 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { return true; diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6365040/ProcBar.java --- a/langtools/test/tools/javac/processing/6365040/ProcBar.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6365040/ProcBar.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,13 +31,11 @@ /** * Second of several processors to run. */ -@SupportedAnnotationTypes("*") -public class ProcBar extends AbstractProcessor { +public class ProcBar extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { if (!roundEnvironment.processingOver()) - processingEnv.getMessager().printMessage(NOTE, - "Hello from ProcBar"); + messager.printMessage(NOTE, "Hello from ProcBar"); return false; } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6365040/ProcFoo.java --- a/langtools/test/tools/javac/processing/6365040/ProcFoo.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6365040/ProcFoo.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,13 +31,11 @@ /** * First of several processors to run. */ -@SupportedAnnotationTypes("*") -public class ProcFoo extends AbstractProcessor { +public class ProcFoo extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { if (!roundEnvironment.processingOver()) - processingEnv.getMessager().printMessage(NOTE, - "Hello from ProcFoo"); + messager.printMessage(NOTE, "Hello from ProcFoo"); return false; } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6365040/T6365040.java --- a/langtools/test/tools/javac/processing/6365040/T6365040.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6365040/T6365040.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6365040 6358129 * @summary Test -processor foo,bar,baz * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile ProcFoo.java * @compile ProcBar.java * @compile T6365040.java @@ -43,13 +45,11 @@ import javax.lang.model.element.TypeElement; import static javax.tools.Diagnostic.Kind.*; -@SupportedAnnotationTypes("*") -public class T6365040 extends AbstractProcessor { +public class T6365040 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { if (!roundEnvironment.processingOver()) - processingEnv.getMessager().printMessage(NOTE, - "Hello from T6365040"); + messager.printMessage(NOTE, "Hello from T6365040"); return true; } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6413690/T6413690.java --- a/langtools/test/tools/javac/processing/6413690/T6413690.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6413690/T6413690.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6413690 6380018 * @summary JavacProcessingEnvironment does not enter trees from preceding rounds * @author Peter von der Ah\u00e9 + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile T6413690.java * @compile -XDfatalEnterError -verbose -processor T6413690 src/Super.java TestMe.java */ @@ -42,11 +44,9 @@ import javax.lang.model.util.Elements; @SupportedAnnotationTypes("TestMe") -public class T6413690 extends AbstractProcessor { +public class T6413690 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { - Elements elements = processingEnv.getElementUtils(); - Filer filer = processingEnv.getFiler(); TypeElement testMe = elements.getTypeElement(TestMe.class.getName()); Set supers = roundEnvironment.getElementsAnnotatedWith(testMe); try { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6414633/A.java --- a/langtools/test/tools/javac/processing/6414633/A.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6414633/A.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,9 +29,8 @@ import javax.lang.model.element.*; import javax.tools.*; -@SupportedAnnotationTypes("*") -public class A extends AbstractProcessor { - +@SuppressWarnings("") +public class A extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { Messager m = processingEnv.getMessager(); for (TypeElement anno: annotations) { @@ -42,8 +41,6 @@ return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } + @SuppressWarnings("") + private void foo() {} } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6414633/T6414633.java --- a/langtools/test/tools/javac/processing/6414633/T6414633.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6414633/T6414633.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test * @bug 6414633 6440109 * @summary Only the first processor message at a source location is reported - * @build A T6414633 + * @library ../../lib + * @build JavacTestingAbstractProcessor A T6414633 * @run main T6414633 */ @@ -55,8 +56,7 @@ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java"))); String[] opts = { "-proc:only", "-processor", A.class.getName(), - "-source", "1.6", - "-classpath", testClasses }; + "-classpath", testClasses + System.getProperty("path.separator") + "../../lib" }; JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files); task.call(); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6430209/T6430209.java --- a/langtools/test/tools/javac/processing/6430209/T6430209.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6430209/T6430209.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test * @bug 6441871 * @summary spurious compiler error elicited by packageElement.getEnclosedElements() - * @build b6341534 + * @library ../../lib + * @build JavacTestingAbstractProcessor b6341534 * @run main T6430209 */ @@ -54,7 +55,7 @@ // run annotation processor b6341534 so we can check diagnostics // -proc:only -processor b6341534 -cp . ./src/*.java String testSrc = System.getProperty("test.src", "."); - String testClasses = System.getProperty("test.classes"); + String testClasses = System.getProperty("test.classes") + System.getProperty("path.separator") + "../../lib"; JavacTool tool = JavacTool.create(); MyDiagListener dl = new MyDiagListener(); StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6430209/b6341534.java --- a/langtools/test/tools/javac/processing/6430209/b6341534.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6430209/b6341534.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,16 +30,9 @@ import java.util.*; import java.util.Set; -@SupportedAnnotationTypes({"*"}) -public class b6341534 extends AbstractProcessor { +public class b6341534 extends JavacTestingAbstractProcessor { static int r = 0; - static Elements E = null; - static Messager msgr = null; - public void init(ProcessingEnvironment penv) { - processingEnv = penv; - msgr = penv.getMessager(); - E = penv.getElementUtils(); - } + //Create directory 'dir1' and a test class in dir1 public boolean process(Set tes, RoundEnvironment renv) { @@ -49,13 +42,13 @@ System.out.println("Round"+r+ ": " + t.toString()); try { - PackageElement PE = E.getPackageElement("dir1"); + PackageElement PE = eltUtils.getPackageElement("dir1"); List LEE = PE.getEnclosedElements(); /* <=This line elicits the error message. */ for(Element e : LEE) System.out.println("found " + e.toString() + " in dir1."); } catch(NullPointerException npe) { - msgr.printMessage(ERROR,npe.toString()); + messager.printMessage(ERROR,npe.toString()); //npe.printStackTrace(); return false; } @@ -63,13 +56,8 @@ // on round 1, expect errorRaised == false && processingOver == false // on round 2, expect errorRaised == true && processingOver == true if( renv.errorRaised() != renv.processingOver()) { - msgr.printMessage(ERROR, "FAILED"); + messager.printMessage(ERROR, "FAILED"); } return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6499119/ClassProcessor.java --- a/langtools/test/tools/javac/processing/6499119/ClassProcessor.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6499119/ClassProcessor.java Tue Oct 26 13:45:25 2010 -0700 @@ -32,20 +32,17 @@ * @test * @bug 6499119 * @summary Created package-info class file modeled improperly + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile ClassProcessor.java package-info.java * @compile/process -cp . -processor ClassProcessor -Akind=java java.lang.Object * @compile/process -cp . -processor ClassProcessor -Akind=class java.lang.Object */ @SupportedOptions({ "gen", "expect" }) -@SupportedAnnotationTypes({"*"}) -public class ClassProcessor extends AbstractProcessor { +public class ClassProcessor extends JavacTestingAbstractProcessor { int round = 1; - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - public boolean process(Set annotations, RoundEnvironment roundEnv) { if (round == 1) { System.out.println("-- Round 1 --"); @@ -71,8 +68,6 @@ } private void createPackageFile() { - Filer filer = processingEnv.getFiler(); - String kind = processingEnv.getOptions().get("kind"); File pkgInfo; @@ -125,7 +120,6 @@ } private void error(String msg) { - Messager messager = processingEnv.getMessager(); messager.printMessage(Kind.ERROR, msg); } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6511613/DummyProcessor.java --- a/langtools/test/tools/javac/processing/6511613/DummyProcessor.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6511613/DummyProcessor.java Tue Oct 26 13:45:25 2010 -0700 @@ -26,15 +26,10 @@ import javax.lang.model.element.*; import java.util.Set; -@SupportedAnnotationTypes("*") -public class DummyProcessor extends AbstractProcessor { +public class DummyProcessor extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6511613/clss41701.java --- a/langtools/test/tools/javac/processing/6511613/clss41701.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6511613/clss41701.java Tue Oct 26 13:45:25 2010 -0700 @@ -26,7 +26,8 @@ * @bug 6511613 * @summary javac unexpectedly doesn't fail in some cases if an annotation processor specified * - * @build DummyProcessor + * @library ../../lib + * @build JavacTestingAbstractProcessor DummyProcessor * @compile/fail clss41701.java * @compile/fail -processor DummyProcessor clss41701.java */ diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6512707/T6512707.java --- a/langtools/test/tools/javac/processing/6512707/T6512707.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6512707/T6512707.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 +26,9 @@ * @bug 6512707 * @summary "incompatible types" after (unrelated) annotation processing * @author Peter Runge + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile T6512707.java - * * @compile -processor T6512707 TestAnnotation.java */ @@ -41,16 +42,10 @@ * Dummy processor to force bug 6512707 to show - it does not matter what * the annotation processor does for this bug. */ -@SupportedAnnotationTypes("*") -public class T6512707 extends AbstractProcessor { +public class T6512707 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { - return(false); - } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); + return false; } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/6634138/T6634138.java --- a/langtools/test/tools/javac/processing/6634138/T6634138.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/6634138/T6634138.java Tue Oct 26 13:45:25 2010 -0700 @@ -26,6 +26,8 @@ * @bug 6634138 * @author Joseph D. Darcy * @summary Verify source files output after processing is over are compiled + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile T6634138.java * @compile -processor T6634138 Dummy.java * @run main ExerciseDependency @@ -44,10 +46,7 @@ import javax.lang.model.element.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") -public class T6634138 extends AbstractProcessor { - private Filer filer; - +public class T6634138 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { // Write out files *after* processing is over. @@ -77,16 +76,6 @@ } return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - filer = processingEnv.getFiler(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/T6439826.java --- a/langtools/test/tools/javac/processing/T6439826.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/T6439826.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 +48,7 @@ StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null); Iterable files = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6439826.class.getName()+".java"))); - Iterable opts = Arrays.asList("-source","1.6", - "-proc:only", + Iterable opts = Arrays.asList("-proc:only", "-processor", "T6439826", "-processorpath", testClasses); StringWriter out = new StringWriter(); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/T6920317.java --- a/langtools/test/tools/javac/processing/T6920317.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/T6920317.java Tue Oct 26 13:45:25 2010 -0700 @@ -25,6 +25,7 @@ * @test * @bug 6920317 * @summary package-info.java file has to be specified on the javac cmdline, else it will not be avail + * @library ../lib */ import java.io.*; @@ -349,12 +350,7 @@ /** Annotation processor used to verify the expected value for the package annotations found by javac. */ @SupportedOptions({ "gen", "expect" }) - @SupportedAnnotationTypes({"*"}) - public static class Processor extends AbstractProcessor { - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - + public static class Processor extends JavacTestingAbstractProcessor { public boolean process(Set annots, RoundEnvironment renv) { round++; System.err.println("Round " + round + " annots:" + annots + " rootElems:" + renv.getRootElements()); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/Xprint.java --- a/langtools/test/tools/javac/processing/Xprint.java Fri Sep 24 22:42:14 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please 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 6266828 - * @summary JSR 269: Java Language Model API - * @author Peter von der Ah\u00e9 - */ -import javax.tools.JavaCompiler; -import javax.tools.ToolProvider; - -public class Xprint { - public static void main(String[] args) { - JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); - javac.run(System.in, null, null, - "-Xprint", - "com.sun.tools.javac.code.Types", - "com.sun.tools.javac.parser.Parser", - "java.util.EnumSet"); - } -} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/environment/TestSourceVersion.java --- a/langtools/test/tools/javac/processing/environment/TestSourceVersion.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/environment/TestSourceVersion.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6402506 * @summary Test that getSourceVersion works properly * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile TestSourceVersion.java * @compile -processor TestSourceVersion -proc:only -source 1.2 -AExpectedVersion=RELEASE_2 HelloWorld.java * @compile -processor TestSourceVersion -proc:only -source 1.3 -AExpectedVersion=RELEASE_3 HelloWorld.java @@ -52,9 +54,8 @@ * This processor checks that ProcessingEnvironment.getSourceVersion() * is consistent with the setting of the -source option. */ -@SupportedAnnotationTypes("*") @SupportedOptions("ExpectedVersion") -public class TestSourceVersion extends AbstractProcessor { +public class TestSourceVersion extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { @@ -68,9 +69,4 @@ return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java --- a/langtools/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 * @summary Tests that getElementsAnnotatedWith works properly. * @author Joseph D. Darcy + * @library ../../../lib + * @build JavacTestingAbstractProcessor * @compile TestElementsAnnotatedWith.java * @compile InheritedAnnotation.java * @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java @@ -57,16 +59,13 @@ * getElementsAnnotatedWith is consistent with the expected results * stored in an AnnotatedElementInfo annotation. */ -@SupportedAnnotationTypes("*") @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", expectedSize=0, names={}) -public class TestElementsAnnotatedWith extends AbstractProcessor { +public class TestElementsAnnotatedWith extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { - Elements elementUtils = processingEnv.getElementUtils(); - TypeElement annotatedElementInfoElement = - elementUtils.getTypeElement("AnnotatedElementInfo"); + elements.getTypeElement("AnnotatedElementInfo"); Set resultsMeta = Collections.emptySet(); Set resultsBase = Collections.emptySet(); @@ -93,9 +92,7 @@ resultsMeta = roundEnvironment. - getElementsAnnotatedWith(elementUtils. - getTypeElement(annotatedElementInfo. - annotationName())) ; + getElementsAnnotatedWith(elements.getTypeElement(annotatedElementInfo.annotationName())); System.err.println("Results: " + resultsMeta); @@ -167,9 +164,4 @@ throw new RuntimeException("Illegal argument exception not thrown"); } catch(IllegalArgumentException iae) {} } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java --- a/langtools/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,9 @@ * @bug 6403459 * @summary Test that generating programs with syntax errors is a fatal condition * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor + * @compile TestReturnCode.java * @compile TestFatalityOfParseErrors.java * @compile/fail -XprintRounds -processor TestFatalityOfParseErrors -proc:only TestFatalityOfParseErrors.java */ @@ -45,11 +48,8 @@ * Write out an incomplete source file and observe that the next round * is marked as an error. */ -@SupportedAnnotationTypes("*") -public class TestFatalityOfParseErrors extends AbstractProcessor { +public class TestFatalityOfParseErrors extends JavacTestingAbstractProcessor { int round = 0; - Messager messager; - Filer filer; public boolean process(Set annotations, RoundEnvironment roundEnvironment) { @@ -87,14 +87,4 @@ } return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - messager = processingEnv.getMessager(); - filer = processingEnv.getFiler(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java --- a/langtools/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6406212 * @summary Test that annotation processor options with illegal syntax are rejected * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile TestOptionSyntaxErrors.java * @compile/fail -A TestOptionSyntaxErrors.java * @compile/fail -A8adOption TestOptionSyntaxErrors.java @@ -46,14 +48,9 @@ /** * No-op processor; should not be run. */ -@SupportedAnnotationTypes("*") -public class TestOptionSyntaxErrors extends AbstractProcessor { +public class TestOptionSyntaxErrors extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/errors/TestReturnCode.java --- a/langtools/test/tools/javac/processing/errors/TestReturnCode.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/errors/TestReturnCode.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6403468 * @summary Test that an erroneous return code results from raising an error. * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile TestReturnCode.java * * @compile -processor TestReturnCode -proc:only Foo.java @@ -60,20 +62,17 @@ * This processor raises errors or throws exceptions on different * rounds to allow the return code to be test. */ -@SupportedAnnotationTypes("*") @SupportedOptions({"ErrorOnFirst", "ErrorOnLast", "ExceptionOnFirst", "ExceptionOnLast"}) -public class TestReturnCode extends AbstractProcessor { +public class TestReturnCode extends JavacTestingAbstractProcessor { private boolean errorOnFirst; private boolean errorOnLast; private boolean exceptionOnFirst; private boolean exceptionOnLast; - private Messager messager; - public boolean process(Set annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { @@ -103,11 +102,5 @@ errorOnLast = keySet.contains("ErrorOnLast"); exceptionOnFirst = keySet.contains("ExceptionOnFirst"); exceptionOnLast = keySet.contains("ExceptionOnLast"); - messager = processingEnv.getMessager(); - } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/filer/TestFilerConstraints.java --- a/langtools/test/tools/javac/processing/filer/TestFilerConstraints.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/filer/TestFilerConstraints.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @bug 6380018 6453386 6457283 * @summary Test that the constraints guaranteed by the Filer and maintained * @author Joseph D. Darcy + * @library ../../lib * @build TestFilerConstraints * @compile -encoding iso-8859-1 -processor TestFilerConstraints -proc:only TestFilerConstraints.java */ @@ -69,11 +70,8 @@ * *

*/ -@SupportedAnnotationTypes("*") -public class TestFilerConstraints extends AbstractProcessor { +public class TestFilerConstraints extends JavacTestingAbstractProcessor { private int round = 0; - private Messager messager; - private Filer filer; private PrintWriter pw_src1 = null; private PrintWriter pw_src2 = null; @@ -167,17 +165,6 @@ return true; } - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - messager = processingEnv.getMessager(); - filer = processingEnv.getFiler(); - - } - /** * Test that the single expected expected type, name, is the root * element. diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/filer/TestGetResource.java --- a/langtools/test/tools/javac/processing/filer/TestGetResource.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/filer/TestGetResource.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6380018 6449798 * @summary Test Filer.getResource * @author Joseph D. Darcy - * @build TestGetResource + * @library ../../lib + * @build JavacTestingAbstractProcessor TestGetResource * @compile -processor TestGetResource -proc:only -Aphase=write TestGetResource.java * @compile -processor TestGetResource -proc:only -Aphase=read TestGetResource.java */ @@ -49,13 +50,8 @@ * first run of the annotation processor, write out a resource file * and on the second run read it in. */ -@SupportedAnnotationTypes("*") @SupportedOptions("phase") -public class TestGetResource extends AbstractProcessor { - private Messager messager; - private Filer filer; - private Map options; - +public class TestGetResource extends JavacTestingAbstractProcessor { private static String CONTENTS = "Hello World."; private static String PKG = ""; private static String RESOURCE_NAME = "Resource1"; @@ -92,15 +88,4 @@ } return false; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - messager = processingEnv.getMessager(); - filer = processingEnv.getFiler(); - options = processingEnv.getOptions(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/filer/TestGetResource2.java --- a/langtools/test/tools/javac/processing/filer/TestGetResource2.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/filer/TestGetResource2.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* @test * @bug 6929404 * @summary Filer.getResource(SOURCE_PATH, ...) does not work when -sourcepath contains >1 entry + * @library ../../lib */ import java.io.*; @@ -114,8 +115,7 @@ throw new Exception(errors + " errors occurred"); } - @SupportedAnnotationTypes("*") - static class AnnoProc extends AbstractProcessor { + static class AnnoProc extends JavacTestingAbstractProcessor { public @Override boolean process(Set annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { @@ -123,27 +123,23 @@ } try { - FileObject resource = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt"); + FileObject resource = filer.getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt"); try { resource.openInputStream().close(); - processingEnv.getMessager().printMessage(Kind.NOTE, "found: " + resource.toUri()); + messager.printMessage(Kind.NOTE, "found: " + resource.toUri()); return true; } catch (IOException x) { - processingEnv.getMessager().printMessage(Kind.ERROR, "could not read: " + resource.toUri()); + messager.printMessage(Kind.ERROR, "could not read: " + resource.toUri()); x.printStackTrace(); } } catch (IOException x) { - processingEnv.getMessager().printMessage(Kind.ERROR, "did not find resource"); + messager.printMessage(Kind.ERROR, "did not find resource"); x.printStackTrace(); } return false; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } private File write(File dir, String path, String contents) throws IOException { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/filer/TestInvalidRelativeNames.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/processing/filer/TestInvalidRelativeNames.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 6502392 + * @summary Invalid relative names for Filer.createResource and Filer.getResource + * @library ../../lib + * @build JavacTestingAbstractProcessor + * @compile TestInvalidRelativeNames.java + * @compile/process -processor TestInvalidRelativeNames java.lang.Object + */ + +import java.io.*; +import java.util.*; +import javax.annotation.processing.*; +import javax.lang.model.*; +import javax.lang.model.element.*; +import javax.tools.Diagnostic; +import javax.tools.StandardLocation; + +public class TestInvalidRelativeNames extends JavacTestingAbstractProcessor { + enum Kind { CREATE_WRITER, GET_READER, CREATE_OUTPUT_STREAM, GET_INPUT_STREAM }; + + static final String[] invalidRelativeNames = { + "/boo", "goo/../hoo", "./ioo", "" + }; + + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) { + for (String relative: invalidRelativeNames) { + for (Kind kind: Kind.values()) { + test(relative, kind); + } + } + } + return true; + } + + void test(String relative, Kind kind) { + System.out.println("test relative path: " + relative + ", kind: " + kind); + try { + switch (kind) { + case CREATE_WRITER: + Writer writer = filer.createResource( + StandardLocation.SOURCE_OUTPUT, "", relative).openWriter(); + writer.close(); + break; + + case GET_READER: + Reader reader = filer.getResource( + StandardLocation.SOURCE_OUTPUT, "", relative).openReader(true); + reader.close(); + break; + + case CREATE_OUTPUT_STREAM: + OutputStream out = filer.createResource( + StandardLocation.SOURCE_OUTPUT, "", relative).openOutputStream(); + out.close(); + break; + + case GET_INPUT_STREAM: + InputStream in = filer.createResource( + StandardLocation.SOURCE_OUTPUT, "", relative).openInputStream(); + in.close(); + break; + } + } catch (IllegalArgumentException expected) { + System.out.println("expected exception thrown: " + expected); + return; + } catch (Exception e) { + messager.printMessage(Diagnostic.Kind.ERROR, + "relative path: " + relative + ", kind: " + kind + ", unexpected exception: " + e); + return; + } + messager.printMessage(Diagnostic.Kind.ERROR, + "relative path: " + relative + ", kind: " + kind + ", no exception thrown"); + } +} + diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/filer/TestLastRound.java --- a/langtools/test/tools/javac/processing/filer/TestLastRound.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/filer/TestLastRound.java Tue Oct 26 13:45:25 2010 -0700 @@ -24,6 +24,8 @@ /* * @test 6966604 * @summary JavacFiler not correctly notified of lastRound + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile TestLastRound.java * @compile/fail/ref=TestLastRound.out -XDrawDiagnostics -Werror -proc:only -processor TestLastRound TestLastRound.java */ @@ -35,12 +37,10 @@ import javax.lang.model.element.*; import javax.tools.*; -@SupportedAnnotationTypes("*") -public class TestLastRound extends AbstractProcessor { +public class TestLastRound extends JavacTestingAbstractProcessor { @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - Filer filer = processingEnv.getFiler(); if (roundEnv.processingOver()) { try { JavaFileObject fo = filer.createSourceFile("LastRound.java"); @@ -52,9 +52,4 @@ } return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/filer/TestPackageInfo.java --- a/langtools/test/tools/javac/processing/filer/TestPackageInfo.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/filer/TestPackageInfo.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6380018 6392177 * @summary Test the ability to create and process package-info.java files * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile TestPackageInfo.java * @compile -processor TestPackageInfo -proc:only foo/bar/package-info.java TestPackageInfo.java */ @@ -49,13 +51,7 @@ * 1) Visibility of package-info files from the command line * 2) Visibility of generated package-info.java source files */ -@SupportedAnnotationTypes("*") -public class TestPackageInfo extends AbstractProcessor { - private Elements eltUtils; - private Messager messager; - private Filer filer; - private Map options; - +public class TestPackageInfo extends JavacTestingAbstractProcessor { private int round = 0; public boolean process(Set annotations, @@ -64,11 +60,7 @@ // Verify annotations are as expected Set expectedAnnotations = new HashSet(); - if (round == 1) - expectedAnnotations.add(eltUtils. - getTypeElement("javax.annotation.processing.SupportedAnnotationTypes")); - expectedAnnotations.add(eltUtils. - getTypeElement("java.lang.SuppressWarnings")); + expectedAnnotations.add(eltUtils.getTypeElement("java.lang.SuppressWarnings")); if (!roundEnv.processingOver()) { System.out.println("\nRound " + round); @@ -127,16 +119,4 @@ } return false; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - eltUtils = processingEnv.getElementUtils(); - messager = processingEnv.getMessager(); - filer = processingEnv.getFiler(); - options = processingEnv.getOptions(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/messager/6362067/T6362067.java --- a/langtools/test/tools/javac/processing/messager/6362067/T6362067.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/messager/6362067/T6362067.java Tue Oct 26 13:45:25 2010 -0700 @@ -2,39 +2,34 @@ * @test /nodynamiccopyright/ * @bug 6362067 * @summary Messager methods do not print out source position information - * @build T6362067 + * @library ../../../lib + * @build JavacTestingAbstractProcessor T6362067 * @compile -processor T6362067 -proc:only T6362067.java * @compile/ref=T6362067.out -XDrawDiagnostics -processor T6362067 -proc:only T6362067.java */ - import java.util.Set; import javax.annotation.processing.*; import javax.lang.model.element.*; import static javax.tools.Diagnostic.Kind.*; -@Deprecated // convenient test annotation -@SupportedAnnotationTypes("*") -public class T6362067 extends AbstractProcessor { +@Deprecated // convenient test annotations +@SuppressWarnings({""}) +public class T6362067 extends JavacTestingAbstractProcessor { public boolean process(Set annos, RoundEnvironment roundEnv) { - Messager msgr = processingEnv.getMessager(); + for (Element e: roundEnv.getRootElements()) { - msgr.printMessage(NOTE, "note:elem", e); + messager.printMessage(NOTE, "note:elem", e); for (AnnotationMirror a: e.getAnnotationMirrors()) { - msgr.printMessage(NOTE, "note:anno", e, a); + messager.printMessage(NOTE, "note:anno", e, a); for (AnnotationValue v: a.getElementValues().values()) { - msgr.printMessage(NOTE, "note:value", e, a, v); + messager.printMessage(NOTE, "note:value", e, a, v); } - } } + if (roundEnv.processingOver()) - msgr.printMessage(NOTE, "note:nopos"); + messager.printMessage(NOTE, "note:nopos"); return true; } - - @Override - public javax.lang.model.SourceVersion getSupportedSourceVersion() { - return javax.lang.model.SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/messager/MessagerBasics.java --- a/langtools/test/tools/javac/processing/messager/MessagerBasics.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/messager/MessagerBasics.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6341173 6341072 * @summary Test presence of Messager methods * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile MessagerBasics.java * @compile -processor MessagerBasics -proc:only MessagerBasics.java * @compile/fail -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java @@ -39,18 +41,16 @@ import javax.lang.model.util.*; import static javax.tools.Diagnostic.Kind.*; -@SupportedAnnotationTypes("*") @SupportedOptions("finalError") -public class MessagerBasics extends AbstractProcessor { +public class MessagerBasics extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { - Messager m = processingEnv.getMessager(); if (roundEnv.processingOver()) { if (processingEnv.getOptions().containsKey("finalError")) - m.printMessage(ERROR, "Does not compute"); + messager.printMessage(ERROR, "Does not compute"); else { - m.printMessage(NOTE, "Post no bills"); - m.printMessage(WARNING, "Beware the ides of March!"); + messager.printMessage(NOTE, "Post no bills"); + messager.printMessage(WARNING, "Beware the ides of March!"); } } return true; diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/6194785/T6194785.java --- a/langtools/test/tools/javac/processing/model/6194785/T6194785.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/6194785/T6194785.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6194785 * @summary ParameterDeclaration.getSimpleName does not return actual name from class files * @author Peter von der Ah\u00e9 + * @library ../../../lib + * @build JavacTestingAbstractProcessor * @compile -g T6194785.java T6194785a.java * @compile -processor T6194785 foo.T6194785a T6194785.java */ @@ -36,13 +38,10 @@ import javax.lang.model.util.*; import static javax.tools.Diagnostic.Kind.*; -@SupportedAnnotationTypes("*") -public class T6194785 extends AbstractProcessor { +public class T6194785 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { - final Messager log = processingEnv.getMessager(); - final Elements elements = processingEnv.getElementUtils(); class Scan extends ElementScanner7 { @Override public Void visitExecutable(ExecutableElement e, Void ignored) { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/6341534/T6341534.java --- a/langtools/test/tools/javac/processing/model/6341534/T6341534.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/6341534/T6341534.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,6 +27,8 @@ * @summary PackageElement.getEnclosedElements results in NullPointerException from parse(JavaCompiler.java:429) * @author Steve Sides * @author Peter von der Ahe + * @library ../../../lib + * @build JavacTestingAbstractProcessor * @compile T6341534.java * @compile -proc:only -processor T6341534 dir/package-info.java * @compile -processor T6341534 dir/package-info.java @@ -40,20 +42,11 @@ import java.util.Set; import static javax.tools.Diagnostic.Kind.*; -@SupportedAnnotationTypes("*") -public class T6341534 extends AbstractProcessor { - Elements elements; - Messager messager; - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - messager = processingEnv.getMessager(); - } - +public class T6341534 extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment renv) { messager.printMessage(NOTE, - String.valueOf(elements.getPackageElement("no.such.package"))); - PackageElement dir = elements.getPackageElement("dir"); + String.valueOf(eltUtils.getPackageElement("no.such.package"))); + PackageElement dir = eltUtils.getPackageElement("dir"); messager.printMessage(NOTE, dir.getQualifiedName().toString()); for (Element e : dir.getEnclosedElements()) messager.printMessage(NOTE, e.toString()); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java --- a/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java Tue Oct 26 13:45:25 2010 -0700 @@ -26,7 +26,8 @@ * @bug 6449781 * @summary Test that reported names of anonymous classes are non-null. * @author Joseph D. Darcy - * @build TestAnonSourceNames + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestAnonSourceNames * @compile -processor TestAnonSourceNames TestAnonClassNames.java * @run main TestAnonClassNames */ @@ -141,8 +142,7 @@ /** * Probe at the various kinds of names of a type element. */ -@SupportedAnnotationTypes("*") -class ClassNameProber extends AbstractProcessor { +class ClassNameProber extends JavacTestingAbstractProcessor { public ClassNameProber(){super();} private boolean classesFound=false; @@ -174,8 +174,4 @@ } return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/element/TestAnonSourceNames.java --- a/langtools/test/tools/javac/processing/model/element/TestAnonSourceNames.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/element/TestAnonSourceNames.java Tue Oct 26 13:45:25 2010 -0700 @@ -36,8 +36,7 @@ * Using the tree API, retrieve element representations of anonymous * classes and verify their names are as specified. */ -@SupportedAnnotationTypes("*") -public class TestAnonSourceNames extends AbstractProcessor { +public class TestAnonSourceNames extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { @@ -84,9 +83,4 @@ return super.visitClass(node, cu); } } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/element/TestElement.java --- a/langtools/test/tools/javac/processing/model/element/TestElement.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/element/TestElement.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6453386 * @summary Test basic properties of javax.lang.element.Element * @author Joseph D. Darcy - * @build TestElement + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestElement * @compile -processor TestElement -proc:only TestElement.java */ @@ -43,8 +44,7 @@ /** * Test basic workings of javax.lang.element.Element */ -@SupportedAnnotationTypes("*") -public class TestElement extends AbstractProcessor { +public class TestElement extends JavacTestingAbstractProcessor { /** * For now, just check that constructors have a simple name of * "". @@ -66,9 +66,4 @@ } return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/element/TestNames.java --- a/langtools/test/tools/javac/processing/model/element/TestNames.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/element/TestNames.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6380016 * @summary Test that the constraints guaranteed by the Filer and maintained * @author Joseph D. Darcy - * @build TestNames + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestNames * @compile -processor TestNames -proc:only TestNames.java */ @@ -45,11 +46,8 @@ /** * Basic tests of semantics of javax.lang.model.element.Name */ -@SupportedAnnotationTypes("*") -public class TestNames extends AbstractProcessor { +public class TestNames extends JavacTestingAbstractProcessor { private int round = 0; - private Filer filer; - private Elements eltUtils; String stringStringName = "java.lang.String"; Name stringName = null; @@ -106,16 +104,6 @@ return true; } - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - filer = processingEnv.getFiler(); - eltUtils = processingEnv.getElementUtils(); - } - private static class Pseudonym implements Name { private String name; diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/element/TestPackageElement.java --- a/langtools/test/tools/javac/processing/model/element/TestPackageElement.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/element/TestPackageElement.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6449798 6399404 * @summary Test basic workings of PackageElement * @author Joseph D. Darcy - * @build TestPackageElement + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestPackageElement * @compile -processor TestPackageElement -proc:only TestPackageElement.java */ @@ -43,11 +44,7 @@ /** * Test basic workings of PackageElement. */ -@SupportedAnnotationTypes("*") -public class TestPackageElement extends AbstractProcessor { - private Filer filer; - private Elements eltUtils; - +public class TestPackageElement extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { @@ -71,15 +68,4 @@ } return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - filer = processingEnv.getFiler(); - eltUtils = processingEnv.getElementUtils(); - } - } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/element/TestResourceElement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/processing/model/element/TestResourceElement.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 6967842 + * @summary Element not returned from tree API for ARM resource variables. + * @author A. Sundararajan + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestResourceElement + * @compile -processor TestResourceElement -proc:only TestResourceElement.java + */ + +import javax.annotation.processing.*; +import javax.lang.model.*; +import javax.lang.model.element.*; +import java.util.*; +import com.sun.source.tree.*; +import com.sun.source.util.*; + +public class TestResourceElement extends JavacTestingAbstractProcessor implements AutoCloseable { + public boolean process(Set annotations, + RoundEnvironment roundEnv) { + if (!roundEnv.processingOver()) { + Trees trees = Trees.instance(processingEnv); + + for(Element rootElement : roundEnv.getRootElements()) { + TreePath treePath = trees.getPath(rootElement); + + VariableScanner varScanner = new VariableScanner(trees); + varScanner.scan(trees.getTree(rootElement), + treePath.getCompilationUnit()); + if (varScanner.getTrvElement() == null) { + throw new AssertionError("Element is null for 'trv'"); + } + } + } + return true; + } + + @Override + public void close() {} + + private void test1() { + // The resource variable "trv"'s Element is checked. + // Do not change the name of the variable. + try(TestResourceElement trv = this) {} + } + + class VariableScanner extends TreeScanner { + private Trees trees; + private Element trvElement; + + public VariableScanner(Trees trees) { + super(); + this.trees = trees; + } + @Override + public Void visitVariable(VariableTree node, CompilationUnitTree cu) { + // if this is "trv", get it's element. + if (node.getName().contentEquals("trv")) { + trvElement = trees.getElement(trees.getPath(cu, node)); + } + return super.visitVariable(node, cu); + } + + Element getTrvElement() { + return trvElement; + } + } +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/element/TestResourceVariable.java --- a/langtools/test/tools/javac/processing/model/element/TestResourceVariable.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/element/TestResourceVariable.java Tue Oct 26 13:45:25 2010 -0700 @@ -23,11 +23,12 @@ /* * @test - * @bug 6911256 6964740 + * @bug 6911256 6964740 6967842 * @summary Test that the resource variable kind is appropriately set * @author Joseph D. Darcy - * @build TestResourceVariable - * @compile/fail -processor TestResourceVariable -proc:only TestResourceVariable.java + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestResourceVariable + * @compile -processor TestResourceVariable -proc:only TestResourceVariable.java */ // Bug should be filed for this misbehavior @@ -48,8 +49,7 @@ * resource of an ARM block and verify their kind tags are set * appropriately. */ -@SupportedAnnotationTypes("*") -public class TestResourceVariable extends AbstractProcessor implements AutoCloseable { +public class TestResourceVariable extends JavacTestingAbstractProcessor implements AutoCloseable { int resourceVariableCount = 0; public boolean process(Set annotations, @@ -105,9 +105,4 @@ return super.visitVariable(node, cu); } } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/element/TypeParamBounds.java --- a/langtools/test/tools/javac/processing/model/element/TypeParamBounds.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/element/TypeParamBounds.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6423972 * @summary Tests TypeParameter.getBounds. * @author Scott Seligman - * @build TypeParamBounds + * @library ../../../lib + * @build JavacTestingAbstractProcessor TypeParamBounds * @compile -processor TypeParamBounds -proc:only TypeParamBounds.java */ @@ -40,18 +41,7 @@ import javax.lang.model.type.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") -public class TypeParamBounds extends AbstractProcessor { - - Elements elements; - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - types = penv.getTypeUtils(); - } - +public class TypeParamBounds extends JavacTestingAbstractProcessor { public boolean process(Set annoTypes, RoundEnvironment round) { if (!round.processingOver()) @@ -59,11 +49,6 @@ return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private void doit(Set annoTypes, RoundEnvironment round) { TypeElement gen = elements.getTypeElement("TypeParamBounds.Gen"); @@ -91,7 +76,6 @@ // Fodder for the processor - static class Gen { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java --- a/langtools/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6362178 * @summary MirroredType[s]Exception shouldn't be created too eagerly * @author Scott Seligman + * @library ../../../../lib + * @build JavacTestingAbstractProcessor * @compile -g OverEager.java * @compile -processor OverEager -proc:only OverEager.java */ @@ -40,17 +42,7 @@ @SupportedAnnotationTypes("IAm") @IAm(OverEager.class) -public class OverEager extends AbstractProcessor { - - Elements elements; - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - types = penv.getTypeUtils(); - } - +public class OverEager extends JavacTestingAbstractProcessor { public boolean process(Set annoTypes, RoundEnvironment round) { if (!round.processingOver()) @@ -58,11 +50,6 @@ return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private void doit(Set annoTypes, RoundEnvironment round) { for (TypeElement t : typesIn(round.getRootElements())) { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java --- a/langtools/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java Tue Oct 26 13:45:25 2010 -0700 @@ -25,6 +25,8 @@ * @test * @bug 6519115 * @summary Verify MirroredTypeException vs MirroredTypesException is thrown + * @library ../../../../lib + * @build JavacTestingAbstractProcessor * @compile Plurality.java * @compile -processor Plurality -proc:only Plurality.java * @author Joseph D. Darcy @@ -38,25 +40,13 @@ import javax.lang.model.type.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") @P0 @P1 @P2 @S1 -public class Plurality extends AbstractProcessor { +public class Plurality extends JavacTestingAbstractProcessor { private boolean executed = false; - Elements elements; - Types types; - - @Override - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - types = penv.getTypeUtils(); - } - - public boolean process(Set annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { @@ -164,11 +154,6 @@ toStringName); } } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } @Retention(RetentionPolicy.RUNTIME) diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/type/NoTypes.java --- a/langtools/test/tools/javac/processing/model/type/NoTypes.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/type/NoTypes.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6418666 6423973 6453386 * @summary Test the NoTypes: VOID, PACKAGE, NONE * @author Scott Seligman + * @library ../../../lib + * @build JavacTestingAbstractProcessor * @compile -g NoTypes.java * @compile -processor NoTypes -proc:only NoTypes.java */ @@ -39,18 +41,7 @@ import static javax.lang.model.type.TypeKind.*; -@SupportedAnnotationTypes("*") -public class NoTypes extends AbstractProcessor { - - Elements elements; - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - types = penv.getTypeUtils(); - } - +public class NoTypes extends JavacTestingAbstractProcessor { public boolean process(Set annoTypes, RoundEnvironment round) { if (!round.processingOver()) @@ -58,11 +49,6 @@ return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private void doit(Set annoTypes, RoundEnvironment round) { diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/BinaryName.java --- a/langtools/test/tools/javac/processing/model/util/BinaryName.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/util/BinaryName.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6346251 * @summary Test Elements.getBinaryName * @author Scott Seligman - * @build BinaryName + * @library ../../../lib + * @build JavacTestingAbstractProcessor BinaryName * @compile -processor BinaryName -proc:only BinaryName.java */ @@ -38,17 +39,8 @@ import static javax.lang.model.util.ElementFilter.typesIn; -@SupportedAnnotationTypes("*") @HelloIm("BinaryName") -public class BinaryName extends AbstractProcessor { - - Elements elements; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - } - +public class BinaryName extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment round) { if (round.processingOver()) return true; diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/GetTypeElemBadArg.java --- a/langtools/test/tools/javac/processing/model/util/GetTypeElemBadArg.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/util/GetTypeElemBadArg.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6346506 6408241 * @summary getTypeElement should tolerate a type that can't be found * @author Scott Seligman - * @build GetTypeElemBadArg + * @library ../../../lib + * @build JavacTestingAbstractProcessor GetTypeElemBadArg * @compile -processor GetTypeElemBadArg -proc:only GetTypeElemBadArg.java */ @@ -37,16 +38,7 @@ import javax.lang.model.type.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") -public class GetTypeElemBadArg extends AbstractProcessor { - - Elements elements; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - } - +public class GetTypeElemBadArg extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment round) { if (round.processingOver()) return true; @@ -63,12 +55,6 @@ return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private static void tellAbout(TypeElement t) { System.out.println(t); System.out.println(t.getClass()); diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/NoSupers.java --- a/langtools/test/tools/javac/processing/model/util/NoSupers.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/util/NoSupers.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6346453 * @summary directSupertypes should return empty list if arg has no supertypes * @author Scott Seligman - * @build NoSupers + * @library ../../../lib + * @build JavacTestingAbstractProcessor NoSupers * @compile -processor NoSupers -proc:only NoSupers.java */ @@ -36,16 +37,7 @@ import javax.lang.model.type.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") -public class NoSupers extends AbstractProcessor { - - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - types = penv.getTypeUtils(); - } - +public class NoSupers extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment round) { if (round.processingOver()) return true; diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/OverridesSpecEx.java --- a/langtools/test/tools/javac/processing/model/util/OverridesSpecEx.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/util/OverridesSpecEx.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6453386 * @summary Verify that example code in Elements.overrides works as spec'ed. * @author Scott Seligman + * @library ../../../lib + * @build JavacTestingAbstractProcessor * @compile -g OverridesSpecEx.java * @compile -processor OverridesSpecEx -proc:only OverridesSpecEx.java */ @@ -39,19 +41,7 @@ import static javax.lang.model.util.ElementFilter.*; - -@SupportedAnnotationTypes("*") -public class OverridesSpecEx extends AbstractProcessor { - - Elements elements; - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - types = penv.getTypeUtils(); - } - +public class OverridesSpecEx extends JavacTestingAbstractProcessor { public boolean process(Set annoTypes, RoundEnvironment round) { if (!round.processingOver()) @@ -59,11 +49,6 @@ return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private void doit(Set annoTypes, RoundEnvironment round) { TypeElement string = elements.getTypeElement("java.lang.String"); @@ -113,9 +98,7 @@ throw new AssertionError("Bogus result"); } - // Fodder for the processor - class A { public void m() {} } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/TypesBadArg.java --- a/langtools/test/tools/javac/processing/model/util/TypesBadArg.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/util/TypesBadArg.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6345812 * @summary Validate argument kinds in Types utilities * @author Scott Seligman - * @build TypesBadArg + * @library ../../../lib + * @build JavacTestingAbstractProcessor TypesBadArg * @compile -processor TypesBadArg -proc:only TypesBadArg.java */ @@ -36,15 +37,9 @@ import javax.lang.model.type.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") -public class TypesBadArg extends AbstractProcessor { - +public class TypesBadArg extends JavacTestingAbstractProcessor { boolean success = true; - public void init(ProcessingEnvironment penv) { - super.init(penv); - } - public boolean process(Set tes, RoundEnvironment round) { if (round.processingOver()) return true; diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java --- a/langtools/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010 Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6392818 * @summary Tests Elements.isDeprecated(Element) * @author Joseph D. Darcy + * @library ../../../../lib + * @build JavacTestingAbstractProcessor * @compile TestDeprecation.java * @compile -processor TestDeprecation -proc:only Dep1.java * @compile Dep1.java @@ -47,8 +49,7 @@ * getElementsAnnotatedWith is consistent with the expected results * stored in an AnnotatedElementInfo annotation. */ -@SupportedAnnotationTypes("*") -public class TestDeprecation extends AbstractProcessor { +public class TestDeprecation extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { @@ -98,9 +99,4 @@ return failure; } } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java --- a/langtools/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6346973 * @summary directSupertypes(t) should not return t * @author Scott Seligman - * @build DirectSupersOfErr + * @library ../../../../lib + * @build JavacTestingAbstractProcessor DirectSupersOfErr * @compile -processor DirectSupersOfErr -proc:only C1.java */ @@ -37,16 +38,7 @@ import javax.lang.model.util.*; import static javax.lang.model.util.ElementFilter.*; -@SupportedAnnotationTypes("*") -public class DirectSupersOfErr extends AbstractProcessor { - - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - types = penv.getTypeUtils(); - } - +public class DirectSupersOfErr extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment round) { if (round.processingOver()) return true; diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java --- a/langtools/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6471577 6517779 * @summary Test Elements.getConstantExpression * @author Joseph D. Darcy - * @build TestGetConstantExpression + * @library ../../../../lib + * @build JavacTestingAbstractProcessor TestGetConstantExpression * @compile -processor TestGetConstantExpression Foo.java */ @@ -44,10 +45,7 @@ /** * Test basic workings of Elements.getConstantExpression. */ -@SupportedAnnotationTypes("*") -public class TestGetConstantExpression extends AbstractProcessor { - private Elements eltUtils; - private Filer filer; +public class TestGetConstantExpression extends JavacTestingAbstractProcessor { private int round = 1; /** @@ -130,14 +128,4 @@ return 0; } } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - eltUtils = processingEnv.getElementUtils(); - filer = processingEnv.getFiler(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java --- a/langtools/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6453386 * @summary Test Elements.getPackageOf * @author Joseph D. Darcy - * @build TestGetPackageOf + * @library ../../../../lib + * @build JavacTestingAbstractProcessor TestGetPackageOf * @compile -processor TestGetPackageOf -proc:only TestGetPackageOf.java */ @@ -43,10 +44,7 @@ /** * Test basic workings of Elements.getPackageOf */ -@SupportedAnnotationTypes("*") -public class TestGetPackageOf extends AbstractProcessor { - private Elements eltUtils; - +public class TestGetPackageOf extends JavacTestingAbstractProcessor { /** * Check expected behavior on classes and packages. */ @@ -69,13 +67,4 @@ } return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - eltUtils = processingEnv.getElementUtils(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 6877202 6986246 + * @summary Elements.getDocComment() is not getting JavaDocComments + */ + +import com.sun.source.tree.*; +import com.sun.source.util.*; +import java.io.*; +import java.util.*; +import javax.annotation.processing.*; +import javax.lang.model.*; +import javax.lang.model.element.*; +import javax.lang.model.util.*; +import javax.tools.*; + +/* + * For a mixture of pre-existing and generated source files, ensure that we can + * get the doc comments. + * The test uses both a standard ElementScanner to find all the elements being + * processed, and a TreeScanner to find all the local and anonymous inner classes + * as well. + * And, because the relevant code paths in the compiler are different for + * command line and JSR 199 invocation, the test covers both ways of invoking the + * compiler. + */ + +@SupportedOptions("scan") +@SupportedAnnotationTypes("*") +public class TestDocComments extends AbstractProcessor { + enum CompileKind { API, CMD }; + enum ScanKind { TREE, ELEMENT }; + + // ----- Main test driver: invoke compiler for the various test cases ------ + + public static void main(String... args) throws Exception { + for (CompileKind ck: CompileKind.values()) { + for (ScanKind sk: ScanKind.values()) { + try { + test(ck, sk); + } catch (IOException e) { + error(e.toString()); + } + } + } + + if (errors > 0) + throw new Exception(errors + " errors occurred"); + } + + static void test(CompileKind ck, ScanKind sk) throws IOException { + String testClasses = System.getProperty("test.classes"); + String testSrc = System.getProperty("test.src"); + File testDir = new File("test." + ck + "." + sk); + testDir.mkdirs(); + String[] opts = { + "-d", testDir.getPath(), + "-implicit:none", + "-processor", TestDocComments.class.getName(), + "-processorpath", testClasses, + //"-XprintRounds", + "-Ascan=" + sk + }; + File[] files = { + new File(testSrc, "a/First.java") + }; + + if (ck == CompileKind.API) + test_javac_api(opts, files); + else + test_javac_cmd(opts, files); + } + + static void test_javac_api(String[] opts, File[] files) throws IOException { + System.err.println("test javac api: " + Arrays.asList(opts) + " " + Arrays.asList(files)); + DiagnosticListener dl = new DiagnosticListener() { + public void report(Diagnostic diagnostic) { + error(diagnostic.toString()); + } + }; + JavaCompiler c = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = c.getStandardFileManager(null, null, null); + Iterable units = fm.getJavaFileObjects(files); + JavacTask t = (JavacTask) c.getTask(null, fm, dl, Arrays.asList(opts), null, units); + t.parse(); + t.analyze(); + } + + static void test_javac_cmd(String[] opts, File[] files) { + System.err.println("test javac cmd: " + Arrays.asList(opts) + " " + Arrays.asList(files)); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + List args = new ArrayList(Arrays.asList(opts)); + for (File f: files) + args.add(f.getPath()); + int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw); + pw.close(); + String out = sw.toString(); + if (out.length() > 0) + System.err.println(out); + if (rc > 0) + error("Compilation failed: rc=" + rc); + } + + static void error(String msg) { + System.err.println(msg); + errors++; + //throw new Error(msg); + } + + static int errors; + + // ----- Annotation processor: scan for elements and check doc comments ---- + + Map options; + Filer filer; + Messager messager; + Elements elements; + Trees trees; + ScanKind skind; + + int round = 0; + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + @Override + public void init(ProcessingEnvironment pEnv) { + super.init(pEnv); + options = pEnv.getOptions(); + filer = pEnv.getFiler(); + messager = pEnv.getMessager(); + elements = pEnv.getElementUtils(); + trees = Trees.instance(processingEnv); + skind = ScanKind.valueOf(options.get("scan")); + } + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + round++; + + // Scan elements using an appropriate scanner, and for each element found, + // call check(Element e) to verify the doc comment on that element + for (Element e: roundEnv.getRootElements()) { + System.err.println("scan " + skind + " " + e.getKind() + " " + e.getSimpleName()); + if (skind == ScanKind.TREE) { + new TestTreeScanner().scan(trees.getPath(e), trees); + } else + new TestElementScanner().scan(e); + } + + // For a few rounds, generate new source files, so that we can check whether + // doc comments are correctly handled in subsequent processing rounds + final int MAX_ROUNDS = 3; + if (round <= MAX_ROUNDS) { + String pkg = "p"; + String currClass = "Gen" + round; + String curr = pkg + "." + currClass; + String next = (round < MAX_ROUNDS) ? (pkg + ".Gen" + (round + 1)) : "z.Last"; + StringBuilder text = new StringBuilder(); + text.append("package ").append(pkg).append(";\n"); + text.append("/** CLASS ").append(currClass).append(" */\n"); + text.append("public class ").append(currClass).append(" {\n"); + text.append(" /** CONSTRUCTOR **/\n"); + text.append(" ").append(currClass).append("() { }\n"); + text.append(" /** FIELD x */\n"); + text.append(" ").append(next).append(" x;\n"); + text.append(" /** METHOD m */\n"); + text.append(" void m() { }\n"); + text.append("}\n"); + + try { + JavaFileObject fo = filer.createSourceFile(curr); + Writer out = fo.openWriter(); + try { + out.write(text.toString()); + } finally { + out.close(); + } + } catch (IOException e) { + throw new Error(e); + } + } + + return true; + } + + /* + * Check that the doc comment on an element is as expected. + * This method is invoked for each element found by the scanners run by process. + */ + void check(Element e) { + System.err.println("Checking " + e); + + String dc = elements.getDocComment(e); + System.err.println(" found " + dc); + + String expect = (e.getKind() + " " + e.getSimpleName()); // default + + Name name = e.getSimpleName(); + Element encl = e.getEnclosingElement(); + Name enclName = encl.getSimpleName(); + ElementKind enclKind = encl.getKind(); + switch (e.getKind()) { + case PARAMETER: + case LOCAL_VARIABLE: + // doc comments not retained for these elements + expect = null; + break; + + case CONSTRUCTOR: + if (enclName.length() == 0 || enclKind == ElementKind.ENUM) { + // Enum constructor is synthetic + expect = null; + } + break; + + case METHOD: + if (enclKind == ElementKind.ENUM + && (name.contentEquals("values") || name.contentEquals("valueOf"))) { + // synthetic enum methods + expect = null; + } + break; + + case CLASS: + if (e.getSimpleName().length() == 0) { + // anon inner class + expect = null; + } + break; + } + + System.err.println(" expect " + expect); + + if (dc == null ? expect == null : dc.trim().equals(expect)) + return; + + if (dc == null) + messager.printMessage(Diagnostic.Kind.ERROR, "doc comment is null", e); + else { + messager.printMessage(Diagnostic.Kind.ERROR, + "unexpected comment: \"" + dc + "\", expected \"" + expect + "\"", e); + } + } + + // ----- Scanners to find elements ----------------------------------------- + + class TestElementScanner extends ElementScanner7 { + @Override + public Void visitExecutable(ExecutableElement e, Void _) { + check(e); + return super.visitExecutable(e, _); + } + @Override + public Void visitType(TypeElement e, Void _) { + check(e); + return super.visitType(e, _); + } + @Override + public Void visitVariable(VariableElement e, Void _) { + check(e); + return super.visitVariable(e, _); + } + } + + class TestTreeScanner extends TreePathScanner { + @Override + public Void visitClass(ClassTree tree, Trees trees) { + check(trees.getElement(getCurrentPath())); + return super.visitClass(tree, trees); + } + @Override + public Void visitMethod(MethodTree tree, Trees trees) { + check(trees.getElement(getCurrentPath())); + return super.visitMethod(tree, trees); + } + @Override + public Void visitVariable(VariableTree tree, Trees trees) { + check(trees.getElement(getCurrentPath())); + return super.visitVariable(tree, trees); + } + } + +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/elements/doccomments/a/First.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/a/First.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package a; + +/** CLASS First */ +public class First { + /** CONSTRUCTOR */ + First() { } + + /** FIELD x */ + p.Gen1 x; + + /** METHOD m **/ + void m(int i) { + /** CLASS Local */ + class Local { + /** CONSTRUCTOR */ + Local() { } + } + + Runnable r = new Runnable() { + /** METHOD run **/ + public void run() { } + }; + + } + + /** ENUM E */ + enum E { + /** ENUM_CONSTANT e1 */ + e1 + } +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/elements/doccomments/z/Last.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/z/Last.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package z; + +// This class should be read last, implicitly. Therefore it should not +// be subject to anno processing. If it is, the lack of doc comments should +// be detected and will flag an error. +public class Last { +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/model/util/filter/TestIterables.java --- a/langtools/test/tools/javac/processing/model/util/filter/TestIterables.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/model/util/filter/TestIterables.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ * @bug 6406164 * @summary Test that ElementFilter iterable methods behave properly. * @author Joseph D. Darcy + * @library ../../../../lib + * @build JavacTestingAbstractProcessor * @compile TestIterables.java * @compile -processor TestIterables -proc:only Foo1.java * @compile Foo1.java @@ -51,9 +53,8 @@ * results. */ @SupportedAnnotationTypes("ExpectedElementCounts") -@ExpectedElementCounts(methods=3) -public class TestIterables extends AbstractProcessor { - +@ExpectedElementCounts(methods=2) +public class TestIterables extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { @@ -118,10 +119,4 @@ return count1; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/options/Xprint.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/processing/options/Xprint.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 6266828 + * @summary JSR 269: Java Language Model API + * @author Peter von der Ah\u00e9 + */ +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; + +public class Xprint { + public static void main(String[] args) { + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + javac.run(System.in, null, null, + "-Xprint", + "com.sun.tools.javac.code.Types", + "com.sun.tools.javac.parser.Parser", + "java.util.EnumSet"); + } +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/options/XprintDocComments.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/processing/options/XprintDocComments.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 6861094 + * @summary javac -Xprint does not print comments + * @compile/ref=XprintDocComments.out -Xprint XprintDocComments.java + */ + +/** + * CLASS XprintDocComments + */ +class XPrintDocComments { + /** + * FIELD i; + */ + int i; +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/options/XprintDocComments.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/processing/options/XprintDocComments.out Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,12 @@ + +/** + * CLASS XprintDocComments + */ +class XPrintDocComments { + + XPrintDocComments(); + /** + * FIELD i; + */ + int i; +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java --- a/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java Tue Oct 26 13:45:25 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,8 @@ /** * This processor returns the supported source level as indicated by - * the "SourceLevel" option. + * the "SourceLevel" option; therefore, don't use + * JavacTestingAbstractProcessor which returns the latest source level. */ @SupportedAnnotationTypes("*") @SupportedOptions("SourceVersion") diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/werror/WError1.java --- a/langtools/test/tools/javac/processing/werror/WError1.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/werror/WError1.java Tue Oct 26 13:45:25 2010 -0700 @@ -24,6 +24,8 @@ /* * @test 6403456 * @summary -Werror should work with annotation processing + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile WError1.java * @compile -proc:only -processor WError1 WError1.java * @compile/fail/ref=WError1.out -XDrawDiagnostics -Werror -proc:only -processor WError1 WError1.java @@ -36,22 +38,15 @@ import javax.lang.model.element.*; import javax.tools.*; -@SupportedAnnotationTypes("*") -public class WError1 extends AbstractProcessor { +public class WError1 extends JavacTestingAbstractProcessor { @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - Messager messager = processingEnv.getMessager(); if (++round == 1) { messager.printMessage(Diagnostic.Kind.WARNING, "round 1"); } return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - int round = 0; } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/werror/WErrorGen.java --- a/langtools/test/tools/javac/processing/werror/WErrorGen.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/werror/WErrorGen.java Tue Oct 26 13:45:25 2010 -0700 @@ -24,6 +24,8 @@ /* * @test 6403456 * @summary -Werror should work with annotation processing + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile WErrorGen.java * @compile -proc:only -processor WErrorGen WErrorGen.java * @compile/fail/ref=WErrorGen.out -XDrawDiagnostics -Werror -Xlint:rawtypes -processor WErrorGen WErrorGen.java @@ -36,12 +38,10 @@ import javax.lang.model.element.*; import javax.tools.*; -@SupportedAnnotationTypes("*") -public class WErrorGen extends AbstractProcessor { +public class WErrorGen extends JavacTestingAbstractProcessor { @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - Filer filer = processingEnv.getFiler(); if (++round == 1) { try { JavaFileObject fo = filer.createSourceFile("Gen"); @@ -54,10 +54,5 @@ return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - int round = 0; } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/processing/werror/WErrorLast.java --- a/langtools/test/tools/javac/processing/werror/WErrorLast.java Fri Sep 24 22:42:14 2010 -0700 +++ b/langtools/test/tools/javac/processing/werror/WErrorLast.java Tue Oct 26 13:45:25 2010 -0700 @@ -24,6 +24,8 @@ /* * @test 6403456 * @summary -Werror should work with annotation processing + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile WErrorLast.java * @compile -proc:only -processor WErrorLast WErrorLast.java * @compile/fail/ref=WErrorLast.out -XDrawDiagnostics -Werror -proc:only -processor WErrorLast WErrorLast.java @@ -36,20 +38,13 @@ import javax.lang.model.element.*; import javax.tools.*; -@SupportedAnnotationTypes("*") -public class WErrorLast extends AbstractProcessor { +public class WErrorLast extends JavacTestingAbstractProcessor { @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - Messager messager = processingEnv.getMessager(); if (roundEnv.processingOver()) { messager.printMessage(Diagnostic.Kind.WARNING, "last round"); } return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javac/tree/TreePosRoundsTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/tree/TreePosRoundsTest.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 6985205 6986246 + * @summary access to tree positions and doc comments may be lost across annotation processing rounds + * @build TreePosRoundsTest + * @compile -proc:only -processor TreePosRoundsTest TreePosRoundsTest.java + * @run main TreePosRoundsTest + */ + +import java.io.*; +import java.util.*; +import javax.annotation.processing.*; +import javax.lang.model.*; +import javax.lang.model.element.*; +import javax.tools.*; + +import com.sun.source.tree.*; +import com.sun.source.util.*; +import javax.tools.JavaCompiler.CompilationTask; + +// This test is an annotation processor that performs multiple rounds of +// processing, and on each round, it checks that source positions are +// available and correct. +// +// The test can be run directly as a processor from the javac command line +// or via JSR 199 by invoking the main program. + +@SupportedAnnotationTypes("*") +public class TreePosRoundsTest extends AbstractProcessor { + public static void main(String... args) throws Exception { + String testSrc = System.getProperty("test.src"); + String testClasses = System.getProperty("test.classes"); + JavaCompiler c = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = c.getStandardFileManager(null, null, null); + String thisName = TreePosRoundsTest.class.getName(); + File thisFile = new File(testSrc, thisName + ".java"); + Iterable files = fm.getJavaFileObjects(thisFile); + List options = Arrays.asList( + "-proc:only", + "-processor", thisName, + "-processorpath", testClasses); + CompilationTask t = c.getTask(null, fm, null, options, null, files); + boolean ok = t.call(); + if (!ok) + throw new Exception("processing failed"); + } + + Filer filer; + Messager messager; + Trees trees; + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + @Override + public void init(ProcessingEnvironment pEnv) { + super.init(pEnv); + filer = pEnv.getFiler(); + messager = pEnv.getMessager(); + trees = Trees.instance(pEnv); + } + + int round = 0; + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + round++; + + // Scan trees for elements, verifying source tree positions + for (Element e: roundEnv.getRootElements()) { + try { + TreePath p = trees.getPath(e); + new TestTreeScanner(p.getCompilationUnit(), trees).scan(trees.getPath(e), null); + } catch (IOException ex) { + messager.printMessage(Diagnostic.Kind.ERROR, + "Cannot get source: " + ex, e); + } + } + + final int MAXROUNDS = 3; + if (round < MAXROUNDS) + generateSource("Gen" + round); + + return true; + } + + void generateSource(String name) { + StringBuilder text = new StringBuilder(); + text.append("class ").append(name).append("{\n"); + text.append(" int one = 1;\n"); + text.append(" int two = 2;\n"); + text.append(" int three = one + two;\n"); + text.append("}\n"); + + try { + JavaFileObject fo = filer.createSourceFile(name); + Writer out = fo.openWriter(); + try { + out.write(text.toString()); + } finally { + out.close(); + } + } catch (IOException e) { + throw new Error(e); + } + } + + class TestTreeScanner extends TreePathScanner { + TestTreeScanner(CompilationUnitTree unit, Trees trees) throws IOException { + this.unit = unit; + JavaFileObject sf = unit.getSourceFile(); + source = sf.getCharContent(true).toString(); + sourcePositions = trees.getSourcePositions(); + } + + @Override + public Void visitVariable(VariableTree tree, Void _) { + check(getCurrentPath()); + return super.visitVariable(tree, _); + } + + void check(TreePath tp) { + Tree tree = tp.getLeaf(); + + String expect = tree.toString(); + if (tree.getKind() == Tree.Kind.VARIABLE) { + // tree.toString() does not know enough context to add ";", + // so deal with that manually... + Tree.Kind enclKind = tp.getParentPath().getLeaf().getKind(); + //System.err.println(" encl: " +enclKind); + if (enclKind == Tree.Kind.CLASS || enclKind == Tree.Kind.BLOCK) + expect += ";"; + } + //System.err.println("expect: " + expect); + + int start = (int)sourcePositions.getStartPosition(unit, tree); + if (start == Diagnostic.NOPOS) { + messager.printMessage(Diagnostic.Kind.ERROR, "start pos not set for " + trim(tree)); + return; + } + + int end = (int)sourcePositions.getEndPosition(unit, tree); + if (end == Diagnostic.NOPOS) { + messager.printMessage(Diagnostic.Kind.ERROR, "end pos not set for " + trim(tree)); + return; + } + + String found = source.substring(start, end); + //System.err.println(" found: " + found); + + // allow for long lines, in which case just compare beginning and + // end of the strings + boolean equal; + if (found.contains("\n")) { + String head = found.substring(0, found.indexOf("\n")); + String tail = found.substring(found.lastIndexOf("\n")).trim(); + equal = expect.startsWith(head) && expect.endsWith(tail); + } else { + equal = expect.equals(found); + } + + if (!equal) { + messager.printMessage(Diagnostic.Kind.ERROR, + "unexpected value found: '" + found + "'; expected: '" + expect + "'"); + } + } + + String trim(Tree tree) { + final int MAXLEN = 32; + String s = tree.toString().replaceAll("\\s+", " ").trim(); + return (s.length() < MAXLEN) ? s : s.substring(0, MAXLEN); + + } + + CompilationUnitTree unit; + SourcePositions sourcePositions; + String source; + } + +} diff -r 79caba0caf4f -r e0bc5b441d60 langtools/test/tools/javah/VersionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javah/VersionTest.java Tue Oct 26 13:45:25 2010 -0700 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 6890226 + * @summary javah -version is broken + */ + +import java.io.*; +import java.util.Locale; + +public class VersionTest { + public static void main(String... args) { + Locale prev = Locale.getDefault(); + try { + Locale.setDefault(Locale.ENGLISH); + System.err.println(Locale.getDefault()); + test("-version", "\\S+ version \"\\S+\""); + test("-fullversion", "\\S+ full version \"\\S+\""); + } finally { + Locale.setDefault(prev); + } + } + + static void test(String option, String regex) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + String[] args = { option }; + int rc = com.sun.tools.javah.Main.run(args, pw); + pw.close(); + if (rc != 0) + throw new Error("javah failed: rc=" + rc); + String out = sw.toString().trim(); + System.err.println(out); + if (!out.matches(regex)) + throw new Error("output does not match pattern: " + regex); + } +} diff -r 79caba0caf4f -r e0bc5b441d60 make/jprt.properties --- a/make/jprt.properties Fri Sep 24 22:42:14 2010 -0700 +++ b/make/jprt.properties Tue Oct 26 13:45:25 2010 -0700 @@ -25,49 +25,310 @@ # Properties for jprt -# Use whatever release that the submitted job requests +# At submit time, the release supplied will be in jprt.submit.release +# and will be one of the official release names defined in jprt. +# jprt supports property value expansion using ${property.name} syntax. + +# This tells jprt what default release we want to build jprt.tools.default.release=${jprt.submit.release} # The different build flavors we want, we override here so we just get these 2 jprt.build.flavors=product,fastdebug -# Shortened list of vm tests -jprt.test.targets= \ - *-product-*-jvm98, \ - *-product-*-scimark, \ - *-product-*-runThese, \ - *-product-*-GCBasher_default, \ - *-product-*-GCOld_default, \ - *-product-*-jbb_default +# Define the Windows we want (temporary) +jprt.my.windows.i586.jdk7b107=windows_i586_5.0 +jprt.my.windows.i586.jdk7temp=windows_i586_5.0 +jprt.my.windows.i586.jdk7=windows_i586_5.1 +jprt.my.windows.i586=${jprt.my.windows.i586.${jprt.tools.default.release}} + +# Standard list of jprt build targets for this source tree +jprt.build.targets= \ + solaris_sparc_5.10-{product|fastdebug}, \ + solaris_sparcv9_5.10-{product|fastdebug}, \ + solaris_i586_5.10-{product|fastdebug}, \ + solaris_x64_5.10-{product|fastdebug}, \ + linux_i586_2.6-{product|fastdebug}, \ + linux_x64_2.6-{product|fastdebug}, \ + ${jprt.my.windows.i586}-{product|fastdebug}, \ + windows_x64_5.2-{product|fastdebug} + +# User can select the test set with jprt submit "-testset name" option +jprt.my.test.set=${jprt.test.set} + +# Default vm test targets (no fastdebug & limited c2 testing) +jprt.vm.default.test.targets= \ + \ + solaris_sparc_5.10-product-c1-jvm98, \ + solaris_sparcv9_5.10-product-c2-jvm98, \ + solaris_i586_5.10-product-c1-jvm98, \ + solaris_x64_5.10-product-c2-jvm98, \ + linux_i586_2.6-product-{c1|c2}-jvm98, \ + linux_x64_2.6-product-c2-jvm98, \ + ${jprt.my.windows.i586}-product-c1-jvm98, \ + windows_x64_5.2-product-c2-jvm98, \ + \ + solaris_sparc_5.10-product-c1-scimark, \ + solaris_sparcv9_5.10-product-c2-scimark, \ + solaris_i586_5.10-product-c1-scimark, \ + solaris_x64_5.10-product-c2-scimark, \ + linux_i586_2.6-product-{c1|c2}-scimark, \ + linux_x64_2.6-product-c2-scimark, \ + ${jprt.my.windows.i586}-product-c1-scimark, \ + windows_x64_5.2-product-c2-scimark -# Test targets in test/Makefile -jprt.make.rule.test.targets= \ - *-product-*-langtools_jtreg, \ - *-product-*-jdk_beans1, \ - *-product-*-jdk_beans2, \ - *-product-*-jdk_beans3, \ - *-product-*-jdk_io, \ - *-product-*-jdk_lang, \ - *-product-*-jdk_management1, \ - *-product-*-jdk_management2, \ - *-product-*-jdk_math, \ - *-product-*-jdk_misc, \ - *-product-*-jdk_net, \ - *-product-*-jdk_nio1, \ - *-product-*-jdk_nio2, \ - *-product-*-jdk_nio3, \ - *-product-*-jdk_security1, \ - *-product-*-jdk_security2, \ - *-product-*-jdk_security3, \ - *-product-*-jdk_text, \ - *-product-*-jdk_tools1, \ - *-product-*-jdk_tools2, \ - *-product-*-jdk_util +# Default jdk test targets in test/Makefile (no fastdebug & limited c2 testing) +jprt.make.rule.default.test.targets= \ + \ + solaris_sparc_5.10-product-c1-langtools_jtreg, \ + solaris_sparcv9_5.10-product-c2-langtools_jtreg, \ + solaris_i586_5.10-product-c1-langtools_jtreg, \ + solaris_x64_5.10-product-c2-langtools_jtreg, \ + linux_i586_2.6-product-{c1|c2}-langtools_jtreg, \ + linux_x64_2.6-product-c2-langtools_jtreg, \ + ${jprt.my.windows.i586}-product-c1-langtools_jtreg, \ + windows_x64_5.2-product-c2-langtools_jtreg, \ + \ + solaris_sparc_5.10-product-c1-jdk_beans1, \ + solaris_sparcv9_5.10-product-c2-jdk_beans1, \ + solaris_i586_5.10-product-c1-jdk_beans1, \ + solaris_x64_5.10-product-c2-jdk_beans1, \ + linux_i586_2.6-product-{c1|c2}-jdk_beans1, \ + linux_x64_2.6-product-c2-jdk_beans1, \ + ${jprt.my.windows.i586}-product-c1-jdk_beans1, \ + windows_x64_5.2-product-c2-jdk_beans1, \ + \ + solaris_sparc_5.10-product-c1-jdk_io, \ + solaris_sparcv9_5.10-product-c2-jdk_io, \ + solaris_i586_5.10-product-c1-jdk_io, \ + solaris_x64_5.10-product-c2-jdk_io, \ + linux_i586_2.6-product-{c1|c2}-jdk_io, \ + linux_x64_2.6-product-c2-jdk_io, \ + ${jprt.my.windows.i586}-product-c1-jdk_io, \ + windows_x64_5.2-product-c2-jdk_io, \ + \ + solaris_sparc_5.10-product-c1-jdk_lang, \ + solaris_sparcv9_5.10-product-c2-jdk_lang, \ + solaris_i586_5.10-product-c1-jdk_lang, \ + solaris_x64_5.10-product-c2-jdk_lang, \ + linux_i586_2.6-product-{c1|c2}-jdk_lang, \ + linux_x64_2.6-product-c2-jdk_lang, \ + ${jprt.my.windows.i586}-product-c1-jdk_lang, \ + windows_x64_5.2-product-c2-jdk_lang, \ + \ + solaris_sparc_5.10-product-c1-jdk_math, \ + solaris_sparcv9_5.10-product-c2-jdk_math, \ + solaris_i586_5.10-product-c1-jdk_math, \ + solaris_x64_5.10-product-c2-jdk_math, \ + linux_i586_2.6-product-{c1|c2}-jdk_math, \ + linux_x64_2.6-product-c2-jdk_math, \ + ${jprt.my.windows.i586}-product-c1-jdk_math, \ + windows_x64_5.2-product-c2-jdk_math, \ + \ + solaris_sparc_5.10-product-c1-jdk_misc, \ + solaris_sparcv9_5.10-product-c2-jdk_misc, \ + solaris_i586_5.10-product-c1-jdk_misc, \ + solaris_x64_5.10-product-c2-jdk_misc, \ + linux_i586_2.6-product-{c1|c2}-jdk_misc, \ + linux_x64_2.6-product-c2-jdk_misc, \ + ${jprt.my.windows.i586}-product-c1-jdk_misc, \ + windows_x64_5.2-product-c2-jdk_misc, \ + \ + solaris_sparc_5.10-product-c1-jdk_net, \ + solaris_sparcv9_5.10-product-c2-jdk_net, \ + solaris_i586_5.10-product-c1-jdk_net, \ + solaris_x64_5.10-product-c2-jdk_net, \ + linux_i586_2.6-product-{c1|c2}-jdk_net, \ + linux_x64_2.6-product-c2-jdk_net, \ + ${jprt.my.windows.i586}-product-c1-jdk_net, \ + windows_x64_5.2-product-c2-jdk_net, \ + \ + solaris_sparc_5.10-product-c1-jdk_nio1, \ + solaris_sparcv9_5.10-product-c2-jdk_nio1, \ + solaris_i586_5.10-product-c1-jdk_nio1, \ + solaris_x64_5.10-product-c2-jdk_nio1, \ + linux_i586_2.6-product-{c1|c2}-jdk_nio1, \ + linux_x64_2.6-product-c2-jdk_nio1, \ + ${jprt.my.windows.i586}-product-c1-jdk_nio1, \ + windows_x64_5.2-product-c2-jdk_nio1, \ + \ + solaris_sparc_5.10-product-c1-jdk_nio2, \ + solaris_sparcv9_5.10-product-c2-jdk_nio2, \ + solaris_i586_5.10-product-c1-jdk_nio2, \ + solaris_x64_5.10-product-c2-jdk_nio2, \ + linux_i586_2.6-product-{c1|c2}-jdk_nio2, \ + linux_x64_2.6-product-c2-jdk_nio2, \ + ${jprt.my.windows.i586}-product-c1-jdk_nio2, \ + windows_x64_5.2-product-c2-jdk_nio2, \ + \ + solaris_sparc_5.10-product-c1-jdk_nio3, \ + solaris_sparcv9_5.10-product-c2-jdk_nio3, \ + solaris_i586_5.10-product-c1-jdk_nio3, \ + solaris_x64_5.10-product-c2-jdk_nio3, \ + linux_i586_2.6-product-{c1|c2}-jdk_nio3, \ + linux_x64_2.6-product-c2-jdk_nio3, \ + ${jprt.my.windows.i586}-product-c1-jdk_nio3, \ + windows_x64_5.2-product-c2-jdk_nio3, \ + \ + solaris_sparc_5.10-product-c1-jdk_security1, \ + solaris_sparcv9_5.10-product-c2-jdk_security1, \ + solaris_i586_5.10-product-c1-jdk_security1, \ + solaris_x64_5.10-product-c2-jdk_security1, \ + linux_i586_2.6-product-{c1|c2}-jdk_security1, \ + linux_x64_2.6-product-c2-jdk_security1, \ + ${jprt.my.windows.i586}-product-c1-jdk_security1, \ + windows_x64_5.2-product-c2-jdk_security1, \ + \ + solaris_sparc_5.10-product-c1-jdk_text, \ + solaris_sparcv9_5.10-product-c2-jdk_text, \ + solaris_i586_5.10-product-c1-jdk_text, \ + solaris_x64_5.10-product-c2-jdk_text, \ + linux_i586_2.6-product-{c1|c2}-jdk_text, \ + linux_x64_2.6-product-c2-jdk_text, \ + ${jprt.my.windows.i586}-product-c1-jdk_text, \ + windows_x64_5.2-product-c2-jdk_text, \ + \ + solaris_sparc_5.10-product-c1-jdk_tools1, \ + solaris_sparcv9_5.10-product-c2-jdk_tools1, \ + solaris_i586_5.10-product-c1-jdk_tools1, \ + solaris_x64_5.10-product-c2-jdk_tools1, \ + linux_i586_2.6-product-{c1|c2}-jdk_tools1, \ + linux_x64_2.6-product-c2-jdk_tools1, \ + ${jprt.my.windows.i586}-product-c1-jdk_tools1, \ + windows_x64_5.2-product-c2-jdk_tools1, \ + \ + solaris_sparc_5.10-product-c1-jdk_util, \ + solaris_sparcv9_5.10-product-c2-jdk_util, \ + solaris_i586_5.10-product-c1-jdk_util, \ + solaris_x64_5.10-product-c2-jdk_util, \ + linux_i586_2.6-product-{c1|c2}-jdk_util, \ + linux_x64_2.6-product-c2-jdk_util, \ + ${jprt.my.windows.i586}-product-c1-jdk_util, \ + windows_x64_5.2-product-c2-jdk_util -# Not Ready Yet: -# *-product-*-jdk_awt -# *-product-*-jdk_rmi -# *-product-*-jdk_swing +# All vm test targets (but still no fastdebug & limited c2 testing) +jprt.vm.all.test.targets= \ + \ + ${jprt.vm.default.test.targets}, \ + \ + solaris_sparc_5.10-product-c1-runThese, \ + solaris_sparcv9_5.10-product-c2-runThese, \ + solaris_i586_5.10-product-c1-runThese, \ + solaris_x64_5.10-product-c2-runThese, \ + linux_i586_2.6-product-{c1|c2}-runThese, \ + linux_x64_2.6-product-c2-runThese, \ + ${jprt.my.windows.i586}-product-c1-runThese, \ + windows_x64_5.2-product-c2-runThese, \ + \ + solaris_sparc_5.10-product-c1-jbb_default, \ + solaris_sparcv9_5.10-product-c2-jbb_default, \ + solaris_i586_5.10-product-c1-jbb_default, \ + solaris_x64_5.10-product-c2-jbb_default, \ + linux_i586_2.6-product-{c1|c2}-jbb_default, \ + linux_x64_2.6-product-c2-jbb_default, \ + ${jprt.my.windows.i586}-product-c1-jbb_default, \ + windows_x64_5.2-product-c2-jbb_default + +# All jdk test targets (but still no fastdebug & limited c2 testing) +jprt.make.rule.all.test.targets= \ + \ + ${jprt.make.rule.default.test.targets}, \ + \ + solaris_sparc_5.10-product-c1-jdk_awt, \ + solaris_sparcv9_5.10-product-c2-jdk_awt, \ + solaris_i586_5.10-product-c1-jdk_awt, \ + solaris_x64_5.10-product-c2-jdk_awt, \ + linux_i586_2.6-product-{c1|c2}-jdk_awt, \ + linux_x64_2.6-product-c2-jdk_awt, \ + ${jprt.my.windows.i586}-product-c1-jdk_awt, \ + windows_x64_5.2-product-c2-jdk_awt, \ + \ + solaris_sparc_5.10-product-c1-jdk_beans2, \ + solaris_sparcv9_5.10-product-c2-jdk_beans2, \ + solaris_i586_5.10-product-c1-jdk_beans2, \ + solaris_x64_5.10-product-c2-jdk_beans2, \ + linux_i586_2.6-product-{c1|c2}-jdk_beans2, \ + linux_x64_2.6-product-c2-jdk_beans2, \ + ${jprt.my.windows.i586}-product-c1-jdk_beans2, \ + windows_x64_5.2-product-c2-jdk_beans2, \ + \ + solaris_sparc_5.10-product-c1-jdk_beans3, \ + solaris_sparcv9_5.10-product-c2-jdk_beans3, \ + solaris_i586_5.10-product-c1-jdk_beans3, \ + solaris_x64_5.10-product-c2-jdk_beans3, \ + linux_i586_2.6-product-{c1|c2}-jdk_beans3, \ + linux_x64_2.6-product-c2-jdk_beans3, \ + ${jprt.my.windows.i586}-product-c1-jdk_beans3, \ + windows_x64_5.2-product-c2-jdk_beans3, \ + \ + solaris_sparc_5.10-product-c1-jdk_management1, \ + solaris_sparcv9_5.10-product-c2-jdk_management1, \ + solaris_i586_5.10-product-c1-jdk_management1, \ + solaris_x64_5.10-product-c2-jdk_management1, \ + linux_i586_2.6-product-{c1|c2}-jdk_management1, \ + linux_x64_2.6-product-c2-jdk_management1, \ + ${jprt.my.windows.i586}-product-c1-jdk_management1, \ + windows_x64_5.2-product-c2-jdk_management1, \ + \ + solaris_sparc_5.10-product-c1-jdk_management2, \ + solaris_sparcv9_5.10-product-c2-jdk_management2, \ + solaris_i586_5.10-product-c1-jdk_management2, \ + solaris_x64_5.10-product-c2-jdk_management2, \ + linux_i586_2.6-product-{c1|c2}-jdk_management2, \ + linux_x64_2.6-product-c2-jdk_management2, \ + ${jprt.my.windows.i586}-product-c1-jdk_management2, \ + windows_x64_5.2-product-c2-jdk_management2, \ + \ + solaris_sparc_5.10-product-c1-jdk_rmi, \ + solaris_sparcv9_5.10-product-c2-jdk_rmi, \ + solaris_i586_5.10-product-c1-jdk_rmi, \ + solaris_x64_5.10-product-c2-jdk_rmi, \ + linux_i586_2.6-product-{c1|c2}-jdk_rmi, \ + linux_x64_2.6-product-c2-jdk_rmi, \ + ${jprt.my.windows.i586}-product-c1-jdk_rmi, \ + windows_x64_5.2-product-c2-jdk_rmi, \ + \ + solaris_sparc_5.10-product-c1-jdk_security2, \ + solaris_sparcv9_5.10-product-c2-jdk_security2, \ + solaris_i586_5.10-product-c1-jdk_security2, \ + solaris_x64_5.10-product-c2-jdk_security2, \ + linux_i586_2.6-product-{c1|c2}-jdk_security2, \ + linux_x64_2.6-product-c2-jdk_security2, \ + ${jprt.my.windows.i586}-product-c1-jdk_security2, \ + windows_x64_5.2-product-c2-jdk_security2, \ + \ + solaris_sparc_5.10-product-c1-jdk_security3, \ + solaris_sparcv9_5.10-product-c2-jdk_security3, \ + solaris_i586_5.10-product-c1-jdk_security3, \ + solaris_x64_5.10-product-c2-jdk_security3, \ + linux_i586_2.6-product-{c1|c2}-jdk_security3, \ + linux_x64_2.6-product-c2-jdk_security3, \ + ${jprt.my.windows.i586}-product-c1-jdk_security3, \ + windows_x64_5.2-product-c2-jdk_security3, \ + \ + solaris_sparc_5.10-product-c1-jdk_swing, \ + solaris_sparcv9_5.10-product-c2-jdk_swing, \ + solaris_i586_5.10-product-c1-jdk_swing, \ + solaris_x64_5.10-product-c2-jdk_swing, \ + linux_i586_2.6-product-{c1|c2}-jdk_swing, \ + linux_x64_2.6-product-c2-jdk_swing, \ + ${jprt.my.windows.i586}-product-c1-jdk_swing, \ + windows_x64_5.2-product-c2-jdk_swing, \ + \ + solaris_sparc_5.10-product-c1-jdk_tools2, \ + solaris_sparcv9_5.10-product-c2-jdk_tools2, \ + solaris_i586_5.10-product-c1-jdk_tools2, \ + solaris_x64_5.10-product-c2-jdk_tools2, \ + linux_i586_2.6-product-{c1|c2}-jdk_tools2, \ + linux_x64_2.6-product-c2-jdk_tools2, \ + ${jprt.my.windows.i586}-product-c1-jdk_tools2, \ + windows_x64_5.2-product-c2-jdk_tools2 + +# Select list to use (allow for testset to be empty too) +jprt.make.rule..test.targets=${jprt.make.rule.default.test.targets} +jprt.make.rule.test.targets=${jprt.make.rule.${jprt.my.test.set}.test.targets} +jprt.vm..test.targets=${jprt.vm.default.test.targets} +jprt.vm.test.targets=${jprt.vm.${jprt.my.test.set}.test.targets} +jprt.test.targets=${jprt.vm.test.targets} # Directories to be excluded from the source bundles jprt.bundle.exclude.src.dirs=build dist webrev