Merge jdk8-b89

Mon, 06 May 2013 11:53:44 -0700

author
lana
date
Mon, 06 May 2013 11:53:44 -0700
changeset 1718
ec434cfd2752
parent 1703
adec2a5d510a
parent 1717
8e27e84de2e9
child 1719
e19283cd30a4
child 1730
c68834236058
child 1830
8074ccd57d89

Merge

make/Makefile-classic file | annotate | diff | comparison | revisions
     1.1 --- a/make/Makefile-classic	Thu May 02 13:35:55 2013 -0700
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,396 +0,0 @@
     1.4 -#
     1.5 -# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 -#
     1.8 -# This code is free software; you can redistribute it and/or modify it
     1.9 -# under the terms of the GNU General Public License version 2 only, as
    1.10 -# published by the Free Software Foundation.  Oracle designates this
    1.11 -# particular file as subject to the "Classpath" exception as provided
    1.12 -# by Oracle in the LICENSE file that accompanied this code.
    1.13 -#
    1.14 -# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 -# version 2 for more details (a copy is included in the LICENSE file that
    1.18 -# accompanied this code).
    1.19 -#
    1.20 -# You should have received a copy of the GNU General Public License version
    1.21 -# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 -#
    1.24 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 -# or visit www.oracle.com if you need additional information or have any
    1.26 -# questions.
    1.27 -#
    1.28 -
    1.29 -#
    1.30 -# Makefile for building the langtools workspace.
    1.31 -#
    1.32 -
    1.33 -#
    1.34 -# On Solaris, the standard 'make' utility will not work with these makefiles.
    1.35 -#    This little rule is only understood by Solaris make, and is harmless
    1.36 -#    when seen by the GNU make tool. If using Solaris make, this causes the
    1.37 -#    make command to fail.
    1.38 -#
    1.39 -SUN_MAKE_TEST:sh = @echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33
    1.40 -
    1.41 -#----- cancel implicit rules
    1.42 -
    1.43 -%: %.o
    1.44 -%: %.obj
    1.45 -%: %.dll
    1.46 -%: %.c
    1.47 -%: %.cc
    1.48 -%: %.C
    1.49 -%: %.p
    1.50 -%: %.f
    1.51 -%: %.s
    1.52 -%: %.F
    1.53 -%: %.r
    1.54 -%: %.S
    1.55 -%: %.mod
    1.56 -%: %.sh
    1.57 -%: %,v
    1.58 -%: RCS/%,v
    1.59 -
    1.60 -#----- imports
    1.61 -
    1.62 -ifdef ALT_BOOT_JAVA_HOME
    1.63 -  BOOT_JAVA_HOME = $(ALT_BOOT_JAVA_HOME)
    1.64 -else 
    1.65 -  ifdef ALT_BOOTDIR
    1.66 -    BOOT_JAVA_HOME = $(ALT_BOOTDIR)
    1.67 -  else
    1.68 -    BOOT_JAVA_HOME=/java/re/jdk/1.5.0/archive/fcs/binaries/solaris-sparc
    1.69 -  endif
    1.70 -endif
    1.71 -
    1.72 -BOOT_JAVA=$(BOOT_JAVA_HOME)/bin/java
    1.73 -BOOT_JAVAC=$(BOOT_JAVA_HOME)/bin/javac
    1.74 -BOOTJAR=$(BOOT_JAVA_HOME)/bin/jar
    1.75 -
    1.76 -ifdef ALT_TESTJAVA_HOME
    1.77 -  TESTJAVA_HOME = $(ALT_TESTJAVA_HOME)
    1.78 -else
    1.79 -  TESTJAVA_HOME=/java/re/jdk/1.6.0/archive/fcs/binaries/solaris-sparc
    1.80 -endif
    1.81 -
    1.82 -TESTJAVA=$(TESTJAVA_HOME)/bin/java
    1.83 -
    1.84 -ifdef ALT_FINDBUGS_HOME
    1.85 -  FINDBUGS_HOME = $(ALT_FINDBUGS_HOME)
    1.86 -else
    1.87 -  FINDBUGS_HOME = /java/devtools/share/findbugs/1.1.2-rc4
    1.88 -endif
    1.89 -
    1.90 -FINDBUGS = $(FINDBUGS_HOME)/bin/findbugs
    1.91 -
    1.92 -#----- commands
    1.93 -
    1.94 -CHMOD = chmod
    1.95 -CP = cp
    1.96 -ECHO = echo # FIXME
    1.97 -FIND = find
    1.98 -MKDIR = mkdir
    1.99 -SED = sed
   1.100 -ZIP = zip
   1.101 -
   1.102 -#-----  locations and deliverables
   1.103 -
   1.104 -TOPDIR = ..
   1.105 -SRC_BIN_DIR = $(TOPDIR)/src/share/bin
   1.106 -SRC_CLASSES_DIR = $(TOPDIR)/src/share/classes
   1.107 -
   1.108 -BUILD_DIR = $(TOPDIR)/build
   1.109 -
   1.110 -CLASSES_DIR = $(BUILD_DIR)/classes
   1.111 -GENSRC_DIR = $(BUILD_DIR)/gensrc
   1.112 -
   1.113 -DIST_DIR = $(TOPDIR)/dist
   1.114 -BIN_DIR = $(DIST_DIR)/bin
   1.115 -LIB_DIR = $(DIST_DIR)/lib
   1.116 -
   1.117 -JAVAC_JAR = $(LIB_DIR)/javac.jar
   1.118 -JAVADOC_JAR = $(LIB_DIR)/javadoc.jar
   1.119 -JAVAH_JAR = $(LIB_DIR)/javah.jar
   1.120 -JAVAP_JAR = $(LIB_DIR)/javap.jar
   1.121 -
   1.122 -CLASSES_JAR = $(DIST_DIR)/classes.jar
   1.123 -SRC_ZIP = $(DIST_DIR)/src.zip
   1.124 -
   1.125 -BUILDTOOLSRC_DIR = tools
   1.126 -BUILDTOOLCLASSES_DIR = $(BUILD_DIR)/toolclasses
   1.127 -
   1.128 -#-----
   1.129 -
   1.130 -ifndef JDK_MAJOR_VERSION
   1.131 -  JDK_MAJOR_VERSION = 1
   1.132 -endif
   1.133 -
   1.134 -ifndef JDK_MINOR_VERSION
   1.135 -  JDK_MINOR_VERSION = 7
   1.136 -endif
   1.137 -
   1.138 -ifndef JDK_MICRO_VERSION
   1.139 -  JDK_MICRO_VERSION = 0
   1.140 -endif
   1.141 -
   1.142 -ifndef JDK_VERSION
   1.143 -  JDK_VERSION = $(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
   1.144 -endif
   1.145 -
   1.146 -ifndef MILESTONE
   1.147 -  MILESTONE = internal
   1.148 -endif
   1.149 -
   1.150 -# RELEASE is JDK_VERSION and -MILESTONE if MILESTONE is set
   1.151 -ifneq ($(MILESTONE),fcs)
   1.152 -  RELEASE      = $(JDK_VERSION)-$(MILESTONE)$(BUILD_VARIANT_RELEASE)
   1.153 -else
   1.154 -  RELEASE      = $(JDK_VERSION)$(BUILD_VARIANT_RELEASE)
   1.155 -endif
   1.156 -
   1.157 -# FULL_VERSION is RELEASE and -BUILD_NUMBER if BUILD_NUMBER is set
   1.158 -ifdef BUILD_NUMBER
   1.159 -  FULL_VERSION = $(RELEASE)-$(BUILD_NUMBER)
   1.160 -else
   1.161 -  BUILD_NUMBER = b00
   1.162 -  USER_RELEASE_SUFFIX := $(shell echo $(USER)_`date '+%d_%b_%Y_%H_%M' | tr "A-Z" "a-z"`)
   1.163 -  FULL_VERSION = $(RELEASE)-$(USER_RELEASE_SUFFIX)-$(BUILD_NUMBER)
   1.164 -endif
   1.165 -
   1.166 -#----- useful macros
   1.167 -
   1.168 -TOOLS =  javac javadoc javah javap
   1.169 -
   1.170 -SOURCE_LEVEL = 5
   1.171 -BOOTSTRAP_TARGET_LEVEL = 5
   1.172 -TARGET_LEVEL = 6
   1.173 -
   1.174 -ifndef TARGET_JAVA
   1.175 -  TARGET_JAVA = java
   1.176 -endif
   1.177 -
   1.178 -NO_PROPRIETARY_API_WARNINGS = -XDignore.symbol.file=true
   1.179 -
   1.180 -SELF = $(lastword $(MAKEFILE_LIST))
   1.181 -
   1.182 -#-----
   1.183 -
   1.184 -# the default is to generate the following:
   1.185 -# dist/{bin,lib}: 
   1.186 -# 	lang tools compiled to run on the target JDK
   1.187 -
   1.188 -default:  
   1.189 -	$(MAKE) -f $(SELF) \
   1.190 -		MILESTONE=bootstrap \
   1.191 -		TARGET_LEVEL=$(BOOTSTRAP_TARGET_LEVEL) \
   1.192 -		TARGET_JAVA=$(BOOT_JAVA_HOME)/bin/java \
   1.193 -		GENSRC_DIR=$(BUILD_DIR)/bootstrap/gensrc \
   1.194 -		CLASSES_DIR=$(BUILD_DIR)/bootstrap/classes \
   1.195 -		BIN_DIR=$(BUILD_DIR)/bootstrap/bin \
   1.196 -		LIB_DIR=$(BUILD_DIR)/bootstrap/lib \
   1.197 -		$(BUILD_DIR)/bootstrap/lib/javac.jar \
   1.198 -		$(BUILD_DIR)/bootstrap/bin/javac
   1.199 -	$(MAKE) -f $(SELF) \
   1.200 -		BOOT_JAVAC=$(BUILD_DIR)/bootstrap/bin/javac \
   1.201 -		tools
   1.202 -
   1.203 -# for jdk, we generate the following:
   1.204 -# dist/bootstrap/{bin,lib}:
   1.205 -#	lang tools compiled to run on the boot JDK
   1.206 -# dist/lib/classes.jar:
   1.207 -#	lang tools recompiled to run on the target JDK,
   1.208 -#	ready for inclusion in rt.jar and tools.jar
   1.209 -# dist/lib/src.zip
   1.210 -#	.properties and .java files for classes in classes.jar,
   1.211 -#	ready for jdk src.zip 
   1.212 -
   1.213 -jdk:
   1.214 -	$(MAKE) -f $(SELF) \
   1.215 -		MILESTONE=bootstrap \
   1.216 -		TARGET_LEVEL=$(BOOTSTRAP_TARGET_LEVEL) \
   1.217 -		TARGET_JAVA=$(BOOT_JAVA_HOME)/bin/java \
   1.218 -		GENSRC_DIR=$(BUILD_DIR)/bootstrap/gensrc \
   1.219 -		CLASSES_DIR=$(BUILD_DIR)/bootstrap/classes \
   1.220 -		BIN_DIR=$(DIST_DIR)/bootstrap/bin \
   1.221 -		LIB_DIR=$(DIST_DIR)/bootstrap/lib \
   1.222 -		tools
   1.223 -	$(MAKE) -f $(SELF) \
   1.224 -		BOOT_JAVAC=$(DIST_DIR)/bootstrap/bin/javac \
   1.225 -		LIB_DIR=$(BUILD_DIR)/jdk/lib \
   1.226 -		$(DIST_DIR)/lib/classes.jar \
   1.227 -		$(DIST_DIR)/lib/src.zip
   1.228 -
   1.229 -tools: $(TOOLS:%=$(LIB_DIR)/%.jar) $(TOOLS:%=$(BIN_DIR)/%)
   1.230 -
   1.231 -clean:
   1.232 -	$(RM) -r $(BUILD_DIR)
   1.233 -
   1.234 -really-clean: clean
   1.235 -	$(RM) -r $(DIST_DIR)
   1.236 -
   1.237 -jprt_product_build \
   1.238 -jprt_debug_build \
   1.239 -jprt_fastdebug_build: lib
   1.240 -
   1.241 -#-----  javac
   1.242 -
   1.243 -JAVAC_DIRS = \
   1.244 -	javax/annotation/processing \
   1.245 -	javax/lang/model \
   1.246 -	javax/tools \
   1.247 -        jdk/ \
   1.248 -	com/sun/source \
   1.249 -	com/sun/tools/javac 
   1.250 -
   1.251 -JAVAC_RESOURCE_FILES = \
   1.252 -	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAC_DIRS)) -name SCCS -prune -o -name \*.properties -print )
   1.253 -
   1.254 -JAVAC_JAVA_FILES = \
   1.255 -	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAC_DIRS)) -name SCCS -prune -o -name \*.java -print ) \
   1.256 -	$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(JAVAC_RESOURCE_FILES)) \
   1.257 -	$(GENSRC_DIR)/com/sun/tools/javac/resources/version.java
   1.258 -
   1.259 -$(JAVAC_JAR): $(JAVAC_JAVA_FILES)
   1.260 -	$(MKDIR) -p $(CLASSES_DIR) $(@D)
   1.261 -	$(BOOT_JAVAC) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(NO_PROPRIETARY_API_WARNINGS) $(JAVAC_JAVA_FILES)
   1.262 -	( $(ECHO) Main-Class: com.sun.tools.javac.Main ) > $(BUILD_DIR)/javac.mf
   1.263 -	$(BOOTJAR) -cfm $@ $(BUILD_DIR)/javac.mf $(patsubst %,-C $(CLASSES_DIR) %, $(JAVAC_DIRS))
   1.264 -
   1.265 -#----- javadoc
   1.266 -
   1.267 -### FIXME -- javadoc has a couple of extra non-property resource files
   1.268 -### that need to be included
   1.269 -
   1.270 -JAVADOC_DIRS = \
   1.271 -	com/sun/javadoc \
   1.272 -	com/sun/tools/doclets \
   1.273 -	com/sun/tools/javadoc
   1.274 -
   1.275 -JAVADOC_RESOURCE_FILES = \
   1.276 -	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVADOC_DIRS)) -name SCCS -prune -o -name \*.properties -print )
   1.277 -
   1.278 -JAVADOC_JAVA_FILES = \
   1.279 -	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVADOC_DIRS)) -name SCCS -prune -o -name \*.java -print ) \
   1.280 -	$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(JAVADOC_RESOURCE_FILES))
   1.281 - 
   1.282 -$(JAVADOC_JAR): $(JAVADOC_JAVA_FILES) $(JAVAC_JAR)
   1.283 -	$(MKDIR) -p $(CLASSES_DIR) $(@D)
   1.284 -	$(BOOT_JAVAC) -sourcepath "" -classpath $(JAVAC_JAR) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(JAVADOC_JAVA_FILES)
   1.285 -	( $(ECHO) Main-Class: com.sun.tools.javadoc.Main ; $(ECHO) Class-Path: javac.jar ) > $(BUILD_DIR)/javadoc.mf
   1.286 -	$(BOOTJAR) -cfm $@ $(BUILD_DIR)/javadoc.mf $(patsubst %,-C $(CLASSES_DIR) %, $(JAVADOC_DIRS))
   1.287 -
   1.288 -#----- javah
   1.289 -
   1.290 -JAVAH_DIRS = \
   1.291 -	com/sun/tools/javah
   1.292 -
   1.293 -JAVAH_RESOURCE_FILES = \
   1.294 -	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAH_DIRS)) -name SCCS -prune -o -name \*.properties -print )
   1.295 -
   1.296 -JAVAH_JAVA_FILES = \
   1.297 -	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAH_DIRS)) -name SCCS -prune -o -name \*.java -print ) \
   1.298 -	$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(JAVAH_RESOURCE_FILES))
   1.299 - 
   1.300 -$(JAVAH_JAR): $(JAVAH_JAVA_FILES) $(JAVADOC_JAR)
   1.301 -	$(MKDIR) -p $(CLASSES_DIR) $(@D)
   1.302 -	$(BOOT_JAVAC) -sourcepath "" -classpath $(CLASSES_DIR) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(JAVAH_JAVA_FILES)
   1.303 -	( $(ECHO) Main-Class: com.sun.tools.javah.Main ; $(ECHO) Class-Path: javadoc.jar ) > $(BUILD_DIR)/javah.mf
   1.304 -	$(BOOTJAR) -cfm $@ $(BUILD_DIR)/javah.mf $(patsubst %,-C $(CLASSES_DIR) %, $(JAVAH_DIRS))
   1.305 -
   1.306 -#----- javap
   1.307 -
   1.308 -JAVAP_DIRS = \
   1.309 -	sun/tools/javap
   1.310 -
   1.311 -JAVAP_RESOURCE_FILES = \
   1.312 -	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAP_DIRS)) -name SCCS -prune -o -name \*.properties -print )
   1.313 -
   1.314 -JAVAP_JAVA_FILES = \
   1.315 -	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAP_DIRS)) -name SCCS -prune -o -name \*.java -print ) \
   1.316 -	$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(JAVAP_RESOURCE_FILES))
   1.317 - 
   1.318 -$(JAVAP_JAR): $(JAVAP_JAVA_FILES) \
   1.319 -		$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(JAVAP_RESOURCE_FILES))
   1.320 -	$(MKDIR) -p $(CLASSES_DIR)
   1.321 -	$(BOOT_JAVAC) -sourcepath "" -classpath $(CLASSES_DIR) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(JAVAP_JAVA_FILES)
   1.322 -	( $(ECHO) Main-Class: sun.tools.javap.Main ) > $(BUILD_DIR)/javap.mf
   1.323 -	$(BOOTJAR) -cfm $@ $(BUILD_DIR)/javap.mf $(patsubst %,-C $(CLASSES_DIR) %, $(JAVAP_DIRS))
   1.324 -
   1.325 -#-----
   1.326 -
   1.327 -build-tools: $(BUILDTOOLCLASSES_DIR)/CompileProperties/CompileProperties.class
   1.328 -
   1.329 -$(GENSRC_DIR)/%.java: $(SRC_CLASSES_DIR)/%.properties $(BUILDTOOLCLASSES_DIR)/CompileProperties/CompileProperties.class
   1.330 -	$(MKDIR) -p $(@D)
   1.331 -	$(BOOT_JAVA) -cp $(BUILDTOOLCLASSES_DIR)/CompileProperties CompileProperties $< $(patsubst $(CLASSES_DIR)/%.class,$(GENSRC_DIR)/%.java,$@)
   1.332 -
   1.333 -$(GENSRC_DIR)/%.java: $(GENSRC_DIR)/%.properties $(BUILDTOOLCLASSES_DIR)/CompileProperties/CompileProperties.class
   1.334 -	$(MKDIR) -p $(@D)
   1.335 -	$(BOOT_JAVA) -cp $(BUILDTOOLCLASSES_DIR)/CompileProperties CompileProperties $< $(patsubst $(CLASSES_DIR)/%.class,$(GENSRC_DIR)/%.java,$@)
   1.336 -
   1.337 -$(GENSRC_DIR)/%.properties: $(SRC_CLASSES_DIR)/%.properties-template
   1.338 -	$(MKDIR) -p $(@D)
   1.339 -	$(SED)  -e 's/$$(JDK_VERSION)/$(JDK_VERSION)/'  \
   1.340 -		-e 's/$$(FULL_VERSION)/$(FULL_VERSION)/' \
   1.341 -		-e 's/$$(RELEASE)/$(RELEASE)/' \
   1.342 -		< $< > $@
   1.343 -
   1.344 -$(BUILDTOOLCLASSES_DIR)/%.class : $(BUILDTOOLSRC_DIR)/%.java
   1.345 -	$(MKDIR) -p $(@D)
   1.346 -	$(BOOT_JAVAC) -d $(@D) $<
   1.347 -
   1.348 -#----- all classes
   1.349 -
   1.350 -$(DIST_DIR)/%/classes.jar: $(JAVAC_JAR) $(JAVADOC_JAR) $(JAVAH_JAR) $(JAVAP_JAR)
   1.351 -	$(MKDIR) -p $(@D)
   1.352 -	$(BOOTJAR) -cf $@ -C $(CLASSES_DIR) .
   1.353 -
   1.354 -#----- src.zip
   1.355 -
   1.356 -SRC_ZIP_FILES = $(shell $(FIND) $(SRC_CLASSES_DIR) \( -name SCCS -o -name \*-template \) -prune -o -type f -print )
   1.357 -
   1.358 -$(DIST_DIR)/%/src.zip: $(SRC_ZIP_FILES)
   1.359 -	abs_src_zip=`cd $(@D) ; pwd`/$(@F) ; \
   1.360 -	( cd $(SRC_CLASSES_DIR) ; $(FIND) . \( -name SCCS -o -name \*-template \) -prune -o -type f -print | $(ZIP) -q $$abs_src_zip -@ ) ; \
   1.361 -	( cd $(SRC_CLASSES_DIR) ; $(FIND) . -name SCCS -prune -o -name \*-template -print | $(SED) -e 's/-template//' ) | ( cd $(GENSRC_DIR) ; $(ZIP) -q $$abs_src_zip -@ ) 
   1.362 -
   1.363 -#----- bin files
   1.364 -
   1.365 -$(BIN_DIR)/%: $(SRC_BIN_DIR)/launcher.sh-template
   1.366 -	$(MKDIR) -p $(@D)
   1.367 -	$(SED) -e 's|#PROGRAM#|$(@F)|' -e 's|#TARGET_JAVA#|$(TARGET_JAVA)|' $< > $@
   1.368 -	$(CHMOD) +x $@
   1.369 -
   1.370 -#-----
   1.371 -
   1.372 -findbugs: $(BUILD_DIR)/findbugs.txt
   1.373 -
   1.374 -$(BUILD_DIR)/findbugs.txt: $(CLASSES_JAR)
   1.375 -	$(MKDIR) -p $(@D)
   1.376 -	$(FINDBUGS) -textui -javahome $(BOOT_JAVA_HOME) -high -emacs -outputFile $@ $<
   1.377 -
   1.378 -#-----
   1.379 -
   1.380 -quick-check: $(patsubst %, $(DIST_LIB_DIR)/%.jar, $(TOOLS))
   1.381 -	$(TESTJAVA) -jar $(JAVAC_JAR) -version
   1.382 -	- $(TESTJAVA) -jar $(JAVADOC_JAR) -version
   1.383 -	$(TESTJAVA) -jar $(JAVAH_JAR) -version
   1.384 -	- $(TESTJAVA) -jar $(JAVAP_JAR) -version
   1.385 -
   1.386 -#-----
   1.387 -
   1.388 -.PHONY: \
   1.389 -	all \
   1.390 -	build \
   1.391 -	build-tools \
   1.392 -	clean \
   1.393 -	default \
   1.394 -	findbugs \
   1.395 -	jprt_product_build \
   1.396 -	jprt_debug_build \
   1.397 -	jprt_fastdebug_build \
   1.398 -	tools
   1.399 -
     2.1 --- a/make/build.xml	Thu May 02 13:35:55 2013 -0700
     2.2 +++ b/make/build.xml	Mon May 06 11:53:44 2013 -0700
     2.3 @@ -717,6 +717,29 @@
     2.4      <target name="sjavac" depends="build-sjavac,jtreg-sjavac,findbugs-sjavac"/>
     2.5  
     2.6      <!--
     2.7 +    **** crules targets.
     2.8 +    -->
     2.9 +
    2.10 +    <target name="build-crules" depends="-def-compilecrules,-def-build-jar-with-services">
    2.11 +        <compilecrules/>
    2.12 +        <build-jar-with-services
    2.13 +                    name="crules"
    2.14 +                    includes="crules/* crules/resources/*"
    2.15 +                    classes.dir="${build.toolclasses.dir}"
    2.16 +                    lib.dir="${build.toolclasses.dir}"
    2.17 +                    jarmainclass=""
    2.18 +                    jarclasspath="crules.jar"
    2.19 +                    service.type="com.sun.source.util.Plugin"
    2.20 +                    service.provider="crules.MutableFieldsAnalyzer"/>
    2.21 +        <build-tool name="crules"/>
    2.22 +    </target>
    2.23 +
    2.24 +    <target name="check-coding-rules" depends="build-bootstrap-javac,-create-import-jdk-stubs,build-crules">
    2.25 +        <build-classes includes="${javac.includes}"
    2.26 +            plugin.options="-J-Xbootclasspath/a:${build.toolclasses.dir}/crules.jar -Xplugin:mutable_fields_analyzer" />
    2.27 +    </target>
    2.28 +
    2.29 +    <!--
    2.30      **** Create import JDK stubs.
    2.31      -->
    2.32  
    2.33 @@ -811,6 +834,31 @@
    2.34          </macrodef>
    2.35      </target>
    2.36  
    2.37 +    <target name="-def-build-jar-with-services">
    2.38 +        <macrodef name="build-jar-with-services">
    2.39 +            <attribute name="name"/>
    2.40 +            <attribute name="includes"/>
    2.41 +            <attribute name="classes.dir" default="${build.classes.dir}"/>
    2.42 +            <attribute name="lib.dir" default="${dist.lib.dir}"/>
    2.43 +            <attribute name="jarmainclass" default="com.sun.tools.@{name}.Main"/>
    2.44 +            <attribute name="jarclasspath" default=""/>
    2.45 +            <attribute name="service.type" default=""/>
    2.46 +            <attribute name="service.provider" default=""/>
    2.47 +            <sequential>
    2.48 +                <mkdir dir="${build.toolclasses.dir}"/>
    2.49 +                <jar destfile="@{lib.dir}/@{name}.jar"
    2.50 +                     basedir="@{classes.dir}"
    2.51 +                     includes="@{includes}">
    2.52 +                    <service type="@{service.type}" provider="@{service.provider}"/>
    2.53 +                    <manifest>
    2.54 +                        <attribute name="Main-Class" value="@{jarmainclass}"/>
    2.55 +                        <attribute name="Class-Path" value="@{jarclasspath}"/>
    2.56 +                    </manifest>
    2.57 +                </jar>
    2.58 +            </sequential>
    2.59 +        </macrodef>
    2.60 +    </target>
    2.61 +
    2.62      <target name="-def-build-classes" depends="-def-pcompile">
    2.63          <macrodef name="build-classes">
    2.64              <attribute name="includes"/>
    2.65 @@ -826,6 +874,7 @@
    2.66              <attribute name="target" default="${javac.target}"/>
    2.67              <attribute name="release" default="${release}"/>
    2.68              <attribute name="full.version" default="${full.version}"/>
    2.69 +            <attribute name="plugin.options" default=""/>
    2.70              <sequential>
    2.71                  <echo level="verbose" message="build-classes: excludes=@{excludes}"/>
    2.72                  <echo level="verbose" message="build-classes: bootclasspath.opt=@{bootclasspath.opt}"/>
    2.73 @@ -868,6 +917,7 @@
    2.74                      <compilerarg line="${javac.no.jdk.warnings}"/>
    2.75                      <compilerarg line="${javac.version.opt}"/>
    2.76                      <compilerarg line="${javac.lint.opts}"/>
    2.77 +                    <compilerarg line="@{plugin.options}"/>
    2.78                  </javac>
    2.79                  <copy todir="@{classes.dir}" includeemptydirs="false">
    2.80                      <fileset dir="${src.classes.dir}" includes="@{includes}" excludes="@{excludes}">
    2.81 @@ -935,6 +985,32 @@
    2.82                   classpath="${build.toolclasses.dir}/"/>
    2.83      </target>
    2.84  
    2.85 +    <target name="-def-compilecrules">
    2.86 +        <macrodef name="compilecrules">
    2.87 +            <sequential>
    2.88 +                <mkdir dir="${build.toolclasses.dir}"/>
    2.89 +                <javac fork="true"
    2.90 +                       source="${boot.javac.source}"
    2.91 +                       target="${boot.javac.target}"
    2.92 +                       executable="${boot.java.home}/bin/javac"
    2.93 +                       srcdir="${make.tools.dir}"
    2.94 +                       includes="crules/*"
    2.95 +                       destdir="${build.toolclasses.dir}/"
    2.96 +                       classpath="${ant.core.lib}"
    2.97 +                       bootclasspath="${boot.java.home}/jre/lib/rt.jar"
    2.98 +                       includeantruntime="false">
    2.99 +                    <compilerarg value="-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
   2.100 +                    <compilerarg line="${javac.lint.opts}"/>
   2.101 +                </javac>
   2.102 +                <copy todir="${build.toolclasses.dir}/" includeemptydirs="false">
   2.103 +                    <fileset dir="${make.tools.dir}">
   2.104 +                        <include name="**/*.properties"/>
   2.105 +                    </fileset>
   2.106 +                </copy>
   2.107 +            </sequential>
   2.108 +        </macrodef>
   2.109 +    </target>
   2.110 +
   2.111      <target name="-def-genstubs" depends="build-bootstrap-javac" if="require.import.jdk.stubs">
   2.112          <mkdir dir="${build.toolclasses.dir}"/>
   2.113          <javac fork="true"
     3.1 --- a/make/netbeans/langtools/nbproject/project.xml	Thu May 02 13:35:55 2013 -0700
     3.2 +++ b/make/netbeans/langtools/nbproject/project.xml	Mon May 06 11:53:44 2013 -0700
     3.3 @@ -1,6 +1,6 @@
     3.4  <?xml version="1.0" encoding="UTF-8"?>
     3.5  <!--
     3.6 - Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
     3.7 + Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
     3.8  
     3.9   Redistribution and use in source and binary forms, with or without
    3.10   modification, are permitted provided that the following conditions
    3.11 @@ -67,7 +67,7 @@
    3.12              </folders>
    3.13              <ide-actions>
    3.14                  <!--
    3.15 - Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
    3.16 + Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
    3.17  
    3.18   Redistribution and use in source and binary forms, with or without
    3.19   modification, are permitted provided that the following conditions
    3.20 @@ -96,7 +96,7 @@
    3.21   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    3.22   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    3.23  -->
    3.24 -                <!-- 
    3.25 +                <!--
    3.26   This file defines the standard actions accepted by langtools projects.
    3.27   It is normally included as an entity into a project's project.xml file.
    3.28  
    3.29 @@ -104,7 +104,7 @@
    3.30     - NetBeans: Setting Up Projects
    3.31       at http://www.netbeans.org/kb/55/using-netbeans/project_setup.html
    3.32     - NetBeans: Advanced Freeform Project Configuration
    3.33 -     at http://www.netbeans.org/kb/41/freeform-config.html 
    3.34 +     at http://www.netbeans.org/kb/41/freeform-config.html
    3.35  -->
    3.36                  <action name="build">
    3.37                      <target>build</target>
    3.38 @@ -144,7 +144,7 @@
    3.39                          </arity>
    3.40                      </context>
    3.41                  </action>
    3.42 -                <!-- 
    3.43 +                <!--
    3.44   Note: NetBeans does not appear to support context menu items
    3.45   on shell scripts :-(
    3.46  -->
    3.47 @@ -178,7 +178,7 @@
    3.48                          </arity>
    3.49                      </context>
    3.50                  </action>
    3.51 -                <!-- 
    3.52 +                <!--
    3.53   Note: NetBeans does not appear to support context menu items
    3.54   on shell scripts :-(
    3.55  -->
    3.56 @@ -239,10 +239,6 @@
    3.57                          <label>Build files</label>
    3.58                          <location>${root}/make</location>
    3.59                      </source-folder>
    3.60 -                    <source-folder style="packages">
    3.61 -                        <label>Source files</label>
    3.62 -                        <location>${root}/src/share/classes</location>
    3.63 -                    </source-folder>
    3.64                      <source-file>
    3.65                          <label>README</label>
    3.66                          <location>README</location>
    3.67 @@ -250,7 +246,7 @@
    3.68                  </items>
    3.69                  <context-menu>
    3.70                      <!--
    3.71 - Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
    3.72 + Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
    3.73  
    3.74   Redistribution and use in source and binary forms, with or without
    3.75   modification, are permitted provided that the following conditions
    3.76 @@ -279,7 +275,7 @@
    3.77   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    3.78   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    3.79  -->
    3.80 -                    <!-- 
    3.81 +                    <!--
    3.82   This file defines the actions that will appear on the project's context
    3.83   menu, in the Projects viewer.
    3.84   It is normally included as an entity into a project's project.xml file.
    3.85 @@ -288,7 +284,7 @@
    3.86     - NetBeans: Setting Up Projects
    3.87       at http://www.netbeans.org/kb/55/using-netbeans/project_setup.html
    3.88     - NetBeans: Advanced Freeform Project Configuration
    3.89 -     at http://www.netbeans.org/kb/41/freeform-config.html 
    3.90 +     at http://www.netbeans.org/kb/41/freeform-config.html
    3.91  -->
    3.92                      <ide-action name="select-tool"/>
    3.93                      <separator/>
    3.94 @@ -305,11 +301,11 @@
    3.95              </view>
    3.96              <subprojects/>
    3.97          </general-data>
    3.98 -        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
    3.99 +        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
   3.100              <compilation-unit>
   3.101                  <package-root>${root}/src/share/classes</package-root>
   3.102                  <built-to>${root}/build/classes</built-to>
   3.103 -                <source-level>1.5</source-level>
   3.104 +                <source-level>1.7</source-level>
   3.105              </compilation-unit>
   3.106          </java-data>
   3.107      </configuration>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/make/tools/crules/AbstractCodingRulesAnalyzer.java	Mon May 06 11:53:44 2013 -0700
     4.3 @@ -0,0 +1,117 @@
     4.4 +/*
     4.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.7 + *
     4.8 + * This code is free software; you can redistribute it and/or modify it
     4.9 + * under the terms of the GNU General Public License version 2 only, as
    4.10 + * published by the Free Software Foundation.
    4.11 + *
    4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    4.15 + * version 2 for more details (a copy is included in the LICENSE file that
    4.16 + * accompanied this code).
    4.17 + *
    4.18 + * You should have received a copy of the GNU General Public License version
    4.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    4.21 + *
    4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    4.23 + * or visit www.oracle.com if you need additional information or have any
    4.24 + * questions.
    4.25 + */
    4.26 +
    4.27 +package crules;
    4.28 +
    4.29 +import java.text.MessageFormat;
    4.30 +import java.util.Locale;
    4.31 +import java.util.ResourceBundle;
    4.32 +
    4.33 +import javax.lang.model.element.TypeElement;
    4.34 +import javax.tools.JavaFileObject;
    4.35 +
    4.36 +import com.sun.source.tree.Tree;
    4.37 +import com.sun.source.util.JavacTask;
    4.38 +import com.sun.source.util.Plugin;
    4.39 +import com.sun.source.util.TaskEvent;
    4.40 +import com.sun.source.util.TaskListener;
    4.41 +import com.sun.source.util.Trees;
    4.42 +import com.sun.tools.javac.api.BasicJavacTask;
    4.43 +import com.sun.tools.javac.tree.JCTree;
    4.44 +import com.sun.tools.javac.tree.TreeScanner;
    4.45 +import com.sun.tools.javac.util.Context;
    4.46 +import com.sun.tools.javac.util.Log;
    4.47 +
    4.48 +import static com.sun.source.util.TaskEvent.Kind;
    4.49 +
    4.50 +public abstract class AbstractCodingRulesAnalyzer implements Plugin {
    4.51 +
    4.52 +    protected Log log;
    4.53 +    protected Trees trees;
    4.54 +    protected TreeScanner treeVisitor;
    4.55 +    protected Kind eventKind;
    4.56 +    protected Messages messages;
    4.57 +
    4.58 +    public void init(JavacTask task, String... args) {
    4.59 +        BasicJavacTask impl = (BasicJavacTask)task;
    4.60 +        Context context = impl.getContext();
    4.61 +        log = Log.instance(context);
    4.62 +        trees = Trees.instance(task);
    4.63 +        messages = new Messages();
    4.64 +        task.addTaskListener(new PostAnalyzeTaskListener());
    4.65 +    }
    4.66 +
    4.67 +    public class PostAnalyzeTaskListener implements TaskListener {
    4.68 +
    4.69 +        @Override
    4.70 +        public void started(TaskEvent taskEvent) {}
    4.71 +
    4.72 +        @Override
    4.73 +        public void finished(TaskEvent taskEvent) {
    4.74 +            if (taskEvent.getKind().equals(eventKind)) {
    4.75 +                TypeElement typeElem = taskEvent.getTypeElement();
    4.76 +                Tree tree = trees.getTree(typeElem);
    4.77 +                if (tree != null) {
    4.78 +                    JavaFileObject prevSource = log.currentSourceFile();
    4.79 +                    try {
    4.80 +                        log.useSource(taskEvent.getCompilationUnit().getSourceFile());
    4.81 +                        treeVisitor.scan((JCTree)tree);
    4.82 +                    } finally {
    4.83 +                        log.useSource(prevSource);
    4.84 +                    }
    4.85 +                }
    4.86 +            }
    4.87 +        }
    4.88 +    }
    4.89 +
    4.90 +    class Messages {
    4.91 +        ResourceBundle bundle;
    4.92 +
    4.93 +        Messages() {
    4.94 +            String name = getClass().getPackage().getName() + ".resources.crules";
    4.95 +            bundle = ResourceBundle.getBundle(name, Locale.ENGLISH);
    4.96 +        }
    4.97 +
    4.98 +        public void error(JCTree tree, String code, Object... args) {
    4.99 +            String msg = (code == null) ? (String) args[0] : localize(code, args);
   4.100 +            log.error(tree, "proc.messager", msg.toString());
   4.101 +        }
   4.102 +
   4.103 +        private String localize(String code, Object... args) {
   4.104 +            String msg = bundle.getString(code);
   4.105 +            if (msg == null) {
   4.106 +                StringBuilder sb = new StringBuilder();
   4.107 +                sb.append("message file broken: code=").append(code);
   4.108 +                if (args.length > 0) {
   4.109 +                    sb.append(" arguments={0}");
   4.110 +                    for (int i = 1; i < args.length; i++) {
   4.111 +                        sb.append(", {").append(i).append("}");
   4.112 +                    }
   4.113 +                }
   4.114 +                msg = sb.toString();
   4.115 +            }
   4.116 +            return MessageFormat.format(msg, args);
   4.117 +        }
   4.118 +    }
   4.119 +
   4.120 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/make/tools/crules/MutableFieldsAnalyzer.java	Mon May 06 11:53:44 2013 -0700
     5.3 @@ -0,0 +1,118 @@
     5.4 +/*
     5.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 + *
     5.8 + * This code is free software; you can redistribute it and/or modify it
     5.9 + * under the terms of the GNU General Public License version 2 only, as
    5.10 + * published by the Free Software Foundation.
    5.11 + *
    5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.15 + * version 2 for more details (a copy is included in the LICENSE file that
    5.16 + * accompanied this code).
    5.17 + *
    5.18 + * You should have received a copy of the GNU General Public License version
    5.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.21 + *
    5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.23 + * or visit www.oracle.com if you need additional information or have any
    5.24 + * questions.
    5.25 + */
    5.26 +
    5.27 +package crules;
    5.28 +
    5.29 +import java.util.Arrays;
    5.30 +import java.util.HashMap;
    5.31 +import java.util.List;
    5.32 +import java.util.Map;
    5.33 +
    5.34 +import com.sun.tools.javac.code.Kinds;
    5.35 +import com.sun.tools.javac.tree.TreeScanner;
    5.36 +
    5.37 +import static com.sun.source.util.TaskEvent.Kind;
    5.38 +import static com.sun.tools.javac.code.Flags.*;
    5.39 +import static com.sun.tools.javac.tree.JCTree.JCVariableDecl;
    5.40 +
    5.41 +public class MutableFieldsAnalyzer extends AbstractCodingRulesAnalyzer {
    5.42 +
    5.43 +    public MutableFieldsAnalyzer() {
    5.44 +        treeVisitor = new MutableFieldsVisitor();
    5.45 +        eventKind = Kind.ANALYZE;
    5.46 +    }
    5.47 +
    5.48 +    public String getName() {
    5.49 +        return "mutable_fields_analyzer";
    5.50 +    }
    5.51 +
    5.52 +    private boolean ignoreField(String className, String field) {
    5.53 +        List<String> currentFieldsToIgnore =
    5.54 +                classFieldsToIgnoreMap.get(className);
    5.55 +        if (currentFieldsToIgnore != null) {
    5.56 +            for (String fieldToIgnore : currentFieldsToIgnore) {
    5.57 +                if (field.equals(fieldToIgnore)) {
    5.58 +                    return true;
    5.59 +                }
    5.60 +            }
    5.61 +        }
    5.62 +        return false;
    5.63 +    }
    5.64 +
    5.65 +    class MutableFieldsVisitor extends TreeScanner {
    5.66 +
    5.67 +        @Override
    5.68 +        public void visitVarDef(JCVariableDecl tree) {
    5.69 +            boolean isJavacPack = tree.sym.outermostClass().fullname.toString()
    5.70 +                    .contains(packageToCheck);
    5.71 +            if (isJavacPack &&
    5.72 +                (tree.sym.flags() & SYNTHETIC) == 0 &&
    5.73 +                tree.sym.owner.kind == Kinds.TYP) {
    5.74 +                if (!ignoreField(tree.sym.owner.flatName().toString(),
    5.75 +                        tree.getName().toString())) {
    5.76 +                    boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0;
    5.77 +                    boolean nonFinalStaticEnumField =
    5.78 +                            (tree.sym.flags() & (ENUM | FINAL)) == 0;
    5.79 +                    boolean nonFinalStaticField =
    5.80 +                            (tree.sym.flags() & STATIC) != 0 &&
    5.81 +                            (tree.sym.flags() & FINAL) == 0;
    5.82 +                    if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
    5.83 +                        messages.error(tree, "crules.err.var.must.be.final", tree);
    5.84 +                    }
    5.85 +                }
    5.86 +            }
    5.87 +            super.visitVarDef(tree);
    5.88 +        }
    5.89 +
    5.90 +    }
    5.91 +
    5.92 +    private static final String packageToCheck = "com.sun.tools.javac";
    5.93 +
    5.94 +    private static final Map<String, List<String>> classFieldsToIgnoreMap =
    5.95 +                new HashMap<String, List<String>>();
    5.96 +
    5.97 +    static {
    5.98 +        classFieldsToIgnoreMap.
    5.99 +                put("com.sun.tools.javac.util.JCDiagnostic",
   5.100 +                    Arrays.asList("fragmentFormatter"));
   5.101 +        classFieldsToIgnoreMap.
   5.102 +                put("com.sun.tools.javac.util.JavacMessages",
   5.103 +                    Arrays.asList("defaultBundle", "defaultMessages"));
   5.104 +        classFieldsToIgnoreMap.
   5.105 +                put("com.sun.tools.javac.file.ZipFileIndexCache",
   5.106 +                    Arrays.asList("sharedInstance"));
   5.107 +        classFieldsToIgnoreMap.
   5.108 +                put("com.sun.tools.javac.main.JavaCompiler",
   5.109 +                    Arrays.asList("versionRB"));
   5.110 +        classFieldsToIgnoreMap.
   5.111 +                put("com.sun.tools.javac.code.Type",
   5.112 +                    Arrays.asList("moreInfo"));
   5.113 +        classFieldsToIgnoreMap.
   5.114 +                put("com.sun.tools.javac.util.SharedNameTable",
   5.115 +                    Arrays.asList("freelist"));
   5.116 +        classFieldsToIgnoreMap.
   5.117 +                put("com.sun.tools.javac.util.Log",
   5.118 +                    Arrays.asList("useRawMessages"));
   5.119 +    }
   5.120 +
   5.121 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/make/tools/crules/resources/crules.properties	Mon May 06 11:53:44 2013 -0700
     6.3 @@ -0,0 +1,28 @@
     6.4 +#
     6.5 +# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     6.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 +#
     6.8 +# This code is free software; you can redistribute it and/or modify it
     6.9 +# under the terms of the GNU General Public License version 2 only, as
    6.10 +# published by the Free Software Foundation.  Oracle designates this
    6.11 +# particular file as subject to the "Classpath" exception as provided
    6.12 +# by Oracle in the LICENSE file that accompanied this code.
    6.13 +#
    6.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
    6.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.17 +# version 2 for more details (a copy is included in the LICENSE file that
    6.18 +# accompanied this code).
    6.19 +#
    6.20 +# You should have received a copy of the GNU General Public License version
    6.21 +# 2 along with this work; if not, write to the Free Software Foundation,
    6.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.23 +#
    6.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.25 +# or visit www.oracle.com if you need additional information or have any
    6.26 +# questions.
    6.27 +#
    6.28 +
    6.29 +# 0: symbol
    6.30 +crules.err.var.must.be.final=\
    6.31 +    Static variable {0} must be final
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/share/classes/com/sun/source/util/DocSourcePositions.java	Mon May 06 11:53:44 2013 -0700
     7.3 @@ -0,0 +1,98 @@
     7.4 +/*
     7.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 + *
     7.8 + * This code is free software; you can redistribute it and/or modify it
     7.9 + * under the terms of the GNU General Public License version 2 only, as
    7.10 + * published by the Free Software Foundation.  Oracle designates this
    7.11 + * particular file as subject to the "Classpath" exception as provided
    7.12 + * by Oracle in the LICENSE file that accompanied this code.
    7.13 + *
    7.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    7.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.17 + * version 2 for more details (a copy is included in the LICENSE file that
    7.18 + * accompanied this code).
    7.19 + *
    7.20 + * You should have received a copy of the GNU General Public License version
    7.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    7.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.23 + *
    7.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    7.25 + * or visit www.oracle.com if you need additional information or have any
    7.26 + * questions.
    7.27 + */
    7.28 +
    7.29 +package com.sun.source.util;
    7.30 +
    7.31 +import com.sun.source.doctree.DocCommentTree;
    7.32 +import com.sun.source.doctree.DocTree;
    7.33 +import com.sun.source.tree.CompilationUnitTree;
    7.34 +
    7.35 +/**
    7.36 + * Provides methods to obtain the position of a DocTree within a javadoc comment.
    7.37 + * A position is defined as a simple character offset from the start of a
    7.38 + * CompilationUnit where the first character is at offset 0.
    7.39 + *
    7.40 + * @since 1.8
    7.41 + */
    7.42 +@jdk.Supported
    7.43 +public interface DocSourcePositions extends SourcePositions {
    7.44 +
    7.45 +    /**
    7.46 +     * Gets the starting position of the tree within the comment within the file.  If tree is not found within
    7.47 +     * file, or if the starting position is not available,
    7.48 +     * return {@link javax.tools.Diagnostic#NOPOS}.
    7.49 +     * The given tree should be under the given comment tree, and the given documentation
    7.50 +     * comment tree should be returned from a {@link DocTrees#getDocCommentTree(com.sun.source.util.TreePath) }
    7.51 +     * for a tree under the given file.
    7.52 +     * The returned position must be at the start of the yield of this tree, that
    7.53 +     * is for any sub-tree of this tree, the following must hold:
    7.54 +     *
    7.55 +     * <p>
    7.56 +     * {@code tree.getStartPosition() <= subtree.getStartPosition()} or <br>
    7.57 +     * {@code tree.getStartPosition() == NOPOS} or <br>
    7.58 +     * {@code subtree.getStartPosition() == NOPOS}
    7.59 +     * </p>
    7.60 +     *
    7.61 +     * @param file CompilationUnit in which to find tree.
    7.62 +     * @param comment the comment tree that encloses the tree for which the
    7.63 +     *                position is being sought
    7.64 +     * @param tree tree for which a position is sought.
    7.65 +     * @return the start position of tree.
    7.66 +     */
    7.67 +    long getStartPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree);
    7.68 +
    7.69 +    /**
    7.70 +     * Gets the ending position of the tree within the comment within the file.  If tree is not found within
    7.71 +     * file, or if the ending position is not available,
    7.72 +     * return {@link javax.tools.Diagnostic#NOPOS}.
    7.73 +     * The given tree should be under the given comment tree, and the given documentation
    7.74 +     * comment tree should be returned from a {@link DocTrees#getDocCommentTree(com.sun.source.util.TreePath) }
    7.75 +     * for a tree under the given file.
    7.76 +     * The returned position must be at the end of the yield of this tree,
    7.77 +     * that is for any sub-tree of this tree, the following must hold:
    7.78 +     *
    7.79 +     * <p>
    7.80 +     * {@code tree.getEndPosition() >= subtree.getEndPosition()} or <br>
    7.81 +     * {@code tree.getEndPosition() == NOPOS} or <br>
    7.82 +     * {@code subtree.getEndPosition() == NOPOS}
    7.83 +     * </p>
    7.84 +     *
    7.85 +     * In addition, the following must hold:
    7.86 +     *
    7.87 +     * <p>
    7.88 +     * {@code tree.getStartPosition() <= tree.getEndPosition()}  or <br>
    7.89 +     * {@code tree.getStartPosition() == NOPOS} or <br>
    7.90 +     * {@code tree.getEndPosition() == NOPOS}
    7.91 +     * </p>
    7.92 +     *
    7.93 +     * @param file CompilationUnit in which to find tree.
    7.94 +     * @param comment the comment tree that encloses the tree for which the
    7.95 +     *                position is being sought
    7.96 +     * @param tree tree for which a position is sought.
    7.97 +     * @return the start position of tree.
    7.98 +     */
    7.99 +    long getEndPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree);
   7.100 +
   7.101 +}
     8.1 --- a/src/share/classes/com/sun/source/util/DocTrees.java	Thu May 02 13:35:55 2013 -0700
     8.2 +++ b/src/share/classes/com/sun/source/util/DocTrees.java	Mon May 06 11:53:44 2013 -0700
     8.3 @@ -72,6 +72,8 @@
     8.4       */
     8.5      public abstract Element getElement(TreePath path, ReferenceTree reference);
     8.6  
     8.7 +    public abstract DocSourcePositions getSourcePositions();
     8.8 +
     8.9      /**
    8.10       * Prints a message of the specified kind at the location of the
    8.11       * tree within the provided compilation unit
     9.1 --- a/src/share/classes/com/sun/source/util/SourcePositions.java	Thu May 02 13:35:55 2013 -0700
     9.2 +++ b/src/share/classes/com/sun/source/util/SourcePositions.java	Mon May 06 11:53:44 2013 -0700
     9.3 @@ -59,7 +59,7 @@
     9.4  
     9.5      /**
     9.6       * Gets the ending position of tree within file.  If tree is not found within
     9.7 -     * file, or if the starting position is not available,
     9.8 +     * file, or if the ending position is not available,
     9.9       * return {@link javax.tools.Diagnostic#NOPOS}.
    9.10       * The returned position must be at the end of the yield of this tree,
    9.11       * that is for any sub-tree of this tree, the following must hold:
    10.1 --- a/src/share/classes/com/sun/tools/classfile/Dependencies.java	Thu May 02 13:35:55 2013 -0700
    10.2 +++ b/src/share/classes/com/sun/tools/classfile/Dependencies.java	Mon May 06 11:53:44 2013 -0700
    10.3 @@ -315,7 +315,7 @@
    10.4      static class SimpleLocation implements Location {
    10.5          public SimpleLocation(String name) {
    10.6              this.name = name;
    10.7 -            this.className = name.replace('/', '.').replace('$', '.');
    10.8 +            this.className = name.replace('/', '.');
    10.9          }
   10.10  
   10.11          public String getName() {
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/share/classes/com/sun/tools/classfile/ReferenceFinder.java	Mon May 06 11:53:44 2013 -0700
    11.3 @@ -0,0 +1,240 @@
    11.4 +/*
    11.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 + *
    11.8 + * This code is free software; you can redistribute it and/or modify it
    11.9 + * under the terms of the GNU General Public License version 2 only, as
   11.10 + * published by the Free Software Foundation.  Oracle designates this
   11.11 + * particular file as subject to the "Classpath" exception as provided
   11.12 + * by Oracle in the LICENSE file that accompanied this code.
   11.13 + *
   11.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   11.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.17 + * version 2 for more details (a copy is included in the LICENSE file that
   11.18 + * accompanied this code).
   11.19 + *
   11.20 + * You should have received a copy of the GNU General Public License version
   11.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   11.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.23 + *
   11.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.25 + * or visit www.oracle.com if you need additional information or have any
   11.26 + * questions.
   11.27 + */
   11.28 +
   11.29 +package com.sun.tools.classfile;
   11.30 +
   11.31 +import java.util.ArrayList;
   11.32 +import java.util.HashSet;
   11.33 +import java.util.List;
   11.34 +import java.util.Objects;
   11.35 +import java.util.Set;
   11.36 +import com.sun.tools.classfile.Instruction.TypeKind;
   11.37 +import static com.sun.tools.classfile.ConstantPool.*;
   11.38 +
   11.39 +/**
   11.40 + * A utility class to find where in a ClassFile references
   11.41 + * a {@link CONSTANT_Methodref_info method},
   11.42 + * a {@link CONSTANT_InterfaceMethodref_info interface method,
   11.43 + * or a {@link CONSTANT_Fieldref_info field}.
   11.44 + */
   11.45 +public final class ReferenceFinder {
   11.46 +    /**
   11.47 +     * Filter for ReferenceFinder of what constant pool entries for reference lookup.
   11.48 +     */
   11.49 +    public interface Filter {
   11.50 +        /**
   11.51 +         * Decides if the given CPRefInfo entry should be accepted or filtered.
   11.52 +         *
   11.53 +         * @param cpool  ConstantPool of the ClassFile being parsed
   11.54 +         * @param cpref  constant pool entry representing a reference to
   11.55 +         *               a fields method, and interface method.
   11.56 +         * @return {@code true} if accepted; otherwise {@code false}
   11.57 +         */
   11.58 +        boolean accept(ConstantPool cpool, CPRefInfo cpref);
   11.59 +    }
   11.60 +
   11.61 +    /**
   11.62 +     * Visitor of individual method of a ClassFile that references the
   11.63 +     * accepted field, method, or interface method references.
   11.64 +     */
   11.65 +    public interface Visitor {
   11.66 +        /**
   11.67 +         * Invoked for a method containing one or more accepted CPRefInfo entries
   11.68 +         *
   11.69 +         * @param cf      ClassFile
   11.70 +         * @param method  Method that does the references the accepted references
   11.71 +         * @param refs    Accepted constant pool method/field reference
   11.72 +         */
   11.73 +        void visit(ClassFile cf, Method method, List<CPRefInfo> refConstantPool);
   11.74 +    }
   11.75 +
   11.76 +    private final Filter filter;
   11.77 +    private final Visitor visitor;
   11.78 +
   11.79 +    /**
   11.80 +     * Constructor.
   11.81 +     */
   11.82 +    public ReferenceFinder(Filter filter, Visitor visitor) {
   11.83 +        this.filter = Objects.requireNonNull(filter);
   11.84 +        this.visitor = Objects.requireNonNull(visitor);
   11.85 +    }
   11.86 +
   11.87 +    /**
   11.88 +     * Parses a given ClassFile and invoke the visitor if there is any reference
   11.89 +     * to the constant pool entries referencing field, method, or
   11.90 +     * interface method that are accepted. This method will return
   11.91 +     * {@code true} if there is one or more accepted constant pool entries
   11.92 +     * to lookup; otherwise, it will return {@code false}.
   11.93 +     *
   11.94 +     * @param  cf  ClassFile
   11.95 +     * @return {@code true} if the given class file is processed to lookup
   11.96 +     *         references
   11.97 +     * @throws ConstantPoolException if an error of the constant pool
   11.98 +     */
   11.99 +    public boolean parse(ClassFile cf) throws ConstantPoolException {
  11.100 +        List<Integer> cprefs = new ArrayList<Integer>();
  11.101 +        int index = 1;
  11.102 +        for (ConstantPool.CPInfo cpInfo : cf.constant_pool.entries()) {
  11.103 +            if (cpInfo.accept(cpVisitor, cf.constant_pool)) {
  11.104 +                cprefs.add(index);
  11.105 +            }
  11.106 +            index += cpInfo.size();
  11.107 +        }
  11.108 +
  11.109 +        if (cprefs.isEmpty()) {
  11.110 +            return false;
  11.111 +        }
  11.112 +
  11.113 +        for (Method m : cf.methods) {
  11.114 +            Set<Integer> ids = new HashSet<Integer>();
  11.115 +            Code_attribute c_attr = (Code_attribute) m.attributes.get(Attribute.Code);
  11.116 +            if (c_attr != null) {
  11.117 +                for (Instruction instr : c_attr.getInstructions()) {
  11.118 +                    int idx = instr.accept(codeVisitor, cprefs);
  11.119 +                    if (idx > 0) {
  11.120 +                        ids.add(idx);
  11.121 +                    }
  11.122 +                }
  11.123 +            }
  11.124 +            if (ids.size() > 0) {
  11.125 +                List<CPRefInfo> refInfos = new ArrayList<CPRefInfo>(ids.size());
  11.126 +                for (int id : ids) {
  11.127 +                    refInfos.add(CPRefInfo.class.cast(cf.constant_pool.get(id)));
  11.128 +                }
  11.129 +                visitor.visit(cf, m, refInfos);
  11.130 +            }
  11.131 +        }
  11.132 +        return true;
  11.133 +    }
  11.134 +
  11.135 +    private ConstantPool.Visitor<Boolean,ConstantPool> cpVisitor =
  11.136 +            new ConstantPool.Visitor<Boolean,ConstantPool>()
  11.137 +    {
  11.138 +        public Boolean visitClass(CONSTANT_Class_info info, ConstantPool cpool) {
  11.139 +            return false;
  11.140 +        }
  11.141 +
  11.142 +        public Boolean visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, ConstantPool cpool) {
  11.143 +            return filter.accept(cpool, info);
  11.144 +        }
  11.145 +
  11.146 +        public Boolean visitMethodref(CONSTANT_Methodref_info info, ConstantPool cpool) {
  11.147 +            return filter.accept(cpool, info);
  11.148 +        }
  11.149 +
  11.150 +        public Boolean visitFieldref(CONSTANT_Fieldref_info info, ConstantPool cpool) {
  11.151 +            return filter.accept(cpool, info);
  11.152 +        }
  11.153 +
  11.154 +        public Boolean visitDouble(CONSTANT_Double_info info, ConstantPool cpool) {
  11.155 +            return false;
  11.156 +        }
  11.157 +
  11.158 +        public Boolean visitFloat(CONSTANT_Float_info info, ConstantPool cpool) {
  11.159 +            return false;
  11.160 +        }
  11.161 +
  11.162 +        public Boolean visitInteger(CONSTANT_Integer_info info, ConstantPool cpool) {
  11.163 +            return false;
  11.164 +        }
  11.165 +
  11.166 +        public Boolean visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, ConstantPool cpool) {
  11.167 +            return false;
  11.168 +        }
  11.169 +
  11.170 +        public Boolean visitLong(CONSTANT_Long_info info, ConstantPool cpool) {
  11.171 +            return false;
  11.172 +        }
  11.173 +
  11.174 +        public Boolean visitNameAndType(CONSTANT_NameAndType_info info, ConstantPool cpool) {
  11.175 +            return false;
  11.176 +        }
  11.177 +
  11.178 +        public Boolean visitMethodHandle(CONSTANT_MethodHandle_info info, ConstantPool cpool) {
  11.179 +            return false;
  11.180 +        }
  11.181 +
  11.182 +        public Boolean visitMethodType(CONSTANT_MethodType_info info, ConstantPool cpool) {
  11.183 +            return false;
  11.184 +        }
  11.185 +
  11.186 +        public Boolean visitString(CONSTANT_String_info info, ConstantPool cpool) {
  11.187 +            return false;
  11.188 +        }
  11.189 +
  11.190 +        public Boolean visitUtf8(CONSTANT_Utf8_info info, ConstantPool cpool) {
  11.191 +            return false;
  11.192 +        }
  11.193 +    };
  11.194 +
  11.195 +    private Instruction.KindVisitor<Integer, List<Integer>> codeVisitor =
  11.196 +            new Instruction.KindVisitor<Integer, List<Integer>>()
  11.197 +    {
  11.198 +        public Integer visitNoOperands(Instruction instr, List<Integer> p) {
  11.199 +            return 0;
  11.200 +        }
  11.201 +
  11.202 +        public Integer visitArrayType(Instruction instr, TypeKind kind, List<Integer> p) {
  11.203 +            return 0;
  11.204 +        }
  11.205 +
  11.206 +        public Integer visitBranch(Instruction instr, int offset, List<Integer> p) {
  11.207 +            return 0;
  11.208 +        }
  11.209 +
  11.210 +        public Integer visitConstantPoolRef(Instruction instr, int index, List<Integer> p) {
  11.211 +            return p.contains(index) ? index : 0;
  11.212 +        }
  11.213 +
  11.214 +        public Integer visitConstantPoolRefAndValue(Instruction instr, int index, int value, List<Integer> p) {
  11.215 +            return p.contains(index) ? index : 0;
  11.216 +        }
  11.217 +
  11.218 +        public Integer visitLocal(Instruction instr, int index, List<Integer> p) {
  11.219 +            return 0;
  11.220 +        }
  11.221 +
  11.222 +        public Integer visitLocalAndValue(Instruction instr, int index, int value, List<Integer> p) {
  11.223 +            return 0;
  11.224 +        }
  11.225 +
  11.226 +        public Integer visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets, List<Integer> p) {
  11.227 +            return 0;
  11.228 +        }
  11.229 +
  11.230 +        public Integer visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets, List<Integer> p) {
  11.231 +            return 0;
  11.232 +        }
  11.233 +
  11.234 +        public Integer visitValue(Instruction instr, int value, List<Integer> p) {
  11.235 +            return 0;
  11.236 +        }
  11.237 +
  11.238 +        public Integer visitUnknown(Instruction instr, List<Integer> p) {
  11.239 +            return 0;
  11.240 +        }
  11.241 +    };
  11.242 +}
  11.243 +
    12.1 --- a/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Thu May 02 13:35:55 2013 -0700
    12.2 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Mon May 06 11:53:44 2013 -0700
    12.3 @@ -1,5 +1,5 @@
    12.4  /*
    12.5 - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    12.6 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
    12.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.8   *
    12.9   * This code is free software; you can redistribute it and/or modify it
   12.10 @@ -43,14 +43,16 @@
   12.11  import javax.tools.JavaFileObject;
   12.12  
   12.13  import com.sun.source.doctree.DocCommentTree;
   12.14 +import com.sun.source.doctree.DocTree;
   12.15  import com.sun.source.doctree.ReferenceTree;
   12.16  import com.sun.source.tree.CatchTree;
   12.17  import com.sun.source.tree.CompilationUnitTree;
   12.18  import com.sun.source.tree.Scope;
   12.19  import com.sun.source.tree.Tree;
   12.20 +import com.sun.source.util.DocSourcePositions;
   12.21 +import com.sun.source.util.DocTreeScanner;
   12.22  import com.sun.source.util.DocTrees;
   12.23  import com.sun.source.util.JavacTask;
   12.24 -import com.sun.source.util.SourcePositions;
   12.25  import com.sun.source.util.TreePath;
   12.26  import com.sun.tools.javac.code.Flags;
   12.27  import com.sun.tools.javac.code.Kinds;
   12.28 @@ -76,8 +78,14 @@
   12.29  import com.sun.tools.javac.model.JavacElements;
   12.30  import com.sun.tools.javac.processing.JavacProcessingEnvironment;
   12.31  import com.sun.tools.javac.tree.DCTree;
   12.32 +import com.sun.tools.javac.tree.DCTree.DCBlockTag;
   12.33  import com.sun.tools.javac.tree.DCTree.DCDocComment;
   12.34 +import com.sun.tools.javac.tree.DCTree.DCEndPosTree;
   12.35 +import com.sun.tools.javac.tree.DCTree.DCErroneous;
   12.36 +import com.sun.tools.javac.tree.DCTree.DCIdentifier;
   12.37 +import com.sun.tools.javac.tree.DCTree.DCParam;
   12.38  import com.sun.tools.javac.tree.DCTree.DCReference;
   12.39 +import com.sun.tools.javac.tree.DCTree.DCText;
   12.40  import com.sun.tools.javac.tree.EndPosTable;
   12.41  import com.sun.tools.javac.tree.JCTree;
   12.42  import com.sun.tools.javac.tree.JCTree.*;
   12.43 @@ -94,6 +102,7 @@
   12.44  import com.sun.tools.javac.util.Name;
   12.45  import com.sun.tools.javac.util.Names;
   12.46  import com.sun.tools.javac.util.Pair;
   12.47 +import com.sun.tools.javac.util.Position;
   12.48  import static com.sun.tools.javac.code.TypeTag.*;
   12.49  
   12.50  /**
   12.51 @@ -166,8 +175,8 @@
   12.52              javacTaskImpl = (JavacTaskImpl) t;
   12.53      }
   12.54  
   12.55 -    public SourcePositions getSourcePositions() {
   12.56 -        return new SourcePositions() {
   12.57 +    public DocSourcePositions getSourcePositions() {
   12.58 +        return new DocSourcePositions() {
   12.59                  public long getStartPosition(CompilationUnitTree file, Tree tree) {
   12.60                      return TreeInfo.getStartPos((JCTree) tree);
   12.61                  }
   12.62 @@ -176,9 +185,80 @@
   12.63                      EndPosTable endPosTable = ((JCCompilationUnit) file).endPositions;
   12.64                      return TreeInfo.getEndPos((JCTree) tree, endPosTable);
   12.65                  }
   12.66 +
   12.67 +                public long getStartPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree) {
   12.68 +                    return ((DCTree) tree).getSourcePosition((DCDocComment) comment);
   12.69 +                }
   12.70 +                @SuppressWarnings("fallthrough")
   12.71 +                public long getEndPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree) {
   12.72 +                    DCDocComment dcComment = (DCDocComment) comment;
   12.73 +                    if (tree instanceof DCEndPosTree) {
   12.74 +                        int endPos = ((DCEndPosTree) tree).getEndPos(dcComment);
   12.75 +
   12.76 +                        if (endPos != Position.NOPOS) {
   12.77 +                            return endPos;
   12.78 +                        }
   12.79 +                    }
   12.80 +                    int correction = 0;
   12.81 +                    switch (tree.getKind()) {
   12.82 +                        case TEXT:
   12.83 +                            DCText text = (DCText) tree;
   12.84 +
   12.85 +                            return dcComment.comment.getSourcePos(text.pos + text.text.length());
   12.86 +                        case ERRONEOUS:
   12.87 +                            DCErroneous err = (DCErroneous) tree;
   12.88 +
   12.89 +                            return dcComment.comment.getSourcePos(err.pos + err.body.length());
   12.90 +                        case IDENTIFIER:
   12.91 +                            DCIdentifier ident = (DCIdentifier) tree;
   12.92 +
   12.93 +                            return dcComment.comment.getSourcePos(ident.pos + (ident.name != names.error ? ident.name.length() : 0));
   12.94 +                        case PARAM:
   12.95 +                            DCParam param = (DCParam) tree;
   12.96 +
   12.97 +                            if (param.isTypeParameter && param.getDescription().isEmpty()) {
   12.98 +                                correction = 1;
   12.99 +                            }
  12.100 +                        case AUTHOR: case DEPRECATED: case RETURN: case SEE:
  12.101 +                        case SERIAL: case SERIAL_DATA: case SERIAL_FIELD: case SINCE:
  12.102 +                        case THROWS: case UNKNOWN_BLOCK_TAG: case VERSION: {
  12.103 +                            DocTree last = getLastChild(tree);
  12.104 +
  12.105 +                            if (last != null) {
  12.106 +                                return getEndPosition(file, comment, last) + correction;
  12.107 +                            }
  12.108 +
  12.109 +                            DCBlockTag block = (DCBlockTag) tree;
  12.110 +
  12.111 +                            return dcComment.comment.getSourcePos(block.pos + block.getTagName().length() + 1);
  12.112 +                        }
  12.113 +                        default:
  12.114 +                            DocTree last = getLastChild(tree);
  12.115 +
  12.116 +                            if (last != null) {
  12.117 +                                return getEndPosition(file, comment, last);
  12.118 +                            }
  12.119 +                            break;
  12.120 +                    }
  12.121 +
  12.122 +                    return Position.NOPOS;
  12.123 +                }
  12.124              };
  12.125      }
  12.126  
  12.127 +    private DocTree getLastChild(DocTree tree) {
  12.128 +        final DocTree[] last = new DocTree[] {null};
  12.129 +
  12.130 +        tree.accept(new DocTreeScanner<Void, Void>() {
  12.131 +            @Override public Void scan(DocTree node, Void p) {
  12.132 +                if (node != null) last[0] = node;
  12.133 +                return null;
  12.134 +            }
  12.135 +        }, null);
  12.136 +
  12.137 +        return last[0];
  12.138 +    }
  12.139 +
  12.140      public JCClassDecl getTree(TypeElement element) {
  12.141          return (JCClassDecl) getTree((Element) element);
  12.142      }
    13.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu May 02 13:35:55 2013 -0700
    13.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Mon May 06 11:53:44 2013 -0700
    13.3 @@ -465,19 +465,12 @@
    13.4       * This is the implementation for {@code
    13.5       * javax.lang.model.element.Element.getAnnotationMirrors()}.
    13.6       */
    13.7 -    public final List<? extends AnnotationMirror> getAnnotationMirrors() {
    13.8 +    @Override
    13.9 +    public List<Attribute.Compound> getAnnotationMirrors() {
   13.10          return getRawAttributes();
   13.11      }
   13.12  
   13.13      /**
   13.14 -     * TODO: Should there be a {@code
   13.15 -     * javax.lang.model.element.Element.getTypeAnnotationMirrors()}.
   13.16 -     */
   13.17 -    public final List<Attribute.TypeCompound> getTypeAnnotationMirrors() {
   13.18 -        return getRawTypeAttributes();
   13.19 -    }
   13.20 -
   13.21 -    /**
   13.22       * @deprecated this method should never be used by javac internally.
   13.23       */
   13.24      @Deprecated
   13.25 @@ -657,6 +650,24 @@
   13.26          }
   13.27  
   13.28          @Override
   13.29 +        public List<Attribute.Compound> getAnnotationMirrors() {
   13.30 +            return onlyTypeVariableAnnotations(owner.getRawTypeAttributes());
   13.31 +        }
   13.32 +
   13.33 +        private List<Attribute.Compound> onlyTypeVariableAnnotations(
   13.34 +                List<Attribute.TypeCompound> candidates) {
   13.35 +            // Declaration annotations on TypeParameters are stored in type attributes
   13.36 +            List<Attribute.Compound> res = List.nil();
   13.37 +            for (Attribute.TypeCompound a : candidates) {
   13.38 +                if (a.position.type == TargetType.CLASS_TYPE_PARAMETER ||
   13.39 +                    a.position.type == TargetType.METHOD_TYPE_PARAMETER)
   13.40 +                    res = res.prepend(a);
   13.41 +            }
   13.42 +
   13.43 +            return res = res.reverse();
   13.44 +        }
   13.45 +
   13.46 +        @Override
   13.47          public <R, P> R accept(ElementVisitor<R, P> v, P p) {
   13.48              return v.visitTypeParameter(this, p);
   13.49          }
    14.1 --- a/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Thu May 02 13:35:55 2013 -0700
    14.2 +++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Mon May 06 11:53:44 2013 -0700
    14.3 @@ -206,7 +206,7 @@
    14.4                      sym.getKind() == ElementKind.EXCEPTION_PARAMETER) {
    14.5                  // Make sure all type annotations from the symbol are also
    14.6                  // on the owner.
    14.7 -                sym.owner.annotations.appendUniqueTypes(sym.getTypeAnnotationMirrors());
    14.8 +                sym.owner.annotations.appendUniqueTypes(sym.getRawTypeAttributes());
    14.9              }
   14.10          }
   14.11  
    15.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu May 02 13:35:55 2013 -0700
    15.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon May 06 11:53:44 2013 -0700
    15.3 @@ -1078,7 +1078,8 @@
    15.4                  mask = MethodFlags;
    15.5              }
    15.6              // Imply STRICTFP if owner has STRICTFP set.
    15.7 -            if (((flags|implicit) & Flags.ABSTRACT) == 0)
    15.8 +            if (((flags|implicit) & Flags.ABSTRACT) == 0 ||
    15.9 +                ((flags) & Flags.DEFAULT) != 0)
   15.10                  implicit |= sym.owner.flags_field & STRICTFP;
   15.11              break;
   15.12          case TYP:
    16.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java	Thu May 02 13:35:55 2013 -0700
    16.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java	Mon May 06 11:53:44 2013 -0700
    16.3 @@ -35,7 +35,6 @@
    16.4  import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    16.5  
    16.6  import com.sun.tools.javac.code.Symbol.*;
    16.7 -import com.sun.tools.javac.comp.Resolve;
    16.8  import com.sun.tools.javac.tree.JCTree.*;
    16.9  
   16.10  import static com.sun.tools.javac.code.Flags.*;
   16.11 @@ -277,6 +276,15 @@
   16.12      }
   16.13  
   16.14      /**
   16.15 +     * Utility method to reset several Bits instances.
   16.16 +     */
   16.17 +    private void resetBits(Bits... bits) {
   16.18 +        for (Bits b : bits) {
   16.19 +            b.reset();
   16.20 +        }
   16.21 +    }
   16.22 +
   16.23 +    /**
   16.24       * Base visitor class for all visitors implementing dataflow analysis logic.
   16.25       * This class define the shared logic for handling jumps (break/continue statements).
   16.26       */
   16.27 @@ -1294,11 +1302,11 @@
   16.28  
   16.29          /** The set of definitely assigned variables.
   16.30           */
   16.31 -        Bits inits;
   16.32 +        final Bits inits;
   16.33  
   16.34          /** The set of definitely unassigned variables.
   16.35           */
   16.36 -        Bits uninits;
   16.37 +        final Bits uninits;
   16.38  
   16.39          /** The set of variables that are definitely unassigned everywhere
   16.40           *  in current try block. This variable is maintained lazily; it is
   16.41 @@ -1308,15 +1316,15 @@
   16.42           *  anywhere in current try block, intersect uninitsTry and
   16.43           *  uninits.
   16.44           */
   16.45 -        Bits uninitsTry;
   16.46 +        final Bits uninitsTry;
   16.47  
   16.48          /** When analyzing a condition, inits and uninits are null.
   16.49           *  Instead we have:
   16.50           */
   16.51 -        Bits initsWhenTrue;
   16.52 -        Bits initsWhenFalse;
   16.53 -        Bits uninitsWhenTrue;
   16.54 -        Bits uninitsWhenFalse;
   16.55 +        final Bits initsWhenTrue;
   16.56 +        final Bits initsWhenFalse;
   16.57 +        final Bits uninitsWhenTrue;
   16.58 +        final Bits uninitsWhenFalse;
   16.59  
   16.60          /** A mapping from addresses to variable symbols.
   16.61           */
   16.62 @@ -1348,15 +1356,25 @@
   16.63          /** The starting position of the analysed tree */
   16.64          int startPos;
   16.65  
   16.66 +        AssignAnalyzer() {
   16.67 +            inits = new Bits();
   16.68 +            uninits = new Bits();
   16.69 +            uninitsTry = new Bits();
   16.70 +            initsWhenTrue = new Bits(true);
   16.71 +            initsWhenFalse = new Bits(true);
   16.72 +            uninitsWhenTrue = new Bits(true);
   16.73 +            uninitsWhenFalse = new Bits(true);
   16.74 +        }
   16.75 +
   16.76          class AssignPendingExit extends BaseAnalyzer.PendingExit {
   16.77  
   16.78 -            Bits exit_inits;
   16.79 -            Bits exit_uninits;
   16.80 +            final Bits exit_inits = new Bits(true);
   16.81 +            final Bits exit_uninits = new Bits(true);
   16.82  
   16.83 -            AssignPendingExit(JCTree tree, Bits inits, Bits uninits) {
   16.84 +            AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) {
   16.85                  super(tree);
   16.86 -                this.exit_inits = inits.dup();
   16.87 -                this.exit_uninits = uninits.dup();
   16.88 +                this.exit_inits.assign(inits);
   16.89 +                this.exit_uninits.assign(uninits);
   16.90              }
   16.91  
   16.92              void resolveJump() {
   16.93 @@ -1476,19 +1494,20 @@
   16.94          /** Split (duplicate) inits/uninits into WhenTrue/WhenFalse sets
   16.95           */
   16.96          void split(boolean setToNull) {
   16.97 -            initsWhenFalse = inits.dup();
   16.98 -            uninitsWhenFalse = uninits.dup();
   16.99 -            initsWhenTrue = inits;
  16.100 -            uninitsWhenTrue = uninits;
  16.101 -            if (setToNull)
  16.102 -                inits = uninits = null;
  16.103 +            initsWhenFalse.assign(inits);
  16.104 +            uninitsWhenFalse.assign(uninits);
  16.105 +            initsWhenTrue.assign(inits);
  16.106 +            uninitsWhenTrue.assign(uninits);
  16.107 +            if (setToNull) {
  16.108 +                resetBits(inits, uninits);
  16.109 +            }
  16.110          }
  16.111  
  16.112          /** Merge (intersect) inits/uninits from WhenTrue/WhenFalse sets.
  16.113           */
  16.114          void merge() {
  16.115 -            inits = initsWhenFalse.andSet(initsWhenTrue);
  16.116 -            uninits = uninitsWhenFalse.andSet(uninitsWhenTrue);
  16.117 +            inits.assign(initsWhenFalse.andSet(initsWhenTrue));
  16.118 +            uninits.assign(uninitsWhenFalse.andSet(uninitsWhenTrue));
  16.119          }
  16.120  
  16.121      /* ************************************************************************
  16.122 @@ -1501,7 +1520,7 @@
  16.123          void scanExpr(JCTree tree) {
  16.124              if (tree != null) {
  16.125                  scan(tree);
  16.126 -                if (inits == null) merge();
  16.127 +                if (inits.isReset()) merge();
  16.128              }
  16.129          }
  16.130  
  16.131 @@ -1518,28 +1537,29 @@
  16.132           */
  16.133          void scanCond(JCTree tree) {
  16.134              if (tree.type.isFalse()) {
  16.135 -                if (inits == null) merge();
  16.136 -                initsWhenTrue = inits.dup();
  16.137 +                if (inits.isReset()) merge();
  16.138 +                initsWhenTrue.assign(inits);
  16.139                  initsWhenTrue.inclRange(firstadr, nextadr);
  16.140 -                uninitsWhenTrue = uninits.dup();
  16.141 +                uninitsWhenTrue.assign(uninits);
  16.142                  uninitsWhenTrue.inclRange(firstadr, nextadr);
  16.143 -                initsWhenFalse = inits;
  16.144 -                uninitsWhenFalse = uninits;
  16.145 +                initsWhenFalse.assign(inits);
  16.146 +                uninitsWhenFalse.assign(uninits);
  16.147              } else if (tree.type.isTrue()) {
  16.148 -                if (inits == null) merge();
  16.149 -                initsWhenFalse = inits.dup();
  16.150 +                if (inits.isReset()) merge();
  16.151 +                initsWhenFalse.assign(inits);
  16.152                  initsWhenFalse.inclRange(firstadr, nextadr);
  16.153 -                uninitsWhenFalse = uninits.dup();
  16.154 +                uninitsWhenFalse.assign(uninits);
  16.155                  uninitsWhenFalse.inclRange(firstadr, nextadr);
  16.156 -                initsWhenTrue = inits;
  16.157 -                uninitsWhenTrue = uninits;
  16.158 +                initsWhenTrue.assign(inits);
  16.159 +                uninitsWhenTrue.assign(uninits);
  16.160              } else {
  16.161                  scan(tree);
  16.162 -                if (inits != null)
  16.163 +                if (!inits.isReset())
  16.164                      split(tree.type != syms.unknownType);
  16.165              }
  16.166 -            if (tree.type != syms.unknownType)
  16.167 -                inits = uninits = null;
  16.168 +            if (tree.type != syms.unknownType) {
  16.169 +                resetBits(inits, uninits);
  16.170 +            }
  16.171          }
  16.172  
  16.173          /* ------------ Visitor methods for various sorts of trees -------------*/
  16.174 @@ -1619,8 +1639,8 @@
  16.175          public void visitMethodDef(JCMethodDecl tree) {
  16.176              if (tree.body == null) return;
  16.177  
  16.178 -            Bits initsPrev = inits.dup();
  16.179 -            Bits uninitsPrev = uninits.dup();
  16.180 +            final Bits initsPrev = new Bits(inits);
  16.181 +            final Bits uninitsPrev = new Bits(uninits);
  16.182              int nextadrPrev = nextadr;
  16.183              int firstadrPrev = firstadr;
  16.184              int returnadrPrev = returnadr;
  16.185 @@ -1658,14 +1678,14 @@
  16.186                      exits = exits.tail;
  16.187                      Assert.check(exit.tree.hasTag(RETURN), exit.tree);
  16.188                      if (isInitialConstructor) {
  16.189 -                        inits = exit.exit_inits;
  16.190 +                        inits.assign(exit.exit_inits);
  16.191                          for (int i = firstadr; i < nextadr; i++)
  16.192                              checkInit(exit.tree.pos(), vars[i]);
  16.193                      }
  16.194                  }
  16.195              } finally {
  16.196 -                inits = initsPrev;
  16.197 -                uninits = uninitsPrev;
  16.198 +                inits.assign(initsPrev);
  16.199 +                uninits.assign(uninitsPrev);
  16.200                  nextadr = nextadrPrev;
  16.201                  firstadr = firstadrPrev;
  16.202                  returnadr = returnadrPrev;
  16.203 @@ -1698,31 +1718,31 @@
  16.204              ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
  16.205              FlowKind prevFlowKind = flowKind;
  16.206              flowKind = FlowKind.NORMAL;
  16.207 -            Bits initsSkip = null;
  16.208 -            Bits uninitsSkip = null;
  16.209 +            final Bits initsSkip = new Bits(true);
  16.210 +            final Bits uninitsSkip = new Bits(true);
  16.211              pendingExits = new ListBuffer<AssignPendingExit>();
  16.212              int prevErrors = log.nerrors;
  16.213              do {
  16.214 -                Bits uninitsEntry = uninits.dup();
  16.215 +                final Bits uninitsEntry = new Bits(uninits);
  16.216                  uninitsEntry.excludeFrom(nextadr);
  16.217                  scan(tree.body);
  16.218                  resolveContinues(tree);
  16.219                  scanCond(tree.cond);
  16.220                  if (!flowKind.isFinal()) {
  16.221 -                    initsSkip = initsWhenFalse;
  16.222 -                    uninitsSkip = uninitsWhenFalse;
  16.223 +                    initsSkip.assign(initsWhenFalse);
  16.224 +                    uninitsSkip.assign(uninitsWhenFalse);
  16.225                  }
  16.226                  if (log.nerrors !=  prevErrors ||
  16.227                      flowKind.isFinal() ||
  16.228 -                    uninitsEntry.dup().diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
  16.229 +                    new Bits(uninitsEntry).diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
  16.230                      break;
  16.231 -                inits = initsWhenTrue;
  16.232 -                uninits = uninitsEntry.andSet(uninitsWhenTrue);
  16.233 +                inits.assign(initsWhenTrue);
  16.234 +                uninits.assign(uninitsEntry.andSet(uninitsWhenTrue));
  16.235                  flowKind = FlowKind.SPECULATIVE_LOOP;
  16.236              } while (true);
  16.237              flowKind = prevFlowKind;
  16.238 -            inits = initsSkip;
  16.239 -            uninits = uninitsSkip;
  16.240 +            inits.assign(initsSkip);
  16.241 +            uninits.assign(uninitsSkip);
  16.242              resolveBreaks(tree, prevPendingExits);
  16.243          }
  16.244  
  16.245 @@ -1730,34 +1750,34 @@
  16.246              ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
  16.247              FlowKind prevFlowKind = flowKind;
  16.248              flowKind = FlowKind.NORMAL;
  16.249 -            Bits initsSkip = null;
  16.250 -            Bits uninitsSkip = null;
  16.251 +            final Bits initsSkip = new Bits(true);
  16.252 +            final Bits uninitsSkip = new Bits(true);
  16.253              pendingExits = new ListBuffer<AssignPendingExit>();
  16.254              int prevErrors = log.nerrors;
  16.255 -            Bits uninitsEntry = uninits.dup();
  16.256 +            final Bits uninitsEntry = new Bits(uninits);
  16.257              uninitsEntry.excludeFrom(nextadr);
  16.258              do {
  16.259                  scanCond(tree.cond);
  16.260                  if (!flowKind.isFinal()) {
  16.261 -                    initsSkip = initsWhenFalse;
  16.262 -                    uninitsSkip = uninitsWhenFalse;
  16.263 +                    initsSkip.assign(initsWhenFalse) ;
  16.264 +                    uninitsSkip.assign(uninitsWhenFalse);
  16.265                  }
  16.266 -                inits = initsWhenTrue;
  16.267 -                uninits = uninitsWhenTrue;
  16.268 +                inits.assign(initsWhenTrue);
  16.269 +                uninits.assign(uninitsWhenTrue);
  16.270                  scan(tree.body);
  16.271                  resolveContinues(tree);
  16.272                  if (log.nerrors != prevErrors ||
  16.273                      flowKind.isFinal() ||
  16.274 -                    uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
  16.275 +                    new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1)
  16.276                      break;
  16.277 -                uninits = uninitsEntry.andSet(uninits);
  16.278 +                uninits.assign(uninitsEntry.andSet(uninits));
  16.279                  flowKind = FlowKind.SPECULATIVE_LOOP;
  16.280              } while (true);
  16.281              flowKind = prevFlowKind;
  16.282              //a variable is DA/DU after the while statement, if it's DA/DU assuming the
  16.283              //branch is not taken AND if it's DA/DU before any break statement
  16.284 -            inits = initsSkip;
  16.285 -            uninits = uninitsSkip;
  16.286 +            inits.assign(initsSkip);
  16.287 +            uninits.assign(uninitsSkip);
  16.288              resolveBreaks(tree, prevPendingExits);
  16.289          }
  16.290  
  16.291 @@ -1767,25 +1787,25 @@
  16.292              flowKind = FlowKind.NORMAL;
  16.293              int nextadrPrev = nextadr;
  16.294              scan(tree.init);
  16.295 -            Bits initsSkip = null;
  16.296 -            Bits uninitsSkip = null;
  16.297 +            final Bits initsSkip = new Bits(true);
  16.298 +            final Bits uninitsSkip = new Bits(true);
  16.299              pendingExits = new ListBuffer<AssignPendingExit>();
  16.300              int prevErrors = log.nerrors;
  16.301              do {
  16.302 -                Bits uninitsEntry = uninits.dup();
  16.303 +                final Bits uninitsEntry = new Bits(uninits);
  16.304                  uninitsEntry.excludeFrom(nextadr);
  16.305                  if (tree.cond != null) {
  16.306                      scanCond(tree.cond);
  16.307                      if (!flowKind.isFinal()) {
  16.308 -                        initsSkip = initsWhenFalse;
  16.309 -                        uninitsSkip = uninitsWhenFalse;
  16.310 +                        initsSkip.assign(initsWhenFalse);
  16.311 +                        uninitsSkip.assign(uninitsWhenFalse);
  16.312                      }
  16.313 -                    inits = initsWhenTrue;
  16.314 -                    uninits = uninitsWhenTrue;
  16.315 +                    inits.assign(initsWhenTrue);
  16.316 +                    uninits.assign(uninitsWhenTrue);
  16.317                  } else if (!flowKind.isFinal()) {
  16.318 -                    initsSkip = inits.dup();
  16.319 +                    initsSkip.assign(inits);
  16.320                      initsSkip.inclRange(firstadr, nextadr);
  16.321 -                    uninitsSkip = uninits.dup();
  16.322 +                    uninitsSkip.assign(uninits);
  16.323                      uninitsSkip.inclRange(firstadr, nextadr);
  16.324                  }
  16.325                  scan(tree.body);
  16.326 @@ -1793,16 +1813,16 @@
  16.327                  scan(tree.step);
  16.328                  if (log.nerrors != prevErrors ||
  16.329                      flowKind.isFinal() ||
  16.330 -                    uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
  16.331 +                    new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1)
  16.332                      break;
  16.333 -                uninits = uninitsEntry.andSet(uninits);
  16.334 +                uninits.assign(uninitsEntry.andSet(uninits));
  16.335                  flowKind = FlowKind.SPECULATIVE_LOOP;
  16.336              } while (true);
  16.337              flowKind = prevFlowKind;
  16.338              //a variable is DA/DU after a for loop, if it's DA/DU assuming the
  16.339              //branch is not taken AND if it's DA/DU before any break statement
  16.340 -            inits = initsSkip;
  16.341 -            uninits = uninitsSkip;
  16.342 +            inits.assign(initsSkip);
  16.343 +            uninits.assign(uninitsSkip);
  16.344              resolveBreaks(tree, prevPendingExits);
  16.345              nextadr = nextadrPrev;
  16.346          }
  16.347 @@ -1815,27 +1835,27 @@
  16.348              flowKind = FlowKind.NORMAL;
  16.349              int nextadrPrev = nextadr;
  16.350              scan(tree.expr);
  16.351 -            Bits initsStart = inits.dup();
  16.352 -            Bits uninitsStart = uninits.dup();
  16.353 +            final Bits initsStart = new Bits(inits);
  16.354 +            final Bits uninitsStart = new Bits(uninits);
  16.355  
  16.356              letInit(tree.pos(), tree.var.sym);
  16.357              pendingExits = new ListBuffer<AssignPendingExit>();
  16.358              int prevErrors = log.nerrors;
  16.359              do {
  16.360 -                Bits uninitsEntry = uninits.dup();
  16.361 +                final Bits uninitsEntry = new Bits(uninits);
  16.362                  uninitsEntry.excludeFrom(nextadr);
  16.363                  scan(tree.body);
  16.364                  resolveContinues(tree);
  16.365                  if (log.nerrors != prevErrors ||
  16.366                      flowKind.isFinal() ||
  16.367 -                    uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
  16.368 +                    new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1)
  16.369                      break;
  16.370 -                uninits = uninitsEntry.andSet(uninits);
  16.371 +                uninits.assign(uninitsEntry.andSet(uninits));
  16.372                  flowKind = FlowKind.SPECULATIVE_LOOP;
  16.373              } while (true);
  16.374              flowKind = prevFlowKind;
  16.375 -            inits = initsStart;
  16.376 -            uninits = uninitsStart.andSet(uninits);
  16.377 +            inits.assign(initsStart);
  16.378 +            uninits.assign(uninitsStart.andSet(uninits));
  16.379              resolveBreaks(tree, prevPendingExits);
  16.380              nextadr = nextadrPrev;
  16.381          }
  16.382 @@ -1852,12 +1872,12 @@
  16.383              pendingExits = new ListBuffer<AssignPendingExit>();
  16.384              int nextadrPrev = nextadr;
  16.385              scanExpr(tree.selector);
  16.386 -            Bits initsSwitch = inits;
  16.387 -            Bits uninitsSwitch = uninits.dup();
  16.388 +            final Bits initsSwitch = new Bits(inits);
  16.389 +            final Bits uninitsSwitch = new Bits(uninits);
  16.390              boolean hasDefault = false;
  16.391              for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
  16.392 -                inits = initsSwitch.dup();
  16.393 -                uninits = uninits.andSet(uninitsSwitch);
  16.394 +                inits.assign(initsSwitch);
  16.395 +                uninits.assign(uninits.andSet(uninitsSwitch));
  16.396                  JCCase c = l.head;
  16.397                  if (c.pat == null)
  16.398                      hasDefault = true;
  16.399 @@ -1875,8 +1895,8 @@
  16.400          }
  16.401          // where
  16.402              /** Add any variables defined in stats to inits and uninits. */
  16.403 -            private void addVars(List<JCStatement> stats, Bits inits,
  16.404 -                                        Bits uninits) {
  16.405 +            private void addVars(List<JCStatement> stats, final Bits inits,
  16.406 +                                        final Bits uninits) {
  16.407                  for (;stats.nonEmpty(); stats = stats.tail) {
  16.408                      JCTree stat = stats.head;
  16.409                      if (stat.hasTag(VARDEF)) {
  16.410 @@ -1889,11 +1909,11 @@
  16.411  
  16.412          public void visitTry(JCTry tree) {
  16.413              ListBuffer<JCVariableDecl> resourceVarDecls = ListBuffer.lb();
  16.414 -            Bits uninitsTryPrev = uninitsTry;
  16.415 +            final Bits uninitsTryPrev = new Bits(uninitsTry);
  16.416              ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
  16.417              pendingExits = new ListBuffer<AssignPendingExit>();
  16.418 -            Bits initsTry = inits.dup();
  16.419 -            uninitsTry = uninits.dup();
  16.420 +            final Bits initsTry = new Bits(inits);
  16.421 +            uninitsTry.assign(uninits);
  16.422              for (JCTree resource : tree.resources) {
  16.423                  if (resource instanceof JCVariableDecl) {
  16.424                      JCVariableDecl vdecl = (JCVariableDecl) resource;
  16.425 @@ -1908,8 +1928,8 @@
  16.426              }
  16.427              scan(tree.body);
  16.428              uninitsTry.andSet(uninits);
  16.429 -            Bits initsEnd = inits;
  16.430 -            Bits uninitsEnd = uninits;
  16.431 +            final Bits initsEnd = new Bits(inits);
  16.432 +            final Bits uninitsEnd = new Bits(uninits);
  16.433              int nextadrCatch = nextadr;
  16.434  
  16.435              if (!resourceVarDecls.isEmpty() &&
  16.436 @@ -1925,8 +1945,8 @@
  16.437  
  16.438              for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
  16.439                  JCVariableDecl param = l.head.param;
  16.440 -                inits = initsTry.dup();
  16.441 -                uninits = uninitsTry.dup();
  16.442 +                inits.assign(initsTry);
  16.443 +                uninits.assign(uninitsTry);
  16.444                  scan(param);
  16.445                  inits.incl(param.sym.adr);
  16.446                  uninits.excl(param.sym.adr);
  16.447 @@ -1936,8 +1956,8 @@
  16.448                  nextadr = nextadrCatch;
  16.449              }
  16.450              if (tree.finalizer != null) {
  16.451 -                inits = initsTry.dup();
  16.452 -                uninits = uninitsTry.dup();
  16.453 +                inits.assign(initsTry);
  16.454 +                uninits.assign(uninitsTry);
  16.455                  ListBuffer<AssignPendingExit> exits = pendingExits;
  16.456                  pendingExits = prevPendingExits;
  16.457                  scan(tree.finalizer);
  16.458 @@ -1958,8 +1978,8 @@
  16.459                      inits.orSet(initsEnd);
  16.460                  }
  16.461              } else {
  16.462 -                inits = initsEnd;
  16.463 -                uninits = uninitsEnd;
  16.464 +                inits.assign(initsEnd);
  16.465 +                uninits.assign(uninitsEnd);
  16.466                  ListBuffer<AssignPendingExit> exits = pendingExits;
  16.467                  pendingExits = prevPendingExits;
  16.468                  while (exits.nonEmpty()) pendingExits.append(exits.next());
  16.469 @@ -1969,10 +1989,10 @@
  16.470  
  16.471          public void visitConditional(JCConditional tree) {
  16.472              scanCond(tree.cond);
  16.473 -            Bits initsBeforeElse = initsWhenFalse;
  16.474 -            Bits uninitsBeforeElse = uninitsWhenFalse;
  16.475 -            inits = initsWhenTrue;
  16.476 -            uninits = uninitsWhenTrue;
  16.477 +            final Bits initsBeforeElse = new Bits(initsWhenFalse);
  16.478 +            final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse);
  16.479 +            inits.assign(initsWhenTrue);
  16.480 +            uninits.assign(uninitsWhenTrue);
  16.481              if (tree.truepart.type.hasTag(BOOLEAN) &&
  16.482                  tree.falsepart.type.hasTag(BOOLEAN)) {
  16.483                  // if b and c are boolean valued, then
  16.484 @@ -1980,12 +2000,12 @@
  16.485                  //    v is (un)assigned after b when true and
  16.486                  //    v is (un)assigned after c when true
  16.487                  scanCond(tree.truepart);
  16.488 -                Bits initsAfterThenWhenTrue = initsWhenTrue.dup();
  16.489 -                Bits initsAfterThenWhenFalse = initsWhenFalse.dup();
  16.490 -                Bits uninitsAfterThenWhenTrue = uninitsWhenTrue.dup();
  16.491 -                Bits uninitsAfterThenWhenFalse = uninitsWhenFalse.dup();
  16.492 -                inits = initsBeforeElse;
  16.493 -                uninits = uninitsBeforeElse;
  16.494 +                final Bits initsAfterThenWhenTrue = new Bits(initsWhenTrue);
  16.495 +                final Bits initsAfterThenWhenFalse = new Bits(initsWhenFalse);
  16.496 +                final Bits uninitsAfterThenWhenTrue = new Bits(uninitsWhenTrue);
  16.497 +                final Bits uninitsAfterThenWhenFalse = new Bits(uninitsWhenFalse);
  16.498 +                inits.assign(initsBeforeElse);
  16.499 +                uninits.assign(uninitsBeforeElse);
  16.500                  scanCond(tree.falsepart);
  16.501                  initsWhenTrue.andSet(initsAfterThenWhenTrue);
  16.502                  initsWhenFalse.andSet(initsAfterThenWhenFalse);
  16.503 @@ -1993,10 +2013,10 @@
  16.504                  uninitsWhenFalse.andSet(uninitsAfterThenWhenFalse);
  16.505              } else {
  16.506                  scanExpr(tree.truepart);
  16.507 -                Bits initsAfterThen = inits.dup();
  16.508 -                Bits uninitsAfterThen = uninits.dup();
  16.509 -                inits = initsBeforeElse;
  16.510 -                uninits = uninitsBeforeElse;
  16.511 +                final Bits initsAfterThen = new Bits(inits);
  16.512 +                final Bits uninitsAfterThen = new Bits(uninits);
  16.513 +                inits.assign(initsBeforeElse);
  16.514 +                uninits.assign(uninitsBeforeElse);
  16.515                  scanExpr(tree.falsepart);
  16.516                  inits.andSet(initsAfterThen);
  16.517                  uninits.andSet(uninitsAfterThen);
  16.518 @@ -2005,16 +2025,16 @@
  16.519  
  16.520          public void visitIf(JCIf tree) {
  16.521              scanCond(tree.cond);
  16.522 -            Bits initsBeforeElse = initsWhenFalse;
  16.523 -            Bits uninitsBeforeElse = uninitsWhenFalse;
  16.524 -            inits = initsWhenTrue;
  16.525 -            uninits = uninitsWhenTrue;
  16.526 +            final Bits initsBeforeElse = new Bits(initsWhenFalse);
  16.527 +            final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse);
  16.528 +            inits.assign(initsWhenTrue);
  16.529 +            uninits.assign(uninitsWhenTrue);
  16.530              scan(tree.thenpart);
  16.531              if (tree.elsepart != null) {
  16.532 -                Bits initsAfterThen = inits.dup();
  16.533 -                Bits uninitsAfterThen = uninits.dup();
  16.534 -                inits = initsBeforeElse;
  16.535 -                uninits = uninitsBeforeElse;
  16.536 +                final Bits initsAfterThen = new Bits(inits);
  16.537 +                final Bits uninitsAfterThen = new Bits(uninits);
  16.538 +                inits.assign(initsBeforeElse);
  16.539 +                uninits.assign(uninitsBeforeElse);
  16.540                  scan(tree.elsepart);
  16.541                  inits.andSet(initsAfterThen);
  16.542                  uninits.andSet(uninitsAfterThen);
  16.543 @@ -2055,8 +2075,8 @@
  16.544  
  16.545          @Override
  16.546          public void visitLambda(JCLambda tree) {
  16.547 -            Bits prevUninits = uninits;
  16.548 -            Bits prevInits = inits;
  16.549 +            final Bits prevUninits = new Bits(uninits);
  16.550 +            final Bits prevInits = new Bits(inits);
  16.551              int returnadrPrev = returnadr;
  16.552              ListBuffer<AssignPendingExit> prevPending = pendingExits;
  16.553              try {
  16.554 @@ -2076,8 +2096,8 @@
  16.555              }
  16.556              finally {
  16.557                  returnadr = returnadrPrev;
  16.558 -                uninits = prevUninits;
  16.559 -                inits = prevInits;
  16.560 +                uninits.assign(prevUninits);
  16.561 +                inits.assign(prevInits);
  16.562                  pendingExits = prevPending;
  16.563              }
  16.564          }
  16.565 @@ -2088,17 +2108,17 @@
  16.566          }
  16.567  
  16.568          public void visitAssert(JCAssert tree) {
  16.569 -            Bits initsExit = inits.dup();
  16.570 -            Bits uninitsExit = uninits.dup();
  16.571 +            final Bits initsExit = new Bits(inits);
  16.572 +            final Bits uninitsExit = new Bits(uninits);
  16.573              scanCond(tree.cond);
  16.574              uninitsExit.andSet(uninitsWhenTrue);
  16.575              if (tree.detail != null) {
  16.576 -                inits = initsWhenFalse;
  16.577 -                uninits = uninitsWhenFalse;
  16.578 +                inits.assign(initsWhenFalse);
  16.579 +                uninits.assign(uninitsWhenFalse);
  16.580                  scanExpr(tree.detail);
  16.581              }
  16.582 -            inits = initsExit;
  16.583 -            uninits = uninitsExit;
  16.584 +            inits.assign(initsExit);
  16.585 +            uninits.assign(uninitsExit);
  16.586          }
  16.587  
  16.588          public void visitAssign(JCAssign tree) {
  16.589 @@ -2120,12 +2140,12 @@
  16.590              switch (tree.getTag()) {
  16.591              case NOT:
  16.592                  scanCond(tree.arg);
  16.593 -                Bits t = initsWhenFalse;
  16.594 -                initsWhenFalse = initsWhenTrue;
  16.595 -                initsWhenTrue = t;
  16.596 -                t = uninitsWhenFalse;
  16.597 -                uninitsWhenFalse = uninitsWhenTrue;
  16.598 -                uninitsWhenTrue = t;
  16.599 +                final Bits t = new Bits(initsWhenFalse);
  16.600 +                initsWhenFalse.assign(initsWhenTrue);
  16.601 +                initsWhenTrue.assign(t);
  16.602 +                t.assign(uninitsWhenFalse);
  16.603 +                uninitsWhenFalse.assign(uninitsWhenTrue);
  16.604 +                uninitsWhenTrue.assign(t);
  16.605                  break;
  16.606              case PREINC: case POSTINC:
  16.607              case PREDEC: case POSTDEC:
  16.608 @@ -2141,20 +2161,20 @@
  16.609              switch (tree.getTag()) {
  16.610              case AND:
  16.611                  scanCond(tree.lhs);
  16.612 -                Bits initsWhenFalseLeft = initsWhenFalse;
  16.613 -                Bits uninitsWhenFalseLeft = uninitsWhenFalse;
  16.614 -                inits = initsWhenTrue;
  16.615 -                uninits = uninitsWhenTrue;
  16.616 +                final Bits initsWhenFalseLeft = new Bits(initsWhenFalse);
  16.617 +                final Bits uninitsWhenFalseLeft = new Bits(uninitsWhenFalse);
  16.618 +                inits.assign(initsWhenTrue);
  16.619 +                uninits.assign(uninitsWhenTrue);
  16.620                  scanCond(tree.rhs);
  16.621                  initsWhenFalse.andSet(initsWhenFalseLeft);
  16.622                  uninitsWhenFalse.andSet(uninitsWhenFalseLeft);
  16.623                  break;
  16.624              case OR:
  16.625                  scanCond(tree.lhs);
  16.626 -                Bits initsWhenTrueLeft = initsWhenTrue;
  16.627 -                Bits uninitsWhenTrueLeft = uninitsWhenTrue;
  16.628 -                inits = initsWhenFalse;
  16.629 -                uninits = uninitsWhenFalse;
  16.630 +                final Bits initsWhenTrueLeft = new Bits(initsWhenTrue);
  16.631 +                final Bits uninitsWhenTrueLeft = new Bits(uninitsWhenTrue);
  16.632 +                inits.assign(initsWhenFalse);
  16.633 +                uninits.assign(uninitsWhenFalse);
  16.634                  scanCond(tree.rhs);
  16.635                  initsWhenTrue.andSet(initsWhenTrueLeft);
  16.636                  uninitsWhenTrue.andSet(uninitsWhenTrueLeft);
  16.637 @@ -2200,11 +2220,7 @@
  16.638                  attrEnv = env;
  16.639                  Flow.this.make = make;
  16.640                  startPos = tree.pos().getStartPosition();
  16.641 -                inits = new Bits();
  16.642 -                uninits = new Bits();
  16.643 -                uninitsTry = new Bits();
  16.644 -                initsWhenTrue = initsWhenFalse =
  16.645 -                    uninitsWhenTrue = uninitsWhenFalse = null;
  16.646 +
  16.647                  if (vars == null)
  16.648                      vars = new VarSymbol[32];
  16.649                  else
  16.650 @@ -2219,9 +2235,8 @@
  16.651              } finally {
  16.652                  // note that recursive invocations of this method fail hard
  16.653                  startPos = -1;
  16.654 -                inits = uninits = uninitsTry = null;
  16.655 -                initsWhenTrue = initsWhenFalse =
  16.656 -                    uninitsWhenTrue = uninitsWhenFalse = null;
  16.657 +                resetBits(inits, uninits, uninitsTry, initsWhenTrue,
  16.658 +                        initsWhenFalse, uninitsWhenTrue, uninitsWhenFalse);
  16.659                  if (vars != null) for (int i=0; i<vars.length; i++)
  16.660                      vars[i] = null;
  16.661                  firstadr = 0;
    17.1 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Thu May 02 13:35:55 2013 -0700
    17.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Mon May 06 11:53:44 2013 -0700
    17.3 @@ -40,10 +40,9 @@
    17.4  import com.sun.tools.javac.code.Symbol.VarSymbol;
    17.5  import com.sun.tools.javac.code.Symtab;
    17.6  import com.sun.tools.javac.code.Type;
    17.7 -import com.sun.tools.javac.code.Type.ClassType;
    17.8  import com.sun.tools.javac.code.Type.MethodType;
    17.9  import com.sun.tools.javac.code.Types;
   17.10 -import com.sun.tools.javac.comp.LambdaToMethod.LambdaAnalyzer.*;
   17.11 +import com.sun.tools.javac.comp.LambdaToMethod.LambdaAnalyzerPreprocessor.*;
   17.12  import com.sun.tools.javac.comp.Lower.BasicFreeVarCollector;
   17.13  import com.sun.tools.javac.jvm.*;
   17.14  import com.sun.tools.javac.util.*;
   17.15 @@ -81,7 +80,7 @@
   17.16      private Env<AttrContext> attrEnv;
   17.17  
   17.18      /** the analyzer scanner */
   17.19 -    private LambdaAnalyzer analyzer;
   17.20 +    private LambdaAnalyzerPreprocessor analyzer;
   17.21  
   17.22      /** map from lambda trees to translation contexts */
   17.23      private Map<JCTree, TranslationContext<?>> contextMap;
   17.24 @@ -156,7 +155,7 @@
   17.25          make = TreeMaker.instance(context);
   17.26          types = Types.instance(context);
   17.27          transTypes = TransTypes.instance(context);
   17.28 -        analyzer = new LambdaAnalyzer();
   17.29 +        analyzer = new LambdaAnalyzerPreprocessor();
   17.30      }
   17.31      // </editor-fold>
   17.32  
   17.33 @@ -206,7 +205,7 @@
   17.34      public void visitClassDef(JCClassDecl tree) {
   17.35          if (tree.sym.owner.kind == PCK) {
   17.36              //analyze class
   17.37 -            analyzer.analyzeClass(tree);
   17.38 +            tree = analyzer.analyzeAndPreprocessClass(tree);
   17.39          }
   17.40          KlassInfo prevKlassInfo = kInfo;
   17.41          try {
   17.42 @@ -531,16 +530,25 @@
   17.43      /** Make an attributed class instance creation expression.
   17.44       *  @param ctype    The class type.
   17.45       *  @param args     The constructor arguments.
   17.46 +     *  @param cons     The constructor symbol
   17.47       */
   17.48 -    JCNewClass makeNewClass(Type ctype, List<JCExpression> args) {
   17.49 +    JCNewClass makeNewClass(Type ctype, List<JCExpression> args, Symbol cons) {
   17.50          JCNewClass tree = make.NewClass(null,
   17.51              null, make.QualIdent(ctype.tsym), args, null);
   17.52 -        tree.constructor = rs.resolveConstructor(
   17.53 -            null, attrEnv, ctype, TreeInfo.types(args), List.<Type>nil());
   17.54 +        tree.constructor = cons;
   17.55          tree.type = ctype;
   17.56          return tree;
   17.57      }
   17.58  
   17.59 +    /** Make an attributed class instance creation expression.
   17.60 +     *  @param ctype    The class type.
   17.61 +     *  @param args     The constructor arguments.
   17.62 +     */
   17.63 +    JCNewClass makeNewClass(Type ctype, List<JCExpression> args) {
   17.64 +        return makeNewClass(ctype, args,
   17.65 +                rs.resolveConstructor(null, attrEnv, ctype, TreeInfo.types(args), List.<Type>nil()));
   17.66 +     }
   17.67 +
   17.68      private void addDeserializationCase(int implMethodKind, Symbol refSym, Type targetType, MethodSymbol samSym,
   17.69              DiagnosticPosition pos, List<Object> staticArgs, MethodType indyType) {
   17.70          String functionalInterfaceClass = classSig(targetType);
   17.71 @@ -1019,8 +1027,9 @@
   17.72       * This visitor collects information about translation of a lambda expression.
   17.73       * More specifically, it keeps track of the enclosing contexts and captured locals
   17.74       * accessed by the lambda being translated (as well as other useful info).
   17.75 +     * It also translates away problems for LambdaToMethod.
   17.76       */
   17.77 -    class LambdaAnalyzer extends TreeScanner {
   17.78 +    class LambdaAnalyzerPreprocessor extends TreeTranslator {
   17.79  
   17.80          /** the frame stack - used to reconstruct translation info about enclosing scopes */
   17.81          private List<Frame> frameStack;
   17.82 @@ -1047,10 +1056,10 @@
   17.83          private Map<ClassSymbol, Symbol> clinits =
   17.84                  new HashMap<ClassSymbol, Symbol>();
   17.85  
   17.86 -        private void analyzeClass(JCClassDecl tree) {
   17.87 +        private JCClassDecl analyzeAndPreprocessClass(JCClassDecl tree) {
   17.88              frameStack = List.nil();
   17.89              localClassDefs = new HashMap<Symbol, JCClassDecl>();
   17.90 -            scan(tree);
   17.91 +            return translate(tree);
   17.92          }
   17.93  
   17.94          @Override
   17.95 @@ -1154,7 +1163,7 @@
   17.96                      frameStack.head.addLocal(param.sym);
   17.97                  }
   17.98                  contextMap.put(tree, context);
   17.99 -                scan(tree.body);
  17.100 +                super.visitLambda(tree);
  17.101                  context.complete();
  17.102              }
  17.103              finally {
  17.104 @@ -1220,12 +1229,47 @@
  17.105                      };
  17.106                      fvc.scan(localCDef);
  17.107                  }
  17.108 -            }
  17.109 +        }
  17.110  
  17.111 +        /**
  17.112 +         * Method references to local class constructors, may, if the local
  17.113 +         * class references local variables, have implicit constructor
  17.114 +         * parameters added in Lower; As a result, the invokedynamic bootstrap
  17.115 +         * information added in the LambdaToMethod pass will have the wrong
  17.116 +         * signature. Hooks between Lower and LambdaToMethod have been added to
  17.117 +         * handle normal "new" in this case. This visitor converts potentially
  17.118 +         * effected method references into a lambda containing a normal "new" of
  17.119 +         * the class.
  17.120 +         *
  17.121 +         * @param tree
  17.122 +         */
  17.123          @Override
  17.124          public void visitReference(JCMemberReference tree) {
  17.125 -            scan(tree.getQualifierExpression());
  17.126 -            contextMap.put(tree, makeReferenceContext(tree));
  17.127 +            if (tree.getMode() == ReferenceMode.NEW
  17.128 +                    && tree.kind != ReferenceKind.ARRAY_CTOR
  17.129 +                    && tree.sym.owner.isLocal()) {
  17.130 +                MethodSymbol consSym = (MethodSymbol) tree.sym;
  17.131 +                List<Type> ptypes = ((MethodType) consSym.type).getParameterTypes();
  17.132 +                Type classType = consSym.owner.type;
  17.133 +
  17.134 +                // Make new-class call
  17.135 +                List<JCVariableDecl> params = make.Params(ptypes, owner());
  17.136 +                JCNewClass nc = makeNewClass(classType, make.Idents(params));
  17.137 +                nc.pos = tree.pos;
  17.138 +
  17.139 +                // Make lambda holding the new-class call
  17.140 +                JCLambda slam = make.Lambda(params, nc);
  17.141 +                slam.descriptorType = tree.descriptorType;
  17.142 +                slam.targets = tree.targets;
  17.143 +                slam.type = tree.type;
  17.144 +                slam.pos = tree.pos;
  17.145 +
  17.146 +                // Now it is a lambda, process as such
  17.147 +                visitLambda(slam);
  17.148 +            } else {
  17.149 +                super.visitReference(tree);
  17.150 +                contextMap.put(tree, makeReferenceContext(tree));
  17.151 +            }
  17.152          }
  17.153  
  17.154          @Override
  17.155 @@ -1240,10 +1284,8 @@
  17.156                      }
  17.157                      localContext = localContext.prev;
  17.158                  }
  17.159 -                scan(tree.selected);
  17.160 -            } else {
  17.161 -                super.visitSelect(tree);
  17.162              }
  17.163 +            super.visitSelect(tree);
  17.164          }
  17.165  
  17.166          @Override
    18.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java	Thu May 02 13:35:55 2013 -0700
    18.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java	Mon May 06 11:53:44 2013 -0700
    18.3 @@ -1647,7 +1647,7 @@
    18.4          State dup() {
    18.5              try {
    18.6                  State state = (State)super.clone();
    18.7 -                state.defined = defined.dup();
    18.8 +                state.defined = new Bits(defined);
    18.9                  state.stack = stack.clone();
   18.10                  if (locks != null) state.locks = locks.clone();
   18.11                  if (debugCode) {
   18.12 @@ -1775,7 +1775,7 @@
   18.13          }
   18.14  
   18.15          State join(State other) {
   18.16 -            defined = defined.andSet(other.defined);
   18.17 +            defined.andSet(other.defined);
   18.18              Assert.check(stacksize == other.stacksize
   18.19                      && nlocks == other.nlocks);
   18.20              for (int i=0; i<stacksize; ) {
   18.21 @@ -1887,7 +1887,7 @@
   18.22      /** Set the current variable defined state. */
   18.23      public void setDefined(Bits newDefined) {
   18.24          if (alive && newDefined != state.defined) {
   18.25 -            Bits diff = state.defined.dup().xorSet(newDefined);
   18.26 +            Bits diff = new Bits(state.defined).xorSet(newDefined);
   18.27              for (int adr = diff.nextBit(0);
   18.28                   adr >= 0;
   18.29                   adr = diff.nextBit(adr+1)) {
    19.1 --- a/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java	Thu May 02 13:35:55 2013 -0700
    19.2 +++ b/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java	Mon May 06 11:53:44 2013 -0700
    19.3 @@ -33,10 +33,13 @@
    19.4  import com.sun.tools.javac.code.Kinds;
    19.5  import com.sun.tools.javac.code.Symbol;
    19.6  import com.sun.tools.javac.code.Symbol.ClassSymbol;
    19.7 +import com.sun.tools.javac.code.Symbol.TypeVariableSymbol;
    19.8 +import com.sun.tools.javac.code.TargetType;
    19.9  import com.sun.tools.javac.code.Type;
   19.10  import com.sun.tools.javac.code.Type.AnnotatedType;
   19.11  import com.sun.tools.javac.util.ListBuffer;
   19.12  import static com.sun.tools.javac.code.TypeTag.CLASS;
   19.13 +import com.sun.tools.javac.util.List;
   19.14  
   19.15  /**
   19.16   * Utility methods for operating on annotated constructs.
   19.17 @@ -61,8 +64,12 @@
   19.18              throw new IllegalArgumentException("Not an annotation type: "
   19.19                                                 + annoType);
   19.20          Attribute.Compound c;
   19.21 -        if (annotated.kind == Kinds.TYP && annotated instanceof ClassSymbol) {
   19.22 +        if (annotated.kind == Kinds.TYP &&
   19.23 +                annotated instanceof ClassSymbol) {
   19.24              c = getAttributeOnClass((ClassSymbol)annotated, annoType);
   19.25 +        } else if (annotated.kind == Kinds.TYP &&
   19.26 +                   annotated instanceof TypeVariableSymbol) {
   19.27 +            c = getAttributeOnTypeVariable((TypeVariableSymbol)annotated, annoType);
   19.28          } else {
   19.29              c = getAttribute(annotated, annoType);
   19.30          }
   19.31 @@ -83,6 +90,24 @@
   19.32      }
   19.33  
   19.34      // Helper to getAnnotation[s]
   19.35 +    private static <A extends Annotation> Attribute.Compound
   19.36 +            getAttributeOnTypeVariable(TypeVariableSymbol annotated, Class<A> annoType) {
   19.37 +        String name = annoType.getName();
   19.38 +
   19.39 +        // Declaration annotations on type variables are stored in type attributes
   19.40 +        // on the owner of the TypeVariableSymbol
   19.41 +        List<Attribute.Compound> res = List.nil();
   19.42 +        List<Attribute.TypeCompound> candidates = annotated.owner.getRawTypeAttributes();
   19.43 +        for (Attribute.TypeCompound anno : candidates)
   19.44 +            if (anno.position.type == TargetType.CLASS_TYPE_PARAMETER ||
   19.45 +                    anno.position.type == TargetType.METHOD_TYPE_PARAMETER)
   19.46 +                if (name.equals(anno.type.tsym.flatName().toString()))
   19.47 +                    return anno;
   19.48 +
   19.49 +        return null;
   19.50 +    }
   19.51 +
   19.52 +    // Helper to getAnnotation[s]
   19.53      private static <A extends Annotation> Attribute.Compound getAttributeOnClass(ClassSymbol annotated,
   19.54                                                                  Class<A> annoType) {
   19.55          boolean inherited = annoType.isAnnotationPresent(Inherited.class);
    20.1 --- a/src/share/classes/com/sun/tools/javac/model/JavacElements.java	Thu May 02 13:35:55 2013 -0700
    20.2 +++ b/src/share/classes/com/sun/tools/javac/model/JavacElements.java	Mon May 06 11:53:44 2013 -0700
    20.3 @@ -402,9 +402,10 @@
    20.4       * @param e  the element being examined
    20.5       * @return all annotations of the element
    20.6       */
    20.7 +    @Override
    20.8      public List<Attribute.Compound> getAllAnnotationMirrors(Element e) {
    20.9          Symbol sym = cast(Symbol.class, e);
   20.10 -        List<Attribute.Compound> annos = sym.getRawAttributes();
   20.11 +        List<Attribute.Compound> annos = sym.getAnnotationMirrors();
   20.12          while (sym.getKind() == ElementKind.CLASS) {
   20.13              Type sup = ((ClassSymbol) sym).getSuperclass();
   20.14              if (!sup.hasTag(CLASS) || sup.isErroneous() ||
   20.15 @@ -413,7 +414,7 @@
   20.16              }
   20.17              sym = sup.tsym;
   20.18              List<Attribute.Compound> oldAnnos = annos;
   20.19 -            List<Attribute.Compound> newAnnos = sym.getRawAttributes();
   20.20 +            List<Attribute.Compound> newAnnos = sym.getAnnotationMirrors();
   20.21              for (Attribute.Compound anno : newAnnos) {
   20.22                  if (isInherited(anno.type) &&
   20.23                          !containsAnnoOfType(oldAnnos, anno.type)) {
    21.1 --- a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java	Thu May 02 13:35:55 2013 -0700
    21.2 +++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java	Mon May 06 11:53:44 2013 -0700
    21.3 @@ -41,6 +41,7 @@
    21.4  import com.sun.tools.javac.tree.DCTree.DCAttribute;
    21.5  import com.sun.tools.javac.tree.DCTree.DCDocComment;
    21.6  import com.sun.tools.javac.tree.DCTree.DCEndElement;
    21.7 +import com.sun.tools.javac.tree.DCTree.DCEndPosTree;
    21.8  import com.sun.tools.javac.tree.DCTree.DCErroneous;
    21.9  import com.sun.tools.javac.tree.DCTree.DCIdentifier;
   21.10  import com.sun.tools.javac.tree.DCTree.DCReference;
   21.11 @@ -336,12 +337,12 @@
   21.12                      DCTree text = inlineText();
   21.13                      if (text != null) {
   21.14                          nextChar();
   21.15 -                        return m.at(p).UnknownInlineTag(name, List.of(text));
   21.16 +                        return m.at(p).UnknownInlineTag(name, List.of(text)).setEndPos(bp);
   21.17                      }
   21.18                  } else if (tp.getKind() == TagParser.Kind.INLINE) {
   21.19 -                    DCTree tree =  tp.parse(p);
   21.20 +                    DCEndPosTree<?> tree = (DCEndPosTree<?>) tp.parse(p);
   21.21                      if (tree != null) {
   21.22 -                        return tree;
   21.23 +                        return tree.setEndPos(bp);
   21.24                      }
   21.25                  } else {
   21.26                      inlineText(); // skip content
   21.27 @@ -509,7 +510,7 @@
   21.28              fac.log.popDiagnosticHandler(deferredDiagnosticHandler);
   21.29          }
   21.30  
   21.31 -        return m.at(pos).Reference(sig, qualExpr, member, paramTypes);
   21.32 +        return m.at(pos).Reference(sig, qualExpr, member, paramTypes).setEndPos(bp);
   21.33      }
   21.34  
   21.35      JCTree parseType(String s) throws ParseException {
   21.36 @@ -741,7 +742,7 @@
   21.37                  }
   21.38                  if (ch == '>') {
   21.39                      nextChar();
   21.40 -                    return m.at(p).StartElement(name, attrs, selfClosing);
   21.41 +                    return m.at(p).StartElement(name, attrs, selfClosing).setEndPos(bp);
   21.42                  }
   21.43              }
   21.44          } else if (ch == '/') {
    22.1 --- a/src/share/classes/com/sun/tools/javac/tree/DCTree.java	Thu May 02 13:35:55 2013 -0700
    22.2 +++ b/src/share/classes/com/sun/tools/javac/tree/DCTree.java	Mon May 06 11:53:44 2013 -0700
    22.3 @@ -36,6 +36,7 @@
    22.4  import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
    22.5  import com.sun.tools.javac.util.List;
    22.6  import com.sun.tools.javac.util.Name;
    22.7 +import com.sun.tools.javac.util.Position;
    22.8  import java.io.IOException;
    22.9  import java.io.StringWriter;
   22.10  import javax.tools.JavaFileObject;
   22.11 @@ -82,8 +83,24 @@
   22.12          return s.toString();
   22.13      }
   22.14  
   22.15 +    public static abstract class DCEndPosTree<T extends DCEndPosTree<T>> extends DCTree {
   22.16 +
   22.17 +        private int endPos = Position.NOPOS;
   22.18 +
   22.19 +        public int getEndPos(DCDocComment dc) {
   22.20 +            return dc.comment.getSourcePos(endPos);
   22.21 +        }
   22.22 +
   22.23 +        @SuppressWarnings("unchecked")
   22.24 +        public T setEndPos(int endPos) {
   22.25 +            this.endPos = endPos;
   22.26 +            return (T) this;
   22.27 +        }
   22.28 +
   22.29 +    }
   22.30 +
   22.31      public static class DCDocComment extends DCTree implements DocCommentTree {
   22.32 -        final Comment comment; // required for the implicit source pos table
   22.33 +        public final Comment comment; // required for the implicit source pos table
   22.34  
   22.35          public final List<DCTree> firstSentence;
   22.36          public final List<DCTree> body;
   22.37 @@ -125,7 +142,7 @@
   22.38          }
   22.39      }
   22.40  
   22.41 -    public static abstract class DCInlineTag extends DCTree implements InlineTagTree {
   22.42 +    public static abstract class DCInlineTag extends DCEndPosTree<DCInlineTag> implements InlineTagTree {
   22.43          public String getTagName() {
   22.44              return getKind().tagName;
   22.45          }
   22.46 @@ -345,6 +362,7 @@
   22.47          public int getEndPosition(EndPosTable endPosTable) {
   22.48              return pos + body.length();
   22.49          }
   22.50 +
   22.51      }
   22.52  
   22.53      public static class DCIdentifier extends DCTree implements IdentifierTree {
   22.54 @@ -478,7 +496,7 @@
   22.55          }
   22.56      }
   22.57  
   22.58 -    public static class DCReference extends DCTree implements ReferenceTree {
   22.59 +    public static class DCReference extends DCEndPosTree<DCReference> implements ReferenceTree {
   22.60          public final String signature;
   22.61  
   22.62          // The following are not directly exposed through ReferenceTree
   22.63 @@ -663,7 +681,7 @@
   22.64          }
   22.65      }
   22.66  
   22.67 -    public static class DCStartElement extends DCTree implements StartElementTree {
   22.68 +    public static class DCStartElement extends DCEndPosTree<DCStartElement> implements StartElementTree {
   22.69          public final Name name;
   22.70          public final List<DCTree> attrs;
   22.71          public final boolean selfClosing;
    23.1 --- a/src/share/classes/com/sun/tools/javac/util/Bits.java	Thu May 02 13:35:55 2013 -0700
    23.2 +++ b/src/share/classes/com/sun/tools/javac/util/Bits.java	Mon May 06 11:53:44 2013 -0700
    23.3 @@ -1,5 +1,5 @@
    23.4  /*
    23.5 - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
    23.6 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    23.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.8   *
    23.9   * This code is free software; you can redistribute it and/or modify it
   23.10 @@ -27,6 +27,8 @@
   23.11  
   23.12  import java.util.Arrays;
   23.13  
   23.14 +import static com.sun.tools.javac.util.Bits.BitsOpKind.*;
   23.15 +
   23.16  /** A class for extensible, mutable bit sets.
   23.17   *
   23.18   *  <p><b>This is NOT part of any supported API.
   23.19 @@ -36,31 +38,114 @@
   23.20   */
   23.21  public class Bits {
   23.22  
   23.23 +    public enum BitsOpKind {
   23.24 +        INIT,
   23.25 +        CLEAR,
   23.26 +        INCL_BIT,
   23.27 +        EXCL_BIT,
   23.28 +        ASSIGN,
   23.29 +        AND_SET,
   23.30 +        OR_SET,
   23.31 +        DIFF_SET,
   23.32 +        XOR_SET,
   23.33 +        INCL_RANGE,
   23.34 +        EXCL_RANGE,
   23.35 +    }
   23.36 +
   23.37 +    //       ____________      reset    _________
   23.38 +    //      /  UNKNOWN   \   <-------- / UNINIT  \
   23.39 +    //      \____________/       |     \_________/
   23.40 +    //            |              |          |
   23.41 +    //            |assign        |          | any
   23.42 +    //            |        ___________      |
   23.43 +    //            ------> /  NORMAL   \ <----
   23.44 +    //                    \___________/     |
   23.45 +    //                            |         |
   23.46 +    //                            |         |
   23.47 +    //                            -----------
   23.48 +    //                               any
   23.49 +    private enum BitsState {
   23.50 +        /*  A Bits instance is in UNKNOWN state if it has been explicitly reset.
   23.51 +         *  It is possible to get to this state from any other by calling the
   23.52 +         *  reset method. An instance in the UNKNOWN state can pass to the
   23.53 +         *  NORMAL state after being assigned another Bits instance.
   23.54 +         */
   23.55 +        UNKNOWN,
   23.56 +        /*  A Bits instance is in UNINIT when it is created with the default
   23.57 +         *  constructor but it isn't explicitly reset. The main objective of this
   23.58 +         *  internal state is to save some memory.
   23.59 +         */
   23.60 +        UNINIT,
   23.61 +        /*  The normal state is reached after creating a Bits instance from an
   23.62 +         *  existing one or after applying any operation to an instance on UNINIT
   23.63 +         *  or NORMAL state. From this state a bits instance can pass to the
   23.64 +         *  UNKNOWN state by calling the reset method.
   23.65 +         */
   23.66 +        NORMAL;
   23.67 +
   23.68 +        static BitsState getState(int[] someBits, boolean reset) {
   23.69 +            if (reset) {
   23.70 +                return UNKNOWN;
   23.71 +            } else {
   23.72 +                if (someBits != unassignedBits) {
   23.73 +                    return NORMAL;
   23.74 +                } else {
   23.75 +                    return UNINIT;
   23.76 +                }
   23.77 +            }
   23.78 +        }
   23.79 +
   23.80 +    }
   23.81  
   23.82      private final static int wordlen = 32;
   23.83      private final static int wordshift = 5;
   23.84      private final static int wordmask = wordlen - 1;
   23.85  
   23.86 -    private int[] bits;
   23.87 +    public int[] bits = null;
   23.88 +    // This field will store last version of bits after every change.
   23.89 +    public int[] oldBits = null;
   23.90 +
   23.91 +    public BitsOpKind lastOperation = null;
   23.92 +
   23.93 +    private static final int[] unassignedBits = new int[0];
   23.94 +
   23.95 +    private BitsState currentState;
   23.96  
   23.97      /** Construct an initially empty set.
   23.98       */
   23.99      public Bits() {
  23.100 -        this(new int[1]);
  23.101 +        this(false);
  23.102 +    }
  23.103 +
  23.104 +    public Bits(Bits someBits) {
  23.105 +        this(someBits.dup().bits, BitsState.getState(someBits.bits, false));
  23.106 +    }
  23.107 +
  23.108 +    public Bits(boolean reset) {
  23.109 +        this(unassignedBits, BitsState.getState(unassignedBits, reset));
  23.110      }
  23.111  
  23.112      /** Construct a set consisting initially of given bit vector.
  23.113       */
  23.114 -    public Bits(int[] bits) {
  23.115 +    private Bits(int[] bits, BitsState initState) {
  23.116          this.bits = bits;
  23.117 +        this.currentState = initState;
  23.118 +        switch (initState) {
  23.119 +            case UNKNOWN:
  23.120 +                reset(); //this will also set current state;
  23.121 +                break;
  23.122 +            case NORMAL:
  23.123 +                Assert.check(bits != unassignedBits);
  23.124 +                lastOperation = INIT;
  23.125 +                break;
  23.126 +        }
  23.127      }
  23.128  
  23.129 -    /** Construct a set consisting initially of given range.
  23.130 +    /** This method will be called after any operation that causes a change to
  23.131 +     *  the bits. Subclasses can thus override it in order to extract information
  23.132 +     *  from the changes produced to the bits by the given operation.
  23.133       */
  23.134 -    public Bits(int start, int limit) {
  23.135 -        this();
  23.136 -        inclRange(start, limit);
  23.137 -    }
  23.138 +    public void changed() {}
  23.139  
  23.140      private void sizeTo(int len) {
  23.141          if (bits.length < len) {
  23.142 @@ -71,57 +156,110 @@
  23.143      /** This set = {}.
  23.144       */
  23.145      public void clear() {
  23.146 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.147 +        oldBits = bits;
  23.148 +        lastOperation = CLEAR;
  23.149          for (int i = 0; i < bits.length; i++) bits[i] = 0;
  23.150 +        changed();
  23.151 +        currentState = BitsState.NORMAL;
  23.152 +    }
  23.153 +
  23.154 +    public void reset() {
  23.155 +        bits = null;
  23.156 +        oldBits = null;
  23.157 +        currentState = BitsState.UNKNOWN;
  23.158 +    }
  23.159 +
  23.160 +    public boolean isReset() {
  23.161 +        return currentState == BitsState.UNKNOWN;
  23.162 +    }
  23.163 +
  23.164 +    public Bits assign(Bits someBits) {
  23.165 +        lastOperation = ASSIGN;
  23.166 +        oldBits = bits;
  23.167 +        bits = someBits.dup().bits;
  23.168 +        changed();
  23.169 +        currentState = BitsState.NORMAL;
  23.170 +        return this;
  23.171      }
  23.172  
  23.173      /** Return a copy of this set.
  23.174       */
  23.175 -    public Bits dup() {
  23.176 -        int[] newbits = new int[bits.length];
  23.177 -        System.arraycopy(bits, 0, newbits, 0, bits.length);
  23.178 -        return new Bits(newbits);
  23.179 +    private Bits dup() {
  23.180 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.181 +        Bits tmp = new Bits();
  23.182 +        if (currentState != BitsState.NORMAL) {
  23.183 +            tmp.bits = bits;
  23.184 +        } else {
  23.185 +            tmp.bits = new int[bits.length];
  23.186 +            System.arraycopy(bits, 0, tmp.bits, 0, bits.length);
  23.187 +        }
  23.188 +        currentState = BitsState.NORMAL;
  23.189 +        return tmp;
  23.190      }
  23.191  
  23.192      /** Include x in this set.
  23.193       */
  23.194      public void incl(int x) {
  23.195 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.196          Assert.check(x >= 0);
  23.197 +        oldBits = bits;
  23.198 +        lastOperation = INCL_BIT;
  23.199          sizeTo((x >>> wordshift) + 1);
  23.200          bits[x >>> wordshift] = bits[x >>> wordshift] |
  23.201              (1 << (x & wordmask));
  23.202 +        changed();
  23.203 +        currentState = BitsState.NORMAL;
  23.204      }
  23.205  
  23.206  
  23.207      /** Include [start..limit) in this set.
  23.208       */
  23.209      public void inclRange(int start, int limit) {
  23.210 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.211 +        oldBits = bits;
  23.212 +        lastOperation = INCL_RANGE;
  23.213          sizeTo((limit >>> wordshift) + 1);
  23.214 -        for (int x = start; x < limit; x++)
  23.215 +        for (int x = start; x < limit; x++) {
  23.216              bits[x >>> wordshift] = bits[x >>> wordshift] |
  23.217                  (1 << (x & wordmask));
  23.218 +        }
  23.219 +        changed();
  23.220 +        currentState = BitsState.NORMAL;
  23.221      }
  23.222  
  23.223      /** Exclude [start...end] from this set.
  23.224       */
  23.225      public void excludeFrom(int start) {
  23.226 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.227 +        oldBits = bits;
  23.228 +        lastOperation = EXCL_RANGE;
  23.229          Bits temp = new Bits();
  23.230          temp.sizeTo(bits.length);
  23.231          temp.inclRange(0, start);
  23.232 -        andSet(temp);
  23.233 +        internalAndSet(temp);
  23.234 +        changed();
  23.235 +        currentState = BitsState.NORMAL;
  23.236      }
  23.237  
  23.238      /** Exclude x from this set.
  23.239       */
  23.240      public void excl(int x) {
  23.241 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.242          Assert.check(x >= 0);
  23.243 +        oldBits = bits;
  23.244 +        lastOperation = EXCL_BIT;
  23.245          sizeTo((x >>> wordshift) + 1);
  23.246          bits[x >>> wordshift] = bits[x >>> wordshift] &
  23.247              ~(1 << (x & wordmask));
  23.248 +        changed();
  23.249 +        currentState = BitsState.NORMAL;
  23.250      }
  23.251  
  23.252      /** Is x an element of this set?
  23.253       */
  23.254      public boolean isMember(int x) {
  23.255 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.256          return
  23.257              0 <= x && x < (bits.length << wordshift) &&
  23.258              (bits[x >>> wordshift] & (1 << (x & wordmask))) != 0;
  23.259 @@ -130,38 +268,66 @@
  23.260      /** {@literal this set = this set & xs}.
  23.261       */
  23.262      public Bits andSet(Bits xs) {
  23.263 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.264 +        oldBits = bits;
  23.265 +        lastOperation = AND_SET;
  23.266 +        internalAndSet(xs);
  23.267 +        changed();
  23.268 +        currentState = BitsState.NORMAL;
  23.269 +        return this;
  23.270 +    }
  23.271 +
  23.272 +    private void internalAndSet(Bits xs) {
  23.273 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.274          sizeTo(xs.bits.length);
  23.275 -        for (int i = 0; i < xs.bits.length; i++)
  23.276 +        for (int i = 0; i < xs.bits.length; i++) {
  23.277              bits[i] = bits[i] & xs.bits[i];
  23.278 -        return this;
  23.279 +        }
  23.280      }
  23.281  
  23.282      /** this set = this set | xs.
  23.283       */
  23.284      public Bits orSet(Bits xs) {
  23.285 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.286 +        oldBits = bits;
  23.287 +        lastOperation = OR_SET;
  23.288          sizeTo(xs.bits.length);
  23.289 -        for (int i = 0; i < xs.bits.length; i++)
  23.290 +        for (int i = 0; i < xs.bits.length; i++) {
  23.291              bits[i] = bits[i] | xs.bits[i];
  23.292 +        }
  23.293 +        changed();
  23.294 +        currentState = BitsState.NORMAL;
  23.295          return this;
  23.296      }
  23.297  
  23.298      /** this set = this set \ xs.
  23.299       */
  23.300      public Bits diffSet(Bits xs) {
  23.301 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.302 +        oldBits = bits;
  23.303 +        lastOperation = DIFF_SET;
  23.304          for (int i = 0; i < bits.length; i++) {
  23.305              if (i < xs.bits.length) {
  23.306                  bits[i] = bits[i] & ~xs.bits[i];
  23.307              }
  23.308          }
  23.309 +        changed();
  23.310 +        currentState = BitsState.NORMAL;
  23.311          return this;
  23.312      }
  23.313  
  23.314      /** this set = this set ^ xs.
  23.315       */
  23.316      public Bits xorSet(Bits xs) {
  23.317 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.318 +        oldBits = bits;
  23.319 +        lastOperation = XOR_SET;
  23.320          sizeTo(xs.bits.length);
  23.321 -        for (int i = 0; i < xs.bits.length; i++)
  23.322 +        for (int i = 0; i < xs.bits.length; i++) {
  23.323              bits[i] = bits[i] ^ xs.bits[i];
  23.324 +        }
  23.325 +        changed();
  23.326 +        currentState = BitsState.NORMAL;
  23.327          return this;
  23.328      }
  23.329  
  23.330 @@ -187,6 +353,7 @@
  23.331       *  }</pre>
  23.332       */
  23.333      public int nextBit(int x) {
  23.334 +        Assert.check(currentState != BitsState.UNKNOWN);
  23.335          int windex = x >>> wordshift;
  23.336          if (windex >= bits.length) return -1;
  23.337          int word = bits[windex] & ~((1 << (x & wordmask))-1);
  23.338 @@ -202,17 +369,20 @@
  23.339      /** a string representation of this set.
  23.340       */
  23.341      public String toString() {
  23.342 -        char[] digits = new char[bits.length * wordlen];
  23.343 -        for (int i = 0; i < bits.length * wordlen; i++)
  23.344 -            digits[i] = isMember(i) ? '1' : '0';
  23.345 -        return new String(digits);
  23.346 +        if (bits.length > 0) {
  23.347 +            char[] digits = new char[bits.length * wordlen];
  23.348 +            for (int i = 0; i < bits.length * wordlen; i++)
  23.349 +                digits[i] = isMember(i) ? '1' : '0';
  23.350 +            return new String(digits);
  23.351 +        } else {
  23.352 +            return "[]";
  23.353 +        }
  23.354      }
  23.355  
  23.356      /** Test Bits.nextBit(int). */
  23.357      public static void main(String[] args) {
  23.358          java.util.Random r = new java.util.Random();
  23.359          Bits bits = new Bits();
  23.360 -        int dupCount = 0;
  23.361          for (int i=0; i<125; i++) {
  23.362              int k;
  23.363              do {
    24.1 --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Thu May 02 13:35:55 2013 -0700
    24.2 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Mon May 06 11:53:44 2013 -0700
    24.3 @@ -341,9 +341,14 @@
    24.4       * </pre>
    24.5       */
    24.6      public String name() {
    24.7 -        return getClassName(tsym, false);
    24.8 +        if (name == null) {
    24.9 +            name = getClassName(tsym, false);
   24.10 +        }
   24.11 +        return name;
   24.12      }
   24.13  
   24.14 +    private String name;
   24.15 +
   24.16      /**
   24.17       * Return the qualified class name as a String.
   24.18       * <pre>
   24.19 @@ -354,9 +359,14 @@
   24.20       * </pre>
   24.21       */
   24.22      public String qualifiedName() {
   24.23 -        return getClassName(tsym, true);
   24.24 +        if (qualifiedName == null) {
   24.25 +            qualifiedName = getClassName(tsym, true);
   24.26 +        }
   24.27 +        return qualifiedName;
   24.28      }
   24.29  
   24.30 +    private String qualifiedName;
   24.31 +
   24.32      /**
   24.33       * Return unqualified name of type excluding any dimension information.
   24.34       * <p>
   24.35 @@ -380,9 +390,14 @@
   24.36       * Return the simple name of this type.
   24.37       */
   24.38      public String simpleTypeName() {
   24.39 -        return tsym.name.toString();
   24.40 +        if (simpleTypeName == null) {
   24.41 +            simpleTypeName = tsym.name.toString();
   24.42 +        }
   24.43 +        return simpleTypeName;
   24.44      }
   24.45  
   24.46 +    private String simpleTypeName;
   24.47 +
   24.48      /**
   24.49       * Return the qualified name and any type parameters.
   24.50       * Each parameter is a type variable with optional bounds.
    25.1 --- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Thu May 02 13:35:55 2013 -0700
    25.2 +++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Mon May 06 11:53:44 2013 -0700
    25.3 @@ -1,5 +1,5 @@
    25.4  /*
    25.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    25.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    25.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.8   *
    25.9   * This code is free software; you can redistribute it and/or modify it
   25.10 @@ -252,13 +252,23 @@
   25.11      }
   25.12  
   25.13      public String name() {
   25.14 -        return sym.name.toString();
   25.15 +        if (name == null) {
   25.16 +            name = sym.name.toString();
   25.17 +        }
   25.18 +        return name;
   25.19      }
   25.20  
   25.21 +    private String name;
   25.22 +
   25.23      public String qualifiedName() {
   25.24 -        return sym.enclClass().getQualifiedName() + "." + name();
   25.25 +        if (qualifiedName == null) {
   25.26 +            qualifiedName = sym.enclClass().getQualifiedName() + "." + name();
   25.27 +        }
   25.28 +        return qualifiedName;
   25.29      }
   25.30  
   25.31 +    private String qualifiedName;
   25.32 +
   25.33      /**
   25.34       * Return the source position of the entity, or null if
   25.35       * no position is available.
    26.1 --- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Thu May 02 13:35:55 2013 -0700
    26.2 +++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Mon May 06 11:53:44 2013 -0700
    26.3 @@ -1,5 +1,5 @@
    26.4  /*
    26.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    26.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    26.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.8   *
    26.9   * This code is free software; you can redistribute it and/or modify it
   26.10 @@ -203,13 +203,23 @@
   26.11  
   26.12  
   26.13      public String name() {
   26.14 -        return sym.name.toString();
   26.15 +        if (name == null) {
   26.16 +            name = sym.name.toString();
   26.17 +        }
   26.18 +        return name;
   26.19      }
   26.20  
   26.21 +    private String name;
   26.22 +
   26.23      public String qualifiedName() {
   26.24 -        return sym.enclClass().getQualifiedName() + "." + sym.name;
   26.25 +        if (qualifiedName == null) {
   26.26 +            qualifiedName =  sym.enclClass().getQualifiedName() + "." + sym.name;
   26.27 +        }
   26.28 +        return qualifiedName;
   26.29      }
   26.30  
   26.31 +    private String qualifiedName;
   26.32 +
   26.33      /**
   26.34       * Returns a string representation of this method.  Includes the
   26.35       * qualified signature, the qualified method name, and any type
    27.1 --- a/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Thu May 02 13:35:55 2013 -0700
    27.2 +++ b/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Mon May 06 11:53:44 2013 -0700
    27.3 @@ -1,5 +1,5 @@
    27.4  /*
    27.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    27.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    27.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    27.8   *
    27.9   * This code is free software; you can redistribute it and/or modify it
   27.10 @@ -334,12 +334,17 @@
   27.11       * Get package name.
   27.12       */
   27.13      public String qualifiedName() {
   27.14 -        Name fullname = sym.getQualifiedName();
   27.15 -        // Some bogus tests depend on the interned "" being returned.
   27.16 -        // See 6457276.
   27.17 -        return fullname.isEmpty() ? "" : fullname.toString();
   27.18 +        if (qualifiedName == null) {
   27.19 +            Name fullname = sym.getQualifiedName();
   27.20 +            // Some bogus tests depend on the interned "" being returned.
   27.21 +            // See 6457276.
   27.22 +            qualifiedName = fullname.isEmpty() ? "" : fullname.toString();
   27.23 +        }
   27.24 +        return qualifiedName;
   27.25      }
   27.26  
   27.27 +    private String qualifiedName;
   27.28 +
   27.29      /**
   27.30       * set doc path for an unzipped directory
   27.31       */
    28.1 --- a/test/tools/javac/api/TestJavacTaskScanner.java	Thu May 02 13:35:55 2013 -0700
    28.2 +++ b/test/tools/javac/api/TestJavacTaskScanner.java	Mon May 06 11:53:44 2013 -0700
    28.3 @@ -1,5 +1,5 @@
    28.4  /*
    28.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
    28.6 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
    28.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.8   *
    28.9   * This code is free software; you can redistribute it and/or modify it
   28.10 @@ -93,7 +93,7 @@
   28.11          System.out.println("#allMembers: " + numAllMembers);
   28.12  
   28.13          check(numTokens, "#Tokens", 1222);
   28.14 -        check(numParseTypeElements, "#parseTypeElements", 136);
   28.15 +        check(numParseTypeElements, "#parseTypeElements", 158);
   28.16          check(numAllMembers, "#allMembers", 52);
   28.17      }
   28.18  
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/test/tools/javac/defaultMethods/CheckACC_STRICTFlagOnDefaultMethodTest.java	Mon May 06 11:53:44 2013 -0700
    29.3 @@ -0,0 +1,96 @@
    29.4 +/*
    29.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    29.7 + *
    29.8 + * This code is free software; you can redistribute it and/or modify it
    29.9 + * under the terms of the GNU General Public License version 2 only, as
   29.10 + * published by the Free Software Foundation.  Oracle designates this
   29.11 + * particular file as subject to the "Classpath" exception as provided
   29.12 + * by Oracle in the LICENSE file that accompanied this code.
   29.13 + *
   29.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   29.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   29.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   29.17 + * version 2 for more details (a copy is included in the LICENSE file that
   29.18 + * accompanied this code).
   29.19 + *
   29.20 + * You should have received a copy of the GNU General Public License version
   29.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   29.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   29.23 + *
   29.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   29.25 + * or visit www.oracle.com if you need additional information or have any
   29.26 + * questions.
   29.27 + */
   29.28 +
   29.29 +/*
   29.30 + * @test
   29.31 + * @bug 8012723
   29.32 + * @summary strictfp interface misses strictfp modifer on default method
   29.33 + * @run main CheckACC_STRICTFlagOnDefaultMethodTest
   29.34 + */
   29.35 +
   29.36 +import java.util.ArrayList;
   29.37 +import java.util.List;
   29.38 +import java.io.File;
   29.39 +import java.io.IOException;
   29.40 +
   29.41 +import com.sun.tools.classfile.ClassFile;
   29.42 +import com.sun.tools.classfile.ConstantPoolException;
   29.43 +import com.sun.tools.classfile.Descriptor;
   29.44 +import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
   29.45 +import com.sun.tools.classfile.Method;
   29.46 +
   29.47 +import static com.sun.tools.classfile.AccessFlags.ACC_STRICT;
   29.48 +
   29.49 +public class CheckACC_STRICTFlagOnDefaultMethodTest {
   29.50 +    private static final String AssertionErrorMessage =
   29.51 +        "All methods should have the ACC_STRICT access flag " +
   29.52 +        "please check output";
   29.53 +    private static final String offendingMethodErrorMessage =
   29.54 +        "Method %s of class %s doesn't have the ACC_STRICT access flag";
   29.55 +
   29.56 +    private List<String> errors = new ArrayList<>();
   29.57 +
   29.58 +    public static void main(String[] args)
   29.59 +            throws IOException, ConstantPoolException, InvalidDescriptor {
   29.60 +        new CheckACC_STRICTFlagOnDefaultMethodTest().run();
   29.61 +    }
   29.62 +
   29.63 +    private void run()
   29.64 +            throws IOException, ConstantPoolException, InvalidDescriptor {
   29.65 +        String testClasses = System.getProperty("test.classes");
   29.66 +        check(testClasses,
   29.67 +                "CheckACC_STRICTFlagOnDefaultMethodTest$StrictfpInterface.class");
   29.68 +        if (errors.size() > 0) {
   29.69 +            for (String error: errors) {
   29.70 +                System.err.println(error);
   29.71 +            }
   29.72 +            throw new AssertionError(AssertionErrorMessage);
   29.73 +        }
   29.74 +    }
   29.75 +
   29.76 +    void check(String dir, String... fileNames)
   29.77 +        throws
   29.78 +            IOException,
   29.79 +            ConstantPoolException,
   29.80 +            Descriptor.InvalidDescriptor {
   29.81 +        for (String fileName : fileNames) {
   29.82 +            ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));
   29.83 +
   29.84 +            for (Method method : classFileToCheck.methods) {
   29.85 +                if ((method.access_flags.flags & ACC_STRICT) == 0) {
   29.86 +                    errors.add(String.format(offendingMethodErrorMessage,
   29.87 +                            method.getName(classFileToCheck.constant_pool),
   29.88 +                            classFileToCheck.getName()));
   29.89 +                }
   29.90 +            }
   29.91 +        }
   29.92 +    }
   29.93 +
   29.94 +    strictfp interface StrictfpInterface {
   29.95 +        default void default_interface_method() {}
   29.96 +        static void static_interface_method() {}
   29.97 +    }
   29.98 +
   29.99 +}
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/test/tools/javac/doctree/positions/TestPosition.java	Mon May 06 11:53:44 2013 -0700
    30.3 @@ -0,0 +1,105 @@
    30.4 +/*
    30.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.7 + *
    30.8 + * This code is free software; you can redistribute it and/or modify it
    30.9 + * under the terms of the GNU General Public License version 2 only, as
   30.10 + * published by the Free Software Foundation.
   30.11 + *
   30.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   30.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   30.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   30.15 + * version 2 for more details (a copy is included in the LICENSE file that
   30.16 + * accompanied this code).
   30.17 + *
   30.18 + * You should have received a copy of the GNU General Public License version
   30.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   30.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   30.21 + *
   30.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   30.23 + * or visit www.oracle.com if you need additional information or have any
   30.24 + * questions.
   30.25 + */
   30.26 +
   30.27 +/*
   30.28 + * @test
   30.29 + * @bug 8008174
   30.30 + * @summary proper source positions for doc comments
   30.31 + * @build TestPosition
   30.32 + * @compile/ref=TestPosition.out -processor TestPosition -proc:only TestPositionSource.java
   30.33 + */
   30.34 +
   30.35 +import com.sun.source.doctree.DocCommentTree;
   30.36 +import com.sun.source.doctree.DocTree;
   30.37 +import com.sun.source.tree.MethodTree;
   30.38 +import com.sun.source.util.DocSourcePositions;
   30.39 +import com.sun.source.util.DocTreeScanner;
   30.40 +import com.sun.source.util.DocTrees;
   30.41 +import com.sun.source.util.TreePath;
   30.42 +import com.sun.source.util.TreePathScanner;
   30.43 +import java.io.IOException;
   30.44 +import java.util.Set;
   30.45 +import javax.annotation.processing.*;
   30.46 +import javax.lang.model.*;
   30.47 +import javax.lang.model.element.*;
   30.48 +
   30.49 +@SupportedAnnotationTypes("*")
   30.50 +public class TestPosition extends AbstractProcessor {
   30.51 +
   30.52 +    @Override
   30.53 +    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
   30.54 +        TypeElement source = processingEnv.getElementUtils().getTypeElement("TestPositionSource");
   30.55 +
   30.56 +        if (source == null) throw new IllegalStateException();
   30.57 +
   30.58 +        if (!roundEnv.getRootElements().contains(source)) return false;
   30.59 +
   30.60 +        final DocTrees trees = DocTrees.instance(processingEnv);
   30.61 +        final TreePath testElement = trees.getPath(source);
   30.62 +
   30.63 +        if (testElement == null) throw new IllegalStateException();
   30.64 +
   30.65 +        String code;
   30.66 +
   30.67 +        try {
   30.68 +            code = testElement.getCompilationUnit().getSourceFile().getCharContent(false).toString();
   30.69 +        } catch ( IOException ex) {
   30.70 +            throw new IllegalStateException(ex);
   30.71 +        }
   30.72 +
   30.73 +        new TreePathScanner<Void, Void>() {
   30.74 +            @Override public Void visitMethod(MethodTree node, Void p) {
   30.75 +                final DocCommentTree docCommentTree = trees.getDocCommentTree(getCurrentPath());
   30.76 +
   30.77 +                if (docCommentTree != null) {
   30.78 +                    System.out.println(node.getName() + ":");
   30.79 +                    new DocTreeScanner<Void, Void>() {
   30.80 +                        @Override public Void scan(DocTree node, Void p) {
   30.81 +                            if (node != null) {
   30.82 +                                DocSourcePositions sp = (DocSourcePositions) trees.getSourcePositions(); //XXX: the cast???
   30.83 +                                int start = (int) sp.getStartPosition(testElement.getCompilationUnit(), docCommentTree, node);
   30.84 +                                int end   = (int) sp.getEndPosition(testElement.getCompilationUnit(), docCommentTree, node);
   30.85 +                                String snippet = code.substring(start, end).replace(" \n", "!trailing-whitespace!\n");
   30.86 +
   30.87 +                                if (snippet.endsWith(" ")) {
   30.88 +                                    snippet = snippet.substring(0, snippet.length() - 1) + "!trailing-whitespace!";
   30.89 +                                }
   30.90 +                                System.out.println(node.getKind().name() + ":" + snippet);
   30.91 +                            }
   30.92 +                            return super.scan(node, p);
   30.93 +                        }
   30.94 +                    }.scan(docCommentTree, null);
   30.95 +                }
   30.96 +
   30.97 +                return super.visitMethod(node, p);
   30.98 +            }
   30.99 +        }.scan(testElement, null);
  30.100 +
  30.101 +        return false;
  30.102 +    }
  30.103 +
  30.104 +    @Override
  30.105 +    public SourceVersion getSupportedSourceVersion() {
  30.106 +        return SourceVersion.latest();
  30.107 +    }
  30.108 +}
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/test/tools/javac/doctree/positions/TestPosition.out	Mon May 06 11:53:44 2013 -0700
    31.3 @@ -0,0 +1,99 @@
    31.4 +valid:
    31.5 +DOC_COMMENT:First sentence.
    31.6 +     *
    31.7 +     * <p>Description with {@link java.io.InputStream link}
    31.8 +     *
    31.9 +     * @param first description
   31.10 +     * @param second description
   31.11 +     * @return whatever
   31.12 +     * @throws IllegalStateException why?
   31.13 +     * @since 1.15
   31.14 +     * @see java.util.List
   31.15 +TEXT:First sentence.
   31.16 +START_ELEMENT:<p>
   31.17 +TEXT:Description with!trailing-whitespace!
   31.18 +LINK:{@link java.io.InputStream link}
   31.19 +REFERENCE:java.io.InputStream
   31.20 +TEXT:link
   31.21 +PARAM:@param first description
   31.22 +IDENTIFIER:first
   31.23 +TEXT:description
   31.24 +PARAM:@param second description
   31.25 +IDENTIFIER:second
   31.26 +TEXT:description
   31.27 +RETURN:@return whatever
   31.28 +TEXT:whatever
   31.29 +THROWS:@throws IllegalStateException why?
   31.30 +REFERENCE:IllegalStateException
   31.31 +TEXT:why?
   31.32 +SINCE:@since 1.15
   31.33 +TEXT:1.15
   31.34 +SEE:@see java.util.List
   31.35 +REFERENCE:java.util.List
   31.36 +erroneous:
   31.37 +DOC_COMMENT:First sentence.
   31.38 +     *
   31.39 +     * <p>Description with {@link}, {@link java.util.List}, {@link
   31.40 +     *
   31.41 +     * @param
   31.42 +     * @param second
   31.43 +     * @return
   31.44 +     * @throws
   31.45 +     * @throws IllegalStateException
   31.46 +     * @since
   31.47 +     * @see
   31.48 +TEXT:First sentence.
   31.49 +START_ELEMENT:<p>
   31.50 +TEXT:Description with!trailing-whitespace!
   31.51 +LINK:{@link}
   31.52 +TEXT:,!trailing-whitespace!
   31.53 +LINK:{@link java.util.List}
   31.54 +REFERENCE:java.util.List
   31.55 +TEXT:,!trailing-whitespace!
   31.56 +ERRONEOUS:{@link
   31.57 +ERRONEOUS:@param
   31.58 +PARAM:@param second
   31.59 +IDENTIFIER:second
   31.60 +RETURN:@return
   31.61 +ERRONEOUS:@throws
   31.62 +THROWS:@throws IllegalStateException
   31.63 +REFERENCE:IllegalStateException
   31.64 +SINCE:@since
   31.65 +ERRONEOUS:@see
   31.66 +withWhiteSpaces:
   31.67 +DOC_COMMENT:First sentence.
   31.68 +     *
   31.69 +     * <p>Description with {@link    }, {@link java.util.List#add(   int   )},
   31.70 +     * {@link java.util.List#add(   int   ) some   text   with   whitespaces}, {@link
   31.71 +     *
   31.72 +     * @param     first
   31.73 +     * @param     second   some   text   with trailing whitespace
   31.74 +     * @return      some   return
   31.75 +     * @throws      java.lang.IllegalStateException
   31.76 +     * @throws   java.lang.IllegalStateException some     text
   31.77 +TEXT:First sentence.
   31.78 +START_ELEMENT:<p>
   31.79 +TEXT:Description with!trailing-whitespace!
   31.80 +LINK:{@link    }
   31.81 +TEXT:,!trailing-whitespace!
   31.82 +LINK:{@link java.util.List#add(   int   )}
   31.83 +REFERENCE:java.util.List#add(   int   )
   31.84 +TEXT:,
   31.85 +     *!trailing-whitespace!
   31.86 +LINK:{@link java.util.List#add(   int   ) some   text   with   whitespaces}
   31.87 +REFERENCE:java.util.List#add(   int   )
   31.88 +TEXT:some   text   with   whitespaces
   31.89 +TEXT:,!trailing-whitespace!
   31.90 +ERRONEOUS:{@link
   31.91 +PARAM:@param     first
   31.92 +IDENTIFIER:first
   31.93 +PARAM:@param     second   some   text   with trailing whitespace
   31.94 +IDENTIFIER:second
   31.95 +TEXT:some   text   with trailing whitespace
   31.96 +RETURN:@return      some   return
   31.97 +TEXT:some   return
   31.98 +THROWS:@throws      java.lang.IllegalStateException
   31.99 +REFERENCE:java.lang.IllegalStateException
  31.100 +THROWS:@throws   java.lang.IllegalStateException some     text
  31.101 +REFERENCE:java.lang.IllegalStateException
  31.102 +TEXT:some     text
  31.103 \ No newline at end of file
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/test/tools/javac/doctree/positions/TestPositionSource.java	Mon May 06 11:53:44 2013 -0700
    32.3 @@ -0,0 +1,71 @@
    32.4 +/*
    32.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    32.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    32.7 + *
    32.8 + * This code is free software; you can redistribute it and/or modify it
    32.9 + * under the terms of the GNU General Public License version 2 only, as
   32.10 + * published by the Free Software Foundation.
   32.11 + *
   32.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   32.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   32.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   32.15 + * version 2 for more details (a copy is included in the LICENSE file that
   32.16 + * accompanied this code).
   32.17 + *
   32.18 + * You should have received a copy of the GNU General Public License version
   32.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   32.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   32.21 + *
   32.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   32.23 + * or visit www.oracle.com if you need additional information or have any
   32.24 + * questions.
   32.25 + */
   32.26 +public class TestPositionSource {
   32.27 +
   32.28 +    /**First sentence.
   32.29 +     *
   32.30 +     * <p>Description with {@link java.io.InputStream link}
   32.31 +     *
   32.32 +     * @param first description
   32.33 +     * @param second description
   32.34 +     * @return whatever
   32.35 +     * @throws IllegalStateException why?
   32.36 +     * @since 1.15
   32.37 +     * @see java.util.List
   32.38 +     */
   32.39 +    public boolean valid(int first, int second) throws IllegalStateException {
   32.40 +        return true;
   32.41 +    }
   32.42 +
   32.43 +    /**First sentence.
   32.44 +     *
   32.45 +     * <p>Description with {@link}, {@link java.util.List}, {@link
   32.46 +     *
   32.47 +     * @param
   32.48 +     * @param second
   32.49 +     * @return
   32.50 +     * @throws
   32.51 +     * @throws IllegalStateException
   32.52 +     * @since
   32.53 +     * @see
   32.54 +     */
   32.55 +    public boolean erroneous(int first, int second) throws IllegalStateException {
   32.56 +        return true;
   32.57 +    }
   32.58 +
   32.59 +    /**First sentence.
   32.60 +     *
   32.61 +     * <p>Description with {@link    }, {@link java.util.List#add(   int   )},
   32.62 +     * {@link java.util.List#add(   int   ) some   text   with   whitespaces}, {@link
   32.63 +     *
   32.64 +     * @param     first
   32.65 +     * @param     second   some   text   with trailing whitespace
   32.66 +     * @return      some   return
   32.67 +     * @throws      java.lang.IllegalStateException
   32.68 +     * @throws   java.lang.IllegalStateException some     text
   32.69 +     */
   32.70 +    public boolean withWhiteSpaces(int first, int second) throws IllegalStateException {
   32.71 +        return true;
   32.72 +    }
   32.73 +
   32.74 +}
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInnerImplicitArgs.java	Mon May 06 11:53:44 2013 -0700
    33.3 @@ -0,0 +1,82 @@
    33.4 +/*
    33.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.7 + *
    33.8 + * This code is free software; you can redistribute it and/or modify it
    33.9 + * under the terms of the GNU General Public License version 2 only, as
   33.10 + * published by the Free Software Foundation.  Oracle designates this
   33.11 + * particular file as subject to the "Classpath" exception as provided
   33.12 + * by Oracle in the LICENSE file that accompanied this code.
   33.13 + *
   33.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   33.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   33.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   33.17 + * version 2 for more details (a copy is included in the LICENSE file that
   33.18 + * accompanied this code).
   33.19 + *
   33.20 + * You should have received a copy of the GNU General Public License version
   33.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   33.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   33.23 + *
   33.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   33.25 + * or visit www.oracle.com if you need additional information or have any
   33.26 + * questions.
   33.27 + */
   33.28 +
   33.29 +/**
   33.30 + * @test
   33.31 + * @bug 8011591
   33.32 + * @summary BootstrapMethodError when capturing constructor ref to local classes
   33.33 + * @run testng MethodReferenceTestNewInnerImplicitArgs
   33.34 + */
   33.35 +
   33.36 +import org.testng.annotations.Test;
   33.37 +
   33.38 +import static org.testng.Assert.assertEquals;
   33.39 +
   33.40 +/**
   33.41 + * Test the case that a constructor has implicit parameters added to
   33.42 + * access local variables and that this constructor is used in a
   33.43 + * method reference.
   33.44 + * @author Robert Field
   33.45 + */
   33.46 +
   33.47 +@Test
   33.48 +public class MethodReferenceTestNewInnerImplicitArgs {
   33.49 +
   33.50 +
   33.51 +    static class S {
   33.52 +        String b;
   33.53 +        S(String s, String s2) { b = s + s2; }
   33.54 +    }
   33.55 +
   33.56 +    interface I {
   33.57 +        S m();
   33.58 +    }
   33.59 +
   33.60 +    interface I2 {
   33.61 +        S m(int i, int j);
   33.62 +    }
   33.63 +
   33.64 +    public static void testConstructorReferenceImplicitParameters() {
   33.65 +        String title = "Hey";
   33.66 +        String a2 = "!!!";
   33.67 +        class MS extends S {
   33.68 +            MS() {
   33.69 +                super(title, a2);
   33.70 +            }
   33.71 +        }
   33.72 +
   33.73 +        I result = MS::new;
   33.74 +        assertEquals(result.m().b, "Hey!!!");
   33.75 +
   33.76 +        class MS2 extends S {
   33.77 +            MS2(int x, int y) {
   33.78 +                super(title+x, a2+y);
   33.79 +            }
   33.80 +        }
   33.81 +
   33.82 +        I2 result2 = MS2::new;
   33.83 +        assertEquals(result2.m(8, 4).b, "Hey8!!!4");
   33.84 +    }
   33.85 +}
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java	Mon May 06 11:53:44 2013 -0700
    34.3 @@ -0,0 +1,190 @@
    34.4 +/*
    34.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    34.7 + *
    34.8 + * This code is free software; you can redistribute it and/or modify it
    34.9 + * under the terms of the GNU General Public License version 2 only, as
   34.10 + * published by the Free Software Foundation.
   34.11 + *
   34.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   34.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   34.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   34.15 + * version 2 for more details (a copy is included in the LICENSE file that
   34.16 + * accompanied this code).
   34.17 + *
   34.18 + * You should have received a copy of the GNU General Public License version
   34.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   34.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   34.21 + *
   34.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   34.23 + * or visit www.oracle.com if you need additional information or have any
   34.24 + * questions.
   34.25 + */
   34.26 +
   34.27 +/*
   34.28 + * @test
   34.29 + * @bug 8011027
   34.30 + * @library /tools/javac/lib
   34.31 + * @build JavacTestingAbstractProcessor TestTypeParameterAnnotations
   34.32 + * @compile -processor TestTypeParameterAnnotations -proc:only TestTypeParameterAnnotations.java
   34.33 + */
   34.34 +
   34.35 +import java.util.*;
   34.36 +import java.lang.annotation.*;
   34.37 +import javax.annotation.processing.*;
   34.38 +import javax.lang.model.element.*;
   34.39 +import javax.lang.model.util.*;
   34.40 +import javax.tools.*;
   34.41 +
   34.42 +public class TestTypeParameterAnnotations<@Foo @Bar @Baz T> extends JavacTestingAbstractProcessor {
   34.43 +    int round = 0;
   34.44 +
   34.45 +    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
   34.46 +        if (++round == 1) {
   34.47 +            int found = (new Scanner()).scan(roundEnv.getRootElements(), null);
   34.48 +            if (found == expect) {
   34.49 +                ; //nop
   34.50 +            } else {
   34.51 +                error("unexpected number of results: expected " + expect
   34.52 +                        + ", found " + found);
   34.53 +            }
   34.54 +
   34.55 +        }
   34.56 +        return true;
   34.57 +    }
   34.58 +
   34.59 +    class Scanner extends JavacTestingAbstractProcessor.ElementScanner<Integer,Void> {
   34.60 +        @Override
   34.61 +        public Integer visitExecutable(ExecutableElement e, Void p) {
   34.62 +            super.visitExecutable(e, p);
   34.63 +            found += check(e, e.getTypeParameters());
   34.64 +            return found;
   34.65 +        }
   34.66 +
   34.67 +        @Override
   34.68 +        public Integer visitType(TypeElement e, Void p) {
   34.69 +            super.visitType(e, p);
   34.70 +            found += check(e, e.getTypeParameters());
   34.71 +            return found;
   34.72 +        }
   34.73 +
   34.74 +        int found;
   34.75 +    }
   34.76 +
   34.77 +    int check(Element e, List<? extends TypeParameterElement> typarams) {
   34.78 +        if (typarams.isEmpty())
   34.79 +            return 0;
   34.80 +        if (typarams.size() != 1)
   34.81 +            return 0;
   34.82 +
   34.83 +        for (TypeParameterElement tpe: typarams) {
   34.84 +            boolean b1 = checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors());
   34.85 +            boolean b2 = checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe));
   34.86 +            boolean b3 = checkGetAnnotation(tpe);
   34.87 +            boolean b4 = checkGetAnnotations(tpe);
   34.88 +            return b1 && b2 && b3 && b4 ? 1 : 0;
   34.89 +        }
   34.90 +        return 0;
   34.91 +    }
   34.92 +
   34.93 +    boolean checkAnnotationMirrors(TypeParameterElement tpe, List<? extends AnnotationMirror> l) {
   34.94 +        if (l.size() != 3) {
   34.95 +            error("To few annotations, got " + l.size() +
   34.96 +                    ", should be 3", tpe);
   34.97 +            return false;
   34.98 +        }
   34.99 +
  34.100 +        AnnotationMirror m = l.get(0);
  34.101 +        if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Foo"))) {
  34.102 +            error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement());
  34.103 +            return false;
  34.104 +        }
  34.105 +        m = l.get(1);
  34.106 +        if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Bar"))) {
  34.107 +            error("Wrong type of annotation, was expecting @Bar", m.getAnnotationType().asElement());
  34.108 +            return false;
  34.109 +        }
  34.110 +        m = l.get(2);
  34.111 +        if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Baz"))) {
  34.112 +            error("Wrong type of annotation, was expecting @Baz", m.getAnnotationType().asElement());
  34.113 +            return false;
  34.114 +        }
  34.115 +        return true;
  34.116 +    }
  34.117 +
  34.118 +    boolean checkGetAnnotation(TypeParameterElement tpe) {
  34.119 +        Foo f = tpe.getAnnotation(Foo.class);
  34.120 +        if (f == null)
  34.121 +            error("Expecting @Foo to be present in getAnnotation()", tpe);
  34.122 +
  34.123 +        Bar b = tpe.getAnnotation(Bar.class);
  34.124 +        if (b == null)
  34.125 +            error("Expecting @Bar to be present in getAnnotation()", tpe);
  34.126 +
  34.127 +        Baz z = tpe.getAnnotation(Baz.class);
  34.128 +        if (z == null)
  34.129 +            error("Expecting @Baz to be present in getAnnotation()", tpe);
  34.130 +
  34.131 +        return f != null &&
  34.132 +            b != null &&
  34.133 +            z != null;
  34.134 +    }
  34.135 +
  34.136 +    boolean checkGetAnnotations(TypeParameterElement tpe) {
  34.137 +        Foo[] f = tpe.getAnnotationsByType(Foo.class);
  34.138 +        if (f.length != 1) {
  34.139 +            error("Expecting 1 @Foo to be present in getAnnotationsByType()", tpe);
  34.140 +            return false;
  34.141 +        }
  34.142 +
  34.143 +        Bar[] b = tpe.getAnnotationsByType(Bar.class);
  34.144 +        if (b.length != 1) {
  34.145 +            error("Expecting 1 @Bar to be present in getAnnotationsByType()", tpe);
  34.146 +            return false;
  34.147 +        }
  34.148 +
  34.149 +        Baz[] z = tpe.getAnnotationsByType(Baz.class);
  34.150 +        if (z.length != 1) {
  34.151 +            error("Expecting 1 @Baz to be present in getAnnotationsByType()", tpe);
  34.152 +            return false;
  34.153 +        }
  34.154 +
  34.155 +        return true;
  34.156 +    }
  34.157 +
  34.158 +    void note(String msg) {
  34.159 +        messager.printMessage(Diagnostic.Kind.NOTE, msg);
  34.160 +    }
  34.161 +
  34.162 +    void note(String msg, Element e) {
  34.163 +        messager.printMessage(Diagnostic.Kind.NOTE, msg, e);
  34.164 +    }
  34.165 +
  34.166 +    void error(String msg, Element e) {
  34.167 +        messager.printMessage(Diagnostic.Kind.ERROR, msg, e);
  34.168 +    }
  34.169 +
  34.170 +    void error(String msg) {
  34.171 +        messager.printMessage(Diagnostic.Kind.ERROR, msg);
  34.172 +    }
  34.173 +
  34.174 +    // additional generic elements to test
  34.175 +    <@Foo @Bar @Baz X> X m(X x) { return x; }
  34.176 +
  34.177 +    interface Intf<@Foo @Bar @Baz X> { X m() ; }
  34.178 +
  34.179 +    class Class<@Foo @Bar @Baz X> {
  34.180 +        <@Foo @Bar @Baz Y> Class() { }
  34.181 +    }
  34.182 +
  34.183 +    final int expect = 5;  // top level class, plus preceding examples
  34.184 +}
  34.185 +
  34.186 +@Target(ElementType.TYPE_PARAMETER)
  34.187 +@interface Foo {}
  34.188 +
  34.189 +@Target(ElementType.TYPE_PARAMETER)
  34.190 +@interface Bar {}
  34.191 +
  34.192 +@Target(ElementType.TYPE_PARAMETER)
  34.193 +@interface Baz {}

mercurial