# HG changeset patch # User andrew # Date 1338247678 -3600 # Node ID 24540bbb4135d9aa38222ce954885242565f7881 # Parent 8caec36723811482ba27b6605663bb24f3a80469# Parent 179fa85aeefab338cccf1cbe8b494c59bc5df122 Merge diff -r 8caec3672381 -r 24540bbb4135 .hgignore --- a/.hgignore Mon Jul 11 22:31:52 2011 +0100 +++ b/.hgignore Tue May 29 00:27:58 2012 +0100 @@ -2,3 +2,4 @@ ^dist/ /nbproject/private/ ^.hgtip +.DS_Store diff -r 8caec3672381 -r 24540bbb4135 .hgtags --- a/.hgtags Mon Jul 11 22:31:52 2011 +0100 +++ b/.hgtags Tue May 29 00:27:58 2012 +0100 @@ -125,3 +125,43 @@ c455e2ae5c93014ae3fc475aba4509b5f70465f7 jdk7-b145 9425dd4f53d5bfcd992d9aecea0eb7d8b2d4f62b jdk7-b146 58bc532d63418ac3c9b42460d89cdaf595c6f3e1 jdk7-b147 +e9f118c2bd3c4690d8d2e6b108b5bad7e226634c jdk8-b01 +b3c059de2a61fc122c99d555cdd8b85f112393c1 jdk8-b02 +f497fac86cf9ada4801ecaf49eb0d2307a2b61c8 jdk8-b03 +5df63fd8fa64741e829281ee6febe9954932841b jdk8-b04 +5304c2a17d4b001e365a8f0163082dc375f1abab jdk8-b05 +d2422276f9dabc848b7a079025719826d2f9a30f jdk8-b06 +116980ecec5cc7d52736f09cf332321e0773265f jdk8-b07 +e8acc2d6c32f0c8321e642e1a86672a2e196a056 jdk8-b08 +b7a7e47c8d3daf7822abf7c37e5179ccbbf53008 jdk8-b09 +f6c783e18bdf4d46a0ab273868afebbf32600ff7 jdk8-b10 +4bf01f1c4e3464f378959d10f3983a0469181d94 jdk8-b11 +f2d6ed25857dfa7f269ac66e13666d648cb988c6 jdk8-b12 +ae25163501bc7477cd907e26a006a6f1b05fdb6d jdk8-b13 +58f1325d72b2bacc901f5189ee5e4e81e81ea657 jdk8-b14 +07599bd780cab1f40da7915e1dc6774629b0cf8c jdk8-b15 +1cbe86c11ba69521875c0b0357d7540781eb334d jdk8-b17 +ec2c0973cc31e143cffc05ceb63d98fae76f97d4 jdk8-b16 +ab1b1cc7857716914f2bb20b3128e5a8978290f7 jdk8-b18 +77b2c066084cbc75150efc6603a713c558329813 jdk8-b19 +ffd294128a48cbb90ce8f0569f82b61f1f164a18 jdk8-b20 +bcb21abf1c4177baf4574f99709513dcd4474727 jdk8-b21 +390a7828ae18324030c0546b6452d51093ffa451 jdk8-b22 +601ffcc6551d5414ef871be306c3a26396cf16a7 jdk8-b23 +6c9d21ca92c41ff5fcfa76c5b7fafe0f042f4aef jdk8-b24 +520c30f85bb529a3daf5d7623764c2464f00fd19 jdk8-b25 +b556aa8a99c358469861770aebdce884e06fa178 jdk8-b26 +be456f9c64e818161c789252145d4ddc292ae863 jdk8-b27 +5bed623b0c773aa8a8d5f8d4004ce9d3974143cc jdk8-b28 +e974e82abe51ef66dc32bb6ab5d0733753d3c7d7 jdk8-b29 +08a3425f39f829502ca0ddbfb2d051c31710cb19 jdk8-b30 +b28cfbe7e8b196da954bed9a22bfd790e55333aa jdk8-b31 +be069d72dde2bfe6f996c46325a320961ca854c2 jdk8-b32 +46831c72b7f6c69fef2cc2935001863643a65f94 jdk8-b33 +6b105afbb77ca9600a99eade31f686d070c70581 jdk8-b34 +defd666a786334465496c8901fa302b779c7e045 jdk8-b35 +94bbaa67686f44a124cd16fd9f1e8a6a3f684d2d jdk8-b36 +5891b38985e8b2502296fc29e726b527d03116d2 jdk8-b37 +1f224f160aa852c9541380735a27a3439dfb7217 jdk8-b38 +a9f547c218d957306dfc0cdd710be041bb62a555 jdk8-b39 +86e0dad6aadf626bf5755f503aee2d0da525d9d5 jdk8-b40 diff -r 8caec3672381 -r 24540bbb4135 make/Makefile-classic --- a/make/Makefile-classic Mon Jul 11 22:31:52 2011 +0100 +++ b/make/Makefile-classic Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2012 Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -115,7 +115,6 @@ JAVADOC_JAR = $(LIB_DIR)/javadoc.jar JAVAH_JAR = $(LIB_DIR)/javah.jar JAVAP_JAR = $(LIB_DIR)/javap.jar -APT_JAR = $(LIB_DIR)/apt.jar CLASSES_JAR = $(DIST_DIR)/classes.jar SRC_ZIP = $(DIST_DIR)/src.zip @@ -163,7 +162,7 @@ #----- useful macros -TOOLS = javac javadoc javah javap apt +TOOLS = javac javadoc javah javap SOURCE_LEVEL = 5 BOOTSTRAP_TARGET_LEVEL = 5 @@ -319,28 +318,6 @@ ( $(ECHO) Main-Class: sun.tools.javap.Main ) > $(BUILD_DIR)/javap.mf $(BOOTJAR) -cfm $@ $(BUILD_DIR)/javap.mf $(patsubst %,-C $(CLASSES_DIR) %, $(JAVAP_DIRS)) -#----- apt - -APT_DIRS = \ - com/sun/mirror \ - com/sun/tools/apt - -APT_RESOURCE_FILES = \ - $(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(APT_DIRS)) -name SCCS -prune -o -name \*.properties -print ) - -APT_JAVA_FILES = \ - $(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(APT_DIRS)) -name SCCS -prune -o -name \*.java -print ) \ - $(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES)) - -$(APT_JAR): $(APT_JAVA_FILES) $(JAVAC_JAR) \ - $(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES)) - $(MKDIR) -p $(CLASSES_DIR) $(@D) - $(BOOT_JAVAC) -sourcepath "" -classpath $(CLASSES_DIR) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(NO_PROPRIETARY_API_WARNINGS) \ - $(APT_JAVA_FILES) \ - $(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES)) - ( $(ECHO) Main-Class: com.sun.tools.apt.Main ; $(ECHO) Class-Path: javac.jar ) > $(BUILD_DIR)/apt.mf - $(BOOTJAR) -cfm $@ $(BUILD_DIR)/apt.mf $(patsubst %,-C $(CLASSES_DIR) %, $(APT_DIRS)) - #----- build-tools: $(BUILDTOOLCLASSES_DIR)/CompileProperties/CompileProperties.class @@ -366,7 +343,7 @@ #----- all classes -$(DIST_DIR)/%/classes.jar: $(JAVAC_JAR) $(JAVADOC_JAR) $(JAVAH_JAR) $(JAVAP_JAR) $(APT_JAR) +$(DIST_DIR)/%/classes.jar: $(JAVAC_JAR) $(JAVADOC_JAR) $(JAVAH_JAR) $(JAVAP_JAR) $(MKDIR) -p $(@D) $(BOOTJAR) -cf $@ -C $(CLASSES_DIR) . @@ -401,7 +378,6 @@ - $(TESTJAVA) -jar $(JAVADOC_JAR) -version $(TESTJAVA) -jar $(JAVAH_JAR) -version - $(TESTJAVA) -jar $(JAVAP_JAR) -version - $(TESTJAVA) -jar $(APT_JAR) -version #----- diff -r 8caec3672381 -r 24540bbb4135 make/build.properties --- a/make/build.properties Mon Jul 11 22:31:52 2011 +0100 +++ b/make/build.properties Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -159,15 +159,6 @@ # -apt.includes = \ - com/sun/mirror/ \ - com/sun/tools/apt/ - -apt.tests = \ - tools/apt/ - -# - # The following files require the latest JDK to be available. # The API can be provided by using a suitable boot.java.home # or by setting import.jdk @@ -196,3 +187,7 @@ # An empty value means all tests # Override as desired to run a specific set of tests jtreg.tests = + +# Check style configuration +# overridable name and version +checkstyle.name.version = checkstyle-5.4 diff -r 8caec3672381 -r 24540bbb4135 make/build.xml --- a/make/build.xml Mon Jul 11 22:31:52 2011 +0100 +++ b/make/build.xml Tue May 29 00:27:58 2012 +0100 @@ -83,7 +83,7 @@ - global property definitions - general top level targets - general diagnostic/debugging targets - - groups of targets for each tool: javac, javadoc, doclets, javah, javap, apt + - groups of targets for each tool: javac, javadoc, doclets, javah, javap Within each group, the following targets are provided, where applicable build-bootstrap-TOOL build the bootstrap version of the tool build-classes-TOOL build the classes for the tool @@ -131,8 +131,10 @@ + + @@ -243,11 +245,11 @@ /> - + @@ -263,6 +265,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + @@ -406,6 +443,7 @@ target.java.home = ${target.java.home} jtreg.home = ${jtreg.home} findbugs.home = ${findbugs.home} + checkstyle.home = ${checkstyle.home} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -690,6 +692,10 @@ + + + + @@ -856,7 +862,8 @@ source="${boot.javac.source}" target="${boot.javac.target}" executable="${boot.java.home}/bin/javac" - srcdir="${make.tools.dir}/CompileProperties" + srcdir="${make.tools.dir}" + includes="compileproperties/* anttasks/CompileProperties*" destdir="${build.toolclasses.dir}/" classpath="${ant.core.lib}" bootclasspath="${boot.java.home}/jre/lib/rt.jar" @@ -864,7 +871,7 @@ @@ -874,7 +881,8 @@ source="${boot.javac.source}" target="${boot.javac.target}" executable="${boot.java.home}/bin/javac" - srcdir="${make.tools.dir}/GenStubs" + srcdir="${make.tools.dir}" + includes="genstubs/* anttasks/GenStubs*" destdir="${build.toolclasses.dir}/" classpath="${ant.core.lib}" includeantruntime="false"> @@ -882,7 +890,7 @@ @@ -925,7 +933,6 @@ - @@ -963,7 +970,7 @@ samevm="@{samevm}" verbose="@{verbose}" failonerror="false" resultproperty="jtreg.@{name}.result" javacoptions="-g" - vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}:${build.classes.dir} @{jpda.jvmargs}"> + vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}${path.separator}${build.classes.dir} @{jpda.jvmargs}"> @@ -989,6 +996,16 @@ + + + + + + + + + diff -r 8caec3672381 -r 24540bbb4135 make/conf/checkstyle-emacs.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/conf/checkstyle-emacs.xsl Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,24 @@ + + + + + +Coding Style Check Results +-------------------------- +Total files checked: + Files with errors: + Total errors: + Errors per file: + + + + + + + + +:: + + + + diff -r 8caec3672381 -r 24540bbb4135 make/conf/checkstyle-langtools.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/conf/checkstyle-langtools.xml Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 8caec3672381 -r 24540bbb4135 make/jprt.properties --- a/make/jprt.properties Mon Jul 11 22:31:52 2011 +0100 +++ b/make/jprt.properties Tue May 29 00:27:58 2012 +0100 @@ -25,12 +25,55 @@ # Properties for jprt -# Use whatever release that the submitted job requests -jprt.tools.default.release=${jprt.submit.release} +# Locked down to jdk8 +jprt.tools.default.release=jdk8 # The different build flavors we want, we override here so we just get these 2 jprt.build.flavors=product,fastdebug +# Standard list of jprt build targets for this source tree +jprt.build.targets= \ + solaris_sparc_5.10-{product|fastdebug}, \ + solaris_sparcv9_5.10-{product|fastdebug}, \ + solaris_i586_5.10-{product|fastdebug}, \ + solaris_x64_5.10-{product|fastdebug}, \ + linux_i586_2.6-{product|fastdebug}, \ + linux_x64_2.6-{product|fastdebug}, \ + macosx_x64_10.7-{product|fastdebug}, \ + windows_i586_5.1-{product|fastdebug}, \ + windows_x64_5.2-{product|fastdebug} + +# Test target list (no fastdebug & limited c2 testing) +jprt.my.test.target.set= \ + solaris_sparc_5.10-product-c1-TESTNAME, \ + solaris_sparcv9_5.10-product-c2-TESTNAME, \ + solaris_i586_5.10-product-c1-TESTNAME, \ + solaris_x64_5.10-product-c2-TESTNAME, \ + linux_i586_2.6-product-{c1|c2}-TESTNAME, \ + linux_x64_2.6-product-c2-TESTNAME, \ + macosx_x64_10.7-product-c2-TESTNAME, \ + windows_i586_5.1-product-c1-TESTNAME, \ + windows_x64_5.2-product-c2-TESTNAME + +# Default test targets +jprt.make.rule.test.targets= \ + ${jprt.my.test.target.set:TESTNAME=jtreg} + # Directories to be excluded from the source bundles jprt.bundle.exclude.src.dirs=build dist webrev +# Test target list (no fastdebug & limited c2 testing) +jprt.my.test.target.set= \ + solaris_sparc_5.10-product-c1-TESTNAME, \ + solaris_sparcv9_5.10-product-c2-TESTNAME, \ + solaris_i586_5.10-product-c1-TESTNAME, \ + solaris_x64_5.10-product-c2-TESTNAME, \ + linux_i586_2.6-product-{c1|c2}-TESTNAME, \ + linux_x64_2.6-product-c2-TESTNAME, \ + macosx_x64_10.7-product-c2-TESTNAME, \ + windows_i586_5.1-product-c1-TESTNAME, \ + windows_x64_5.2-product-c2-TESTNAME + +# Default test targets +jprt.make.rule.test.targets= \ + ${jprt.my.test.target.set:TESTNAME=jtreg} diff -r 8caec3672381 -r 24540bbb4135 make/netbeans/README --- a/make/netbeans/README Mon Jul 11 22:31:52 2011 +0100 +++ b/make/netbeans/README Tue May 29 00:27:58 2012 +0100 @@ -7,7 +7,7 @@ repository. The repository contains a number of tools: - apt, javac, javadoc and its doclets, javah and javap. + javac, javadoc and its doclets, javah and javap. Build Properties. diff -r 8caec3672381 -r 24540bbb4135 make/netbeans/langtools/build.xml --- a/make/netbeans/langtools/build.xml Mon Jul 11 22:31:52 2011 +0100 +++ b/make/netbeans/langtools/build.xml Tue May 29 00:27:58 2012 +0100 @@ -261,7 +261,8 @@ - diff -r 8caec3672381 -r 24540bbb4135 make/test/lib/apt.sh --- a/make/test/lib/apt.sh Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @summary Verify the basic execution of the apt classes in classes.jar. - -TESTSRC=${TESTSRC:-.} -TOPDIR=${TESTSRC}/../../.. -TESTJAVAEXE="${TESTJAVA:+${TESTJAVA}/bin/}java" - -"${TESTJAVAEXE}" -Xbootclasspath/p:${TOPDIR}/dist/lib/classes.jar \ - com.sun.tools.apt.Main \ - -print "${TESTSRC}"/../HelloWorld.java > apt.tmp - -if diff ${TESTSRC}/../HelloWorld.apt.gold.txt apt.tmp ; then - echo "Test passed." -else - echo "Test failed." - exit 1 -fi diff -r 8caec3672381 -r 24540bbb4135 make/test/lib/src.gold.txt --- a/make/test/lib/src.gold.txt Mon Jul 11 22:31:52 2011 +0100 +++ b/make/test/lib/src.gold.txt Tue May 29 00:27:58 2012 +0100 @@ -1,14 +1,4 @@ com/sun/javadoc/package.html -com/sun/mirror/apt/package.html -com/sun/mirror/declaration/package.html -com/sun/mirror/overview.html -com/sun/mirror/type/package.html -com/sun/mirror/util/package.html -com/sun/tools/apt/Main.java -com/sun/tools/apt/main/Main.java -com/sun/tools/apt/resources/apt.properties -com/sun/tools/apt/resources/apt_ja.properties -com/sun/tools/apt/resources/apt_zh_CN.properties com/sun/tools/doclets/formats/html/markup/package.html com/sun/tools/doclets/formats/html/package.html com/sun/tools/doclets/formats/html/resources/standard.properties diff -r 8caec3672381 -r 24540bbb4135 make/tools/CompileProperties/CompileProperties.java --- a/make/tools/CompileProperties/CompileProperties.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,402 +0,0 @@ -/* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; - -/** Translates a .properties file into a .java file containing the - * definition of a java.util.Properties subclass which can then be - * compiled with javac.

- * - * Usage: java CompileProperties [path to .properties file] [path to .java file to be output] [super class] - * - * Infers the package by looking at the common suffix of the two - * inputs, eliminating "classes" from it. - * - * @author Scott Violet - * @author Kenneth Russell - */ - -public class CompileProperties { - - public static void main(String[] args) { - CompileProperties cp = new CompileProperties(); - boolean ok = cp.run(args); - if ( !ok ) { - System.exit(1); - } - } - - static interface Log { - void info(String msg); - void verbose(String msg); - void error(String msg, Exception e); - } - - private String propfiles[]; - private String outfiles[] ; - private String supers[] ; - private int compileCount = 0; - private boolean quiet = false; - private Log log; - - public void setLog(Log log) { - this.log = log; - } - - public boolean run(String[] args) { - if (log == null) { - log = new Log() { - public void error(String msg, Exception e) { - System.err.println("ERROR: CompileProperties: " + msg); - if ( e != null ) { - System.err.println("EXCEPTION: " + e.toString()); - e.printStackTrace(); - } - } - public void info(String msg) { - System.out.println(msg); - } - public void verbose(String msg) { - if (!quiet) - System.out.println(msg); - } - }; - } - - boolean ok = true; - /* Original usage */ - if (args.length == 2 && args[0].charAt(0) != '-' ) { - ok = createFile(args[0], args[1], "java.util.ListResourceBundle"); - } else if (args.length == 3) { - ok = createFile(args[0], args[1], args[2]); - } else if (args.length == 0) { - usage(log); - ok = false; - } else { - /* New batch usage */ - ok = parseOptions(args); - if ( ok && compileCount == 0 ) { - log.error("options parsed but no files to compile", null); - ok = false; - } - /* Need at least one file. */ - if ( !ok ) { - usage(log); - } else { - /* Process files */ - for ( int i = 0; i < compileCount && ok ; i++ ) { - ok = createFile(propfiles[i], outfiles[i], supers[i]); - } - } - } - return ok; - } - - private boolean parseOptions(String args[]) { - boolean ok = true; - if ( compileCount > 0 ) { - String new_propfiles[] = new String[compileCount + args.length]; - String new_outfiles[] = new String[compileCount + args.length]; - String new_supers[] = new String[compileCount + args.length]; - System.arraycopy(propfiles, 0, new_propfiles, 0, compileCount); - System.arraycopy(outfiles, 0, new_outfiles, 0, compileCount); - System.arraycopy(supers, 0, new_supers, 0, compileCount); - propfiles = new_propfiles; - outfiles = new_outfiles; - supers = new_supers; - } else { - propfiles = new String[args.length]; - outfiles = new String[args.length]; - supers = new String[args.length]; - } - - for ( int i = 0; i < args.length ; i++ ) { - if ( "-compile".equals(args[i]) && i+3 < args.length ) { - propfiles[compileCount] = args[++i]; - outfiles[compileCount] = args[++i]; - supers[compileCount] = args[++i]; - compileCount++; - } else if ( "-optionsfile".equals(args[i]) && i+1 < args.length ) { - String filename = args[++i]; - FileInputStream finput = null; - byte contents[] = null; - try { - finput = new FileInputStream(filename); - int byteCount = finput.available(); - if ( byteCount <= 0 ) { - log.error("The -optionsfile file is empty", null); - ok = false; - } else { - contents = new byte[byteCount]; - int bytesRead = finput.read(contents); - if ( byteCount != bytesRead ) { - log.error("Cannot read all of -optionsfile file", null); - ok = false; - } - } - } catch ( IOException e ) { - log.error("cannot open " + filename, e); - ok = false; - } - if ( finput != null ) { - try { - finput.close(); - } catch ( IOException e ) { - ok = false; - log.error("cannot close " + filename, e); - } - } - if ( ok = true && contents != null ) { - String tokens[] = (new String(contents)).split("\\s+"); - if ( tokens.length > 0 ) { - ok = parseOptions(tokens); - } - } - if ( !ok ) { - break; - } - } else if ( "-quiet".equals(args[i]) ) { - quiet = true; - } else { - log.error("argument error", null); - ok = false; - } - } - return ok; - } - - private boolean createFile(String propertiesPath, String outputPath, - String superClass) { - boolean ok = true; - log.verbose("parsing: " + propertiesPath); - Properties p = new Properties(); - try { - p.load(new FileInputStream(propertiesPath)); - } catch ( FileNotFoundException e ) { - ok = false; - log.error("Cannot find file " + propertiesPath, e); - } catch ( IOException e ) { - ok = false; - log.error("IO error on file " + propertiesPath, e); - } - if ( ok ) { - String packageName = inferPackageName(propertiesPath, outputPath); - log.verbose("inferred package name: " + packageName); - List sortedKeys = new ArrayList(); - for ( Object key : p.keySet() ) { - sortedKeys.add((String)key); - } - Collections.sort(sortedKeys); - Iterator keys = sortedKeys.iterator(); - - StringBuffer data = new StringBuffer(); - - while (keys.hasNext()) { - String key = keys.next(); - data.append(" { \"" + escape(key) + "\", \"" + - escape((String)p.get(key)) + "\" },\n"); - } - - // Get class name from java filename, not the properties filename. - // (zh_TW properties might be used to create zh_HK files) - File file = new File(outputPath); - String name = file.getName(); - int dotIndex = name.lastIndexOf('.'); - String className; - if (dotIndex == -1) { - className = name; - } else { - className = name.substring(0, dotIndex); - } - - String packageString = ""; - if (packageName != null && !packageName.equals("")) { - packageString = "package " + packageName + ";\n\n"; - } - - Writer writer = null; - try { - writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(outputPath), "8859_1")); - MessageFormat format = new MessageFormat(FORMAT); - writer.write(format.format(new Object[] { packageString, className, superClass, data })); - } catch ( IOException e ) { - ok = false; - log.error("IO error writing to file " + outputPath, e); - } - if ( writer != null ) { - try { - writer.flush(); - } catch ( IOException e ) { - ok = false; - log.error("IO error flush " + outputPath, e); - } - try { - writer.close(); - } catch ( IOException e ) { - ok = false; - log.error("IO error close " + outputPath, e); - } - } - log.verbose("wrote: " + outputPath); - } - return ok; - } - - private static void usage(Log log) { - log.info("usage:"); - log.info(" java CompileProperties path_to_properties_file path_to_java_output_file [super_class]"); - log.info(" -OR-"); - log.info(" java CompileProperties {-compile path_to_properties_file path_to_java_output_file super_class} -or- -optionsfile filename"); - log.info(""); - log.info("Example:"); - log.info(" java CompileProperties -compile test.properties test.java java.util.ListResourceBundle"); - log.info(" java CompileProperties -optionsfile option_file"); - log.info("option_file contains: -compile test.properties test.java java.util.ListResourceBundle"); - } - - private static String escape(String theString) { - // This is taken from Properties.saveConvert with changes for Java strings - int len = theString.length(); - StringBuffer outBuffer = new StringBuffer(len*2); - - for(int x=0; x 0x007e)) { - outBuffer.append('\\'); - outBuffer.append('u'); - outBuffer.append(toHex((aChar >> 12) & 0xF)); - outBuffer.append(toHex((aChar >> 8) & 0xF)); - outBuffer.append(toHex((aChar >> 4) & 0xF)); - outBuffer.append(toHex( aChar & 0xF)); - } else { - if (specialSaveChars.indexOf(aChar) != -1) { - outBuffer.append('\\'); - } - outBuffer.append(aChar); - } - } - } - return outBuffer.toString(); - } - - private static String inferPackageName(String inputPath, String outputPath) { - // Normalize file names - inputPath = new File(inputPath).getPath(); - outputPath = new File(outputPath).getPath(); - // Split into components - String sep; - if (File.separatorChar == '\\') { - sep = "\\\\"; - } else { - sep = File.separator; - } - String[] inputs = inputPath.split(sep); - String[] outputs = outputPath.split(sep); - // Match common names, eliminating first "classes" entry from - // each if present - int inStart = 0; - int inEnd = inputs.length - 2; - int outEnd = outputs.length - 2; - int i = inEnd; - int j = outEnd; - while (i >= 0 && j >= 0) { - if (!inputs[i].equals(outputs[j]) || - (inputs[i].equals("gensrc") && inputs[j].equals("gensrc"))) { - ++i; - ++j; - break; - } - --i; - --j; - } - String result; - if (i < 0 || j < 0 || i >= inEnd || j >= outEnd) { - result = ""; - } else { - if (inputs[i].equals("classes") && outputs[j].equals("classes")) { - ++i; - } - inStart = i; - StringBuffer buf = new StringBuffer(); - for (i = inStart; i <= inEnd; i++) { - buf.append(inputs[i]); - if (i < inEnd) { - buf.append('.'); - } - } - result = buf.toString(); - } - return result; - } - - private static final String FORMAT = - "{0}" + - "public final class {1} extends {2} '{'\n" + - " protected final Object[][] getContents() '{'\n" + - " return new Object[][] '{'\n" + - "{3}" + - " };\n" + - " }\n" + - "}\n"; - - // This comes from Properties - private static char toHex(int nibble) { - return hexDigit[(nibble & 0xF)]; - } - - // This comes from Properties - private static final char[] hexDigit = { - '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' - }; - - // Note: different from that in Properties - private static final String specialSaveChars = "\""; -} diff -r 8caec3672381 -r 24540bbb4135 make/tools/CompileProperties/CompilePropertiesTask.java --- a/make/tools/CompileProperties/CompilePropertiesTask.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.MatchingTask; - -public class CompilePropertiesTask extends MatchingTask { - public void setSrcDir(File srcDir) { - this.srcDir = srcDir; - } - - public void setDestDir(File destDir) { - this.destDir = destDir; - } - - public void setSuperclass(String superclass) { - this.superclass = superclass; - } - - @Override - public void execute() { - CompileProperties.Log log = new CompileProperties.Log() { - public void error(String msg, Exception e) { - log(msg, Project.MSG_ERR); - } - public void info(String msg) { - log(msg, Project.MSG_INFO); - } - public void verbose(String msg) { - log(msg, Project.MSG_VERBOSE); - } - }; - List mainOpts = new ArrayList(); - int count = 0; - DirectoryScanner s = getDirectoryScanner(srcDir); - for (String path: s.getIncludedFiles()) { - if (path.endsWith(".properties")) { - String destPath = - path.substring(0, path.length() - ".properties".length()) + - ".java"; - File srcFile = new File(srcDir, path); - File destFile = new File(destDir, destPath); - // Arguably, the comparison in the next line should be ">", not ">=" - // but that assumes the resolution of the last modified time is fine - // grained enough; in practice, it is better to use ">=". - if (destFile.exists() && destFile.lastModified() >= srcFile.lastModified()) - continue; - destFile.getParentFile().mkdirs(); - mainOpts.add("-compile"); - mainOpts.add(srcFile.getPath()); - mainOpts.add(destFile.getPath()); - mainOpts.add(superclass); - count++; - } - } - if (mainOpts.size() > 0) { - log("Generating " + count + " resource files to " + destDir, Project.MSG_INFO); - CompileProperties cp = new CompileProperties(); - cp.setLog(log); - boolean ok = cp.run(mainOpts.toArray(new String[mainOpts.size()])); - if (!ok) - throw new BuildException("CompileProperties failed."); - } - } - - private File srcDir; - private File destDir; - private String superclass = "java.util.ListResourceBundle"; -} diff -r 8caec3672381 -r 24540bbb4135 make/tools/GenStubs/GenStubs.java --- a/make/tools/GenStubs/GenStubs.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,448 +0,0 @@ -/* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.io.*; -import java.util.*; -import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.StandardLocation; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.taskdefs.MatchingTask; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Reference; - - -import com.sun.source.tree.CompilationUnitTree; -import com.sun.source.util.JavacTask; -import com.sun.tools.javac.api.JavacTool; -import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.TypeTags; -import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; -import com.sun.tools.javac.tree.JCTree.JCFieldAccess; -import com.sun.tools.javac.tree.JCTree.JCIdent; -import com.sun.tools.javac.tree.JCTree.JCImport; -import com.sun.tools.javac.tree.JCTree.JCLiteral; -import com.sun.tools.javac.tree.JCTree.JCMethodDecl; -import com.sun.tools.javac.tree.JCTree.JCModifiers; -import com.sun.tools.javac.tree.JCTree.JCVariableDecl; -import com.sun.tools.javac.tree.Pretty; -import com.sun.tools.javac.tree.TreeMaker; -import com.sun.tools.javac.tree.TreeScanner; -import com.sun.tools.javac.tree.TreeTranslator; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.ListBuffer; -import com.sun.tools.javac.util.Name; -import javax.tools.JavaFileManager; - -/** - * Generate stub source files by removing implementation details from input files. - * - * This is a special purpose stub generator, specific to the needs of generating - * stub files for JDK 7 API that are needed to compile langtools files that depend - * on that API. The stub generator works by removing as much of the API source code - * as possible without affecting the public signature, in order to reduce the - * transitive closure of the API being referenced. The resulting stubs can be - * put on the langtools sourcepath with -implicit:none to compile the langtools - * files that depend on the JDK 7 API. - * - * Usage: - * genstubs -s -sourcepath - * - * The specified class names are looked up on the sourcepath, and corresponding - * stubs are written to the source output directory. - * - * Classes are parsed into javac ASTs, then processed with a javac TreeTranslator - * to remove implementation details, and written out in the source output directory. - * Documentation comments and annotations are removed. Method bodies are removed - * and methods are marked native. Private and package-private field definitions - * have their initializers replace with 0, 0.0, false, null as appropriate. - * - * An Ant task, Main$Ant is also provided. Files are specified with an implicit - * fileset, using srcdir as a base directory. The set of files to be included - * is specified with an includes attribute or nested set. However, - * unlike a normal fileset, an empty includes attribute means "no files" instead - * of "all files". The Ant task also accepts "fork=true" and classpath attribute - * or nested element to run GenStubs in a separate VM with the specified - * path. This is likely necessary if a JDK 7 parser is required to read the - * JDK 7 input files. - */ - -public class GenStubs { - static class Fault extends Exception { - private static final long serialVersionUID = 0; - Fault(String message) { - super(message); - } - Fault(String message, Throwable cause) { - super(message); - initCause(cause); - } - } - - public static void main(String[] args) { - boolean ok = new GenStubs().run(args); - if (!ok) - System.exit(1); - } - - boolean run(String... args) { - File outdir = null; - String sourcepath = null; - List classes = new ArrayList(); - for (ListIterator iter = Arrays.asList(args).listIterator(); iter.hasNext(); ) { - String arg = iter.next(); - if (arg.equals("-s") && iter.hasNext()) - outdir = new File(iter.next()); - else if (arg.equals("-sourcepath") && iter.hasNext()) - sourcepath = iter.next(); - else if (arg.startsWith("-")) - throw new IllegalArgumentException(arg); - else { - classes.add(arg); - while (iter.hasNext()) - classes.add(iter.next()); - } - } - - return run(sourcepath, outdir, classes); - } - - boolean run(String sourcepath, File outdir, List classes) { - //System.err.println("run: sourcepath:" + sourcepath + " outdir:" + outdir + " classes:" + classes); - if (sourcepath == null) - throw new IllegalArgumentException("sourcepath not set"); - if (outdir == null) - throw new IllegalArgumentException("source output dir not set"); - - JavacTool tool = JavacTool.create(); - StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); - - try { - fm.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outdir)); - fm.setLocation(StandardLocation.SOURCE_PATH, splitPath(sourcepath)); - List files = new ArrayList(); - for (String c: classes) { - JavaFileObject fo = fm.getJavaFileForInput( - StandardLocation.SOURCE_PATH, c, JavaFileObject.Kind.SOURCE); - if (fo == null) - error("class not found: " + c); - else - files.add(fo); - } - - JavacTask t = tool.getTask(null, fm, null, null, null, files); - Iterable trees = t.parse(); - for (CompilationUnitTree tree: trees) { - makeStub(fm, tree); - } - } catch (IOException e) { - error("IO error " + e, e); - } - - return (errors == 0); - } - - void makeStub(StandardJavaFileManager fm, CompilationUnitTree tree) throws IOException { - CompilationUnitTree tree2 = new StubMaker().translate(tree); - CompilationUnitTree tree3 = new ImportCleaner(fm).removeRedundantImports(tree2); - - String className = fm.inferBinaryName(StandardLocation.SOURCE_PATH, tree.getSourceFile()); - JavaFileObject fo = fm.getJavaFileForOutput(StandardLocation.SOURCE_OUTPUT, - className, JavaFileObject.Kind.SOURCE, null); - // System.err.println("Writing " + className + " to " + fo.getName()); - Writer out = fo.openWriter(); - try { - new Pretty(out, true).printExpr((JCTree) tree3); - } finally { - out.close(); - } - } - - List splitPath(String path) { - List list = new ArrayList(); - for (String p: path.split(File.pathSeparator)) { - if (p.length() > 0) - list.add(new File(p)); - } - return list; - } - - void error(String message) { - System.err.println(message); - errors++; - } - - void error(String message, Throwable cause) { - error(message); - } - - int errors; - - class StubMaker extends TreeTranslator { - CompilationUnitTree translate(CompilationUnitTree tree) { - return super.translate((JCCompilationUnit) tree); - } - - /** - * compilation units: remove javadoc comments - * -- required, in order to remove @deprecated tags, since we - * (separately) remove all annotations, including @Deprecated - */ - public void visitTopLevel(JCCompilationUnit tree) { - super.visitTopLevel(tree); - tree.docComments = Collections.emptyMap(); - } - - /** - * methods: remove method bodies, make methods native - */ - @Override - public void visitMethodDef(JCMethodDecl tree) { - tree.mods = translate(tree.mods); - tree.restype = translate(tree.restype); - tree.typarams = translateTypeParams(tree.typarams); - tree.params = translateVarDefs(tree.params); - tree.thrown = translate(tree.thrown); - if (tree.restype != null && tree.body != null) { - tree.mods.flags |= Flags.NATIVE; - tree.body = null; - } - result = tree; - } - - /** - * modifiers: remove annotations - */ - @Override - public void visitModifiers(JCModifiers tree) { - tree.annotations = com.sun.tools.javac.util.List.nil(); - result = tree; - } - - /** - * field definitions: replace initializers with 0, 0.0, false etc - * when possible -- i.e. leave public, protected initializers alone - */ - @Override - public void visitVarDef(JCVariableDecl tree) { - tree.mods = translate(tree.mods); - tree.vartype = translate(tree.vartype); - if (tree.init != null) { - if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0) - tree.init = translate(tree.init); - else { - String t = tree.vartype.toString(); - if (t.equals("boolean")) - tree.init = new JCLiteral(TypeTags.BOOLEAN, 0) { }; - else if (t.equals("byte")) - tree.init = new JCLiteral(TypeTags.BYTE, 0) { }; - else if (t.equals("char")) - tree.init = new JCLiteral(TypeTags.CHAR, 0) { }; - else if (t.equals("double")) - tree.init = new JCLiteral(TypeTags.DOUBLE, 0.d) { }; - else if (t.equals("float")) - tree.init = new JCLiteral(TypeTags.FLOAT, 0.f) { }; - else if (t.equals("int")) - tree.init = new JCLiteral(TypeTags.INT, 0) { }; - else if (t.equals("long")) - tree.init = new JCLiteral(TypeTags.LONG, 0) { }; - else if (t.equals("short")) - tree.init = new JCLiteral(TypeTags.SHORT, 0) { }; - else - tree.init = new JCLiteral(TypeTags.BOT, null) { }; - } - } - result = tree; - } - } - - class ImportCleaner extends TreeScanner { - private Set names = new HashSet(); - private TreeMaker m; - - ImportCleaner(JavaFileManager fm) { - // ImportCleaner itself doesn't require a filemanager, but instantiating - // a TreeMaker does, indirectly (via ClassReader, sigh) - Context c = new Context(); - c.put(JavaFileManager.class, fm); - m = TreeMaker.instance(c); - } - - CompilationUnitTree removeRedundantImports(CompilationUnitTree t) { - JCCompilationUnit tree = (JCCompilationUnit) t; - tree.accept(this); - ListBuffer defs = new ListBuffer(); - for (JCTree def: tree.defs) { - if (def.getTag() == JCTree.IMPORT) { - JCImport imp = (JCImport) def; - if (imp.qualid.getTag() == JCTree.SELECT) { - JCFieldAccess qualid = (JCFieldAccess) imp.qualid; - if (!qualid.name.toString().equals("*") - && !names.contains(qualid.name)) { - continue; - } - } - } - defs.add(def); - } - return m.TopLevel(tree.packageAnnotations, tree.pid, defs.toList()); - } - - @Override - public void visitImport(JCImport tree) { } // ignore names found in imports - - @Override - public void visitIdent(JCIdent tree) { - names.add(tree.name); - } - - @Override - public void visitSelect(JCFieldAccess tree) { - super.visitSelect(tree); - names.add(tree.name); - } - } - - //---------- Ant Invocation ------------------------------------------------ - - public static class Ant extends MatchingTask { - private File srcDir; - private File destDir; - private boolean fork; - private Path classpath; - private String includes; - - public void setSrcDir(File dir) { - this.srcDir = dir; - } - - public void setDestDir(File dir) { - this.destDir = dir; - } - - public void setFork(boolean v) { - this.fork = v; - } - - public void setClasspath(Path cp) { - if (classpath == null) - classpath = cp; - else - classpath.append(cp); - } - - public Path createClasspath() { - if (classpath == null) { - classpath = new Path(getProject()); - } - return classpath.createPath(); - } - - public void setClasspathRef(Reference r) { - createClasspath().setRefid(r); - } - - public void setIncludes(String includes) { - super.setIncludes(includes); - this.includes = includes; - } - - @Override - public void execute() { - if (includes != null && includes.trim().isEmpty()) - return; - - DirectoryScanner s = getDirectoryScanner(srcDir); - String[] files = s.getIncludedFiles(); -// System.err.println("Ant.execute: srcDir " + srcDir); -// System.err.println("Ant.execute: destDir " + destDir); -// System.err.println("Ant.execute: files " + Arrays.asList(files)); - - files = filter(srcDir, destDir, files); - if (files.length == 0) - return; - System.out.println("Generating " + files.length + " stub files to " + destDir); - - List classNames = new ArrayList(); - for (String file: files) { - classNames.add(file.replaceAll(".java$", "").replace('/', '.')); - } - - if (!fork) { - GenStubs m = new GenStubs(); - boolean ok = m.run(srcDir.getPath(), destDir, classNames); - if (!ok) - throw new BuildException("genstubs failed"); - } else { - List cmd = new ArrayList(); - String java_home = System.getProperty("java.home"); - cmd.add(new File(new File(java_home, "bin"), "java").getPath()); - if (classpath != null) - cmd.add("-Xbootclasspath/p:" + classpath); - cmd.add(GenStubs.class.getName()); - cmd.add("-sourcepath"); - cmd.add(srcDir.getPath()); - cmd.add("-s"); - cmd.add(destDir.getPath()); - cmd.addAll(classNames); - //System.err.println("GenStubs exec " + cmd); - ProcessBuilder pb = new ProcessBuilder(cmd); - pb.redirectErrorStream(true); - try { - Process p = pb.start(); - BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); - try { - String line; - while ((line = in.readLine()) != null) - System.out.println(line); - } finally { - in.close(); - } - int rc = p.waitFor(); - if (rc != 0) - throw new BuildException("genstubs failed"); - } catch (IOException e) { - throw new BuildException("genstubs failed", e); - } catch (InterruptedException e) { - throw new BuildException("genstubs failed", e); - } - } - } - - String[] filter(File srcDir, File destDir, String[] files) { - List results = new ArrayList(); - for (String f: files) { - long srcTime = new File(srcDir, f).lastModified(); - long destTime = new File(destDir, f).lastModified(); - if (srcTime > destTime) - results.add(f); - } - return results.toArray(new String[results.size()]); - } - } -} diff -r 8caec3672381 -r 24540bbb4135 make/tools/SelectTool/SelectToolTask.java --- a/make/tools/SelectTool/SelectToolTask.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,284 +0,0 @@ -/* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import javax.swing.SwingUtilities; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; - -/** - * Task to allow the user to control langtools tools built when using NetBeans. - * - * There are two primary modes. - * 1) Property mode. In this mode, property names are provided to get values - * that may be specified by the user, either directly in a GUI dialog, or - * read from a properties file. If the GUI dialog is invoked, values may - * optionally be set for future use. - * 2) Setup mode. In this mode, no property names are provided, and the GUI - * is invoked to allow the user to set or reset values for use in property mode. - */ -public class SelectToolTask extends Task { - /** - * Set the location of the private properties file used to keep the retain - * user preferences for this repository. - */ - public void setPropertyFile(File propertyFile) { - this.propertyFile = propertyFile; - } - - /** - * Set the name of the property which will be set to the name of the - * selected tool, if any. If no tool is selected, the property will - * remain unset. - */ - public void setToolProperty(String toolProperty) { - this.toolProperty = toolProperty; - } - - /** - * Set the name of the property which will be set to the execution args of the - * selected tool, if any. The args default to an empty string. - */ - public void setArgsProperty(String argsProperty) { - this.argsProperty = argsProperty; - } - - /** - * Specify whether or not to pop up a dialog if the user has not specified - * a default value for a property. - */ - public void setAskIfUnset(boolean askIfUnset) { - this.askIfUnset = askIfUnset; - } - - @Override - public void execute() { - Project p = getProject(); - - Properties props = readProperties(propertyFile); - toolName = props.getProperty("tool.name"); - if (toolName != null) { - toolArgs = props.getProperty(toolName + ".args", ""); - } - - if (toolProperty == null || - askIfUnset && (toolName == null - || (argsProperty != null && toolArgs == null))) { - showGUI(props); - } - - // finally, return required values, if any - if (toolProperty != null && !(toolName == null || toolName.equals(""))) { - p.setProperty(toolProperty, toolName); - - if (argsProperty != null && toolArgs != null) - p.setProperty(argsProperty, toolArgs); - } - } - - void showGUI(Properties fileProps) { - Properties guiProps = new Properties(fileProps); - JOptionPane p = createPane(guiProps); - p.createDialog("Select Tool").setVisible(true); - - toolName = (String) toolChoice.getSelectedItem(); - toolArgs = argsField.getText(); - - if (defaultCheck.isSelected()) { - if (toolName.equals("")) { - fileProps.remove("tool.name"); - } else { - fileProps.put("tool.name", toolName); - fileProps.put(toolName + ".args", toolArgs); - } - writeProperties(propertyFile, fileProps); - } - } - - JOptionPane createPane(final Properties props) { - JPanel body = new JPanel(new GridBagLayout()); - GridBagConstraints lc = new GridBagConstraints(); - lc.insets.right = 10; - lc.insets.bottom = 3; - GridBagConstraints fc = new GridBagConstraints(); - fc.anchor = GridBagConstraints.WEST; - fc.gridx = 1; - fc.gridwidth = GridBagConstraints.REMAINDER; - fc.insets.bottom = 3; - - JLabel toolLabel = new JLabel("Tool:"); - body.add(toolLabel, lc); - String[] toolChoices = { "apt", "javac", "javadoc", "javah", "javap" }; - if (true || toolProperty == null) { - // include empty value in setup mode - List l = new ArrayList(Arrays.asList(toolChoices)); - l.add(0, ""); - toolChoices = l.toArray(new String[l.size()]); - } - toolChoice = new JComboBox(toolChoices); - if (toolName != null) - toolChoice.setSelectedItem(toolName); - toolChoice.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - String tn = (String) e.getItem(); - argsField.setText(getDefaultArgsForTool(props, tn)); - if (toolProperty != null) - okButton.setEnabled(!tn.equals("")); - } - }); - body.add(toolChoice, fc); - - argsField = new JTextField(getDefaultArgsForTool(props, toolName), 40); - if (toolProperty == null || argsProperty != null) { - JLabel argsLabel = new JLabel("Args:"); - body.add(argsLabel, lc); - body.add(argsField, fc); - argsField.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - } - public void focusLost(FocusEvent e) { - String toolName = (String) toolChoice.getSelectedItem(); - if (toolName.length() > 0) - props.put(toolName + ".args", argsField.getText()); - } - }); - } - - defaultCheck = new JCheckBox("Set as default"); - if (toolProperty == null) - defaultCheck.setSelected(true); - else - body.add(defaultCheck, fc); - - final JOptionPane p = new JOptionPane(body); - okButton = new JButton("OK"); - okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.equals(""))); - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p); - d.setVisible(false); - } - }); - p.setOptions(new Object[] { okButton }); - - return p; - } - - Properties readProperties(File file) { - Properties p = new Properties(); - if (file != null && file.exists()) { - Reader in = null; - try { - in = new BufferedReader(new FileReader(file)); - p.load(in); - in.close(); - } catch (IOException e) { - throw new BuildException("error reading property file", e); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - throw new BuildException("cannot close property file", e); - } - } - } - } - return p; - } - - void writeProperties(File file, Properties p) { - if (file != null) { - Writer out = null; - try { - File dir = file.getParentFile(); - if (dir != null && !dir.exists()) - dir.mkdirs(); - out = new BufferedWriter(new FileWriter(file)); - p.store(out, "langtools properties"); - out.close(); - } catch (IOException e) { - throw new BuildException("error writing property file", e); - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException e) { - throw new BuildException("cannot close property file", e); - } - } - } - } - } - - String getDefaultArgsForTool(Properties props, String tn) { - return (tn == null || tn.equals("")) ? "" : props.getProperty(tn + ".args", ""); - } - - // Ant task parameters - private boolean askIfUnset; - private String toolProperty; - private String argsProperty; - private File propertyFile; - - // GUI components - private JComboBox toolChoice; - private JTextField argsField; - private JCheckBox defaultCheck; - private JButton okButton; - - // Result values for the client - private String toolName; - private String toolArgs; -} diff -r 8caec3672381 -r 24540bbb4135 make/tools/anttasks/CompilePropertiesTask.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/tools/anttasks/CompilePropertiesTask.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package anttasks; + +import compileproperties.CompileProperties; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.MatchingTask; + +public class CompilePropertiesTask extends MatchingTask { + public void setSrcDir(File srcDir) { + this.srcDir = srcDir; + } + + public void setDestDir(File destDir) { + this.destDir = destDir; + } + + public void setSuperclass(String superclass) { + this.superclass = superclass; + } + + @Override + public void execute() { + CompileProperties.Log log = new CompileProperties.Log() { + public void error(String msg, Exception e) { + log(msg, Project.MSG_ERR); + } + public void info(String msg) { + log(msg, Project.MSG_INFO); + } + public void verbose(String msg) { + log(msg, Project.MSG_VERBOSE); + } + }; + List mainOpts = new ArrayList(); + int count = 0; + DirectoryScanner s = getDirectoryScanner(srcDir); + for (String path: s.getIncludedFiles()) { + if (path.endsWith(".properties")) { + String destPath = + path.substring(0, path.length() - ".properties".length()) + + ".java"; + File srcFile = new File(srcDir, path); + File destFile = new File(destDir, destPath); + // Arguably, the comparison in the next line should be ">", not ">=" + // but that assumes the resolution of the last modified time is fine + // grained enough; in practice, it is better to use ">=". + if (destFile.exists() && destFile.lastModified() >= srcFile.lastModified()) + continue; + destFile.getParentFile().mkdirs(); + mainOpts.add("-compile"); + mainOpts.add(srcFile.getPath()); + mainOpts.add(destFile.getPath()); + mainOpts.add(superclass); + count++; + } + } + if (mainOpts.size() > 0) { + log("Generating " + count + " resource files to " + destDir, Project.MSG_INFO); + CompileProperties cp = new CompileProperties(); + cp.setLog(log); + boolean ok = cp.run(mainOpts.toArray(new String[mainOpts.size()])); + if (!ok) + throw new BuildException("CompileProperties failed."); + } + } + + private File srcDir; + private File destDir; + private String superclass = "java.util.ListResourceBundle"; +} diff -r 8caec3672381 -r 24540bbb4135 make/tools/anttasks/GenStubsTask.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/tools/anttasks/GenStubsTask.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package anttasks; + +import genstubs.GenStubs; + +import java.io.*; +import java.util.*; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.taskdefs.MatchingTask; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Reference; + +/** + * Files are specified with an implicit fileset, using srcdir as a base directory. + * The set of files to be included is specified with an includes attribute or + * nested set. However, unlike a normal fileset, an empty includes attribute + * means "no files" instead of "all files". The Ant task also accepts "fork=true" and + * classpath attribute or nested element to run GenStubs in a separate VM + * with the specified path. This is likely necessary if a JDK 7 parser is required to read the + * JDK 7 input files. + */ +public class GenStubsTask extends MatchingTask { + private File srcDir; + private File destDir; + private boolean fork; + private Path classpath; + private String includes; + + public void setSrcDir(File dir) { + this.srcDir = dir; + } + + public void setDestDir(File dir) { + this.destDir = dir; + } + + public void setFork(boolean v) { + this.fork = v; + } + + public void setClasspath(Path cp) { + if (classpath == null) + classpath = cp; + else + classpath.append(cp); + } + + public Path createClasspath() { + if (classpath == null) { + classpath = new Path(getProject()); + } + return classpath.createPath(); + } + + public void setClasspathRef(Reference r) { + createClasspath().setRefid(r); + } + + public void setIncludes(String includes) { + super.setIncludes(includes); + this.includes = includes; + } + + @Override + public void execute() { + if (includes != null && includes.trim().isEmpty()) + return; + + DirectoryScanner s = getDirectoryScanner(srcDir); + String[] files = s.getIncludedFiles(); +// System.err.println("Ant.execute: srcDir " + srcDir); +// System.err.println("Ant.execute: destDir " + destDir); +// System.err.println("Ant.execute: files " + Arrays.asList(files)); + + files = filter(srcDir, destDir, files); + if (files.length == 0) + return; + System.out.println("Generating " + files.length + " stub files to " + destDir); + + List classNames = new ArrayList(); + for (String file: files) { + classNames.add(file.replaceAll(".java$", "").replace('/', '.')); + } + + if (!fork) { + GenStubs m = new GenStubs(); + boolean ok = m.run(srcDir.getPath(), destDir, classNames); + if (!ok) + throw new BuildException("genstubs failed"); + } else { + List cmd = new ArrayList(); + String java_home = System.getProperty("java.home"); + cmd.add(new File(new File(java_home, "bin"), "java").getPath()); + if (classpath != null) + cmd.add("-Xbootclasspath/p:" + classpath); + cmd.add(GenStubs.class.getName()); + cmd.add("-sourcepath"); + cmd.add(srcDir.getPath()); + cmd.add("-s"); + cmd.add(destDir.getPath()); + cmd.addAll(classNames); + //System.err.println("GenStubs exec " + cmd); + ProcessBuilder pb = new ProcessBuilder(cmd); + pb.redirectErrorStream(true); + try { + Process p = pb.start(); + BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); + try { + String line; + while ((line = in.readLine()) != null) + System.out.println(line); + } finally { + in.close(); + } + int rc = p.waitFor(); + if (rc != 0) + throw new BuildException("genstubs failed"); + } catch (IOException e) { + throw new BuildException("genstubs failed", e); + } catch (InterruptedException e) { + throw new BuildException("genstubs failed", e); + } + } + } + + String[] filter(File srcDir, File destDir, String[] files) { + List results = new ArrayList(); + for (String f: files) { + long srcTime = new File(srcDir, f).lastModified(); + long destTime = new File(destDir, f).lastModified(); + if (srcTime > destTime) + results.add(f); + } + return results.toArray(new String[results.size()]); + } +} diff -r 8caec3672381 -r 24540bbb4135 make/tools/anttasks/SelectToolTask.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/tools/anttasks/SelectToolTask.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,286 @@ +/* + * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package anttasks; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import javax.swing.SwingUtilities; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; + +/** + * Task to allow the user to control langtools tools built when using NetBeans. + * + * There are two primary modes. + * 1) Property mode. In this mode, property names are provided to get values + * that may be specified by the user, either directly in a GUI dialog, or + * read from a properties file. If the GUI dialog is invoked, values may + * optionally be set for future use. + * 2) Setup mode. In this mode, no property names are provided, and the GUI + * is invoked to allow the user to set or reset values for use in property mode. + */ +public class SelectToolTask extends Task { + /** + * Set the location of the private properties file used to keep the retain + * user preferences for this repository. + */ + public void setPropertyFile(File propertyFile) { + this.propertyFile = propertyFile; + } + + /** + * Set the name of the property which will be set to the name of the + * selected tool, if any. If no tool is selected, the property will + * remain unset. + */ + public void setToolProperty(String toolProperty) { + this.toolProperty = toolProperty; + } + + /** + * Set the name of the property which will be set to the execution args of the + * selected tool, if any. The args default to an empty string. + */ + public void setArgsProperty(String argsProperty) { + this.argsProperty = argsProperty; + } + + /** + * Specify whether or not to pop up a dialog if the user has not specified + * a default value for a property. + */ + public void setAskIfUnset(boolean askIfUnset) { + this.askIfUnset = askIfUnset; + } + + @Override + public void execute() { + Project p = getProject(); + + Properties props = readProperties(propertyFile); + toolName = props.getProperty("tool.name"); + if (toolName != null) { + toolArgs = props.getProperty(toolName + ".args", ""); + } + + if (toolProperty == null || + askIfUnset && (toolName == null + || (argsProperty != null && toolArgs == null))) { + showGUI(props); + } + + // finally, return required values, if any + if (toolProperty != null && !(toolName == null || toolName.equals(""))) { + p.setProperty(toolProperty, toolName); + + if (argsProperty != null && toolArgs != null) + p.setProperty(argsProperty, toolArgs); + } + } + + void showGUI(Properties fileProps) { + Properties guiProps = new Properties(fileProps); + JOptionPane p = createPane(guiProps); + p.createDialog("Select Tool").setVisible(true); + + toolName = (String) toolChoice.getSelectedItem(); + toolArgs = argsField.getText(); + + if (defaultCheck.isSelected()) { + if (toolName.equals("")) { + fileProps.remove("tool.name"); + } else { + fileProps.put("tool.name", toolName); + fileProps.put(toolName + ".args", toolArgs); + } + writeProperties(propertyFile, fileProps); + } + } + + JOptionPane createPane(final Properties props) { + JPanel body = new JPanel(new GridBagLayout()); + GridBagConstraints lc = new GridBagConstraints(); + lc.insets.right = 10; + lc.insets.bottom = 3; + GridBagConstraints fc = new GridBagConstraints(); + fc.anchor = GridBagConstraints.WEST; + fc.gridx = 1; + fc.gridwidth = GridBagConstraints.REMAINDER; + fc.insets.bottom = 3; + + JLabel toolLabel = new JLabel("Tool:"); + body.add(toolLabel, lc); + String[] toolChoices = { "apt", "javac", "javadoc", "javah", "javap" }; + if (true || toolProperty == null) { + // include empty value in setup mode + List l = new ArrayList(Arrays.asList(toolChoices)); + l.add(0, ""); + toolChoices = l.toArray(new String[l.size()]); + } + toolChoice = new JComboBox(toolChoices); + if (toolName != null) + toolChoice.setSelectedItem(toolName); + toolChoice.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + String tn = (String) e.getItem(); + argsField.setText(getDefaultArgsForTool(props, tn)); + if (toolProperty != null) + okButton.setEnabled(!tn.equals("")); + } + }); + body.add(toolChoice, fc); + + argsField = new JTextField(getDefaultArgsForTool(props, toolName), 40); + if (toolProperty == null || argsProperty != null) { + JLabel argsLabel = new JLabel("Args:"); + body.add(argsLabel, lc); + body.add(argsField, fc); + argsField.addFocusListener(new FocusListener() { + public void focusGained(FocusEvent e) { + } + public void focusLost(FocusEvent e) { + String toolName = (String) toolChoice.getSelectedItem(); + if (toolName.length() > 0) + props.put(toolName + ".args", argsField.getText()); + } + }); + } + + defaultCheck = new JCheckBox("Set as default"); + if (toolProperty == null) + defaultCheck.setSelected(true); + else + body.add(defaultCheck, fc); + + final JOptionPane p = new JOptionPane(body); + okButton = new JButton("OK"); + okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.equals(""))); + okButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p); + d.setVisible(false); + } + }); + p.setOptions(new Object[] { okButton }); + + return p; + } + + Properties readProperties(File file) { + Properties p = new Properties(); + if (file != null && file.exists()) { + Reader in = null; + try { + in = new BufferedReader(new FileReader(file)); + p.load(in); + in.close(); + } catch (IOException e) { + throw new BuildException("error reading property file", e); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + throw new BuildException("cannot close property file", e); + } + } + } + } + return p; + } + + void writeProperties(File file, Properties p) { + if (file != null) { + Writer out = null; + try { + File dir = file.getParentFile(); + if (dir != null && !dir.exists()) + dir.mkdirs(); + out = new BufferedWriter(new FileWriter(file)); + p.store(out, "langtools properties"); + out.close(); + } catch (IOException e) { + throw new BuildException("error writing property file", e); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + throw new BuildException("cannot close property file", e); + } + } + } + } + } + + String getDefaultArgsForTool(Properties props, String tn) { + return (tn == null || tn.equals("")) ? "" : props.getProperty(tn + ".args", ""); + } + + // Ant task parameters + private boolean askIfUnset; + private String toolProperty; + private String argsProperty; + private File propertyFile; + + // GUI components + private JComboBox toolChoice; + private JTextField argsField; + private JCheckBox defaultCheck; + private JButton okButton; + + // Result values for the client + private String toolName; + private String toolArgs; +} diff -r 8caec3672381 -r 24540bbb4135 make/tools/compileproperties/CompileProperties.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/tools/compileproperties/CompileProperties.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,404 @@ +/* + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compileproperties; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; + +/** Translates a .properties file into a .java file containing the + * definition of a java.util.Properties subclass which can then be + * compiled with javac.

+ * + * Usage: java CompileProperties [path to .properties file] [path to .java file to be output] [super class] + * + * Infers the package by looking at the common suffix of the two + * inputs, eliminating "classes" from it. + * + * @author Scott Violet + * @author Kenneth Russell + */ + +public class CompileProperties { + + public static void main(String[] args) { + CompileProperties cp = new CompileProperties(); + boolean ok = cp.run(args); + if ( !ok ) { + System.exit(1); + } + } + + public static interface Log { + void info(String msg); + void verbose(String msg); + void error(String msg, Exception e); + } + + private String propfiles[]; + private String outfiles[] ; + private String supers[] ; + private int compileCount = 0; + private boolean quiet = false; + public Log log; + + public void setLog(Log log) { + this.log = log; + } + + public boolean run(String[] args) { + if (log == null) { + log = new Log() { + public void error(String msg, Exception e) { + System.err.println("ERROR: CompileProperties: " + msg); + if ( e != null ) { + System.err.println("EXCEPTION: " + e.toString()); + e.printStackTrace(); + } + } + public void info(String msg) { + System.out.println(msg); + } + public void verbose(String msg) { + if (!quiet) + System.out.println(msg); + } + }; + } + + boolean ok = true; + /* Original usage */ + if (args.length == 2 && args[0].charAt(0) != '-' ) { + ok = createFile(args[0], args[1], "java.util.ListResourceBundle"); + } else if (args.length == 3) { + ok = createFile(args[0], args[1], args[2]); + } else if (args.length == 0) { + usage(log); + ok = false; + } else { + /* New batch usage */ + ok = parseOptions(args); + if ( ok && compileCount == 0 ) { + log.error("options parsed but no files to compile", null); + ok = false; + } + /* Need at least one file. */ + if ( !ok ) { + usage(log); + } else { + /* Process files */ + for ( int i = 0; i < compileCount && ok ; i++ ) { + ok = createFile(propfiles[i], outfiles[i], supers[i]); + } + } + } + return ok; + } + + private boolean parseOptions(String args[]) { + boolean ok = true; + if ( compileCount > 0 ) { + String new_propfiles[] = new String[compileCount + args.length]; + String new_outfiles[] = new String[compileCount + args.length]; + String new_supers[] = new String[compileCount + args.length]; + System.arraycopy(propfiles, 0, new_propfiles, 0, compileCount); + System.arraycopy(outfiles, 0, new_outfiles, 0, compileCount); + System.arraycopy(supers, 0, new_supers, 0, compileCount); + propfiles = new_propfiles; + outfiles = new_outfiles; + supers = new_supers; + } else { + propfiles = new String[args.length]; + outfiles = new String[args.length]; + supers = new String[args.length]; + } + + for ( int i = 0; i < args.length ; i++ ) { + if ( "-compile".equals(args[i]) && i+3 < args.length ) { + propfiles[compileCount] = args[++i]; + outfiles[compileCount] = args[++i]; + supers[compileCount] = args[++i]; + compileCount++; + } else if ( "-optionsfile".equals(args[i]) && i+1 < args.length ) { + String filename = args[++i]; + FileInputStream finput = null; + byte contents[] = null; + try { + finput = new FileInputStream(filename); + int byteCount = finput.available(); + if ( byteCount <= 0 ) { + log.error("The -optionsfile file is empty", null); + ok = false; + } else { + contents = new byte[byteCount]; + int bytesRead = finput.read(contents); + if ( byteCount != bytesRead ) { + log.error("Cannot read all of -optionsfile file", null); + ok = false; + } + } + } catch ( IOException e ) { + log.error("cannot open " + filename, e); + ok = false; + } + if ( finput != null ) { + try { + finput.close(); + } catch ( IOException e ) { + ok = false; + log.error("cannot close " + filename, e); + } + } + if ( ok = true && contents != null ) { + String tokens[] = (new String(contents)).split("\\s+"); + if ( tokens.length > 0 ) { + ok = parseOptions(tokens); + } + } + if ( !ok ) { + break; + } + } else if ( "-quiet".equals(args[i]) ) { + quiet = true; + } else { + log.error("argument error", null); + ok = false; + } + } + return ok; + } + + private boolean createFile(String propertiesPath, String outputPath, + String superClass) { + boolean ok = true; + log.verbose("parsing: " + propertiesPath); + Properties p = new Properties(); + try { + p.load(new FileInputStream(propertiesPath)); + } catch ( FileNotFoundException e ) { + ok = false; + log.error("Cannot find file " + propertiesPath, e); + } catch ( IOException e ) { + ok = false; + log.error("IO error on file " + propertiesPath, e); + } + if ( ok ) { + String packageName = inferPackageName(propertiesPath, outputPath); + log.verbose("inferred package name: " + packageName); + List sortedKeys = new ArrayList(); + for ( Object key : p.keySet() ) { + sortedKeys.add((String)key); + } + Collections.sort(sortedKeys); + Iterator keys = sortedKeys.iterator(); + + StringBuffer data = new StringBuffer(); + + while (keys.hasNext()) { + String key = keys.next(); + data.append(" { \"" + escape(key) + "\", \"" + + escape((String)p.get(key)) + "\" },\n"); + } + + // Get class name from java filename, not the properties filename. + // (zh_TW properties might be used to create zh_HK files) + File file = new File(outputPath); + String name = file.getName(); + int dotIndex = name.lastIndexOf('.'); + String className; + if (dotIndex == -1) { + className = name; + } else { + className = name.substring(0, dotIndex); + } + + String packageString = ""; + if (packageName != null && !packageName.equals("")) { + packageString = "package " + packageName + ";\n\n"; + } + + Writer writer = null; + try { + writer = new BufferedWriter( + new OutputStreamWriter(new FileOutputStream(outputPath), "8859_1")); + MessageFormat format = new MessageFormat(FORMAT); + writer.write(format.format(new Object[] { packageString, className, superClass, data })); + } catch ( IOException e ) { + ok = false; + log.error("IO error writing to file " + outputPath, e); + } + if ( writer != null ) { + try { + writer.flush(); + } catch ( IOException e ) { + ok = false; + log.error("IO error flush " + outputPath, e); + } + try { + writer.close(); + } catch ( IOException e ) { + ok = false; + log.error("IO error close " + outputPath, e); + } + } + log.verbose("wrote: " + outputPath); + } + return ok; + } + + private static void usage(Log log) { + log.info("usage:"); + log.info(" java CompileProperties path_to_properties_file path_to_java_output_file [super_class]"); + log.info(" -OR-"); + log.info(" java CompileProperties {-compile path_to_properties_file path_to_java_output_file super_class} -or- -optionsfile filename"); + log.info(""); + log.info("Example:"); + log.info(" java CompileProperties -compile test.properties test.java java.util.ListResourceBundle"); + log.info(" java CompileProperties -optionsfile option_file"); + log.info("option_file contains: -compile test.properties test.java java.util.ListResourceBundle"); + } + + private static String escape(String theString) { + // This is taken from Properties.saveConvert with changes for Java strings + int len = theString.length(); + StringBuffer outBuffer = new StringBuffer(len*2); + + for(int x=0; x 0x007e)) { + outBuffer.append('\\'); + outBuffer.append('u'); + outBuffer.append(toHex((aChar >> 12) & 0xF)); + outBuffer.append(toHex((aChar >> 8) & 0xF)); + outBuffer.append(toHex((aChar >> 4) & 0xF)); + outBuffer.append(toHex( aChar & 0xF)); + } else { + if (specialSaveChars.indexOf(aChar) != -1) { + outBuffer.append('\\'); + } + outBuffer.append(aChar); + } + } + } + return outBuffer.toString(); + } + + private static String inferPackageName(String inputPath, String outputPath) { + // Normalize file names + inputPath = new File(inputPath).getPath(); + outputPath = new File(outputPath).getPath(); + // Split into components + String sep; + if (File.separatorChar == '\\') { + sep = "\\\\"; + } else { + sep = File.separator; + } + String[] inputs = inputPath.split(sep); + String[] outputs = outputPath.split(sep); + // Match common names, eliminating first "classes" entry from + // each if present + int inStart = 0; + int inEnd = inputs.length - 2; + int outEnd = outputs.length - 2; + int i = inEnd; + int j = outEnd; + while (i >= 0 && j >= 0) { + if (!inputs[i].equals(outputs[j]) || + (inputs[i].equals("gensrc") && inputs[j].equals("gensrc"))) { + ++i; + ++j; + break; + } + --i; + --j; + } + String result; + if (i < 0 || j < 0 || i >= inEnd || j >= outEnd) { + result = ""; + } else { + if (inputs[i].equals("classes") && outputs[j].equals("classes")) { + ++i; + } + inStart = i; + StringBuffer buf = new StringBuffer(); + for (i = inStart; i <= inEnd; i++) { + buf.append(inputs[i]); + if (i < inEnd) { + buf.append('.'); + } + } + result = buf.toString(); + } + return result; + } + + private static final String FORMAT = + "{0}" + + "public final class {1} extends {2} '{'\n" + + " protected final Object[][] getContents() '{'\n" + + " return new Object[][] '{'\n" + + "{3}" + + " };\n" + + " }\n" + + "}\n"; + + // This comes from Properties + private static char toHex(int nibble) { + return hexDigit[(nibble & 0xF)]; + } + + // This comes from Properties + private static final char[] hexDigit = { + '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' + }; + + // Note: different from that in Properties + private static final String specialSaveChars = "\""; +} diff -r 8caec3672381 -r 24540bbb4135 make/tools/genstubs/GenStubs.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/tools/genstubs/GenStubs.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package genstubs; + +import java.io.*; +import java.util.*; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; + +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.util.JavacTask; +import com.sun.tools.javac.api.JavacTool; +import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.code.TypeTags; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; +import com.sun.tools.javac.tree.JCTree.JCFieldAccess; +import com.sun.tools.javac.tree.JCTree.JCIdent; +import com.sun.tools.javac.tree.JCTree.JCImport; +import com.sun.tools.javac.tree.JCTree.JCLiteral; +import com.sun.tools.javac.tree.JCTree.JCMethodDecl; +import com.sun.tools.javac.tree.JCTree.JCModifiers; +import com.sun.tools.javac.tree.JCTree.JCVariableDecl; +import com.sun.tools.javac.tree.Pretty; +import com.sun.tools.javac.tree.TreeMaker; +import com.sun.tools.javac.tree.TreeScanner; +import com.sun.tools.javac.tree.TreeTranslator; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.javac.util.Name; +import javax.tools.JavaFileManager; + +/** + * Generate stub source files by removing implementation details from input files. + * + * This is a special purpose stub generator, specific to the needs of generating + * stub files for JDK 7 API that are needed to compile langtools files that depend + * on that API. The stub generator works by removing as much of the API source code + * as possible without affecting the public signature, in order to reduce the + * transitive closure of the API being referenced. The resulting stubs can be + * put on the langtools sourcepath with -implicit:none to compile the langtools + * files that depend on the JDK 7 API. + * + * Usage: + * genstubs -s -sourcepath + * + * The specified class names are looked up on the sourcepath, and corresponding + * stubs are written to the source output directory. + * + * Classes are parsed into javac ASTs, then processed with a javac TreeTranslator + * to remove implementation details, and written out in the source output directory. + * Documentation comments and annotations are removed. Method bodies are removed + * and methods are marked native. Private and package-private field definitions + * have their initializers replace with 0, 0.0, false, null as appropriate. + */ + +public class GenStubs { + static class Fault extends Exception { + private static final long serialVersionUID = 0; + Fault(String message) { + super(message); + } + Fault(String message, Throwable cause) { + super(message); + initCause(cause); + } + } + + public static void main(String[] args) { + boolean ok = new GenStubs().run(args); + if (!ok) + System.exit(1); + } + + public boolean run(String... args) { + File outdir = null; + String sourcepath = null; + List classes = new ArrayList(); + for (ListIterator iter = Arrays.asList(args).listIterator(); iter.hasNext(); ) { + String arg = iter.next(); + if (arg.equals("-s") && iter.hasNext()) + outdir = new File(iter.next()); + else if (arg.equals("-sourcepath") && iter.hasNext()) + sourcepath = iter.next(); + else if (arg.startsWith("-")) + throw new IllegalArgumentException(arg); + else { + classes.add(arg); + while (iter.hasNext()) + classes.add(iter.next()); + } + } + + return run(sourcepath, outdir, classes); + } + + public boolean run(String sourcepath, File outdir, List classes) { + //System.err.println("run: sourcepath:" + sourcepath + " outdir:" + outdir + " classes:" + classes); + if (sourcepath == null) + throw new IllegalArgumentException("sourcepath not set"); + if (outdir == null) + throw new IllegalArgumentException("source output dir not set"); + + JavacTool tool = JavacTool.create(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + + try { + fm.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outdir)); + fm.setLocation(StandardLocation.SOURCE_PATH, splitPath(sourcepath)); + List files = new ArrayList(); + for (String c: classes) { + JavaFileObject fo = fm.getJavaFileForInput( + StandardLocation.SOURCE_PATH, c, JavaFileObject.Kind.SOURCE); + if (fo == null) + error("class not found: " + c); + else + files.add(fo); + } + + JavacTask t = tool.getTask(null, fm, null, null, null, files); + Iterable trees = t.parse(); + for (CompilationUnitTree tree: trees) { + makeStub(fm, tree); + } + } catch (IOException e) { + error("IO error " + e, e); + } + + return (errors == 0); + } + + void makeStub(StandardJavaFileManager fm, CompilationUnitTree tree) throws IOException { + CompilationUnitTree tree2 = new StubMaker().translate(tree); + CompilationUnitTree tree3 = new ImportCleaner(fm).removeRedundantImports(tree2); + + String className = fm.inferBinaryName(StandardLocation.SOURCE_PATH, tree.getSourceFile()); + JavaFileObject fo = fm.getJavaFileForOutput(StandardLocation.SOURCE_OUTPUT, + className, JavaFileObject.Kind.SOURCE, null); + // System.err.println("Writing " + className + " to " + fo.getName()); + Writer out = fo.openWriter(); + try { + new Pretty(out, true).printExpr((JCTree) tree3); + } finally { + out.close(); + } + } + + List splitPath(String path) { + List list = new ArrayList(); + for (String p: path.split(File.pathSeparator)) { + if (p.length() > 0) + list.add(new File(p)); + } + return list; + } + + void error(String message) { + System.err.println(message); + errors++; + } + + void error(String message, Throwable cause) { + error(message); + } + + int errors; + + class StubMaker extends TreeTranslator { + CompilationUnitTree translate(CompilationUnitTree tree) { + return super.translate((JCCompilationUnit) tree); + } + + /** + * compilation units: remove javadoc comments + * -- required, in order to remove @deprecated tags, since we + * (separately) remove all annotations, including @Deprecated + */ + public void visitTopLevel(JCCompilationUnit tree) { + super.visitTopLevel(tree); + tree.docComments = Collections.emptyMap(); + } + + /** + * methods: remove method bodies, make methods native + */ + @Override + public void visitMethodDef(JCMethodDecl tree) { + tree.mods = translate(tree.mods); + tree.restype = translate(tree.restype); + tree.typarams = translateTypeParams(tree.typarams); + tree.params = translateVarDefs(tree.params); + tree.thrown = translate(tree.thrown); + if (tree.restype != null && tree.body != null) { + tree.mods.flags |= Flags.NATIVE; + tree.body = null; + } + result = tree; + } + + /** + * modifiers: remove annotations + */ + @Override + public void visitModifiers(JCModifiers tree) { + tree.annotations = com.sun.tools.javac.util.List.nil(); + result = tree; + } + + /** + * field definitions: replace initializers with 0, 0.0, false etc + * when possible -- i.e. leave public, protected initializers alone + */ + @Override + public void visitVarDef(JCVariableDecl tree) { + tree.mods = translate(tree.mods); + tree.vartype = translate(tree.vartype); + if (tree.init != null) { + if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0) + tree.init = translate(tree.init); + else { + String t = tree.vartype.toString(); + if (t.equals("boolean")) + tree.init = new JCLiteral(TypeTags.BOOLEAN, 0) { }; + else if (t.equals("byte")) + tree.init = new JCLiteral(TypeTags.BYTE, 0) { }; + else if (t.equals("char")) + tree.init = new JCLiteral(TypeTags.CHAR, 0) { }; + else if (t.equals("double")) + tree.init = new JCLiteral(TypeTags.DOUBLE, 0.d) { }; + else if (t.equals("float")) + tree.init = new JCLiteral(TypeTags.FLOAT, 0.f) { }; + else if (t.equals("int")) + tree.init = new JCLiteral(TypeTags.INT, 0) { }; + else if (t.equals("long")) + tree.init = new JCLiteral(TypeTags.LONG, 0) { }; + else if (t.equals("short")) + tree.init = new JCLiteral(TypeTags.SHORT, 0) { }; + else + tree.init = new JCLiteral(TypeTags.BOT, null) { }; + } + } + result = tree; + } + } + + class ImportCleaner extends TreeScanner { + private Set names = new HashSet(); + private TreeMaker m; + + ImportCleaner(JavaFileManager fm) { + // ImportCleaner itself doesn't require a filemanager, but instantiating + // a TreeMaker does, indirectly (via ClassReader, sigh) + Context c = new Context(); + c.put(JavaFileManager.class, fm); + m = TreeMaker.instance(c); + } + + CompilationUnitTree removeRedundantImports(CompilationUnitTree t) { + JCCompilationUnit tree = (JCCompilationUnit) t; + tree.accept(this); + ListBuffer defs = new ListBuffer(); + for (JCTree def: tree.defs) { + if (def.getTag() == JCTree.Tag.IMPORT) { + JCImport imp = (JCImport) def; + if (imp.qualid.getTag() == JCTree.Tag.SELECT) { + JCFieldAccess qualid = (JCFieldAccess) imp.qualid; + if (!qualid.name.toString().equals("*") + && !names.contains(qualid.name)) { + continue; + } + } + } + defs.add(def); + } + return m.TopLevel(tree.packageAnnotations, tree.pid, defs.toList()); + } + + @Override + public void visitImport(JCImport tree) { } // ignore names found in imports + + @Override + public void visitIdent(JCIdent tree) { + names.add(tree.name); + } + + @Override + public void visitSelect(JCFieldAccess tree) { + super.visitSelect(tree); + names.add(tree.name); + } + } +} diff -r 8caec3672381 -r 24540bbb4135 makefiles/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/makefiles/Makefile Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,203 @@ +# +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +include $(SPEC) +include MakeBase.gmk +include JavaCompilation.gmk + +default: all + +# The BOOT_JAVAC setup uses the bootdir compiler to compile the tools +# and the bootstrap javac, to be run by the bootdir jvm. +$(eval $(call SetupJavaCompiler,BOOT_JAVAC,\ + JAVAC:=$(JAVAC),\ + FLAGS:=-Xprefer:source -XDignore.symbol.file=true -g,\ + MODE:=SINGLE_THREADED_BATCH)) + +# Now setup the compilation of the properties compilation tool. You can depend +# upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we +# add src/share/classes to the sourcepath. This is necessary since the GenStubs +# program needs to be linked and run towards the new javac sources. +$(eval $(call SetupJavaCompilation,BUILD_TOOLS,\ + SETUP:=BOOT_JAVAC,\ + SRC:=$(LANGTOOLS_TOPDIR)/make/tools $(LANGTOOLS_TOPDIR)/src/share/classes,\ + INCLUDES:=compileproperties genstubs,\ + BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses)) + +# The compileprops tools compiles a properties file into a resource bundle. +TOOL_COMPILEPROPS_CMD:=$(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/btclasses compileproperties.CompileProperties -quiet +# Lookup the properties that need to be compiled into resource bundles. +PROPSOURCES:=$(shell find $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties") +# Strip away prefix and suffix, leaving for example only: "com/sun/tools/javac/resources/javac_zh_CN" +PROPPATHS:=$(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties,%,$(PROPSOURCES)) +# Generate the list of java files to be created. +PROPJAVAS:=$(patsubst %,$(LANGTOOLS_OUTPUTDIR)/gensrc/%.java,$(PROPPATHS)) +# Generate the package dirs for the tobe generated java files. +PROPDIRS:=$(dir $(PROPJAVAS)) +# Now generate a sequence of "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle" +# suitable to be fed into the CompileProperties command. +PROPCMDLINE:=$(subst _SPACE_,$(SPACE),$(join $(addprefix -compile_SPACE_,$(PROPSOURCES)), \ + $(addsuffix _SPACE_java.util.ListResourceBundle,$(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/,$(addsuffix .java,$(PROPPATHS)))))) + +# Now setup the rule for the generation of the resource bundles. +$(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d : $(PROPSOURCES) $(BUILD_TOOLS) + rm -rf $(@D)/* + mkdir -p $(@D) $(PROPDIRS) + printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties + printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties + printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties + echo Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles + $(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \ + -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \ + $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \ + java.util.ListResourceBundle \ + -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \ + $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \ + java.util.ListResourceBundle \ + -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \ + $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \ + java.util.ListResourceBundle + echo PROPS_ARE_CREATED=yes > $@ + +# Trigger the generation of the resource bundles. After the resource bundles have +# been compiled, then the makefile will restart and the newly created java files +# will become part of the build further along in the makefile. +-include $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d + +ifeq ($(PROPS_ARE_CREATED),yes) + # Setup the rules to build a dist/bootstrap/lib/javac.jar, ie a smaller intermediate javac + # that can be compiled with an old javac. The intermediate javac is then used + # to compile javac again and to build the complete new jdk. + $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_LANGTOOLS,\ + SETUP:=BOOT_JAVAC,\ + SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\ + EXCLUDES:=com/sun/tools/javac/nio,\ + BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap)) + + $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC,$(BUILD_BOOTSTRAP_LANGTOOLS),\ + SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ + JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar,\ + JARMAIN:=com.sun.tools.javac.Main)) + + $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAH,$(BUILD_BOOTSTRAP_LANGTOOLS),\ + SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ + JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javah.jar,\ + JARMAIN:=com.sun.tools.javah.Main)) + + $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAP,$(BUILD_BOOTSTRAP_LANGTOOLS),\ + SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ + JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javap.jar,\ + JARMAIN:=com.sun.tools.javap.Main)) + + $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVADOC,$(BUILD_BOOTSTRAP_LANGTOOLS),\ + SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ + JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javadoc.jar,\ + JARMAIN:=com.sun.tools.javadoc.Main)) + + # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not + # yet built. It is currently not needed but might be again in the future. The following + # exercises the functionality to verify that it works. + TOOL_GENSTUBS_CMD=$(JAVA) \ + "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ + -cp "$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar$(PATH_SEP)$(LANGTOOLS_OUTPUTDIR)/btclasses" \ + genstubs.GenStubs + # We fetch source from the JDK... + JDKS=$(JDK_TOPDIR)/src/share/classes + # Build the list of classes to generate stubs from. java/util/Objects.java isn't + # currently needed, but is used as a demo for now. + STUBSOURCES:=$(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \ + -e "$(JDKS)/java/util/Objects.java") + # Rewrite the file names into class names because the GenStubs tool require this. + STUBCLASSES:=$(subst /,.,$(patsubst $(JDKS)/%.java,%,$(STUBSOURCES))) + + # Now setup the build recipe for genstubs. + $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d : $(STUBSOURCES) $(BUILD_TOOLS) \ + $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ + $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d + mkdir -p $(@D) + mkdir -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs + echo Generating stubs from JDK sources. + ($(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES) && echo STUBS_ARE_CREATED=yes > $@) + if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs > /dev/null 2>&1; then \ + echo No changes in the stubs!; \ + rm -rf $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \ + else \ + echo Changes in stubs detected!; \ + rm -rf $(@D); \ + mv $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \ + fi + echo STUBS_ARE_CREATED=yes > $@ + + # Trigger a generation of the genstubs java source code and a restart + # of the makefile to make sure that the following build setup use the + # newly created java files. + -include $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d + + ifeq ($(STUBS_ARE_CREATED),yes) + # Setup a compiler configuration using the intermediate javac in dist/bootstrap/lib/javac.jar + # that generates code for the new jdk that is being built. + # The code compiled by this compiler setup, cannot necessarily be run with the bootstrap jvm. + $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE,\ + JVM:=$(JAVA),\ + JAVAC:="-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ + -jar $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar,\ + FLAGS:=-Xprefer:source -XDignore.symbol.file=true,\ + SERVER_DIR:=$(JAVAC_SERVERS),\ + SERVER_JVM:=$(SERVER_JAVA),\ + MODE:=$(JAVAC_USE_MODE),\ + USE_DEPS:=$(JAVAC_USE_DEPS))) + + # javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied. + RESOURCE_SUFFIXES:=.gif .xml .css javax.tools.JavaCompilerTool + + $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC,\ + SETUP:=GENERATE_NEWBYTECODE,\ + SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \ + $(LANGTOOLS_OUTPUTDIR)/genstubs,\ + EXCLUDES:=java/util java/io java/nio,\ + COPY:=$(RESOURCE_SUFFIXES),\ + BIN:=$(LANGTOOLS_OUTPUTDIR)/classes)) + + $(eval $(call SetupArchive,ARCHIVE_FULL_JAVAC,$(BUILD_FULL_JAVAC),\ + SETUP:=GENERATE_NEWBYTECODE,\ + SRCS:=$(LANGTOOLS_OUTPUTDIR)/classes,\ + SUFFIXES:=.class $(RESOURCE_SUFFIXES),\ + JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar,\ + HEADERS:=$(LANGTOOLS_OUTPUTDIR)/gensrc_headers)) + + $(eval $(call SetupZipArchive,ZIP_FULL_JAVAC_SOURCE,\ + SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\ + ZIP:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip)) + + all: $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar \ + $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip \ + $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ + $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javah.jar \ + $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javap.jar \ + $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javadoc.jar + + + endif +endif diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/apt/AnnotationProcessor.java --- a/src/share/classes/com/sun/mirror/apt/AnnotationProcessor.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - - -import java.io.IOException; -import java.util.Collection; - - -/** - * An annotation processor, used to examine and process the - * annotations of program elements. An annotation processor may, - * for example, create new source files and XML documents to be used - * in conjunction with the original code. - * - *

An annotation processor is constructed by a - * {@linkplain AnnotationProcessorFactory factory}, which provides it with an - * {@linkplain AnnotationProcessorEnvironment environment} that - * encapsulates the state it needs. - * Messages regarding warnings and errors encountered during processing - * should be directed to the environment's {@link Messager}, - * and new files may be created using the environment's {@link Filer}. - * - *

Each annotation processor is created to process annotations - * of a particular annotation type or set of annotation types. - * It may use its environment to find the program elements with - * annotations of those types. It may freely examine any other program - * elements in the course of its processing. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.Processor}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationProcessor { - - /** - * Process all program elements supported by this annotation processor. - */ - void process(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/apt/AnnotationProcessorEnvironment.java --- a/src/share/classes/com/sun/mirror/apt/AnnotationProcessorEnvironment.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - - -import java.util.Collection; -import java.util.Map; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.*; - - -/** - * The environment encapsulating the state needed by an annotation processor. - * An annotation processing tool makes this environment available - * to all annotation processors. - * - *

When an annotation processing tool is invoked, it is given a - * set of type declarations on which to operate. These - * are refered to as the specified types. - * The type declarations said to be included in this invocation - * consist of the specified types and any types nested within them. - * - *

{@link DeclarationFilter} - * provides a simple way to select just the items of interest - * when a method returns a collection of declarations. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.ProcessingEnvironment}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationProcessorEnvironment { - - /** - * Returns the options passed to the annotation processing tool. - * Options are returned in the form of a map from option name - * (such as "-encoding") to option value. - * For an option with no value (such as "-help"), the - * corresponding value in the map is null. - * - *

Options beginning with "-A" are processor-specific. - * Such options are unrecognized by the tool, but intended to be used by - * some annotation processor. - * - * @return the options passed to the tool - */ - Map getOptions(); - - /** - * Returns the messager used to report errors, warnings, and other - * notices. - * - * @return the messager - */ - Messager getMessager(); - - /** - * Returns the filer used to create new source, class, or auxiliary - * files. - * - * @return the filer - */ - Filer getFiler(); - - - /** - * Returns the declarations of the types specified when the - * annotation processing tool was invoked. - * - * @return the types specified when the tool was invoked, or an - * empty collection if there were none - */ - Collection getSpecifiedTypeDeclarations(); - - /** - * Returns the declaration of a package given its fully qualified name. - * - * @param name fully qualified package name, or "" for the unnamed package - * @return the declaration of the named package, or null if it cannot - * be found - */ - PackageDeclaration getPackage(String name); - - /** - * Returns the declaration of a type given its fully qualified name. - * - * @param name fully qualified type name - * @return the declaration of the named type, or null if it cannot be - * found - */ - TypeDeclaration getTypeDeclaration(String name); - - /** - * A convenience method that returns the declarations of the types - * {@linkplain AnnotationProcessorEnvironment included} - * in this invocation of the annotation processing tool. - * - * @return the declarations of the types included in this invocation - * of the tool, or an empty collection if there are none - */ - Collection getTypeDeclarations(); - - /** - * Returns the declarations annotated with the given annotation type. - * Only declarations of the types - * {@linkplain AnnotationProcessorEnvironment included} - * in this invocation of the annotation processing tool, or - * declarations of members, parameters, or type parameters - * declared within those, are returned. - * - * @param a annotation type being requested - * @return the declarations annotated with the given annotation type, - * or an empty collection if there are none - */ - Collection getDeclarationsAnnotatedWith( - AnnotationTypeDeclaration a); - - /** - * Returns an implementation of some utility methods for - * operating on declarations. - * - * @return declaration utilities - */ - Declarations getDeclarationUtils(); - - /** - * Returns an implementation of some utility methods for - * operating on types. - * - * @return type utilities - */ - Types getTypeUtils(); - - /** - * Add a listener. If the listener is currently registered to listen, - * adding it again will have no effect. - * - * @param listener The listener to add. - * @throws NullPointerException if the listener is null - */ - void addListener(AnnotationProcessorListener listener); - - - /** - * Remove a listener. If the listener is not currently listening, - * the method call does nothing. - * - * @param listener The listener to remove. - * @throws NullPointerException if the listener is null - */ - void removeListener(AnnotationProcessorListener listener); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/apt/AnnotationProcessorFactory.java --- a/src/share/classes/com/sun/mirror/apt/AnnotationProcessorFactory.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - - -import java.util.Collection; -import java.util.Set; - -import com.sun.mirror.declaration.AnnotationTypeDeclaration; - - -/** - * A factory for creating annotation processors. - * Each factory is responsible for creating processors for one or more - * annotation types. - * The factory is said to support these types. - * - *

Each implementation of an AnnotationProcessorFactory - * must provide a public no-argument constructor to be used by tools to - * instantiate the factory. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.Processor}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationProcessorFactory { - - /** - * Returns the options recognized by this factory or by any of the - * processors it may create. - * Only {@linkplain AnnotationProcessorEnvironment#getOptions() - * processor-specific} options are included, each of which begins - * with "-A". For example, if this factory recognizes - * options such as -Adebug -Aloglevel=3, it will - * return the strings "-Adebug" and "-Aloglevel". - * - *

A tool might use this information to determine if any - * options provided by a user are unrecognized by any processor, - * in which case it may wish to report an error. - * - * @return the options recognized by this factory or by any of the - * processors it may create, or an empty collection if none - */ - Collection supportedOptions(); - - /** - * Returns the names of the annotation types supported by this factory. - * An element of the result may be the canonical (fully qualified) name - * of a supported annotation type. Alternately it may be of the form - * "name.*" - * representing the set of all annotation types - * with canonical names beginning with "name." - * Finally, "*" by itself represents the set of all - * annotation types. - * - * @return the names of the annotation types supported by this factory - */ - Collection supportedAnnotationTypes(); - - /** - * Returns an annotation processor for a set of annotation - * types. The set will be empty if the factory supports - * "*" and the specified type declarations have - * no annotations. Note that the set of annotation types may be - * empty for other reasons, such as giving the factory an - * opportunity to register a listener. An - * AnnotationProcessorFactory must gracefully handle an - * empty set of annotations; an appropriate response to an empty - * set will often be returning {@link AnnotationProcessors#NO_OP}. - * - * @param atds type declarations of the annotation types to be processed - * @param env environment to use during processing - * @return an annotation processor for the given annotation types, - * or null if the types are not supported or the - * processor cannot be created - */ - AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/apt/AnnotationProcessorListener.java --- a/src/share/classes/com/sun/mirror/apt/AnnotationProcessorListener.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -/** - * Superinterface for all annotation processor event listeners. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. This interface has no - * direct analog in the standardized API because the different round - * model renders it unnecessary. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationProcessorListener extends java.util.EventListener {} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/apt/AnnotationProcessors.java --- a/src/share/classes/com/sun/mirror/apt/AnnotationProcessors.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -import com.sun.mirror.apt.*; -import java.util.*; - -/** - * Utilities to create specialized annotation processors. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. There is no direct analog - * of the functionality of this class in the standardized API. - * - * @since 1.5 - * @author Joseph D. Darcy - * @author Scott Seligman - */ -@Deprecated -@SuppressWarnings("deprecation") -public class AnnotationProcessors { - static class NoOpAP implements AnnotationProcessor { - NoOpAP() {} - public void process(){} - } - - /** - * Combines multiple annotation processors into a simple composite - * processor. - * The composite processor functions by invoking each of its component - * processors in sequence. - */ - static class CompositeAnnotationProcessor implements AnnotationProcessor { - - private List aps = - new LinkedList(); - - /** - * Constructs a new composite annotation processor. - * @param aps the component annotation processors - */ - public CompositeAnnotationProcessor(Collection aps) { - this.aps.addAll(aps); - } - - /** - * Constructs a new composite annotation processor. - * @param aps the component annotation processors - */ - public CompositeAnnotationProcessor(AnnotationProcessor... aps) { - for(AnnotationProcessor ap: aps) - this.aps.add(ap); - } - - /** - * Invokes the process method of each component processor, - * in the order in which the processors were passed to the constructor. - */ - public void process() { - for(AnnotationProcessor ap: aps) - ap.process(); - } - } - - - /** - * An annotation processor that does nothing and has no state. - * May be used multiple times. - * - * @since 1.5 - */ - public final static AnnotationProcessor NO_OP = new NoOpAP(); - - /** - * Constructs a new composite annotation processor. A composite - * annotation processor combines multiple annotation processors - * into one and functions by invoking each of its component - * processors' process methods in sequence. - * - * @param aps The processors to create a composite of - * @since 1.5 - */ - public static AnnotationProcessor getCompositeAnnotationProcessor(AnnotationProcessor... aps) { - return new CompositeAnnotationProcessor(aps); - } - - /** - * Constructs a new composite annotation processor. A composite - * annotation processor combines multiple annotation processors - * into one and functions by invoking each of its component - * processors' process methods in the sequence the processors are - * returned by the collection's iterator. - * - * @param aps A collection of processors to create a composite of - * @since 1.5 - */ - public static AnnotationProcessor getCompositeAnnotationProcessor(Collection aps) { - return new CompositeAnnotationProcessor(aps); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/apt/Filer.java --- a/src/share/classes/com/sun/mirror/apt/Filer.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - - -import java.io.*; - - -/** - * This interface supports the creation of new files by an - * annotation processor. - * Files created in this way will be known to the annotation processing - * tool implementing this interface, better enabling the tool to manage them. - * Four kinds of files are distinguished: - * source files, class files, other text files, and other binary files. - * The latter two are collectively referred to as auxiliary files. - * - *

There are two distinguished locations (subtrees within the - * file system) where newly created files are placed: - * one for new source files, and one for new class files. - * (These might be specified on a tool's command line, for example, - * using flags such as -s and -d.) - * Auxiliary files may be created in either location. - * - *

During each run of an annotation processing tool, a file - * with a given pathname may be created only once. If that file already - * exists before the first attempt to create it, the old contents will - * be deleted. Any subsequent attempt to create the same file during - * a run will fail. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.Filer}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface Filer { - - /** - * Creates a new source file and returns a writer for it. - * The file's name and path (relative to the root of all newly created - * source files) is based on the type to be declared in that file. - * If more than one type is being declared, the name of the principal - * top-level type (the public one, for example) should be used. - * - *

The {@linkplain java.nio.charset.Charset charset} used to - * encode the file is determined by the implementation. - * An annotation processing tool may have an -encoding - * flag or the like for specifying this. It will typically use - * the platform's default encoding if none is specified. - * - * @param name canonical (fully qualified) name of the principal type - * being declared in this file - * @return a writer for the new file - * @throws IOException if the file cannot be created - */ - PrintWriter createSourceFile(String name) throws IOException; - - /** - * Creates a new class file, and returns a stream for writing to it. - * The file's name and path (relative to the root of all newly created - * class files) is based on the name of the type being written. - * - * @param name canonical (fully qualified) name of the type being written - * @return a stream for writing to the new file - * @throws IOException if the file cannot be created - */ - OutputStream createClassFile(String name) throws IOException; - - /** - * Creates a new text file, and returns a writer for it. - * The file is located along with either the - * newly created source or newly created binary files. It may be - * named relative to some package (as are source and binary files), - * and from there by an arbitrary pathname. In a loose sense, the - * pathname of the new file will be the concatenation of - * loc, pkg, and relPath. - * - *

A {@linkplain java.nio.charset.Charset charset} for - * encoding the file may be provided. If none is given, the - * charset used to encode source files - * (see {@link #createSourceFile(String)}) will be used. - * - * @param loc location of the new file - * @param pkg package relative to which the file should be named, - * or the empty string if none - * @param relPath final pathname components of the file - * @param charsetName the name of the charset to use, or null if none - * is being explicitly specified - * @return a writer for the new file - * @throws IOException if the file cannot be created - */ - PrintWriter createTextFile(Location loc, - String pkg, - File relPath, - String charsetName) throws IOException; - - /** - * Creates a new binary file, and returns a stream for writing to it. - * The file is located along with either the - * newly created source or newly created binary files. It may be - * named relative to some package (as are source and binary files), - * and from there by an arbitrary pathname. In a loose sense, the - * pathname of the new file will be the concatenation of - * loc, pkg, and relPath. - * - * @param loc location of the new file - * @param pkg package relative to which the file should be named, - * or the empty string if none - * @param relPath final pathname components of the file - * @return a stream for writing to the new file - * @throws IOException if the file cannot be created - */ - OutputStream createBinaryFile(Location loc, - String pkg, - File relPath) throws IOException; - - - /** - * Locations (subtrees within the file system) where new files are created. - * - * @deprecated All components of this API have been superseded by - * the standardized annotation processing API. The replacement - * for the functionality of this enum is {@link - * javax.tools.StandardLocation}. - */ - @Deprecated - enum Location { - /** The location of new source files. */ - SOURCE_TREE, - /** The location of new class files. */ - CLASS_TREE - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/apt/Messager.java --- a/src/share/classes/com/sun/mirror/apt/Messager.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -import com.sun.mirror.util.SourcePosition; - -/** - * A Messager provides the way for - * an annotation processor to report error messages, warnings, and - * other notices. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.Messager}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface Messager { - - /** - * Prints an error message. - * Equivalent to printError(null, msg). - * @param msg the message, or an empty string if none - */ - void printError(String msg); - - /** - * Prints an error message. - * @param pos the position where the error occured, or null if it is - * unknown or not applicable - * @param msg the message, or an empty string if none - */ - void printError(SourcePosition pos, String msg); - - /** - * Prints a warning message. - * Equivalent to printWarning(null, msg). - * @param msg the message, or an empty string if none - */ - void printWarning(String msg); - - /** - * Prints a warning message. - * @param pos the position where the warning occured, or null if it is - * unknown or not applicable - * @param msg the message, or an empty string if none - */ - void printWarning(SourcePosition pos, String msg); - - /** - * Prints a notice. - * Equivalent to printNotice(null, msg). - * @param msg the message, or an empty string if none - */ - void printNotice(String msg); - - /** - * Prints a notice. - * @param pos the position where the noticed occured, or null if it is - * unknown or not applicable - * @param msg the message, or an empty string if none - */ - void printNotice(SourcePosition pos, String msg); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/apt/RoundCompleteEvent.java --- a/src/share/classes/com/sun/mirror/apt/RoundCompleteEvent.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -/** - * Event for the completion of a round of annotation processing. - * - *

While this class extends the serializable EventObject, it - * cannot meaningfully be serialized because all of the annotation - * processing tool's internal state would potentially be needed. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. This class has no direct - * analog in the standardized API because the different round model - * renders it unnecessary. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public abstract class RoundCompleteEvent extends java.util.EventObject { - private RoundState rs; - - /** - * The current AnnotationProcessorEnvironment is regarded - * as the source of events. - * - * @param source The source of events - * @param rs The state of the round - */ - protected RoundCompleteEvent(AnnotationProcessorEnvironment source, - RoundState rs) { - super(source); - this.rs = rs; - } - - /** - * Return round state. - */ - public RoundState getRoundState() { - return rs; - } - - /** - * Return source. - */ - public AnnotationProcessorEnvironment getSource() { - return (AnnotationProcessorEnvironment)super.getSource(); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/apt/RoundCompleteListener.java --- a/src/share/classes/com/sun/mirror/apt/RoundCompleteListener.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -/** - * Listener for the completion of a round of annotation processing. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. This interface has no - * direct analog in the standardized API because the different round - * model renders it unnecessary. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface RoundCompleteListener extends AnnotationProcessorListener { - /** - * Invoked after all processors for a round have run to completion. - * - * @param event An event for round completion - */ - void roundComplete(RoundCompleteEvent event); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/apt/RoundState.java --- a/src/share/classes/com/sun/mirror/apt/RoundState.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -/** - * Represents the status of a completed round of annotation processing. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.RoundEnvironment}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface RoundState { - /** - * Returns true if this was the last round of annotation - * processing; returns false if there will be a subsequent round. - */ - boolean finalRound(); - - /** - * Returns true if an error was raised in this round of processing; - * returns false otherwise. - */ - boolean errorRaised(); - - /** - * Returns true if new source files were created in this round of - * processing; returns false otherwise. - */ - boolean sourceFilesCreated(); - - /** - * Returns true if new class files were created in this round of - * processing; returns false otherwise. - */ - boolean classFilesCreated(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/apt/package-info.java --- a/src/share/classes/com/sun/mirror/apt/package-info.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Classes used to communicate information between {@linkplain - * com.sun.mirror.apt.AnnotationProcessor annotation processors} and - * an annotation processing tool. - * - *

The {@code apt} tool and its associated API have been superseded - * by the standardized annotation processing API. The replacement for - * the functionality in this package is {@link - * javax.annotation.processing}. - * - * @since 1.5 - */ -package com.sun.mirror.apt; diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/AnnotationMirror.java --- a/src/share/classes/com/sun/mirror/declaration/AnnotationMirror.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - -import java.util.Map; -import com.sun.mirror.type.AnnotationType; -import com.sun.mirror.util.SourcePosition; - - -/** - * Represents an annotation. An annotation associates a value with - * each element of an annotation type. - * - *

Annotations should not be compared using reference-equality - * ("=="). There is no guarantee that any particular - * annotation will always be represented by the same object. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.AnnotationMirror}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationMirror { - - /** - * Returns the annotation type of this annotation. - * - * @return the annotation type of this annotation - */ - AnnotationType getAnnotationType(); - - /** - * Returns the source position of the beginning of this annotation. - * Returns null if the position is unknown or not applicable. - * - *

This source position is intended for use in providing diagnostics, - * and indicates only approximately where an annotation begins. - * - * @return the source position of the beginning of this annotation or - * null if the position is unknown or not applicable - */ - SourcePosition getPosition(); - - /** - * Returns this annotation's elements and their values. - * This is returned in the form of a map that associates elements - * with their corresponding values. - * Only those elements and values explicitly present in the - * annotation are included, not those that are implicitly assuming - * their default values. - * The order of the map matches the order in which the - * elements appear in the annotation's source. - * - * @return this annotation's elements and their values, - * or an empty map if there are none - */ - Map getElementValues(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/AnnotationTypeDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/AnnotationTypeDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - - -/** - * Represents the declaration of an annotation type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.TypeElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationTypeDeclaration extends InterfaceDeclaration { - - /** - * Returns the annotation type elements of this annotation type. - * These are the methods that are directly declared in the type's - * declaration. - * - * @return the annotation type elements of this annotation type, - * or an empty collection if there are none - */ - Collection getMethods(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -/** - * Represents an element of an annotation type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.ExecutableElement}. - * - * @author Joe Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationTypeElementDeclaration extends MethodDeclaration { - - /** - * Returns the default value of this element. - * - * @return the default value of this element, or null if this element - * has no default. - */ - AnnotationValue getDefaultValue(); - - /** - * {@inheritDoc} - */ - AnnotationTypeDeclaration getDeclaringType(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/AnnotationValue.java --- a/src/share/classes/com/sun/mirror/declaration/AnnotationValue.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - -import com.sun.mirror.util.SourcePosition; - -/** - * Represents a value of an annotation type element. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.AnnotationValue}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationValue { - - /** - * Returns the value. - * The result has one of the following types: - *

  • a wrapper class (such as {@link Integer}) for a primitive type - *
  • {@code String} - *
  • {@code TypeMirror} - *
  • {@code EnumConstantDeclaration} - *
  • {@code AnnotationMirror} - *
  • {@code Collection} - * (representing the elements, in order, if the value is an array) - *
- * - * @return the value - */ - Object getValue(); - - /** - * Returns the source position of the beginning of this annotation value. - * Returns null if the position is unknown or not applicable. - * - *

This source position is intended for use in providing diagnostics, - * and indicates only approximately where an annotation value begins. - * - * @return the source position of the beginning of this annotation value or - * null if the position is unknown or not applicable - */ - SourcePosition getPosition(); - - /** - * Returns a string representation of this value. - * This is returned in a form suitable for representing this value - * in the source code of an annotation. - * - * @return a string representation of this value - */ - String toString(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/ClassDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/ClassDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.type.ClassType; - - -/** - * Represents the declaration of a class. - * For the declaration of an interface, see {@link InterfaceDeclaration}. - * Provides access to information about the class, its members, and - * its constructors. - * Note that an {@linkplain EnumDeclaration enum} is a kind of class. - * - *

While a ClassDeclaration represents the declaration - * of a class, a {@link ClassType} represents a class type. - * See {@link TypeDeclaration} for more on this distinction. - * - *

{@link com.sun.mirror.util.DeclarationFilter} - * provides a simple way to select just the items of interest - * when a method returns a collection of declarations. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.TypeElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @see ClassType - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ClassDeclaration extends TypeDeclaration { - - /** - * Returns the class type directly extended by this class. - * The only class with no superclass is java.lang.Object, - * for which this method returns null. - * - * @return the class type directly extended by this class, or null - * if there is none - */ - ClassType getSuperclass(); - - /** - * Returns the constructors of this class. - * This includes the default constructor if this class has - * no constructors explicitly declared. - * - * @return the constructors of this class - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getConstructors(); - - /** - * {@inheritDoc} - */ - Collection getMethods(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/ConstructorDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/ConstructorDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -/** - * Represents a constructor of a class or interface. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.ExecutableElement}. - * - * @author Joe Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ConstructorDeclaration extends ExecutableDeclaration { -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/Declaration.java --- a/src/share/classes/com/sun/mirror/declaration/Declaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.lang.annotation.Annotation; -import java.util.Collection; - -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -/** - * Represents the declaration of a program element such as a package, - * class, or method. Each declaration represents a static, language-level - * construct (and not, for example, a runtime construct of the virtual - * machine), and typically corresponds one-to-one with a particular - * fragment of source code. - * - *

Declarations should be compared using the {@link #equals(Object)} - * method. There is no guarantee that any particular declaration will - * always be represented by the same object. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.Element}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @see Declarations - * @see TypeMirror - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface Declaration { - - /** - * Tests whether an object represents the same declaration as this. - * - * @param obj the object to be compared with this declaration - * @return true if the specified object represents the same - * declaration as this - */ - boolean equals(Object obj); - - /** - * Returns the text of the documentation ("javadoc") comment of - * this declaration. - * - * @return the documentation comment of this declaration, or null - * if there is none - */ - String getDocComment(); - - /** - * Returns the annotations that are directly present on this declaration. - * - * @return the annotations directly present on this declaration; - * an empty collection if there are none - */ - Collection getAnnotationMirrors(); - - /** - * Returns the annotation of this declaration having the specified - * type. The annotation may be either inherited or directly - * present on this declaration. - * - *

The annotation returned by this method could contain an element - * whose value is of type Class. - * This value cannot be returned directly: information necessary to - * locate and load a class (such as the class loader to use) is - * not available, and the class might not be loadable at all. - * Attempting to read a Class object by invoking the relevant - * method on the returned annotation - * will result in a {@link MirroredTypeException}, - * from which the corresponding {@link TypeMirror} may be extracted. - * Similarly, attempting to read a Class[]-valued element - * will result in a {@link MirroredTypesException}. - * - *

- * Note: This method is unlike - * others in this and related interfaces. It operates on run-time - * reflective information -- representations of annotation types - * currently loaded into the VM -- rather than on the mirrored - * representations defined by and used throughout these - * interfaces. It is intended for callers that are written to - * operate on a known, fixed set of annotation types. - *
- * - * @param the annotation type - * @param annotationType the Class object corresponding to - * the annotation type - * @return the annotation of this declaration having the specified type - * - * @see #getAnnotationMirrors() - */ - A getAnnotation(Class annotationType); - - /** - * Returns the modifiers of this declaration, excluding annotations. - * Implicit modifiers, such as the public and static - * modifiers of interface members, are included. - * - * @return the modifiers of this declaration in undefined order; - * an empty collection if there are none - */ - Collection getModifiers(); - - /** - * Returns the simple (unqualified) name of this declaration. - * The name of a generic type does not include any reference - * to its formal type parameters. - * For example, the simple name of the interface declaration - * {@code java.util.Set} is "Set". - * If this declaration represents the empty package, an empty - * string is returned. - * If it represents a constructor, the simple name of its - * declaring class is returned. - * - * @return the simple name of this declaration - */ - String getSimpleName(); - - /** - * Returns the source position of the beginning of this declaration. - * Returns null if the position is unknown or not applicable. - * - *

This source position is intended for use in providing - * diagnostics, and indicates only approximately where a declaration - * begins. - * - * @return the source position of the beginning of this declaration, - * or null if the position is unknown or not applicable - */ - SourcePosition getPosition(); - - /** - * Applies a visitor to this declaration. - * - * @param v the visitor operating on this declaration - */ - void accept(DeclarationVisitor v); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/EnumConstantDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/EnumConstantDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -/** - * Represents an enum constant declaration. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.VariableElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface EnumConstantDeclaration extends FieldDeclaration { - /** - * {@inheritDoc} - */ - EnumDeclaration getDeclaringType(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/EnumDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/EnumDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - - -/** - * Represents the declaration of an enum type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.TypeElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface EnumDeclaration extends ClassDeclaration { - - /** - * Returns the enum constants defined for this enum. - * - * @return the enum constants defined for this enum, - * or an empty collection if there are none - */ - Collection getEnumConstants(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/ExecutableDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/ExecutableDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.type.ReferenceType; - - -/** - * Represents a method or constructor of a class or interface. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.ExecutableElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ExecutableDeclaration extends MemberDeclaration { - - /** - * Returns true if this method or constructor accepts a variable - * number of arguments. - * - * @return true if this method or constructor accepts a variable - * number of arguments - */ - boolean isVarArgs(); - - /** - * Returns the formal type parameters of this method or constructor. - * They are returned in declaration order. - * - * @return the formal type parameters of this method or constructor, - * or an empty collection if there are none - */ - Collection getFormalTypeParameters(); - - /** - * Returns the formal parameters of this method or constructor. - * They are returned in declaration order. - * - * @return the formal parameters of this method or constructor, - * or an empty collection if there are none - */ - Collection getParameters(); - - /** - * Returns the exceptions and other throwables listed in this - * method or constructor's throws clause. - * - * @return the exceptions and other throwables listed in the - * throws clause, or an empty collection if there are none - */ - Collection getThrownTypes(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/FieldDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/FieldDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import com.sun.mirror.type.TypeMirror; - - -/** - * Represents a field of a type declaration. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.VariableElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface FieldDeclaration extends MemberDeclaration { - - /** - * Returns the type of this field. - * - * @return the type of this field - */ - TypeMirror getType(); - - /** - * Returns the value of this field if this field is a compile-time - * constant. Returns null otherwise. - * The value will be of a primitive type or String. - * If the value is of a primitive type, it is wrapped in the - * appropriate wrapper class (such as {@link Integer}). - * - * @return the value of this field if this field is a compile-time - * constant, or null otherwise - */ - Object getConstantValue(); - - /** - * Returns the text of a constant expression representing the - * value of this field if this field is a compile-time constant. - * Returns null otherwise. - * The value will be of a primitive type or String. - * The text returned is in a form suitable for representing the value - * in source code. - * - * @return the text of a constant expression if this field is a - * compile-time constant, or null otherwise - */ - String getConstantExpression(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/InterfaceDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/InterfaceDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import com.sun.mirror.type.InterfaceType; - - -/** - * Represents the declaration of an interface. - * Provides access to information about the interface and its members. - * Note that an {@linkplain AnnotationTypeDeclaration annotation type} is - * a kind of interface. - * - *

While an InterfaceDeclaration represents the - * declaration of an interface, an {@link InterfaceType} - * represents an interface type. - * See {@link TypeDeclaration} for more on this distinction. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.TypeElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @see InterfaceType - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface InterfaceDeclaration extends TypeDeclaration { -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/MemberDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/MemberDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -/** - * Represents a declaration that may be a member or constructor of a declared - * type. This includes fields, constructors, methods, and (since they - * may be nested) declared types themselves. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.Element}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface MemberDeclaration extends Declaration { - - /** - * Returns the type declaration within which this member or constructor - * is declared. - * If this is the declaration of a top-level type (a non-nested class - * or interface), returns null. - * - * @return the type declaration within which this member or constructor - * is declared, or null if there is none - */ - TypeDeclaration getDeclaringType(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/MethodDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/MethodDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import com.sun.mirror.type.TypeMirror; -import com.sun.mirror.type.VoidType; - - -/** - * Represents a method of a class or interface. - * Note that an - * {@linkplain AnnotationTypeElementDeclaration annotation type element} - * is a kind of method. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.ExecutableElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface MethodDeclaration extends ExecutableDeclaration { - - /** - * Returns the formal return type of this method. - * Returns {@link VoidType} if this method does not return a value. - * - * @return the formal return type of this method - */ - TypeMirror getReturnType(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/Modifier.java --- a/src/share/classes/com/sun/mirror/declaration/Modifier.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -/** - * Represents a modifier on the declaration of a program element such - * as a class, method, or field. - * - *

Not all modifiers are applicable to all kinds of declarations. - * When two or more modifiers appear in the source code of a declaration, - * then it is customary, though not required, that they appear in the same - * order as the constants listed in the detail section below. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this enum is {@link javax.lang.model.element.Modifier}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public enum Modifier { - - // See JLS2 sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1. - // java.lang.reflect.Modifier includes INTERFACE, but that's a VMism. - - /** The modifier public */ PUBLIC, - /** The modifier protected */ PROTECTED, - /** The modifier private */ PRIVATE, - /** The modifier abstract */ ABSTRACT, - /** The modifier static */ STATIC, - /** The modifier final */ FINAL, - /** The modifier transient */ TRANSIENT, - /** The modifier volatile */ VOLATILE, - /** The modifier synchronized */ SYNCHRONIZED, - /** The modifier native */ NATIVE, - /** The modifier strictfp */ STRICTFP; - - - private String lowercase = null; // modifier name in lowercase - - /** - * Returns this modifier's name in lowercase. - */ - public String toString() { - if (lowercase == null) { - lowercase = name().toLowerCase(java.util.Locale.US); - } - return lowercase; - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/PackageDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/PackageDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - - -/** - * Represents the declaration of a package. Provides access to information - * about the package and its members. - * - *

{@link com.sun.mirror.util.DeclarationFilter} - * provides a simple way to select just the items of interest - * when a method returns a collection of declarations. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.PackageElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface PackageDeclaration extends Declaration { - - /** - * Returns the fully qualified name of this package. - * This is also known as the package's canonical name. - * - * @return the fully qualified name of this package, or the - * empty string if this is the unnamed package - */ - String getQualifiedName(); - - /** - * Returns the declarations of the top-level classes in this package. - * Interfaces are not included, but enum types are. - * - * @return the declarations of the top-level classes in this package - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getClasses(); - - /** - * Returns the declarations of the top-level enum types in this package. - * - * @return the declarations of the top-level enum types in this package - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getEnums(); - - /** - * Returns the declarations of the top-level interfaces in this package. - * Annotation types are included. - * - * @return the declarations of the top-level interfaces in this package - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getInterfaces(); - - /** - * Returns the declarations of the top-level annotation types in this - * package. - * - * @return the declarations of the top-level annotation types in this - * package - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getAnnotationTypes(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/ParameterDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/ParameterDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import com.sun.mirror.type.TypeMirror; - - -/** - * Represents a formal parameter of a method or constructor. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.VariableElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ParameterDeclaration extends Declaration { - - /** - * Returns the type of this parameter. - * - * @return the type of this parameter - */ - TypeMirror getType(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/TypeDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/TypeDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.type.*; - - -/** - * Represents the declaration of a class or interface. - * Provides access to information about the type and its members. - * Note that an {@linkplain EnumDeclaration enum} is a kind of class, - * and an {@linkplain AnnotationTypeDeclaration annotation type} is - * a kind of interface. - * - *

- * While a TypeDeclaration represents the declaration - * of a class or interface, a {@link DeclaredType} represents a class - * or interface type, the latter being a use - * (or invocation) of the former. - * The distinction is most apparent with generic types, - * for which a single declaration can define a whole - * family of types. For example, the declaration of - * {@code java.util.Set} corresponds to the parameterized types - * {@code java.util.Set} and {@code java.util.Set} - * (and many others), and to the raw type {@code java.util.Set}. - * - *

{@link com.sun.mirror.util.DeclarationFilter} - * provides a simple way to select just the items of interest - * when a method returns a collection of declarations. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.TypeElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @see DeclaredType - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface TypeDeclaration extends MemberDeclaration { - - /** - * Returns the package within which this type is declared. - * - * @return the package within which this type is declared - */ - PackageDeclaration getPackage(); - - /** - * Returns the fully qualified name of this class or interface - * declaration. More precisely, it returns the canonical - * name. - * The name of a generic type does not include any reference - * to its formal type parameters. - * For example, the the fully qualified name of the interface declaration - * {@code java.util.Set} is "java.util.Set". - * - * @return the fully qualified name of this class or interface declaration - */ - String getQualifiedName(); - - /** - * Returns the formal type parameters of this class or interface. - * - * @return the formal type parameters, or an empty collection - * if there are none - */ - Collection getFormalTypeParameters(); - - /** - * Returns the interface types directly implemented by this class - * or extended by this interface. - * - * @return the interface types directly implemented by this class - * or extended by this interface, or an empty collection if there are none - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getSuperinterfaces(); - - /** - * Returns the fields that are directly declared by this class or - * interface. Includes enum constants. - * - * @return the fields that are directly declared, - * or an empty collection if there are none - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getFields(); - - /** - * Returns the methods that are directly declared by this class or - * interface. Includes annotation type elements. Excludes - * implicitly declared methods of an interface, such as - * toString, that correspond to the methods of - * java.lang.Object. - * - * @return the methods that are directly declared, - * or an empty collection if there are none - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getMethods(); - - /** - * Returns the declarations of the nested classes and interfaces - * that are directly declared by this class or interface. - * - * @return the declarations of the nested classes and interfaces, - * or an empty collection if there are none - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getNestedTypes(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/TypeParameterDeclaration.java --- a/src/share/classes/com/sun/mirror/declaration/TypeParameterDeclaration.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.type.*; - - -/** - * Represents a formal type parameter of a generic type, method, - * or constructor declaration. - * A type parameter declares a {@link TypeVariable}. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.TypeParameterElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface TypeParameterDeclaration extends Declaration { - - /** - * Returns the bounds of this type parameter. - * These are the types given by the extends clause. - * If there is no explicit extends clause, then - * java.lang.Object is considered to be the sole bound. - * - * @return the bounds of this type parameter - */ - Collection getBounds(); - - /** - * Returns the type, method, or constructor declaration within which - * this type parameter is declared. - * - * @return the declaration within which this type parameter is declared - */ - Declaration getOwner(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/declaration/package-info.java --- a/src/share/classes/com/sun/mirror/declaration/package-info.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Interfaces used to model program element declarations. A - * declaration is represented by the appropriate subinterface of - * {@link com.sun.mirror.declaration.Declaration}, and an annotation - * is represented as an {@link - * com.sun.mirror.declaration.AnnotationMirror}. - * - *

The {@code apt} tool and its associated API have been superseded - * by the standardized annotation processing API. The replacement for - * the functionality in this package is {@link - * javax.lang.model.element}. - * - * @since 1.5 - */ -package com.sun.mirror.declaration; diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/overview.html --- a/src/share/classes/com/sun/mirror/overview.html Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ - - - - - - - - -The Mirror API is used to model the semantic structure of a program. -It provides representations of the entities -declared in a program, such as classes, methods, and fields. -Constructs below the method level, such as -individual statements and expressions, are not represented. - -

Also included is support for writing -{@linkplain com.sun.mirror.apt.AnnotationProcessor annotation processors} -to examine and process the annotations -of program elements. An annotation processor may, as an example, create -new source files and XML documents to be used in conjunction with the -original code. - - -

Characteristics of the API

- -A program is represented at the language level, rather than at the -level of the virtual machine. Nested classes, for example, are -handled as first-class constructs, -rather than in the translated form understood by the VM. -Both source code and compiled code (class files) may be modeled -in this way. - -

Programs are modeled in their static, or build-time, form. -This differs from the {@linkplain java.lang.reflect reflection} API, -which provides run-time information about classes and objects. - -

The API does not provide direct support for generating new code. - - -

Declarations and Types

- -The mirror API represents program constructs principally through the -{@link com.sun.mirror.declaration.Declaration} interface -and its hierarchy of subinterfaces in the package {@link -com.sun.mirror.declaration}. A Declaration represents a -program element such as a package, class, or method. -The interface hierarchy is depicted - here. - -

Types are represented by the {@link com.sun.mirror.type.TypeMirror} -interface and its hierarchy of subinterfaces in the -package {@link com.sun.mirror.type}. Types include primitive types, -class and interface types, array types, type variables, and wildcards. -The interface hierarchy is depicted - here. - -

The API makes a clear distinction between declarations and types. -This is most significant for generic types, where a single declaration -can define an infinite family of types. For example, the declaration of -java.util.Set defines the raw type java.util.Set, -the parameterized type {@code java.util.Set}, -and much more. Only the declaration can be annotated, for example, -and only a type can appear in a method signature. - -

A program being modeled may be incomplete, in that -it may depend on an unknown class or interface type. -This may be the result of a processing error such as a missing class file, -or perhaps the missing type is to be created by an annotation processor. -See {@link com.sun.mirror.type.DeclaredType} for information on -how such unknown types are handled. - - -

Utilities and Tool Support

- -The {@link com.sun.mirror.util} package provides -utilities to assist in the processing of declarations and types. -Included is support for using the visitor design pattern when -operating on declaration and type objects. - -

The {@link com.sun.mirror.apt} package supports the writing -of annotation processors. It provides the mechanism for them to -interact with an annotation processing tool. - - -@since 1.5 - - - diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/AnnotationType.java --- a/src/share/classes/com/sun/mirror/type/AnnotationType.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.AnnotationTypeDeclaration; - - -/** - * Represents an annotation type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.DeclaredType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationType extends InterfaceType { - - /** - * {@inheritDoc} - */ - AnnotationTypeDeclaration getDeclaration(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/ArrayType.java --- a/src/share/classes/com/sun/mirror/type/ArrayType.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -/** - * Represents an array type. - * A multidimensional array type is represented as an array type - * whose component type is also an array type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.ArrayType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ArrayType extends ReferenceType { - - /** - * Returns the component type of this array type. - * - * @return the component type of this array type - */ - TypeMirror getComponentType(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/ClassType.java --- a/src/share/classes/com/sun/mirror/type/ClassType.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.*; - - -/** - * Represents a class type. - * Interface types are represented separately by {@link InterfaceType}. - * Note that an {@linkplain EnumType enum} is a kind of class. - * - *

While a {@link ClassDeclaration} represents the declaration - * of a class, a ClassType represents a class type. - * See {@link TypeDeclaration} for more on this distinction. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.DeclaredType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ClassType extends DeclaredType { - - /** - * {@inheritDoc} - */ - ClassDeclaration getDeclaration(); - - /** - * Returns the class type that is a direct supertype of this one. - * This is the superclass of this type's declaring class, with any - * type arguments substituted in. - * The only class with no superclass is java.lang.Object, - * for which this method returns null. - * - *

For example, the class type extended by - * {@code java.util.TreeSet} is - * {@code java.util.AbstractSet}. - * - * @return the class type that is a direct supertype of this one, - * or null if there is none - */ - ClassType getSuperclass(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/DeclaredType.java --- a/src/share/classes/com/sun/mirror/type/DeclaredType.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import java.util.Collection; - -import com.sun.mirror.declaration.TypeDeclaration; - - -/** - * Represents a declared type, either a class type or an interface type. - * This includes parameterized types such as {@code java.util.Set} - * as well as raw types. - * - *

While a TypeDeclaration represents the declaration - * of a class or interface, a DeclaredType represents a class - * or interface type, the latter being a use of the former. - * See {@link TypeDeclaration} for more on this distinction. - * - *

A DeclaredType may represent a type - * for which details (declaration, supertypes, etc.) are unknown. - * This may be the result of a processing error, such as a missing class file, - * and is indicated by {@link #getDeclaration()} returning null. - * Other method invocations on such an unknown type will not, in general, - * return meaningful results. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.DeclaredType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface DeclaredType extends ReferenceType { - - /** - * Returns the declaration of this type. - * - *

Returns null if this type's declaration is unknown. This may - * be the result of a processing error, such as a missing class file. - * - * @return the declaration of this type, or null if unknown - */ - TypeDeclaration getDeclaration(); - - /** - * Returns the type that contains this type as a member. - * Returns null if this is a top-level type. - * - *

For example, the containing type of {@code O.I} - * is the type {@code O}, and the containing type of - * {@code O.I} is the type {@code O}. - * - * @return the type that contains this type, - * or null if this is a top-level type - */ - DeclaredType getContainingType(); - - /** - * Returns (in order) the actual type arguments of this type. - * For a generic type nested within another generic type - * (such as {@code Outer.Inner}), only the type - * arguments of the innermost type are included. - * - * @return the actual type arguments of this type, or an empty collection - * if there are none - */ - Collection getActualTypeArguments(); - - /** - * Returns the interface types that are direct supertypes of this type. - * These are the interface types implemented or extended - * by this type's declaration, with any type arguments - * substituted in. - * - *

For example, the interface type extended by - * {@code java.util.Set} is {@code java.util.Collection}. - * - * @return the interface types that are direct supertypes of this type, - * or an empty collection if there are none - */ - Collection getSuperinterfaces(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/EnumType.java --- a/src/share/classes/com/sun/mirror/type/EnumType.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.EnumDeclaration; - - -/** - * Represents an enum type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.DeclaredType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface EnumType extends ClassType { - - /** - * {@inheritDoc} - */ - EnumDeclaration getDeclaration(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/InterfaceType.java --- a/src/share/classes/com/sun/mirror/type/InterfaceType.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.*; - - -/** - * Represents an interface type. - * Note that an {@linkplain AnnotationType annotation type} is - * a kind of interface. - * - *

While an {@link InterfaceDeclaration} represents the - * declaration of an interface, an InterfaceType - * represents an interface type. - * See {@link TypeDeclaration} for more on this distinction. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.DeclaredType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface InterfaceType extends DeclaredType { - - /** - * {@inheritDoc} - */ - InterfaceDeclaration getDeclaration(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/MirroredTypeException.java --- a/src/share/classes/com/sun/mirror/type/MirroredTypeException.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import java.lang.annotation.Annotation; - -import com.sun.mirror.declaration.Declaration; - - -/** - * Thrown when an application attempts to access the {@link Class} object - * corresponding to a {@link TypeMirror}. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this exception is {@link - * javax.lang.model.type.MirroredTypeException}. - * - * @see MirroredTypesException - * @see Declaration#getAnnotation(Class) - */ -@Deprecated -@SuppressWarnings("deprecation") -public class MirroredTypeException extends RuntimeException { - - private static final long serialVersionUID = 1; - - private transient TypeMirror type; // cannot be serialized - private String name; // type's qualified "name" - - /** - * Constructs a new MirroredTypeException for the specified type. - * - * @param type the type being accessed - */ - public MirroredTypeException(TypeMirror type) { - super("Attempt to access Class object for TypeMirror " + type); - this.type = type; - name = type.toString(); - } - - /** - * Returns the type mirror corresponding to the type being accessed. - * The type mirror may be unavailable if this exception has been - * serialized and then read back in. - * - * @return the type mirror, or null if unavailable - */ - public TypeMirror getTypeMirror() { - return type; - } - - /** - * Returns the fully qualified name of the type being accessed. - * More precisely, returns the canonical name of a class, - * interface, array, or primitive, and returns "void" for - * the pseudo-type representing the type of void. - * - * @return the fully qualified name of the type being accessed - */ - public String getQualifiedName() { - return name; - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/MirroredTypesException.java --- a/src/share/classes/com/sun/mirror/type/MirroredTypesException.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -import com.sun.mirror.declaration.Declaration; - - -/** - * Thrown when an application attempts to access a sequence of {@link Class} - * objects each corresponding to a {@link TypeMirror}. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this exception is {@link - * javax.lang.model.type.MirroredTypesException}. - * - * @see MirroredTypeException - * @see Declaration#getAnnotation(Class) - */ -@Deprecated -@SuppressWarnings("deprecation") -public class MirroredTypesException extends RuntimeException { - - private static final long serialVersionUID = 1; - - private transient Collection types; // cannot be serialized - private Collection names; // types' qualified "names" - - /** - * Constructs a new MirroredTypesException for the specified types. - * - * @param types an ordered collection of the types being accessed - */ - public MirroredTypesException(Collection types) { - super("Attempt to access Class objects for TypeMirrors " + types); - this.types = types; - names = new ArrayList(); - for (TypeMirror t : types) { - names.add(t.toString()); - } - } - - /** - * Returns the type mirrors corresponding to the types being accessed. - * The type mirrors may be unavailable if this exception has been - * serialized and then read back in. - * - * @return the type mirrors in order, or null if unavailable - */ - public Collection getTypeMirrors() { - return (types != null) - ? Collections.unmodifiableCollection(types) - : null; - } - - /** - * Returns the fully qualified names of the types being accessed. - * More precisely, returns the canonical names of each class, - * interface, array, or primitive, and "void" for - * the pseudo-type representing the type of void. - * - * @return the fully qualified names, in order, of the types being - * accessed - */ - public Collection getQualifiedNames() { - return Collections.unmodifiableCollection(names); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/PrimitiveType.java --- a/src/share/classes/com/sun/mirror/type/PrimitiveType.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -/** - * Represents a primitive type. These include - * boolean, byte, short, int, - * long, char, float, and double. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.PrimitiveType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface PrimitiveType extends TypeMirror { - - /** - * Returns the kind of primitive type that this object represents. - * - * @return the kind of primitive type that this object represents - */ - Kind getKind(); - - /** - * An enumeration of the different kinds of primitive types. - * - * @deprecated All components of this API have been superseded by - * the standardized annotation processing API. The replacement - * for the functionality of this enum is {@link - * javax.lang.model.type.TypeKind}. - */ - @Deprecated - enum Kind { - /** The primitive type boolean */ BOOLEAN, - /** The primitive type byte */ BYTE, - /** The primitive type short */ SHORT, - /** The primitive type int */ INT, - /** The primitive type long */ LONG, - /** The primitive type char */ CHAR, - /** The primitive type float */ FLOAT, - /** The primitive type double */ DOUBLE - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/ReferenceType.java --- a/src/share/classes/com/sun/mirror/type/ReferenceType.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -/** - * Represents a reference type. - * These include class and interface types, array types, and type variables. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.ReferenceType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ReferenceType extends TypeMirror { -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/TypeMirror.java --- a/src/share/classes/com/sun/mirror/type/TypeMirror.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.Declaration; -import com.sun.mirror.util.Types; -import com.sun.mirror.util.TypeVisitor; - - -/** - * Represents a type in the Java programming language. - * Types include primitive types, class and interface types, array - * types, and type variables. Wildcard type arguments, and the - * pseudo-type representing the type of void, are represented - * by type mirrors as well. - * - *

Types may be compared using the utility methods in - * {@link Types}. - * There is no guarantee that any particular type will - * always be represented by the same object. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.TypeMirror}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @see Declaration - * @see Types - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface TypeMirror { - - /** - * Returns a string representation of this type. - * Any names embedded in the expression are qualified. - * - * @return a string representation of this type - */ - String toString(); - - /** - * Tests whether two types represent the same type. - * - * @param obj the object to be compared with this type - * @return true if the specified object represents the same - * type as this. - */ - boolean equals(Object obj); - - /** - * Applies a visitor to this type. - * - * @param v the visitor operating on this type - */ - void accept(TypeVisitor v); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/TypeVariable.java --- a/src/share/classes/com/sun/mirror/type/TypeVariable.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.*; - - -/** - * Represents a type variable. - * A type variable is declared by a - * {@linkplain TypeParameterDeclaration type parameter} of a - * type, method, or constructor. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.TypeVariable}. - * - * @author Joe Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface TypeVariable extends ReferenceType { - - /** - * Returns the type parameter that declared this type variable. - * - * @return the type parameter that declared this type variable - */ - TypeParameterDeclaration getDeclaration(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/VoidType.java --- a/src/share/classes/com/sun/mirror/type/VoidType.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.MethodDeclaration; - - -/** - * A pseudo-type representing the type of void. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.NoType}. - * - * @see MethodDeclaration#getReturnType() - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface VoidType extends TypeMirror { -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/WildcardType.java --- a/src/share/classes/com/sun/mirror/type/WildcardType.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import java.util.Collection; - - -/** - * Represents a wildcard type argument. - * Examples include:


- *   ?
- *   ? extends Number
- *   ? super T
- * 
- * - *

A wildcard may have its upper bound explicitly set by an - * extends clause, its lower bound explicitly set by a - * super clause, or neither (but not both). - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.WildcardType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface WildcardType extends TypeMirror { - - /** - * Returns the upper bounds of this wildcard. - * If no upper bound is explicitly declared, then - * an empty collection is returned. - * - * @return the upper bounds of this wildcard - */ - Collection getUpperBounds(); - - /** - * Returns the lower bounds of this wildcard. - * If no lower bound is explicitly declared, then - * an empty collection is returned. - * - * @return the lower bounds of this wildcard - */ - Collection getLowerBounds(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/type/package-info.java --- a/src/share/classes/com/sun/mirror/type/package-info.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Interfaces used to model types. A type is represented by the - * appropriate subinterface of {@link com.sun.mirror.type.TypeMirror}. - * - *

The {@code apt} tool and its associated API have been - * superseded by the standardized annotation processing API. The - * replacement for the functionality in this package is {@link - * javax.lang.model.type}. - * - * @since 1.5 - */ -package com.sun.mirror.type; diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/DeclarationFilter.java --- a/src/share/classes/com/sun/mirror/util/DeclarationFilter.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,319 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import java.util.ArrayList; -import java.util.Collection; - -import com.sun.mirror.declaration.Declaration; -import com.sun.mirror.declaration.Modifier; - -import static com.sun.mirror.declaration.Modifier.*; - - -/** - * A filter for selecting just the items of interest - * from a collection of declarations. - * The filter is said to select or to match those declarations. - * Filters can be created in several ways: - * by the static methods described below, - * by negating or composing existing filters, - * or by subclasses that implement arbitrary matching rules. - * - *

A subclass can create an arbitrary filter simply by implementing - * the {@link #matches(Declaration)} method. - * - *

Examples. - *

Selecting the public declarations from a collection: - *

- *     result = FILTER_PUBLIC.filter(decls);            
- * Selecting class declarations (including enums): - *
- *     classFilter = DeclarationFilter.getFilter(ClassDeclaration.class);
- *     result = classFilter.filter(decls);              
- * Selecting class declarations but excluding enums: - *
- *     enumFilter = DeclarationFilter.getFilter(EnumDeclaration.class);
- *     compoundFilter = classFilter.and(enumFilter.not());
- *     result = compoundFilter.filter(decls);           
- * Selecting declarations named "Bob": - *
- *     nameFilter = new DeclarationFilter() {
- *                      public boolean matches(Declaration d) {
- *                          return d.getSimpleName().equals("Bob");
- *                      }
- *                  };
- *     result = nameFilter.filter(decls);               
- * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this class is {@link - * javax.lang.model.util.ElementFilter}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public class DeclarationFilter { - - // Predefined filters for convenience. - - /** - * A filter that selects only public declarations. - */ - public static final DeclarationFilter FILTER_PUBLIC = - new AccessFilter(PUBLIC); - - /** - * A filter that selects only protected declarations. - */ - public static final DeclarationFilter FILTER_PROTECTED = - new AccessFilter(PROTECTED); - - /** - * A filter that selects only public or protected - * declarations. - */ - public static final DeclarationFilter FILTER_PUBLIC_OR_PROTECTED = - new AccessFilter(PUBLIC, PROTECTED); - - /** - * A filter that selects only package-private (default) - * declarations. - */ - public static final DeclarationFilter FILTER_PACKAGE = - new AccessFilter(); - - /** - * A filter that selects only private declarations. - */ - public static final DeclarationFilter FILTER_PRIVATE = - new AccessFilter(PRIVATE); - - - /** - * Constructs an identity filter: one that selects all declarations. - */ - public DeclarationFilter() { - } - - - - // Methods to create a filter. - - /** - * Returns a filter that selects declarations containing all of a - * collection of modifiers. - * - * @param mods the modifiers to match (non-null) - * @return a filter that matches declarations containing mods - */ - public static DeclarationFilter getFilter( - final Collection mods) { - return new DeclarationFilter() { - public boolean matches(Declaration d) { - return d.getModifiers().containsAll(mods); - } - }; - } - - /** - * Returns a filter that selects declarations of a particular kind. - * For example, there may be a filter that selects only class - * declarations, or only fields. - * The filter will select declarations of the specified kind, - * and also any subtypes of that kind; for example, a field filter - * will also select enum constants. - * - * @param kind the kind of declarations to select - * @return a filter that selects declarations of a particular kind - */ - public static DeclarationFilter getFilter( - final Class kind) { - return new DeclarationFilter() { - public boolean matches(Declaration d) { - return kind.isInstance(d); - } - }; - } - - /** - * Returns a filter that selects those declarations selected - * by both this filter and another. - * - * @param f filter to be composed with this one - * @return a filter that selects those declarations selected by - * both this filter and another - */ - public DeclarationFilter and(DeclarationFilter f) { - final DeclarationFilter f1 = this; - final DeclarationFilter f2 = f; - return new DeclarationFilter() { - public boolean matches(Declaration d) { - return f1.matches(d) && f2.matches(d); - } - }; - } - - /** - * Returns a filter that selects those declarations selected - * by either this filter or another. - * - * @param f filter to be composed with this one - * @return a filter that selects those declarations selected by - * either this filter or another - */ - public DeclarationFilter or(DeclarationFilter f) { - final DeclarationFilter f1 = this; - final DeclarationFilter f2 = f; - return new DeclarationFilter() { - public boolean matches(Declaration d) { - return f1.matches(d) || f2.matches(d); - } - }; - } - - /** - * Returns a filter that selects those declarations not selected - * by this filter. - * - * @return a filter that selects those declarations not selected - * by this filter - */ - public DeclarationFilter not() { - return new DeclarationFilter() { - public boolean matches(Declaration d) { - return !DeclarationFilter.this.matches(d); - } - }; - } - - - - // Methods to apply a filter. - - /** - * Tests whether this filter matches a given declaration. - * The default implementation always returns true; - * subclasses should override this. - * - * @param decl the declaration to match - * @return true if this filter matches the given declaration - */ - public boolean matches(Declaration decl) { - return true; - } - - /** - * Returns the declarations matched by this filter. - * The result is a collection of the same type as the argument; - * the {@linkplain #filter(Collection, Class) two-parameter version} - * of filter offers control over the result type. - * - * @param type of the declarations being filtered - * @param decls declarations being filtered - * @return the declarations matched by this filter - */ - public Collection filter(Collection decls) { - ArrayList res = new ArrayList(decls.size()); - for (D d : decls) { - if (matches(d)) { - res.add(d); - } - } - return res; - } - - /** - * Returns the declarations matched by this filter, with the result - * being restricted to declarations of a given kind. - * Similar to the simpler - * {@linkplain #filter(Collection) single-parameter version} - * of filter, but the result type is specified explicitly. - * - * @param type of the declarations being returned - * @param decls declarations being filtered - * @param resType type of the declarations being returned -- - * the reflective view of D - * @return the declarations matched by this filter, restricted to those - * of the specified type - */ - public Collection - filter(Collection decls, Class resType) { - ArrayList res = new ArrayList(decls.size()); - for (Declaration d : decls) { - if (resType.isInstance(d) && matches(d)) { - res.add(resType.cast(d)); - } - } - return res; - } - - - - /* - * A filter based on access modifiers. - */ - private static class AccessFilter extends DeclarationFilter { - - // The first access modifier to filter on, or null if we're looking - // for declarations with no access modifiers. - private Modifier mod1 = null; - - // The second access modifier to filter on, or null if none. - private Modifier mod2 = null; - - // Returns a filter that matches declarations with no access - // modifiers. - AccessFilter() { - } - - // Returns a filter that matches m. - AccessFilter(Modifier m) { - mod1 = m; - } - - // Returns a filter that matches either m1 or m2. - AccessFilter(Modifier m1, Modifier m2) { - mod1 = m1; - mod2 = m2; - } - - public boolean matches(Declaration d) { - Collection mods = d.getModifiers(); - if (mod1 == null) { // looking for package private - return !(mods.contains(PUBLIC) || - mods.contains(PROTECTED) || - mods.contains(PRIVATE)); - } - return mods.contains(mod1) && - (mod2 == null || mods.contains(mod2)); - } - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/DeclarationScanner.java --- a/src/share/classes/com/sun/mirror/util/DeclarationScanner.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,267 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - -import com.sun.mirror.declaration.*; - -/** - * A visitor for declarations that scans declarations contained within - * the given declaration. For example, when visiting a class, the - * methods, fields, constructors, and nested types of the class are - * also visited. - * - *

To control the processing done on a declaration, users of this - * class pass in their own visitors for pre and post processing. The - * preprocessing visitor is called before the contained declarations - * are scanned; the postprocessing visitor is called after the - * contained declarations are scanned. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this class is {@link - * javax.lang.model.util.ElementScanner6}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -class DeclarationScanner implements DeclarationVisitor { - protected DeclarationVisitor pre; - protected DeclarationVisitor post; - - DeclarationScanner(DeclarationVisitor pre, DeclarationVisitor post) { - this.pre = pre; - this.post = post; - } - - /** - * Visits a declaration. - * - * @param d the declaration to visit - */ - public void visitDeclaration(Declaration d) { - d.accept(pre); - d.accept(post); - } - - /** - * Visits a package declaration. - * - * @param d the declaration to visit - */ - public void visitPackageDeclaration(PackageDeclaration d) { - d.accept(pre); - - for(ClassDeclaration classDecl: d.getClasses()) { - classDecl.accept(this); - } - - for(InterfaceDeclaration interfaceDecl: d.getInterfaces()) { - interfaceDecl.accept(this); - } - - d.accept(post); - } - - /** - * Visits a member or constructor declaration. - * - * @param d the declaration to visit - */ - public void visitMemberDeclaration(MemberDeclaration d) { - visitDeclaration(d); - } - - /** - * Visits a type declaration. - * - * @param d the declaration to visit - */ - public void visitTypeDeclaration(TypeDeclaration d) { - d.accept(pre); - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { - tpDecl.accept(this); - } - - for(FieldDeclaration fieldDecl: d.getFields()) { - fieldDecl.accept(this); - } - - for(MethodDeclaration methodDecl: d.getMethods()) { - methodDecl.accept(this); - } - - for(TypeDeclaration typeDecl: d.getNestedTypes()) { - typeDecl.accept(this); - } - - d.accept(post); - } - - /** - * Visits a class declaration. - * - * @param d the declaration to visit - */ - public void visitClassDeclaration(ClassDeclaration d) { - d.accept(pre); - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { - tpDecl.accept(this); - } - - for(FieldDeclaration fieldDecl: d.getFields()) { - fieldDecl.accept(this); - } - - for(MethodDeclaration methodDecl: d.getMethods()) { - methodDecl.accept(this); - } - - for(TypeDeclaration typeDecl: d.getNestedTypes()) { - typeDecl.accept(this); - } - - for(ConstructorDeclaration ctorDecl: d.getConstructors()) { - ctorDecl.accept(this); - } - - d.accept(post); - } - - /** - * Visits an enum declaration. - * - * @param d the declaration to visit - */ - public void visitEnumDeclaration(EnumDeclaration d) { - visitClassDeclaration(d); - } - - /** - * Visits an interface declaration. - * - * @param d the declaration to visit - */ - public void visitInterfaceDeclaration(InterfaceDeclaration d) { - visitTypeDeclaration(d); - } - - /** - * Visits an annotation type declaration. - * - * @param d the declaration to visit - */ - public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) { - visitInterfaceDeclaration(d); - } - - /** - * Visits a field declaration. - * - * @param d the declaration to visit - */ - public void visitFieldDeclaration(FieldDeclaration d) { - visitMemberDeclaration(d); - } - - /** - * Visits an enum constant declaration. - * - * @param d the declaration to visit - */ - public void visitEnumConstantDeclaration(EnumConstantDeclaration d) { - visitFieldDeclaration(d); - } - - /** - * Visits a method or constructor declaration. - * - * @param d the declaration to visit - */ - public void visitExecutableDeclaration(ExecutableDeclaration d) { - d.accept(pre); - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { - tpDecl.accept(this); - } - - for(ParameterDeclaration pDecl: d.getParameters()) { - pDecl.accept(this); - } - - d.accept(post); - } - - /** - * Visits a constructor declaration. - * - * @param d the declaration to visit - */ - public void visitConstructorDeclaration(ConstructorDeclaration d) { - visitExecutableDeclaration(d); - } - - /** - * Visits a method declaration. - * - * @param d the declaration to visit - */ - public void visitMethodDeclaration(MethodDeclaration d) { - visitExecutableDeclaration(d); - } - - /** - * Visits an annotation type element declaration. - * - * @param d the declaration to visit - */ - public void visitAnnotationTypeElementDeclaration( - AnnotationTypeElementDeclaration d) { - visitMethodDeclaration(d); - } - - /** - * Visits a parameter declaration. - * - * @param d the declaration to visit - */ - public void visitParameterDeclaration(ParameterDeclaration d) { - visitDeclaration(d); - } - - /** - * Visits a type parameter declaration. - * - * @param d the declaration to visit - */ - public void visitTypeParameterDeclaration(TypeParameterDeclaration d) { - visitDeclaration(d); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/DeclarationVisitor.java --- a/src/share/classes/com/sun/mirror/util/DeclarationVisitor.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - -import com.sun.mirror.declaration.*; - - -/** - * A visitor for declarations, in the style of the standard visitor - * design pattern. Classes implementing this interface are used to - * operate on a declaration when the kind of declaration is unknown at - * compile time. When a visitor is passed to a declaration's {@link - * Declaration#accept accept} method, the most specific - * visitXxx method applicable to that declaration is - * invoked. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.ElementVisitor}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface DeclarationVisitor { - - /** - * Visits a declaration. - * @param d the declaration to visit - */ - public void visitDeclaration(Declaration d); - - /** - * Visits a package declaration. - * @param d the declaration to visit - */ - public void visitPackageDeclaration(PackageDeclaration d); - - /** - * Visits a member or constructor declaration. - * @param d the declaration to visit - */ - public void visitMemberDeclaration(MemberDeclaration d); - - /** - * Visits a type declaration. - * @param d the declaration to visit - */ - public void visitTypeDeclaration(TypeDeclaration d); - - /** - * Visits a class declaration. - * @param d the declaration to visit - */ - public void visitClassDeclaration(ClassDeclaration d); - - /** - * Visits an enum declaration. - * @param d the declaration to visit - */ - public void visitEnumDeclaration(EnumDeclaration d); - - /** - * Visits an interface declaration. - * @param d the declaration to visit - */ - public void visitInterfaceDeclaration(InterfaceDeclaration d); - - /** - * Visits an annotation type declaration. - * @param d the declaration to visit - */ - public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d); - - /** - * Visits a field declaration. - * @param d the declaration to visit - */ - public void visitFieldDeclaration(FieldDeclaration d); - - /** - * Visits an enum constant declaration. - * @param d the declaration to visit - */ - public void visitEnumConstantDeclaration(EnumConstantDeclaration d); - - /** - * Visits a method or constructor declaration. - * @param d the declaration to visit - */ - public void visitExecutableDeclaration(ExecutableDeclaration d); - - /** - * Visits a constructor declaration. - * @param d the declaration to visit - */ - public void visitConstructorDeclaration(ConstructorDeclaration d); - - /** - * Visits a method declaration. - * @param d the declaration to visit - */ - public void visitMethodDeclaration(MethodDeclaration d); - - /** - * Visits an annotation type element declaration. - * @param d the declaration to visit - */ - public void visitAnnotationTypeElementDeclaration( - AnnotationTypeElementDeclaration d); - - /** - * Visits a parameter declaration. - * @param d the declaration to visit - */ - public void visitParameterDeclaration(ParameterDeclaration d); - - /** - * Visits a type parameter declaration. - * @param d the declaration to visit - */ - public void visitTypeParameterDeclaration(TypeParameterDeclaration d); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/DeclarationVisitors.java --- a/src/share/classes/com/sun/mirror/util/DeclarationVisitors.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - -/** - * Utilities to create specialized DeclarationVisitor instances. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. There is no direct - * replacement for the functionality of this class in the standardized - * API due to that API's different visitor structure. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public class DeclarationVisitors { - private DeclarationVisitors(){} // do not instantiate. - - /** - * A visitor that has no side effects and keeps no state. - */ - public static final DeclarationVisitor NO_OP = new SimpleDeclarationVisitor(); - - /** - * Return a DeclarationVisitor that will scan the - * declaration structure, visiting declarations contained in - * another declaration. For example, when visiting a class, the - * fields, methods, constructors, etc. of the class are also - * visited. The order in which the contained declarations are scanned is - * not specified. - * - *

The pre and post - * DeclarationVisitor parameters specify, - * respectively, the processing the scanner will do before or - * after visiting the contained declarations. If only one of pre - * and post processing is needed, use {@link - * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the - * other parameter. - * - * @param pre visitor representing processing to do before - * visiting contained declarations. - * - * @param post visitor representing processing to do after - * visiting contained declarations. - */ - public static DeclarationVisitor getDeclarationScanner(DeclarationVisitor pre, - DeclarationVisitor post) { - return new DeclarationScanner(pre, post); - } - - /** - * Return a DeclarationVisitor that will scan the - * declaration structure, visiting declarations contained in - * another declaration in source code order. For example, when - * visiting a class, the fields, methods, constructors, etc. of - * the class are also visited. The order in which the contained - * declarations are visited is as close to source code order as - * possible; declaration mirrors created from class files instead - * of source code will not have source position information. - * - *

The pre and post - * DeclarationVisitor parameters specify, - * respectively, the processing the scanner will do before or - * after visiting the contained declarations. If only one of pre - * and post processing is needed, use {@link - * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the other parameter. - * - * @param pre visitor representing processing to do before - * visiting contained declarations. - * - * @param post visitor representing processing to do after - * visiting contained declarations. - */ - public static DeclarationVisitor getSourceOrderDeclarationScanner(DeclarationVisitor pre, - DeclarationVisitor post) { - return new SourceOrderDeclScanner(pre, post); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/Declarations.java --- a/src/share/classes/com/sun/mirror/util/Declarations.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import com.sun.mirror.declaration.*; - - -/** - * Utility methods for operating on declarations. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.util.Elements}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface Declarations { - - /** - * Tests whether one type, method, or field declaration hides another. - * - * @param sub the first member - * @param sup the second member - * @return true if and only if the first member hides - * the second - */ - boolean hides(MemberDeclaration sub, MemberDeclaration sup); - - /** - * Tests whether one method overrides another. When a - * non-abstract method overrides an abstract one, the - * former is also said to implement the latter. - * - * @param sub the first method - * @param sup the second method - * @return true if and only if the first method overrides - * the second - */ - boolean overrides(MethodDeclaration sub, MethodDeclaration sup); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/SimpleDeclarationVisitor.java --- a/src/share/classes/com/sun/mirror/util/SimpleDeclarationVisitor.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import com.sun.mirror.declaration.*; - - -/** - * A simple visitor for declarations. - * - *

The implementations of the methods of this class do nothing but - * delegate up the declaration hierarchy. A subclass should override the - * methods that correspond to the kinds of declarations on which it - * will operate. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this class is {@link - * javax.lang.model.util.SimpleElementVisitor6}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public class SimpleDeclarationVisitor implements DeclarationVisitor { - - /** - * Creates a new SimpleDeclarationVisitor. - */ - public SimpleDeclarationVisitor(){} - - /** - * Visits a declaration. - * The implementation does nothing. - * @param d the declaration to visit - */ - public void visitDeclaration(Declaration d) { - } - - /** - * Visits a package declaration. - * The implementation simply invokes - * {@link #visitDeclaration visitDeclaration}. - * @param d the declaration to visit - */ - public void visitPackageDeclaration(PackageDeclaration d) { - visitDeclaration(d); - } - - /** - * Visits a member or constructor declaration. - * The implementation simply invokes - * {@link #visitDeclaration visitDeclaration}. - * @param d the declaration to visit - */ - public void visitMemberDeclaration(MemberDeclaration d) { - visitDeclaration(d); - } - - /** - * Visits a type declaration. - * The implementation simply invokes - * {@link #visitMemberDeclaration visitMemberDeclaration}. - * @param d the declaration to visit - */ - public void visitTypeDeclaration(TypeDeclaration d) { - visitMemberDeclaration(d); - } - - /** - * Visits a class declaration. - * The implementation simply invokes - * {@link #visitTypeDeclaration visitTypeDeclaration}. - * @param d the declaration to visit - */ - public void visitClassDeclaration(ClassDeclaration d) { - visitTypeDeclaration(d); - } - - /** - * Visits an enum declaration. - * The implementation simply invokes - * {@link #visitClassDeclaration visitClassDeclaration}. - * @param d the declaration to visit - */ - public void visitEnumDeclaration(EnumDeclaration d) { - visitClassDeclaration(d); - } - - /** - * Visits an interface declaration. - * The implementation simply invokes - * {@link #visitTypeDeclaration visitTypeDeclaration}. - * @param d the declaration to visit - */ - public void visitInterfaceDeclaration(InterfaceDeclaration d) { - visitTypeDeclaration(d); - } - - /** - * Visits an annotation type declaration. - * The implementation simply invokes - * {@link #visitInterfaceDeclaration visitInterfaceDeclaration}. - * @param d the declaration to visit - */ - public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) { - visitInterfaceDeclaration(d); - } - - /** - * Visits a field declaration. - * The implementation simply invokes - * {@link #visitMemberDeclaration visitMemberDeclaration}. - * @param d the declaration to visit - */ - public void visitFieldDeclaration(FieldDeclaration d) { - visitMemberDeclaration(d); - } - - /** - * Visits an enum constant declaration. - * The implementation simply invokes - * {@link #visitFieldDeclaration visitFieldDeclaration}. - * @param d the declaration to visit - */ - public void visitEnumConstantDeclaration(EnumConstantDeclaration d) { - visitFieldDeclaration(d); - } - - /** - * Visits a method or constructor declaration. - * The implementation simply invokes - * {@link #visitMemberDeclaration visitMemberDeclaration}. - * @param d the declaration to visit - */ - public void visitExecutableDeclaration(ExecutableDeclaration d) { - visitMemberDeclaration(d); - } - - /** - * Visits a constructor declaration. - * The implementation simply invokes - * {@link #visitExecutableDeclaration visitExecutableDeclaration}. - * @param d the declaration to visit - */ - public void visitConstructorDeclaration(ConstructorDeclaration d) { - visitExecutableDeclaration(d); - } - - /** - * Visits a method declaration. - * The implementation simply invokes - * {@link #visitExecutableDeclaration visitExecutableDeclaration}. - * @param d the declaration to visit - */ - public void visitMethodDeclaration(MethodDeclaration d) { - visitExecutableDeclaration(d); - } - - /** - * Visits an annotation type element declaration. - * The implementation simply invokes - * {@link #visitMethodDeclaration visitMethodDeclaration}. - * @param d the declaration to visit - */ - public void visitAnnotationTypeElementDeclaration( - AnnotationTypeElementDeclaration d) { - visitMethodDeclaration(d); - } - - /** - * Visits a parameter declaration. - * The implementation simply invokes - * {@link #visitDeclaration visitDeclaration}. - * @param d the declaration to visit - */ - public void visitParameterDeclaration(ParameterDeclaration d) { - visitDeclaration(d); - } - - /** - * Visits a type parameter declaration. - * The implementation simply invokes - * {@link #visitDeclaration visitDeclaration}. - * @param d the declaration to visit - */ - public void visitTypeParameterDeclaration(TypeParameterDeclaration d) { - visitDeclaration(d); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/SimpleTypeVisitor.java --- a/src/share/classes/com/sun/mirror/util/SimpleTypeVisitor.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import com.sun.mirror.type.*; - - -/** - * A simple visitor for types. - * - *

The implementations of the methods of this class do nothing but - * delegate up the type hierarchy. A subclass should override the - * methods that correspond to the kinds of types on which it will - * operate. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this class is {@link - * javax.lang.model.util.SimpleTypeVisitor6}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public class SimpleTypeVisitor implements TypeVisitor { - - /** - * Creates a new SimpleTypeVisitor. - */ - public SimpleTypeVisitor() {} - - /** - * Visits a type mirror. - * The implementation does nothing. - * @param t the type to visit - */ - public void visitTypeMirror(TypeMirror t) { - } - - /** - * Visits a primitive type. - * The implementation simply invokes - * {@link #visitTypeMirror visitTypeMirror}. - * @param t the type to visit - */ - public void visitPrimitiveType(PrimitiveType t) { - visitTypeMirror(t); - } - - /** - * Visits a void type. - * The implementation simply invokes - * {@link #visitTypeMirror visitTypeMirror}. - * @param t the type to visit - */ - public void visitVoidType(VoidType t) { - visitTypeMirror(t); - } - - /** - * Visits a reference type. - * The implementation simply invokes - * {@link #visitTypeMirror visitTypeMirror}. - * @param t the type to visit - */ - public void visitReferenceType(ReferenceType t) { - visitTypeMirror(t); - } - - /** - * Visits a declared type. - * The implementation simply invokes - * {@link #visitReferenceType visitReferenceType}. - * @param t the type to visit - */ - public void visitDeclaredType(DeclaredType t) { - visitReferenceType(t); - } - - /** - * Visits a class type. - * The implementation simply invokes - * {@link #visitDeclaredType visitDeclaredType}. - * @param t the type to visit - */ - public void visitClassType(ClassType t) { - visitDeclaredType(t); - } - - /** - * Visits an enum type. - * The implementation simply invokes - * {@link #visitClassType visitClassType}. - * @param t the type to visit - */ - public void visitEnumType(EnumType t) { - visitClassType(t); - } - - /** - * Visits an interface type. - * The implementation simply invokes - * {@link #visitDeclaredType visitDeclaredType}. - * @param t the type to visit - */ - public void visitInterfaceType(InterfaceType t) { - visitDeclaredType(t); - } - - /** - * Visits an annotation type. - * The implementation simply invokes - * {@link #visitInterfaceType visitInterfaceType}. - * @param t the type to visit - */ - public void visitAnnotationType(AnnotationType t) { - visitInterfaceType(t); - } - - /** - * Visits an array type. - * The implementation simply invokes - * {@link #visitReferenceType visitReferenceType}. - * @param t the type to visit - */ - public void visitArrayType(ArrayType t) { - visitReferenceType(t); - } - - /** - * Visits a type variable. - * The implementation simply invokes - * {@link #visitReferenceType visitReferenceType}. - * @param t the type to visit - */ - public void visitTypeVariable(TypeVariable t) { - visitReferenceType(t); - } - - /** - * Visits a wildcard. - * The implementation simply invokes - * {@link #visitTypeMirror visitTypeMirror}. - * @param t the type to visit - */ - public void visitWildcardType(WildcardType t) { - visitTypeMirror(t); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java --- a/src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,258 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - -import com.sun.mirror.declaration.*; - -import java.util.SortedSet; -import java.util.TreeSet; - -/** - * A visitor for declarations that scans declarations contained within - * the given declaration in source code order. For example, when - * visiting a class, the methods, fields, constructors, and nested - * types of the class are also visited. - * - * To control the processing done on a declaration, users of this - * class pass in their own visitors for pre and post processing. The - * preprocessing visitor is called before the contained declarations - * are scanned; the postprocessing visitor is called after the - * contained declarations are scanned. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this class is {@link - * javax.lang.model.util.SimpleElementVisitor6}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -class SourceOrderDeclScanner extends DeclarationScanner { - static class SourceOrderComparator implements java.util.Comparator { - SourceOrderComparator(){} - - - static boolean equals(Declaration d1, Declaration d2) { - return d1 == d2 || (d1 != null && d1.equals(d2)); - } - - private static class DeclPartialOrder extends com.sun.mirror.util.SimpleDeclarationVisitor { - private int value = 1000; - private static int staticAdjust(Declaration d) { - return d.getModifiers().contains(Modifier.STATIC)?0:1; - } - - DeclPartialOrder() {} - - public int getValue() { return value; } - - @Override - public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {value = 0;} - - @Override - public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {value = 1;} - - @Override - public void visitClassDeclaration(ClassDeclaration d) {value = 2 + staticAdjust(d);} - - @Override - public void visitInterfaceDeclaration(InterfaceDeclaration d) {value = 4;} - - @Override - public void visitEnumDeclaration(EnumDeclaration d) {value = 6;} - - @Override - public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {value = 8;} - - @Override - public void visitFieldDeclaration(FieldDeclaration d) {value = 10 + staticAdjust(d);} - - @Override - public void visitConstructorDeclaration(ConstructorDeclaration d) {value = 12;} - - @Override - public void visitMethodDeclaration(MethodDeclaration d) {value = 14 + staticAdjust(d);} - } - @SuppressWarnings("cast") - private int compareEqualPosition(Declaration d1, Declaration d2) { - assert - (d1.getPosition() == d2.getPosition()) || // Handles two null positions. - (d1.getPosition().file().compareTo(d2.getPosition().file()) == 0 && - d1.getPosition().line() == d2.getPosition().line() && - d1.getPosition().column() == d2.getPosition().column()); - - DeclPartialOrder dpo1 = new DeclPartialOrder(); - DeclPartialOrder dpo2 = new DeclPartialOrder(); - - d1.accept(dpo1); - d2.accept(dpo2); - - int difference = dpo1.getValue() - dpo2.getValue(); - if (difference != 0) - return difference; - else { - int result = d1.getSimpleName().compareTo(d2.getSimpleName()); - if (result != 0) - return result; - return (int)( Long.signum((long)System.identityHashCode(d1) - - (long)System.identityHashCode(d2))); - } - } - - public int compare(Declaration d1, Declaration d2) { - if (equals(d1, d2)) - return 0; - - SourcePosition p1 = d1.getPosition(); - SourcePosition p2 = d2.getPosition(); - - if (p1 == null && p2 != null) - return 1; - else if (p1 != null && p2 == null) - return -1; - else if(p1 == null && p2 == null) - return compareEqualPosition(d1, d2); - else { - assert p1 != null && p2 != null; - int fileComp = p1.file().compareTo(p2.file()) ; - if (fileComp == 0) { - long diff = (long)p1.line() - (long)p2.line(); - if (diff == 0) { - diff = Long.signum((long)p1.column() - (long)p2.column()); - if (diff != 0) - return (int)diff; - else { - // declarations may be two - // compiler-generated members with the - // same source position - return compareEqualPosition(d1, d2); - } - } else - return (diff<0)? -1:1; - } else - return fileComp; - } - } - } - - final static java.util.Comparator comparator = new SourceOrderComparator(); - - SourceOrderDeclScanner(DeclarationVisitor pre, DeclarationVisitor post) { - super(pre, post); - } - - /** - * Visits a type declaration. - * - * @param d the declaration to visit - */ - public void visitTypeDeclaration(TypeDeclaration d) { - d.accept(pre); - - SortedSet decls = new - TreeSet(SourceOrderDeclScanner.comparator) ; - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { - decls.add(tpDecl); - } - - for(FieldDeclaration fieldDecl: d.getFields()) { - decls.add(fieldDecl); - } - - for(MethodDeclaration methodDecl: d.getMethods()) { - decls.add(methodDecl); - } - - for(TypeDeclaration typeDecl: d.getNestedTypes()) { - decls.add(typeDecl); - } - - for(Declaration decl: decls ) - decl.accept(this); - - d.accept(post); - } - - /** - * Visits a class declaration. - * - * @param d the declaration to visit - */ - public void visitClassDeclaration(ClassDeclaration d) { - d.accept(pre); - - SortedSet decls = new - TreeSet(SourceOrderDeclScanner.comparator) ; - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { - decls.add(tpDecl); - } - - for(FieldDeclaration fieldDecl: d.getFields()) { - decls.add(fieldDecl); - } - - for(MethodDeclaration methodDecl: d.getMethods()) { - decls.add(methodDecl); - } - - for(TypeDeclaration typeDecl: d.getNestedTypes()) { - decls.add(typeDecl); - } - - for(ConstructorDeclaration ctorDecl: d.getConstructors()) { - decls.add(ctorDecl); - } - - for(Declaration decl: decls ) - decl.accept(this); - - d.accept(post); - } - - public void visitExecutableDeclaration(ExecutableDeclaration d) { - d.accept(pre); - - SortedSet decls = new - TreeSet(SourceOrderDeclScanner.comparator) ; - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) - decls.add(tpDecl); - - for(ParameterDeclaration pDecl: d.getParameters()) - decls.add(pDecl); - - for(Declaration decl: decls ) - decl.accept(this); - - d.accept(post); - } - -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/SourcePosition.java --- a/src/share/classes/com/sun/mirror/util/SourcePosition.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import java.io.File; - - -/** - * Represents a position in a source file. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. There is no direct - * replacement for the functionality of this interface since the - * standardized {@link javax.annotation.processing.Messager Messager} - * API implicitly takes a source position argument via any element, - * annotation mirror, or annotation value passed along with the - * message. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface SourcePosition { - - /** - * Returns the source file containing this position. - * - * @return the source file containing this position; never null - */ - File file(); - - /** - * Returns the line number of this position. Lines are numbered - * starting with 1. - * - * @return the line number of this position, or 0 if the line - * number is unknown or not applicable - */ - int line(); - - /** - * Returns the column number of this position. Columns are numbered - * starting with 1. - * - * @return the column number of this position, or 0 if the column - * number is unknown or not applicable - */ - int column(); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/TypeVisitor.java --- a/src/share/classes/com/sun/mirror/util/TypeVisitor.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import com.sun.mirror.type.*; - - -/** - * A visitor for types, in the style of the standard visitor design pattern. - * This is used to operate on a type when the kind - * of type is unknown at compile time. - * When a visitor is passed to a type's - * {@link TypeMirror#accept accept} method, - * the most specific visitXxx method applicable to - * that type is invoked. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.TypeVisitor}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface TypeVisitor { - - /** - * Visits a type mirror. - * - * @param t the type to visit - */ - public void visitTypeMirror(TypeMirror t); - - /** - * Visits a primitive type. - - * @param t the type to visit - */ - public void visitPrimitiveType(PrimitiveType t); - - /** - * Visits a void type. - * - * @param t the type to visit - */ - public void visitVoidType(VoidType t); - - /** - * Visits a reference type. - * - * @param t the type to visit - */ - public void visitReferenceType(ReferenceType t); - - /** - * Visits a declared type. - * - * @param t the type to visit - */ - public void visitDeclaredType(DeclaredType t); - - /** - * Visits a class type. - * - * @param t the type to visit - */ - public void visitClassType(ClassType t); - - /** - * Visits an enum type. - * - * @param t the type to visit - */ - public void visitEnumType(EnumType t); - - /** - * Visits an interface type. - * - * @param t the type to visit - */ - public void visitInterfaceType(InterfaceType t); - - /** - * Visits an annotation type. - * - * @param t the type to visit - */ - public void visitAnnotationType(AnnotationType t); - - /** - * Visits an array type. - * - * @param t the type to visit - */ - public void visitArrayType(ArrayType t); - - /** - * Visits a type variable. - * - * @param t the type to visit - */ - public void visitTypeVariable(TypeVariable t); - - /** - * Visits a wildcard. - * - * @param t the type to visit - */ - public void visitWildcardType(WildcardType t); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/Types.java --- a/src/share/classes/com/sun/mirror/util/Types.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; - - -/** - * Utility methods for operating on types. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.util.Types}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface Types { - - /** - * Tests whether one type is a subtype of the another. - * Any type is considered to be a subtype of itself. - * - * @param t1 the first type - * @param t2 the second type - * @return true if and only if the first type is a subtype - * of the second - */ - boolean isSubtype(TypeMirror t1, TypeMirror t2); - - /** - * Tests whether one type is assignable to another. - * - * @param t1 the first type - * @param t2 the second type - * @return true if and only if the first type is assignable - * to the second - */ - boolean isAssignable(TypeMirror t1, TypeMirror t2); - - /** - * Returns the erasure of a type. - * - * @param t the type to be erased - * @return the erasure of the given type - */ - TypeMirror getErasure(TypeMirror t); - - /** - * Returns a primitive type. - * - * @param kind the kind of primitive type to return - * @return a primitive type - */ - PrimitiveType getPrimitiveType(PrimitiveType.Kind kind); - - /** - * Returns the pseudo-type representing the type of void. - * - * @return the pseudo-type representing the type of void - */ - VoidType getVoidType(); - - /** - * Returns an array type with the specified component type. - * - * @param componentType the component type - * @return an array type with the specified component type. - * @throws IllegalArgumentException if the component type is not valid for - * an array - */ - ArrayType getArrayType(TypeMirror componentType); - - /** - * Returns the type variable declared by a type parameter. - * - * @param tparam the type parameter - * @return the type variable declared by the type parameter - */ - TypeVariable getTypeVariable(TypeParameterDeclaration tparam); - - /** - * Returns a new wildcard. - * Either the wildcards's upper bounds or lower bounds may be - * specified, or neither, but not both. - * - * @param upperBounds the upper bounds of this wildcard, - * or an empty collection if none - * @param lowerBounds the lower bounds of this wildcard, - * or an empty collection if none - * @return a new wildcard - * @throws IllegalArgumentException if bounds are not valid - */ - WildcardType getWildcardType(Collection upperBounds, - Collection lowerBounds); - - /** - * Returns the type corresponding to a type declaration and - * actual type arguments. - * Given the declaration for String, for example, this - * method may be used to get the String type. It may - * then be invoked a second time, with the declaration for Set, - * to make the parameterized type {@code Set}. - * - *

The number of type arguments must either equal the - * number of the declaration's formal type parameters, or must be - * zero. If zero, and if the declaration is generic, - * then the declaration's raw type is returned. - * - *

If a parameterized type is being returned, its declaration - * must not be contained within a generic outer class. - * The parameterized type {@code Outer.Inner}, - * for example, may be constructed by first using this - * method to get the type {@code Outer}, and then invoking - * {@link #getDeclaredType(DeclaredType, TypeDeclaration, TypeMirror...)}. - * - * @param decl the type declaration - * @param typeArgs the actual type arguments - * @return the type corresponding to the type declaration and - * actual type arguments - * @throws IllegalArgumentException if too many or too few - * type arguments are given, or if an inappropriate type - * argument or declaration is provided - */ - DeclaredType getDeclaredType(TypeDeclaration decl, - TypeMirror... typeArgs); - - /** - * Returns the type corresponding to a type declaration - * and actual arguments, given a - * {@linkplain DeclaredType#getContainingType() containing type} - * of which it is a member. - * The parameterized type {@code Outer.Inner}, - * for example, may be constructed by first using - * {@link #getDeclaredType(TypeDeclaration, TypeMirror...)} - * to get the type {@code Outer}, and then invoking - * this method. - * - *

If the containing type is a parameterized type, - * the number of type arguments must equal the - * number of the declaration's formal type parameters. - * If it is not parameterized or if it is null, this method is - * equivalent to getDeclaredType(decl, typeArgs). - * - * @param containing the containing type, or null if none - * @param decl the type declaration - * @param typeArgs the actual type arguments - * @return the type corresponding to the type declaration and - * actual type arguments, - * contained within the given type - * @throws IllegalArgumentException if too many or too few - * type arguments are given, or if an inappropriate type - * argument, declaration, or containing type is provided - */ - DeclaredType getDeclaredType(DeclaredType containing, - TypeDeclaration decl, - TypeMirror... typeArgs); -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/mirror/util/package-info.java --- a/src/share/classes/com/sun/mirror/util/package-info.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Utilities to assist in the processing of {@linkplain - * com.sun.mirror.declaration declarations} and {@linkplain - * com.sun.mirror.type types}. - * - *

The {@code apt} tool and its associated API have been superseded - * by the standardized annotation processing API. The replacement for - * the functionality in this package is {@link javax.lang.model.util}. - * - * @since 1.5 - */ -package com.sun.mirror.util; diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/source/tree/LambdaExpressionTree.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.tree; + +import java.util.List; + +/** + * A tree node for a lambda expression. + * + * For example: + *

+ *   ()->{}
+ *   (List ls)->ls.size()
+ *   (x,y)-> { return x + y; }
+ * 
+ */ +public interface LambdaExpressionTree extends ExpressionTree { + + /** + * Lambda expressions come in two forms: (i) expression lambdas, whose body + * is an expression, and (ii) statement lambdas, whose body is a block + */ + public enum BodyKind { + /** enum constant for expression lambdas */ + EXPRESSION, + /** enum constant for statement lambdas */ + STATEMENT; + } + + List getParameters(); + Tree getBody(); + BodyKind getBodyKind(); +} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/source/tree/MemberReferenceTree.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/source/tree/MemberReferenceTree.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.source.tree; + +import java.util.List; + +import javax.lang.model.element.Name; + +/** + * A tree node for a member reference expression. + * + * For example: + *
+ *   expression # [ identifier | new ]
+ * 
+ * + * @since 1.8 + */ +public interface MemberReferenceTree extends ExpressionTree { + + /** + * There are two kinds of member references: (i) method references and + * (ii) constructor references + */ + public enum ReferenceMode { + /** enum constant for method references */ + INVOKE, + /** enum constant for constructor references */ + NEW + } + ReferenceMode getMode(); + ExpressionTree getQualifierExpression(); + Name getName(); + List getTypeArguments(); +} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/source/tree/Tree.java --- a/src/share/classes/com/sun/source/tree/Tree.java Mon Jul 11 22:31:52 2011 +0100 +++ b/src/share/classes/com/sun/source/tree/Tree.java Tue May 29 00:27:58 2012 +0100 @@ -132,6 +132,11 @@ MEMBER_SELECT(MemberSelectTree.class), /** + * Used for instances of {@link MemberReferenceTree}. + */ + MEMBER_REFERENCE(MemberReferenceTree.class), + + /** * Used for instances of {@link ForLoopTree}. */ FOR_LOOP(ForLoopTree.class), @@ -187,6 +192,11 @@ NEW_CLASS(NewClassTree.class), /** + * Used for instances of {@link LambdaExpressionTree}. + */ + LAMBDA_EXPRESSION(LambdaExpressionTree.class), + + /** * Used for instances of {@link ParenthesizedTree}. */ PARENTHESIZED(ParenthesizedTree.class), diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/source/tree/TreeVisitor.java --- a/src/share/classes/com/sun/source/tree/TreeVisitor.java Mon Jul 11 22:31:52 2011 +0100 +++ b/src/share/classes/com/sun/source/tree/TreeVisitor.java Tue May 29 00:27:58 2012 +0100 @@ -85,9 +85,11 @@ R visitModifiers(ModifiersTree node, P p); R visitNewArray(NewArrayTree node, P p); R visitNewClass(NewClassTree node, P p); + R visitLambdaExpression(LambdaExpressionTree node, P p); R visitParenthesized(ParenthesizedTree node, P p); R visitReturn(ReturnTree node, P p); R visitMemberSelect(MemberSelectTree node, P p); + R visitMemberReference(MemberReferenceTree node, P p); R visitEmptyStatement(EmptyStatementTree node, P p); R visitSwitch(SwitchTree node, P p); R visitSynchronized(SynchronizedTree node, P p); diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/source/util/JavacTask.java --- a/src/share/classes/com/sun/source/util/JavacTask.java Mon Jul 11 22:31:52 2011 +0100 +++ b/src/share/classes/com/sun/source/util/JavacTask.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,9 +25,9 @@ package com.sun.source.util; -import com.sun.source.tree.CompilationUnitTree; -import com.sun.source.tree.Tree; import java.io.IOException; + +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.Elements; @@ -35,6 +35,12 @@ import javax.tools.JavaCompiler.CompilationTask; import javax.tools.JavaFileObject; +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.Tree; +import com.sun.tools.javac.api.BasicJavacTask; +import com.sun.tools.javac.processing.JavacProcessingEnvironment; +import com.sun.tools.javac.util.Context; + /** * Provides access to functionality specific to the JDK Java Compiler, javac. * @@ -45,10 +51,29 @@ public abstract class JavacTask implements CompilationTask { /** + * Get the {@code JavacTask} for a {@code ProcessingEnvironment}. + * If the compiler is being invoked using a + * {@link javax.tools.JavaCompiler.CompilationTask CompilationTask}, + * then that task will be returned. + * @param processingEnvironment + * @return the {@code JavacTask} for a {@code ProcessingEnvironment} + * @since 1.8 + */ + public static JavacTask instance(ProcessingEnvironment processingEnvironment) { + if (!processingEnvironment.getClass().getName().equals( + "com.sun.tools.javac.processing.JavacProcessingEnvironment")) + throw new IllegalArgumentException(); + Context c = ((JavacProcessingEnvironment) processingEnvironment).getContext(); + JavacTask t = c.get(JavacTask.class); + return (t != null) ? t : new BasicJavacTask(c, true); + } + + /** * Parse the specified files returning a list of abstract syntax trees. * * @return a list of abstract syntax trees * @throws IOException if an unhandled I/O error occurred in the compiler. + * @throws IllegalStateException if the operation cannot be performed at this time. */ public abstract Iterable parse() throws IOException; @@ -58,6 +83,7 @@ * * @return a list of elements that were analyzed * @throws IOException if an unhandled I/O error occurred in the compiler. + * @throws IllegalStateException if the operation cannot be performed at this time. */ public abstract Iterable analyze() throws IOException; @@ -66,17 +92,51 @@ * * @return a list of files that were generated * @throws IOException if an unhandled I/O error occurred in the compiler. + * @throws IllegalStateException if the operation cannot be performed at this time. */ public abstract Iterable generate() throws IOException; /** - * The specified listener will receive events describing the progress of - * this compilation task. + * The specified listener will receive notification of events + * describing the progress of this compilation task. + * + * If another listener is receiving notifications as a result of a prior + * call of this method, then that listener will no longer receive notifications. + * + * Informally, this method is equivalent to calling {@code removeTaskListener} for + * any listener that has been previously set, followed by {@code addTaskListener} + * for the new listener. + * + * @throws IllegalStateException if the specified listener has already been added. */ public abstract void setTaskListener(TaskListener taskListener); /** + * The specified listener will receive notification of events + * describing the progress of this compilation task. + * + * This method may be called at any time before or during the compilation. + * + * @throws IllegalStateException if the specified listener has already been added. + * @since 1.8 + */ + public abstract void addTaskListener(TaskListener taskListener); + + /** + * The specified listener will no longer receive notification of events + * describing the progress of this compilation task. + * + * This method may be called at any time before or during the compilation. + * + * @since 1.8 + */ + public abstract void removeTaskListener(TaskListener taskListener); + + /** * Get a type mirror of the tree node determined by the specified path. + * This method has been superceded by methods on + * {@link com.sun.source.util.Trees Trees}. + * @see com.sun.source.util.Trees#getTypeMirror */ public abstract TypeMirror getTypeMirror(Iterable path); /** diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/source/util/SimpleTreeVisitor.java --- a/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Mon Jul 11 22:31:52 2011 +0100 +++ b/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Tue May 29 00:27:58 2012 +0100 @@ -172,6 +172,10 @@ return defaultAction(node, p); } + public R visitLambdaExpression(LambdaExpressionTree node, P p) { + return defaultAction(node, p); + } + public R visitParenthesized(ParenthesizedTree node, P p) { return defaultAction(node, p); } @@ -208,6 +212,10 @@ return defaultAction(node, p); } + public R visitMemberReference(MemberReferenceTree node, P p) { + return defaultAction(node, p); + } + public R visitIdentifier(IdentifierTree node, P p) { return defaultAction(node, p); } diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/source/util/TreeScanner.java --- a/src/share/classes/com/sun/source/util/TreeScanner.java Mon Jul 11 22:31:52 2011 +0100 +++ b/src/share/classes/com/sun/source/util/TreeScanner.java Tue May 29 00:27:58 2012 +0100 @@ -285,6 +285,12 @@ return r; } + public R visitLambdaExpression(LambdaExpressionTree node, P p) { + R r = scan(node.getParameters(), p); + r = scanAndReduce(node.getBody(), p, r); + return r; + } + public R visitParenthesized(ParenthesizedTree node, P p) { return scan(node.getExpression(), p); } @@ -333,6 +339,12 @@ return scan(node.getExpression(), p); } + public R visitMemberReference(MemberReferenceTree node, P p) { + R r = scan(node.getQualifierExpression(), p); + r = scanAndReduce(node.getTypeArguments(), p, r); + return r; + } + public R visitIdentifier(IdentifierTree node, P p) { return null; } diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/Main.java --- a/src/share/classes/com/sun/tools/apt/Main.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt; - -import java.io.PrintWriter; -import com.sun.mirror.apt.AnnotationProcessorFactory; - -/** - * The main program for the command-line tool apt. - * - *

Nothing described in this source file is part of any supported - * API. If you write code that depends on this, you do so at your own - * risk. This code and its internal interfaces are subject to change - * or deletion without notice. - */ -public class Main { - - static { - ClassLoader loader = Main.class.getClassLoader(); - if (loader != null) - loader.setPackageAssertionStatus("com.sun.tools.apt", true); - } - - /** Command line interface. If args is null, a - * NullPointerException is thrown. - * @param args The command line parameters. - */ - public static void main(String... args) { - System.exit(process(args)); - } - - /** Programatic interface. If args is null, a - * NullPointerException is thrown. - * Output is directed to System.err. - * @param args The command line parameters. - */ - public static int process(String... args) { - return processing(null, null, args); - } - - /** Programmatic interface. If any argument - * is null, a NullPointerException is thrown. - * @param args The command line parameters. - * @param out Where the tool's output is directed. - */ - public static int process(PrintWriter out, String... args) { - if (out == null) - throw new NullPointerException("Parameter out cannot be null."); - return processing(null, out, args); - } - - /** Programmatic interface. If factory or args - * is null, a NullPointerException is thrown. - * The "-factory" and "-factorypath" - * command line parameters are ignored by this entry point. - * Output is directed to System.err. - * - * @param factory The annotation processor factory to use - * @param args The command line parameters. - */ - public static int process(AnnotationProcessorFactory factory, String... args) { - return process(factory, new PrintWriter(System.err, true), args); - } - - /** Programmatic interface. If any argument - * is null, a NullPointerException is thrown. - * The "-factory" and "-factorypath" - * command line parameters are ignored by this entry point. - * - * @param factory The annotation processor factory to use - * @param args The command line parameters. - * @param out Where the tool's output is directed. - */ - public static int process(AnnotationProcessorFactory factory, PrintWriter out, - String... args) { - if (out == null) - throw new NullPointerException("Parameter out cannot be null."); - if (factory == null) - throw new NullPointerException("Parameter factory cannot be null"); - return processing(factory, out, args); - } - - private static int processing(AnnotationProcessorFactory factory, - PrintWriter out, - String... args) { - if (out == null) - out = new PrintWriter(System.err, true); - com.sun.tools.apt.main.Main compiler = - new com.sun.tools.apt.main.Main("apt", out); - return compiler.compile(args, factory); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java --- a/src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.comp; - -public class AnnotationProcessingError extends Error { - private static final long serialVersionUID = 3279196183341719287L; - AnnotationProcessingError(Throwable cause) { - super(cause); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/comp/Apt.java --- a/src/share/classes/com/sun/tools/apt/comp/Apt.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,509 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.comp; - -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.comp.*; -import com.sun.tools.javac.tree.*; -import com.sun.tools.javac.util.*; -import com.sun.tools.javac.tree.TreeScanner; -import com.sun.tools.javac.util.Context; -import com.sun.tools.apt.util.Bark; -import com.sun.tools.javac.util.Position; - -import java.util.*; -import java.util.regex.*; -import java.lang.reflect.*; -import java.lang.reflect.InvocationTargetException; -import java.io.IOException; - -import com.sun.tools.apt.*; -import com.sun.tools.apt.comp.*; -import com.sun.tools.javac.code.Symbol.*; - -import com.sun.mirror.declaration.TypeDeclaration; -import com.sun.mirror.declaration.AnnotationTypeDeclaration; -import com.sun.mirror.apt.*; -// import com.sun.mirror.apt.AnnotationProcessorFactory; -import com.sun.mirror.apt.AnnotationProcessors; - -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.apt.mirror.apt.FilerImpl; -import com.sun.tools.apt.mirror.apt.AnnotationProcessorEnvironmentImpl; - - -import static com.sun.tools.apt.mirror.declaration.DeclarationMaker.isJavaIdentifier; - -/** - * Apt compiler phase. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own - * risk. This code and its internal interfaces are subject to change - * or deletion without notice. - */ -@SuppressWarnings("deprecation") -public class Apt extends ListBuffer> { - java.util.Set genSourceFileNames = new java.util.LinkedHashSet(); - public java.util.Set getSourceFileNames() { - return genSourceFileNames; - } - - /** List of names of generated class files. - */ - java.util.Set genClassFileNames = new java.util.LinkedHashSet(); - public java.util.Set getClassFileNames() { - return genClassFileNames; - } - - /* AptEnvironment */ - AptEnv aptenv; - - private Context context; - - /** The context key for the todo list. */ - - protected static final Context.Key aptKey = - new Context.Key(); - - /** Get the Apt instance for this context. */ - public static Apt instance(Context context) { - Apt instance = context.get(aptKey); - if (instance == null) - instance = new Apt(context); - return instance; - } - - /** Create a new apt list. */ - protected Apt(Context context) { - this.context = context; - - context.put(aptKey, this); - aptenv = AptEnv.instance(context); - } - - /** - * Used to scan javac trees to build data structures needed for - * bootstrapping the apt environment. In particular: - * - *

    - * - *
  • Generate list of canonical names of annotation types that - * appear in source files given on the command line - * - *
  • Collect list of javac symbols representing source files - * given on the command line - * - *
- */ - static class AptTreeScanner extends TreeScanner { - - // Set of fully qualified names of annotation types present in - // examined source - private Set annotationSet; - - // Symbols to build bootstrapping declaration list - private Collection specifiedDeclCollection; - private Collection declCollection; - - public Set getAnnotationSet() { - return annotationSet; - } - - public AptTreeScanner() { - annotationSet = new LinkedHashSet(); - specifiedDeclCollection = new LinkedHashSet(); - declCollection = new LinkedHashSet(); - } - - public void visitTopLevel(JCTree.JCCompilationUnit tree) { - super.visitTopLevel(tree); - // Print out contents -- what are we dealing with? - - for(JCTree d: tree.defs) { - if (d instanceof JCTree.JCClassDecl) - specifiedDeclCollection.add(((JCTree.JCClassDecl) d).sym); - } - - } - - public void visitBlock(JCTree.JCBlock tree) { - ; // Do nothing. - } - - - // should add nested classes to packages, etc. - public void visitClassDef(JCTree.JCClassDecl tree) { - if (tree.sym == null) { - // could be an anon class w/in an initializer - return; - } - - super.visitClassDef(tree); - - declCollection.add(tree.sym); - } - - public void visitMethodDef(JCTree.JCMethodDecl tree) { - super.visitMethodDef(tree); - } - - public void visitVarDef(JCTree.JCVariableDecl tree) { - super.visitVarDef(tree); - } - - public void visitAnnotation(JCTree.JCAnnotation tree) { - super.visitAnnotation(tree); - annotationSet.add(tree.type.tsym.toString()); - } - } - - Set computeAnnotationSet(Collection classSymbols) { - Set annotationSet = new HashSet(); - - for(ClassSymbol classSymbol: classSymbols) { - computeAnnotationSet(classSymbol, annotationSet); - } - return annotationSet; - } - - void computeAnnotationSet(Symbol symbol, Set annotationSet) { - if (symbol != null ) { - if (symbol.getAnnotationMirrors() != null) - for(Attribute.Compound compound: symbol.getAnnotationMirrors()) - annotationSet.add(compound.type.tsym.toString()); // should fullName be used instead of toString? - - if (symbol instanceof Symbol.MethodSymbol) // add parameter annotations - for(Symbol param: ((MethodSymbol) symbol).params()) - computeAnnotationSet(param, annotationSet); - - if (symbol.members() != null) { - for(Scope.Entry e = symbol.members().elems; e != null; e = e.sibling) - computeAnnotationSet(e.sym, annotationSet); - } - } - } - - public void main(com.sun.tools.javac.util.List treeList, - ListBuffer classes, - Map origOptions, - ClassLoader aptCL, - AnnotationProcessorFactory providedFactory, - java.util.Set > productiveFactories) { - Bark bark = Bark.instance(context); - java.io.PrintWriter out = bark.warnWriter; - Options options = Options.instance(context); - - Collection spectypedecls = new LinkedHashSet(); - Collection typedecls = new LinkedHashSet(); - Set unmatchedAnnotations = new LinkedHashSet(); - Set emptyATDS = Collections.emptySet(); - Set > currentRoundFactories = - new LinkedHashSet >(); - - // Determine what annotations are present on the input source - // files, create collections of specified type declarations, - // and type declarations. - AptTreeScanner ats = new AptTreeScanner(); - for(JCTree t: treeList) { - t.accept(ats); - } - - // Turn collection of ClassSymbols into Collection of apt decls - for (ClassSymbol cs : ats.specifiedDeclCollection) { - TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs); - spectypedecls.add(decl); - } - - for (ClassSymbol cs : ats.declCollection) { - TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs); - typedecls.add(decl); - } - - unmatchedAnnotations.addAll(ats.getAnnotationSet()); - - // Process input class files - for(ClassSymbol cs : classes) { - TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs); - // System.out.println("Adding a class to spectypedecls"); - spectypedecls.add(decl); - typedecls.add(decl); - computeAnnotationSet(cs, unmatchedAnnotations); - } - - if (options.get("-XListAnnotationTypes") != null) { - out.println("Set of annotations found:" + - (new TreeSet(unmatchedAnnotations)).toString()); - } - - AnnotationProcessorEnvironmentImpl trivAPE = - new AnnotationProcessorEnvironmentImpl(spectypedecls, typedecls, origOptions, context); - - if (options.get("-XListDeclarations") != null) { - out.println("Set of Specified Declarations:" + - spectypedecls); - - out.println("Set of Included Declarations: " + - typedecls); - } - - if (options.get("-print") != null) { - if (spectypedecls.size() == 0 ) - throw new UsageMessageNeededException(); - - // Run the printing processor - AnnotationProcessor proc = (new BootstrapAPF()).getProcessorFor(new HashSet(), - trivAPE); - proc.process(); - } else { - // Discovery process - - // List of annotation processory factory instances - java.util.Iterator providers = null; - { - /* - * If a factory is provided by the user, the - * "-factory" and "-factorypath" options are not used. - * - * Otherwise, if the "-factory" option is used, search - * the appropriate path for the named class. - * Otherwise, use sun.misc.Service to implement the - * default discovery policy. - */ - - java.util.List list = - new LinkedList(); - String factoryName = options.get("-factory"); - - if (providedFactory != null) { - list.add(providedFactory); - providers = list.iterator(); - } else if (factoryName != null) { - try { - AnnotationProcessorFactory factory = - (AnnotationProcessorFactory) (aptCL.loadClass(factoryName).newInstance()); - list.add(factory); - } catch (ClassNotFoundException cnfe) { - bark.aptWarning("FactoryNotFound", factoryName); - } catch (ClassCastException cce) { - bark.aptWarning("FactoryWrongType", factoryName); - } catch (Exception e ) { - bark.aptWarning("FactoryCantInstantiate", factoryName); - } catch(Throwable t) { - throw new AnnotationProcessingError(t); - } - - providers = list.iterator(); - } else { - @SuppressWarnings("unchecked") - Iterator iter = - sun.misc.Service.providers(AnnotationProcessorFactory.class, aptCL); - providers = iter; - - } - } - - java.util.Map> factoryToAnnotation = - new LinkedHashMap>(); - - if (!providers.hasNext() && productiveFactories.size() == 0) { - if (unmatchedAnnotations.size() > 0) - bark.aptWarning("NoAnnotationProcessors"); - if (spectypedecls.size() == 0) - throw new UsageMessageNeededException(); - return; // no processors; nothing else to do - } else { - // If there are no annotations, still give - // processors that match everything a chance to - // run. - - if(unmatchedAnnotations.size() == 0) - unmatchedAnnotations.add(""); - - Set emptyStringSet = new HashSet(); - emptyStringSet.add(""); - emptyStringSet = Collections.unmodifiableSet(emptyStringSet); - - while (providers.hasNext() ) { - Object provider = providers.next(); - try { - Set matchedStrings = new HashSet(); - - AnnotationProcessorFactory apf = (AnnotationProcessorFactory) provider; - Collection supportedTypes = apf.supportedAnnotationTypes(); - - Collection supportedTypePatterns = new LinkedList(); - for(String s: supportedTypes) - supportedTypePatterns.add(importStringToPattern(s)); - - for(String s: unmatchedAnnotations) { - for(Pattern p: supportedTypePatterns) { - if (p.matcher(s).matches()) { - matchedStrings.add(s); - break; - } - } - } - - unmatchedAnnotations.removeAll(matchedStrings); - - if (options.get("-XPrintFactoryInfo") != null) { - out.println("Factory " + apf.getClass().getName() + - " matches " + - ((matchedStrings.size() == 0)? - "nothing.": matchedStrings)); - } - - if (matchedStrings.size() > 0) { - // convert annotation names to annotation - // type decls - Set atds = new HashSet(); - - // If a "*" processor is called on the - // empty string, pass in an empty set of - // annotation type declarations. - if (!matchedStrings.equals(emptyStringSet)) { - for(String s: matchedStrings) { - TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(s); - AnnotationTypeDeclaration annotdecl; - if (decl == null) { - bark.aptError("DeclarationCreation", s); - } else { - try { - annotdecl = (AnnotationTypeDeclaration)decl; - atds.add(annotdecl); - - } catch (ClassCastException cce) { - bark.aptError("BadDeclaration", s); - } - } - } - } - - currentRoundFactories.add(apf.getClass()); - productiveFactories.add(apf.getClass()); - factoryToAnnotation.put(apf, atds); - } else if (productiveFactories.contains(apf.getClass())) { - // If a factory provided a processor in a - // previous round but doesn't match any - // annotations this round, call it with an - // empty set of declarations. - currentRoundFactories.add(apf.getClass()); - factoryToAnnotation.put(apf, emptyATDS ); - } - - if (unmatchedAnnotations.size() == 0) - break; - - } catch (ClassCastException cce) { - bark.aptWarning("BadFactory", cce); - } - } - - unmatchedAnnotations.remove(""); - } - - // If the set difference of productiveFactories and - // currentRoundFactories is non-empty, call the remaining - // productive factories with an empty set of declarations. - { - java.util.Set > neglectedFactories = - new LinkedHashSet>(productiveFactories); - neglectedFactories.removeAll(currentRoundFactories); - for(Class working : neglectedFactories) { - try { - AnnotationProcessorFactory factory = working.newInstance(); - factoryToAnnotation.put(factory, emptyATDS); - } catch (Exception e ) { - bark.aptWarning("FactoryCantInstantiate", working.getName()); - } catch(Throwable t) { - throw new AnnotationProcessingError(t); - } - } - } - - if (unmatchedAnnotations.size() > 0) - bark.aptWarning("AnnotationsWithoutProcessors", unmatchedAnnotations); - - Set processors = new LinkedHashSet(); - - // If there were no source files AND no factory matching "*", - // make sure the usage message is printed - if (spectypedecls.size() == 0 && - factoryToAnnotation.keySet().size() == 0 ) - throw new UsageMessageNeededException(); - - try { - for(Map.Entry> entry : - factoryToAnnotation.entrySet()) { - AnnotationProcessorFactory apFactory = entry.getKey(); - AnnotationProcessor processor = apFactory.getProcessorFor(entry.getValue(), - trivAPE); - if (processor != null) - processors.add(processor); - else - bark.aptWarning("NullProcessor", apFactory.getClass().getName()); - } - } catch(Throwable t) { - throw new AnnotationProcessingError(t); - } - - LinkedList temp = new LinkedList(); - temp.addAll(processors); - - AnnotationProcessor proc = AnnotationProcessors.getCompositeAnnotationProcessor(temp); - - try { - proc.process(); - } catch (Throwable t) { - throw new AnnotationProcessingError(t); - } - - // Invoke listener callback mechanism - trivAPE.roundComplete(); - - FilerImpl filerimpl = (FilerImpl)trivAPE.getFiler(); - genSourceFileNames = filerimpl.getSourceFileNames(); - genClassFileNames = filerimpl.getClassFileNames(); - filerimpl.flush(); // Make sure new files are written out - } - } - - /** - * Convert import-style string to regex matching that string. If - * the string is a valid import-style string, return a regex that - * won't match anything. - */ - Pattern importStringToPattern(String s) { - if (com.sun.tools.javac.processing.JavacProcessingEnvironment.isValidImportString(s)) { - return com.sun.tools.javac.processing.JavacProcessingEnvironment.validImportStringToPattern(s); - } else { - Bark bark = Bark.instance(context); - bark.aptWarning("MalformedSupportedString", s); - return com.sun.tools.javac.processing.JavacProcessingEnvironment.noMatches; - } - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/comp/BootstrapAPF.java --- a/src/share/classes/com/sun/tools/apt/comp/BootstrapAPF.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.comp; - -import java.util.*; -import com.sun.mirror.apt.*; -import com.sun.mirror.declaration.AnnotationTypeDeclaration; - -@SuppressWarnings("deprecation") -public class BootstrapAPF implements AnnotationProcessorFactory { - - static final Collection supportedOptions = - Collections.unmodifiableSet(new HashSet()); - - static Collection supportedAnnotations; - static { - Collection c = new HashSet(); - c.add("*"); - supportedAnnotations = Collections.unmodifiableCollection(c); - } - - public BootstrapAPF(){} - - public Collection supportedOptions() { - return BootstrapAPF.supportedOptions; - } - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new PrintAP(env); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/comp/PrintAP.java --- a/src/share/classes/com/sun/tools/apt/comp/PrintAP.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,467 +0,0 @@ -/* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.comp; - -import com.sun.mirror.declaration.*; -import static com.sun.mirror.declaration.Modifier.*; -import com.sun.mirror.type.*; -import com.sun.mirror.apt.*; - -import java.util.*; -import com.sun.mirror.util.*; - -/** - * Class used to implement "-print" option. - */ -@SuppressWarnings("deprecation") -public class PrintAP implements AnnotationProcessor { - - - static class PrintingVisitors { - int indentation = 0; // Indentation level; - AnnotationProcessorEnvironment env; - Messager out; - Declaration java_lang_Object; - Declaration java_lang_annotation_Annotation; - - static Set EMPTY_ELIDES = Collections.emptySet(); - static Set INTERFACE_ELIDES = EnumSet.of(ABSTRACT); - static Set ENUM_ELIDES = EnumSet.of(FINAL, ABSTRACT); - static Set INTERFACE_MEMBER_ELIDES = EnumSet.of(ABSTRACT, PUBLIC, STATIC, FINAL); - - PrintingVisitors(AnnotationProcessorEnvironment env) { - this.env = env; - this.out = env.getMessager(); - this.java_lang_Object = env.getTypeDeclaration("java.lang.Object"); - this.java_lang_annotation_Annotation = env.getTypeDeclaration("java.lang.annotation.Annotation"); - } - - - static String [] spaces = { - "", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " " - }; - - - String indent(){ - int indentation = this.indentation; - if (indentation < 0) - return ""; - else if (indentation <= 10) - return spaces[indentation]; - else { - StringBuilder sb = new StringBuilder(); - while (indentation > 10) { - sb.append(spaces[indentation]); - indentation -= 10; - } - sb.append(spaces[indentation]); - return sb.toString(); - } - } - - - class PrePrinting extends SimpleDeclarationVisitor { - Map enumCardinality = new HashMap(); - Map enumConstVisited = new HashMap(); - - PrePrinting(){} - - public void visitClassDeclaration(ClassDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, EMPTY_ELIDES); - System.out.print("class " + d.getSimpleName()); - printFormalTypeParameters(d); - - // Elide "extends Object" - ClassType Super = d.getSuperclass(); - if (Super != null && !java_lang_Object.equals(Super.getDeclaration()) ) - System.out.print(" extends " + Super.toString()); - - printInterfaces(d); - - System.out.println(" {"); - - PrintingVisitors.this.indentation++; - } - - public void visitEnumDeclaration(EnumDeclaration d) { - enumCardinality.put(d, d.getEnumConstants().size()); - enumConstVisited.put(d, 1); - - System.out.println(); - printDocComment(d); - printModifiers(d, ENUM_ELIDES); - - System.out.print("enum " + d.getSimpleName()); - printFormalTypeParameters(d); - printInterfaces(d); - - System.out.println(" {"); - - PrintingVisitors.this.indentation++; - } - - - public void visitInterfaceDeclaration(InterfaceDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, INTERFACE_ELIDES); - System.out.print("interface " + d.getSimpleName()); - - printFormalTypeParameters(d); - printInterfaces(d); - - System.out.println(" {"); - - PrintingVisitors.this.indentation++; - } - - public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, INTERFACE_ELIDES); - System.out.print("@interface " + d.getSimpleName()); - printFormalTypeParameters(d); - - printInterfaces(d); - - System.out.println(" {"); - - PrintingVisitors.this.indentation++; - } - - public void visitFieldDeclaration(FieldDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, - (d.getDeclaringType() instanceof InterfaceDeclaration)? - INTERFACE_MEMBER_ELIDES : EMPTY_ELIDES); - System.out.print(d.getType().toString() + " " + - d.getSimpleName() ); - String constantExpr = d.getConstantExpression(); - if (constantExpr != null) { - System.out.print(" = " + constantExpr); - } - System.out.println(";" ); - } - - public void visitEnumConstantDeclaration(EnumConstantDeclaration d) { - EnumDeclaration ed = d.getDeclaringType(); - int enumCard = enumCardinality.get(ed); - int enumVisit = enumConstVisited.get(ed); - - System.out.println(); - printDocComment(d); - System.out.print(PrintingVisitors.this.indent()); - System.out.print(d.getSimpleName() ); - System.out.println((enumVisit < enumCard )? ",":";" ); - - enumConstVisited.put(ed, enumVisit+1); - } - - public void visitMethodDeclaration(MethodDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, - (d.getDeclaringType() instanceof InterfaceDeclaration)? - INTERFACE_MEMBER_ELIDES : EMPTY_ELIDES); - printFormalTypeParameters(d); - System.out.print(d.getReturnType().toString() + " "); - System.out.print(d.getSimpleName() + "("); - printParameters(d); - System.out.print(")"); - printThrows(d); - System.out.println(";"); - } - - public void visitConstructorDeclaration(ConstructorDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, EMPTY_ELIDES); - printFormalTypeParameters(d); - System.out.print(d.getSimpleName() + "("); - printParameters(d); - System.out.print(")"); - printThrows(d); - System.out.println(";"); - } - - - } - - class PostPrinting extends SimpleDeclarationVisitor { - PostPrinting(){} - - public void visitTypeDeclaration(TypeDeclaration d) { - PrintingVisitors.this.indentation--; - - System.out.print(PrintingVisitors.this.indent()); - System.out.println("}"); - } - } - - private void printAnnotations(Collection annots) { - - for(AnnotationMirror annot: annots) { - System.out.print(this.indent()); - System.out.print(annot.toString()); - System.out.println(); - } - } - - private void printAnnotationsInline(Collection annots) { - - for(AnnotationMirror annot: annots) { - System.out.print(annot); - System.out.print(" "); - } - } - - - private void printParameters(ExecutableDeclaration ex) { - - Collection parameters = ex.getParameters(); - int size = parameters.size(); - - switch (size) { - case 0: - break; - - case 1: - for(ParameterDeclaration parameter: parameters) { - printModifiers(parameter, EMPTY_ELIDES); - - if (ex.isVarArgs() ) { - System.out.print(((ArrayType)parameter.getType()).getComponentType() ); - System.out.print("..."); - } else - System.out.print(parameter.getType()); - System.out.print(" " + parameter.getSimpleName()); - } - break; - - default: - { - int i = 1; - for(ParameterDeclaration parameter: parameters) { - if (i == 2) - PrintingVisitors.this.indentation++; - - if (i > 1) - System.out.print(PrintingVisitors.this.indent()); - - printModifiers(parameter, EMPTY_ELIDES); - - if (i == size && ex.isVarArgs() ) { - System.out.print(((ArrayType)parameter.getType()).getComponentType() ); - System.out.print("..."); - } else - System.out.print(parameter.getType()); - System.out.print(" " + parameter.getSimpleName()); - - if (i < size) - System.out.println(","); - - i++; - } - - if (parameters.size() >= 2) - PrintingVisitors.this.indentation--; - } - break; - } - } - - private void printDocComment(Declaration d) { - String docComment = d.getDocComment(); - - if (docComment != null) { - // Break comment into lines - java.util.StringTokenizer st = new StringTokenizer(docComment, - "\n\r"); - System.out.print(PrintingVisitors.this.indent()); - System.out.println("/**"); - - while(st.hasMoreTokens()) { - System.out.print(PrintingVisitors.this.indent()); - System.out.print(" *"); - System.out.println(st.nextToken()); - } - - System.out.print(PrintingVisitors.this.indent()); - System.out.println(" */"); - } - } - - private void printModifiers(Declaration d, Collection elides) { - printAnnotations(d.getAnnotationMirrors()); - - System.out.print(PrintingVisitors.this.indent()); - - for(Modifier m: adjustModifiers(d.getModifiers(), elides) ){ - System.out.print(m.toString() + " "); - } - } - - private void printModifiers(ParameterDeclaration d, Collection elides) { - printAnnotationsInline(d.getAnnotationMirrors()); - - for(Modifier m: adjustModifiers(d.getModifiers(), elides) ) { - System.out.print(m.toString() + " "); - } - } - - private Collection adjustModifiers(Collection mods, - Collection elides) { - if (elides.isEmpty()) - return mods; - else { - Collection newMods = new LinkedHashSet(); - newMods.addAll(mods); - newMods.removeAll(elides); - return newMods; - } - } - - private void printFormalTypeParameters(ExecutableDeclaration e) { - printFormalTypeParameterSet(e.getFormalTypeParameters(), true); - } - - private void printFormalTypeParameters(TypeDeclaration d) { - printFormalTypeParameterSet(d.getFormalTypeParameters(), false); - } - - private void printFormalTypeParameterSet(Collection typeParams, boolean pad) { - if (typeParams.size() != 0) { - System.out.print("<"); - - boolean first = true; - for(TypeParameterDeclaration tpd: typeParams) { - if (!first) - System.out.print(", "); - System.out.print(tpd.toString()); - } - - System.out.print(">"); - if (pad) - System.out.print(" "); - - } - } - - private void printInterfaceSet(Collection interfaces, - boolean classNotInterface) { - if (interfaces.size() != 0) { - System.out.print((classNotInterface?" implements" : " extends")); - - boolean first = true; - for(InterfaceType interType: interfaces) { - if (!first) - System.out.print(","); - System.out.print(" "); - System.out.print(interType.toString()); - first = false; - } - } - } - - private void printInterfaces(TypeDeclaration d) { - printInterfaceSet(d.getSuperinterfaces(), d instanceof ClassDeclaration); - } - - private void printInterfaces(AnnotationTypeDeclaration d) { - Collection interfaces = new HashSet(d.getSuperinterfaces()); - - for(InterfaceType interType: interfaces) { - if (java_lang_annotation_Annotation.equals(interType.getDeclaration()) ) - interfaces.remove(interType); - } - - printInterfaceSet(interfaces, d instanceof ClassDeclaration); - } - - private void printThrows(ExecutableDeclaration d) { - Collection thrownTypes = d.getThrownTypes(); - final int size = thrownTypes.size(); - if (size != 0) { - System.out.print(" throws"); - - int i = 1; - for(ReferenceType thrownType: thrownTypes) { - if (i == 1) { - System.out.print(" "); - } - - if (i == 2) - PrintingVisitors.this.indentation++; - - if (i >= 2) - System.out.print(PrintingVisitors.this.indent()); - - System.out.print(thrownType.toString()); - - - if (i != size) { - System.out.println(", "); - } - i++; - } - - if (size >= 2) - PrintingVisitors.this.indentation--; - } - } - - DeclarationVisitor getPrintingVisitor() { - return DeclarationVisitors.getSourceOrderDeclarationScanner(new PrePrinting(), - new PostPrinting()); - } - } - - AnnotationProcessorEnvironment env; - PrintAP(AnnotationProcessorEnvironment env) { - this.env = env; - } - - - public void process() { - Collection typedecls = env.getSpecifiedTypeDeclarations(); - - for (TypeDeclaration td: typedecls) - td.accept((new PrintingVisitors(env)).getPrintingVisitor()); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java --- a/src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.comp; - - -public class UsageMessageNeededException extends RuntimeException { - private static final long serialVersionUID = -3265159608992825840L; -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java --- a/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,292 +0,0 @@ -/* - * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.main; - -import java.io.*; -import java.util.Map; - -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; - -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.util.*; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.jvm.*; - -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.tree.JCTree.*; - -import com.sun.tools.apt.comp.*; -import com.sun.tools.apt.util.Bark; -import com.sun.mirror.apt.AnnotationProcessorFactory; -import com.sun.tools.javac.parser.DocCommentScanner; - -/** - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own - * risk. This code and its internal interfaces are subject to change - * or deletion without notice. - */ -@SuppressWarnings("deprecation") -public class AptJavaCompiler extends com.sun.tools.javac.main.JavaCompiler { - /** The context key for the compiler. */ - protected static final Context.Key compilerKey = - new Context.Key(); - - /** Get the JavaCompiler instance for this context. */ - public static AptJavaCompiler instance(Context context) { - AptJavaCompiler instance = context.get(compilerKey); - if (instance == null) - instance = new AptJavaCompiler(context); - return instance; - } - - - java.util.Set genSourceFileNames; - java.util.Set genClassFileNames; - - public java.util.Set getSourceFileNames() { - return genSourceFileNames; - } - - /** List of names of generated class files. - */ - public java.util.Set getClassFileNames() { - return genClassFileNames; - } - - java.util.Set aggregateGenFiles = java.util.Collections.emptySet(); - - public java.util.Set getAggregateGenFiles() { - return aggregateGenFiles; - } - - /** The bark to be used for error reporting. - */ - Bark bark; - - /** The log to be used for error reporting. - */ - Log log; - - /** The annotation framework - */ - Apt apt; - - private static Context preRegister(Context context) { - Bark.preRegister(context); - - if (context.get(JavaFileManager.class) == null) - JavacFileManager.preRegister(context); - - return context; - } - - /** Construct a new compiler from a shared context. - */ - public AptJavaCompiler(Context context) { - super(preRegister(context)); - - context.put(compilerKey, this); - apt = Apt.instance(context); - - ClassReader classReader = ClassReader.instance(context); - classReader.preferSource = true; - - // TEMPORARY NOTE: bark==log, but while refactoring, we maintain their - // original identities, to remember the original intent. - log = Log.instance(context); - bark = Bark.instance(context); - - Options options = Options.instance(context); - classOutput = options.get("-retrofit") == null; - nocompile = options.get("-nocompile") != null; - print = options.get("-print") != null; - classesAsDecls= options.get("-XclassesAsDecls") != null; - - genSourceFileNames = new java.util.LinkedHashSet(); - genClassFileNames = new java.util.LinkedHashSet(); - - // this forces a copy of the line map to be kept in the tree, - // for use by com.sun.mirror.util.SourcePosition. - lineDebugInfo = true; - } - - /* Switches: - */ - - /** Emit class files. This switch is always set, except for the first - * phase of retrofitting, where signatures are parsed. - */ - public boolean classOutput; - - /** The internal printing annotation processor should be used. - */ - public boolean print; - - /** Compilation should not be done after annotation processing. - */ - public boolean nocompile; - - /** Are class files being treated as declarations - */ - public boolean classesAsDecls; - - /** Try to open input stream with given name. - * Report an error if this fails. - * @param filename The file name of the input stream to be opened. - */ - // PROVIDED FOR EXTREME BACKWARDS COMPATIBILITY - // There are some very obscure errors that can arise while translating - // the contents of a file from bytes to characters. In Tiger, these - // diagnostics were ignored. This method provides compatibility with - // that behavior. It would be better to honor those diagnostics, in which - // case, this method can be deleted. - @Override - public CharSequence readSource(JavaFileObject filename) { - try { - inputFiles.add(filename); - boolean prev = bark.setDiagnosticsIgnored(true); - try { - return filename.getCharContent(false); - } - finally { - bark.setDiagnosticsIgnored(prev); - } - } catch (IOException e) { - bark.error(Position.NOPOS, "cant.read.file", filename); - return null; - } - } - - /** Parse contents of input stream. - * @param filename The name of the file from which input stream comes. - * @param input The input stream to be parsed. - */ - // PROVIDED FOR BACKWARDS COMPATIBILITY - // In Tiger, diagnostics from the scanner and parser were ignored. - // This method provides compatibility with that behavior. - // It would be better to honor those diagnostics, in which - // case, this method can be deleted. - @Override - protected JCCompilationUnit parse(JavaFileObject filename, CharSequence content) { - boolean prev = bark.setDiagnosticsIgnored(true); - try { - return super.parse(filename, content); - } - finally { - bark.setDiagnosticsIgnored(prev); - } - } - - @Override - protected boolean keepComments() { - return true; // make doc comments available to mirror API impl. - } - - /** Track when the JavaCompiler has been used to compile something. */ - private boolean hasBeenUsed = false; - - /** Main method: compile a list of files, return all compiled classes - * @param filenames The names of all files to be compiled. - */ - public List compile(List filenames, - Map origOptions, - ClassLoader aptCL, - AnnotationProcessorFactory providedFactory, - java.util.Set > productiveFactories, - java.util.Set aggregateGenFiles) - throws Throwable { - // as a JavaCompiler can only be used once, throw an exception if - // it has been used before. - assert !hasBeenUsed : "attempt to reuse JavaCompiler"; - hasBeenUsed = true; - - this.aggregateGenFiles = aggregateGenFiles; - - long msec = System.currentTimeMillis(); - - ListBuffer classes = new ListBuffer(); - try { - JavacFileManager fm = (JavacFileManager)fileManager; - //parse all files - ListBuffer trees = new ListBuffer(); - for (List l = filenames; l.nonEmpty(); l = l.tail) { - if (classesAsDecls) { - if (! l.head.endsWith(".java") ) { // process as class file - ClassSymbol cs = reader.enterClass(names.fromString(l.head)); - try { - cs.complete(); - } catch(Symbol.CompletionFailure cf) { - bark.aptError("CantFindClass", l); - continue; - } - - classes.append(cs); // add to list of classes - continue; - } - } - JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next(); - trees.append(parse(fo)); - } - - //enter symbols for all files - List roots = trees.toList(); - - if (errorCount() == 0) { - boolean prev = bark.setDiagnosticsIgnored(true); - try { - enter.main(roots); - } - finally { - bark.setDiagnosticsIgnored(prev); - } - } - - if (errorCount() == 0) { - apt.main(roots, - classes, - origOptions, aptCL, - providedFactory, - productiveFactories); - genSourceFileNames.addAll(apt.getSourceFileNames()); - genClassFileNames.addAll(apt.getClassFileNames()); - } - - } catch (Abort ex) { - } - - if (verbose) - log.printVerbose("total", Long.toString(System.currentTimeMillis() - msec)); - - chk.reportDeferredDiagnostics(); - - printCount("error", errorCount()); - printCount("warn", warningCount()); - - return classes.toList(); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/main/CommandLine.java --- a/src/share/classes/com/sun/tools/apt/main/CommandLine.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.main; - -import java.io.IOException; -import java.io.Reader; -import java.io.FileReader; -import java.io.BufferedReader; -import java.io.StreamTokenizer; -import com.sun.tools.javac.util.ListBuffer; - -/** - * Various utility methods for processing Java tool command line arguments. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice. - */ -public class CommandLine { - /** - * Process Win32-style command files for the specified command line - * arguments and return the resulting arguments. A command file argument - * is of the form '@file' where 'file' is the name of the file whose - * contents are to be parsed for additional arguments. The contents of - * the command file are parsed using StreamTokenizer and the original - * '@file' argument replaced with the resulting tokens. Recursive command - * files are not supported. The '@' character itself can be quoted with - * the sequence '@@'. - */ - public static String[] parse(String[] args) - throws IOException - { - ListBuffer newArgs = new ListBuffer(); - for (int i = 0; i < args.length; i++) { - String arg = args[i]; - if (arg.length() > 1 && arg.charAt(0) == '@') { - arg = arg.substring(1); - if (arg.charAt(0) == '@') { - newArgs.append(arg); - } else { - loadCmdFile(arg, newArgs); - } - } else { - newArgs.append(arg); - } - } - return newArgs.toList().toArray(new String[newArgs.length()]); - } - - private static void loadCmdFile(String name, ListBuffer args) - throws IOException - { - Reader r = new BufferedReader(new FileReader(name)); - StreamTokenizer st = new StreamTokenizer(r); - st.resetSyntax(); - st.wordChars(' ', 255); - st.whitespaceChars(0, ' '); - st.commentChar('#'); - st.quoteChar('"'); - st.quoteChar('\''); - while (st.nextToken() != StreamTokenizer.TT_EOF) { - args.append(st.sval); - } - r.close(); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/main/Main.java --- a/src/share/classes/com/sun/tools/apt/main/Main.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1281 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.main; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.text.MessageFormat; -import java.util.ResourceBundle; -import java.util.MissingResourceException; -import java.util.StringTokenizer; -import java.util.Map; -import java.util.HashMap; -import java.util.Collections; - -import java.net.URLClassLoader; -import java.net.URL; -import java.net.MalformedURLException; - -import javax.tools.JavaFileManager; -import javax.tools.StandardLocation; - -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.code.Source; -import com.sun.tools.javac.code.Symbol; -import com.sun.tools.javac.code.Type; -import com.sun.tools.javac.jvm.Target; -import com.sun.tools.javac.util.*; - -import com.sun.tools.apt.comp.AnnotationProcessingError; -import com.sun.tools.apt.comp.UsageMessageNeededException; -import com.sun.tools.apt.util.Bark; -import com.sun.mirror.apt.AnnotationProcessorFactory; - -import static com.sun.tools.javac.file.Paths.pathToURLs; - -/** This class provides a commandline interface to the apt build-time - * tool. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own - * risk. This code and its internal interfaces are subject to change - * or deletion without notice. - */ -@SuppressWarnings("deprecation") -public class Main { - - /** For testing: enter any options you want to be set implicitly - * here. - */ - static String[] forcedOpts = { - // Preserve parameter names from class files if the class was - // compiled with debug enabled - "-XDsave-parameter-names" - }; - - /** The name of the compiler, for use in diagnostics. - */ - String ownName; - - /** The writer to use for diagnostic output. - */ - PrintWriter out; - - - /** Instantiated factory to use in lieu of discovery process. - */ - AnnotationProcessorFactory providedFactory = null; - - /** Map representing original command-line arguments. - */ - Map origOptions = new HashMap(); - - /** Classloader to use for finding factories. - */ - ClassLoader aptCL = null; - - /** Result codes. - */ - static final int - EXIT_OK = 0, // Compilation completed with no errors. - EXIT_ERROR = 1, // Completed but reported errors. - EXIT_CMDERR = 2, // Bad command-line arguments - EXIT_SYSERR = 3, // System error or resource exhaustion. - EXIT_ABNORMAL = 4; // Compiler terminated abnormally - - /** This class represents an option recognized by the main program - */ - private class Option { - /** Whether or not the option is used only aptOnly. - */ - boolean aptOnly = false; - - /** Option string. - */ - String name; - - /** Documentation key for arguments. - */ - String argsNameKey; - - /** Documentation key for description. - */ - String descrKey; - - /** Suffix option (-foo=bar or -foo:bar) - */ - boolean hasSuffix; - - Option(String name, String argsNameKey, String descrKey) { - this.name = name; - this.argsNameKey = argsNameKey; - this.descrKey = descrKey; - char lastChar = name.charAt(name.length()-1); - hasSuffix = lastChar == ':' || lastChar == '='; - } - Option(String name, String descrKey) { - this(name, null, descrKey); - } - - public String toString() { - return name; - } - - /** Does this option take a (separate) operand? - */ - boolean hasArg() { - return argsNameKey != null && !hasSuffix; - } - - /** Does argument string match option pattern? - * @param arg The command line argument string. - */ - boolean matches(String arg) { - return hasSuffix ? arg.startsWith(name) : arg.equals(name); - } - - /** For javac-only options, print nothing. - */ - void help() { - } - - String helpSynopsis() { - return name + - (argsNameKey == null ? "" : - ((hasSuffix ? "" : " ") + - getLocalizedString(argsNameKey))); - } - - /** Print a line of documentation describing this option, if non-standard. - */ - void xhelp() {} - - /** Process the option (with arg). Return true if error detected. - */ - boolean process(String option, String arg) { - options.put(option, arg); - return false; - } - - /** Process the option (without arg). Return true if error detected. - */ - boolean process(String option) { - if (hasSuffix) - return process(name, option.substring(name.length())); - else - return process(option, option); - } - }; - - private class SharedOption extends Option { - SharedOption(String name, String argsNameKey, String descrKey) { - super(name, argsNameKey, descrKey); - } - - SharedOption(String name, String descrKey) { - super(name, descrKey); - } - - void help() { - String s = " " + helpSynopsis(); - out.print(s); - for (int j = s.length(); j < 29; j++) out.print(" "); - Bark.printLines(out, getLocalizedString(descrKey)); - } - - } - - private class AptOption extends Option { - AptOption(String name, String argsNameKey, String descrKey) { - super(name, argsNameKey, descrKey); - aptOnly = true; - } - - AptOption(String name, String descrKey) { - super(name, descrKey); - aptOnly = true; - } - - /** Print a line of documentation describing this option, if standard. - */ - void help() { - String s = " " + helpSynopsis(); - out.print(s); - for (int j = s.length(); j < 29; j++) out.print(" "); - Bark.printLines(out, getLocalizedString(descrKey)); - } - - } - - /** A nonstandard or extended (-X) option - */ - private class XOption extends Option { - XOption(String name, String argsNameKey, String descrKey) { - super(name, argsNameKey, descrKey); - } - XOption(String name, String descrKey) { - this(name, null, descrKey); - } - void help() {} - void xhelp() {} - }; - - /** A nonstandard or extended (-X) option - */ - private class AptXOption extends Option { - AptXOption(String name, String argsNameKey, String descrKey) { - super(name, argsNameKey, descrKey); - aptOnly = true; - } - AptXOption(String name, String descrKey) { - this(name, null, descrKey); - } - void xhelp() { - String s = " " + helpSynopsis(); - out.print(s); - for (int j = s.length(); j < 29; j++) out.print(" "); - Log.printLines(out, getLocalizedString(descrKey)); - } - }; - - /** A hidden (implementor) option - */ - private class HiddenOption extends Option { - HiddenOption(String name) { - super(name, null, null); - } - HiddenOption(String name, String argsNameKey) { - super(name, argsNameKey, null); - } - void help() {} - void xhelp() {} - }; - - private class AptHiddenOption extends HiddenOption { - AptHiddenOption(String name) { - super(name); - aptOnly = true; - } - AptHiddenOption(String name, String argsNameKey) { - super(name, argsNameKey); - aptOnly = true; - } - } - - private Option[] recognizedOptions = { - new Option("-g", "opt.g"), - new Option("-g:none", "opt.g.none") { - boolean process(String option) { - options.put("-g:", "none"); - return false; - } - }, - - new Option("-g:{lines,vars,source}", "opt.g.lines.vars.source") { - boolean matches(String s) { - return s.startsWith("-g:"); - } - boolean process(String option) { - String suboptions = option.substring(3); - options.put("-g:", suboptions); - // enter all the -g suboptions as "-g:suboption" - for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) { - String tok = t.nextToken(); - String opt = "-g:" + tok; - options.put(opt, opt); - } - return false; - } - }, - - new XOption("-Xlint", "opt.Xlint"), - new XOption("-Xlint:{" - + "all," - + "cast,deprecation,divzero,empty,unchecked,fallthrough,path,serial,finally,overrides," - + "-cast,-deprecation,-divzero,-empty,-unchecked,-fallthrough,-path,-serial,-finally,-overrides," - + "none}", - "opt.Xlint.suboptlist") { - boolean matches(String s) { - return s.startsWith("-Xlint:"); - } - boolean process(String option) { - String suboptions = option.substring(7); - options.put("-Xlint:", suboptions); - // enter all the -Xlint suboptions as "-Xlint:suboption" - for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) { - String tok = t.nextToken(); - String opt = "-Xlint:" + tok; - options.put(opt, opt); - } - return false; - } - }, - - new Option("-nowarn", "opt.nowarn"), - new Option("-verbose", "opt.verbose"), - - // -deprecation is retained for command-line backward compatibility - new Option("-deprecation", "opt.deprecation") { - boolean process(String option) { - options.put("-Xlint:deprecation", option); - return false; - } - }, - - new SharedOption("-classpath", "opt.arg.path", "opt.classpath"), - new SharedOption("-cp", "opt.arg.path", "opt.classpath") { - boolean process(String option, String arg) { - return super.process("-classpath", arg); - } - }, - new Option("-sourcepath", "opt.arg.path", "opt.sourcepath"), - new Option("-bootclasspath", "opt.arg.path", "opt.bootclasspath") { - boolean process(String option, String arg) { - options.remove("-Xbootclasspath/p:"); - options.remove("-Xbootclasspath/a:"); - return super.process(option, arg); - } - }, - new XOption("-Xbootclasspath/p:", "opt.arg.path", "opt.Xbootclasspath.p"), - new XOption("-Xbootclasspath/a:", "opt.arg.path", "opt.Xbootclasspath.a"), - new XOption("-Xbootclasspath:", "opt.arg.path", "opt.bootclasspath") { - boolean process(String option, String arg) { - options.remove("-Xbootclasspath/p:"); - options.remove("-Xbootclasspath/a:"); - return super.process("-bootclasspath", arg); - } - }, - new Option("-extdirs", "opt.arg.dirs", "opt.extdirs"), - new XOption("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs") { - boolean process(String option, String arg) { - return super.process("-extdirs", arg); - } - }, - new Option("-endorseddirs", "opt.arg.dirs", "opt.endorseddirs"), - new XOption("-Djava.endorsed.dirs=","opt.arg.dirs", "opt.endorseddirs") { - boolean process(String option, String arg) { - return super.process("-endorseddirs", arg); - } - }, - new Option("-proc:{none, only}", "opt.proc.none.only") { - public boolean matches(String s) { - return s.equals("-proc:none") || s.equals("-proc:only"); - } - }, - new Option("-processor", "opt.arg.class", "opt.processor"), - new Option("-processorpath", "opt.arg.path", "opt.processorpath"), - - new SharedOption("-d", "opt.arg.path", "opt.d"), - new SharedOption("-s", "opt.arg.path", "opt.s"), - new Option("-encoding", "opt.arg.encoding", "opt.encoding"), - new SharedOption("-source", "opt.arg.release", "opt.source") { - boolean process(String option, String operand) { - Source source = Source.lookup(operand); - if (source == null) { - error("err.invalid.source", operand); - return true; - } else if (source.compareTo(Source.JDK1_5) > 0) { - error("err.unsupported.source.version", operand); - return true; - } - return super.process(option, operand); - } - }, - new Option("-target", "opt.arg.release", "opt.target") { - boolean process(String option, String operand) { - Target target = Target.lookup(operand); - if (target == null) { - error("err.invalid.target", operand); - return true; - } else if (target.compareTo(Target.JDK1_5) > 0) { - error("err.unsupported.target.version", operand); - return true; - } - return super.process(option, operand); - } - }, - new AptOption("-version", "opt.version") { - boolean process(String option) { - Bark.printLines(out, ownName + " " + AptJavaCompiler.version()); - return super.process(option); - } - }, - new HiddenOption("-fullversion"), - new AptOption("-help", "opt.help") { - boolean process(String option) { - Main.this.help(); - return super.process(option); - } - }, - new SharedOption("-X", "opt.X") { - boolean process(String option) { - Main.this.xhelp(); - return super.process(option); - } - }, - - // This option exists only for the purpose of documenting itself. - // It's actually implemented by the launcher. - new AptOption("-J", "opt.arg.flag", "opt.J") { - String helpSynopsis() { - hasSuffix = true; - return super.helpSynopsis(); - } - boolean process(String option) { - throw new AssertionError - ("the -J flag should be caught by the launcher."); - } - }, - - - new SharedOption("-A", "opt.proc.flag", "opt.A") { - String helpSynopsis() { - hasSuffix = true; - return super.helpSynopsis(); - } - - boolean matches(String arg) { - return arg.startsWith("-A"); - } - - boolean hasArg() { - return false; - } - - boolean process(String option) { - return process(option, option); - } - }, - - new AptOption("-nocompile", "opt.nocompile"), - - new AptOption("-print", "opt.print"), - - new AptOption("-factorypath", "opt.arg.path", "opt.factorypath"), - - new AptOption("-factory", "opt.arg.class", "opt.factory"), - - new AptXOption("-XListAnnotationTypes", "opt.XListAnnotationTypes"), - - new AptXOption("-XListDeclarations", "opt.XListDeclarations"), - - new AptXOption("-XPrintAptRounds", "opt.XPrintAptRounds"), - - new AptXOption("-XPrintFactoryInfo", "opt.XPrintFactoryInfo"), - - /* - * Option to treat both classes and source files as - * declarations that can be given on the command line and - * processed as the result of an apt round. - */ - new AptXOption("-XclassesAsDecls", "opt.XClassesAsDecls"), - - // new Option("-moreinfo", "opt.moreinfo") { - new HiddenOption("-moreinfo") { - boolean process(String option) { - Type.moreInfo = true; - return super.process(option); - } - }, - - // treat warnings as errors - new HiddenOption("-Werror"), - - // use complex inference from context in the position of a method call argument - new HiddenOption("-complexinference"), - - // prompt after each error - // new Option("-prompt", "opt.prompt"), - new HiddenOption("-prompt"), - - // dump stack on error - new HiddenOption("-doe"), - - // display warnings for generic unchecked and unsafe operations - new HiddenOption("-warnunchecked") { - boolean process(String option) { - options.put("-Xlint:unchecked", option); - return false; - } - }, - - new HiddenOption("-Xswitchcheck") { - boolean process(String option) { - options.put("-Xlint:switchcheck", option); - return false; - } - }, - - // generate trace output for subtyping operations - new HiddenOption("-debugsubtyping"), - - new XOption("-Xmaxerrs", "opt.arg.number", "opt.maxerrs"), - new XOption("-Xmaxwarns", "opt.arg.number", "opt.maxwarns"), - new XOption("-Xstdout", "opt.arg.file", "opt.Xstdout") { - boolean process(String option, String arg) { - try { - out = new PrintWriter(new FileWriter(arg), true); - } catch (java.io.IOException e) { - error("err.error.writing.file", arg, e); - return true; - } - return super.process(option, arg); - } - }, - - new XOption("-Xprint", "opt.print"), - - new XOption("-XprintRounds", "opt.printRounds"), - - new XOption("-XprintProcessorInfo", "opt.printProcessorInfo"), - - - /* -O is a no-op, accepted for backward compatibility. */ - new HiddenOption("-O"), - - /* -Xjcov produces tables to support the code coverage tool jcov. */ - new HiddenOption("-Xjcov"), - - /* This is a back door to the compiler's option table. - * -Dx=y sets the option x to the value y. - * -Dx sets the option x to the value x. - */ - new HiddenOption("-XD") { - String s; - boolean matches(String s) { - this.s = s; - return s.startsWith(name); - } - boolean process(String option) { - s = s.substring(name.length()); - int eq = s.indexOf('='); - String key = (eq < 0) ? s : s.substring(0, eq); - String value = (eq < 0) ? s : s.substring(eq+1); - options.put(key, value); - return false; - } - }, - - new HiddenOption("sourcefile") { - String s; - boolean matches(String s) { - this.s = s; - return s.endsWith(".java") || - (options.get("-XclassesAsDecls") != null); - } - boolean process(String option) { - if (s.endsWith(".java")) { - if (!sourceFileNames.contains(s)) - sourceFileNames.add(s); - } else if (options.get("-XclassesAsDecls") != null) { - classFileNames.add(s); - } - return false; - } - }, - }; - - /** - * Construct a compiler instance. - */ - public Main(String name) { - this(name, new PrintWriter(System.err, true)); - } - - /** - * Construct a compiler instance. - */ - public Main(String name, PrintWriter out) { - this.ownName = name; - this.out = out; - } - - /** A table of all options that's passed to the JavaCompiler constructor. */ - private Options options = null; - - /** The list of source files to process - */ - java.util.List sourceFileNames = new java.util.LinkedList(); - - /** The list of class files to process - */ - java.util.List classFileNames = new java.util.LinkedList(); - - /** List of top level names of generated source files from most recent apt round. - */ - java.util.Set genSourceFileNames = new java.util.LinkedHashSet(); - - /** List of names of generated class files from most recent apt round. - */ - java.util.Set genClassFileNames = new java.util.LinkedHashSet(); - - /** - * List of all the generated source file names across all apt rounds. - */ - java.util.Set aggregateGenSourceFileNames = new java.util.LinkedHashSet(); - - /** - * List of all the generated class file names across all apt rounds. - */ - java.util.Set aggregateGenClassFileNames = new java.util.LinkedHashSet(); - - /** - * List of all the generated file names across all apt rounds. - */ - java.util.Set aggregateGenFiles = new java.util.LinkedHashSet(); - - /** - * Set of all factories that have provided a processor on some apt round. - */ - java.util.Set > productiveFactories = - new java.util.LinkedHashSet >(); - - - - /** Print a string that explains usage. - */ - void help() { - Bark.printLines(out, getLocalizedString("msg.usage.header", ownName)); - for (int i=0; i < recognizedOptions.length; i++) { - recognizedOptions[i].help(); - } - Bark.printLines(out, getLocalizedString("msg.usage.footer")); - out.println(); - } - - /** Print a string that explains usage for X options. - */ - void xhelp() { - for (int i=0; i processArgs(String[] flags) { - int ac = 0; - while (ac < flags.length) { - String flag = flags[ac]; - ac++; - - int j; - for (j=0; j < recognizedOptions.length; j++) - if (recognizedOptions[j].matches(flag)) - break; - - if (j == recognizedOptions.length) { - error("err.invalid.flag", flag); - return null; - } - - Option option = recognizedOptions[j]; - if (option.hasArg()) { - if (ac == flags.length) { - error("err.req.arg", flag); - return null; - } - String operand = flags[ac]; - ac++; - if (option.process(flag, operand)) - return null; - } else { - if (option.process(flag)) - return null; - } - } - - String sourceString = options.get("-source"); - Source source = (sourceString != null) - ? Source.lookup(sourceString) - : Source.JDK1_5; // JDK 5 is the latest supported source version - String targetString = options.get("-target"); - Target target = (targetString != null) - ? Target.lookup(targetString) - : Target.JDK1_5; // JDK 5 is the latest supported source version - // We don't check source/target consistency for CLDC, as J2ME - // profiles are not aligned with J2SE targets; moreover, a - // single CLDC target may have many profiles. In addition, - // this is needed for the continued functioning of the JSR14 - // prototype. - if (Character.isDigit(target.name.charAt(0)) && - target.compareTo(source.requiredTarget()) < 0) { - if (targetString != null) { - if (sourceString == null) { - warning("warn.target.default.source.conflict", - targetString, - source.requiredTarget().name); - } else { - warning("warn.source.target.conflict", - sourceString, - source.requiredTarget().name); - } - return null; - } else { - options.put("-target", source.requiredTarget().name); - } - } - return sourceFileNames; - } - - /** Programmatic interface for main function. - * @param args The command line parameters. - */ - public int compile(String[] args, AnnotationProcessorFactory factory) { - int returnCode = 0; - providedFactory = factory; - - Context context = new Context(); - JavacFileManager.preRegister(context); - options = Options.instance(context); - Bark bark; - - /* - * Process the command line options to create the intial - * options data. This processing is at least partially reused - * by any recursive apt calls. - */ - - // For testing: assume all arguments in forcedOpts are - // prefixed to command line arguments. - processArgs(forcedOpts); - - /* - * A run of apt only gets passed the most recently generated - * files; the initial run of apt gets passed the files from - * the command line. - */ - - java.util.List origFilenames; - try { - // assign args the result of parse to capture results of - // '@file' expansion - origFilenames = processArgs((args=CommandLine.parse(args))); - - if (options.get("suppress-tool-api-removal-message") == null) { - Bark.printLines(out, getLocalizedString("misc.Deprecation")); - } - - if (origFilenames == null) { - return EXIT_CMDERR; - } else if (origFilenames.size() == 0) { - // it is allowed to compile nothing if just asking for help - if (options.get("-help") != null || - options.get("-X") != null) - return EXIT_OK; - } - } catch (java.io.FileNotFoundException e) { - Bark.printLines(out, ownName + ": " + - getLocalizedString("err.file.not.found", - e.getMessage())); - return EXIT_SYSERR; - } catch (IOException ex) { - ioMessage(ex); - return EXIT_SYSERR; - } catch (OutOfMemoryError ex) { - resourceMessage(ex); - return EXIT_SYSERR; - } catch (StackOverflowError ex) { - resourceMessage(ex); - return EXIT_SYSERR; - } catch (FatalError ex) { - feMessage(ex); - return EXIT_SYSERR; - } catch (sun.misc.ServiceConfigurationError sce) { - sceMessage(sce); - return EXIT_ABNORMAL; - } catch (Throwable ex) { - bugMessage(ex); - return EXIT_ABNORMAL; - } - - - boolean firstRound = true; - boolean needSourcePath = false; - boolean needClassPath = false; - boolean classesAsDecls = options.get("-XclassesAsDecls") != null; - - /* - * Create augumented classpath and sourcepath values. - * - * If any of the prior apt rounds generated any new source - * files, the n'th apt round (and any javac invocation) has the - * source destination path ("-s path") as the last element of - * the "-sourcepath" to the n'th call. - * - * If any of the prior apt rounds generated any new class files, - * the n'th apt round (and any javac invocation) has the class - * destination path ("-d path") as the last element of the - * "-classpath" to the n'th call. - */ - String augmentedSourcePath = ""; - String augmentedClassPath = ""; - String baseClassPath = ""; - - try { - /* - * Record original options for future annotation processor - * invocations. - */ - origOptions = new HashMap(options.size()); - for(String s: options.keySet()) { - String value; - if (s.equals(value = options.get(s))) - origOptions.put(s, (String)null); - else - origOptions.put(s, value); - } - origOptions = Collections.unmodifiableMap(origOptions); - - JavacFileManager fm = (JavacFileManager) context.get(JavaFileManager.class); - { - // Note: it might be necessary to check for an empty - // component ("") of the source path or class path - - String sourceDest = options.get("-s"); - if (fm.hasLocation(StandardLocation.SOURCE_PATH)) { - for(File f: fm.getLocation(StandardLocation.SOURCE_PATH)) - augmentedSourcePath += (f + File.pathSeparator); - augmentedSourcePath += (sourceDest == null)?".":sourceDest; - } else { - augmentedSourcePath = "."; - - if (sourceDest != null) - augmentedSourcePath += (File.pathSeparator + sourceDest); - } - - String classDest = options.get("-d"); - if (fm.hasLocation(StandardLocation.CLASS_PATH)) { - for(File f: fm.getLocation(StandardLocation.CLASS_PATH)) - baseClassPath += (f + File.pathSeparator); - // put baseClassPath into map to handle any - // value needed for the classloader - options.put("-classpath", baseClassPath); - - augmentedClassPath = baseClassPath + ((classDest == null)?".":classDest); - } else { - baseClassPath = "."; - if (classDest != null) - augmentedClassPath = baseClassPath + (File.pathSeparator + classDest); - } - assert options.get("-classpath") != null; - } - - /* - * Create base and augmented class loaders - */ - ClassLoader augmentedAptCL = null; - { - /* - * Use a url class loader to look for classes on the - * user-specified class path. Prepend computed bootclass - * path, which includes extdirs, to the URLClassLoader apt - * uses. - */ - String aptclasspath = ""; - String bcp = ""; - Iterable bootclasspath = fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH); - - if (bootclasspath != null) { - for(File f: bootclasspath) - bcp += (f + File.pathSeparator); - } - - // If the factory path is set, use that path - if (providedFactory == null) - aptclasspath = options.get("-factorypath"); - if (aptclasspath == null) - aptclasspath = options.get("-classpath"); - - assert aptclasspath != null; - aptclasspath = (bcp + aptclasspath); - aptCL = new URLClassLoader(pathToURLs(aptclasspath)); - - if (providedFactory == null && - options.get("-factorypath") != null) // same CL even if new class files written - augmentedAptCL = aptCL; - else { - // Create class loader in case new class files are - // written - augmentedAptCL = new URLClassLoader(pathToURLs(augmentedClassPath. - substring(baseClassPath.length())), - aptCL); - } - } - - int round = 0; // For -XPrintAptRounds - do { - round++; - - Context newContext = new Context(); - Options newOptions = Options.instance(newContext); // creates a new context - newOptions.putAll(options); - - // populate with old options... don't bother reparsing command line, etc. - - // if genSource files, must add destination to source path - if (genSourceFileNames.size() > 0 && !firstRound) { - newOptions.put("-sourcepath", augmentedSourcePath); - needSourcePath = true; - } - aggregateGenSourceFileNames.addAll(genSourceFileNames); - sourceFileNames.addAll(genSourceFileNames); - genSourceFileNames.clear(); - - // Don't really need to track this; just have to add -d - // "foo" to class path if any class files are generated - if (genClassFileNames.size() > 0) { - newOptions.put("-classpath", augmentedClassPath); - aptCL = augmentedAptCL; - needClassPath = true; - } - aggregateGenClassFileNames.addAll(genClassFileNames); - classFileNames.addAll(genClassFileNames); - genClassFileNames.clear(); - - options = newOptions; - - if (options.get("-XPrintAptRounds") != null) { - out.println("apt Round : " + round); - out.println("filenames: " + sourceFileNames); - if (classesAsDecls) - out.println("classnames: " + classFileNames); - out.println("options: " + options); - } - - returnCode = compile(args, newContext); - firstRound = false; - - // Check for reported errors before continuing - bark = Bark.instance(newContext); - } while(((genSourceFileNames.size() != 0 ) || - (classesAsDecls && genClassFileNames.size() != 0)) && - bark.nerrors == 0); - } catch (UsageMessageNeededException umne) { - help(); - return EXIT_CMDERR; // will cause usage message to be printed - } - - /* - * Do not compile if a processor has reported an error or if - * there are no source files to process. A more sophisticated - * test would also fail for syntax errors caught by javac. - */ - if (options.get("-nocompile") == null && - options.get("-print") == null && - bark.nerrors == 0 && - (origFilenames.size() > 0 || aggregateGenSourceFileNames.size() > 0 )) { - /* - * Need to create new argument string for calling javac: - * 1. apt specific arguments (e.g. -factory) must be stripped out - * 2. proper settings for sourcepath and classpath must be used - * 3. generated class names must be added - * 4. class file names as declarations must be removed - */ - - int newArgsLength = args.length + - (needSourcePath?1:0) + - (needClassPath?1:0) + - aggregateGenSourceFileNames.size(); - - // Null out apt-specific options and don't copy over into - // newArgs. This loop should be a lot faster; the options - // array should be replaced with a better data structure - // which includes a map from strings to options. - // - // If treating classes as declarations, must strip out - // class names from the javac argument list - argLoop: - for(int i = 0; i < args.length; i++) { - int matchPosition = -1; - - // "-A" by itself is recognized by apt but not javac - if (args[i] != null && args[i].equals("-A")) { - newArgsLength--; - args[i] = null; - continue argLoop; - } else { - optionLoop: - for(int j = 0; j < recognizedOptions.length; j++) { - if (args[i] != null && recognizedOptions[j].matches(args[i])) { - matchPosition = j; - break optionLoop; - } - } - - if (matchPosition != -1) { - Option op = recognizedOptions[matchPosition]; - if (op.aptOnly) { - newArgsLength--; - args[i] = null; - if (op.hasArg()) { - newArgsLength--; - args[i+1] = null; - } - } else { - if (op.hasArg()) { // skip over next string - i++; - continue argLoop; - } - - if ((options.get("-XclassesAsDecls") != null) && - (matchPosition == (recognizedOptions.length-1)) ){ - // Remove class file names from - // consideration by javac. - if (! args[i].endsWith(".java")) { - newArgsLength--; - args[i] = null; - } - } - } - } - } - } - - String newArgs[] = new String[newArgsLength]; - - int j = 0; - for(int i=0; i < args.length; i++) { - if (args[i] != null) - newArgs[j++] = args[i]; - } - - if (needClassPath) - newArgs[j++] = "-XD-classpath=" + augmentedClassPath; - - if (needSourcePath) { - newArgs[j++] = "-XD-sourcepath=" + augmentedSourcePath; - - for(String s: aggregateGenSourceFileNames) - newArgs[j++] = s; - } - - returnCode = com.sun.tools.javac.Main.compile(newArgs); - } - - return returnCode; - } - - /** Programmatic interface for main function. - * @param args The command line parameters. - */ - int compile(String[] args, Context context) { - boolean assertionsEnabled = false; - assert assertionsEnabled = true; - if (!assertionsEnabled) { - // Bark.printLines(out, "fatal error: assertions must be enabled when running javac"); - // return EXIT_ABNORMAL; - } - int exitCode = EXIT_OK; - - AptJavaCompiler comp = null; - try { - context.put(Bark.outKey, out); - - comp = AptJavaCompiler.instance(context); - if (comp == null) - return EXIT_SYSERR; - - java.util.List nameList = new java.util.LinkedList(); - nameList.addAll(sourceFileNames); - if (options.get("-XclassesAsDecls") != null) - nameList.addAll(classFileNames); - - List cs - = comp.compile(List.from(nameList.toArray(new String[0])), - origOptions, - aptCL, - providedFactory, - productiveFactories, - aggregateGenFiles); - - /* - * If there aren't new source files, we shouldn't bother - * running javac if there were errors. - * - * If there are new files, we should try running javac in - * case there were typing errors. - * - */ - - if (comp.errorCount() != 0 || - options.get("-Werror") != null && comp.warningCount() != 0) - return EXIT_ERROR; - } catch (IOException ex) { - ioMessage(ex); - return EXIT_SYSERR; - } catch (OutOfMemoryError ex) { - resourceMessage(ex); - return EXIT_SYSERR; - } catch (StackOverflowError ex) { - resourceMessage(ex); - return EXIT_SYSERR; - } catch (FatalError ex) { - feMessage(ex); - return EXIT_SYSERR; - } catch (UsageMessageNeededException umne) { - help(); - return EXIT_CMDERR; // will cause usage message to be printed - } catch (AnnotationProcessingError ex) { - apMessage(ex); - return EXIT_ABNORMAL; - } catch (sun.misc.ServiceConfigurationError sce) { - sceMessage(sce); - return EXIT_ABNORMAL; - } catch (Throwable ex) { - bugMessage(ex); - return EXIT_ABNORMAL; - } finally { - if (comp != null) { - comp.close(); - genSourceFileNames.addAll(comp.getSourceFileNames()); - genClassFileNames.addAll(comp.getClassFileNames()); - } - sourceFileNames = new java.util.LinkedList(); - classFileNames = new java.util.LinkedList(); - } - return exitCode; - } - - /** Print a message reporting an internal error. - */ - void bugMessage(Throwable ex) { - Bark.printLines(out, getLocalizedString("msg.bug", - AptJavaCompiler.version())); - ex.printStackTrace(out); - } - - /** Print a message reporting an fatal error. - */ - void apMessage(AnnotationProcessingError ex) { - Bark.printLines(out, getLocalizedString("misc.Problem")); - ex.getCause().printStackTrace(out); - } - - /** Print a message about sun.misc.Service problem. - */ - void sceMessage(sun.misc.ServiceConfigurationError ex) { - Bark.printLines(out, getLocalizedString("misc.SunMiscService")); - ex.printStackTrace(out); - } - - /** Print a message reporting an fatal error. - */ - void feMessage(Throwable ex) { - Bark.printLines(out, ex.toString()); - } - - /** Print a message reporting an input/output error. - */ - void ioMessage(Throwable ex) { - Bark.printLines(out, getLocalizedString("msg.io")); - ex.printStackTrace(out); - } - - /** Print a message reporting an out-of-resources error. - */ - void resourceMessage(Throwable ex) { - Bark.printLines(out, getLocalizedString("msg.resource")); - ex.printStackTrace(out); - } - - /* ************************************************************************ - * Internationalization - *************************************************************************/ - - /** Find a localized string in the resource bundle. - * @param key The key for the localized string. - */ - private static String getLocalizedString(String key, Object... args) { - return getText(key, args); - } - - private static final String javacRB = - "com.sun.tools.javac.resources.javac"; - - private static final String aptRB = - "com.sun.tools.apt.resources.apt"; - - private static ResourceBundle messageRBjavac; - private static ResourceBundle messageRBapt; - - /** Initialize ResourceBundle. - */ - private static void initResource() { - try { - messageRBapt = ResourceBundle.getBundle(aptRB); - messageRBjavac = ResourceBundle.getBundle(javacRB); - } catch (MissingResourceException e) { - Error x = new FatalError("Fatal Error: Resource for apt or javac is missing"); - x.initCause(e); - throw x; - } - } - - /** Get and format message string from resource. - */ - private static String getText(String key, Object... _args) { - String[] args = new String[_args.length]; - for (int i=0; i<_args.length; i++) { - args[i] = "" + _args[i]; - } - if (messageRBapt == null || messageRBjavac == null ) - initResource(); - try { - return MessageFormat.format(messageRBapt.getString("apt." + key), - (Object[]) args); - } catch (MissingResourceException e) { - try { - return MessageFormat.format(messageRBjavac.getString("javac." + key), - (Object[]) args); - } catch (MissingResourceException f) { - String msg = "apt or javac message file broken: key={0} " - + "arguments={1}, {2}"; - return MessageFormat.format(msg, (Object[]) args); - } - } - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/AptEnv.java --- a/src/share/classes/com/sun/tools/apt/mirror/AptEnv.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror; - - -import com.sun.tools.apt.mirror.declaration.DeclarationMaker; -import com.sun.tools.apt.mirror.type.TypeMaker; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.CompletionFailure; -import com.sun.tools.javac.comp.Attr; -import com.sun.tools.javac.comp.Enter; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Names; - - -/** - * The environment for a run of apt. - */ -@SuppressWarnings("deprecation") -public class AptEnv { - - public Names names; // javac's name table - public Symtab symtab; // javac's predefined symbols - public Types jctypes; // javac's type utilities - public Enter enter; // javac's enter phase - public Attr attr; // javac's attr phase (to evaluate - // constant initializers) - public TypeMaker typeMaker; // apt's internal type utilities - public DeclarationMaker declMaker; // apt's internal declaration utilities - - - private static final Context.Key aptEnvKey = - new Context.Key(); - - public static AptEnv instance(Context context) { - AptEnv instance = context.get(aptEnvKey); - if (instance == null) { - instance = new AptEnv(context); - } - return instance; - } - - private AptEnv(Context context) { - context.put(aptEnvKey, this); - - names = Names.instance(context); - symtab = Symtab.instance(context); - jctypes = Types.instance(context); - enter = Enter.instance(context); - attr = Attr.instance(context); - typeMaker = TypeMaker.instance(context); - declMaker = DeclarationMaker.instance(context); - } - - - /** - * Does a symbol have a given flag? Forces symbol completion. - */ - public static boolean hasFlag(Symbol sym, long flag) { - return (getFlags(sym) & flag) != 0; - } - - /** - * Returns a symbol's flags. Forces completion. - */ - public static long getFlags(Symbol sym) { - complete(sym); - return sym.flags(); - } - - /** - * Completes a symbol, ignoring completion failures. - */ - private static void complete(Symbol sym) { - while (true) { - try { - sym.complete(); - return; - } catch (CompletionFailure e) { - // Should never see two in a row, but loop just to be sure. - } - } - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/apt/AnnotationProcessorEnvironmentImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/apt/AnnotationProcessorEnvironmentImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.apt; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.*; -import com.sun.mirror.apt.*; -import com.sun.tools.apt.mirror.apt.*; -import com.sun.tools.apt.mirror.declaration.DeclarationMaker; -import com.sun.tools.apt.mirror.util.*; -import com.sun.tools.apt.util.Bark; -import com.sun.tools.javac.util.Context; - -import com.sun.tools.apt.mirror.apt.FilerImpl; -import com.sun.tools.apt.mirror.apt.MessagerImpl; -import com.sun.tools.apt.mirror.apt.RoundStateImpl; -import com.sun.tools.apt.mirror.apt.RoundCompleteEventImpl; - -import com.sun.tools.javac.util.Context; - -import java.util.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * Annotation Processor Environment implementation. - */ -@SuppressWarnings("deprecation") -public class AnnotationProcessorEnvironmentImpl implements AnnotationProcessorEnvironment { - - Collection spectypedecls; - Collection typedecls; - Map origOptions; - DeclarationMaker declMaker; - Declarations declUtils; - Types typeUtils; - Messager messager; - FilerImpl filer; - Bark bark; - Set roundCompleteListeners; - - public AnnotationProcessorEnvironmentImpl(Collection spectypedecls, - Collection typedecls, - Map origOptions, - Context context) { - // Safer to copy collections before applying unmodifiable - // wrapper. - this.spectypedecls = Collections.unmodifiableCollection(spectypedecls); - this.typedecls = Collections.unmodifiableCollection(typedecls); - this.origOptions = Collections.unmodifiableMap(origOptions); - - declMaker = DeclarationMaker.instance(context); - declUtils = DeclarationsImpl.instance(context); - typeUtils = TypesImpl.instance(context); - messager = MessagerImpl.instance(context); - filer = FilerImpl.instance(context); - bark = Bark.instance(context); - roundCompleteListeners = new LinkedHashSet(); - } - - public Map getOptions() { - return origOptions; - } - - public Messager getMessager() { - return messager; - } - - public Filer getFiler() { - return filer; - } - - public Collection getSpecifiedTypeDeclarations() { - return spectypedecls; - } - - public PackageDeclaration getPackage(String name) { - return declMaker.getPackageDeclaration(name); - } - - public TypeDeclaration getTypeDeclaration(String name) { - return declMaker.getTypeDeclaration(name); - } - - public Collection getTypeDeclarations() { - return typedecls; - } - - public Collection getDeclarationsAnnotatedWith( - AnnotationTypeDeclaration a) { - /* - * create collection of Declarations annotated with a given - * annotation. - */ - - CollectingAP proc = new CollectingAP(this, a); - proc.process(); - return proc.decls; - } - - private static class CollectingAP implements AnnotationProcessor { - AnnotationProcessorEnvironment env; - Collection decls; - AnnotationTypeDeclaration atd; - CollectingAP(AnnotationProcessorEnvironment env, - AnnotationTypeDeclaration atd) { - this.env = env; - this.atd = atd; - decls = new HashSet(); - } - - private class CollectingVisitor extends SimpleDeclarationVisitor { - public void visitDeclaration(Declaration d) { - for(AnnotationMirror am: d.getAnnotationMirrors()) { - if (am.getAnnotationType().getDeclaration().equals(CollectingAP.this.atd)) - CollectingAP.this.decls.add(d); - } - } - } - - public void process() { - for(TypeDeclaration d: env.getSpecifiedTypeDeclarations()) - d.accept(getSourceOrderDeclarationScanner(new CollectingVisitor(), - NO_OP)); - } - } - - public Declarations getDeclarationUtils() { - return declUtils; - } - - public Types getTypeUtils() { - return typeUtils; - } - - public void addListener(AnnotationProcessorListener listener) { - if (listener == null) - throw new NullPointerException(); - else { - if (listener instanceof RoundCompleteListener) - roundCompleteListeners.add((RoundCompleteListener)listener); - } - } - - public void removeListener(AnnotationProcessorListener listener) { - if (listener == null) - throw new NullPointerException(); - else - roundCompleteListeners.remove(listener); - } - - public void roundComplete() { - RoundState roundState = new RoundStateImpl(bark.nerrors > 0, - filer.getSourceFileNames().size() > 0, - filer.getClassFileNames().size() > 0, - origOptions); - RoundCompleteEvent roundCompleteEvent = new RoundCompleteEventImpl(this, roundState); - - filer.roundOver(); - for(RoundCompleteListener rcl: roundCompleteListeners) - rcl.roundComplete(roundCompleteEvent); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/apt/FilerImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/apt/FilerImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,354 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.apt; - - -import java.io.*; -import java.util.Collection; -import java.util.EnumMap; -import java.util.HashSet; -import java.util.Set; - -import com.sun.mirror.apt.Filer; -import com.sun.tools.apt.mirror.declaration.DeclarationMaker; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Options; -import com.sun.tools.javac.util.Position; -import com.sun.tools.apt.util.Bark; - -import static com.sun.mirror.apt.Filer.Location.*; - - -/** - * Implementation of Filer. - */ -@SuppressWarnings("deprecation") -public class FilerImpl implements Filer { - /* - * The Filer class must maintain a number of constraints. First, - * multiple attempts to open the same path within the same - * invocation of apt results in an IOException being thrown. For - * example, trying to open the same source file twice: - * - * createSourceFile("foo.Bar") - * ... - * createSourceFile("foo.Bar") - * - * is disallowed as is opening a text file that happens to have - * the same name as a source file: - * - * createSourceFile("foo.Bar") - * ... - * createTextFile(SOURCE_TREE, "foo", new File("Bar"), null) - * - * Additionally, creating a source file that corresponds to an - * already created class file (or vice versa) generates at least a - * warning. This is an error if -XclassesAsDecls is being used - * since you can't create the same type twice. However, if the - * Filer is used to create a text file named *.java that happens - * to correspond to an existing class file, a warning is *not* - * generated. Similarly, a warning is not generated for a binary - * file named *.class and an existing source file. - * - * The reason for this difference is that source files and class - * files are registered with apt and can get passed on as - * declarations to the next round of processing. Files that are - * just named *.java and *.class are not processed in that manner; - * although having extra source files and class files on the - * source path and class path can alter the behavior of the tool - * and any final compile. - */ - - private enum FileKind { - SOURCE { - void register(File file, String name, FilerImpl that) throws IOException { - // Check for corresponding class file - if (that.filesCreated.contains(new File(that.locations.get(CLASS_TREE), - that.nameToPath(name, ".class")))) { - - that.bark.aptWarning("CorrespondingClassFile", name); - if (that.opts.get("-XclassesAsDecls") != null) - throw new IOException(); - } - that.sourceFileNames.add(file.getPath()); - } - }, - - CLASS { - void register(File file, String name, FilerImpl that) throws IOException { - if (that.filesCreated.contains(new File(that.locations.get(SOURCE_TREE), - that.nameToPath(name, ".java")))) { - that.bark.aptWarning("CorrespondingSourceFile", name); - if (that.opts.get("-XclassesAsDecls") != null) - throw new IOException(); - } - // Track the binary name instead of the filesystem location - that.classFileNames.add(name); - } - }, - - OTHER { - // Nothing special to do - void register(File file, String name, FilerImpl that) throws IOException {} - }; - - abstract void register(File file, String name, FilerImpl that) throws IOException; - } - - private final Options opts; - private final DeclarationMaker declMaker; - private final com.sun.tools.apt.main.AptJavaCompiler comp; - - // Platform's default encoding - private final static String DEFAULT_ENCODING = - new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding(); - - private String encoding; // name of charset used for source files - - private final EnumMap locations; // where new files go - - - private static final Context.Key filerKey = - new Context.Key(); - - // Set of files opened. - private Collection wc; - - private Bark bark; - - // All created files. - private final Set filesCreated; - - // Names of newly created source files - private HashSet sourceFileNames = new HashSet(); - - // Names of newly created class files - private HashSet classFileNames = new HashSet(); - - private boolean roundOver; - - public static FilerImpl instance(Context context) { - FilerImpl instance = context.get(filerKey); - if (instance == null) { - instance = new FilerImpl(context); - } - return instance; - } - - // flush all output streams; - public void flush() { - for(Flushable opendedFile: wc) { - try { - opendedFile.flush(); - if (opendedFile instanceof FileOutputStream) { - try { - ((FileOutputStream) opendedFile).getFD().sync() ; - } catch (java.io.SyncFailedException sfe) {} - } - } catch (IOException e) { } - } - } - - private FilerImpl(Context context) { - context.put(filerKey, this); - opts = Options.instance(context); - declMaker = DeclarationMaker.instance(context); - bark = Bark.instance(context); - comp = com.sun.tools.apt.main.AptJavaCompiler.instance(context); - roundOver = false; - this.filesCreated = comp.getAggregateGenFiles(); - - // Encoding - encoding = opts.get("-encoding"); - if (encoding == null) { - encoding = DEFAULT_ENCODING; - } - - wc = new HashSet(); - - // Locations - locations = new EnumMap(Location.class); - String s = opts.get("-s"); // location for new source files - String d = opts.get("-d"); // location for new class files - locations.put(SOURCE_TREE, new File(s != null ? s : ".")); - locations.put(CLASS_TREE, new File(d != null ? d : ".")); - } - - - /** - * {@inheritDoc} - */ - public PrintWriter createSourceFile(String name) throws IOException { - String pathname = nameToPath(name, ".java"); - File file = new File(locations.get(SOURCE_TREE), - pathname); - PrintWriter pw = getPrintWriter(file, encoding, name, FileKind.SOURCE); - return pw; - } - - /** - * {@inheritDoc} - */ - public OutputStream createClassFile(String name) throws IOException { - String pathname = nameToPath(name, ".class"); - File file = new File(locations.get(CLASS_TREE), - pathname); - OutputStream os = getOutputStream(file, name, FileKind.CLASS); - return os; - } - - /** - * {@inheritDoc} - */ - public PrintWriter createTextFile(Location loc, - String pkg, - File relPath, - String charsetName) throws IOException { - File file = (pkg.length() == 0) - ? relPath - : new File(nameToPath(pkg), relPath.getPath()); - if (charsetName == null) { - charsetName = encoding; - } - return getPrintWriter(loc, file.getPath(), charsetName, null, FileKind.OTHER); - } - - /** - * {@inheritDoc} - */ - public OutputStream createBinaryFile(Location loc, - String pkg, - File relPath) throws IOException { - File file = (pkg.length() == 0) - ? relPath - : new File(nameToPath(pkg), relPath.getPath()); - return getOutputStream(loc, file.getPath(), null, FileKind.OTHER); - } - - - /** - * Converts the canonical name of a top-level type or package to a - * pathname. Suffix is ".java" or ".class" or "". - */ - private String nameToPath(String name, String suffix) throws IOException { - if (!DeclarationMaker.isJavaIdentifier(name.replace('.', '_'))) { - bark.aptWarning("IllegalFileName", name); - throw new IOException(); - } - return name.replace('.', File.separatorChar) + suffix; - } - - private String nameToPath(String name) throws IOException { - return nameToPath(name, ""); - } - - /** - * Returns a writer for a text file given its location, its - * pathname relative to that location, and its encoding. - */ - private PrintWriter getPrintWriter(Location loc, String pathname, - String encoding, String name, FileKind kind) throws IOException { - File file = new File(locations.get(loc), pathname); - return getPrintWriter(file, encoding, name, kind); - } - - /** - * Returns a writer for a text file given its encoding. - */ - private PrintWriter getPrintWriter(File file, - String encoding, String name, FileKind kind) throws IOException { - prepareFile(file, name, kind); - PrintWriter pw = - new PrintWriter( - new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(file), - encoding))); - wc.add(pw); - return pw; - } - - /** - * Returns an output stream for a binary file given its location - * and its pathname relative to that location. - */ - private OutputStream getOutputStream(Location loc, String pathname, String name, FileKind kind) - throws IOException { - File file = new File(locations.get(loc), pathname); - return getOutputStream(file, name, kind); - } - - private OutputStream getOutputStream(File file, String name, FileKind kind) throws IOException { - prepareFile(file, name, kind); - OutputStream os = new FileOutputStream(file); - wc.add(os); - return os; - - } - - public Set getSourceFileNames() { - return sourceFileNames; - } - - public Set getClassFileNames() { - return classFileNames; - } - - public void roundOver() { - roundOver = true; - } - - /** - * Checks that the file has not already been created during this - * invocation. If not, creates intermediate directories, and - * deletes the file if it already exists. - */ - private void prepareFile(File file, String name, FileKind kind) throws IOException { - if (roundOver) { - bark.aptWarning("NoNewFilesAfterRound", file.toString()); - throw new IOException(); - } - - if (filesCreated.contains(file)) { - bark.aptWarning("FileReopening", file.toString()); - throw new IOException(); - } else { - if (file.exists()) { - file.delete(); - } else { - File parent = file.getParentFile(); - if (parent != null && !parent.exists()) { - if(!parent.mkdirs()) { - bark.aptWarning("BadParentDirectory", file.toString()); - throw new IOException(); - } - } - } - - kind.register(file, name, this); - filesCreated.add(file); - } - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/apt/MessagerImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/apt/MessagerImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.apt; - -import javax.tools.JavaFileObject; -import com.sun.mirror.apt.Messager; -import com.sun.tools.apt.mirror.util.SourcePositionImpl; -import com.sun.mirror.util.SourcePosition; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.util.Position; -import com.sun.tools.apt.util.Bark; - - -/** - * Implementation of Messager. - */ -@SuppressWarnings("deprecation") -public class MessagerImpl implements Messager { - private final Bark bark; - - private static final Context.Key messagerKey = - new Context.Key(); - - public static MessagerImpl instance(Context context) { - MessagerImpl instance = context.get(messagerKey); - if (instance == null) { - instance = new MessagerImpl(context); - } - return instance; - } - - private MessagerImpl(Context context) { - context.put(messagerKey, this); - bark = Bark.instance(context); - } - - - /** - * {@inheritDoc} - */ - public void printError(String msg) { - bark.aptError("Messager", msg); - } - - /** - * {@inheritDoc} - */ - public void printError(SourcePosition pos, String msg) { - if (pos instanceof SourcePositionImpl) { - SourcePositionImpl posImpl = (SourcePositionImpl) pos; - JavaFileObject prev = bark.useSource(posImpl.getSource()); - bark.aptError(posImpl.getJavacPosition(), "Messager", msg); - bark.useSource(prev); - } else - printError(msg); - } - - /** - * {@inheritDoc} - */ - public void printWarning(String msg) { - bark.aptWarning("Messager", msg); - } - - /** - * {@inheritDoc} - */ - public void printWarning(SourcePosition pos, String msg) { - if (pos instanceof SourcePositionImpl) { - SourcePositionImpl posImpl = (SourcePositionImpl) pos; - JavaFileObject prev = bark.useSource(posImpl.getSource()); - bark.aptWarning(posImpl.getJavacPosition(), "Messager", msg); - bark.useSource(prev); - } else - printWarning(msg); - } - - /** - * {@inheritDoc} - */ - public void printNotice(String msg) { - bark.aptNote("Messager", msg); - } - - /** - * {@inheritDoc} - */ - public void printNotice(SourcePosition pos, String msg) { - if (pos instanceof SourcePositionImpl) { - SourcePositionImpl posImpl = (SourcePositionImpl) pos; - JavaFileObject prev = bark.useSource(posImpl.getSource()); - bark.aptNote(posImpl.getJavacPosition(), "Messager", msg); - bark.useSource(prev); - } else - printNotice(msg); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.apt; - -import com.sun.mirror.apt.AnnotationProcessorEnvironment; -import com.sun.mirror.apt.RoundCompleteEvent; -import com.sun.mirror.apt.RoundState; - -@SuppressWarnings("deprecation") -public class RoundCompleteEventImpl extends RoundCompleteEvent { - private static final long serialVersionUID = 7067621446720784300L; - - public RoundCompleteEventImpl(AnnotationProcessorEnvironment source, - RoundState rs) { - super(source, rs); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/apt/RoundStateImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/apt/RoundStateImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.apt; - -import com.sun.mirror.apt.RoundState; -import java.util.Map; - -@SuppressWarnings("deprecation") -public class RoundStateImpl implements RoundState { - private final boolean finalRound; - private final boolean errorRaised; - private final boolean sourceFilesCreated; - private final boolean classFilesCreated; - - public RoundStateImpl(boolean errorRaised, - boolean sourceFilesCreated, - boolean classFilesCreated, - Map options) { - /* - * In the default mode of operation, this round is the final - * round if an error was raised OR there were no new source - * files generated. If classes are being treated as - * declarations, this is the final round if an error was - * raised OR neither new source files nor new class files were - * generated. - */ - this.finalRound = - errorRaised || - (!sourceFilesCreated && - !(classFilesCreated && options.keySet().contains("-XclassesAsDecls")) ); - this.errorRaised = errorRaised; - this.sourceFilesCreated = sourceFilesCreated; - this.classFilesCreated = classFilesCreated; - } - - public boolean finalRound() { - return finalRound; - } - - public boolean errorRaised() { - return errorRaised; - } - - public boolean sourceFilesCreated() { - return sourceFilesCreated; - } - - public boolean classFilesCreated() { - return classFilesCreated; - } - - public String toString() { - return - "[final round: " + finalRound + - ", error raised: " + errorRaised + - ", source files created: " + sourceFilesCreated + - ", class files created: " + classFilesCreated + "]"; - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationMirrorImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationMirrorImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.LinkedHashMap; -import java.util.Map; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.AnnotationType; -import com.sun.mirror.util.SourcePosition; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Attribute; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.util.Pair; - - -/** - * Implementation of AnnotationMirror - */ -@SuppressWarnings("deprecation") -public class AnnotationMirrorImpl implements AnnotationMirror { - - protected final AptEnv env; - protected final Attribute.Compound anno; - protected final Declaration decl; - - - AnnotationMirrorImpl(AptEnv env, Attribute.Compound anno, Declaration decl) { - this.env = env; - this.anno = anno; - this.decl = decl; - } - - - /** - * Returns a string representation of this annotation. - * String is of one of the forms: - * @com.example.foo(name1=val1, name2=val2) - * @com.example.foo(val) - * @com.example.foo - * Omit parens for marker annotations, and omit "value=" when allowed. - */ - public String toString() { - StringBuilder sb = new StringBuilder("@"); - Constants.Formatter fmtr = Constants.getFormatter(sb); - - fmtr.append(anno.type.tsym); - - int len = anno.values.length(); - if (len > 0) { // omit parens for marker annotations - sb.append('('); - boolean first = true; - for (Pair val : anno.values) { - if (!first) { - sb.append(", "); - } - first = false; - - Name name = val.fst.name; - if (len > 1 || name != env.names.value) { - fmtr.append(name); - sb.append('='); - } - sb.append(new AnnotationValueImpl(env, val.snd, this)); - } - sb.append(')'); - } - return fmtr.toString(); - } - - /** - * {@inheritDoc} - */ - public AnnotationType getAnnotationType() { - return (AnnotationType) env.typeMaker.getType(anno.type); - } - - /** - * {@inheritDoc} - */ - public Map - getElementValues() { - Map res = - new LinkedHashMap(); // whew! - for (Pair val : anno.values) { - res.put(getElement(val.fst), - new AnnotationValueImpl(env, val.snd, this)); - } - return res; - } - - public SourcePosition getPosition() { - // Return position of the declaration on which this annotation - // appears. - return (decl == null) ? null : decl.getPosition(); - - } - - public Declaration getDeclaration() { - return this.decl; - } - - /** - * Returns the annotation type element for a symbol. - */ - private AnnotationTypeElementDeclaration getElement(MethodSymbol m) { - return (AnnotationTypeElementDeclaration) - env.declMaker.getExecutableDeclaration(m); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,355 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.lang.annotation.*; -import java.lang.reflect.Array; -import java.lang.reflect.Method; -import java.util.*; -import sun.reflect.annotation.*; - -import com.sun.mirror.type.TypeMirror; -import com.sun.mirror.type.MirroredTypeException; -import com.sun.mirror.type.MirroredTypesException; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.util.Pair; - - -/** - * A generator of dynamic proxy implementations of - * java.lang.annotation.Annotation. - * - *

The "dynamic proxy return form" of an attribute element value is - * the form used by sun.reflect.annotation.AnnotationInvocationHandler. - */ -@SuppressWarnings("deprecation") -class AnnotationProxyMaker { - - private final AptEnv env; - private final Attribute.Compound attrs; - private final Class annoType; - - - private AnnotationProxyMaker(AptEnv env, - Attribute.Compound attrs, - Class annoType) { - this.env = env; - this.attrs = attrs; - this.annoType = annoType; - } - - - /** - * Returns a dynamic proxy for an annotation mirror. - */ - public static A generateAnnotation( - AptEnv env, Attribute.Compound attrs, Class annoType) { - AnnotationProxyMaker apm = new AnnotationProxyMaker(env, attrs, annoType); - return annoType.cast(apm.generateAnnotation()); - } - - - /** - * Returns a dynamic proxy for an annotation mirror. - */ - private Annotation generateAnnotation() { - return AnnotationParser.annotationForMap(annoType, - getAllReflectedValues()); - } - - /** - * Returns a map from element names to their values in "dynamic - * proxy return form". Includes all elements, whether explicit or - * defaulted. - */ - private Map getAllReflectedValues() { - Map res = new LinkedHashMap(); - - for (Map.Entry entry : - getAllValues().entrySet()) { - MethodSymbol meth = entry.getKey(); - Object value = generateValue(meth, entry.getValue()); - if (value != null) { - res.put(meth.name.toString(), value); - } else { - // Ignore this element. May lead to - // IncompleteAnnotationException somewhere down the line. - } - } - return res; - } - - /** - * Returns a map from element symbols to their values. - * Includes all elements, whether explicit or defaulted. - */ - private Map getAllValues() { - Map res = - new LinkedHashMap(); - - // First find the default values. - ClassSymbol sym = (ClassSymbol) attrs.type.tsym; - for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) { - if (e.sym.kind == Kinds.MTH) { - MethodSymbol m = (MethodSymbol) e.sym; - Attribute def = m.defaultValue; - if (def != null) { - res.put(m, def); - } - } - } - // Next find the explicit values, possibly overriding defaults. - for (Pair p : attrs.values) { - res.put(p.fst, p.snd); - } - return res; - } - - /** - * Converts an element value to its "dynamic proxy return form". - * Returns an exception proxy on some errors, but may return null if - * a useful exception cannot or should not be generated at this point. - */ - private Object generateValue(MethodSymbol meth, Attribute attr) { - ValueVisitor vv = new ValueVisitor(meth); - return vv.getValue(attr); - } - - - private class ValueVisitor implements Attribute.Visitor { - - private MethodSymbol meth; // annotation element being visited - private Class runtimeType; // runtime type of annotation element - private Object value; // value in "dynamic proxy return form" - - ValueVisitor(MethodSymbol meth) { - this.meth = meth; - } - - Object getValue(Attribute attr) { - Method method; // runtime method of annotation element - try { - method = annoType.getMethod(meth.name.toString()); - } catch (NoSuchMethodException e) { - return null; - } - runtimeType = method.getReturnType(); - attr.accept(this); - if (!(value instanceof ExceptionProxy) && - !AnnotationType.invocationHandlerReturnType(runtimeType) - .isInstance(value)) { - typeMismatch(method, attr); - } - return value; - } - - - public void visitConstant(Attribute.Constant c) { - value = Constants.decodeConstant(c.value, c.type); - } - - public void visitClass(Attribute.Class c) { - value = new MirroredTypeExceptionProxy( - env.typeMaker.getType(c.type)); - } - - public void visitArray(Attribute.Array a) { - Type elemtype = env.jctypes.elemtype(a.type); - - if (elemtype.tsym == env.symtab.classType.tsym) { // Class[] - // Construct a proxy for a MirroredTypesException - ArrayList elems = new ArrayList(); - for (int i = 0; i < a.values.length; i++) { - Type elem = ((Attribute.Class) a.values[i]).type; - elems.add(env.typeMaker.getType(elem)); - } - value = new MirroredTypesExceptionProxy(elems); - - } else { - int len = a.values.length; - Class runtimeTypeSaved = runtimeType; - runtimeType = runtimeType.getComponentType(); - try { - Object res = Array.newInstance(runtimeType, len); - for (int i = 0; i < len; i++) { - a.values[i].accept(this); - if (value == null || value instanceof ExceptionProxy) { - return; - } - try { - Array.set(res, i, value); - } catch (IllegalArgumentException e) { - value = null; // indicates a type mismatch - return; - } - } - value = res; - } finally { - runtimeType = runtimeTypeSaved; - } - } - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - public void visitEnum(Attribute.Enum e) { - if (runtimeType.isEnum()) { - String constName = e.value.toString(); - try { - value = Enum.valueOf((Class)runtimeType, constName); - } catch (IllegalArgumentException ex) { - value = new EnumConstantNotPresentExceptionProxy( - (Class>)runtimeType, constName); - } - } else { - value = null; // indicates a type mismatch - } - } - - public void visitCompound(Attribute.Compound c) { - try { - Class nested = - runtimeType.asSubclass(Annotation.class); - value = generateAnnotation(env, c, nested); - } catch (ClassCastException ex) { - value = null; // indicates a type mismatch - } - } - - public void visitError(Attribute.Error e) { - value = null; // indicates a type mismatch - } - - - /** - * Sets "value" to an ExceptionProxy indicating a type mismatch. - */ - private void typeMismatch(Method method, final Attribute attr) { - class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy { - private static final long serialVersionUID = 8473323277815075163L; - transient final Method method; - AnnotationTypeMismatchExceptionProxy(Method method) { - this.method = method; - } - public String toString() { - return ""; // eg: @Anno(value=) - } - protected RuntimeException generateException() { - return new AnnotationTypeMismatchException(method, - attr.type.toString()); - } - } - value = new AnnotationTypeMismatchExceptionProxy(method); - } - } - - - /** - * ExceptionProxy for MirroredTypeException. - * The toString, hashCode, and equals methods foward to the underlying - * type. - */ - private static final class MirroredTypeExceptionProxy extends ExceptionProxy { - private static final long serialVersionUID = 6662035281599933545L; - - private MirroredTypeException ex; - - MirroredTypeExceptionProxy(TypeMirror t) { - // It would be safer if we could construct the exception in - // generateException(), but there would be no way to do - // that properly following deserialization. - ex = new MirroredTypeException(t); - } - - public String toString() { - return ex.getQualifiedName(); - } - - public int hashCode() { - TypeMirror t = ex.getTypeMirror(); - return (t != null) - ? t.hashCode() - : ex.getQualifiedName().hashCode(); - } - - public boolean equals(Object obj) { - TypeMirror t = ex.getTypeMirror(); - return t != null && - obj instanceof MirroredTypeExceptionProxy && - t.equals( - ((MirroredTypeExceptionProxy) obj).ex.getTypeMirror()); - } - - protected RuntimeException generateException() { - return (RuntimeException) ex.fillInStackTrace(); - } - } - - - /** - * ExceptionProxy for MirroredTypesException. - * The toString, hashCode, and equals methods foward to the underlying - * types. - */ - private static final class MirroredTypesExceptionProxy extends ExceptionProxy { - private static final long serialVersionUID = -6670822532616693951L; - - private MirroredTypesException ex; - - MirroredTypesExceptionProxy(Collection ts) { - // It would be safer if we could construct the exception in - // generateException(), but there would be no way to do - // that properly following deserialization. - ex = new MirroredTypesException(ts); - } - - public String toString() { - return ex.getQualifiedNames().toString(); - } - - public int hashCode() { - Collection ts = ex.getTypeMirrors(); - return (ts != null) - ? ts.hashCode() - : ex.getQualifiedNames().hashCode(); - } - - public boolean equals(Object obj) { - Collection ts = ex.getTypeMirrors(); - return ts != null && - obj instanceof MirroredTypesExceptionProxy && - ts.equals( - ((MirroredTypesExceptionProxy) obj).ex.getTypeMirrors()); - } - - protected RuntimeException generateException() { - return (RuntimeException) ex.fillInStackTrace(); - } - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of AnnotationTypeDeclaration - */ -@SuppressWarnings("deprecation") -public class AnnotationTypeDeclarationImpl extends InterfaceDeclarationImpl - implements AnnotationTypeDeclaration -{ - AnnotationTypeDeclarationImpl(AptEnv env, ClassSymbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - */ - public Collection getMethods() { - return identityFilter.filter(super.getMethods(), - AnnotationTypeElementDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitAnnotationTypeDeclaration(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeElementDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeElementDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.MethodSymbol; - - -/** - * Implementation of AnnotationTypeElementDeclaration - */ -@SuppressWarnings("deprecation") -public class AnnotationTypeElementDeclarationImpl extends MethodDeclarationImpl - implements AnnotationTypeElementDeclaration { - - AnnotationTypeElementDeclarationImpl(AptEnv env, MethodSymbol sym) { - super(env, sym); - } - - /** - * {@inheritDoc} - */ - public AnnotationTypeDeclaration getDeclaringType() { - return (AnnotationTypeDeclaration) super.getDeclaringType(); - } - - /** - * {@inheritDoc} - */ - public AnnotationValue getDefaultValue() { - return (sym.defaultValue == null) - ? null - : new AnnotationValueImpl(env, sym.defaultValue, null); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitAnnotationTypeElementDeclaration(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationValueImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationValueImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.SourcePosition; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Attribute; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.code.TypeTags; - - -/** - * Implementation of AnnotationValue - */ -@SuppressWarnings("deprecation") -public class AnnotationValueImpl implements AnnotationValue { - - protected final AptEnv env; - protected final Attribute attr; - protected final AnnotationMirrorImpl annotation; - - AnnotationValueImpl(AptEnv env, Attribute attr, AnnotationMirrorImpl annotation) { - this.env = env; - this.attr = attr; - this.annotation = annotation; - } - - - /** - * {@inheritDoc} - */ - public String toString() { - StringBuilder sb = new StringBuilder(); - Constants.Formatter fmtr = Constants.getFormatter(sb); - - fmtr.append(getValue()); - return fmtr.toString(); - } - - /** - * {@inheritDoc} - */ - public Object getValue() { - ValueVisitor vv = new ValueVisitor(); - attr.accept(vv); - return vv.value; - } - - - public SourcePosition getPosition() { - // Imprecise implementation; just return position of enclosing - // annotation. - return (annotation == null) ? null : annotation.getPosition(); - } - - private class ValueVisitor implements Attribute.Visitor { - - public Object value; - - public void visitConstant(Attribute.Constant c) { - value = Constants.decodeConstant(c.value, c.type); - } - - public void visitClass(Attribute.Class c) { - value = env.typeMaker.getType( - env.jctypes.erasure(c.type)); - } - - public void visitEnum(Attribute.Enum e) { - value = env.declMaker.getFieldDeclaration(e.value); - } - - public void visitCompound(Attribute.Compound c) { - value = new AnnotationMirrorImpl(env, c, - (annotation == null) ? - null : - annotation.getDeclaration()); - } - - public void visitArray(Attribute.Array a) { - ArrayList vals = - new ArrayList(a.values.length); - for (Attribute elem : a.values) { - vals.add(new AnnotationValueImpl(env, elem, annotation)); - } - value = vals; - } - - public void visitError(Attribute.Error e) { - value = ""; // javac will already have logged an error msg - } - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/ClassDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/ClassDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.lang.annotation.Annotation; -import java.lang.annotation.Inherited; -import java.util.ArrayList; -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.ClassType; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of ClassDeclaration - */ -@SuppressWarnings("deprecation") -public class ClassDeclarationImpl extends TypeDeclarationImpl - implements ClassDeclaration { - - ClassDeclarationImpl(AptEnv env, ClassSymbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - * Overridden here to handle @Inherited. - */ - public A getAnnotation(Class annoType) { - - boolean inherited = annoType.isAnnotationPresent(Inherited.class); - for (Type t = sym.type; - t.tsym != env.symtab.objectType.tsym && !t.isErroneous(); - t = env.jctypes.supertype(t)) { - - A result = getAnnotation(annoType, t.tsym); - if (result != null || !inherited) { - return result; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - public ClassType getSuperclass() { - // java.lang.Object has no superclass - if (sym == env.symtab.objectType.tsym) { - return null; - } - Type t = env.jctypes.supertype(sym.type); - return (ClassType) env.typeMaker.getType(t); - } - - /** - * {@inheritDoc} - */ - public Collection getConstructors() { - ArrayList res = - new ArrayList(); - for (Symbol s : getMembers(true)) { - if (s.isConstructor()) { - MethodSymbol m = (MethodSymbol) s; - res.add((ConstructorDeclaration) - env.declMaker.getExecutableDeclaration(m)); - } - } - return res; - } - - /** - * {@inheritDoc} - */ - public Collection getMethods() { - return identityFilter.filter(super.getMethods(), - MethodDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitClassDeclaration(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/Constants.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/Constants.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,294 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.TypeMirror; -import com.sun.tools.apt.mirror.type.TypeMirrorImpl; -import com.sun.tools.javac.code.Type; - -import static com.sun.tools.javac.code.TypeTags.*; - - -/** - * Utility class for operating on constant expressions. - */ -@SuppressWarnings("deprecation") -class Constants { - - /** - * Converts a constant in javac's internal representation (in which - * boolean, char, byte, short, and int are each represented by an Integer) - * into standard representation. Other values (including null) are - * returned unchanged. - */ - static Object decodeConstant(Object value, Type type) { - if (value instanceof Integer) { - int i = ((Integer) value).intValue(); - switch (type.tag) { - case BOOLEAN: return Boolean.valueOf(i != 0); - case CHAR: return Character.valueOf((char) i); - case BYTE: return Byte.valueOf((byte) i); - case SHORT: return Short.valueOf((short) i); - } - } - return value; - } - - /** - * Returns a formatter for generating the text of constant - * expressions. Equivalent to - * getFormatter(new StringBuilder()). - */ - static Formatter getFormatter() { - return new Formatter(new StringBuilder()); - } - - /** - * Returns a formatter for generating the text of constant - * expressions. Also generates the text of constant - * "pseudo-expressions" for annotations and array-valued - * annotation elements. - * - * @param buf where the expression is written - */ - static Formatter getFormatter(StringBuilder buf) { - return new Formatter(buf); - } - - - /** - * Utility class used to generate the text of constant - * expressions. Also generates the text of constant - * "pseudo-expressions" for annotations and array-valued - * annotation elements. - */ - static class Formatter { - - private StringBuilder buf; // where the output goes - - private Formatter(StringBuilder buf) { - this.buf = buf; - } - - - public String toString() { - return buf.toString(); - } - - /** - * Appends a constant whose type is not statically known - * by dispatching to the appropriate overloaded append method. - */ - void append(Object val) { - if (val instanceof String) { - append((String) val); - } else if (val instanceof Character) { - append((Character) val); - } else if (val instanceof Boolean) { - append((Boolean) val); - } else if (val instanceof Byte) { - append((Byte) val); - } else if (val instanceof Short) { - append((Short) val); - } else if (val instanceof Integer) { - append((Integer) val); - } else if (val instanceof Long) { - append((Long) val); - } else if (val instanceof Float) { - append((Float) val); - } else if (val instanceof Double) { - append((Double) val); - } else if (val instanceof TypeMirror) { - append((TypeMirrorImpl) val); - } else if (val instanceof EnumConstantDeclaration) { - append((EnumConstantDeclarationImpl) val); - } else if (val instanceof AnnotationMirror) { - append((AnnotationMirrorImpl) val); - } else if (val instanceof Collection) { - append((Collection) val); - } else { - appendUnquoted(val.toString()); - } - } - - /** - * Appends a string, escaped (as needed) and quoted. - */ - void append(String val) { - buf.append('"'); - appendUnquoted(val); - buf.append('"'); - } - - /** - * Appends a Character, escaped (as needed) and quoted. - */ - void append(Character val) { - buf.append('\''); - appendUnquoted(val.charValue()); - buf.append('\''); - } - - void append(Boolean val) { - buf.append(val); - } - - void append(Byte val) { - buf.append(String.format("0x%02x", val)); - } - - void append(Short val) { - buf.append(val); - } - - void append(Integer val) { - buf.append(val); - } - - void append(Long val) { - buf.append(val).append('L'); - } - - void append(Float val) { - if (val.isNaN()) { - buf.append("0.0f/0.0f"); - } else if (val.isInfinite()) { - if (val.floatValue() < 0) { - buf.append('-'); - } - buf.append("1.0f/0.0f"); - } else { - buf.append(val).append('f'); - } - } - - void append(Double val) { - if (val.isNaN()) { - buf.append("0.0/0.0"); - } else if (val.isInfinite()) { - if (val.doubleValue() < 0) { - buf.append('-'); - } - buf.append("1.0/0.0"); - } else { - buf.append(val); - } - } - - /** - * Appends the class literal corresponding to a type. Should - * only be invoked for types that have an associated literal. - * e.g: "java.lang.String.class" - * "boolean.class" - * "int[].class" - */ - void append(TypeMirrorImpl t) { - appendUnquoted(t.type.toString()); - buf.append(".class"); - } - - /** - * Appends the fully qualified name of an enum constant. - * e.g: "java.math.RoundingMode.UP" - */ - void append(EnumConstantDeclarationImpl e) { - appendUnquoted(e.sym.enclClass() + "." + e); - } - - /** - * Appends the text of an annotation pseudo-expression. - * e.g: "@pkg.Format(linesep='\n')" - */ - void append(AnnotationMirrorImpl anno) { - appendUnquoted(anno.toString()); - } - - /** - * Appends the elements of a collection, enclosed within braces - * and separated by ", ". Useful for array-valued annotation - * elements. - */ - void append(Collection vals) { - buf.append('{'); - boolean first = true; - for (Object val : vals) { - if (first) { - first = false; - } else { - buf.append(", "); - } - append(((AnnotationValue) val).getValue()); - } - buf.append('}'); - } - - - /** - * For each char of a string, append using appendUnquoted(char). - */ - private void appendUnquoted(String s) { - for (char c : s.toCharArray()) { - appendUnquoted(c); - } - } - - /** - * Appends a char (unquoted), using escapes for those that are not - * printable ASCII. We don't know what is actually printable in - * the locale in which this result will be used, so ASCII is our - * best guess as to the least common denominator. - */ - private void appendUnquoted(char c) { - switch (c) { - case '\b': buf.append("\\b"); break; - case '\t': buf.append("\\t"); break; - case '\n': buf.append("\\n"); break; - case '\f': buf.append("\\f"); break; - case '\r': buf.append("\\r"); break; - case '\"': buf.append("\\\""); break; - case '\'': buf.append("\\\'"); break; - case '\\': buf.append("\\\\"); break; - default: - if (isPrintableAscii(c)) { - buf.append(c); - } else { - buf.append(String.format("\\u%04x", (int) c)); - } - } - } - - /** - * Is c a printable ASCII character? - */ - private static boolean isPrintableAscii(char c) { - return c >= ' ' && c <= '~'; - } - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/ConstructorDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/ConstructorDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.ArrayList; -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.Symbol.MethodSymbol; - - -/** - * Implementation of ConstructorDeclaration - */ -@SuppressWarnings("deprecation") -public class ConstructorDeclarationImpl extends ExecutableDeclarationImpl - implements ConstructorDeclaration { - - ConstructorDeclarationImpl(AptEnv env, MethodSymbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - * Returns the simple name of the declaring class. - */ - public String getSimpleName() { - return sym.enclClass().name.toString(); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitConstructorDeclaration(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.Collection; -import java.util.EnumSet; -import javax.tools.JavaFileObject; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.apt.mirror.util.SourcePositionImpl; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.comp.AttrContext; -import com.sun.tools.javac.comp.Env; -import com.sun.tools.javac.tree.*; -import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.util.Position; - -import static com.sun.mirror.declaration.Modifier.*; -import static com.sun.tools.javac.code.Kinds.*; - - -/** - * Implementation of Declaration - */ -@SuppressWarnings("deprecation") -public abstract class DeclarationImpl implements Declaration { - - protected final AptEnv env; - public final Symbol sym; - - protected static final DeclarationFilter identityFilter = - new DeclarationFilter(); - - - /** - * "sym" should be completed before this constructor is called. - */ - protected DeclarationImpl(AptEnv env, Symbol sym) { - this.env = env; - this.sym = sym; - } - - - /** - * {@inheritDoc} - *

ParameterDeclarationImpl overrides this implementation. - */ - public boolean equals(Object obj) { - if (obj instanceof DeclarationImpl) { - DeclarationImpl that = (DeclarationImpl) obj; - return sym == that.sym && env == that.env; - } else { - return false; - } - } - - /** - * {@inheritDoc} - *

ParameterDeclarationImpl overrides this implementation. - */ - public int hashCode() { - return sym.hashCode() + env.hashCode(); - } - - /** - * {@inheritDoc} - */ - public String getDocComment() { - // Our doc comment is contained in a map in our toplevel, - // indexed by our tree. Find our enter environment, which gives - // us our toplevel. It also gives us a tree that contains our - // tree: walk it to find our tree. This is painful. - Env enterEnv = getEnterEnv(); - if (enterEnv == null) - return null; - JCTree tree = TreeInfo.declarationFor(sym, enterEnv.tree); - return enterEnv.toplevel.docComments.get(tree); - } - - /** - * {@inheritDoc} - */ - public Collection getAnnotationMirrors() { - Collection res = - new ArrayList(); - for (Attribute.Compound a : sym.getAnnotationMirrors()) { - res.add(env.declMaker.getAnnotationMirror(a, this)); - } - return res; - } - - /** - * {@inheritDoc} - * Overridden by ClassDeclarationImpl to handle @Inherited. - */ - public A getAnnotation(Class annoType) { - return getAnnotation(annoType, sym); - } - - protected A getAnnotation(Class annoType, - Symbol annotated) { - if (!annoType.isAnnotation()) { - throw new IllegalArgumentException( - "Not an annotation type: " + annoType); - } - String name = annoType.getName(); - for (Attribute.Compound attr : annotated.getAnnotationMirrors()) { - if (name.equals(attr.type.tsym.flatName().toString())) { - return AnnotationProxyMaker.generateAnnotation(env, attr, - annoType); - } - } - return null; - } - - // Cache for modifiers. - private EnumSet modifiers = null; - - /** - * {@inheritDoc} - */ - public Collection getModifiers() { - if (modifiers == null) { - modifiers = EnumSet.noneOf(Modifier.class); - long flags = AptEnv.getFlags(sym); - - if (0 != (flags & Flags.PUBLIC)) modifiers.add(PUBLIC); - if (0 != (flags & Flags.PROTECTED)) modifiers.add(PROTECTED); - if (0 != (flags & Flags.PRIVATE)) modifiers.add(PRIVATE); - if (0 != (flags & Flags.ABSTRACT)) modifiers.add(ABSTRACT); - if (0 != (flags & Flags.STATIC)) modifiers.add(STATIC); - if (0 != (flags & Flags.FINAL)) modifiers.add(FINAL); - if (0 != (flags & Flags.TRANSIENT)) modifiers.add(TRANSIENT); - if (0 != (flags & Flags.VOLATILE)) modifiers.add(VOLATILE); - if (0 != (flags & Flags.SYNCHRONIZED)) modifiers.add(SYNCHRONIZED); - if (0 != (flags & Flags.NATIVE)) modifiers.add(NATIVE); - if (0 != (flags & Flags.STRICTFP)) modifiers.add(STRICTFP); - } - return modifiers; - } - - /** - * {@inheritDoc} - * Overridden in some subclasses. - */ - public String getSimpleName() { - return sym.name.toString(); - } - - /** - * {@inheritDoc} - */ - public SourcePosition getPosition() { - // Find the toplevel. From there use a tree-walking utility - // that finds the tree for our symbol, and with it the position. - Env enterEnv = getEnterEnv(); - if (enterEnv == null) - return null; - JCTree.JCCompilationUnit toplevel = enterEnv.toplevel; - JavaFileObject sourcefile = toplevel.sourcefile; - if (sourcefile == null) - return null; - int pos = TreeInfo.positionFor(sym, toplevel); - - return new SourcePositionImpl(sourcefile, pos, toplevel.lineMap); - } - - /** - * Applies a visitor to this declaration. - * - * @param v the visitor operating on this declaration - */ - public void accept(DeclarationVisitor v) { - v.visitDeclaration(this); - } - - - private Collection members = null; // cache for getMembers() - - /** - * Returns the symbols of type or package members (and constructors) - * that are not synthetic or otherwise unwanted. - * Caches the result if "cache" is true. - */ - protected Collection getMembers(boolean cache) { - if (members != null) { - return members; - } - LinkedList res = new LinkedList(); - for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) { - if (e.sym != null && !unwanted(e.sym)) { - res.addFirst(e.sym); - } - } - return cache ? (members = res) : res; - } - - /** - * Tests whether this is a symbol that should never be seen by clients, - * such as a synthetic class. - * Note that a class synthesized by the compiler may not be flagged as - * synthetic: see bugid 4959932. - */ - private static boolean unwanted(Symbol s) { - return AptEnv.hasFlag(s, Flags.SYNTHETIC) || - (s.kind == TYP && - !DeclarationMaker.isJavaIdentifier(s.name.toString())); - } - - /** - * Returns this declaration's enter environment, or null if it - * has none. - */ - private Env getEnterEnv() { - // Get enclosing class of sym, or sym itself if it is a class - // or package. - TypeSymbol ts = (sym.kind != PCK) - ? sym.enclClass() - : (PackageSymbol) sym; - return (ts != null) - ? env.enter.getEnv(ts) - : null; - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationMaker.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationMaker.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,270 +0,0 @@ -/* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.HashMap; -import java.util.Map; - -import com.sun.mirror.declaration.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.main.JavaCompiler; - -/** - * Utilities for constructing and caching declarations. - */ -@SuppressWarnings("deprecation") -public class DeclarationMaker { - - private AptEnv env; - private Context context; - private JavaCompiler javacompiler; - private static final Context.Key declarationMakerKey = - new Context.Key(); - - public static DeclarationMaker instance(Context context) { - DeclarationMaker instance = context.get(declarationMakerKey); - if (instance == null) { - instance = new DeclarationMaker(context); - } - return instance; - } - - private DeclarationMaker(Context context) { - context.put(declarationMakerKey, this); - env = AptEnv.instance(context); - this.context = context; - this.javacompiler = JavaCompiler.instance(context); - } - - - - // Cache of package declarations - private Map packageDecls = - new HashMap(); - - /** - * Returns the package declaration for a package symbol. - */ - public PackageDeclaration getPackageDeclaration(PackageSymbol p) { - PackageDeclaration res = packageDecls.get(p); - if (res == null) { - res = new PackageDeclarationImpl(env, p); - packageDecls.put(p, res); - } - return res; - } - - /** - * Returns the package declaration for the package with the given name. - * Name is fully-qualified, or "" for the unnamed package. - * Returns null if package declaration not found. - */ - public PackageDeclaration getPackageDeclaration(String name) { - PackageSymbol p = null; - if (name.equals("") ) - p = env.symtab.unnamedPackage; - else { - if (!isJavaName(name)) - return null; - Symbol s = nameToSymbol(name, false); - if (s instanceof PackageSymbol) { - p = (PackageSymbol) s; - if (!p.exists()) - return null; - } else - return null; - } - return getPackageDeclaration(p); - } - - // Cache of type declarations - private Map typeDecls = - new HashMap(); - - /** - * Returns the type declaration for a class symbol. - * Forces completion, and returns null on error. - */ - public TypeDeclaration getTypeDeclaration(ClassSymbol c) { - long flags = AptEnv.getFlags(c); // forces symbol completion - if (c.kind == Kinds.ERR) { - return null; - } - TypeDeclaration res = typeDecls.get(c); - if (res == null) { - if ((flags & Flags.ANNOTATION) != 0) { - res = new AnnotationTypeDeclarationImpl(env, c); - } else if ((flags & Flags.INTERFACE) != 0) { - res = new InterfaceDeclarationImpl(env, c); - } else if ((flags & Flags.ENUM) != 0) { - res = new EnumDeclarationImpl(env, c); - } else { - res = new ClassDeclarationImpl(env, c); - } - typeDecls.put(c, res); - } - return res; - } - - /** - * Returns the type declaration for the type with the given canonical name. - * Returns null if type declaration not found. - */ - public TypeDeclaration getTypeDeclaration(String name) { - if (!isJavaName(name)) - return null; - Symbol s = nameToSymbol(name, true); - if (s instanceof ClassSymbol) { - ClassSymbol c = (ClassSymbol) s; - return getTypeDeclaration(c); - } else - return null; - } - - /** - * Returns a symbol given the type's or packages's canonical name, - * or null if the name isn't found. - */ - private Symbol nameToSymbol(String name, boolean classCache) { - Symbol s = null; - Name nameName = env.names.fromString(name); - if (classCache) - s = env.symtab.classes.get(nameName); - else - s = env.symtab.packages.get(nameName); - - if (s != null && s.exists()) - return s; - - s = javacompiler.resolveIdent(name); - if (s.kind == Kinds.ERR ) - return null; - - if (s.kind == Kinds.PCK) - s.complete(); - - return s; - } - - // Cache of method and constructor declarations - private Map executableDecls = - new HashMap(); - - /** - * Returns the method or constructor declaration for a method symbol. - */ - ExecutableDeclaration getExecutableDeclaration(MethodSymbol m) { - ExecutableDeclaration res = executableDecls.get(m); - if (res == null) { - if (m.isConstructor()) { - res = new ConstructorDeclarationImpl(env, m); - } else if (isAnnotationTypeElement(m)) { - res = new AnnotationTypeElementDeclarationImpl(env, m); - } else { - res = new MethodDeclarationImpl(env, m); - } - executableDecls.put(m, res); - } - return res; - } - - // Cache of field declarations - private Map fieldDecls = - new HashMap(); - - /** - * Returns the field declaration for a var symbol. - */ - FieldDeclaration getFieldDeclaration(VarSymbol v) { - FieldDeclaration res = fieldDecls.get(v); - if (res == null) { - if (hasFlag(v, Flags.ENUM)) { - res = new EnumConstantDeclarationImpl(env, v); - } else { - res = new FieldDeclarationImpl(env, v); - } - fieldDecls.put(v, res); - } - return res; - } - - /** - * Returns a parameter declaration. - */ - ParameterDeclaration getParameterDeclaration(VarSymbol v) { - return new ParameterDeclarationImpl(env, v); - } - - /** - * Returns a type parameter declaration. - */ - public TypeParameterDeclaration getTypeParameterDeclaration(TypeSymbol t) { - return new TypeParameterDeclarationImpl(env, t); - } - - /** - * Returns an annotation. - */ - AnnotationMirror getAnnotationMirror(Attribute.Compound a, Declaration decl) { - return new AnnotationMirrorImpl(env, a, decl); - } - - - /** - * Is a string a valid Java identifier? - */ - public static boolean isJavaIdentifier(String id) { - return javax.lang.model.SourceVersion.isIdentifier(id); - } - - public static boolean isJavaName(String name) { - for(String id: name.split("\\.")) { - if (! isJavaIdentifier(id)) - return false; - } - return true; - } - - /** - * Is a method an annotation type element? - * It is if it's declared in an annotation type. - */ - private static boolean isAnnotationTypeElement(MethodSymbol m) { - return hasFlag(m.enclClass(), Flags.ANNOTATION); - } - - /** - * Does a symbol have a given flag? - */ - private static boolean hasFlag(Symbol s, long flag) { - return AptEnv.hasFlag(s, flag); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/EnumConstantDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumConstantDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.VarSymbol; - - -/** - * Implementation of EnumConstantDeclaration - */ -@SuppressWarnings("deprecation") -public class EnumConstantDeclarationImpl extends FieldDeclarationImpl - implements EnumConstantDeclaration { - - EnumConstantDeclarationImpl(AptEnv env, VarSymbol sym) { - super(env, sym); - } - - /** - * {@inheritDoc} - */ - public EnumDeclaration getDeclaringType() { - return (EnumDeclaration) super.getDeclaringType(); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitEnumConstantDeclaration(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/EnumDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of EnumDeclaration - */ -@SuppressWarnings("deprecation") -public class EnumDeclarationImpl extends ClassDeclarationImpl - implements EnumDeclaration { - - EnumDeclarationImpl(AptEnv env, ClassSymbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - */ - public Collection getEnumConstants() { - return identityFilter.filter(getFields(), - EnumConstantDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitEnumDeclaration(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/ExecutableDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/ExecutableDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.ReferenceType; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of ExecutableDeclaration - */ -@SuppressWarnings("deprecation") -public abstract class ExecutableDeclarationImpl extends MemberDeclarationImpl - implements ExecutableDeclaration { - public MethodSymbol sym; - - protected ExecutableDeclarationImpl(AptEnv env, MethodSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns type parameters (if any), method name, and signature - * (value parameter types). - */ - public String toString() { - return sym.toString(); - } - - /** - * {@inheritDoc} - */ - public boolean isVarArgs() { - return AptEnv.hasFlag(sym, Flags.VARARGS); - } - - /** - * {@inheritDoc} - */ - public Collection getParameters() { - Collection res = - new ArrayList(); - for (VarSymbol param : sym.params()) - res.add(env.declMaker.getParameterDeclaration(param)); - return res; - } - - /** - * {@inheritDoc} - */ - public Collection getThrownTypes() { - ArrayList res = new ArrayList(); - for (Type t : sym.type.getThrownTypes()) { - res.add((ReferenceType) env.typeMaker.getType(t)); - } - return res; - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/FieldDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/FieldDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.TypeMirror; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.code.TypeTags; - - -/** - * Implementation of FieldDeclaration - */ -@SuppressWarnings("deprecation") -class FieldDeclarationImpl extends MemberDeclarationImpl - implements FieldDeclaration { - - protected VarSymbol sym; - - FieldDeclarationImpl(AptEnv env, VarSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns the field's name. - */ - public String toString() { - return getSimpleName(); - } - - /** - * {@inheritDoc} - */ - public TypeMirror getType() { - return env.typeMaker.getType(sym.type); - } - - /** - * {@inheritDoc} - */ - public Object getConstantValue() { - Object val = sym.getConstValue(); - // val may be null, indicating that this is not a constant. - - return Constants.decodeConstant(val, sym.type); - } - - /** - * {@inheritDoc} - */ - public String getConstantExpression() { - Object val = getConstantValue(); - if (val == null) { - return null; - } - Constants.Formatter fmtr = Constants.getFormatter(); - fmtr.append(val); - return fmtr.toString(); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitFieldDeclaration(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/InterfaceDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/InterfaceDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of InterfaceDeclaration - */ -@SuppressWarnings("deprecation") -public class InterfaceDeclarationImpl extends TypeDeclarationImpl - implements InterfaceDeclaration { - - InterfaceDeclarationImpl(AptEnv env, ClassSymbol sym) { - super(env, sym); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitInterfaceDeclaration(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/MemberDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/MemberDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol; -import com.sun.tools.javac.code.Symbol.ClassSymbol; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of MemberDeclaration - */ -@SuppressWarnings("deprecation") -public abstract class MemberDeclarationImpl extends DeclarationImpl - implements MemberDeclaration { - - protected MemberDeclarationImpl(AptEnv env, Symbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - */ - public TypeDeclaration getDeclaringType() { - ClassSymbol c = getDeclaringClassSymbol(); - return (c == null) - ? null - : env.declMaker.getTypeDeclaration(c); - } - - /** - * {@inheritDoc} - * For methods, constructors, and types. - */ - public Collection getFormalTypeParameters() { - ArrayList res = - new ArrayList(); - for (Type t : sym.type.getTypeArguments()) { - res.add(env.declMaker.getTypeParameterDeclaration(t.tsym)); - } - return res; - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitMemberDeclaration(this); - } - - - /** - * Returns the ClassSymbol of the declaring type, - * or null if this is a top-level type. - */ - private ClassSymbol getDeclaringClassSymbol() { - return sym.owner.enclClass(); - } - - /** - * Returns the formal type parameters of a type, member or constructor - * as an angle-bracketed string. Each parameter consists of the simple - * type variable name and any bounds (with no implicit "extends Object" - * clause added). Type names are qualified. - * Returns "" if there are no type parameters. - */ - protected static String typeParamsToString(AptEnv env, Symbol sym) { - if (sym.type.getTypeArguments().isEmpty()) { - return ""; - } - StringBuilder s = new StringBuilder(); - for (Type t : sym.type.getTypeArguments()) { - Type.TypeVar tv = (Type.TypeVar) t; - s.append(s.length() == 0 ? "<" : ", ") - .append(TypeParameterDeclarationImpl.toString(env, tv)); - } - s.append(">"); - return s.toString(); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/MethodDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/MethodDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.mirror.type.TypeMirror; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.MethodSymbol; - - -/** - * Implementation of MethodDeclaration - */ -@SuppressWarnings("deprecation") -public class MethodDeclarationImpl extends ExecutableDeclarationImpl - implements MethodDeclaration { - - MethodDeclarationImpl(AptEnv env, MethodSymbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - */ - public TypeMirror getReturnType() { - return env.typeMaker.getType(sym.type.getReturnType()); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitMethodDeclaration(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/PackageDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/PackageDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.ArrayList; -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of PackageDeclaration. - */ -@SuppressWarnings("deprecation") -public class PackageDeclarationImpl extends DeclarationImpl - implements PackageDeclaration { - - private PackageSymbol sym; - - - public PackageDeclarationImpl(AptEnv env, PackageSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns the qualified name. - */ - public String toString() { - return getQualifiedName(); - } - - /** - * {@inheritDoc} - */ - public String getQualifiedName() { - return sym.getQualifiedName().toString(); - } - - /** - * {@inheritDoc} - */ - public Collection getClasses() { - return identityFilter.filter(getAllTypes(), - ClassDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public Collection getEnums() { - return identityFilter.filter(getAllTypes(), - EnumDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public Collection getInterfaces() { - return identityFilter.filter(getAllTypes(), - InterfaceDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public Collection getAnnotationTypes() { - return identityFilter.filter(getAllTypes(), - AnnotationTypeDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitPackageDeclaration(this); - } - - - // Cache of all top-level type declarations in this package. - private Collection allTypes = null; - - /** - * Caches and returns all top-level type declarations in this package. - * Omits synthetic types. - */ - private Collection getAllTypes() { - if (allTypes != null) { - return allTypes; - } - allTypes = new ArrayList(); - for (Symbol s : getMembers(false)) { - allTypes.add(env.declMaker.getTypeDeclaration((ClassSymbol) s)); - } - return allTypes; - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/ParameterDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/ParameterDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.TypeMirror; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.VarSymbol; - - -/** - * Implementation of ParameterDeclaration - */ -@SuppressWarnings("deprecation") -public class ParameterDeclarationImpl extends DeclarationImpl - implements ParameterDeclaration -{ - protected VarSymbol sym; - - - ParameterDeclarationImpl(AptEnv env, VarSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns the simple name of the parameter. - */ - public String toString() { - return getType() + " " + sym.name; - } - - /** - * {@inheritDoc} - */ - public boolean equals(Object obj) { - // Neither ParameterDeclarationImpl objects nor their symbols - // are cached by the current implementation, so check symbol - // owners and names. - - if (obj instanceof ParameterDeclarationImpl) { - ParameterDeclarationImpl that = (ParameterDeclarationImpl) obj; - return sym.owner == that.sym.owner && - sym.name == that.sym.name && - env == that.env; - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public int hashCode() { - return sym.owner.hashCode() + sym.name.hashCode() + env.hashCode(); - } - - /** - * {@inheritDoc} - */ - public TypeMirror getType() { - return env.typeMaker.getType(sym.type); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitParameterDeclaration(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/TypeDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.util.Name; - -/** - * Implementation of TypeDeclaration - */ -@SuppressWarnings("deprecation") -public class TypeDeclarationImpl extends MemberDeclarationImpl - implements TypeDeclaration { - - public ClassSymbol sym; - - - /** - * "sym" should be completed before this constructor is called. - */ - protected TypeDeclarationImpl(AptEnv env, ClassSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns the type's name, with any type parameters (including those - * of outer classes). Type names are qualified. - */ - public String toString() { - return toString(env, sym); - } - - /** - * {@inheritDoc} - */ - public PackageDeclaration getPackage() { - return env.declMaker.getPackageDeclaration(sym.packge()); - } - - /** - * {@inheritDoc} - */ - public String getQualifiedName() { - return sym.toString(); - } - - /** - * {@inheritDoc} - */ - public Collection getSuperinterfaces() { - return env.typeMaker.getTypes(env.jctypes.interfaces(sym.type), - InterfaceType.class); - } - - /** - * {@inheritDoc} - */ - public Collection getFields() { - ArrayList res = new ArrayList(); - for (Symbol s : getMembers(true)) { - if (s.kind == Kinds.VAR) { - res.add(env.declMaker.getFieldDeclaration((VarSymbol) s)); - } - } - return res; - } - - /** - * {@inheritDoc} - */ - public Collection getMethods() { - ArrayList res = new ArrayList(); - for (Symbol s : getMembers(true)) { - if (s.kind == Kinds.MTH && !s.isConstructor() && - !env.names.clinit.equals(s.name) ) { // screen out static initializers - MethodSymbol m = (MethodSymbol) s; - res.add((MethodDeclaration) - env.declMaker.getExecutableDeclaration(m)); - } - } - return res; - } - - /** - * {@inheritDoc} - */ - public Collection getNestedTypes() { - ArrayList res = new ArrayList(); - for (Symbol s : getMembers(true)) { - if (s.kind == Kinds.TYP) { - res.add(env.declMaker.getTypeDeclaration((ClassSymbol) s)); - } - } - return res; - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitTypeDeclaration(this); - } - - - /** - * Returns a type's name, with any type parameters (including those - * of outer classes). Type names are qualified. - */ - static String toString(AptEnv env, ClassSymbol c) { - StringBuilder sb = new StringBuilder(); - if (c.isInner()) { - // c is an inner class, so include type params of outer. - ClassSymbol enclosing = c.owner.enclClass(); - sb.append(toString(env, enclosing)) - .append('.') - .append(c.name); - } else { - sb.append(c); - } - sb.append(typeParamsToString(env, c)); - return sb.toString(); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/declaration/TypeParameterDeclarationImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeParameterDeclarationImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.ReferenceType; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of TypeParameterDeclaration - */ -@SuppressWarnings("deprecation") -public class TypeParameterDeclarationImpl extends DeclarationImpl - implements TypeParameterDeclaration -{ - protected TypeSymbol sym; - - - TypeParameterDeclarationImpl(AptEnv env, TypeSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns the type parameter's name along with any "extends" clause. - * Class names are qualified. No implicit "extends Object" is added. - */ - public String toString() { - return toString(env, (Type.TypeVar) sym.type); - } - - /** - * {@inheritDoc} - */ - public Collection getBounds() { - ArrayList res = new ArrayList(); - for (Type t : env.jctypes.getBounds((Type.TypeVar) sym.type)) { - res.add((ReferenceType) env.typeMaker.getType(t)); - } - return res; - } - - /** - * {@inheritDoc} - */ - public Declaration getOwner() { - Symbol owner = sym.owner; - return ((owner.kind & Kinds.TYP) != 0) - ? env.declMaker.getTypeDeclaration((ClassSymbol) owner) - : env.declMaker.getExecutableDeclaration((MethodSymbol) owner); - } - - - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitTypeParameterDeclaration(this); - } - - - /** - * Returns the type parameter's name along with any "extends" clause. - * See {@link #toString()} for details. - */ - static String toString(AptEnv env, Type.TypeVar tv) { - StringBuilder s = new StringBuilder(); - s.append(tv); - boolean first = true; - for (Type bound : getExtendsBounds(env, tv)) { - s.append(first ? " extends " : " & "); - s.append(env.typeMaker.typeToString(bound)); - first = false; - } - return s.toString(); - } - - /** - * Returns the bounds of a type variable, eliding java.lang.Object - * if it appears alone. - */ - private static Iterable getExtendsBounds(AptEnv env, - Type.TypeVar tv) { - return (tv.getUpperBound().tsym == env.symtab.objectType.tsym) - ? com.sun.tools.javac.util.List.nil() - : env.jctypes.getBounds(tv); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/AnnotationTypeImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/AnnotationTypeImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of AnnotationType - */ -@SuppressWarnings("deprecation") -public class AnnotationTypeImpl extends InterfaceTypeImpl - implements AnnotationType { - - AnnotationTypeImpl(AptEnv env, Type.ClassType type) { - super(env, type); - } - - - /** - * {@inheritDoc} - */ - public AnnotationTypeDeclaration getDeclaration() { - return (AnnotationTypeDeclaration) super.getDeclaration(); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitAnnotationType(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/ArrayTypeImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/ArrayTypeImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of ArrayType - */ -@SuppressWarnings("deprecation") -public class ArrayTypeImpl extends TypeMirrorImpl implements ArrayType { - - protected Type.ArrayType type; - - - ArrayTypeImpl(AptEnv env, Type.ArrayType type) { - super(env, type); - this.type = type; - } - - - /** - * {@inheritDoc} - */ - public TypeMirror getComponentType() { - return env.typeMaker.getType(type.elemtype); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitArrayType(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/ClassTypeImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/ClassTypeImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of ClassType - */ -@SuppressWarnings("deprecation") -public class ClassTypeImpl extends DeclaredTypeImpl implements ClassType { - - ClassTypeImpl(AptEnv env, Type.ClassType type) { - super(env, type); - } - - - /** - * {@inheritDoc} - */ - public ClassDeclaration getDeclaration() { - return (ClassDeclaration) super.getDeclaration(); - } - - /** - * {@inheritDoc} - */ - public ClassType getSuperclass() { - // java.lang.Object has no superclass - if (type.tsym == env.symtab.objectType.tsym) { - return null; - } - Type sup = env.jctypes.supertype(type); - return (ClassType) env.typeMaker.getType(sup); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitClassType(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/DeclaredTypeImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/DeclaredTypeImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import java.util.Collection; - -import com.sun.mirror.declaration.TypeDeclaration; -import com.sun.mirror.type.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.ClassSymbol; - - -/** - * Implementation of DeclaredType - */ -@SuppressWarnings("deprecation") -abstract class DeclaredTypeImpl extends TypeMirrorImpl - implements DeclaredType { - - protected Type.ClassType type; - - - protected DeclaredTypeImpl(AptEnv env, Type.ClassType type) { - super(env, type); - this.type = type; - } - - - /** - * Returns a string representation of this declared type. - * This includes the type's name and any actual type arguments. - * Type names are qualified. - */ - public String toString() { - return toString(env, type); - } - - /** - * {@inheritDoc} - */ - public TypeDeclaration getDeclaration() { - return env.declMaker.getTypeDeclaration((ClassSymbol) type.tsym); - } - - /** - * {@inheritDoc} - */ - public DeclaredType getContainingType() { - if (type.getEnclosingType().tag == TypeTags.CLASS) { - // This is the type of an inner class. - return (DeclaredType) env.typeMaker.getType(type.getEnclosingType()); - } - ClassSymbol enclosing = type.tsym.owner.enclClass(); - if (enclosing != null) { - // Nested but not inner. Return the raw type of the enclosing - // class or interface. - // See java.lang.reflect.ParameterizedType.getOwnerType(). - return (DeclaredType) env.typeMaker.getType( - env.jctypes.erasure(enclosing.type)); - } - return null; - } - - /** - * {@inheritDoc} - */ - public Collection getActualTypeArguments() { - return env.typeMaker.getTypes(type.getTypeArguments()); - } - - /** - * {@inheritDoc} - */ - public Collection getSuperinterfaces() { - return env.typeMaker.getTypes(env.jctypes.interfaces(type), - InterfaceType.class); - } - - - /** - * Returns a string representation of this declared type. - * See {@link #toString()} for details. - */ - static String toString(AptEnv env, Type.ClassType c) { - return c.toString(); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/EnumTypeImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/EnumTypeImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of EnumType - */ -@SuppressWarnings("deprecation") -public class EnumTypeImpl extends ClassTypeImpl implements EnumType { - - EnumTypeImpl(AptEnv env, Type.ClassType type) { - super(env, type); - } - - - /** - * {@inheritDoc} - */ - public EnumDeclaration getDeclaration() { - return (EnumDeclaration) super.getDeclaration(); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitEnumType(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/InterfaceTypeImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/InterfaceTypeImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of InterfaceType - */ -@SuppressWarnings("deprecation") -public class InterfaceTypeImpl extends DeclaredTypeImpl - implements InterfaceType { - - InterfaceTypeImpl(AptEnv env, Type.ClassType type) { - super(env, type); - } - - - /** - * {@inheritDoc} - */ - public InterfaceDeclaration getDeclaration() { - return (InterfaceDeclaration) super.getDeclaration(); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitInterfaceType(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/PrimitiveTypeImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/PrimitiveTypeImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - - -import com.sun.mirror.type.PrimitiveType; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - -import static com.sun.mirror.type.PrimitiveType.Kind.*; - - -/** - * Implementation of PrimitiveType. - */ -@SuppressWarnings("deprecation") -class PrimitiveTypeImpl extends TypeMirrorImpl implements PrimitiveType { - - private final Kind kind; // the kind of primitive - - - PrimitiveTypeImpl(AptEnv env, Kind kind) { - super(env, getType(env, kind)); - this.kind = kind; - } - - - /** - * {@inheritDoc} - */ - public Kind getKind() { - return kind; - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitPrimitiveType(this); - } - - - /** - * Returns the javac type corresponding to a kind of primitive type. - */ - private static Type getType(AptEnv env, Kind kind) { - switch (kind) { - case BOOLEAN: return env.symtab.booleanType; - case BYTE: return env.symtab.byteType; - case SHORT: return env.symtab.shortType; - case INT: return env.symtab.intType; - case LONG: return env.symtab.longType; - case CHAR: return env.symtab.charType; - case FLOAT: return env.symtab.floatType; - case DOUBLE: return env.symtab.doubleType; - default: throw new AssertionError(); - } - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/TypeMaker.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/TypeMaker.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.type.*; -import com.sun.mirror.type.PrimitiveType.Kind; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.util.Context; - -import static com.sun.tools.javac.code.TypeTags.*; - - -/** - * Utilities for constructing type objects. - */ -@SuppressWarnings("deprecation") -public class TypeMaker { - - private final AptEnv env; - private final VoidType voidType; - private PrimitiveType[] primTypes = new PrimitiveType[VOID]; - // VOID is past all prim types - - - private static final Context.Key typeMakerKey = - new Context.Key(); - - public static TypeMaker instance(Context context) { - TypeMaker instance = context.get(typeMakerKey); - if (instance == null) { - instance = new TypeMaker(context); - } - return instance; - } - - private TypeMaker(Context context) { - context.put(typeMakerKey, this); - env = AptEnv.instance(context); - - voidType = new VoidTypeImpl(env); - primTypes[BOOLEAN] = new PrimitiveTypeImpl(env, Kind.BOOLEAN); - primTypes[BYTE] = new PrimitiveTypeImpl(env, Kind.BYTE); - primTypes[SHORT] = new PrimitiveTypeImpl(env, Kind.SHORT); - primTypes[INT] = new PrimitiveTypeImpl(env, Kind.INT); - primTypes[LONG] = new PrimitiveTypeImpl(env, Kind.LONG); - primTypes[CHAR] = new PrimitiveTypeImpl(env, Kind.CHAR); - primTypes[FLOAT] = new PrimitiveTypeImpl(env, Kind.FLOAT); - primTypes[DOUBLE] = new PrimitiveTypeImpl(env, Kind.DOUBLE); - } - - - /** - * Returns the TypeMirror corresponding to a javac Type object. - */ - public TypeMirror getType(Type t) { - if (t.isPrimitive()) { - return primTypes[t.tag]; - } - switch (t.tag) { - case ERROR: // fall through - case CLASS: return getDeclaredType((Type.ClassType) t); - case WILDCARD: return new WildcardTypeImpl(env, (Type.WildcardType) t); - case TYPEVAR: return new TypeVariableImpl(env, (Type.TypeVar) t); - case ARRAY: return new ArrayTypeImpl(env, (Type.ArrayType) t); - case VOID: return voidType; - default: throw new AssertionError(); - } - } - - /** - * Returns the declared type corresponding to a given ClassType. - */ - public DeclaredType getDeclaredType(Type.ClassType t) { - return - hasFlag(t.tsym, Flags.ANNOTATION) ? new AnnotationTypeImpl(env, t) : - hasFlag(t.tsym, Flags.INTERFACE) ? new InterfaceTypeImpl(env, t) : - hasFlag(t.tsym, Flags.ENUM) ? new EnumTypeImpl(env, t) : - new ClassTypeImpl(env, t); - } - - /** - * Returns a collection of types corresponding to a list of javac Type - * objects. - */ - public Collection getTypes(Iterable types) { - return getTypes(types, TypeMirror.class); - } - - /** - * Returns a collection of types corresponding to a list of javac Type - * objects. The element type of the result is specified explicitly. - */ - public Collection getTypes(Iterable types, - Class resType) { - ArrayList res = new ArrayList(); - for (Type t : types) { - TypeMirror mir = getType(t); - if (resType.isInstance(mir)) { - res.add(resType.cast(mir)); - } - } - return res; - } - - /** - * Returns the string representation of a type. - * Bounds of type variables are not included; bounds of wildcard types are. - * Type names are qualified. - */ - public String typeToString(Type t) { - switch (t.tag) { - case ARRAY: - return typeToString(env.jctypes.elemtype(t)) + "[]"; - case CLASS: - Type.ClassType c = (Type.ClassType) t; - return DeclaredTypeImpl.toString(env, c); - case WILDCARD: - Type.WildcardType a = (Type.WildcardType) t; - return WildcardTypeImpl.toString(env, a); - default: - return t.tsym.toString(); - } - } - - - /** - * Does a symbol have a given flag? - */ - private static boolean hasFlag(Symbol s, long flag) { - return AptEnv.hasFlag(s, flag); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/TypeMirrorImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/TypeMirrorImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; - - -/** - * Implementation of TypeMirror - */ -@SuppressWarnings("deprecation") -public abstract class TypeMirrorImpl implements TypeMirror { - - protected final AptEnv env; - public final Type type; - - - protected TypeMirrorImpl(AptEnv env, Type type) { - this.env = env; - this.type = type; - } - - - /** - * {@inheritDoc} - */ - public String toString() { - return type.toString(); - } - - /** - * {@inheritDoc} - */ - public boolean equals(Object obj) { - if (obj instanceof TypeMirrorImpl) { - TypeMirrorImpl that = (TypeMirrorImpl) obj; - return env.jctypes.isSameType(this.type, that.type); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public int hashCode() { - return Types.hashCode(type); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.TypeSymbol; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of TypeVariable - */ -@SuppressWarnings("deprecation") -public class TypeVariableImpl extends TypeMirrorImpl implements TypeVariable { - - protected Type.TypeVar type; - - - TypeVariableImpl(AptEnv env, Type.TypeVar type) { - super(env, type); - this.type = type; - } - - - /** - * Returns the simple name of this type variable. Bounds are - * not included. - */ - public String toString() { - return type.tsym.name.toString(); - } - - /** - * {@inheritDoc} - */ - public TypeParameterDeclaration getDeclaration() { - TypeSymbol sym = type.tsym; - return env.declMaker.getTypeParameterDeclaration(sym); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitTypeVariable(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/VoidTypeImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/VoidTypeImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.type.VoidType; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; - - -/** - * Implementation of VoidType. - */ -@SuppressWarnings("deprecation") -class VoidTypeImpl extends TypeMirrorImpl implements VoidType { - - VoidTypeImpl(AptEnv env) { - super(env, env.symtab.voidType); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitVoidType(this); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/type/WildcardTypeImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/type/WildcardTypeImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of WildcardType - */ -@SuppressWarnings("deprecation") -public class WildcardTypeImpl extends TypeMirrorImpl implements WildcardType { - - protected Type.WildcardType type; - - WildcardTypeImpl(AptEnv env, Type.WildcardType type) { - super(env, type); - this.type = type; - } - - - /** - * Returns the string form of a wildcard type, consisting of "?" - * and any "extends" or "super" clause. - * Delimiting brackets are not included. Class names are qualified. - */ - public String toString() { - return toString(env, type); - } - - /** - * {@inheritDoc} - */ - public Collection getUpperBounds() { - return type.isSuperBound() - ? Collections.emptyList() - : typeToCollection(type.type); - } - - /** - * {@inheritDoc} - */ - public Collection getLowerBounds() { - return type.isExtendsBound() - ? Collections.emptyList() - : typeToCollection(type.type); - } - - /** - * Gets the ReferenceType for a javac Type object, and returns - * it in a singleton collection. If type is null, returns an empty - * collection. - */ - private Collection typeToCollection(Type type) { - ArrayList res = new ArrayList(1); - if (type != null) { - res.add((ReferenceType) env.typeMaker.getType(type)); - } - return res; - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitWildcardType(this); - } - - - /** - * Returns the string form of a wildcard type, consisting of "?" - * and any "extends" or "super" clause. - * See {@link #toString()} for details. - */ - static String toString(AptEnv env, Type.WildcardType wildThing) { - return wildThing.toString(); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/util/DeclarationsImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/util/DeclarationsImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.util; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.Declarations; -import com.sun.tools.apt.mirror.declaration.DeclarationImpl; -import com.sun.tools.apt.mirror.declaration.MethodDeclarationImpl; -import com.sun.tools.apt.mirror.util.DeclarationsImpl; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.util.Context; - -import static com.sun.tools.javac.code.Kinds.*; - - -/** - * Implementation of Declarations utility methods for annotation processors - */ -@SuppressWarnings("deprecation") -public class DeclarationsImpl implements Declarations { - - private final AptEnv env; - - - private static final Context.Key declarationsKey = - new Context.Key(); - - public static Declarations instance(Context context) { - Declarations instance = context.get(declarationsKey); - if (instance == null) { - instance = new DeclarationsImpl(context); - } - return instance; - } - - private DeclarationsImpl(Context context) { - context.put(declarationsKey, this); - env = AptEnv.instance(context); - } - - - /** - * {@inheritDoc} - * See sections 8.3 and 8.4.6 of - * The Java™ Language Specification - */ - public boolean hides(MemberDeclaration sub, MemberDeclaration sup) { - Symbol hider = ((DeclarationImpl) sub).sym; - Symbol hidee = ((DeclarationImpl) sup).sym; - - // Fields only hide fields; methods only methods; types only types. - // Names must match. Nothing hides itself (just try it). - if (hider == hidee || - hider.kind != hidee.kind || - hider.name != hidee.name) { - return false; - } - - // Only static methods can hide other methods. - // Methods only hide methods with matching signatures. - if (hider.kind == MTH) { - if ((hider.flags() & Flags.STATIC) == 0 || - !env.jctypes.isSubSignature(hider.type, hidee.type)) { - return false; - } - } - - // Hider must be in a subclass of hidee's class. - // Note that if M1 hides M2, and M2 hides M3, and M3 is accessible - // in M1's class, then M1 and M2 both hide M3. - ClassSymbol hiderClass = hider.owner.enclClass(); - ClassSymbol hideeClass = hidee.owner.enclClass(); - if (hiderClass == null || hideeClass == null || - !hiderClass.isSubClass(hideeClass, env.jctypes)) { - return false; - } - - // Hidee must be accessible in hider's class. - // The method isInheritedIn is poorly named: it checks only access. - return hidee.isInheritedIn(hiderClass, env.jctypes); - } - - /** - * {@inheritDoc} - * See section 8.4.6.1 of - * The Java™ Language Specification - */ - public boolean overrides(MethodDeclaration sub, MethodDeclaration sup) { - MethodSymbol overrider = ((MethodDeclarationImpl) sub).sym; - MethodSymbol overridee = ((MethodDeclarationImpl) sup).sym; - ClassSymbol origin = (ClassSymbol) overrider.owner; - - return overrider.name == overridee.name && - - // not reflexive as per JLS - overrider != overridee && - - // we don't care if overridee is static, though that wouldn't - // compile - !overrider.isStatic() && - - // overrider, whose declaring type is the origin, must be - // in a subtype of overridee's type - env.jctypes.asSuper(origin.type, overridee.owner) != null && - - // check access and signatures; don't check return types - overrider.overrides(overridee, origin, env.jctypes, false); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/util/SourcePositionImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/util/SourcePositionImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.util; - - -import java.io.File; -import javax.tools.JavaFileObject; - -import com.sun.mirror.util.SourcePosition; -import com.sun.tools.javac.util.Position; - - -/** - * Implementation of SourcePosition - */ -@SuppressWarnings("deprecation") -public class SourcePositionImpl implements SourcePosition { - - private JavaFileObject sourcefile; - private int pos; // file position, in javac's internal format - private Position.LineMap linemap; - - - public SourcePositionImpl(JavaFileObject sourcefile, int pos, Position.LineMap linemap) { - this.sourcefile = sourcefile; - this.pos = pos; - this.linemap = linemap; - assert sourcefile != null; - assert linemap != null; - } - - public int getJavacPosition() { - return pos; - } - - public JavaFileObject getSource() { - return sourcefile; - } - - /** - * Returns a string representation of this position in the - * form "sourcefile:line", or "sourcefile" if no line number is available. - */ - public String toString() { - int ln = line(); - return (ln == Position.NOPOS) - ? sourcefile.getName() - : sourcefile.getName() + ":" + ln; - } - - /** - * {@inheritDoc} - */ - public File file() { - return new File(sourcefile.toUri()); - } - - /** - * {@inheritDoc} - */ - public int line() { - return linemap.getLineNumber(pos); - } - - /** - * {@inheritDoc} - */ - public int column() { - return linemap.getColumnNumber(pos); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/mirror/util/TypesImpl.java --- a/src/share/classes/com/sun/tools/apt/mirror/util/TypesImpl.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.util; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.Types; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.apt.mirror.declaration.*; -import com.sun.tools.apt.mirror.type.TypeMirrorImpl; -import com.sun.tools.javac.code.BoundKind; -import com.sun.tools.javac.code.Type; -import com.sun.tools.javac.code.Symbol.ClassSymbol; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.ListBuffer; - - -/** - * Implementation of Types utility methods for annotation processors - */ -@SuppressWarnings("deprecation") -public class TypesImpl implements Types { - - private final AptEnv env; - - - private static final Context.Key typesKey = - new Context.Key(); - - public static Types instance(Context context) { - Types instance = context.get(typesKey); - if (instance == null) { - instance = new TypesImpl(context); - } - return instance; - } - - private TypesImpl(Context context) { - context.put(typesKey, this); - env = AptEnv.instance(context); - } - - - /** - * {@inheritDoc} - */ - public boolean isSubtype(TypeMirror t1, TypeMirror t2) { - return env.jctypes.isSubtype(((TypeMirrorImpl) t1).type, - ((TypeMirrorImpl) t2).type); - } - - /** - * {@inheritDoc} - */ - public boolean isAssignable(TypeMirror t1, TypeMirror t2) { - return env.jctypes.isAssignable(((TypeMirrorImpl) t1).type, - ((TypeMirrorImpl) t2).type); - } - - /** - * {@inheritDoc} - */ - public TypeMirror getErasure(TypeMirror t) { - return env.typeMaker.getType( - env.jctypes.erasure(((TypeMirrorImpl) t).type)); - } - - /** - * {@inheritDoc} - */ - public PrimitiveType getPrimitiveType(PrimitiveType.Kind kind) { - Type prim = null; - switch (kind) { - case BOOLEAN: prim = env.symtab.booleanType; break; - case BYTE: prim = env.symtab.byteType; break; - case SHORT: prim = env.symtab.shortType; break; - case INT: prim = env.symtab.intType; break; - case LONG: prim = env.symtab.longType; break; - case CHAR: prim = env.symtab.charType; break; - case FLOAT: prim = env.symtab.floatType; break; - case DOUBLE: prim = env.symtab.doubleType; break; - default: assert false; - } - return (PrimitiveType) env.typeMaker.getType(prim); - } - - /** - * {@inheritDoc} - */ - public VoidType getVoidType() { - return (VoidType) env.typeMaker.getType(env.symtab.voidType); - } - - /** - * {@inheritDoc} - */ - public ArrayType getArrayType(TypeMirror componentType) { - if (componentType instanceof VoidType) { - throw new IllegalArgumentException("void"); - } - return (ArrayType) env.typeMaker.getType( - new Type.ArrayType(((TypeMirrorImpl) componentType).type, - env.symtab.arrayClass)); - } - - /** - * {@inheritDoc} - */ - public TypeVariable getTypeVariable(TypeParameterDeclaration tparam) { - return (TypeVariable) env.typeMaker.getType( - ((DeclarationImpl) tparam).sym.type); - } - - /** - * {@inheritDoc} - */ - public WildcardType getWildcardType(Collection upperBounds, - Collection lowerBounds) { - BoundKind kind; - Type bound; - int uppers = upperBounds.size(); - int downers = lowerBounds.size(); - - if (uppers + downers > 1) { - throw new IllegalArgumentException("Multiple bounds not allowed"); - - } else if (uppers + downers == 0) { - kind = BoundKind.UNBOUND; - bound = env.symtab.objectType; - - } else if (uppers == 1) { - assert downers == 0; - kind = BoundKind.EXTENDS; - bound = ((TypeMirrorImpl) upperBounds.iterator().next()).type; - - } else { - assert uppers == 0 && downers == 1; - kind = BoundKind.SUPER; - bound = ((TypeMirrorImpl) lowerBounds.iterator().next()).type; - } - - if (bound instanceof Type.WildcardType) - throw new IllegalArgumentException(bound.toString()); - - return (WildcardType) env.typeMaker.getType( - new Type.WildcardType(bound, kind, env.symtab.boundClass)); - } - - /** - * {@inheritDoc} - */ - public DeclaredType getDeclaredType(TypeDeclaration decl, - TypeMirror... typeArgs) { - ClassSymbol sym = ((TypeDeclarationImpl) decl).sym; - - if (typeArgs.length == 0) - return (DeclaredType) env.typeMaker.getType( - env.jctypes.erasure(sym.type)); - if (sym.type.getEnclosingType().isParameterized()) - throw new IllegalArgumentException(decl.toString()); - - return getDeclaredType(sym.type.getEnclosingType(), sym, typeArgs); - } - - /** - * {@inheritDoc} - */ - public DeclaredType getDeclaredType(DeclaredType containing, - TypeDeclaration decl, - TypeMirror... typeArgs) { - if (containing == null) - return getDeclaredType(decl, typeArgs); - - ClassSymbol sym = ((TypeDeclarationImpl) decl).sym; - Type outer = ((TypeMirrorImpl) containing).type; - - if (outer.tsym != sym.owner.enclClass()) - throw new IllegalArgumentException(containing.toString()); - if (!outer.isParameterized()) - return getDeclaredType(decl, typeArgs); - - return getDeclaredType(outer, sym, typeArgs); - } - - private DeclaredType getDeclaredType(Type outer, - ClassSymbol sym, - TypeMirror... typeArgs) { - if (typeArgs.length != sym.type.getTypeArguments().length()) - throw new IllegalArgumentException( - "Incorrect number of type arguments"); - - ListBuffer targs = new ListBuffer(); - for (TypeMirror t : typeArgs) { - if (!(t instanceof ReferenceType || t instanceof WildcardType)) - throw new IllegalArgumentException(t.toString()); - targs.append(((TypeMirrorImpl) t).type); - } - //### Need a way to check that type args match formals. - - return (DeclaredType) env.typeMaker.getType( - new Type.ClassType(outer, targs.toList(), sym)); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/resources/apt.properties --- a/src/share/classes/com/sun/tools/apt/resources/apt.properties Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,184 +0,0 @@ -# -# Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -apt.msg.usage.header=\ -Usage: {0} \n\ -where apt options include: - -apt.msg.usage.footer=\ -See javac -help for information on javac options. - -apt.msg.usage.nonstandard.footer=\ -These options are non-standard and subject to change without notice, \nas is the format of their output. - -apt.msg.bug=\ -An exception has occurred in apt ({0}). \ -Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) \ -after checking the Bug Parade for duplicates. \ -Include your program and the following diagnostic in your report. Thank you. - -## apt options - -apt.opt.A=\ - Options to pass to annotation processors -apt.opt.arg.class=\ - -apt.opt.arg.directory=\ - Specify where to place processor and javac generated class files -apt.opt.classpath=\ - Specify where to find user class files and annotation processor factories -apt.opt.d=\ - Specify where to place processor and javac generated class files -apt.opt.factory=\ - Name of AnnotationProcessorFactory to use; bypasses default discovery process -apt.opt.factorypath=\ - Specify where to find annotation processor factories -apt.opt.s=\ - Specify where to place processor generated source files -apt.opt.help=\ - Print a synopsis of standard options; use javac -help for more options -apt.opt.print=\ - Print out textual representation of specified types -apt.opt.nocompile=\ - Do not compile source files to class files -apt.opt.proc.flag=\ - [key[=value]] -apt.opt.version=\ - Version information -apt.opt.XListAnnotationTypes=\ - List found annotation types -apt.opt.XListDeclarations=\ - List specified and included declarations -apt.opt.XPrintAptRounds=\ - Print information about initial and recursive apt rounds -apt.opt.XPrintFactoryInfo=\ - Print information about which annotations a factory is asked to process -apt.opt.XClassesAsDecls=\ - Treat both class and source files as declarations to process - -## -## errors -## - -## All errors which do not refer to a particular line in the source code are -## preceded by this string. - -apt.err.error=\ - error:\u0020 - -apt.err.unsupported.source.version=\ - Source release {0} is not supported; use release 5 or earlier - -apt.err.unsupported.target.version=\ - Target release {0} is not supported; use release 5 or earlier - -apt.err.BadDeclaration=\ - Bad declaration created for annotation type {0} - -apt.err.CantFindClass=\ - Could not find class file for {0} - -apt.err.DeclarationCreation=\ - Could not create declaration for annotation type {0} - -# Print an error from the Messager -apt.err.Messager=\ - {0} - -## -## miscellaneous strings -## - -apt.misc.Deprecation=\ - \nwarning:\u0020The apt tool and its associated API are planned to be\n\ - removed in the next major JDK release. These features have been\n\ - superseded by javac and the standardized annotation processing API,\n\ - javax.annotation.processing and javax.lang.model. Users are\n\ - recommended to migrate to the annotation processing features of\n\ - javac; see the javac man page for more information.\n - -apt.misc.Problem=\ - Problem encountered during annotation processing; \nsee stacktrace below for more information. - -apt.misc.SunMiscService=\ - Error finding annotation processor factories; \ncheck META-INF/services information. - -# Print a notice from the Messager -apt.note.Messager=\ - {0} - -## -## warnings -## - -## All warning messages are preceded by the following string. -apt.warn.warning=\ - warning:\u0020 - -apt.warn.AnnotationsWithoutProcessors=\ - Annotation types without processors: {0} - -apt.warn.BadFactory=\ - Bad annotation processor factory: {0} - -apt.warn.BadParentDirectory=\ - Failed to create some parent directory of {0} - -apt.warn.FactoryCantInstantiate=\ - Could not instantiate an instance of factory ''{0}''. - -apt.warn.FactoryWrongType=\ - Specified factory, ''{0}'', is not an AnnotationProcessorFactory. - -apt.warn.FactoryNotFound=\ - Specified AnnotationProcessorFactory, ''{0}'', not found on search path. - -apt.warn.FileReopening=\ - Attempt to create ''{0}'' multiple times - -apt.warn.IllegalFileName=\ - Cannot create file for illegal name ''{0}''. - -apt.warn.MalformedSupportedString=\ - Malformed string for annotation support, ''{0}'', returned by factory. - -apt.warn.NoNewFilesAfterRound=\ - Cannot create file ''{0}'' after a round has ended. - -# Print a warning from the Messager -apt.warn.Messager=\ - {0} - -apt.warn.NoAnnotationProcessors=\ - No annotation processors found but annotations present. - -apt.warn.NullProcessor=\ - Factory {0} returned null for an annotation processor. - -apt.warn.CorrespondingClassFile=\ - A class file corresponding to source file ''{0}'' has already been created. - -apt.warn.CorrespondingSourceFile=\ - A source file corresponding to class file ''{0}'' has already been created. diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/resources/apt_ja.properties --- a/src/share/classes/com/sun/tools/apt/resources/apt_ja.properties Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -# -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -apt.msg.usage.header=\u4F7F\u7528\u65B9\u6CD5: {0} \n\u6B21\u306Eapt\u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u3042\u308A\u307E\u3059: - -apt.msg.usage.footer=javac\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u3064\u3044\u3066\u306F\u3001javac -help\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002 - -apt.msg.usage.nonstandard.footer=\u3053\u308C\u3089\u306F\u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3042\u308A\u3001\u8868\u793A\u5F62\u5F0F\u4E88\u544A\u306A\u3057\u306B\u5909\u66F4\u3055\u308C\u308B\n\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002 - -apt.msg.bug=\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Parade\u306B\u540C\u3058\u30D0\u30B0\u304C\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3044\u3053\u3068\u3092\u3054\u78BA\u8A8D\u306E\u4E0A\u3001Java Developer Connection(http://java.sun.com/webapps/bugreport)\u3067\u30D0\u30B0\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 - -## apt options - -apt.opt.A=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306B\u6E21\u3055\u308C\u308B\u30AA\u30D7\u30B7\u30E7\u30F3 -apt.opt.arg.class= -apt.opt.arg.directory=\u30D7\u30ED\u30BB\u30C3\u30B5\u304A\u3088\u3073javac\u304C\u751F\u6210\u3057\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B -apt.opt.classpath=\u30E6\u30FC\u30B6\u30FC\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304A\u3088\u3073\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B -apt.opt.d=\u30D7\u30ED\u30BB\u30C3\u30B5\u304A\u3088\u3073javac\u304C\u751F\u6210\u3057\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B -apt.opt.factory=\u4F7F\u7528\u3059\u308BAnnotationProcessorFactory\u306E\u540D\u524D\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u691C\u51FA\u51E6\u7406\u3092\u30D0\u30A4\u30D1\u30B9 -apt.opt.factorypath=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u306E\u691C\u7D22\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B -apt.opt.s=\u30D7\u30ED\u30BB\u30C3\u30B5\u304C\u751F\u6210\u3057\u305F\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B -apt.opt.help=\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u6982\u8981\u3092\u51FA\u529B\u3059\u308B\u3002\u8A73\u7D30\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u3064\u3044\u3066\u306Fjavac -help\u3092\u53C2\u7167 -apt.opt.print=\u6307\u5B9A\u3057\u305F\u578B\u306E\u30C6\u30AD\u30B9\u30C8\u8868\u793A\u3092\u51FA\u529B\u3059\u308B -apt.opt.nocompile=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306B\u30B3\u30F3\u30D1\u30A4\u30EB\u3057\u306A\u3044 -apt.opt.proc.flag=[key[=value]] -apt.opt.version=\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831 -apt.opt.XListAnnotationTypes=\u898B\u3064\u304B\u3063\u305F\u6CE8\u91C8\u578B\u3092\u30EA\u30B9\u30C8\u3059\u308B -apt.opt.XListDeclarations=\u6307\u5B9A\u3055\u308C\u305F\u5BA3\u8A00\u304A\u3088\u3073\u30A4\u30F3\u30AF\u30EB\u30FC\u30C9\u3055\u308C\u305F\u5BA3\u8A00\u3092\u30EA\u30B9\u30C8\u3059\u308B -apt.opt.XPrintAptRounds=\u521D\u671F\u304A\u3088\u3073\u518D\u5E30apt\u5F80\u5FA9\u306B\u3064\u3044\u3066\u306E\u60C5\u5831\u3092\u5370\u5237\u3059\u308B -apt.opt.XPrintFactoryInfo=\u30D5\u30A1\u30AF\u30C8\u30EA\u304C\u51E6\u7406\u3092\u4F9D\u983C\u3055\u308C\u308B\u6CE8\u91C8\u306B\u3064\u3044\u3066\u306E\u60C5\u5831\u3092\u5370\u5237\u3059\u308B -apt.opt.XClassesAsDecls=\u30AF\u30E9\u30B9\u3068\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u4E21\u65B9\u3068\u3082\u51E6\u7406\u3059\u308B\u5BA3\u8A00\u3068\u3057\u3066\u51E6\u7406 - -## -## errors -## - -## All errors which do not refer to a particular line in the source code are -## preceded by this string. - -apt.err.error=\u30A8\u30E9\u30FC:\u0020 - -apt.err.unsupported.source.version=\u30BD\u30FC\u30B9\u30FB\u30EA\u30EA\u30FC\u30B9{0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u30EA\u30EA\u30FC\u30B95\u4EE5\u524D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044 - -apt.err.unsupported.target.version=\u30BF\u30FC\u30B2\u30C3\u30C8\u30FB\u30EA\u30EA\u30FC\u30B9{0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u30EA\u30EA\u30FC\u30B95\u4EE5\u524D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044 - -apt.err.BadDeclaration=\u6CE8\u91C8\u578B{0}\u7528\u306B\u4F5C\u6210\u3055\u308C\u305F\u7121\u52B9\u306A\u5BA3\u8A00\u3067\u3059 - -apt.err.CantFindClass={0}\u306E\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 - -apt.err.DeclarationCreation=\u6CE8\u91C8\u578B{0}\u7528\u306B\u5BA3\u8A00\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F - -# Print an error from the Messager -apt.err.Messager={0} - -## -## miscellaneous strings -## - -apt.misc.Deprecation=\n\u8B66\u544A: apt\u30C4\u30FC\u30EB\u3068\u30C4\u30FC\u30EB\u306B\u95A2\u9023\u4ED8\u3051\u3089\u308C\u305FAPI\u306F\u3001\u6B21\u56DE\u306EJDK\n\u30E1\u30B8\u30E3\u30FC\u30FB\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u4E88\u5B9A\u3067\u3059\u3002\u3053\u308C\u3089\u306E\u6A5F\u80FD\u306Fjavac\u304A\u3088\u3073\n\u6A19\u6E96\u5316\u3055\u308C\u305F\u6CE8\u91C8\u51E6\u7406API\u306Ejavax.annotation.processing\u304A\u3088\u3073javax.lang.model\n\u306B\u3088\u3063\u3066\u7F6E\u304D\u63DB\u3048\u3089\u308C\u307E\u3057\u305F\u3002\u30E6\u30FC\u30B6\u30FC\u306Fjavac\u306E\u6CE8\u91C8\u51E6\u7406\u6A5F\u80FD\u306B\n\u79FB\u884C\u3059\u308B\u3053\u3068\u3092\u304A\u85A6\u3081\u3057\u307E\u3059\u3002\n\u8A73\u7D30\u306F\u3001javac man\u30DA\u30FC\u30B8\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n - -apt.misc.Problem=\u6CE8\u91C8\u51E6\u7406\u4E2D\u306B\u554F\u984C\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u3001\u4E0B\u8A18\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002 - -apt.misc.SunMiscService=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u306E\u691C\u7D22\u30A8\u30E9\u30FC\u3067\u3059\u3002\nMETA-INF/services\u5185\u306E\u60C5\u5831\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 - -# Print a notice from the Messager -apt.note.Messager={0} - -## -## warnings -## - -## All warning messages are preceded by the following string. -apt.warn.warning=\u8B66\u544A: - -apt.warn.AnnotationsWithoutProcessors=\u30D7\u30ED\u30BB\u30C3\u30B5\u306A\u3057\u306E\u6CE8\u91C8\u578B\u3067\u3059: {0} - -apt.warn.BadFactory=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u304C\u7121\u52B9\u3067\u3059: {0} - -apt.warn.BadParentDirectory={0}\u306E\u3044\u304F\u3064\u304B\u306E\u89AA\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u4F5C\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F - -apt.warn.FactoryCantInstantiate=\u30D5\u30A1\u30AF\u30C8\u30EA''{0}''\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3092\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002 - -apt.warn.FactoryWrongType=\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30AF\u30C8\u30EA''{0}''\u306FAnnotationProcessorFactory\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002 - -apt.warn.FactoryNotFound=\u6307\u5B9A\u3057\u305FAnnotationProcessorFactory ''{0}''\u306F\u691C\u7D22\u30D1\u30B9\u3067\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002 - -apt.warn.FileReopening=''{0}''\u3092\u8907\u6570\u56DE\u4F5C\u6210\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307E\u3059 - -apt.warn.IllegalFileName=\u7121\u52B9\u306A\u540D\u524D''{0}''\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002 - -apt.warn.MalformedSupportedString=\u30D5\u30A1\u30AF\u30C8\u30EA\u304C\u8FD4\u3057\u305F\u6CE8\u91C8\u30B5\u30DD\u30FC\u30C8''{0}''\u306E\u6587\u5B57\u5217\u304C\u4E0D\u6B63\u3067\u3059\u3002 - -apt.warn.NoNewFilesAfterRound=\u5F80\u5FA9\u306E\u7D42\u4E86\u5F8C\u306B\u30D5\u30A1\u30A4\u30EB''{0}''\u3092\u4F5C\u6210\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002 - -# Print a warning from the Messager -apt.warn.Messager={0} - -apt.warn.NoAnnotationProcessors=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u304C\u3001\u6CE8\u91C8\u306F\u5B58\u5728\u3057\u307E\u3059\u3002 - -apt.warn.NullProcessor=\u30D5\u30A1\u30AF\u30C8\u30EA{0}\u304C\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306Bnull\u3092\u8FD4\u3057\u307E\u3057\u305F\u3002 - -apt.warn.CorrespondingClassFile=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB''{0}''\u306B\u5BFE\u5FDC\u3059\u308B\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306F\u3059\u3067\u306B\u4F5C\u6210\u3055\u308C\u3066\u3044\u307E\u3059\u3002 - -apt.warn.CorrespondingSourceFile=\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB''{0}''\u306B\u5BFE\u5FDC\u3059\u308B\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306F\u3059\u3067\u306B\u4F5C\u6210\u3055\u308C\u3066\u3044\u307E\u3059\u3002 diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/resources/apt_zh_CN.properties --- a/src/share/classes/com/sun/tools/apt/resources/apt_zh_CN.properties Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -# -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -apt.msg.usage.header=\u7528\u6CD5: {0} \n\u5176\u4E2D, apt \u9009\u9879\u5305\u62EC: - -apt.msg.usage.footer=\u6709\u5173 javac \u9009\u9879\u7684\u4FE1\u606F, \u8BF7\u53C2\u9605 javac -help\u3002 - -apt.msg.usage.nonstandard.footer=\u8FD9\u4E9B\u9009\u9879\u53CA\u5176\u8F93\u51FA\u683C\u5F0F\u90FD\u4E0D\u662F\u6807\u51C6\u7684, \n\u5982\u6709\u66F4\u6539, \u6055\u4E0D\u53E6\u884C\u901A\u77E5\u3002 - -apt.msg.bug=apt ({0}) \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002 \u5982\u679C\u5728 Bug Parade \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u5728 Java Developer Connection (http://java.sun.com/webapps/bugreport) \u4E2D\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 - -## apt options - -apt.opt.A=\u4F20\u9012\u7ED9\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u7684\u9009\u9879 -apt.opt.arg.class=<\u7C7B> -apt.opt.arg.directory=\u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u548C javac \u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E -apt.opt.classpath=\u6307\u5B9A\u67E5\u627E\u7528\u6237\u7C7B\u6587\u4EF6\u548C\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u7684\u4F4D\u7F6E -apt.opt.d=\u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u548C javac \u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E -apt.opt.factory=\u8981\u4F7F\u7528\u7684 AnnotationProcessorFactory \u7684\u540D\u79F0; \u7ED5\u8FC7\u9ED8\u8BA4\u7684\u641C\u7D22\u8FDB\u7A0B -apt.opt.factorypath=\u6307\u5B9A\u67E5\u627E\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u7684\u4F4D\u7F6E -apt.opt.s=\u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u751F\u6210\u7684\u6E90\u6587\u4EF6\u7684\u4F4D\u7F6E -apt.opt.help=\u8F93\u51FA\u6807\u51C6\u9009\u9879\u7684\u63D0\u8981; \u4F7F\u7528 javac -help \u53EF\u4EE5\u5F97\u5230\u66F4\u591A\u9009\u9879 -apt.opt.print=\u8F93\u51FA\u6307\u5B9A\u7C7B\u578B\u7684\u6587\u672C\u8868\u793A -apt.opt.nocompile=\u8BF7\u52FF\u5C06\u6E90\u6587\u4EF6\u7F16\u8BD1\u4E3A\u7C7B\u6587\u4EF6 -apt.opt.proc.flag=[\u5173\u952E\u5B57[=\u503C]] -apt.opt.version=\u7248\u672C\u4FE1\u606F -apt.opt.XListAnnotationTypes=\u5217\u51FA\u627E\u5230\u7684\u6CE8\u91CA\u7C7B\u578B -apt.opt.XListDeclarations=\u5217\u51FA\u6307\u5B9A\u548C\u5305\u542B\u7684\u58F0\u660E -apt.opt.XPrintAptRounds=\u8F93\u51FA\u6709\u5173\u521D\u59CB\u548C\u9012\u5F52 apt \u5FAA\u73AF\u7684\u4FE1\u606F -apt.opt.XPrintFactoryInfo=\u8F93\u51FA\u6709\u5173\u8BF7\u6C42\u5DE5\u5382\u5904\u7406\u54EA\u4E9B\u6CE8\u91CA\u7684\u4FE1\u606F -apt.opt.XClassesAsDecls=\u5C06\u7C7B\u6587\u4EF6\u548C\u6E90\u6587\u4EF6\u90FD\u89C6\u4E3A\u8981\u5904\u7406\u7684\u58F0\u660E - -## -## errors -## - -## All errors which do not refer to a particular line in the source code are -## preceded by this string. - -apt.err.error=\u9519\u8BEF:\u0020 - -apt.err.unsupported.source.version=\u4E0D\u652F\u6301\u6E90\u53D1\u884C\u7248 {0}; \u8BF7\u4F7F\u7528\u53D1\u884C\u7248 5 \u6216\u65E9\u671F\u53D1\u884C\u7248 - -apt.err.unsupported.target.version=\u4E0D\u652F\u6301\u76EE\u6807\u53D1\u884C\u7248 {0}; \u8BF7\u4F7F\u7528\u53D1\u884C\u7248 5 \u6216\u65E9\u671F\u53D1\u884C\u7248 - -apt.err.BadDeclaration=\u4E3A\u6CE8\u91CA\u7C7B\u578B{0}\u521B\u5EFA\u7684\u58F0\u660E\u51FA\u73B0\u9519\u8BEF - -apt.err.CantFindClass=\u627E\u4E0D\u5230{0}\u7684\u7C7B\u6587\u4EF6 - -apt.err.DeclarationCreation=\u65E0\u6CD5\u4E3A\u6CE8\u91CA\u7C7B\u578B{0}\u521B\u5EFA\u58F0\u660E - -# Print an error from the Messager -apt.err.Messager={0} - -## -## miscellaneous strings -## - -apt.misc.Deprecation=\n\u8B66\u544A:\u0020\u5DF2\u8BA1\u5212\u5728\u4E0B\u4E00\u4E2A JDK \u4E3B\u53D1\u884C\u7248\u4E2D\n\u5220\u9664 apt \u5DE5\u5177\u53CA\u5176\u5173\u8054\u7684 API\u3002\u8FD9\u4E9B\u529F\u80FD\n\u5DF2\u88AB javac \u548C\u6807\u51C6\u6CE8\u91CA\u5904\u7406 API,\njavax.annotation.processing \u548C javax.lang.model \u53D6\u4EE3\u3002\u5EFA\u8BAE\u7528\u6237\n\u79FB\u690D\u5230 javac \u7684\u6CE8\u91CA\u5904\u7406\u529F\u80FD;\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605 javac \u5E2E\u52A9\u9875\u3002\n - -apt.misc.Problem=\u6CE8\u91CA\u5904\u7406\u8FC7\u7A0B\u4E2D\u9047\u5230\u95EE\u9898; \n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605\u4E0B\u9762\u7684\u5806\u6808\u8DDF\u8E2A\u3002 - -apt.misc.SunMiscService=\u67E5\u627E\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u65F6\u51FA\u9519; \n\u8BF7\u67E5\u770B META-INF/\u670D\u52A1\u4FE1\u606F\u3002 - -# Print a notice from the Messager -apt.note.Messager={0} - -## -## warnings -## - -## All warning messages are preceded by the following string. -apt.warn.warning=\u8B66\u544A:\u0020 - -apt.warn.AnnotationsWithoutProcessors=\u4E0D\u5E26\u5904\u7406\u7A0B\u5E8F\u7684\u6CE8\u91CA\u7C7B\u578B: {0} - -apt.warn.BadFactory=\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u51FA\u73B0\u9519\u8BEF: {0} - -apt.warn.BadParentDirectory=\u65E0\u6CD5\u521B\u5EFA{0}\u7684\u67D0\u4E9B\u7236\u76EE\u5F55 - -apt.warn.FactoryCantInstantiate=\u65E0\u6CD5\u5B9E\u4F8B\u5316\u5DE5\u5382 ''{0}'' \u7684\u5B9E\u4F8B\u3002 - -apt.warn.FactoryWrongType=\u6307\u5B9A\u7684\u5DE5\u5382 ''{0}'' \u4E0D\u662F AnnotationProcessorFactory\u3002 - -apt.warn.FactoryNotFound=\u5728\u641C\u7D22\u8DEF\u5F84\u4E2D\u627E\u4E0D\u5230\u6307\u5B9A\u7684 AnnotationProcessorFactory ''{0}''\u3002 - -apt.warn.FileReopening=\u5C1D\u8BD5\u591A\u6B21\u521B\u5EFA ''{0}'' - -apt.warn.IllegalFileName=\u65E0\u6CD5\u521B\u5EFA\u5E26\u6709\u975E\u6CD5\u540D\u79F0 ''{0}'' \u7684\u6587\u4EF6\u3002 - -apt.warn.MalformedSupportedString=\u5DE5\u5382\u8FD4\u56DE\u683C\u5F0F\u9519\u8BEF\u7684\u6CE8\u91CA\u652F\u6301\u5B57\u7B26\u4E32 ''{0}''\u3002 - -apt.warn.NoNewFilesAfterRound=\u5FAA\u73AF\u7ED3\u675F\u540E\u65E0\u6CD5\u521B\u5EFA\u6587\u4EF6 ''{0}''\u3002 - -# Print a warning from the Messager -apt.warn.Messager={0} - -apt.warn.NoAnnotationProcessors=\u627E\u4E0D\u5230\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F, \u4F46\u5B58\u5728\u6CE8\u91CA\u3002 - -apt.warn.NullProcessor=\u5BF9\u4E8E\u67D0\u4E2A\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F, \u5DE5\u5382{0}\u8FD4\u56DE\u7684\u503C\u4E3A\u7A7A\u503C\u3002 - -apt.warn.CorrespondingClassFile=\u5DF2\u521B\u5EFA\u4E0E\u6E90\u6587\u4EF6 ''{0}'' \u76F8\u5BF9\u5E94\u7684\u7C7B\u6587\u4EF6\u3002 - -apt.warn.CorrespondingSourceFile=\u5DF2\u521B\u5EFA\u4E0E\u7C7B\u6587\u4EF6 ''{0}'' \u76F8\u5BF9\u5E94\u7684\u6E90\u6587\u4EF6\u3002 diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/apt/util/Bark.java --- a/src/share/classes/com/sun/tools/apt/util/Bark.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.util; - -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.JCDiagnostic; -import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; -import com.sun.tools.javac.util.Log; -import com.sun.tools.javac.util.JavacMessages; -import com.sun.tools.javac.util.Position; - -/** A subtype of Log for use in APT. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice. - */ -public class Bark extends Log { - /** The context key for the bark. */ - protected static final Context.Key barkKey = - new Context.Key(); - - /** - * Preregisters factories to create and use a Bark object for use as - * both a Log and a Bark. - */ - public static void preRegister(Context context) { - context.put(barkKey, new Context.Factory() { - public Bark make(Context c) { - return new Bark(c); - } - }); - context.put(Log.logKey, new Context.Factory() { - public Log make(Context c) { - return Bark.instance(c); - } - }); - } - - /** Get the Bark instance for this context. */ - public static Bark instance(Context context) { - Bark instance = context.get(barkKey); - if (instance == null) - instance = new Bark(context); - return instance; - } - - /** Specifies whether or not to ignore any diagnostics that are reported. - */ - private boolean ignoreDiagnostics; - - /** - * Factory for APT-specific diagnostics. - */ - private JCDiagnostic.Factory aptDiags; - - - /** - * Creates a Bark. - */ - protected Bark(Context context) { - super(context); // will register this object in context with Log.logKey - context.put(barkKey, this); - - // register additional resource bundle for APT messages. - JavacMessages aptMessages = JavacMessages.instance(context); - aptMessages.add("com.sun.tools.apt.resources.apt"); - aptDiags = new JCDiagnostic.Factory(aptMessages, "apt"); - - multipleErrors = true; - } - - /** - * Sets a flag indicating whether or not to ignore all diagnostics. - * When ignored, they are not reported to the output writers, not are they - * counted in the various counters. - * @param b If true, subsequent diagnostics will be ignored. - * @return the previous state of the flag - */ - public boolean setDiagnosticsIgnored(boolean b) { - boolean prev = ignoreDiagnostics; - ignoreDiagnostics = b; - return prev; - } - - /** - * Report a diagnostic if they are not currently being ignored. - */ - @Override - public void report(JCDiagnostic diagnostic) { - if (ignoreDiagnostics) - return; - - super.report(diagnostic); - } - - /** Report an error. - * @param key The key for the localized error message. - * @param args Fields of the error message. - */ - public void aptError(String key, Object... args) { - aptError(Position.NOPOS, key, args); - } - - /** Report an error, unless another error was already reported at same - * source position. - * @param pos The source position at which to report the error. - * @param key The key for the localized error message. - * @param args Fields of the error message. - */ - public void aptError(int pos, String key, Object ... args) { - report(aptDiags.error(source, new SimpleDiagnosticPosition(pos), key, args)); - } - - /** Report a warning, unless suppressed by the -nowarn option or the - * maximum number of warnings has been reached. - * @param key The key for the localized warning message. - * @param args Fields of the warning message. - */ - public void aptWarning(String key, Object... args) { - aptWarning(Position.NOPOS, key, args); - } - - /** Report a warning, unless suppressed by the -nowarn option or the - * maximum number of warnings has been reached. - * @param pos The source position at which to report the warning. - * @param key The key for the localized warning message. - * @param args Fields of the warning message. - */ - public void aptWarning(int pos, String key, Object ... args) { - report(aptDiags.warning(source, new SimpleDiagnosticPosition(pos), key, args)); - } - - /** Report a note, unless suppressed by the -nowarn option. - * @param key The key for the localized note message. - * @param args Fields of the note message. - */ - public void aptNote(String key, Object... args) { - aptNote(Position.NOPOS, key, args); - } - - /** Report a note, unless suppressed by the -nowarn option. - * @param pos The source position at which to report the note. - * @param key The key for the localized note message. - * @param args Fields of the note message. - */ - public void aptNote(int pos, String key, Object ... args) { - report(aptDiags.note(source, new SimpleDiagnosticPosition(pos), key, args)); - } -} diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties --- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Mon Jul 11 22:31:52 2011 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Tue May 29 00:27:58 2012 +0100 @@ -216,6 +216,7 @@ doclet.Same_package_name_used=Package name format used twice: {0} doclet.Serialization.Excluded_Class=Non-transient field {1} uses excluded class {0}. doclet.Serialization.Nonexcluded_Class=Non-transient field {1} uses hidden, non-included class {0}. +doclet.exception_encountered=Exception encountered while processing {1}\n{0} doclet.usage=Provided by Standard doclet:\n\ -d Destination directory for output files\n\ -use Create class and package usage pages\n\ diff -r 8caec3672381 -r 24540bbb4135 src/share/classes/com/sun/tools/doclets/package.html --- a/src/share/classes/com/sun/tools/doclets/package.html Mon Jul 11 22:31:52 2011 +0100 +++ b/src/share/classes/com/sun/tools/doclets/package.html Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ - - - - -Herein lieth the package comment. -An HTML file it be, and wonderous to behold. - - - diff -r 8caec3672381 -r 24540bbb4135 test/tools/apt/mirror/type/AnnoTyp.java --- a/test/tools/apt/mirror/type/AnnoTyp.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * @test - * @bug 4853450 - * @summary AnnotationType tests - * @library ../../lib - * @compile -source 1.5 AnnoTyp.java - * @run main/othervm AnnoTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class AnnoTyp extends Tester { - - public static void main(String[] args) { - (new AnnoTyp()).run(); - } - - - // Declaration used by tests - - @interface AT { - } - - - private AnnotationType at; // an annotation type - - @AT - protected void init() { - at = getAnno("init", "AnnoTyp.AT").getAnnotationType(); - } - - - // TypeMirror methods - - @Test(result="anno type") - Collection accept() { - final Collection res = new ArrayList(); - - at.accept(new SimpleTypeVisitor() { - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitClassType(ClassType t) { - res.add("class"); - } - public void visitInterfaceType(InterfaceType t) { - res.add("interface"); - } - public void visitAnnotationType(AnnotationType t) { - res.add("anno type"); - } - }); - return res; - } - - - // AnnotationType method - - @Test(result="AnnoTyp.AT") - AnnotationTypeDeclaration getDeclaration() { - return at.getDeclaration(); - } -} diff -r 8caec3672381 -r 24540bbb4135 test/tools/apt/mirror/type/ArrayTyp.java --- a/test/tools/apt/mirror/type/ArrayTyp.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * @test - * @bug 4853450 5009357 - * @summary ArrayType tests - * @library ../../lib - * @compile -source 1.5 ArrayTyp.java - * @run main/othervm ArrayTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class ArrayTyp extends Tester { - - public static void main(String[] args) { - (new ArrayTyp()).run(); - } - - - // Declaration used by tests - - private boolean[] bs; - private String[][] bss; - - - private ArrayType arr; // an array type - private ArrayType arrarr; // a multi-dimensional array type - - protected void init() { - arr = (ArrayType) getField("bs").getType(); - arrarr = (ArrayType) getField("bss").getType(); - } - - - // TypeMirror methods - - @Test(result="array") - Collection accept() { - final Collection res = new ArrayList(); - - arr.accept(new SimpleTypeVisitor() { - public void visitTypeMirror(TypeMirror t) { - res.add("type"); - } - public void visitArrayType(ArrayType t) { - res.add("array"); - } - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - }); - return res; - } - - @Test(result="boolean[]") - String toStringTest() { - return arr.toString(); - } - - @Test(result="java.lang.String[][]") - String toStringTestMulti() { - return arrarr.toString(); - } - - - // ArrayType method - - @Test(result="boolean") - TypeMirror getComponentType() { - return (PrimitiveType) arr.getComponentType(); - } - - @Test(result="java.lang.String[]") - TypeMirror getComponentTypeMulti() { - return (ArrayType) arrarr.getComponentType(); - } -} diff -r 8caec3672381 -r 24540bbb4135 test/tools/apt/mirror/type/ClassTyp.java --- a/test/tools/apt/mirror/type/ClassTyp.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,240 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * @test - * @bug 4853450 5009360 5055963 - * @summary ClassType tests - * @library ../../lib - * @run main/othervm ClassTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class ClassTyp extends Tester { - - public static void main(String[] args) { - (new ClassTyp()).run(); - } - - - // Declarations used by tests - - static class C1 extends AbstractSet implements Set { - class C2 { - } - - static class C3 { - class C4 { - } - } - - public Iterator iterator() { - return null; - } - - public int size() { - return 0; - } - } - - - // Generate some class types to test. - private C1 f0; - private C1 f1; - private C1 f2; - private C1.C3 f3; - private C1.C2 f4; - private C1.C2 f5; - private C1 f6; - private C1.C3.C4 f7; - private static final int NUMTYPES = 8; - - // Type mirrors corresponding to the types of the above fields - private ClassType[] t = new ClassType[NUMTYPES]; - - // One more type: our own. - private ClassTyp me = this; - - - protected void init() { - for (int i = 0; i < t.length; i++) { - t[i] = (ClassType) getField("f"+i).getType(); - } - } - - - // TypeMirror methods - - @Test(result="class") - Collection accept() { - final Collection res = new ArrayList(); - - t[0].accept(new SimpleTypeVisitor() { - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitClassType(ClassType t) { - res.add("class"); - } - public void visitInterfaceType(InterfaceType t) { - res.add("interface"); - } - }); - return res; - } - - @Test(result="true") - boolean equals1() { - return t[0].equals(t[0]); - } - - @Test(result="false") - boolean equals2() { - return t[0].equals(t[1]); - } - - // Raw type is not same as type instantiated with unbounded type var. - @Test(result="false") - boolean equals3() { - return t[0].equals(t[2]); - } - - // C1 is same type as C1 - @Test(result="true") - boolean equals4() { - return t[0].equals(t[6]); - } - - @Test(result={ - "ClassTyp.C1", - "ClassTyp.C1", - "ClassTyp.C1", - "ClassTyp.C1.C3", - "ClassTyp.C1.C2", - "ClassTyp.C1.C2", - "ClassTyp.C1", - "ClassTyp.C1.C3.C4" - }, - ordered=true) - Collection toStringTests() { - Collection res = new ArrayList(); - for (ClassType c : t) { - res.add(c.toString()); - } - return res; - } - - - // DeclaredType methods - - @Test(result={"T1"}) - Collection getActualTypeArguments1() { - return t[0].getActualTypeArguments(); - } - - @Test(result={}) - Collection getActualTypeArguments2() { - return t[2].getActualTypeArguments(); - } - - @Test(result={"T2"}) - Collection getActualTypeArguments3() { - return t[3].getActualTypeArguments(); - } - - @Test(result="null") - DeclaredType getContainingType1() { - ClassType thisType = (ClassType) getField("me").getType(); - return thisType.getContainingType(); - } - - @Test(result="ClassTyp") - DeclaredType getContainingType2() { - return t[0].getContainingType(); - } - - @Test(result="ClassTyp.C1") - DeclaredType getContainingType3() { - return t[3].getContainingType(); - } - - @Test(result="ClassTyp.C1") - DeclaredType getContainingType4() { - return t[4].getContainingType(); - } - - @Test(result={"java.util.Set"}) - Collection getSuperinterfaces() { - return t[0].getSuperinterfaces(); - } - - - // ClassType methods - - @Test(result="ClassTyp.C1") - ClassDeclaration getDeclaration1() { - return t[0].getDeclaration(); - } - - @Test(result="ClassTyp.C1.C3") - ClassDeclaration getDeclaration2() { - return t[3].getDeclaration(); - } - - @Test(result="ClassTyp.C1.C2") - ClassDeclaration getDeclaration3a() { - return t[4].getDeclaration(); - } - - @Test(result="ClassTyp.C1.C2") - ClassDeclaration getDeclaration3b() { - return t[5].getDeclaration(); - } - - @Test(result="true") - boolean getDeclarationEq() { - return t[0].getDeclaration() == t[6].getDeclaration(); - } - - @Test(result="java.util.AbstractSet") - ClassType getSuperclass1() { - return t[0].getSuperclass(); - } - - @Test(result="java.lang.Object") - ClassType getSuperclass2() { - return t[4].getSuperclass(); - } - - @Test(result="null") - ClassType getSuperclassOfObject() { - return t[4].getSuperclass().getSuperclass(); - } -} diff -r 8caec3672381 -r 24540bbb4135 test/tools/apt/mirror/type/EnumTyp.java --- a/test/tools/apt/mirror/type/EnumTyp.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * @test - * @bug 4853450 - * @summary EnumType tests - * @library ../../lib - * @compile -source 1.5 EnumTyp.java - * @run main/othervm EnumTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class EnumTyp extends Tester { - - public static void main(String[] args) { - (new EnumTyp()).run(); - } - - - // Declarations used by tests - - enum Suit { - CIVIL, - CRIMINAL - } - - private Suit s; - - - private EnumType e; // an enum type - - protected void init() { - e = (EnumType) getField("s").getType(); - } - - - // TypeMirror methods - - @Test(result="enum") - Collection accept() { - final Collection res = new ArrayList(); - - e.accept(new SimpleTypeVisitor() { - public void visitTypeMirror(TypeMirror t) { - res.add("type"); - } - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitClassType(ClassType t) { - res.add("class"); - } - public void visitEnumType(EnumType t) { - res.add("enum"); - } - public void visitInterfaceType(InterfaceType t) { - res.add("interface"); - } - }); - return res; - } - - - // EnumType method - - @Test(result="EnumTyp.Suit") - EnumDeclaration getDeclaration() { - return e.getDeclaration(); - } -} diff -r 8caec3672381 -r 24540bbb4135 test/tools/apt/mirror/type/InterfaceTyp.java --- a/test/tools/apt/mirror/type/InterfaceTyp.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * @test - * @bug 4853450 5055963 - * @summary InterfaceType tests - * @library ../../lib - * @run main/othervm InterfaceTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class InterfaceTyp extends Tester { - - public static void main(String[] args) { - (new InterfaceTyp()).run(); - } - - - // Declarations used by tests - - interface I1 extends Set { - interface I2 { - } - } - - - // Generate some interface types to test - private I1 f0; - private I1 f1; - private I1 f2; - private I1.I2 f3; - private I1.I2 f4; - private I1 f5; - private I3 f6; - private static final int NUMTYPES = 7; - - // Type mirrors corresponding to the types of the above fields - private InterfaceType[] t = new InterfaceType[NUMTYPES]; - - protected void init() { - for (int i = 0; i < t.length; i++) { - t[i] = (InterfaceType) getField("f"+i).getType(); - } - } - - - // TypeMirror methods - - @Test(result="interface") - Collection accept() { - final Collection res = new ArrayList(); - - t[0].accept(new SimpleTypeVisitor() { - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitClassType(ClassType t) { - res.add("class"); - } - public void visitInterfaceType(InterfaceType t) { - res.add("interface"); - } - }); - return res; - } - - @Test(result="true") - boolean equals1() { - return t[0].equals(t[0]); - } - - @Test(result="false") - boolean equals2() { - return t[0].equals(t[1]); - } - - // Raw type is not same as type instantiated with unbounded type var. - @Test(result="false") - boolean equals3() { - return t[0].equals(t[2]); - } - - // I1 is same type as I1 - @Test(result="true") - boolean equals4() { - return t[0].equals(t[5]); - } - - @Test(result={ - "InterfaceTyp.I1", - "InterfaceTyp.I1", - "InterfaceTyp.I1", - "InterfaceTyp.I1.I2", - "InterfaceTyp.I1.I2", - "InterfaceTyp.I1", - "I3" - }, - ordered=true) - Collection toStringTests() { - Collection res = new ArrayList(); - for (InterfaceType i : t) { - res.add(i.toString()); - } - return res; - } - - - // DeclaredType methods - - @Test(result={"T1"}) - Collection getActualTypeArguments1() { - return t[0].getActualTypeArguments(); - } - - @Test(result={}) - Collection getActualTypeArguments2() { - return t[2].getActualTypeArguments(); - } - - @Test(result={"java.lang.String"}) - Collection getActualTypeArguments3() { - return t[3].getActualTypeArguments(); - } - - @Test(result="InterfaceTyp") - DeclaredType getContainingType1() { - return t[0].getContainingType(); - } - - @Test(result="InterfaceTyp.I1") - DeclaredType getContainingType2() { - return t[3].getContainingType(); - } - - @Test(result="null") - DeclaredType getContainingTypeTopLevel() { - return t[6].getContainingType(); - } - - @Test(result={"java.util.Set"}) - Collection getSuperinterfaces() { - return t[0].getSuperinterfaces(); - } - - - - // InterfaceType method - - @Test(result="InterfaceTyp.I1") - InterfaceDeclaration getDeclaration1() { - return t[0].getDeclaration(); - } - - @Test(result="InterfaceTyp.I1.I2") - InterfaceDeclaration getDeclaration2a() { - return t[3].getDeclaration(); - } - - @Test(result="InterfaceTyp.I1.I2") - InterfaceDeclaration getDeclaration2b() { - return t[4].getDeclaration(); - } - - @Test(result="true") - boolean getDeclarationCaching() { - return t[0].getDeclaration() == t[5].getDeclaration(); - } -} - - -// A top-level interface used by tests. - -interface I3 { -} diff -r 8caec3672381 -r 24540bbb4135 test/tools/apt/mirror/type/PrimitiveTyp.java --- a/test/tools/apt/mirror/type/PrimitiveTyp.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * @test - * @bug 4853450 - * @summary PrimitiveType tests - * @library ../../lib - * @compile -source 1.5 PrimitiveTyp.java - * @run main/othervm PrimitiveTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class PrimitiveTyp extends Tester { - - public static void main(String[] args) { - (new PrimitiveTyp()).run(); - } - - - // Declaration used by tests - - private boolean b; - - - private PrimitiveType prim; // a primitive type - - protected void init() { - prim = (PrimitiveType) getField("b").getType(); - } - - - // TypeMirror methods - - @Test(result="primitive") - Collection accept() { - final Collection res = new ArrayList(); - - prim.accept(new SimpleTypeVisitor() { - public void visitTypeMirror(TypeMirror t) { - res.add("type"); - } - public void visitPrimitiveType(PrimitiveType t) { - res.add("primitive"); - } - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - }); - return res; - } - - @Test(result="boolean") - String toStringTest() { - return prim.toString(); - } - - - // PrimitiveType method - - @Test(result="BOOLEAN") - PrimitiveType.Kind getKind() { - return prim.getKind(); - } -} diff -r 8caec3672381 -r 24540bbb4135 test/tools/apt/mirror/type/TypeVar.java --- a/test/tools/apt/mirror/type/TypeVar.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * @test - * @bug 4853450 - * @summary TypeVariable tests - * @library ../../lib - * @compile -source 1.5 TypeVar.java - * @run main/othervm TypeVar - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class TypeVar extends Tester { - - public static void main(String[] args) { - (new TypeVar()).run(); - } - - - // Declarations used by tests - - private T t; - private S s; - - - private TypeVariable tvT; // type variable T - private TypeVariable tvS; // type variable S - - protected void init() { - tvT = (TypeVariable) getField("t").getType(); - tvS = (TypeVariable) getField("s").getType(); - } - - - // TypeMirror methods - - @Test(result="type var") - Collection accept() { - final Collection res = new ArrayList(); - - tvT.accept(new SimpleTypeVisitor() { - public void visitTypeMirror(TypeMirror t) { - res.add("type"); - } - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitTypeVariable(TypeVariable t) { - res.add("type var"); - } - }); - return res; - } - - @Test(result="T") - String toStringTest1() { - return tvT.toString(); - } - - @Test(result="S") - String toStringTest2() { - return tvS.toString(); - } - - - // TypeVariable method - - @Test(result="S extends java.lang.Number & java.lang.Runnable") - TypeParameterDeclaration getDeclaration() { - return tvS.getDeclaration(); - } -} diff -r 8caec3672381 -r 24540bbb4135 test/tools/apt/mirror/type/WildcardTyp.java --- a/test/tools/apt/mirror/type/WildcardTyp.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * @test - * @bug 4853450 5009396 5010636 5031156 - * @summary WildcardType tests - * @library ../../lib - * @compile -source 1.5 WildcardTyp.java - * @run main/othervm WildcardTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class WildcardTyp extends Tester { - - public static void main(String[] args) { - (new WildcardTyp()).run(); - } - - - // Declarations to use for testing - - interface G { - } - - interface G1 { - } - - interface G2> { - } - - // Some wildcard types to test. - private G f0; // unbound - private G f1; // covariant - private G f2; // contravariant - private G f3; // - private G1 f4; // "true" upper bound is an intersection type - private G2 f5; // 'true" upper bound is a recursive F-bound and - // not expressible - private static final int NUMTYPES = 6; - - // Type mirrors corresponding to the wildcard types of the above fields - private WildcardType[] t = new WildcardType[NUMTYPES]; - - - protected void init() { - for (int i = 0; i < t.length; i++) { - DeclaredType type = (DeclaredType) getField("f"+i).getType(); - t[i] = (WildcardType) - type.getActualTypeArguments().iterator().next(); - } - } - - private WildcardType wildcardFor(String field) { - DeclaredType d = (DeclaredType) getField(field).getType(); - return (WildcardType) d.getActualTypeArguments().iterator().next(); - } - - - // TypeMirror methods - - @Test(result="wild thing") - Collection accept() { - final Collection res = new ArrayList(); - - t[0].accept(new SimpleTypeVisitor() { - public void visitTypeMirror(TypeMirror t) { - res.add("type"); - } - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitWildcardType(WildcardType t) { - res.add("wild thing"); - } - }); - return res; - } - - @Test(result={ - "?", - "? extends java.lang.Number", - "? super java.lang.Number", - "? extends java.lang.Object", - "?", - "?" - }, - ordered=true) - Collection toStringTests() { - Collection res = new ArrayList(); - for (WildcardType w : t) { - res.add(w.toString()); - } - return res; - } - - - // WildcardType methods - - @Test(result={ - "null", - "null", - "java.lang.Number", - "null", - "null", - "null" - }, - ordered=true) - Collection getLowerBounds() { - Collection res = new ArrayList(); - for (WildcardType w : t) { - Collection bounds = w.getLowerBounds(); - int num = bounds.size(); - if (num > 1) { - throw new AssertionError("Bounds abound"); - } - res.add((num > 0) ? bounds.iterator().next() : null); - } - return res; - } - - @Test(result={ - "null", - "java.lang.Number", - "null", - "java.lang.Object", - "null", - "null" - }, - ordered=true) - Collection getUpperBounds() { - Collection res = new ArrayList(); - for (WildcardType w : t) { - Collection bounds = w.getUpperBounds(); - int num = bounds.size(); - if (num > 1) { - throw new AssertionError("Bounds abound"); - } - res.add((num > 0) ? bounds.iterator().next() : null); - } - return res; - } -} diff -r 8caec3672381 -r 24540bbb4135 test/tools/apt/mirror/util/Overrides.java --- a/test/tools/apt/mirror/util/Overrides.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * @test - * @bug 5037165 - * @summary Test the Declarations.overrides method - * @library ../../lib - * @run main/othervm Overrides - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class Overrides extends Tester { - - public static void main(String[] args) { - (new Overrides()).run(); - } - - - // Declarations used by tests - - static class A { - void m1(int i) {}; // does not override itself - void m2(int i) {}; - static void m3(int i) {}; - } - - static class B extends A { - void m1(int j) {}; // overrides A.m1 - void m1(String i) {}; // does not override A.m1 - void m4(int i) {}; // does not override A.m1 - } - - static class C extends B { - void m1(int i) {}; // overrides A.m1 and B.m1 - void m2(int i) {}; // overrides A.m2 - } - - static class D extends A { - static void m3(int i) {}; // does not override A.m3 - } - - static class E { - void m1(int i) {}; // does not override A.m1 - } - - - - private Declarations decls; - - private TypeDeclaration A; - private TypeDeclaration B; - private TypeDeclaration C; - private TypeDeclaration D; - private TypeDeclaration E; - private MethodDeclaration Am1; - private MethodDeclaration Am2; - private MethodDeclaration Am3; - private MethodDeclaration Bm1; - private MethodDeclaration Bm1b; - private MethodDeclaration Bm4; - private MethodDeclaration Cm1; - private MethodDeclaration Cm2; - private MethodDeclaration Dm3; - private MethodDeclaration Em1; - - protected void init() { - decls = env.getDeclarationUtils(); - - A = env.getTypeDeclaration("Overrides.A"); - B = env.getTypeDeclaration("Overrides.B"); - C = env.getTypeDeclaration("Overrides.C"); - D = env.getTypeDeclaration("Overrides.D"); - E = env.getTypeDeclaration("Overrides.E"); - - Am1 = getMethod(A, "m1", "i"); - Am2 = getMethod(A, "m2", "i"); - Am3 = getMethod(A, "m3", "i"); - Bm1 = getMethod(B, "m1", "j"); - Bm1b = getMethod(B, "m1", "i"); - Bm4 = getMethod(B, "m4", "i"); - Cm1 = getMethod(C, "m1", "i"); - Cm2 = getMethod(C, "m2", "i"); - Dm3 = getMethod(D, "m3", "i"); - Em1 = getMethod(E, "m1", "i"); - } - - private MethodDeclaration getMethod(TypeDeclaration t, - String methodName, String paramName) { - for (MethodDeclaration m : t.getMethods()) { - if (methodName.equals(m.getSimpleName()) && - paramName.equals(m.getParameters().iterator().next() - .getSimpleName())) { - return m; - } - } - throw new AssertionError(); - } - - - // Declarations methods - - @Test(result={"false", - "true", - "false", - "false", - "true", - "true", - "true", - "false", - "false"}, - ordered=true) - List overrides() { - return Arrays.asList( - decls.overrides(Am1, Am1), - decls.overrides(Bm1, Am1), - decls.overrides(Bm1b,Am1), - decls.overrides(Bm4, Am1), - decls.overrides(Cm1, Am1), - decls.overrides(Cm1, Bm1), - decls.overrides(Cm2, Am2), - decls.overrides(Dm3, Am3), - decls.overrides(Em1, Am1)); - } -} diff -r 8caec3672381 -r 24540bbb4135 test/tools/apt/mirror/util/TypeCreation.java --- a/test/tools/apt/mirror/util/TypeCreation.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * @test - * @bug 5033381 - * @summary Test the type creation methods in Types. - * @library ../../lib - * @run main/othervm TypeCreation - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import static com.sun.mirror.type.PrimitiveType.Kind.*; - - -public class TypeCreation extends Tester { - - public static void main(String[] args) { - (new TypeCreation()).run(); - } - - - // Declarations used by tests - - class A { - } - - class O { - class I { - } - } - - - private Types types; - - private TypeDeclaration A; - private TypeDeclaration O; - private TypeDeclaration I; - - private DeclaredType AType; - - protected void init() { - types = env.getTypeUtils(); - A = env.getTypeDeclaration("TypeCreation.A"); - O = env.getTypeDeclaration("TypeCreation.O"); - I = env.getTypeDeclaration("TypeCreation.O.I"); - - AType = types.getDeclaredType(A); - } - - - @Test(result="boolean") - PrimitiveType getPrimitiveType() { - return types.getPrimitiveType(BOOLEAN); - } - - @Test(result="void") - VoidType getVoidType() { - return types.getVoidType(); - } - - @Test(result="boolean[]") - ArrayType getArrayType1() { - return types.getArrayType( - types.getPrimitiveType(BOOLEAN)); - } - - @Test(result="TypeCreation.A[]") - ArrayType getArrayType2() { - return types.getArrayType(AType); - } - - @Test(result="? extends TypeCreation.A") - WildcardType getWildcardType() { - Collection uppers = new ArrayList(); - Collection downers = new ArrayList(); - uppers.add(AType); - return types.getWildcardType(uppers, downers); - } - - @Test(result="TypeCreation.O") - DeclaredType getDeclaredType1() { - TypeDeclaration stringDecl = env.getTypeDeclaration("java.lang.String"); - DeclaredType stringType = types.getDeclaredType(stringDecl); - return types.getDeclaredType(O, stringType); - } - - @Test(result="TypeCreation.O.I") - DeclaredType getDeclaredType2() { - TypeDeclaration numDecl = env.getTypeDeclaration("java.lang.Number"); - DeclaredType numType = types.getDeclaredType(numDecl); - DeclaredType OType = getDeclaredType1(); - return types.getDeclaredType(OType, I, numType); - } -} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/4846262/Test.sh --- a/test/tools/javac/4846262/Test.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/4846262/Test.sh Tue May 29 00:27:58 2012 +0100 @@ -1,7 +1,7 @@ #!/bin/sh -f # -# Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux ) + SunOS | Linux | Darwin ) FS="/" ;; CYGWIN* ) @@ -71,7 +71,7 @@ diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out result=$? -if [ $result -eq o ] +if [ $result -eq 0 ] then echo "Passed" else diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/6302184/T6302184.sh --- a/test/tools/javac/6302184/T6302184.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/6302184/T6302184.sh Tue May 29 00:27:58 2012 +0100 @@ -41,7 +41,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux ) + SunOS | Linux | Darwin ) FS="/" ;; CYGWIN* ) diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/6304921/TestLog.java --- a/test/tools/javac/6304921/TestLog.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/6304921/TestLog.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import javax.tools.JavaFileObject; import javax.tools.SimpleJavaFileObject; import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.parser.EndPosTable; import com.sun.tools.javac.parser.Parser; import com.sun.tools.javac.parser.ParserFactory; import com.sun.tools.javac.tree.JCTree; @@ -97,9 +98,9 @@ } private static class LogTester extends TreeScanner { - LogTester(Log log, java.util.Map endPositions) { + LogTester(Log log, EndPosTable endPosTable) { this.log = log; - this.endPositions = endPositions; + this.endPosTable = endPosTable; } public void visitIf(JCTree.JCIf tree) { @@ -117,7 +118,7 @@ } private Log log; - private java.util.Map endPositions; + private EndPosTable endPosTable; } private static class StringJavaFileObject extends SimpleJavaFileObject { diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/6402516/CheckLocalElements.java --- a/test/tools/javac/6402516/CheckLocalElements.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/6402516/CheckLocalElements.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,7 +95,7 @@ return encl == null ? "" : encl.accept(qualNameVisitor, null); } - private ElementVisitor qualNameVisitor = new SimpleElementVisitor7() { + private ElementVisitor qualNameVisitor = new SimpleElementVisitor8() { protected String defaultAction(Element e, Void ignore) { return ""; } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/6410653/T6410653.java --- a/test/tools/javac/6410653/T6410653.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/6410653/T6410653.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ * @author Peter von der Ah\u00e9 */ -import java.lang.reflect.Method; +import java.lang.reflect.Field; import java.io.File; import java.io.ByteArrayOutputStream; import javax.tools.*; @@ -39,12 +39,13 @@ String source = new File(testSrc, "T6410653.java").getPath(); ClassLoader cl = ToolProvider.getSystemToolClassLoader(); Tool compiler = ToolProvider.getSystemJavaCompiler(); - Class main = Class.forName("com.sun.tools.javac.main.Main", true, cl); - Method useRawMessages = main.getMethod("useRawMessages", boolean.class); - useRawMessages.invoke(null, true); + Class log = Class.forName("com.sun.tools.javac.util.Log", true, cl); + Field useRawMessages = log.getDeclaredField("useRawMessages"); + useRawMessages.setAccessible(true); + useRawMessages.setBoolean(null, true); ByteArrayOutputStream out = new ByteArrayOutputStream(); compiler.run(null, null, out, "-d", source, source); - useRawMessages.invoke(null, false); + useRawMessages.setBoolean(null, false); if (!out.toString().equals(String.format("%s%n%s%n", "javac: javac.err.file.not.directory", "javac.msg.usage"))) { diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/6758789/T6758789b.out diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/6979683/TestCast6979683_BAD34.java.errlog --- a/test/tools/javac/6979683/TestCast6979683_BAD34.java.errlog Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/6979683/TestCast6979683_BAD34.java.errlog Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -TestCast6979683_BAD34.java:34:49: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Number, boolean +TestCast6979683_BAD34.java:34:49: compiler.err.prob.found.req: java.lang.Number, boolean 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/6979683/TestCast6979683_BAD35.java.errlog --- a/test/tools/javac/6979683/TestCast6979683_BAD35.java.errlog Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/6979683/TestCast6979683_BAD35.java.errlog Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -TestCast6979683_BAD35.java:35:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Number, int +TestCast6979683_BAD35.java:35:45: compiler.err.prob.found.req: java.lang.Number, int 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/6979683/TestCast6979683_BAD36.java.errlog --- a/test/tools/javac/6979683/TestCast6979683_BAD36.java.errlog Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/6979683/TestCast6979683_BAD36.java.errlog Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -TestCast6979683_BAD36.java:36:58: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Comparable, int +TestCast6979683_BAD36.java:36:58: compiler.err.prob.found.req: java.lang.Comparable, int 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/6979683/TestCast6979683_BAD37.java.errlog --- a/test/tools/javac/6979683/TestCast6979683_BAD37.java.errlog Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/6979683/TestCast6979683_BAD37.java.errlog Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -TestCast6979683_BAD37.java:37:61: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), java.lang.Comparable, int +TestCast6979683_BAD37.java:37:61: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: java.lang.Comparable, int) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/6979683/TestCast6979683_BAD38.java.errlog --- a/test/tools/javac/6979683/TestCast6979683_BAD38.java.errlog Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/6979683/TestCast6979683_BAD38.java.errlog Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -TestCast6979683_BAD38.java:38:62: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Comparable, float +TestCast6979683_BAD38.java:38:62: compiler.err.prob.found.req: java.lang.Comparable, float 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/6979683/TestCast6979683_BAD39.java.errlog --- a/test/tools/javac/6979683/TestCast6979683_BAD39.java.errlog Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/6979683/TestCast6979683_BAD39.java.errlog Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -TestCast6979683_BAD39.java:39:53: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), java.lang.Number, char +TestCast6979683_BAD39.java:39:53: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: java.lang.Number, char) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7003595/T7003595.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7003595/T7003595.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7003595 + * @summary IncompatibleClassChangeError with unreferenced local class with subclass + */ + +import com.sun.source.util.JavacTask; +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.InnerClasses_attribute; +import com.sun.tools.classfile.ConstantPool.*; +import com.sun.tools.javac.api.JavacTool; + +import java.io.File; +import java.net.URI; +import java.util.Arrays; +import java.util.ArrayList; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + + +public class T7003595 { + + /** global decls ***/ + + // Create a single file manager and reuse it for each compile to save time. + static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null); + + //statistics + static int checkCount = 0; + + enum ClassKind { + NESTED("static class #N { #B }", "$", true), + INNER("class #N { #B }", "$", false), + LOCAL_REF("void test() { class #N { #B }; new #N(); }", "$1", false), + LOCAL_NOREF("void test() { class #N { #B }; }", "$1", false), + ANON("void test() { new Object() { #B }; }", "$1", false), + NONE("", "", false); + + String memberInnerStr; + String sep; + boolean staticAllowed; + + private ClassKind(String memberInnerStr, String sep, boolean staticAllowed) { + this.memberInnerStr = memberInnerStr; + this.sep = sep; + this.staticAllowed = staticAllowed; + } + + String getSource(String className, String outerName, String nested) { + return memberInnerStr.replaceAll("#O", outerName). + replaceAll("#N", className).replaceAll("#B", nested); + } + + static String getClassfileName(String[] names, ClassKind[] outerKinds, int pos) { + System.out.println(" pos = " + pos + " kind = " + outerKinds[pos] + " sep = " + outerKinds[pos].sep); + String name = outerKinds[pos] != ANON ? + names[pos] : ""; + if (pos == 0) { + return "Test" + outerKinds[pos].sep + name; + } else { + String outerStr = getClassfileName(names, outerKinds, pos - 1); + return outerStr + outerKinds[pos].sep + name; + } + } + + boolean isAllowed(ClassKind nestedKind) { + return nestedKind != NESTED || + staticAllowed; + } + } + + enum LocalInnerClass { + LOCAL_REF("class L {}; new L();", "Test$1L"), + LOCAL_NOREF("class L {};", "Test$1L"), + ANON("new Object() {};", "Test$1"), + NONE("", ""); + + String localInnerStr; + String canonicalInnerStr; + + private LocalInnerClass(String localInnerStr, String canonicalInnerStr) { + this.localInnerStr = localInnerStr; + this.canonicalInnerStr = canonicalInnerStr; + } + } + + public static void main(String... args) throws Exception { + for (ClassKind ck1 : ClassKind.values()) { + String cname1 = "C1"; + for (ClassKind ck2 : ClassKind.values()) { + if (!ck1.isAllowed(ck2)) continue; + String cname2 = "C2"; + for (ClassKind ck3 : ClassKind.values()) { + if (!ck2.isAllowed(ck3)) continue; + String cname3 = "C3"; + new T7003595(new ClassKind[] {ck1, ck2, ck3}, new String[] { cname1, cname2, cname3 }).compileAndCheck(); + } + } + } + + System.out.println("Total checks made: " + checkCount); + } + + /** instance decls **/ + + ClassKind[] cks; + String[] cnames; + + T7003595(ClassKind[] cks, String[] cnames) { + this.cks = cks; + this.cnames = cnames; + } + + void compileAndCheck() throws Exception { + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + JavaSource source = new JavaSource(); + JavacTask ct = (JavacTask)tool.getTask(null, fm, null, + null, null, Arrays.asList(source)); + ct.call(); + verifyBytecode(source); + } + + void verifyBytecode(JavaSource source) { + for (int i = 0; i < 3 ; i ++) { + if (cks[i] == ClassKind.NONE) break; + checkCount++; + String filename = cks[i].getClassfileName(cnames, cks, i); + File compiledTest = new File(filename + ".class"); + try { + ClassFile cf = ClassFile.read(compiledTest); + if (cf == null) { + throw new Error("Classfile not found: " + filename); + } + + InnerClasses_attribute innerClasses = (InnerClasses_attribute)cf.getAttribute(Attribute.InnerClasses); + + ArrayList foundInnerSig = new ArrayList<>(); + if (innerClasses != null) { + for (InnerClasses_attribute.Info info : innerClasses.classes) { + String foundSig = info.getInnerClassInfo(cf.constant_pool).getName(); + foundInnerSig.add(foundSig); + } + } + + ArrayList expectedInnerSig = new ArrayList<>(); + //add inner class (if any) + if (i < 2 && cks[i + 1] != ClassKind.NONE) { + expectedInnerSig.add(cks[i + 1].getClassfileName(cnames, cks, i + 1)); + } + //add inner classes + for (int j = 0 ; j != i + 1 && j < 3; j++) { + expectedInnerSig.add(cks[j].getClassfileName(cnames, cks, j)); + } + + if (expectedInnerSig.size() != foundInnerSig.size()) { + throw new Error("InnerClasses attribute for " + cnames[i] + " has wrong size\n" + + "expected " + expectedInnerSig.size() + "\n" + + "found " + innerClasses.number_of_classes + "\n" + + source); + } + + for (String foundSig : foundInnerSig) { + if (!expectedInnerSig.contains(foundSig)) { + throw new Error("InnerClasses attribute for " + cnames[i] + " has unexpected signature: " + + foundSig + "\n" + source + "\n" + expectedInnerSig); + } + } + + for (String expectedSig : expectedInnerSig) { + if (!foundInnerSig.contains(expectedSig)) { + throw new Error("InnerClasses attribute for " + cnames[i] + " does not contain expected signature: " + + expectedSig + "\n" + source); + } + } + } catch (Exception e) { + e.printStackTrace(); + throw new Error("error reading " + compiledTest +": " + e); + } + } + } + + class JavaSource extends SimpleJavaFileObject { + + static final String source_template = "class Test { #C }"; + + String source; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + String c3 = cks[2].getSource(cnames[2], cnames[1], ""); + String c2 = cks[1].getSource(cnames[1], cnames[0], c3); + String c1 = cks[0].getSource(cnames[0], "Test", c2); + source = source_template.replace("#C", c1); + } + + @Override + public String toString() { + return source; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7003595/T7003595b.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7003595/T7003595b.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7003595 + * @summary IncompatibleClassChangeError with unreferenced local class with subclass + */ + +public class T7003595b { + public static void main(String... args) throws Exception { + class A {} + class B extends A {} + B.class.getSuperclass().getDeclaringClass(); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7079713/TestCircularClassfile.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7079713/TestCircularClassfile.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7079713 + * @summary javac hangs when compiling a class that references a cyclically inherited class + * @run main TestCircularClassfile + */ + +import java.io.*; +import java.net.URI; +import java.util.Arrays; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +import com.sun.source.util.JavacTask; + +public class TestCircularClassfile { + + enum SourceKind { + A_EXTENDS_B("class B {} class A extends B { void m() {} }"), + B_EXTENDS_A("class A { void m() {} } class B extends A {}"); + + String sourceStr; + + private SourceKind(String sourceStr) { + this.sourceStr = sourceStr; + } + + SimpleJavaFileObject getSource() { + return new SimpleJavaFileObject(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE) { + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + return sourceStr; + } + }; + } + } + + enum TestKind { + REPLACE_A("A.class"), + REPLACE_B("B.class"); + + String targetClass; + + private TestKind(String targetClass) { + this.targetClass = targetClass; + } + } + + enum ClientKind { + METHOD_CALL1("A a = null; a.m();"), + METHOD_CALL2("B b = null; b.m();"), + CONSTR_CALL1("new A();"), + CONSTR_CALL2("new B();"), + ASSIGN1("A a = null; B b = a;"), + ASSIGN2("B b = null; A a = b;"); + + String mainMethod; + + private ClientKind(String mainMethod) { + this.mainMethod = mainMethod; + } + + SimpleJavaFileObject getSource() { + return new SimpleJavaFileObject(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE) { + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + return "class Test { public static void main(String[] args) { #M } }" + .replace("#M", mainMethod); + } + }; + } + } + + public static void main(String... args) throws Exception { + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + int count = 0; + for (SourceKind sk1 : SourceKind.values()) { + for (SourceKind sk2 : SourceKind.values()) { + for (TestKind tk : TestKind.values()) { + for (ClientKind ck : ClientKind.values()) { + new TestCircularClassfile("sub_"+count++, sk1, sk2, tk, ck).check(comp, fm); + } + } + } + } + } + + static String workDir = System.getProperty("user.dir"); + + String destPath; + SourceKind sk1; + SourceKind sk2; + TestKind tk; + ClientKind ck; + + TestCircularClassfile(String destPath, SourceKind sk1, SourceKind sk2, TestKind tk, ClientKind ck) { + this.destPath = destPath; + this.sk1 = sk1; + this.sk2 = sk2; + this.tk = tk; + this.ck = ck; + } + + void check(JavaCompiler comp, StandardJavaFileManager fm) throws Exception { + //step 1: compile first source code in the test subfolder + File destDir = new File(workDir, destPath); destDir.mkdir(); + //output dir must be set explicitly as we are sharing the fm (see bug 7026941) + fm.setLocation(javax.tools.StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir)); + JavacTask ct = (JavacTask)comp.getTask(null, fm, null, + null, null, Arrays.asList(sk1.getSource())); + ct.generate(); + + //step 2: compile second source code in a temp folder + File tmpDir = new File(destDir, "tmp"); tmpDir.mkdir(); + //output dir must be set explicitly as we are sharing the fm (see bug 7026941) + fm.setLocation(javax.tools.StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir)); + ct = (JavacTask)comp.getTask(null, fm, null, + null, null, Arrays.asList(sk2.getSource())); + ct.generate(); + + //step 3: move a classfile from the temp folder to the test subfolder + File fileToMove = new File(tmpDir, tk.targetClass); + File target = new File(destDir, tk.targetClass); + target.delete(); + boolean success = fileToMove.renameTo(target); + + if (!success) { + throw new AssertionError("error when moving file " + tk.targetClass); + } + + //step 4: compile the client class against the classes in the test subfolder + //input/output dir must be set explicitly as we are sharing the fm (see bug 7026941) + fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir)); + fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(destDir)); + ct = (JavacTask)comp.getTask(null, fm, null, + null, null, Arrays.asList(ck.getSource())); + + ct.generate(); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7085024/T7085024.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7085024/T7085024.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,12 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7085024 + * @summary internal error; cannot instantiate Foo + * @compile/fail/ref=T7085024.out -XDrawDiagnostics T7085024.java + */ + +class T7085024 { + T7085024 (boolean ret) { } //internal error goes away if constructor accepts a reference type + + T7085024 f = new T7085024((NonExistentClass) null ); +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7085024/T7085024.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7085024/T7085024.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,2 @@ +T7085024.java:11:32: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, T7085024, null) +1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7086595/T7086595.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7086595/T7086595.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,32 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7086595 + * @summary Error message bug: name of initializer is 'null' + * @compile/fail/ref=T7086595.out -XDrawDiagnostics T7086595.java + */ + +class T7086595 { + + String s = "x"; + String s = nonExistent; + + int foo() { + String s = "x"; + String s = nonExistent; + } + + static int bar() { + String s = "x"; + String s = nonExistent; + } + + { + String s = "x"; + String s = nonExistent; + } + + static { + String s = "x"; + String s = nonExistent; + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7086595/T7086595.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7086595/T7086595.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,11 @@ +T7086595.java:11:12: compiler.err.already.defined: kindname.variable, s, kindname.class, T7086595 +T7086595.java:11:16: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, T7086595, null) +T7086595.java:15:16: compiler.err.already.defined: kindname.variable, s, kindname.method, foo() +T7086595.java:15:20: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, T7086595, null) +T7086595.java:20:16: compiler.err.already.defined: kindname.variable, s, kindname.method, bar() +T7086595.java:20:20: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, T7086595, null) +T7086595.java:25:16: compiler.err.already.defined.in.clinit: kindname.variable, s, kindname.instance.init, kindname.class, T7086595 +T7086595.java:25:20: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, T7086595, null) +T7086595.java:30:16: compiler.err.already.defined.in.clinit: kindname.variable, s, kindname.static.init, kindname.class, T7086595 +T7086595.java:30:20: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, T7086595, null) +10 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7102515/T7102515.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7102515/T7102515.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,11 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7102515 + * @summary javac running very very long and not returning + * @compile/fail/ref=T7102515.out -XDrawDiagnostics T7102515.java + */ + +class T7102515 { + T7102515 badBinary = new T7102515() + new T7102515(); + Object badUnary = badBinary++; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7102515/T7102515.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7102515/T7102515.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,3 @@ +T7102515.java:9:41: compiler.err.operator.cant.be.applied.1: +, T7102515, T7102515 +T7102515.java:10:32: compiler.err.operator.cant.be.applied: ++, T7102515, null +2 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7129225/Anno.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7129225/Anno.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +public @interface Anno { +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7129225/AnnoProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7129225/AnnoProcessor.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.Set; +import javax.annotation.processing.*; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic.Kind; + +@SupportedAnnotationTypes("Anno") +public class AnnoProcessor extends JavacTestingAbstractProcessor { + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + @Override + public boolean process(Set set, RoundEnvironment re) { + messager.printMessage(Kind.NOTE, "RUNNING - lastRound = " + re.processingOver()); + return true; + } +} + diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7129225/NegTest.ref --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7129225/NegTest.ref Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,2 @@ +TestImportStar.java:39:1: compiler.err.doesnt.exist: xxx +1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7129225/TestImportStar.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7129225/TestImportStar.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 7129225 + * @summary import xxx.* isn't handled correctly by annotation processing + * @library ../lib + * @build JavacTestingAbstractProcessor + * @compile/fail/ref=NegTest.ref -XDrawDiagnostics TestImportStar.java + * @compile Anno.java AnnoProcessor.java + * @compile/ref=TestImportStar.ref -XDrawDiagnostics -processor AnnoProcessor -proc:only TestImportStar.java + */ + + //The @compile/fail... verifies that the fix doesn't break the normal compilation of import xxx.* + //The @comple/ref... verifies the fix fixes the bug + +import xxx.*; + +@Anno +public class TestImportStar { +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7129225/TestImportStar.ref --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7129225/TestImportStar.ref Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,3 @@ +- compiler.note.proc.messager: RUNNING - lastRound = false +TestImportStar.java:39:1: compiler.err.doesnt.exist: xxx +- compiler.note.proc.messager: RUNNING - lastRound = true diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7132880/T7132880.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7132880/T7132880.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,60 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7132880 + * @summary Resolve should support nested resolution contexts + * @compile/fail/ref=T7132880.out -XDrawDiagnostics T7132880.java + */ +class Outer { + void m1(String s) { } + void m2(int i1, int i2) { } + + class Inner { + void test() { + //ok - no method named 'm' in Inner - hence, class to search is Outer + m1(""); + } + } + + class Inner1 { + void m1(Integer i) { } + + void test() { + //error - Inner1 defines an incompatible method - hence, class to search is Inner1 + m1(""); + } + } + + class Inner2 { + private void m1(Integer i) { } + private void m1(Double d) { } + + void test() { + //error - Inner2 defines multiple incompatible methods - hence, class to search is Inner2 + m1(""); + } + } + + class Inner3 { + private void m2(Object o, int i) { } + private void m2(int i, Object o) { } + + void test() { + //error - Inner3 defines multiple ambiguous methods - hence, class to search is Inner3 + m2(1, 1); + } + } + + class Inner4 extends Inner2 { + void test() { + //ok - Inner2 defines multiple incompatible inaccessible methods - hence, class to search is Outer + m1(""); + } + } + + class Inner5 extends Inner3 { + void test() { + //ok - Inner3 defines multiple inaccessible ambiguous methods - hence, class to search is Outer + m2(1, 1); + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7132880/T7132880.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7132880/T7132880.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,4 @@ +T7132880.java:23:12: compiler.err.cant.apply.symbol.1: kindname.method, m1, java.lang.Integer, java.lang.String, kindname.class, Outer.Inner1, (compiler.misc.no.conforming.assignment.exists: java.lang.String, java.lang.Integer) +T7132880.java:33:12: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.String,{(compiler.misc.inapplicable.method: kindname.method, Outer.Inner2, m1(java.lang.Double), (compiler.misc.no.conforming.assignment.exists: java.lang.String, java.lang.Double)),(compiler.misc.inapplicable.method: kindname.method, Outer.Inner2, m1(java.lang.Integer), (compiler.misc.no.conforming.assignment.exists: java.lang.String, java.lang.Integer))} +T7132880.java:43:12: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Object,int), Outer.Inner3, kindname.method, m2(int,java.lang.Object), Outer.Inner3 +3 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/7142086/T7142086.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7142086/T7142086.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7142086 + * @summary performance problem in Check.checkOverrideClashes(...) + * @run main/timeout=10 T7142086 + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.List; +import java.util.ArrayList; +import java.util.Locale; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +public class T7142086 { + + final static int N_METHODS = 1000; + + static class TestClass extends SimpleJavaFileObject { + + String methTemplate = "abstract void m(A#N p);"; + String classTemplate = "abstract class Test { #M }"; + + String source; + + public TestClass() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + StringBuilder buf = new StringBuilder(); + for (int i = 0 ; i < N_METHODS ; i++) { + buf.append(methTemplate.replace("#N", String.valueOf(i))); + buf.append("\n"); + } + source = classTemplate.replace("#M", buf.toString()); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + static class AnSource extends SimpleJavaFileObject { + + String classTemplate = "abstract class A#N { }"; + + String source; + + public AnSource(int n) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = classTemplate.replace("#N", String.valueOf(n)); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + public static void main(String... args) throws Exception { + ArrayList sources = new ArrayList<>(); + for (int i = 0 ; i < N_METHODS ; i++) { + sources.add(new AnSource(i)); + } + sources.add(new TestClass()); + new T7142086().run(sources); + } + + void run(List sources) throws Exception { + DiagnosticChecker dc = new DiagnosticChecker(); + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, + null, null, sources); + ct.analyze(); + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + throw new AssertionError("unexpected diagnostic: " + diagnostic.getMessage(Locale.getDefault())); + } + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/ClassPathTest/ClassPathTest.sh --- a/test/tools/javac/ClassPathTest/ClassPathTest.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/ClassPathTest/ClassPathTest.sh Tue May 29 00:27:58 2012 +0100 @@ -56,7 +56,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | CYGWIN* ) + SunOS | Linux | Darwin | CYGWIN* ) FS="/" ;; Windows* ) diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/Diagnostics/6722234/T6722234b_1.out --- a/test/tools/javac/Diagnostics/6722234/T6722234b_1.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/Diagnostics/6722234/T6722234b_1.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List,List, List,List, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List, List) +T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List,List, List,List, kindname.class, T6722234b, (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 2, ? extends T6722234b, compiler.misc.type.captureof: 2, ? extends T6722234b,compiler.misc.type.captureof: 1, ? extends T6722234b) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/Diagnostics/6722234/T6722234b_2.out --- a/test/tools/javac/Diagnostics/6722234/T6722234b_2.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/Diagnostics/6722234/T6722234b_2.out Tue May 29 00:27:58 2012 +0100 @@ -1,4 +1,4 @@ -T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List,List, List,List, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List, List) +T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List,List, List,List, kindname.class, T6722234b, (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.captured.type: 2, compiler.misc.captured.type: 2,compiler.misc.captured.type: 1) - compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, Object, kindname.method, m(List,List))} - compiler.misc.where.description.captured.1: compiler.misc.captured.type: 1,compiler.misc.captured.type: 2,{(compiler.misc.where.captured.1: compiler.misc.captured.type: 1, T6722234b, compiler.misc.type.null, ? extends T6722234b),(compiler.misc.where.captured.1: compiler.misc.captured.type: 2, T6722234b, compiler.misc.type.null, ? extends T6722234b)} 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/Diagnostics/6722234/T6722234d_1.out --- a/test/tools/javac/Diagnostics/6722234/T6722234d_1.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/Diagnostics/6722234/T6722234d_1.out Tue May 29 00:27:58 2012 +0100 @@ -1,3 +1,3 @@ -T6722234d.java:18:20: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.intersection.type: 1, T6722234d.A +T6722234d.java:18:20: compiler.err.prob.found.req: compiler.misc.intersection.type: 1, T6722234d.A - compiler.misc.where.description.intersection: compiler.misc.intersection.type: 1,{(compiler.misc.where.intersection: compiler.misc.intersection.type: 1, java.lang.Object,T6722234d.I1,T6722234d.I2)} 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/Diagnostics/6722234/T6722234d_2.out --- a/test/tools/javac/Diagnostics/6722234/T6722234d_2.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/Diagnostics/6722234/T6722234d_2.out Tue May 29 00:27:58 2012 +0100 @@ -1,3 +1,3 @@ -T6722234d.java:18:20: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.intersection.type: 1, T6722234d.A +T6722234d.java:18:20: compiler.err.prob.found.req: compiler.misc.intersection.type: 1, T6722234d.A - compiler.misc.where.description.intersection: compiler.misc.intersection.type: 1,{(compiler.misc.where.intersection: compiler.misc.intersection.type: 1, Object,I1,I2)} 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/Diagnostics/6799605/T6799605.out --- a/test/tools/javac/Diagnostics/6799605/T6799605.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/Diagnostics/6799605/T6799605.out Tue May 29 00:27:58 2012 +0100 @@ -1,4 +1,4 @@ -T6799605.java:17:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605,{(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605), (compiler.misc.inferred.do.not.conform.to.bounds: compiler.misc.type.captureof: 1, ?, T6799605))} -T6799605.java:18:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605,T6799605,{(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605, T6799605)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605), (compiler.misc.infer.arg.length.mismatch))} -T6799605.java:19:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605,T6799605,T6799605,{(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605,T6799605), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605, T6799605)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605), (compiler.misc.infer.arg.length.mismatch))} +T6799605.java:17:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605,{(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605), (compiler.misc.inferred.do.not.conform.to.upper.bounds: compiler.misc.type.captureof: 1, ?, T6799605))} +T6799605.java:18:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605,T6799605,{(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605), (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 2, ?, compiler.misc.type.captureof: 2, ?,compiler.misc.type.captureof: 1, ?)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605), (compiler.misc.infer.arg.length.mismatch))} +T6799605.java:19:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605,T6799605,T6799605,{(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605,T6799605), (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 3, ?, compiler.misc.type.captureof: 3, ?,compiler.misc.type.captureof: 2, ?,compiler.misc.type.captureof: 1, ?)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605,T6799605), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, m(T6799605), (compiler.misc.infer.arg.length.mismatch))} 3 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/Diagnostics/6860795/T6860795.out --- a/test/tools/javac/Diagnostics/6860795/T6860795.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/Diagnostics/6860795/T6860795.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6860795.java:10:27: compiler.err.already.defined: x, foo +T6860795.java:10:27: compiler.err.already.defined: kindname.variable, x, kindname.method, foo 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/Diagnostics/6862608/T6862608a.out --- a/test/tools/javac/Diagnostics/6862608/T6862608a.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/Diagnostics/6862608/T6862608a.out Tue May 29 00:27:58 2012 +0100 @@ -1,3 +1,3 @@ -T6862608a.java:19:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, java.util.Comparator, java.util.Comparator)), java.util.Comparator, java.util.Comparator +T6862608a.java:19:33: compiler.err.cant.apply.symbol.1: kindname.method, compound, java.lang.Iterable>, java.util.List>, kindname.class, T6862608a, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List>, java.lang.Iterable>) - compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, java.lang.Object, kindname.method, compound(java.lang.Iterable>))} 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/ExtDirs/ExtDirs.sh --- a/test/tools/javac/ExtDirs/ExtDirs.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/ExtDirs/ExtDirs.sh Tue May 29 00:27:58 2012 +0100 @@ -54,7 +54,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux ) + SunOS | Linux | Darwin ) PS=":" FS="/" ;; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/LocalClasses_2.out --- a/test/tools/javac/LocalClasses_2.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/LocalClasses_2.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -LocalClasses_2.java:15:13: compiler.err.already.defined: Local, foo() +LocalClasses_2.java:15:13: compiler.err.already.defined: kindname.class, Local, kindname.method, foo() 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/MissingInclude.sh --- a/test/tools/javac/MissingInclude.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/MissingInclude.sh Tue May 29 00:27:58 2012 +0100 @@ -47,7 +47,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | CYGWIN* ) + SunOS | Linux | Darwin | CYGWIN* ) FS="/" ;; Windows* ) diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/NestedInnerClassNames.out --- a/test/tools/javac/NestedInnerClassNames.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/NestedInnerClassNames.out Tue May 29 00:27:58 2012 +0100 @@ -1,18 +1,18 @@ -NestedInnerClassNames.java:16:5: compiler.err.already.defined: NestedInnerClassNames, compiler.misc.unnamed.package -NestedInnerClassNames.java:23:9: compiler.err.already.defined: NestedInnerClassNames.foo, NestedInnerClassNames -NestedInnerClassNames.java:34:9: compiler.err.already.defined: NestedInnerClassNames, compiler.misc.unnamed.package -NestedInnerClassNames.java:45:9: compiler.err.already.defined: NestedInnerClassNames.baz, NestedInnerClassNames -NestedInnerClassNames.java:46:13: compiler.err.already.defined: NestedInnerClassNames.baz.baz, NestedInnerClassNames.baz -NestedInnerClassNames.java:59:9: compiler.err.already.defined: NestedInnerClassNames.foo$bar, NestedInnerClassNames -NestedInnerClassNames.java:76:13: compiler.err.already.defined: NestedInnerClassNames.$bar, NestedInnerClassNames -NestedInnerClassNames.java:90:13: compiler.err.already.defined: NestedInnerClassNames.bar$bar.bar, NestedInnerClassNames.bar$bar +NestedInnerClassNames.java:16:5: compiler.err.already.defined: kindname.class, NestedInnerClassNames, kindname.package, compiler.misc.unnamed.package +NestedInnerClassNames.java:23:9: compiler.err.already.defined: kindname.class, NestedInnerClassNames.foo, kindname.class, NestedInnerClassNames +NestedInnerClassNames.java:34:9: compiler.err.already.defined: kindname.class, NestedInnerClassNames, kindname.package, compiler.misc.unnamed.package +NestedInnerClassNames.java:45:9: compiler.err.already.defined: kindname.class, NestedInnerClassNames.baz, kindname.class, NestedInnerClassNames +NestedInnerClassNames.java:46:13: compiler.err.already.defined: kindname.class, NestedInnerClassNames.baz.baz, kindname.class, NestedInnerClassNames.baz +NestedInnerClassNames.java:59:9: compiler.err.already.defined: kindname.class, NestedInnerClassNames.foo$bar, kindname.class, NestedInnerClassNames +NestedInnerClassNames.java:76:13: compiler.err.already.defined: kindname.class, NestedInnerClassNames.$bar, kindname.class, NestedInnerClassNames +NestedInnerClassNames.java:90:13: compiler.err.already.defined: kindname.class, NestedInnerClassNames.bar$bar.bar, kindname.class, NestedInnerClassNames.bar$bar NestedInnerClassNames.java:109:5: compiler.err.duplicate.class: NestedInnerClassNames.foo.foo -NestedInnerClassNames.java:19:9: compiler.err.already.defined: NestedInnerClassNames, compiler.misc.unnamed.package -NestedInnerClassNames.java:28:13: compiler.err.already.defined: foo, m2() -NestedInnerClassNames.java:40:13: compiler.err.already.defined: NestedInnerClassNames, compiler.misc.unnamed.package -NestedInnerClassNames.java:52:13: compiler.err.already.defined: baz, m4() -NestedInnerClassNames.java:53:17: compiler.err.already.defined: baz.baz, baz -NestedInnerClassNames.java:67:13: compiler.err.already.defined: foo$bar, m5() -NestedInnerClassNames.java:83:17: compiler.err.already.defined: $bar, m6() -NestedInnerClassNames.java:97:17: compiler.err.already.defined: bar$bar.bar, bar$bar +NestedInnerClassNames.java:19:9: compiler.err.already.defined: kindname.class, NestedInnerClassNames, kindname.package, compiler.misc.unnamed.package +NestedInnerClassNames.java:28:13: compiler.err.already.defined: kindname.class, foo, kindname.method, m2() +NestedInnerClassNames.java:40:13: compiler.err.already.defined: kindname.class, NestedInnerClassNames, kindname.package, compiler.misc.unnamed.package +NestedInnerClassNames.java:52:13: compiler.err.already.defined: kindname.class, baz, kindname.method, m4() +NestedInnerClassNames.java:53:17: compiler.err.already.defined: kindname.class, baz.baz, kindname.class, baz +NestedInnerClassNames.java:67:13: compiler.err.already.defined: kindname.class, foo$bar, kindname.method, m5() +NestedInnerClassNames.java:83:17: compiler.err.already.defined: kindname.class, $bar, kindname.method, m6() +NestedInnerClassNames.java:97:17: compiler.err.already.defined: kindname.class, bar$bar.bar, kindname.class, bar$bar 17 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/OverrideChecks/6400189/T6400189a.out --- a/test/tools/javac/OverrideChecks/6400189/T6400189a.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/OverrideChecks/6400189/T6400189a.out Tue May 29 00:27:58 2012 +0100 @@ -1,4 +1,4 @@ T6400189a.java:14:35: compiler.warn.unchecked.call.mbr.of.raw.type: getAnnotation(java.lang.Class), java.lang.reflect.Constructor -T6400189a.java:14:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.annotation.Annotation, java.lang.annotation.Documented +T6400189a.java:14:35: compiler.err.prob.found.req: java.lang.annotation.Annotation, java.lang.annotation.Documented 1 error 1 warning diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/OverrideChecks/6400189/T6400189b.out --- a/test/tools/javac/OverrideChecks/6400189/T6400189b.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/OverrideChecks/6400189/T6400189b.out Tue May 29 00:27:58 2012 +0100 @@ -1,4 +1,4 @@ T6400189b.java:24:24: compiler.warn.unchecked.call.mbr.of.raw.type: m(T6400189b), T6400189b.B -T6400189b.java:24:24: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Object, java.lang.Integer +T6400189b.java:24:24: compiler.err.prob.found.req: java.lang.Object, java.lang.Integer 1 error 1 warning diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh --- a/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh Tue May 29 00:27:58 2012 +0100 @@ -52,7 +52,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux ) + SunOS | Linux | Darwin ) PS=":" FS="/" ;; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/StringsInSwitch/BadlyTypedLabel1.out --- a/test/tools/javac/StringsInSwitch/BadlyTypedLabel1.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/StringsInSwitch/BadlyTypedLabel1.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -BadlyTypedLabel1.java:13:14: compiler.err.prob.found.req: (compiler.misc.incompatible.types), int, java.lang.String +BadlyTypedLabel1.java:13:14: compiler.err.prob.found.req: int, java.lang.String 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/StringsInSwitch/BadlyTypedLabel2.out --- a/test/tools/javac/StringsInSwitch/BadlyTypedLabel2.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/StringsInSwitch/BadlyTypedLabel2.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -BadlyTypedLabel2.java:15:14: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.math.RoundingMode, java.lang.String +BadlyTypedLabel2.java:15:14: compiler.err.prob.found.req: java.math.RoundingMode, java.lang.String 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/StringsInSwitch/StringSwitches.java --- a/test/tools/javac/StringsInSwitch/StringSwitches.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/StringsInSwitch/StringSwitches.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6827009 + * @bug 6827009 7071246 * @summary Positive tests for strings in switch. * @author Joseph D. Darcy */ @@ -36,6 +36,7 @@ failures += testPileup(); failures += testSwitchingTwoWays(); failures += testNamedBreak(); + failures += testExtraParens(); if (failures > 0) { throw new RuntimeException(); @@ -260,4 +261,19 @@ result |= (1<<5); return result; } + + private static int testExtraParens() { + int failures = 1; + String s = "first"; + + switch(s) { + case (("first")): + failures = 0; + break; + case ("second"): + throw new RuntimeException("Should not be reached."); + } + + return failures; + } } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/T5090006/compiler.sh --- a/test/tools/javac/T5090006/compiler.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/T5090006/compiler.sh Tue May 29 00:27:58 2012 +0100 @@ -47,7 +47,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | CYGWIN* ) + SunOS | Linux | Darwin | CYGWIN* ) FS="/" ;; Windows* ) diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/T6326754.out --- a/test/tools/javac/T6326754.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/T6326754.out Tue May 29 00:27:58 2012 +0100 @@ -1,6 +1,6 @@ T6326754.java:44:12: compiler.err.name.clash.same.erasure: TestConstructor(T), TestConstructor(K) T6326754.java:52:17: compiler.err.name.clash.same.erasure: setT(K), setT(T) -T6326754.java:64:18: compiler.err.prob.found.req: (compiler.misc.incompatible.types), T, T +T6326754.java:64:18: compiler.err.prob.found.req: T, T T6326754.java:70:11: compiler.err.cant.apply.symbol.1: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC, (compiler.misc.arg.length.mismatch) - compiler.note.unchecked.filename: T6326754.java - compiler.note.unchecked.recompile diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/T6358166.java --- a/test/tools/javac/T6358166.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/T6358166.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,7 @@ Main compilerMain = new Main("javac", new PrintWriter(System.err, true)); compilerMain.setOptions(Options.instance(context)); - compilerMain.filenames = new ListBuffer(); + compilerMain.filenames = new LinkedHashSet(); compilerMain.processArgs(args); JavaCompiler c = JavaCompiler.instance(context); diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/T6358168.java --- a/test/tools/javac/T6358168.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/T6358168.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,7 @@ Main compilerMain = new Main("javac", new PrintWriter(System.err, true)); compilerMain.setOptions(Options.instance(context)); - compilerMain.filenames = new ListBuffer(); + compilerMain.filenames = new LinkedHashSet(); compilerMain.processArgs(new String[] { "-d", "." }); JavaCompiler compiler = JavaCompiler.instance(context); @@ -91,7 +91,7 @@ Main compilerMain = new Main("javac", new PrintWriter(System.err, true)); compilerMain.setOptions(Options.instance(context)); - compilerMain.filenames = new ListBuffer(); + compilerMain.filenames = new LinkedHashSet(); compilerMain.processArgs(new String[] { "-XprintRounds", "-processorpath", testClasses, diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/T7093325.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T7093325.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7093325 + * @summary Redundant entry in bytecode exception table + */ + +import com.sun.source.util.JavacTask; +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Code_attribute; +import com.sun.tools.classfile.ConstantPool.*; +import com.sun.tools.classfile.Method; +import com.sun.tools.javac.api.JavacTool; + +import java.io.File; +import java.net.URI; +import java.util.Arrays; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + + +public class T7093325 { + + /** global decls ***/ + + // Create a single file manager and reuse it for each compile to save time. + static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null); + + //statistics + static int checkCount = 0; + + enum StatementKind { + THROW("throw new RuntimeException();", false, false), + RETURN_NONEMPTY("System.out.println(); return;", true, false), + RETURN_EMPTY("return;", true, true), + APPLY("System.out.println();", true, false); + + String stmt; + boolean canInline; + boolean empty; + + private StatementKind(String stmt, boolean canInline, boolean empty) { + this.stmt = stmt; + this.canInline = canInline; + this.empty = empty; + } + } + + enum CatchArity { + NONE(""), + ONE("catch (A a) { #S1 }"), + TWO("catch (B b) { #S2 }"), + THREE("catch (C c) { #S3 }"), + FOUR("catch (D d) { #S4 }"); + + String catchStr; + + private CatchArity(String catchStr) { + this.catchStr = catchStr; + } + + String catchers() { + if (this.ordinal() == 0) { + return catchStr; + } else { + return CatchArity.values()[this.ordinal() - 1].catchers() + catchStr; + } + } + } + + public static void main(String... args) throws Exception { + for (CatchArity ca : CatchArity.values()) { + for (StatementKind stmt0 : StatementKind.values()) { + if (ca.ordinal() == 0) { + new T7093325(ca, stmt0).compileAndCheck(); + continue; + } + for (StatementKind stmt1 : StatementKind.values()) { + if (ca.ordinal() == 1) { + new T7093325(ca, stmt0, stmt1).compileAndCheck(); + continue; + } + for (StatementKind stmt2 : StatementKind.values()) { + if (ca.ordinal() == 2) { + new T7093325(ca, stmt0, stmt1, stmt2).compileAndCheck(); + continue; + } + for (StatementKind stmt3 : StatementKind.values()) { + if (ca.ordinal() == 3) { + new T7093325(ca, stmt0, stmt1, stmt2, stmt3).compileAndCheck(); + continue; + } + for (StatementKind stmt4 : StatementKind.values()) { + if (ca.ordinal() == 4) { + new T7093325(ca, stmt0, stmt1, stmt2, stmt3, stmt4).compileAndCheck(); + continue; + } + for (StatementKind stmt5 : StatementKind.values()) { + new T7093325(ca, stmt0, stmt1, stmt2, stmt3, stmt4, stmt5).compileAndCheck(); + } + } + } + } + } + } + } + + System.out.println("Total checks made: " + checkCount); + } + + /** instance decls **/ + + CatchArity ca; + StatementKind[] stmts; + + public T7093325(CatchArity ca, StatementKind... stmts) { + this.ca = ca; + this.stmts = stmts; + } + + void compileAndCheck() throws Exception { + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + JavaSource source = new JavaSource(); + JavacTask ct = (JavacTask)tool.getTask(null, fm, null, + null, null, Arrays.asList(source)); + ct.call(); + verifyBytecode(source); + } + + void verifyBytecode(JavaSource source) { + checkCount++; + boolean lastInlined = false; + boolean hasCode = false; + int gapsCount = 0; + for (int i = 0; i < stmts.length ; i++) { + lastInlined = stmts[i].canInline; + hasCode = hasCode || !stmts[i].empty; + if (lastInlined && hasCode) { + hasCode = false; + gapsCount++; + } + } + if (!lastInlined) { + gapsCount++; + } + + //System.out.printf("gaps %d \n %s \n", gapsCount, source.toString()); + + File compiledTest = new File("Test.class"); + try { + ClassFile cf = ClassFile.read(compiledTest); + if (cf == null) { + throw new Error("Classfile not found: " + compiledTest.getName()); + } + + Method test_method = null; + for (Method m : cf.methods) { + if (m.getName(cf.constant_pool).equals("test")) { + test_method = m; + break; + } + } + + if (test_method == null) { + throw new Error("Method test() not found in class Test"); + } + + Code_attribute code = null; + for (Attribute a : test_method.attributes) { + if (a.getName(cf.constant_pool).equals(Attribute.Code)) { + code = (Code_attribute)a; + break; + } + } + + if (code == null) { + throw new Error("Code attribute not found in method test()"); + } + + int actualGapsCount = 0; + for (int i = 0; i < code.exception_table_langth ; i++) { + int catchType = code.exception_table[i].catch_type; + if (catchType == 0) { //any + actualGapsCount++; + } + } + + if (actualGapsCount != gapsCount) { + throw new Error("Bad exception table for test()\n" + + "expected gaps: " + gapsCount + "\n" + + "found gaps: " + actualGapsCount + "\n" + + source); + } + } catch (Exception e) { + e.printStackTrace(); + throw new Error("error reading " + compiledTest +": " + e); + } + + } + + class JavaSource extends SimpleJavaFileObject { + + static final String source_template = + "class A extends RuntimeException {} \n" + + "class B extends RuntimeException {} \n" + + "class C extends RuntimeException {} \n" + + "class D extends RuntimeException {} \n" + + "class E extends RuntimeException {} \n" + + "class Test {\n" + + " void test() {\n" + + " try { #S0 } #C finally { System.out.println(); }\n" + + " }\n" + + "}"; + + String source; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = source_template.replace("#C", ca.catchers()); + source = source.replace("#S0", stmts[0].stmt); + for (int i = 1; i < ca.ordinal() + 1; i++) { + source = source.replace("#S" + i, stmts[i].stmt); + } + } + + @Override + public String toString() { + return source; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/T7120266.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T7120266.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7120266 + * @summary javac fails to compile hotspot code + * @compile T7120266.java + */ + +class T7120266 { + void test(int i, int len) { that(i < len, "oopmap"); } + void that(boolean b, String s) { }; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/T7142672/AnnoProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T7142672/AnnoProcessor.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.Set; +import javax.annotation.processing.*; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.TypeElement; + +@SupportedAnnotationTypes("Anno") +public class AnnoProcessor extends AbstractProcessor { + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + @Override + public boolean process(Set set, RoundEnvironment re) { + System.out.println("RUNNING..."); + if(set.isEmpty()) { + return false; + } + return false; + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/T7142672/Bug.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T7142672/Bug.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7142672 + * @summary Problems with the value passed to the 'classes' param of JavaCompiler.CompilationTask.getTask(...) + * @author holmlund + * @compile AnnoProcessor.java Bug.java Test3.java + * @run main Bug Test2.java + * @run main Bug Test2.foo + * @run main Bug Test3.java + */ +import java.io.*; +import java.util.*; +import javax.tools.*; + +// Each run should output the 'could not find class file' message, and not throw an AssertError. +public class Bug { + public static void main(String... arg) throws Throwable { + String name = arg[0]; + final String expectedMsg = "error: Could not find class file for '" + name + "'."; + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + JavaCompiler.CompilationTask task2; + StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + + + DiagnosticListener dl = + new DiagnosticListener() { + public void report(Diagnostic message) { + pw.print("Diagnostic:\n"+ message.toString()+"\n"); + if (!message.toString().equals(expectedMsg)){ + System.err.println("Diagnostic:\n"+ message.toString()+"\n"); + System.err.println("--Failed: Unexpected diagnostic"); + System.exit(1); + } + } + }; + + StandardJavaFileManager sjfm = javac.getStandardFileManager(dl,null,null); + + List opts = new ArrayList(); + opts.add("-proc:only"); + opts.add("-processor"); + opts.add("AnnoProcessor"); + + boolean xxx; + + System.err.println("\n-- " + name); + task2 = javac.getTask(pw, sjfm, dl, opts, Arrays.asList(name), null); + xxx = task2.call(); + + String out = sw.toString(); + System.err.println(out); + if (out.contains("Assert")) { + System.err.println("--Failed: Assertion failure"); + System.exit(1); + } + if (!out.contains(expectedMsg)) { + System.err.println("--Failed: Expected diagnostic not found"); + System.exit(1); + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/T7142672/Test2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T7142672/Test2.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +class Test2 { +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/T7142672/Test3.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T7142672/Test3.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +class Test3 { +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/TryWithResources/BadTwr.out --- a/test/tools/javac/TryWithResources/BadTwr.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/TryWithResources/BadTwr.out Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ -BadTwr.java:13:39: compiler.err.already.defined: r1, main(java.lang.String...) -BadTwr.java:18:13: compiler.err.already.defined: args, main(java.lang.String...) +BadTwr.java:13:46: compiler.err.already.defined: kindname.variable, r1, kindname.method, main(java.lang.String...) +BadTwr.java:18:20: compiler.err.already.defined: kindname.variable, args, kindname.method, main(java.lang.String...) BadTwr.java:21:13: compiler.err.cant.assign.val.to.final.var: thatsIt -BadTwr.java:26:17: compiler.err.already.defined: name, main(java.lang.String...) +BadTwr.java:26:24: compiler.err.already.defined: kindname.variable, name, kindname.method, main(java.lang.String...) 4 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/TryWithResources/DuplicateResourceDecl.out --- a/test/tools/javac/TryWithResources/DuplicateResourceDecl.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/TryWithResources/DuplicateResourceDecl.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -DuplicateResourceDecl.java:12:45: compiler.err.already.defined: c, main(java.lang.String[]) +DuplicateResourceDecl.java:12:56: compiler.err.already.defined: kindname.variable, c, kindname.method, main(java.lang.String[]) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/TryWithResources/ResourceInterface.out --- a/test/tools/javac/TryWithResources/ResourceInterface.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/TryWithResources/ResourceInterface.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -ResourceInterface.java:38:13: compiler.err.unreported.exception.implicit.close: ResourceInterface.E1, r2 +ResourceInterface.java:38:23: compiler.err.unreported.exception.implicit.close: ResourceInterface.E1, r2 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/TryWithResources/T7164542.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/TryWithResources/T7164542.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7164542 + * @summary try-with-resources: problem with intersection types + * @compile T7164542.java + */ + +public class T7164542 { + public static + void copy(S s, T t, int size) throws Exception { + /* + * compiler used to fail here with: + * symbol: method close() + * location: interface Readable + * Fatal Error: Unable to find method close + */ + try (S src = s; T trg = t) { + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/TryWithResources/TwrFlow.out --- a/test/tools/javac/TryWithResources/TwrFlow.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/TryWithResources/TwrFlow.out Tue May 29 00:27:58 2012 +0100 @@ -1,3 +1,3 @@ TwrFlow.java:14:11: compiler.err.except.never.thrown.in.try: java.io.IOException -TwrFlow.java:12:13: compiler.err.unreported.exception.implicit.close: CustomCloseException, twrFlow +TwrFlow.java:12:21: compiler.err.unreported.exception.implicit.close: CustomCloseException, twrFlow 2 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/TryWithResources/TwrLint.out --- a/test/tools/javac/TryWithResources/TwrLint.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/TryWithResources/TwrLint.out Tue May 29 00:27:58 2012 +0100 @@ -1,3 +1,3 @@ TwrLint.java:14:15: compiler.warn.try.explicit.close.call -TwrLint.java:13:13: compiler.warn.try.resource.not.referenced: r3 +TwrLint.java:13:21: compiler.warn.try.resource.not.referenced: r3 2 warnings diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/TryWithResources/TwrOnNonResource.out --- a/test/tools/javac/TryWithResources/TwrOnNonResource.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/TryWithResources/TwrOnNonResource.out Tue May 29 00:27:58 2012 +0100 @@ -1,4 +1,4 @@ -TwrOnNonResource.java:12:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable -TwrOnNonResource.java:15:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable -TwrOnNonResource.java:18:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable +TwrOnNonResource.java:12:30: compiler.err.prob.found.req.1: (compiler.misc.try.not.applicable.to.type: TwrOnNonResource) +TwrOnNonResource.java:15:30: compiler.err.prob.found.req.1: (compiler.misc.try.not.applicable.to.type: TwrOnNonResource) +TwrOnNonResource.java:18:30: compiler.err.prob.found.req.1: (compiler.misc.try.not.applicable.to.type: TwrOnNonResource) 3 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/TryWithResources/UnusedResourcesTest.java --- a/test/tools/javac/TryWithResources/UnusedResourcesTest.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/TryWithResources/UnusedResourcesTest.java Tue May 29 00:27:58 2012 +0100 @@ -28,6 +28,7 @@ */ import com.sun.source.util.JavacTask; +import com.sun.tools.javac.api.ClientCodeWrapper; import com.sun.tools.javac.api.JavacTool; import com.sun.tools.javac.util.JCDiagnostic; import java.net.URI; @@ -236,7 +237,7 @@ public void report(Diagnostic diagnostic) { if (diagnostic.getKind() == Diagnostic.Kind.WARNING && diagnostic.getCode().contains("try.resource.not.referenced")) { - String varName = ((JCDiagnostic)diagnostic).getArgs()[0].toString(); + String varName = unwrap(diagnostic).getArgs()[0].toString(); if (varName.equals(TwrStmt.TWR1.resourceName)) { unused_r1 = true; } else if (varName.equals(TwrStmt.TWR2.resourceName)) { @@ -246,5 +247,13 @@ } } } + + private JCDiagnostic unwrap(Diagnostic diagnostic) { + if (diagnostic instanceof JCDiagnostic) + return (JCDiagnostic) diagnostic; + if (diagnostic instanceof ClientCodeWrapper.DiagnosticSourceUnwrapper) + return ((ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic).d; + throw new IllegalArgumentException(); + } } } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/annotations/T7043371.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/T7043371.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7043371 + * @summary javac7 fails with NPE during compilation + * @compile T7043371.java + */ + +@interface Anno { + String value(); +} + +class B { + @Anno(value=A.a) + public static final int b = 0; +} + +class A { + @Deprecated + public static final String a = "a"; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/annotations/T7073477.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/T7073477.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7073477 + * @summary NPE in com.sun.tools.javac.code.Symbol$VarSymbol.getConstValue + * @compile T7073477.java + */ + +@SuppressWarnings(T7073477A.S) +class T7073477 { +} + +class T7073477A { + @SuppressWarnings("") + static final String S = ""; +} + diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/api/7086261/T7086261.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/api/7086261/T7086261.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7086261 + * @summary javac doesn't report error as expected, it only reports ClientCodeWrapper$DiagnosticSourceUnwrapper + */ + +import javax.tools.*; + +import com.sun.tools.javac.api.ClientCodeWrapper.DiagnosticSourceUnwrapper; +import com.sun.tools.javac.util.JCDiagnostic; + +import java.net.URI; +import java.util.Arrays; + +import static javax.tools.StandardLocation.*; +import static javax.tools.JavaFileObject.Kind.*; + + +public class T7086261 { + + static class ErroneousSource extends SimpleJavaFileObject { + public ErroneousSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + } + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return "class Test { NonexistentClass c = null; }"; + } + } + + static class DiagnosticChecker implements DiagnosticListener { + public void report(Diagnostic message) { + if (!(message instanceof DiagnosticSourceUnwrapper)) { + throw new AssertionError("Wrapped diagnostic expected!"); + } + String actual = message.toString(); + JCDiagnostic jd = (JCDiagnostic)((DiagnosticSourceUnwrapper)message).d; + String expected = jd.toString(); + if (!actual.equals(expected)) { + throw new AssertionError("expected = " + expected + "\nfound = " + actual); + } + } + }; + + void test() throws Throwable { + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + JavaFileManager jfm = javac.getStandardFileManager(null, null, null); + JavaCompiler.CompilationTask task = + javac.getTask(null, jfm, new DiagnosticChecker(), null, null, Arrays.asList(new ErroneousSource())); + task.call(); + } + + public static void main(String[] args) throws Throwable { + new T7086261().test(); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/api/T6397104.java --- a/test/tools/javac/api/T6397104.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/api/T6397104.java Tue May 29 00:27:58 2012 +0100 @@ -26,10 +26,10 @@ * @bug 6397104 * @summary JSR 199: JavaFileManager.getFileForOutput should have sibling argument * @author Peter von der Ah\u00e9 - * @ignore this test should be rewritten when fixing 6473901 */ import java.io.File; +import java.net.URI; import java.util.Arrays; import javax.tools.*; import javax.tools.JavaFileManager.Location; @@ -52,10 +52,14 @@ : fm.getJavaFileObjectsFromFiles(Arrays.asList(siblingFile)).iterator().next(); FileObject fileObject = fm.getFileForOutput(location, "java.lang", relName, sibling); - if (!fileObject.toUri().getPath().equals(expectedPath)) - throw new AssertionError("Expected " + expectedPath + - ", got " + fileObject.toUri().getPath()); - System.out.format("OK: (%s, %s) => %s%n", siblingFile, relName, fileObject.toUri()); + + File expectedFile = new File(expectedPath).getCanonicalFile(); + File fileObjectFile = new File(fileObject.toUri()).getCanonicalFile(); + + if (!fileObjectFile.equals(expectedFile)) + throw new AssertionError("Expected " + expectedFile + + ", got " + fileObjectFile); + System.out.format("OK: (%s, %s) => %s%n", siblingFile, relName, fileObjectFile); } void test(boolean hasLocation, File siblingFile, String relName, String expectedPath) diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/api/T6838467.java --- a/test/tools/javac/api/T6838467.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/api/T6838467.java Tue May 29 00:27:58 2012 +0100 @@ -32,7 +32,6 @@ import java.util.zip.*; import javax.tools.*; import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.main.OptionName; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Options; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/api/TestGetScope.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/api/TestGetScope.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7090249 + * @summary IllegalStateException from Trees.getScope when called from JSR 199 + */ + +import com.sun.source.tree.IdentifierTree; +import java.io.File; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +import com.sun.source.util.JavacTask; +import com.sun.source.util.TreePath; +import com.sun.source.util.TreePathScanner; +import com.sun.source.util.Trees; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; + +@SupportedAnnotationTypes("*") +public class TestGetScope extends AbstractProcessor { + public static void main(String... args) { + new TestGetScope().run(); + } + + public void run() { + File srcDir = new File(System.getProperty("test.src")); + File thisFile = new File(srcDir, getClass().getName() + ".java"); + + JavaCompiler c = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = c.getStandardFileManager(null, null, null); + + List opts = Arrays.asList("-proc:only", "-doe"); + Iterable files = fm.getJavaFileObjects(thisFile); + JavacTask t = (JavacTask) c.getTask(null, fm, null, opts, null, files); + t.setProcessors(Collections.singleton(this)); + boolean ok = t.call(); + if (!ok) + throw new Error("compilation failed"); + } + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + Trees trees = Trees.instance(processingEnv); + if (round++ == 0) { + for (Element e: roundEnv.getRootElements()) { + TreePath p = trees.getPath(e); + new Scanner().scan(p, trees); + } + } + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + int round; + + static class Scanner extends TreePathScanner { + @Override + public Void visitIdentifier(IdentifierTree t, Trees trees) { + System.err.println("visitIdentifier: " + t); + trees.getScope(getCurrentPath()); + return null; + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/api/TestJavacTaskScanner.java --- a/test/tools/javac/api/TestJavacTaskScanner.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/api/TestJavacTaskScanner.java Tue May 29 00:27:58 2012 +0100 @@ -32,6 +32,7 @@ import com.sun.tools.javac.api.JavacTaskImpl; import com.sun.tools.javac.parser.*; +import com.sun.tools.javac.parser.Tokens.Token; import com.sun.tools.javac.util.*; import java.io.*; import java.net.*; @@ -93,7 +94,7 @@ check(numTokens, "#Tokens", 1222); check(numParseTypeElements, "#parseTypeElements", 136); - check(numAllMembers, "#allMembers", 67); + check(numAllMembers, "#allMembers", 52); } void check(int value, String name, int expected) { @@ -206,7 +207,8 @@ public void nextToken() { super.nextToken(); - System.err.format("Saw token %s (%s)%n", token(), name()); + Token tk = token(); + System.err.format("Saw token %s %n", tk.kind); test.numTokens++; } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/api/TestOperators.java --- a/test/tools/javac/api/TestOperators.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/api/TestOperators.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6338064 6346249 6340951 6392177 * @summary Tree API: can't determine kind of operator * @author Peter von der Ah\u00e9 - * @compile TestOperators.java + * @library ../lib + * @build JavacTestingAbstractProcessor TestOperators * @compile -processor TestOperators -proc:only TestOperators.java */ @@ -46,7 +47,7 @@ } @SupportedAnnotationTypes("TestMe") -public class TestOperators extends AbstractProcessor { +public class TestOperators extends JavacTestingAbstractProcessor { @TestMe(POSTFIX_INCREMENT) public int test_POSTFIX_INCREMENT(int i) { @@ -299,7 +300,7 @@ final Trees trees = Trees.instance(processingEnv); final Messager log = processingEnv.getMessager(); final Elements elements = processingEnv.getElementUtils(); - class Scan extends ElementScanner7 { + class Scan extends ElementScanner { @Override public Void visitExecutable(ExecutableElement e, Void p) { Object debug = e; // info for exception handler @@ -343,5 +344,4 @@ } return true; } - } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/api/taskListeners/TestSimpleAddRemove.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/api/taskListeners/TestSimpleAddRemove.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,351 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7093891 + * @summary support multiple task listeners + */ + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.EnumMap; +import java.util.List; +import java.util.Set; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.element.TypeElement; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +import com.sun.source.util.JavacTask; +import com.sun.source.util.TaskEvent; +import com.sun.source.util.TaskListener; +import com.sun.tools.javac.api.JavacTool; + +public class TestSimpleAddRemove { + enum AddKind { + SET_IN_TASK, + ADD_IN_TASK, + ADD_IN_PROCESSOR, + ADD_IN_LISTENER; + } + + enum RemoveKind { + REMOVE_IN_TASK, + REMOVE_IN_PROCESSOR, + REMOVE_IN_LISTENER, + } + + enum CompileKind { + CALL { + void run(JavacTask t) { + if (!t.call()) throw new Error("compilation failed"); + } + }, + GENERATE { + void run(JavacTask t) throws IOException { + t.generate(); + } + }; + abstract void run(JavacTask t) throws IOException; + } + + static class EventKindCounter extends EnumMap { + static class Count { + int started; + int finished; + + @Override + public String toString() { + return started + ":" + finished; + } + } + + EventKindCounter() { + super(TaskEvent.Kind.class); + } + + void inc(TaskEvent.Kind k, boolean started) { + Count c = get(k); + if (c == null) + put(k, c = new Count()); + + if (started) + c.started++; + else + c.finished++; + } + } + + static class TestListener implements TaskListener { + EventKindCounter counter; + + TestListener(EventKindCounter c) { + counter = c; + } + + public void started(TaskEvent e) { + counter.inc(e.getKind(), true); + } + + public void finished(TaskEvent e) { + counter.inc(e.getKind(), false); + } + } + + static void addInListener(final JavacTask task, final TaskEvent.Kind kind, final TaskListener listener) { + task.addTaskListener(new TaskListener() { + public void started(TaskEvent e) { + if (e.getKind() == kind) { + task.addTaskListener(listener); + task.removeTaskListener(this); + } + } + + public void finished(TaskEvent e) { } + }); + } + + static void removeInListener(final JavacTask task, final TaskEvent.Kind kind, final TaskListener listener) { + task.addTaskListener(new TaskListener() { + public void started(TaskEvent e) { + if (e.getKind() == kind) { + task.removeTaskListener(listener); + task.removeTaskListener(this); + } + } + + public void finished(TaskEvent e) { } + }); + } + + @SupportedAnnotationTypes("*") + class TestProcessor extends AbstractProcessor { + AddKind ak; + RemoveKind rk; + TaskListener listener; + + TestProcessor(AddKind ak, RemoveKind rk, TaskListener listener) { + this.ak = ak; + this.rk = rk; + this.listener = listener; + } + + int round = 0; + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { +// System.err.println("TestProcessor.process " + roundEnv); + JavacTask task = JavacTask.instance(processingEnv); + if (++round == 1) { + switch (ak) { + case ADD_IN_PROCESSOR: + task.addTaskListener(listener); + break; + case ADD_IN_LISTENER: + addInListener(task, TaskEvent.Kind.ANALYZE, listener); + break; + } + } else if (roundEnv.processingOver()) { + switch (rk) { + case REMOVE_IN_PROCESSOR: + task.removeTaskListener(listener); + break; + case REMOVE_IN_LISTENER: + removeInListener(task, TaskEvent.Kind.GENERATE, listener); + break; + } + } + return true; + } + } + + static class TestSource extends SimpleJavaFileObject { + public TestSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return "class Test { }"; + } + } + + public static void main(String... args) throws Exception { + new TestSimpleAddRemove().run(); + } + + JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + + void run() throws Exception { + for (CompileKind ck: CompileKind.values()) { + for (AddKind ak: AddKind.values()) { + for (RemoveKind rk: RemoveKind.values()) { + test(ck, ak, rk); + } + } + } + if (errors > 0) + throw new Exception(errors + " errors occurred"); + } + + void test(CompileKind ck, AddKind ak, RemoveKind rk) throws IOException { + System.err.println("Test: " + ck + " " + ak + " " + rk); + + File tmpDir = new File(ck + "-" + ak + "-" + rk); + tmpDir.mkdirs(); + fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir)); + + List options = new ArrayList(); + Iterable files = Arrays.asList(new TestSource()); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + JavacTask task = tool.getTask(pw, fm, null, options, null, files); + + EventKindCounter ec = new EventKindCounter(); + TaskListener listener = new TestListener(ec); + boolean needProcessor = false; + + switch (ak) { + case SET_IN_TASK: + task.setTaskListener(listener); + break; + case ADD_IN_TASK: + task.addTaskListener(listener); + break; + case ADD_IN_PROCESSOR: + case ADD_IN_LISTENER: + needProcessor = true; + } + + switch (rk) { + case REMOVE_IN_TASK: + task.removeTaskListener(listener); + break; + case REMOVE_IN_PROCESSOR: + case REMOVE_IN_LISTENER: + needProcessor = true; + } + + if (needProcessor) + task.setProcessors(Arrays.asList(new TestProcessor(ak, rk, listener))); + + ck.run(task); + System.err.println(ec); + + check(ck, ak, rk, ec); + + System.err.println(); + } + + void check(CompileKind ck, AddKind ak, RemoveKind rk, EventKindCounter ec) { + // All results should be independent of ck, so we can ignore that + + // Quick way to compare expected values of ec, by comparing ec.toString() + String expect = ec.toString(); + String found; + + switch (ak) { + // Add/set in task should record all events until the listener is removed + case SET_IN_TASK: + case ADD_IN_TASK: + switch (rk) { + case REMOVE_IN_TASK: + // Remove will succeed, meaning no events will be recorded + found = "{}"; + break; + case REMOVE_IN_PROCESSOR: + found = "{PARSE=1:1, ENTER=2:2, ANNOTATION_PROCESSING=1:0, ANNOTATION_PROCESSING_ROUND=2:1}"; + break; + case REMOVE_IN_LISTENER: + found = "{PARSE=1:1, ENTER=3:3, ANALYZE=1:1, GENERATE=1:0, ANNOTATION_PROCESSING=1:1, ANNOTATION_PROCESSING_ROUND=2:2}"; + break; + default: + throw new IllegalStateException(); + } + break; + + // "Add in processor" should skip initial PARSE/ENTER events + case ADD_IN_PROCESSOR: + switch (rk) { + // Remove will fail (too early), so events to end will be recorded + case REMOVE_IN_TASK: + found = "{ENTER=2:2, ANALYZE=1:1, GENERATE=1:1, ANNOTATION_PROCESSING=0:1, ANNOTATION_PROCESSING_ROUND=1:2}"; + break; + case REMOVE_IN_PROCESSOR: + found = "{ENTER=1:1, ANNOTATION_PROCESSING_ROUND=1:1}"; + break; + case REMOVE_IN_LISTENER: + found = "{ENTER=2:2, ANALYZE=1:1, GENERATE=1:0, ANNOTATION_PROCESSING=0:1, ANNOTATION_PROCESSING_ROUND=1:2}"; + break; + default: + throw new IllegalStateException(); + } + break; + + // "Add in listener" will occur during "ANALYSE.started" event + case ADD_IN_LISTENER: + switch (rk) { + // Remove will fail (too early, so events to end will be recorded + case REMOVE_IN_TASK: + case REMOVE_IN_PROCESSOR: + found = "{ANALYZE=0:1, GENERATE=1:1}"; + break; + // Remove will succeed during "GENERATE.finished" event + case REMOVE_IN_LISTENER: + found = "{ANALYZE=0:1, GENERATE=1:0}"; + break; + default: + throw new IllegalStateException(); + } + break; + default: + throw new IllegalStateException(); + } + + if (!found.equals(expect)) { + System.err.println("Expected: " + expect); + System.err.println(" Found: " + found); + error("unexpected value found"); + } + } + + int errors; + + void error(String message) { + System.err.println("Error: " + message); + errors++; + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/apt.sh --- a/test/tools/javac/apt.sh Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -#! /bin/sh -f - -# -# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# Usage: -# @run apt.sh -# -# This script is to run apt for a regression test - -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -CLASSPATH="${TESTCLASSES}${PS}${TESTJAVA}${FS}lib${FS}tools.jar" "${TESTJAVA}${FS}bin${FS}apt" ${TESTTOOLVMOPTS} $* -result=$? - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result - - diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/6270087/T6270087neg.out --- a/test/tools/javac/cast/6270087/T6270087neg.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/cast/6270087/T6270087neg.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6270087neg.java:36:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6270087neg.Foo, T6270087neg.Foo +T6270087neg.java:36:29: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6270087neg.Foo, T6270087neg.Foo) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/6557182/T6557182.out --- a/test/tools/javac/cast/6557182/T6557182.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/cast/6557182/T6557182.out Tue May 29 00:27:58 2012 +0100 @@ -1,4 +1,4 @@ -T6557182.java:12:56: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T, java.lang.Comparable +T6557182.java:12:56: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T, java.lang.Comparable) T6557182.java:16:56: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), T, java.lang.Comparable 1 error 1 warning diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/6665356/T6665356.out --- a/test/tools/javac/cast/6665356/T6665356.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/cast/6665356/T6665356.out Tue May 29 00:27:58 2012 +0100 @@ -1,8 +1,8 @@ -T6665356.java:31:55: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner -T6665356.java:35:58: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner -T6665356.java:39:65: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner -T6665356.java:43:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner -T6665356.java:47:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner -T6665356.java:51:55: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner -T6665356.java:55:58: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner +T6665356.java:31:55: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6665356.Outer.Inner, T6665356.Outer.Inner) +T6665356.java:35:58: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6665356.Outer.Inner, T6665356.Outer.Inner) +T6665356.java:39:65: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6665356.Outer.Inner, T6665356.Outer.Inner) +T6665356.java:43:57: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6665356.Outer.Inner, T6665356.Outer.Inner) +T6665356.java:47:60: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6665356.Outer.Inner, T6665356.Outer.Inner) +T6665356.java:51:55: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6665356.Outer.Inner, T6665356.Outer.Inner) +T6665356.java:55:58: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6665356.Outer.Inner, T6665356.Outer.Inner) 7 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/6795580/T6795580.out --- a/test/tools/javac/cast/6795580/T6795580.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/cast/6795580/T6795580.out Tue May 29 00:27:58 2012 +0100 @@ -1,8 +1,8 @@ -T6795580.java:31:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] -T6795580.java:35:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] -T6795580.java:39:67: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] -T6795580.java:43:59: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] -T6795580.java:47:62: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] -T6795580.java:51:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] -T6795580.java:55:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:31:57: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6795580.Outer.Inner[], T6795580.Outer.Inner[]) +T6795580.java:35:60: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6795580.Outer.Inner[], T6795580.Outer.Inner[]) +T6795580.java:39:67: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6795580.Outer.Inner[], T6795580.Outer.Inner[]) +T6795580.java:43:59: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6795580.Outer.Inner[], T6795580.Outer.Inner[]) +T6795580.java:47:62: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6795580.Outer.Inner[], T6795580.Outer.Inner[]) +T6795580.java:51:57: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6795580.Outer.Inner[], T6795580.Outer.Inner[]) +T6795580.java:55:60: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6795580.Outer.Inner[], T6795580.Outer.Inner[]) 7 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/6932571/T6932571neg.out --- a/test/tools/javac/cast/6932571/T6932571neg.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/cast/6932571/T6932571neg.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6932571neg.java:39:19: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6932571neg.S, G +T6932571neg.java:39:19: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T6932571neg.S, G) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7005095/T7005095neg.out --- a/test/tools/javac/cast/7005095/T7005095neg.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/cast/7005095/T7005095neg.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T7005095neg.java:13:25: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T7005095pos.FooImpl, T7005095pos.Foo +T7005095neg.java:13:25: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: T7005095pos.FooImpl, T7005095pos.Foo) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7005671/T7005671.out --- a/test/tools/javac/cast/7005671/T7005671.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/cast/7005671/T7005671.out Tue May 29 00:27:58 2012 +0100 @@ -1,17 +1,17 @@ -T7005671.java:12:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), byte[], X[] -T7005671.java:13:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), short[], X[] -T7005671.java:14:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), int[], X[] -T7005671.java:15:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), long[], X[] -T7005671.java:16:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), float[], X[] -T7005671.java:17:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), double[], X[] -T7005671.java:18:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), char[], X[] -T7005671.java:19:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), boolean[], X[] -T7005671.java:23:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], byte[] -T7005671.java:24:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], short[] -T7005671.java:25:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], int[] -T7005671.java:26:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], long[] -T7005671.java:27:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], float[] -T7005671.java:28:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], double[] -T7005671.java:29:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], char[] -T7005671.java:30:32: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], boolean[] +T7005671.java:12:26: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: byte[], X[]) +T7005671.java:13:26: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: short[], X[]) +T7005671.java:14:26: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: int[], X[]) +T7005671.java:15:26: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: long[], X[]) +T7005671.java:16:26: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: float[], X[]) +T7005671.java:17:26: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: double[], X[]) +T7005671.java:18:26: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: char[], X[]) +T7005671.java:19:26: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: boolean[], X[]) +T7005671.java:23:29: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: X[], byte[]) +T7005671.java:24:30: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: X[], short[]) +T7005671.java:25:28: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: X[], int[]) +T7005671.java:26:29: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: X[], long[]) +T7005671.java:27:30: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: X[], float[]) +T7005671.java:28:31: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: X[], double[]) +T7005671.java:29:29: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: X[], char[]) +T7005671.java:30:32: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: X[], boolean[]) 16 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7123100/T7123100a.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/cast/7123100/T7123100a.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,16 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7123100 + * @summary javac fails with java.lang.StackOverflowError + * @compile/fail/ref=T7123100a.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100a.java + */ + +class T7123100a { + > E m() { + return null; + } + + void test() { + Z z = (Z)m(); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7123100/T7123100a.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/cast/7123100/T7123100a.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,4 @@ +T7123100a.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), E, Z +- compiler.err.warnings.and.werror +1 error +1 warning diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7123100/T7123100b.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/cast/7123100/T7123100b.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,12 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7123100 + * @summary javac fails with java.lang.StackOverflowError + * @compile/fail/ref=T7123100b.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100b.java + */ + +class T7123100b { + void test(Enum e) { + Z z = (Z)e; + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7123100/T7123100b.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/cast/7123100/T7123100b.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,4 @@ +T7123100b.java:10:18: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Enum, Z +- compiler.err.warnings.and.werror +1 error +1 warning diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7123100/T7123100c.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/cast/7123100/T7123100c.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,16 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7123100 + * @summary javac fails with java.lang.StackOverflowError + * @compile/fail/ref=T7123100c.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100c.java + */ + +class T7123100c { + E m(E e) { + return null; + } + + void test(Enum e) { + Z z = (Z)m(e); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7123100/T7123100c.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/cast/7123100/T7123100c.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,4 @@ +T7123100c.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Enum, Z +- compiler.err.warnings.and.werror +1 error +1 warning diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7123100/T7123100d.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/cast/7123100/T7123100d.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,16 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7123100 + * @summary javac fails with java.lang.StackOverflowError + * @compile/fail/ref=T7123100d.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100d.java + */ + +class T7123100d { + > E m(Enum e) { + return null; + } + + void test(Enum e) { + Z z = (Z)m(e); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7123100/T7123100d.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/cast/7123100/T7123100d.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,4 @@ +T7123100d.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), compiler.misc.type.captureof: 1, ?, Z +- compiler.err.warnings.and.werror +1 error +1 warning diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7126754/T7126754.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/cast/7126754/T7126754.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,14 @@ +/* + * @test /nodynamiccopyright/ + * @author mcimadamore + * @bug 7005671 + * @summary Generics compilation failure casting List to List + * @compile/fail/ref=T7126754.out -Xlint:unchecked -Werror -XDrawDiagnostics T7126754.java + */ + +import java.util.List; + +class T7126754 { + List> c = null; + List> d = (List>)c; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/cast/7126754/T7126754.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/cast/7126754/T7126754.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,4 @@ +T7126754.java:13:68: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.util.List>, java.util.List> +- compiler.err.warnings.and.werror +1 error +1 warning diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/classfiles/ClassVersionChecker.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/classfiles/ClassVersionChecker.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7157626 + * @summary Test major version for all legal combinations for -source and -target + * @author sgoel + * + */ + +import java.io.*; +import java.nio.*; +import java.util.*; +import java.util.regex.*; + +public class ClassVersionChecker { + + int errors; + String[] jdk = {"","1.2","1.3","1.4","1.5","1.6","1.7","1.8"}; + File javaFile = null; + + public static void main(String[] args) throws Throwable { + new ClassVersionChecker().run(); + } + + void run() throws Exception { + writeTestFile(); + /* Rules applicable for -source and -target combinations + * 1. If both empty, version num is for 1.7 + * 2. If source is not empty and target is empty, version is based on source + * 3. If both non-empty, version is based on target + */ + + /* -source (0=>empty,1=>1.2,...) X -target (0=>empty,1=>1.2,...) + * ver[0][0] => no -source or -target was given + * -1 => invalid combinations + */ + int[][] ver = + {{51, -1, -1, -1, -1, -1, -1, -1}, + {48, 46, 47, 48, 49, 50, 51, 51}, + {48, 46, 47, 48, 49, 50, 51, 51}, + {48, -1, -1, 48, 49, 50, 51, 51}, + {51, -1, -1, -1, 49, 50, 51, 51}, + {51, -1, -1, -1, -1, 50, 51, 51}, + {51, -1, -1, -1, -1, -1, 51, 51}, + {51, -1, -1, -1, -1, -1, -1, 51}}; + + // Loop to run all possible combinations of source/target values + for (int i = 0; i< ver.length; i++) { + for (int j = 0 ; j< ver[i].length; j++) { + if(ver[i][j] != -1) { + logMsg("Index values for i = " + i + " j = " + j); + logMsg("Running for src = " + jdk[i] + " target = "+jdk[j] +" expected = " + ver[i][j]); + test(i,j, ver[i][j]); + } + } + } + + if (errors > 0) + throw new Exception(errors + " errors found"); + } + + void test (int i, int j, int expected) { + File classFile = compileTestFile(i, j, javaFile); + short majorVer = getMajorVersion(classFile); + checkVersion(majorVer, expected); + } + + void writeTestFile() throws IOException { + javaFile = new File("Test.java"); + try(PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(javaFile)));) { + out.println("class Test { "); + out.println(" public void foo() { }"); + out.println("}"); + } catch (IOException ioe) { + error("IOException while creating Test.java" + ioe); + } + } + + File compileTestFile(int i , int j, File f) { + int rc = -1; + // Src and target are empty + if (i == 0 && j == 0 ) { + rc = compile("-g", f.getPath()); + } else if( j == 0 ) { // target is empty + rc = compile("-source", jdk[i], "-g", f.getPath()); + } else { + rc = compile("-source", jdk[i], "-target", jdk[j], "-g", f.getPath()); + } + if (rc != 0) + throw new Error("compilation failed. rc=" + rc); + String path = f.getPath(); + return new File(path.substring(0, path.length() - 5) + ".class"); + } + + int compile(String... args) { + return com.sun.tools.javac.Main.compile(args); + } + + void logMsg (String str) { + System.out.println(str); + } + + short getMajorVersion(File f) { + List args = new ArrayList(); + short majorVer = 0; + try(DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(f)));) { + in.readInt(); + in.readShort(); + majorVer = in.readShort(); + System.out.println("major version:" + majorVer); + } catch (IOException e) { + error("IOException while reading Test.class" + e); + } + return majorVer; + } + + void checkVersion(short majorVer, int expected) { + if (majorVer != expected ) { + error("versions did not match, Expected: " + expected + "Got: " + majorVer); + } + } + + void error(String msg) { + System.out.println("error: " + msg); + errors++; + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/constDebug/ConstDebug.sh --- a/test/tools/javac/constDebug/ConstDebug.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/constDebug/ConstDebug.sh Tue May 29 00:27:58 2012 +0100 @@ -47,7 +47,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux ) + SunOS | Linux | Darwin ) PS=":" FS="/" ;; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/depDocComment/DeprecatedDocComment3.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/depDocComment/DeprecatedDocComment3.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 7096014 + * @summary Javac tokens should retain state + * @compile -Xlint -Werror DeprecatedDocComment3.java + */ + +class DeprecatedDocComment3 { + static class Foo { } + + ; /** @deprecated */ ; + + static class A {} + + static class B { + A a; //not deprecated! + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/depDocComment/DeprecatedDocComment4.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/depDocComment/DeprecatedDocComment4.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,20 @@ +/** + * @test /nodynamiccopyright/ + * @bug 7104201 + * @summary Refactor DocCommentScanner + * @compile/fail/ref=DeprecatedDocComment4.out -XDrawDiagnostics -Werror -Xlint:dep-ann DeprecatedDocComment4.java + */ + +class DeprecatedDocComment4 { + /** @deprecated **/ + /* block */ + void test1() {}; + + /** @deprecated **/ + /** double javadoc */ + void test2() {}; + + /** @deprecated **/ + //line comment + void test3() {}; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/depDocComment/DeprecatedDocComment4.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/depDocComment/DeprecatedDocComment4.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,6 @@ +DeprecatedDocComment4.java:11:10: compiler.warn.missing.deprecated.annotation +DeprecatedDocComment4.java:15:10: compiler.warn.missing.deprecated.annotation +DeprecatedDocComment4.java:19:10: compiler.warn.missing.deprecated.annotation +- compiler.err.warnings.and.werror +1 error +3 warnings diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/ArgTypeCompilerFactory.java --- a/test/tools/javac/diags/ArgTypeCompilerFactory.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/ArgTypeCompilerFactory.java Tue May 29 00:27:58 2012 +0100 @@ -35,7 +35,7 @@ import com.sun.tools.javac.file.*; import com.sun.tools.javac.main.Main; import com.sun.tools.javac.main.JavaCompiler; -import com.sun.tools.javac.parser.Token; +import com.sun.tools.javac.parser.Tokens.TokenKind; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration; import javax.lang.model.SourceVersion; @@ -105,13 +105,11 @@ Iterable fos = fm.getJavaFileObjectsFromFiles(files); - JavacTaskImpl t = (JavacTaskImpl) tool.getTask(out, fm, null, opts, null, fos); - Context c = t.getContext(); + Context c = new Context(); ArgTypeMessages.preRegister(c); ArgTypeJavaCompiler.preRegister(c); - Boolean ok = t.call(); - - return ok; + JavacTaskImpl t = (JavacTaskImpl) tool.getTask(out, fm, null, opts, null, fos, c); + return t.call(); } } @@ -146,9 +144,9 @@ JavacFileManager.preRegister(c); // can't create it until Log has been set up ArgTypeJavaCompiler.preRegister(c); ArgTypeMessages.preRegister(c); - int result = main.compile(args.toArray(new String[args.size()]), c); + Main.Result result = main.compile(args.toArray(new String[args.size()]), c); - return (result == 0); + return result.isOK(); } } @@ -172,10 +170,10 @@ JavacFileManager.preRegister(c); // can't create it until Log has been set up ArgTypeJavaCompiler.preRegister(c); ArgTypeMessages.preRegister(c); - com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", out); - int rc = m.compile(args.toArray(new String[args.size()]), c); + Main m = new Main("javac", out); + Main.Result result = m.compile(args.toArray(new String[args.size()]), c); - return (rc == 0); + return result.isOK(); } } @@ -319,7 +317,7 @@ return "modifier"; if (o instanceof KindName) return "symbol kind"; - if (o instanceof Token) + if (o instanceof TokenKind) return "token"; if (o instanceof Symbol) return "symbol"; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/CheckExamples.java --- a/test/tools/javac/diags/CheckExamples.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/CheckExamples.java Tue May 29 00:27:58 2012 +0100 @@ -23,10 +23,13 @@ /* * @test - * @bug 6968063 + * @bug 6968063 7127924 * @summary provide examples of code that generate diagnostics * @build Example CheckExamples - * @run main CheckExamples + * @run main/othervm CheckExamples + */ +/* + * See CR 7127924 for info on why othervm is used. */ import java.io.*; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/CheckResourceKeys.java --- a/test/tools/javac/diags/CheckResourceKeys.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/CheckResourceKeys.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -259,6 +259,7 @@ "application.home", // in Paths.java "env.class.path", "line.separator", + "os.name", "user.dir", // file names "ct.sym", diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/Example.java --- a/test/tools/javac/diags/Example.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/Example.java Tue May 29 00:27:58 2012 +0100 @@ -21,10 +21,12 @@ * questions. */ -import com.sun.tools.javac.file.JavacFileManager; import java.io.*; +import java.net.URL; +import java.net.URLClassLoader; import java.util.*; import java.util.regex.*; +import javax.annotation.processing.Processor; import javax.tools.Diagnostic; import javax.tools.DiagnosticCollector; import javax.tools.JavaCompiler; @@ -37,12 +39,12 @@ // import com.sun.tools.javac.Main // import com.sun.tools.javac.main.Main +import com.sun.tools.javac.api.ClientCodeWrapper; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.main.Main; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.JavacMessages; import com.sun.tools.javac.util.JCDiagnostic; -import java.net.URL; -import java.net.URLClassLoader; -import javax.annotation.processing.Processor; /** * Class to handle example code designed to illustrate javac diagnostic messages. @@ -397,7 +399,7 @@ if (keys != null) { for (Diagnostic d: dc.getDiagnostics()) { - scanForKeys((JCDiagnostic) d, keys); + scanForKeys(unwrap(d), keys); } } @@ -418,6 +420,14 @@ for (JCDiagnostic sd: d.getSubdiagnostics()) scanForKeys(sd, keys); } + + private JCDiagnostic unwrap(Diagnostic diagnostic) { + if (diagnostic instanceof JCDiagnostic) + return (JCDiagnostic) diagnostic; + if (diagnostic instanceof ClientCodeWrapper.DiagnosticSourceUnwrapper) + return ((ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic).d; + throw new IllegalArgumentException(); + } } /** @@ -506,14 +516,14 @@ Context c = new Context(); JavacFileManager.preRegister(c); // can't create it until Log has been set up MessageTracker.preRegister(c, keys); - com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", pw); - int rc = m.compile(args.toArray(new String[args.size()]), c); + Main m = new Main("javac", pw); + Main.Result rc = m.compile(args.toArray(new String[args.size()]), c); if (keys != null) { pw.close(); } - return (rc == 0); + return rc.isOK(); } static class MessageTracker extends JavacMessages { diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/MessageInfo.java --- a/test/tools/javac/diags/MessageInfo.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/MessageInfo.java Tue May 29 00:27:58 2012 +0100 @@ -23,10 +23,13 @@ /** * @test - * @bug 7013272 + * @bug 7013272 7127924 * @summary Automatically generate info about how compiler resource keys are used * @build Example ArgTypeCompilerFactory MessageFile MessageInfo - * @run main MessageInfo + * @run main/othervm MessageInfo + */ +/* + * See CR 7127924 for info on why othervm is used. */ import java.io.*; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/RunExamples.java --- a/test/tools/javac/diags/RunExamples.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/RunExamples.java Tue May 29 00:27:58 2012 +0100 @@ -23,10 +23,13 @@ /** * @test - * @bug 6968063 + * @bug 6968063 7127924 * @summary provide examples of code that generate diagnostics * @build ArgTypeCompilerFactory Example HTMLWriter RunExamples - * @run main RunExamples + * @run main/othervm RunExamples + */ +/* + * See CR 7127924 for info on why othervm is used. */ import java.io.*; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples.not-yet.txt --- a/test/tools/javac/diags/examples.not-yet.txt Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples.not-yet.txt Tue May 29 00:27:58 2012 +0100 @@ -1,8 +1,6 @@ compiler.err.already.annotated # internal compiler error? compiler.err.already.defined.this.unit # seems to be masked by compiler.err.duplicate.class compiler.err.annotation.value.not.allowable.type # cannot happen: precluded by complete type-specific tests -compiler.err.assignment.from.super-bound # DEAD -compiler.err.assignment.to.extends-bound # DEAD compiler.err.cant.apply.symbol compiler.err.cant.read.file # (apt.JavaCompiler?) compiler.err.cant.select.static.class.from.param.type @@ -24,7 +22,6 @@ compiler.err.no.encl.instance.of.type.in.scope # cannot occur; always followed by assert false; compiler.err.no.match.entry # UNUSED? compiler.err.not.annotation.type # cannot occur given preceding checkType -compiler.err.prob.found.req.1 # Check: DEAD, in unused method compiler.err.proc.bad.config.file # JavacProcessingEnvironment compiler.err.proc.cant.access # completion failure compiler.err.proc.cant.access.1 # completion failure, no stack trace @@ -38,12 +35,8 @@ compiler.err.stack.sim.error compiler.err.type.var.more.than.once # UNUSED compiler.err.type.var.more.than.once.in.result # UNUSED -compiler.err.undetermined.type compiler.err.unexpected.type compiler.err.unsupported.cross.fp.lit # Scanner: host system dependent -compiler.err.wrong.target.for.polymorphic.signature.definition # Transitional 292 -compiler.misc.assignment.from.super-bound -compiler.misc.assignment.to.extends-bound compiler.misc.bad.class.file.header # bad class file compiler.misc.bad.class.signature # bad class file compiler.misc.bad.const.pool.tag # bad class file @@ -60,7 +53,7 @@ compiler.misc.fatal.err.cant.locate.ctor # Resolve, from Lower compiler.misc.fatal.err.cant.locate.field # Resolve, from Lower compiler.misc.fatal.err.cant.locate.meth # Resolve, from Lower -compiler.misc.fatal.err.cant.close.loader # JavacProcessingEnvironment +compiler.misc.fatal.err.cant.close # JavaCompiler compiler.misc.file.does.not.contain.package compiler.misc.illegal.start.of.class.file compiler.misc.kindname.annotation @@ -85,10 +78,8 @@ compiler.misc.type.captureof.1 compiler.misc.type.none compiler.misc.type.req.exact -compiler.misc.type.variable.has.undetermined.type compiler.misc.unable.to.access.file # ClassFile compiler.misc.undecl.type.var # ClassReader -compiler.misc.undetermined.type compiler.misc.unicode.str.not.supported # ClassReader compiler.misc.verbose.retro # UNUSED compiler.misc.verbose.retro.with # UNUSED diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/AlreadyDefinedClinit.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/AlreadyDefinedClinit.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.already.defined.in.clinit + +class AlreadyDefinedClinit { + static { + int i; + int i; + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/ApplicableMethodFound.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/ApplicableMethodFound.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.misc.applicable.method.found +// key: compiler.note.verbose.resolve.multi +// options: -XDverboseResolution=applicable,success + +class ApplicableMethodFound { + + void m() {} + + { m(); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/ApplicableMethodFound1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/ApplicableMethodFound1.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.misc.applicable.method.found.1 +// key: compiler.note.verbose.resolve.multi +// key: compiler.misc.full.inst.sig +// options: -XDverboseResolution=applicable,success + +class ApplicableMethodFound1 { + + void m(X x) {} + + { m(1); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/CannotCreateArrayWithDiamond.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/CannotCreateArrayWithDiamond.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.cannot.create.array.with.diamond + +class CannotCreateArrayWithDiamond { + Object[] array = new Object<>[3]; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/CantApplyDiamond1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/CantApplyDiamond1.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.prob.found.req.1 +// key: compiler.misc.cant.apply.diamond.1 +// key: compiler.misc.no.conforming.assignment.exists +// key: compiler.misc.diamond + +class CantApplyDiamond1 { + + CantApplyDiamond1(CantApplyDiamond1 lz) { } + + void test(CantApplyDiamond1 li) { + CantApplyDiamond1 ls = new CantApplyDiamond1<>(li); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/CatchWithoutTry.java --- a/test/tools/javac/diags/examples/CatchWithoutTry.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/CatchWithoutTry.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ // key: compiler.err.catch.without.try // key: compiler.err.expected -// key: compiler.err.not.stmt class CatchWithoutTry { void m() { diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/DeferredMethodInst.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/DeferredMethodInst.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.misc.applicable.method.found.1 +// key: compiler.note.verbose.resolve.multi +// key: compiler.note.deferred.method.inst +// key: compiler.misc.partial.inst.sig +// options: -XDverboseResolution=applicable,success,deferred-inference + +class DeferredMethodInst { + + X m() { return null; } + + { Integer i = m(); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/EmptyCharLiteral.java --- a/test/tools/javac/diags/examples/EmptyCharLiteral.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/EmptyCharLiteral.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ // key: compiler.err.empty.char.lit // key: compiler.err.unclosed.char.lit -// key: compiler.err.expected // key: compiler.err.premature.eof class X { diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/ForeachBadInitialization.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/ForeachBadInitialization.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.bad.initializer +import java.util.List; +class ForeachBadInitialization { + void m() { + List s = null; + for (a : s) {} + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/FullInstSig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/FullInstSig.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.misc.applicable.method.found.1 +// key: compiler.note.verbose.resolve.multi +// key: compiler.misc.full.inst.sig +// options: -XDverboseResolution=applicable,success + +class FullInstSig { + + void m(X x) {} + + { m(1); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/IllegalChar.java --- a/test/tools/javac/diags/examples/IllegalChar.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/IllegalChar.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,5 +24,5 @@ // key: compiler.err.illegal.char class IllegalChar { - int i = #; + int i = `; } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/IllegalDot.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/IllegalDot.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.illegal.dot +// key: compiler.err.expected +// key: compiler.err.illegal.start.of.type + +class X { + void m(Object.. args) { } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/IllegalStartOfStmt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/IllegalStartOfStmt.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.illegal.start.of.stmt +// key: compiler.err.expected3 + +class IllegalStartOfStmt { + void m() { + if (true) } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/IncompatibleTypes1.java --- a/test/tools/javac/diags/examples/IncompatibleTypes1.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/IncompatibleTypes1.java Tue May 29 00:27:58 2012 +0100 @@ -21,14 +21,13 @@ * questions. */ -// key: compiler.misc.incompatible.types.1 // key: compiler.misc.infer.no.conforming.instance.exists -// key: compiler.err.prob.found.req +// key: compiler.err.prob.found.req.1 class IncompatibleTypes1 { - IncompatibleTypes1 m() { + IncompatibleTypes1 m() { return null; } - IncompatibleTypes1 o = m(); + IncompatibleTypes1 o = m(); } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/IncompatibleUpperBounds.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/IncompatibleUpperBounds.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +//key: compiler.err.cant.apply.symbols +//key: compiler.misc.inapplicable.method +//key: compiler.misc.arg.length.mismatch +//key: compiler.misc.incompatible.upper.bounds + +import java.util.List; + +class IncompatibleUpperBounds { + void m(List s1, List s2) { } + void m(Object o) {} + + void test(List li, List ls) { + m(li, ls); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/InconvertibleTypes.java --- a/test/tools/javac/diags/examples/InconvertibleTypes.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/InconvertibleTypes.java Tue May 29 00:27:58 2012 +0100 @@ -22,7 +22,7 @@ */ // key: compiler.misc.inconvertible.types -// key: compiler.err.prob.found.req +// key: compiler.err.prob.found.req.1 class InconvertibleTypes { class Outer { diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/InferNoConformingAssignment.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/InferNoConformingAssignment.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.infer.no.conforming.assignment.exists + +import java.util.*; + +class InferNoConformingAssignment { + List m(String s) { return null; } + { this.m(1); } +} + diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/InferVarargsArgumentMismatch.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/InferVarargsArgumentMismatch.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.infer.varargs.argument.mismatch + +class InferVarargsArgumentMismatch { + void m(X x1, String... xs) {} + { this.m("", 1); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/InferredDoNotConformToBounds.java --- a/test/tools/javac/diags/examples/InferredDoNotConformToBounds.java Mon Jul 11 22:31:52 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// key: compiler.misc.inferred.do.not.conform.to.bounds -// key: compiler.err.cant.apply.diamond.1 -// key: compiler.misc.diamond - -class InferredDoNotConformToBounds { - static class SuperFoo {} - static class Foo extends SuperFoo { - Foo(X x) {} - } - - SuperFoo sf1 = new Foo<>(""); -} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/InferredDoNotConformToEq.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/InferredDoNotConformToEq.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.inferred.do.not.conform.to.eq.bounds + +import java.util.*; + +class InferredDoNotConformToEq { + void m(List lx1, List lx2) {} + { this.m(Arrays.asList(""), Arrays.asList(1)); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/InferredDoNotConformToLower.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/InferredDoNotConformToLower.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.misc.invalid.inferred.types +// key: compiler.err.prob.found.req.1 +// key: compiler.misc.inferred.do.not.conform.to.lower.bounds + +import java.util.*; + +class InferredDoNotConformToLower { + List m() { return null; } + { List lss = this.m(); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/InferredDoNotConformToUpper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/InferredDoNotConformToUpper.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.inferred.do.not.conform.to.upper.bounds + +import java.util.*; + +class InferredDoNotConformToUpper { + void m(X x, List lx) {} + { this.m("", Arrays.asList(1)); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/InvalidInferredTypes.java --- a/test/tools/javac/diags/examples/InvalidInferredTypes.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/InvalidInferredTypes.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,18 +21,17 @@ * questions. */ -// key: compiler.err.invalid.inferred.types -// key: compiler.misc.inferred.do.not.conform.to.bounds +// key: compiler.err.prob.found.req.1 +// key: compiler.misc.invalid.inferred.types +// key: compiler.misc.inferred.do.not.conform.to.upper.bounds import java.util.*; class InvalidInferredTypes { - > T makeList() { - return null; - } + List m() { return null; } - public void test() { - List l = makeList(); + void test() { + List li = m(); } } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/KindnameInstanceInit.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/KindnameInstanceInit.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.already.defined.in.clinit +// key: compiler.misc.kindname.instance.init +// key: compiler.misc.kindname.class +// key: compiler.misc.kindname.variable +// key: compiler.misc.count.error +// key: compiler.err.error +// run: backdoor + +class KindnameInstanceInit { + { + int i; + int i; + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/KindnameStaticInit.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/KindnameStaticInit.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.already.defined.in.clinit +// key: compiler.misc.kindname.static.init +// key: compiler.misc.kindname.class +// key: compiler.misc.kindname.variable +// key: compiler.misc.count.error +// key: compiler.err.error +// run: backdoor + +class KindnameStaticInit { + static { + int i; + int i; + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/LambdaNotSupported.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/LambdaNotSupported.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.lambda.not.supported.in.source +// options: -source 7 -Xlint:-options + +class LambdaNotSupported { + S s = ()->{}; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/MethodReferencesNotSupported.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/MethodReferencesNotSupported.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.method.references.not.supported.in.source +// options: -source 7 -Xlint:-options + +class MethodReferencesNotSupported { + S s = A#foo; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/NotAStatement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/NotAStatement.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.not.stmt + +class NotAStatement { + void m() { + x + 1; + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/NotAllowedClass.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/NotAllowedClass.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.class.not.allowed + +class NotAllowedClass { + void t1() { + if (true) + class X {} + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/NotAllowedVariable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/NotAllowedVariable.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.variable.not.allowed + +class NotAllowedVariable { + void t1() { + if (true) + int x = 0; + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/NotApplicableMethodFound.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/NotApplicableMethodFound.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.misc.not.applicable.method.found +// key: compiler.note.verbose.resolve.multi.1 +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.no.conforming.assignment.exists +// options: -XDverboseResolution=inapplicable,failure + +class NotApplicableMethodFound { + + void m(int i) {} + + { m(""); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/PartialInstSig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/PartialInstSig.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.misc.applicable.method.found.1 +// key: compiler.note.verbose.resolve.multi +// key: compiler.misc.partial.inst.sig +// options: -XDverboseResolution=applicable,success + +class PartialInstSig { + + X m() { return null; } + + { m(); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/PossibleLossPrecision.java --- a/test/tools/javac/diags/examples/PossibleLossPrecision.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/PossibleLossPrecision.java Tue May 29 00:27:58 2012 +0100 @@ -22,7 +22,7 @@ */ // key: compiler.misc.possible.loss.of.precision -// key: compiler.err.prob.found.req +// key: compiler.err.prob.found.req.1 class PossibleLossPrecision { long l; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/ResourceNotApplicableToType.java --- a/test/tools/javac/diags/examples/ResourceNotApplicableToType.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/ResourceNotApplicableToType.java Tue May 29 00:27:58 2012 +0100 @@ -22,7 +22,7 @@ */ // key: compiler.misc.try.not.applicable.to.type -// key: compiler.err.prob.found.req +// key: compiler.err.prob.found.req.1 class ResourceNotApplicableToType { void m() { diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/UndeterminedType1.java --- a/test/tools/javac/diags/examples/UndeterminedType1.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/UndeterminedType1.java Tue May 29 00:27:58 2012 +0100 @@ -21,7 +21,8 @@ * questions. */ -// key: compiler.err.undetermined.type.1 +// key: compiler.err.prob.found.req.1 +// key: compiler.misc.undetermined.type // key: compiler.misc.no.unique.maximal.instance.exists class UndeterminedType1 { diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/UnsupportedEncoding.java --- a/test/tools/javac/diags/examples/UnsupportedEncoding.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/UnsupportedEncoding.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,5 +23,6 @@ // key: compiler.err.unsupported.encoding // options: -encoding UNSUPPORTED -doe +// run: simple class UnsupportedEncoding { } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/VerboseResolveMulti.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/VerboseResolveMulti.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.misc.applicable.method.found +// key: compiler.note.verbose.resolve.multi +// options: -XDverboseResolution=applicable,success + +class VerboseResolveMulti { + + void m() {} + + { m(); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/VerboseResolveMulti1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/VerboseResolveMulti1.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.misc.not.applicable.method.found +// key: compiler.note.verbose.resolve.multi.1 +// key: compiler.err.cant.apply.symbol.1 +// key: compiler.misc.no.conforming.assignment.exists +// options: -XDverboseResolution=inapplicable,failure + +class VerboseResolveMulti1 { + + void m(int i) {} + + { m(""); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/WhereCaptured.java --- a/test/tools/javac/diags/examples/WhereCaptured.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/WhereCaptured.java Tue May 29 00:27:58 2012 +0100 @@ -26,7 +26,7 @@ // key: compiler.misc.where.description.typevar // key: compiler.misc.where.typevar // key: compiler.err.cant.apply.symbol.1 -// key: compiler.misc.infer.no.conforming.assignment.exists +// key: compiler.misc.inferred.do.not.conform.to.eq.bounds // key: compiler.misc.captured.type // options: -XDdiags=where,simpleNames // run: simple diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/WhereCaptured1.java --- a/test/tools/javac/diags/examples/WhereCaptured1.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/WhereCaptured1.java Tue May 29 00:27:58 2012 +0100 @@ -26,7 +26,7 @@ // key: compiler.misc.where.description.typevar // key: compiler.misc.where.typevar // key: compiler.err.cant.apply.symbol.1 -// key: compiler.misc.infer.no.conforming.assignment.exists +// key: compiler.misc.inferred.do.not.conform.to.eq.bounds // key: compiler.misc.captured.type // key: compiler.misc.type.null // options: -XDdiags=where,simpleNames diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/WhereFreshTvar.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/WhereFreshTvar.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.misc.where.fresh.typevar +// key: compiler.misc.where.description.typevar.1 +// key: compiler.misc.where.typevar +// key: compiler.misc.invalid.inferred.types +// key: compiler.err.prob.found.req.1 +// key: compiler.misc.inferred.do.not.conform.to.upper.bounds +// options: -XDdiags=where,simpleNames +// run: simple + +import java.util.*; + +class WhereFreshTvar { + > T m() {} + + { List ls = m(); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/diags/examples/WhereIntersection.java --- a/test/tools/javac/diags/examples/WhereIntersection.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/diags/examples/WhereIntersection.java Tue May 29 00:27:58 2012 +0100 @@ -24,7 +24,6 @@ // key: compiler.misc.where.intersection // key: compiler.misc.where.description.intersection // key: compiler.misc.intersection.type -// key: compiler.misc.incompatible.types // key: compiler.err.prob.found.req // options: -XDdiags=where // run: simple diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/enum/6350057/T6350057.java --- a/test/tools/javac/enum/6350057/T6350057.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/enum/6350057/T6350057.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,11 @@ /* * @test - * @bug 6350057 + * @bug 6350057 7025809 * @summary Test that parameters on implicit enum methods have the right kind * @author Joseph D. Darcy - * @compile T6350057.java + * @library ../../lib + * @build JavacTestingAbstractProcessor T6350057 * @compile -processor T6350057 -proc:only TestEnum.java */ @@ -38,9 +39,8 @@ import javax.lang.model.util.*; import static javax.tools.Diagnostic.Kind.*; -@SupportedAnnotationTypes("*") -public class T6350057 extends AbstractProcessor { - static class LocalVarAllergy extends ElementKindVisitor6 { +public class T6350057 extends JavacTestingAbstractProcessor { + static class LocalVarAllergy extends ElementKindVisitor { @Override public Boolean visitTypeAsEnum(TypeElement e, Void v) { System.out.println("visitTypeAsEnum: " + e.getSimpleName().toString()); diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/enum/6424358/T6424358.java --- a/test/tools/javac/enum/6424358/T6424358.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/enum/6424358/T6424358.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,11 @@ /* * @test - * @bug 6424358 + * @bug 6424358 7025809 * @summary Synthesized static enum method values() is final * @author Peter von der Ah\u00e9 - * @compile T6424358.java + * @library ../../lib + * @build JavacTestingAbstractProcessor T6424358 * @compile -processor T6424358 -proc:only T6424358.java */ @@ -39,8 +40,7 @@ @interface TestMe {} -@SupportedAnnotationTypes("*") -public class T6424358 extends AbstractProcessor { +public class T6424358 extends JavacTestingAbstractProcessor { @TestMe enum Test { FOO; } public boolean process(Set annotations, @@ -48,7 +48,7 @@ final Messager log = processingEnv.getMessager(); final Elements elements = processingEnv.getElementUtils(); final TypeElement testMe = elements.getTypeElement("TestMe"); - class Scan extends ElementScanner7 { + class Scan extends ElementScanner { @Override public Void visitExecutable(ExecutableElement e, Void p) { System.err.println("Looking at " + e); @@ -65,9 +65,4 @@ scan.scan(e); return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/failover/CheckAttributedTree.java --- a/test/tools/javac/failover/CheckAttributedTree.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/failover/CheckAttributedTree.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,12 +55,8 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.nio.charset.Charset; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import javax.tools.Diagnostic; import javax.tools.DiagnosticListener; import javax.tools.JavaFileObject; @@ -72,8 +68,8 @@ import com.sun.tools.javac.api.JavacTool; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Type; +import com.sun.tools.javac.parser.EndPosTable; import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.tree.JCTree.JCClassDecl; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.tree.JCTree.JCImport; import com.sun.tools.javac.tree.TreeInfo; @@ -85,6 +81,8 @@ import java.util.Set; import javax.lang.model.element.Element; +import static com.sun.tools.javac.tree.JCTree.Tag.*; + /** * Utility and test program to check validity of tree positions for tree nodes. * The program can be run standalone, or as a jtreg test. In standalone mode, @@ -289,7 +287,7 @@ for (CompilationUnitTree t : trees) { JCCompilationUnit cu = (JCCompilationUnit)t; for (JCTree def : cu.defs) { - if (def.getTag() == JCTree.CLASSDEF && + if (def.hasTag(CLASSDEF) && analyzedElems.contains(((JCTree.JCClassDecl)def).sym)) { //System.out.println("Adding pair..."); res.add(new Pair<>(cu, def)); @@ -373,9 +371,9 @@ private boolean mandatoryType(JCTree that) { return that instanceof JCTree.JCExpression || - that.getTag() == JCTree.VARDEF || - that.getTag() == JCTree.METHODDEF || - that.getTag() == JCTree.CLASSDEF; + that.hasTag(VARDEF) || + that.hasTag(METHODDEF) || + that.hasTag(CLASSDEF); } private final List excludedFields = Arrays.asList("varargsElement"); @@ -419,7 +417,7 @@ } JavaFileObject sourcefile; - Map endPosTable; + EndPosTable endPosTable; Info encl; } @@ -429,13 +427,13 @@ private class Info { Info() { tree = null; - tag = JCTree.ERRONEOUS; + tag = ERRONEOUS; start = 0; pos = 0; end = Integer.MAX_VALUE; } - Info(JCTree tree, Map endPosTable) { + Info(JCTree tree, EndPosTable endPosTable) { this.tree = tree; tag = tree.getTag(); start = TreeInfo.getStartPos(tree); @@ -449,7 +447,7 @@ } final JCTree tree; - final int tag; + final JCTree.Tag tag; final int start; final int pos; final int end; @@ -457,27 +455,10 @@ /** * Names for tree tags. - * javac does not provide an API to convert tag values to strings, so this class uses - * reflection to determine names of public static final int values in JCTree. */ private static class TreeUtil { - String nameFromTag(int tag) { - if (names == null) { - names = new HashMap(); - Class c = JCTree.class; - for (Field f : c.getDeclaredFields()) { - if (f.getType().equals(int.class)) { - int mods = f.getModifiers(); - if (Modifier.isPublic(mods) && Modifier.isStatic(mods) && Modifier.isFinal(mods)) { - try { - names.put(f.getInt(null), f.getName()); - } catch (IllegalAccessException e) { - } - } - } - } - } - String name = names.get(tag); + String nameFromTag(JCTree.Tag tag) { + String name = tag.name(); return (name == null) ? "??" : name; } @@ -496,8 +477,6 @@ } return buf; } - - private Map names; } /** diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/failover/FailOver15.out --- a/test/tools/javac/failover/FailOver15.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/failover/FailOver15.out Tue May 29 00:27:58 2012 +0100 @@ -1,4 +1,3 @@ FailOver15.java:17:10: compiler.err.expected: ';' FailOver15.java:11:13: compiler.err.cant.resolve.location: kindname.class, UnknownClass, , , (compiler.misc.location: kindname.class, Test, null) 2 errors - diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/fatalErrors/NoJavaLang.sh --- a/test/tools/javac/fatalErrors/NoJavaLang.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/fatalErrors/NoJavaLang.sh Tue May 29 00:27:58 2012 +0100 @@ -48,7 +48,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux ) + SunOS | Linux | Darwin ) FS="/" ;; CYGWIN* ) diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/file/T7068437.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/file/T7068437.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7068437 + * @summary Filer.getResource(SOURCE_OUTPUT, ...) no longer works in JDK 7 w/o -s + */ + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.Writer; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.Filer; +import javax.annotation.processing.Messager; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.annotation.processing.SupportedOptions; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic.Kind; +import javax.tools.JavaCompiler; +import javax.tools.JavaCompiler.CompilationTask; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +public class T7068437 { + public static void main(String[] args) throws Exception { + new T7068437().run(); + } + + void run() throws Exception { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + System.err.println("using " + compiler.getClass() + + " from " + compiler.getClass().getProtectionDomain().getCodeSource()); + + CompilationTask task = compiler.getTask(null, null, null, + Collections.singleton("-proc:only"), + Collections.singleton("java.lang.Object"), + null); + task.setProcessors(Collections.singleton(new Proc())); + check("compilation", task.call()); + + task = compiler.getTask(null, null, null, + Arrays.asList("-proc:only", "-AexpectFile"), + Collections.singleton("java.lang.Object"), + null); + task.setProcessors(Collections.singleton(new Proc())); + check("compilation", task.call()); + } + + void check(String msg, boolean ok) { + System.err.println(msg + ": " + (ok ? "ok" : "failed")); + if (!ok) + throw new AssertionError(msg); + } + + @SupportedAnnotationTypes("*") + @SupportedOptions("expectFile") + private static class Proc extends AbstractProcessor { + int count; + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver() || count++ > 0) { + return false; + } + + Filer filer = processingEnv.getFiler(); + Messager messager = processingEnv.getMessager(); + Map options = processingEnv.getOptions(); + System.err.println(options); + boolean expectFile = options.containsKey("expectFile"); + + System.err.println("running Proc: expectFile=" + expectFile); + + boolean found; + try { + messager.printMessage(Kind.NOTE, "found previous content of length " + + filer.getResource(StandardLocation.SOURCE_OUTPUT, "p", "C.java").getCharContent(false).length()); + found = true; + } catch (FileNotFoundException x) { + messager.printMessage(Kind.NOTE, "not previously there"); + found = false; + } catch (IOException x) { + messager.printMessage(Kind.ERROR, "while reading: " + x); + found = false; + } + + if (expectFile && !found) { + messager.printMessage(Kind.ERROR, "expected file but file not found"); + } + + try { + Writer w = filer.createSourceFile("p.C").openWriter(); + w.write("/* hello! */ package p; class C {}"); + w.close(); + messager.printMessage(Kind.NOTE, "wrote new content"); + } catch (IOException x) { + messager.printMessage(Kind.ERROR, "while writing: " + x); + } + + return true; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/file/T7068451.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/file/T7068451.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7068451 + * @summary Regression: javac compiles fixed sources against previous, + * not current, version of generated sources + */ + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.Filer; +import javax.annotation.processing.Messager; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic.Kind; +import javax.tools.JavaCompiler; +import javax.tools.JavaCompiler.CompilationTask; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +public class T7068451 { + public static void main(String[] args) throws Exception { + new T7068451().run(); + } + + void run() throws Exception { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + System.err.println("using " + compiler.getClass() + " from " + compiler.getClass().getProtectionDomain().getCodeSource()); + + File tmp = new File("tmp"); + tmp.mkdir(); + for (File f: tmp.listFiles()) + f.delete(); + + File input = writeFile(tmp, "X.java", "package p; class X { { p.C.first(); } }"); + + List opts = Arrays.asList( + "-s", tmp.getPath(), + "-d", tmp.getPath(), + "-XprintRounds"); + + System.err.println(); + System.err.println("FIRST compilation"); + System.err.println(); + + CompilationTask task = compiler.getTask(null, null, null, opts, null, + compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input)); + task.setProcessors(Collections.singleton(new Proc("first"))); + check("compilation", task.call()); + + writeFile(tmp, "X.java", "package p; class X { { p.C.second(); } }"); + + //Thread.sleep(2000); + + System.err.println(); + System.err.println("SECOND compilation"); + System.err.println(); + + task = compiler.getTask(null, null, null, opts, null, + compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input)); + task.setProcessors(Collections.singleton(new Proc("second"))); + check("compilation", task.call()); + + //Thread.sleep(2000); + + System.err.println(); + System.err.println("SECOND compilation, REPEATED"); + System.err.println(); + + task = compiler.getTask(null, null, null, opts, null, + compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input)); + task.setProcessors(Collections.singleton(new Proc("second"))); + check("compilation", task.call()); + } + + void check(String msg, boolean ok) { + System.err.println(msg + ": " + (ok ? "ok" : "failed")); + if (!ok) + throw new AssertionError(msg); + } + + static File writeFile(File base, String path, String body) throws IOException { + File f = new File(base, path); + FileWriter out = new FileWriter(f); + out.write(body); + out.close(); + System.err.println("wrote " + path + ": " + body); + return f; + } + + @SupportedAnnotationTypes("*") + private static class Proc extends AbstractProcessor { + final String m; + Proc(String m) { + this.m = m; + } + + int count; + @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver() || count++ > 0) { + return false; + } + + Filer filer = processingEnv.getFiler(); + Messager messager = processingEnv.getMessager(); + + System.err.println("running Proc"); + try { + int len = filer.getResource(StandardLocation.SOURCE_OUTPUT, "p", "C.java").getCharContent(false).length(); + messager.printMessage(Kind.NOTE, "C.java: found previous content of length " + len); + } catch (FileNotFoundException x) { + messager.printMessage(Kind.NOTE, "C.java: not previously there"); + } catch (IOException x) { + messager.printMessage(Kind.ERROR, "while reading: " + x); + } + + try { + String body = "package p; public class C { public static void " + m + "() {} }"; + Writer w = filer.createSourceFile("p.C").openWriter(); + w.write(body); + w.close(); + messager.printMessage(Kind.NOTE, "C.java: wrote new content: " + body); + } catch (IOException x) { + messager.printMessage(Kind.ERROR, "while writing: " + x); + } + + return true; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + } +} + diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/6207386/T6207386.out --- a/test/tools/javac/generics/6207386/T6207386.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/6207386/T6207386.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6207386.java:13:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), X, T6207386.F +T6207386.java:13:30: compiler.err.prob.found.req: X, T6207386.F 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/6723444/T6723444.out --- a/test/tools/javac/generics/6723444/T6723444.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/6723444/T6723444.out Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ -T6723444.java:42:9: compiler.err.unreported.exception.need.to.catch.or.throw: X2 -T6723444.java:43:9: compiler.err.unreported.exception.need.to.catch.or.throw: X2 +T6723444.java:42:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable +T6723444.java:43:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable T6723444.java:45:32: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable T6723444.java:46:17: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable T6723444.java:48:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/6910550/T6910550d.out --- a/test/tools/javac/generics/6910550/T6910550d.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/6910550/T6910550d.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6910550d.java:12:14: compiler.err.already.defined: m(X), T6910550d +T6910550d.java:12:14: compiler.err.already.defined: kindname.method, m(X), kindname.class, T6910550d 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/7015430/T7015430.out diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/7151070/T7151070.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/7151070/T7151070.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7151070 + * @summary NullPointerException in Resolve.isAccessible + * @compile/fail/ref=T7151070.out -XDrawDiagnostics T7151070.java + */ + +class T7151070a { + private static class PrivateCls { } + public static class PublicCls extends PrivateCls { } + + public void m(PrivateCls p) { } +} + +class T7151070b { + public void test(Test obj, T7151070a outer) { + outer.m(obj.get()); + } + + public static class Test { + public T get() { + return null; + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/7151070/T7151070.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/7151070/T7151070.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,2 @@ +T7151070.java:17:24: compiler.err.report.access: T7151070a.PrivateCls, private, T7151070a +1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/7151802/T7151802.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/7151802/T7151802.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,43 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7151802 + * @summary compiler update caused sqe test failed + * @compile/fail/ref=T7151802.out -Werror -Xlint:unchecked -XDrawDiagnostics T7151802.java + */ +class T7151802 { + static class Foo { } + + static class SubFoo extends Foo { } + + //generic - bound - arg - non-slilent + > void get1(Z fz) { } + void test1(Foo foo) { get1(foo); } + + //generic - bound - arg - silent + > void get2(Z fz) { } + void test2(Foo foo) { get2(foo); } + + //generic - nobound - arg - non-slilent + void get3(Foo fz) { } + void test(Foo foo) { get3(foo); } + + //generic - nobound - arg - slilent + void get4(Foo fz) { } + void test4(Foo foo) { get4(foo); } + + //generic - bound - ret - non-slilent + > Z get5() { return null; } + void test5() { SubFoo sf = get5(); } + + //generic - bound - ret - slilent + static > Z get6() { return null; } + void test6() { SubFoo sf = get6(); } + + //nogeneric - nobound - arg - non-slilent + void get7(Foo fz) { } + void test7(Foo foo) { get7(foo); } + + //nogeneric - nobound - arg - slilent + static void get8(Foo fz) { } + void test8(Foo foo) { get8(foo); } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/7151802/T7151802.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/7151802/T7151802.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,9 @@ +T7151802.java:14:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get1, Z, T7151802.Foo, kindname.class, T7151802 +T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo +T7151802.java:22:30: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get3, T7151802.Foo, T7151802.Foo, kindname.class, T7151802 +T7151802.java:30:36: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get5, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T7151802 +T7151802.java:38:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo +T7151802.java:38:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get7, T7151802.Foo, T7151802.Foo, kindname.class, T7151802 +- compiler.err.warnings.and.werror +1 error +6 warnings diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/diamond/7046778/DiamondAndInnerClassTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/diamond/7046778/DiamondAndInnerClassTest.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7046778 + * @summary Project Coin: problem with diamond and member inner classes + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +public class DiamondAndInnerClassTest { + + static int checkCount = 0; + + enum TypeArgumentKind { + NONE(""), + STRING(""), + INTEGER(""), + DIAMOND("<>"); + + String typeargStr; + + private TypeArgumentKind(String typeargStr) { + this.typeargStr = typeargStr; + } + + boolean compatible(TypeArgumentKind that) { + switch (this) { + case NONE: return true; + case STRING: return that != INTEGER; + case INTEGER: return that != STRING; + default: throw new AssertionError("Unexpected decl kind: " + this); + } + } + + boolean compatible(ArgumentKind that) { + switch (this) { + case NONE: return true; + case STRING: return that == ArgumentKind.STRING; + case INTEGER: return that == ArgumentKind.INTEGER; + default: throw new AssertionError("Unexpected decl kind: " + this); + } + } + } + + enum ArgumentKind { + OBJECT("(Object)null"), + STRING("(String)null"), + INTEGER("(Integer)null"); + + String argStr; + + private ArgumentKind(String argStr) { + this.argStr = argStr; + } + } + + enum TypeQualifierArity { + ONE(1, "A1#TA1"), + TWO(2, "A1#TA1.A2#TA2"), + THREE(3, "A1#TA1.A2#TA2.A3#TA3"); + + int n; + String qualifierStr; + + private TypeQualifierArity(int n, String qualifierStr) { + this.n = n; + this.qualifierStr = qualifierStr; + } + + String getType(TypeArgumentKind... typeArgumentKinds) { + String res = qualifierStr; + for (int i = 1 ; i <= typeArgumentKinds.length ; i++) { + res = res.replace("#TA" + i, typeArgumentKinds[i-1].typeargStr); + } + return res; + } + + boolean matches(InnerClassDeclArity innerClassDeclArity) { + return n ==innerClassDeclArity.n; + } + } + + enum InnerClassDeclArity { + ONE(1, "class A1 { A1(X x1) { } #B }"), + TWO(2, "class A1 { class A2 { A2(X1 x1, X2 x2) { } #B } }"), + THREE(3, "class A1 { class A2 { class A3 { A3(X1 x1, X2 x2, X3 x3) { } #B } } }"); + + int n; + String classDeclStr; + + private InnerClassDeclArity(int n, String classDeclStr) { + this.n = n; + this.classDeclStr = classDeclStr; + } + } + + enum ArgumentListArity { + ONE(1, "(#A1)"), + TWO(2, "(#A1,#A2)"), + THREE(3, "(#A1,#A2,#A3)"); + + int n; + String argListStr; + + private ArgumentListArity(int n, String argListStr) { + this.n = n; + this.argListStr = argListStr; + } + + String getArgs(ArgumentKind... argumentKinds) { + String res = argListStr; + for (int i = 1 ; i <= argumentKinds.length ; i++) { + res = res.replace("#A" + i, argumentKinds[i-1].argStr); + } + return res; + } + + boolean matches(InnerClassDeclArity innerClassDeclArity) { + return n ==innerClassDeclArity.n; + } + } + + public static void main(String... args) throws Exception { + + //create default shared JavaCompiler - reused across multiple compilations + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + for (InnerClassDeclArity innerClassDeclArity : InnerClassDeclArity.values()) { + for (TypeQualifierArity declType : TypeQualifierArity.values()) { + if (!declType.matches(innerClassDeclArity)) continue; + for (TypeQualifierArity newClassType : TypeQualifierArity.values()) { + if (!newClassType.matches(innerClassDeclArity)) continue; + for (ArgumentListArity argList : ArgumentListArity.values()) { + if (!argList.matches(innerClassDeclArity)) continue; + for (TypeArgumentKind taDecl1 : TypeArgumentKind.values()) { + boolean isDeclRaw = taDecl1 == TypeArgumentKind.NONE; + //no diamond on decl site + if (taDecl1 == TypeArgumentKind.DIAMOND) continue; + for (TypeArgumentKind taSite1 : TypeArgumentKind.values()) { + boolean isSiteRaw = taSite1 == TypeArgumentKind.NONE; + //diamond only allowed on the last type qualifier + if (taSite1 == TypeArgumentKind.DIAMOND && + innerClassDeclArity != InnerClassDeclArity.ONE) continue; + for (ArgumentKind arg1 : ArgumentKind.values()) { + if (innerClassDeclArity == innerClassDeclArity.ONE) { + new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType, + argList, new TypeArgumentKind[] {taDecl1}, + new TypeArgumentKind[] {taSite1}, new ArgumentKind[] {arg1}).run(comp, fm); + continue; + } + for (TypeArgumentKind taDecl2 : TypeArgumentKind.values()) { + //no rare types + if (isDeclRaw != (taDecl2 == TypeArgumentKind.NONE)) continue; + //no diamond on decl site + if (taDecl2 == TypeArgumentKind.DIAMOND) continue; + for (TypeArgumentKind taSite2 : TypeArgumentKind.values()) { + //no rare types + if (isSiteRaw != (taSite2 == TypeArgumentKind.NONE)) continue; + //diamond only allowed on the last type qualifier + if (taSite2 == TypeArgumentKind.DIAMOND && + innerClassDeclArity != InnerClassDeclArity.TWO) continue; + for (ArgumentKind arg2 : ArgumentKind.values()) { + if (innerClassDeclArity == innerClassDeclArity.TWO) { + new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType, + argList, new TypeArgumentKind[] {taDecl1, taDecl2}, + new TypeArgumentKind[] {taSite1, taSite2}, + new ArgumentKind[] {arg1, arg2}).run(comp, fm); + continue; + } + for (TypeArgumentKind taDecl3 : TypeArgumentKind.values()) { + //no rare types + if (isDeclRaw != (taDecl3 == TypeArgumentKind.NONE)) continue; + //no diamond on decl site + if (taDecl3 == TypeArgumentKind.DIAMOND) continue; + for (TypeArgumentKind taSite3 : TypeArgumentKind.values()) { + //no rare types + if (isSiteRaw != (taSite3 == TypeArgumentKind.NONE)) continue; + //diamond only allowed on the last type qualifier + if (taSite3 == TypeArgumentKind.DIAMOND && + innerClassDeclArity != InnerClassDeclArity.THREE) continue; + for (ArgumentKind arg3 : ArgumentKind.values()) { + if (innerClassDeclArity == innerClassDeclArity.THREE) { + new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType, + argList, new TypeArgumentKind[] {taDecl1, taDecl2, taDecl3}, + new TypeArgumentKind[] {taSite1, taSite2, taSite3}, + new ArgumentKind[] {arg1, arg2, arg3}).run(comp, fm); + continue; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + System.out.println("Total check executed: " + checkCount); + } + + InnerClassDeclArity innerClassDeclArity; + TypeQualifierArity declType; + TypeQualifierArity siteType; + ArgumentListArity argList; + TypeArgumentKind[] declTypeArgumentKinds; + TypeArgumentKind[] siteTypeArgumentKinds; + ArgumentKind[] argumentKinds; + JavaSource source; + DiagnosticChecker diagChecker; + + DiamondAndInnerClassTest(InnerClassDeclArity innerClassDeclArity, + TypeQualifierArity declType, TypeQualifierArity siteType, ArgumentListArity argList, + TypeArgumentKind[] declTypeArgumentKinds, TypeArgumentKind[] siteTypeArgumentKinds, + ArgumentKind[] argumentKinds) { + this.innerClassDeclArity = innerClassDeclArity; + this.declType = declType; + this.siteType = siteType; + this.argList = argList; + this.declTypeArgumentKinds = declTypeArgumentKinds; + this.siteTypeArgumentKinds = siteTypeArgumentKinds; + this.argumentKinds = argumentKinds; + this.source = new JavaSource(); + this.diagChecker = new DiagnosticChecker(); + } + + class JavaSource extends SimpleJavaFileObject { + + String bodyTemplate = "#D res = new #S#AL;"; + + String source; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = innerClassDeclArity.classDeclStr.replace("#B", bodyTemplate) + .replace("#D", declType.getType(declTypeArgumentKinds)) + .replace("#S", siteType.getType(siteTypeArgumentKinds)) + .replace("#AL", argList.getArgs(argumentKinds)); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, + null, null, Arrays.asList(source)); + try { + ct.analyze(); + } catch (Throwable ex) { + throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true)); + } + check(); + } + + void check() { + checkCount++; + + boolean errorExpected = false; + + TypeArgumentKind[] expectedArgKinds = new TypeArgumentKind[innerClassDeclArity.n]; + + for (int i = 0 ; i < innerClassDeclArity.n ; i++) { + if (!declTypeArgumentKinds[i].compatible(siteTypeArgumentKinds[i])) { + errorExpected = true; + break; + } + expectedArgKinds[i] = siteTypeArgumentKinds[i] == TypeArgumentKind.DIAMOND ? + declTypeArgumentKinds[i] : siteTypeArgumentKinds[i]; + } + + if (!errorExpected) { + for (int i = 0 ; i < innerClassDeclArity.n ; i++) { + //System.out.println("check " + expectedArgKinds[i] + " against " + argumentKinds[i]); + if (!expectedArgKinds[i].compatible(argumentKinds[i])) { + errorExpected = true; + break; + } + } + } + + if (errorExpected != diagChecker.errorFound) { + throw new Error("invalid diagnostics for source:\n" + + source.getCharContent(true) + + "\nFound error: " + diagChecker.errorFound + + "\nExpected error: " + errorExpected); + } + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + errorFound = true; + } + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/diamond/7057297/T7057297.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/diamond/7057297/T7057297.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,29 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7057297 + * + * @summary Project Coin: diamond erroneously accepts in array initializer expressions + * @compile/fail/ref=T7057297.out T7057297.java -XDrawDiagnostics + * + */ + +class T7205797 { + + class Inner {} + + T7205797[] o1 = new T7205797<>[1]; //error + T7205797[] o2 = new T7205797<>[1][1]; //error + T7205797[] o3 = new T7205797<>[1][1][1]; //error + + T7205797[] o4 = new T7205797<>[] { }; //error + T7205797[] o5 = new T7205797<>[][] { }; //error + T7205797[] o6 = new T7205797<>[][][] { }; //error + + T7205797.Inner[] o1 = new T7205797.Inner<>[1]; //error + T7205797.Inner[] o2 = new T7205797.Inner<>[1][1]; //error + T7205797.Inner[] o3 = new T7205797.Inner<>[1][1][1]; //error + + T7205797.Inner[] o4 = new T7205797.Inner<>[] { }; //error + T7205797.Inner[] o5 = new T7205797.Inner<>[][] { }; //error + T7205797.Inner[] o6 = new T7205797.Inner<>[][][] { }; //error +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/diamond/7057297/T7057297.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/diamond/7057297/T7057297.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,13 @@ +T7057297.java:14:41: compiler.err.cannot.create.array.with.diamond +T7057297.java:15:41: compiler.err.cannot.create.array.with.diamond +T7057297.java:16:41: compiler.err.cannot.create.array.with.diamond +T7057297.java:18:41: compiler.err.cannot.create.array.with.diamond +T7057297.java:19:41: compiler.err.cannot.create.array.with.diamond +T7057297.java:20:41: compiler.err.cannot.create.array.with.diamond +T7057297.java:22:69: compiler.err.cannot.create.array.with.diamond +T7057297.java:23:69: compiler.err.cannot.create.array.with.diamond +T7057297.java:24:69: compiler.err.cannot.create.array.with.diamond +T7057297.java:26:69: compiler.err.cannot.create.array.with.diamond +T7057297.java:27:69: compiler.err.cannot.create.array.with.diamond +T7057297.java:28:69: compiler.err.cannot.create.array.with.diamond +12 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/diamond/neg/Neg05.out --- a/test/tools/javac/generics/diamond/neg/Neg05.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/diamond/neg/Neg05.out Tue May 29 00:27:58 2012 +0100 @@ -1,19 +1,19 @@ Neg05.java:19:48: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:19:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo, Neg05.Foo +Neg05.java:19:35: compiler.err.prob.found.req: Neg05.Foo, Neg05.Foo Neg05.java:20:58: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:20:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo, Neg05.Foo +Neg05.java:20:45: compiler.err.prob.found.req: Neg05.Foo, Neg05.Foo Neg05.java:21:43: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:21:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo, Neg05.Foo +Neg05.java:21:30: compiler.err.prob.found.req: Neg05.Foo, Neg05.Foo Neg05.java:22:56: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:22:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo, Neg05.Foo +Neg05.java:22:43: compiler.err.prob.found.req: Neg05.Foo, Neg05.Foo Neg05.java:24:48: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:24:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo, Neg05.Foo +Neg05.java:24:35: compiler.err.prob.found.req: Neg05.Foo, Neg05.Foo Neg05.java:25:58: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:25:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo, Neg05.Foo +Neg05.java:25:45: compiler.err.prob.found.req: Neg05.Foo, Neg05.Foo Neg05.java:26:43: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:26:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo, Neg05.Foo +Neg05.java:26:30: compiler.err.prob.found.req: Neg05.Foo, Neg05.Foo Neg05.java:27:56: compiler.err.improperly.formed.type.inner.raw.param -Neg05.java:27:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo, Neg05.Foo +Neg05.java:27:43: compiler.err.prob.found.req: Neg05.Foo, Neg05.Foo Neg05.java:31:37: compiler.err.improperly.formed.type.inner.raw.param Neg05.java:32:47: compiler.err.improperly.formed.type.inner.raw.param Neg05.java:33:32: compiler.err.improperly.formed.type.inner.raw.param diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/diamond/neg/Neg06.out --- a/test/tools/javac/generics/diamond/neg/Neg06.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/diamond/neg/Neg06.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -Neg06.java:16:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo, Neg06.CSuperFoo) +Neg06.java:16:37: compiler.err.prob.found.req.1: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/diamond/neg/Neg07.out --- a/test/tools/javac/generics/diamond/neg/Neg07.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/diamond/neg/Neg07.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.String, java.lang.Number) +Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/diamond/neg/Neg09.out --- a/test/tools/javac/generics/diamond/neg/Neg09.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/diamond/neg/Neg09.out Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ -Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member) -Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested) -Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member) -Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested) +Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member) +Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested) +Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member) +Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested) 4 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/diamond/neg/Neg10.out --- a/test/tools/javac/generics/diamond/neg/Neg10.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/diamond/neg/Neg10.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -Neg10.java:16:22: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg10.Foo, Neg10.Foo +Neg10.java:16:22: compiler.err.prob.found.req: Neg10.Foo, Neg10.Foo 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/6315770/T6315770.out --- a/test/tools/javac/generics/inference/6315770/T6315770.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/inference/6315770/T6315770.out Tue May 29 00:27:58 2012 +0100 @@ -1,3 +1,3 @@ -T6315770.java:16:42: compiler.err.undetermined.type.1: T6315770, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable) -T6315770.java:17:40: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, T6315770, T6315770)), T6315770, T6315770 +T6315770.java:16:42: compiler.err.prob.found.req.1: (compiler.misc.undetermined.type: T6315770, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable)) +T6315770.java:17:40: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer&java.lang.Runnable, java.lang.String)) 2 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/6611449/T6611449.out --- a/test/tools/javac/generics/inference/6611449/T6611449.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/inference/6611449/T6611449.out Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ -T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T,T), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S))} -T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T), (compiler.misc.infer.arg.length.mismatch))} -T6611449.java:20:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, T, int, kindname.class, T6611449, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S) -T6611449.java:21:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, T,T, int,int, kindname.class, T6611449, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S) +T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T,T), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S))} +T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, T6611449(T), (compiler.misc.infer.arg.length.mismatch))} +T6611449.java:20:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, T, int, kindname.class, T6611449, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S) +T6611449.java:21:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, T,T, int,int, kindname.class, T6611449, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S) 4 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/6638712/T6638712a.out --- a/test/tools/javac/generics/inference/6638712/T6638712a.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/inference/6638712/T6638712a.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6638712a.java:16:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, java.util.Comparator, java.util.Comparator)), java.util.Comparator, java.util.Comparator +T6638712a.java:16:33: compiler.err.cant.apply.symbol.1: kindname.method, compound, java.lang.Iterable>, java.util.List>, kindname.class, T6638712a, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List>, java.lang.Iterable>) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/6638712/T6638712b.out --- a/test/tools/javac/generics/inference/6638712/T6638712b.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/inference/6638712/T6638712b.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6638712b.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, T, java.lang.String)), T, java.lang.String +T6638712b.java:14:21: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String,java.lang.Object)) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/6638712/T6638712d.out --- a/test/tools/javac/generics/inference/6638712/T6638712d.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/inference/6638712/T6638712d.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6638712d.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, U,java.util.List>, int,java.util.List>, kindname.class, T6638712d, (compiler.misc.no.conforming.assignment.exists: int, java.lang.String) +T6638712d.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, U,java.util.List>, int,java.util.List>, kindname.class, T6638712d, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.String, java.lang.Integer) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/6638712/T6638712e.out --- a/test/tools/javac/generics/inference/6638712/T6638712e.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/inference/6638712/T6638712e.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6638712e.java:17:27: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: X, T6638712e.Foo, T6638712e.Foo)), T6638712e.Foo, T6638712e.Foo +T6638712e.java:17:27: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.no.conforming.assignment.exists: T6638712e.Foo, T6638712e.Foo)) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/6650759/T6650759m.out --- a/test/tools/javac/generics/inference/6650759/T6650759m.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/inference/6650759/T6650759m.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6650759m.java:43:36: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.util.List, java.util.List +T6650759m.java:43:36: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: Z, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer, java.lang.String)) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/7086586/T7086586.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/7086586/T7086586.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,19 @@ +/** + * @test /nodynamiccopyright/ + * @bug 7086586 + * @summary Inference producing null type argument + * @compile/fail/ref=T7086586.out -XDrawDiagnostics T7086586.java + */ +import java.util.List; + +class T7086586 { + + List m(List dummy) { return null; } + + void test(List l) { + String s = m(l).get(0); + Number n = m(l).get(0); + Exception e = m(l).get(0); + m(l).nonExistentMethod(); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/7086586/T7086586.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/7086586/T7086586.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,5 @@ +T7086586.java:14:20: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List, java.util.List, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List, java.util.List) +T7086586.java:15:20: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List, java.util.List, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List, java.util.List) +T7086586.java:16:23: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List, java.util.List, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List, java.util.List) +T7086586.java:17:9: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List, java.util.List, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List, java.util.List) +4 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/7086586/T7086586b.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/7086586/T7086586b.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7086586 + * + * @summary Inference producing null type argument + */ +import java.util.List; + +public class T7086586b { + + int assertionCount = 0; + + void assertTrue(boolean cond) { + if (!cond) { + throw new AssertionError(); + } + assertionCount++; + } + + void m(List dummy) { assertTrue(false); } + void m(Object dummy) { assertTrue(true); } + + void test(List l) { + m(l); + assertTrue(assertionCount == 1); + } + + public static void main(String[] args) { + new T7086586b().test(null); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/7086601/T7086601a.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/7086601/T7086601a.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,34 @@ +/** + * @test /nodynamiccopyright/ + * @bug 7086601 + * @summary Error message bug: cause for method mismatch is 'null' + * @compile/fail/ref=T7086601a.out -XDrawDiagnostics T7086601a.java + */ + +class T7086601 { + static void m1(Iterable s1, Iterable s2) { } + static void m1(Object o) {} + + static void m2(Iterable s1, Iterable s2, Iterable s3) { } + static void m2(Object o) {} + + @SafeVarargs + static void m3(Iterable... ss) { } + static void m3(Object o) {} + + static void test1(Iterable is, Iterable ii) { + m1(is, ii); + } + + static void test2(Iterable is, Iterable ii, Iterable id) { + m2(is, ii, id); + } + + static void test3(Iterable is, Iterable ii) { + m3(is, ii); + } + + static void test4(Iterable is, Iterable ii, Iterable id) { + m3(is, ii, id); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/7086601/T7086601a.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/7086601/T7086601a.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,5 @@ +T7086601a.java:20:9: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.Iterable,java.lang.Iterable,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m1(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, m1(java.lang.Iterable,java.lang.Iterable), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String,java.lang.Object))} +T7086601a.java:24:9: compiler.err.cant.apply.symbols: kindname.method, m2, java.lang.Iterable,java.lang.Iterable,java.lang.Iterable,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m2(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, m2(java.lang.Iterable,java.lang.Iterable,java.lang.Iterable), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object))} +T7086601a.java:28:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable,java.lang.Iterable,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Iterable...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String,java.lang.Object))} +T7086601a.java:32:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable,java.lang.Iterable,java.lang.Iterable,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Iterable...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object))} +4 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/7086601/T7086601b.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/7086601/T7086601b.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7086601 + * @summary Error message bug: cause for method mismatch is 'null' + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import java.util.ArrayList; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + + +public class T7086601b { + + static int checkCount = 0; + + enum TypeKind { + STRING("String", false), + INTEGER("Integer", false), + NUMBER("Number", false), + SERIALIZABLE("java.io.Serializable", true), + CLONEABLE("Cloneable", true), + X("X", false), + Y("Y", false), + Z("Z", false); + + String typeStr; + boolean isInterface; + + private TypeKind(String typeStr, boolean isInterface) { + this.typeStr = typeStr; + this.isInterface = isInterface; + } + + boolean isSubtypeof(TypeKind other) { + return (this == INTEGER && other == NUMBER || + this == Z && other == Y || + this == other); + } + } + + enum MethodCallKind { + ARITY_ONE("m(a1);", 1), + ARITY_TWO("m(a1, a2);", 2), + ARITY_THREE("m(a1, a2, a3);", 3); + + String invokeString; + int arity; + + private MethodCallKind(String invokeString, int arity) { + this.invokeString = invokeString; + this.arity = arity; + } + } + + public static void main(String... args) throws Exception { + + //create default shared JavaCompiler - reused across multiple compilations + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + for (TypeKind a1 : TypeKind.values()) { + for (TypeKind a2 : TypeKind.values()) { + for (TypeKind a3 : TypeKind.values()) { + for (MethodCallKind mck : MethodCallKind.values()) { + new T7086601b(a1, a2, a3, mck).run(comp, fm); + } + } + } + } + System.out.println("Total check executed: " + checkCount); + } + + TypeKind a1; + TypeKind a2; + TypeKind a3; + MethodCallKind mck; + JavaSource source; + DiagnosticChecker diagChecker; + + T7086601b(TypeKind a1, TypeKind a2, TypeKind a3, MethodCallKind mck) { + this.a1 = a1; + this.a2 = a2; + this.a3 = a3; + this.mck = mck; + this.source = new JavaSource(); + this.diagChecker = new DiagnosticChecker(); + } + + class JavaSource extends SimpleJavaFileObject { + + final String bodyTemplate = "import java.util.List;\n"+ + "class Test {\n" + + " void m(List l1) { }\n" + + " void m(List l1, List l2) { }\n" + + " void m(List l1, List l2, List l3) { }\n" + + " void test(List<#A1> a1, List<#A2> a2, List<#A3> a3) { #MC } }"; + + String source; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = bodyTemplate.replace("#A1", a1.typeStr) + .replace("#A2", a2.typeStr).replace("#A3", a3.typeStr) + .replace("#MC", mck.invokeString); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, + null, null, Arrays.asList(source)); + try { + ct.analyze(); + } catch (Throwable ex) { + throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true)); + } + check(); + } + + void check() { + checkCount++; + + boolean errorExpected = false; + + if (mck.arity > 1) { + TypeKind[] argtypes = { a1, a2, a3 }; + ArrayList classes = new ArrayList<>(); + for (int i = 0 ; i < mck.arity ; i ++ ) { + if (!argtypes[i].isInterface) { + classes.add(argtypes[i]); + } + } + boolean glb_exists = true; + for (TypeKind arg_i : classes) { + glb_exists = true; + for (TypeKind arg_j : classes) { + if (!arg_i.isSubtypeof(arg_j)) { + glb_exists = false; + break; + } + } + if (glb_exists) break; + } + errorExpected = !glb_exists; + } + + if (errorExpected != diagChecker.errorFound) { + throw new Error("invalid diagnostics for source:\n" + + source.getCharContent(true) + + "\nFound error: " + diagChecker.errorFound + + "\nExpected error: " + errorExpected); + } + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + errorFound = true; + } + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/7154127/T7154127.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/7154127/T7154127.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,21 @@ +/** + * @test /nodynamiccopyright/ + * @bug 7154127 + * @summary Inference cleanup: remove bound check analysis from visitors in Types.java + * @compile/fail/ref=T7154127.out -XDrawDiagnostics T7154127.java + */ +class T7154127 { + + static class B {} + + static class D extends B {} + static class E extends B {} + + static class Triple { } + + static , U extends B> Triple m() { return null; } + + void test() { + Triple t = m(); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/inference/7154127/T7154127.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/7154127/T7154127.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,2 @@ +T7154127.java:19:49: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T,Y,U, (compiler.misc.inferred.do.not.conform.to.upper.bounds: Y, T7154127.D,T7154127.B)) +1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/rare/6665356/T6665356.out --- a/test/tools/javac/generics/rare/6665356/T6665356.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/rare/6665356/T6665356.out Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ T6665356.java:17:37: compiler.err.improperly.formed.type.param.missing T6665356.java:18:40: compiler.err.improperly.formed.type.inner.raw.param -T6665356.java:26:23: compiler.err.improperly.formed.type.param.missing +T6665356.java:26:22: compiler.err.improperly.formed.type.param.missing T6665356.java:27:25: compiler.err.improperly.formed.type.inner.raw.param 4 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,286 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7062745 + * @summary Regression: difference in overload resolution when two methods are maximally specific + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +public class GenericOverrideTest { + + static int checkCount = 0; + + enum SignatureKind { + NON_GENERIC(""), + GENERIC(""); + + String paramStr; + + private SignatureKind(String paramStr) { + this.paramStr = paramStr; + } + } + + enum ReturnTypeKind { + LIST("List"), + ARRAYLIST("ArrayList"); + + String retStr; + + private ReturnTypeKind(String retStr) { + this.retStr = retStr; + } + + boolean moreSpecificThan(ReturnTypeKind that) { + switch (this) { + case LIST: + return that == this; + case ARRAYLIST: + return that == LIST || that == ARRAYLIST; + default: throw new AssertionError("Unexpected ret kind: " + this); + } + } + } + + enum TypeArgumentKind { + NONE(""), + UNBOUND(""), + INTEGER(""), + NUMBER(""), + TYPEVAR(""); + + String typeargStr; + + private TypeArgumentKind(String typeargStr) { + this.typeargStr = typeargStr; + } + + boolean compatibleWith(SignatureKind sig) { + switch (this) { + case TYPEVAR: return sig != SignatureKind.NON_GENERIC; + default: return true; + } + } + + boolean moreSpecificThan(TypeArgumentKind that, boolean strict) { + switch (this) { + case NONE: + return that == this || !strict; + case UNBOUND: + return that == this || that == NONE; + case INTEGER: + case NUMBER: + case TYPEVAR: + return that == this || that == NONE || that == UNBOUND; + default: throw new AssertionError("Unexpected typearg kind: " + this); + } + } + + boolean assignableTo(TypeArgumentKind that, SignatureKind sig) { + switch (this) { + case NONE: + //this case needs to workaround to javac's impl of 15.12.2.8 being too strict + //ideally should be just 'return true' (see 7067746) + return sig == SignatureKind.NON_GENERIC || that == NONE; + case UNBOUND: + return that == this || that == NONE; + case INTEGER: + case NUMBER: + return that == this || that == NONE || that == UNBOUND; + case TYPEVAR: + return true; + default: throw new AssertionError("Unexpected typearg kind: " + this); + } + } + } + + public static void main(String... args) throws Exception { + + //create default shared JavaCompiler - reused across multiple compilations + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + for (SignatureKind sig1 : SignatureKind.values()) { + for (ReturnTypeKind rt1 : ReturnTypeKind.values()) { + for (TypeArgumentKind ta1 : TypeArgumentKind.values()) { + if (!ta1.compatibleWith(sig1)) continue; + for (SignatureKind sig2 : SignatureKind.values()) { + for (ReturnTypeKind rt2 : ReturnTypeKind.values()) { + for (TypeArgumentKind ta2 : TypeArgumentKind.values()) { + if (!ta2.compatibleWith(sig2)) continue; + for (ReturnTypeKind rt3 : ReturnTypeKind.values()) { + for (TypeArgumentKind ta3 : TypeArgumentKind.values()) { + if (!ta3.compatibleWith(SignatureKind.NON_GENERIC)) continue; + new GenericOverrideTest(sig1, rt1, ta1, sig2, rt2, ta2, rt3, ta3).run(comp, fm); + } + } + } + } + } + } + } + } + System.out.println("Total check executed: " + checkCount); + } + + SignatureKind sig1, sig2; + ReturnTypeKind rt1, rt2, rt3; + TypeArgumentKind ta1, ta2, ta3; + JavaSource source; + DiagnosticChecker diagChecker; + + GenericOverrideTest(SignatureKind sig1, ReturnTypeKind rt1, TypeArgumentKind ta1, + SignatureKind sig2, ReturnTypeKind rt2, TypeArgumentKind ta2, ReturnTypeKind rt3, TypeArgumentKind ta3) { + this.sig1 = sig1; + this.sig2 = sig2; + this.rt1 = rt1; + this.rt2 = rt2; + this.rt3 = rt3; + this.ta1 = ta1; + this.ta2 = ta2; + this.ta3 = ta3; + this.source = new JavaSource(); + this.diagChecker = new DiagnosticChecker(); + } + + class JavaSource extends SimpleJavaFileObject { + + String template = "import java.util.*;\n" + + "interface A { #S1 #R1#TA1 m(); }\n" + + "interface B { #S2 #R2#TA2 m(); }\n" + + "interface AB extends A, B {}\n" + + "class Test {\n" + + " void test(AB ab) { #R3#TA3 n = ab.m(); }\n" + + "}"; + + String source; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = template.replace("#S1", sig1.paramStr). + replace("#S2", sig2.paramStr). + replace("#R1", rt1.retStr). + replace("#R2", rt2.retStr). + replace("#R3", rt3.retStr). + replace("#TA1", ta1.typeargStr). + replace("#TA2", ta2.typeargStr). + replace("#TA3", ta3.typeargStr); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, + null, null, Arrays.asList(source)); + try { + ct.analyze(); + } catch (Throwable ex) { + throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true)); + } + check(); + } + + void check() { + checkCount++; + + boolean errorExpected = false; + int mostSpecific = 0; + + //first check that either |R1| <: |R2| or |R2| <: |R1| + if (rt1 != rt2) { + if (!rt1.moreSpecificThan(rt2) && + !rt2.moreSpecificThan(rt1)) { + errorExpected = true; + } else { + mostSpecific = rt1.moreSpecificThan(rt2) ? 1 : 2; + } + } + + //check that either TA1 <= TA2 or TA2 <= TA1 (unless most specific return found above is raw) + if (!errorExpected) { + if (ta1 != ta2) { + boolean useStrictCheck = ta1.moreSpecificThan(ta2, true) || ta2.moreSpecificThan(ta1, true); + if (!ta1.moreSpecificThan(ta2, useStrictCheck) && + !ta2.moreSpecificThan(ta1, useStrictCheck)) { + errorExpected = true; + } else { + int mostSpecific2 = ta1.moreSpecificThan(ta2, useStrictCheck) ? 1 : 2; + if (mostSpecific != 0 && mostSpecific2 != mostSpecific) { + errorExpected = mostSpecific == 1 ? ta1 != TypeArgumentKind.NONE : ta2 != TypeArgumentKind.NONE; + } else { + mostSpecific = mostSpecific2; + } + } + } else if (mostSpecific == 0) { + //when no signature is better than the other, an arbitrary choice + //must be made - javac always picks the second signature + mostSpecific = 2; + } + } + + //finally, check that most specific return type is compatible with expected type + if (!errorExpected) { + ReturnTypeKind msrt = mostSpecific == 1 ? rt1 : rt2; + TypeArgumentKind msta = mostSpecific == 1 ? ta1 : ta2; + SignatureKind mssig = mostSpecific == 1 ? sig1 : sig2; + + if (!msrt.moreSpecificThan(rt3) || + !msta.assignableTo(ta3, mssig)) { + errorExpected = true; + } + } + + if (errorExpected != diagChecker.errorFound) { + throw new Error("invalid diagnostics for source:\n" + + source.getCharContent(true) + + "\nFound error: " + diagChecker.errorFound + + "\nExpected error: " + errorExpected); + } + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + errorFound = true; + } + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/rawOverride/7062745/T7062745neg.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/rawOverride/7062745/T7062745neg.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,18 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7062745 + * @summary Regression: difference in overload resolution when two methods are maximally specific + * @compile/fail/ref=T7062745neg.out -XDrawDiagnostics T7062745neg.java + */ + +import java.util.*; + +class T7062745neg { + interface A { List getList(); } + interface B { ArrayList getList(); } + interface AB extends A, B {} + + void test(AB ab) { + Number n = ab.getList().get(1); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/rawOverride/7062745/T7062745neg.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/rawOverride/7062745/T7062745neg.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,2 @@ +T7062745neg.java:16:36: compiler.err.prob.found.req: java.lang.Object, java.lang.Number +1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/rawOverride/7062745/T7062745pos.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/rawOverride/7062745/T7062745pos.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7062745 + * @summary Regression: difference in overload resolution when two methods are maximally specific + * + * @compile T7062745pos.java + */ + +import java.util.*; + +class T7062745pos { + interface A { List getList(); } + interface B { List getList(); } + interface AB extends A, B {} + + void test(AB ab) { + Number n = ab.getList().get(1); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/rawOverride/T7148556.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/rawOverride/T7148556.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7148556 + * @summary Implementing a generic interface causes a public clone() to become inaccessible + * @compile T7148556.java + */ + +class T7148556 { + + interface A extends Cloneable { + public Object clone(); + } + + interface B extends A, java.util.List { } + + void test(B b) { + b.clone(); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/typevars/T7148242.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/typevars/T7148242.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7148242 + * @summary Regression: valid code rejected during generic type well-formedness check + * @compile T7148242.java + */ +class T7148242 { + static abstract class A, I2 extends Pair> { + abstract A test(); + } + static class Pair { } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/generics/wildcards/6886247/T6886247_2.out --- a/test/tools/javac/generics/wildcards/6886247/T6886247_2.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/generics/wildcards/6886247/T6886247_2.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -T6886247_2.java:35:28: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.type.captureof: 1, ?, E +T6886247_2.java:35:28: compiler.err.prob.found.req: compiler.misc.type.captureof: 1, ?, E 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/innerClassFile/Driver.sh --- a/test/tools/javac/innerClassFile/Driver.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/innerClassFile/Driver.sh Tue May 29 00:27:58 2012 +0100 @@ -53,7 +53,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | CYGWIN* ) + SunOS | Linux | Darwin | CYGWIN* ) FS="/" ;; Windows* ) diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/javazip/Test.sh --- a/test/tools/javac/javazip/Test.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/javazip/Test.sh Tue May 29 00:27:58 2012 +0100 @@ -41,13 +41,13 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux ) + SunOS | Linux | Darwin ) FS="/" SCR=`pwd` ;; CYGWIN* ) FS="/" - SCR=`pwd | cygpath -d` + SCR=`pwd | cygpath -d -f -` ;; Windows* ) FS="\\" diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/jvm/T7024096.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/jvm/T7024096.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,31 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7024096 + * @summary Stack trace has invalid line numbers + * @author Bruce Chapman + * @compile T7024096.java + * @run main T7024096 + */ + +public class T7024096 { + private static final int START = 14; // starting line number for the test + public static void main(String[] args) { + T7024096 m = new T7024096(); + m.nest(START); + m.nest(START + 1, m.nest(START + 1), m.nest(START + 1), + m.nest(START + 2), + m.nest(START + 3, m.nest(START + 3))); + } + + public T7024096 nest(int expectedline, T7024096... args) { + Exception e = new Exception("expected line#: " + expectedline); + int myline = e.getStackTrace()[1].getLineNumber(); + if( myline != expectedline) { + throw new RuntimeException("Incorrect line number " + + "expected: " + expectedline + + ", got: " + myline, e); + } + System.out.format("Got expected line number %d correct %n", myline); + return null; + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/lambda/LambdaParserTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/LambdaParserTest.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7115050 + * @summary Add parser support for lambda expressions + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +public class LambdaParserTest { + + static int checkCount = 0; + + enum LambdaKind { + NILARY_EXPR("()->x"), + NILARY_STMT("()->{ return x; }"), + ONEARY_SHORT_EXPR("x->x"), + ONEARY_SHORT_STMT("x->{ return x; }"), + ONEARY_EXPR("(#M1 #T1 x)->x"), + ONEARY_STMT("(#M1 #T1 x)->{ return x; }"), + TWOARY_EXPR("(#M1 #T1 x, #M2 #T2 y)->x"), + TWOARY_STMT("(#M1 #T1 x, #M2 #T2 y)->{ return x; }"); + + String lambdaTemplate; + + LambdaKind(String lambdaTemplate) { + this.lambdaTemplate = lambdaTemplate; + } + + String getLambdaString(LambdaParameterKind pk1, LambdaParameterKind pk2, + ModifierKind mk1, ModifierKind mk2) { + return lambdaTemplate.replaceAll("#M1", mk1.modifier) + .replaceAll("#M2", mk2.modifier) + .replaceAll("#T1", pk1.parameterType) + .replaceAll("#T2", pk2.parameterType); + } + + int arity() { + switch (this) { + case NILARY_EXPR: + case NILARY_STMT: return 0; + case ONEARY_SHORT_EXPR: + case ONEARY_SHORT_STMT: + case ONEARY_EXPR: + case ONEARY_STMT: return 1; + case TWOARY_EXPR: + case TWOARY_STMT: return 2; + default: throw new AssertionError("Invalid lambda kind " + this); + } + } + + boolean isShort() { + return this == ONEARY_SHORT_EXPR || + this == ONEARY_SHORT_STMT; + } + } + + enum LambdaParameterKind { + IMPLICIT(""), + EXPLIICT_SIMPLE("A"), + EXPLICIT_VARARGS("A..."), + EXPLICIT_GENERIC1("A"), + EXPLICIT_GENERIC3("A"); + + String parameterType; + + LambdaParameterKind(String parameterType) { + this.parameterType = parameterType; + } + + boolean explicit() { + return this != IMPLICIT; + } + } + + enum ModifierKind { + NONE(""), + FINAL("final"), + PUBLIC("public"); + + String modifier; + + ModifierKind(String modifier) { + this.modifier = modifier; + } + + boolean compatibleWith(LambdaParameterKind pk) { + switch (this) { + case PUBLIC: return false; + case FINAL: return pk != LambdaParameterKind.IMPLICIT; + case NONE: return true; + default: throw new AssertionError("Invalid modifier kind " + this); + } + } + } + + enum ExprKind { + NONE("#L#S"), + SINGLE_PAREN1("(#L#S)"), + SINGLE_PAREN2("(#L)#S"), + DOUBLE_PAREN1("((#L#S))"), + DOUBLE_PAREN2("((#L)#S)"), + DOUBLE_PAREN3("((#L))#S"); + + String expressionTemplate; + + ExprKind(String expressionTemplate) { + this.expressionTemplate = expressionTemplate; + } + + String expressionString(LambdaParameterKind pk1, LambdaParameterKind pk2, + ModifierKind mk1, ModifierKind mk2, LambdaKind lk, SubExprKind sk) { + return expressionTemplate.replaceAll("#L", lk.getLambdaString(pk1, pk2, mk1, mk2)) + .replaceAll("#S", sk.subExpression); + } + } + + enum SubExprKind { + NONE(""), + SELECT_FIELD(".f"), + SELECT_METHOD(".f()"), + SELECT_NEW(".new Foo()"), + POSTINC("++"), + POSTDEC("--"); + + String subExpression; + + SubExprKind(String subExpression) { + this.subExpression = subExpression; + } + } + + public static void main(String... args) throws Exception { + + //create default shared JavaCompiler - reused across multiple compilations + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + for (LambdaKind lk : LambdaKind.values()) { + for (LambdaParameterKind pk1 : LambdaParameterKind.values()) { + if (lk.arity() < 1 && pk1 != LambdaParameterKind.IMPLICIT) continue; + for (LambdaParameterKind pk2 : LambdaParameterKind.values()) { + if (lk.arity() < 2 && pk2 != LambdaParameterKind.IMPLICIT) continue; + for (ModifierKind mk1 : ModifierKind.values()) { + if (mk1 != ModifierKind.NONE && lk.isShort()) continue; + if (lk.arity() < 1 && mk1 != ModifierKind.NONE) continue; + for (ModifierKind mk2 : ModifierKind.values()) { + if (lk.arity() < 2 && mk2 != ModifierKind.NONE) continue; + for (SubExprKind sk : SubExprKind.values()) { + for (ExprKind ek : ExprKind.values()) { + new LambdaParserTest(pk1, pk2, mk1, mk2, lk, sk, ek) + .run(comp, fm); + } + } + } + } + } + } + } + System.out.println("Total check executed: " + checkCount); + } + + LambdaParameterKind pk1; + LambdaParameterKind pk2; + ModifierKind mk1; + ModifierKind mk2; + LambdaKind lk; + SubExprKind sk; + ExprKind ek; + JavaSource source; + DiagnosticChecker diagChecker; + + LambdaParserTest(LambdaParameterKind pk1, LambdaParameterKind pk2, ModifierKind mk1, + ModifierKind mk2, LambdaKind lk, SubExprKind sk, ExprKind ek) { + this.pk1 = pk1; + this.pk2 = pk2; + this.mk1 = mk1; + this.mk2 = mk2; + this.lk = lk; + this.sk = sk; + this.ek = ek; + this.source = new JavaSource(); + this.diagChecker = new DiagnosticChecker(); + } + + class JavaSource extends SimpleJavaFileObject { + + String template = "class Test {\n" + + " SAM s = #E;\n" + + "}"; + + String source; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = template.replaceAll("#E", ek.expressionString(pk1, pk2, mk1, mk2, lk, sk)); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, + Arrays.asList("-XDallowLambda"), null, Arrays.asList(source)); + try { + ct.parse(); + } catch (Throwable ex) { + throw new AssertionError("Error thrown when parsing the following source:\n" + source.getCharContent(true)); + } + check(); + } + + void check() { + checkCount++; + + boolean errorExpected = (lk.arity() > 0 && !mk1.compatibleWith(pk1)) || + (lk.arity() > 1 && !mk2.compatibleWith(pk2)); + + if (lk.arity() == 2 && + (pk1.explicit() != pk2.explicit() || + pk1 == LambdaParameterKind.EXPLICIT_VARARGS)) { + errorExpected = true; + } + + if (errorExpected != diagChecker.errorFound) { + throw new Error("invalid diagnostics for source:\n" + + source.getCharContent(true) + + "\nFound error: " + diagChecker.errorFound + + "\nExpected error: " + errorExpected); + } + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + errorFound = true; + } + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/lambda/MethodReferenceParserTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/MethodReferenceParserTest.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7115052 + * @summary Add parser support for method references + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +public class MethodReferenceParserTest { + + static int checkCount = 0; + + enum ReferenceKind { + METHOD_REF("#Q##Gm"), + CONSTRUCTOR_REF("#Q##Gnew"), + FALSE_REF("min < max"), + ERR_SUPER("#Q##Gsuper"), + ERR_METH0("#Q##Gm()"), + ERR_METH1("#Q##Gm(X)"), + ERR_CONSTR0("#Q##Gnew()"), + ERR_CONSTR1("#Q##Gnew(X)"); + + String referenceTemplate; + + ReferenceKind(String referenceTemplate) { + this.referenceTemplate = referenceTemplate; + } + + String getReferenceString(QualifierKind qk, GenericKind gk) { + return referenceTemplate + .replaceAll("#Q", qk.qualifier) + .replaceAll("#G", gk.typeParameters); + } + + boolean erroneous() { + switch (this) { + case ERR_SUPER: + case ERR_METH0: + case ERR_METH1: + case ERR_CONSTR0: + case ERR_CONSTR1: + return true; + default: return false; + } + } + } + + enum ContextKind { + ASSIGN("SAM s = #E;"), + METHOD("m(#E, i);"); + + String contextTemplate; + + ContextKind(String contextTemplate) { + this.contextTemplate = contextTemplate; + } + + String contextString(ExprKind ek, ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk) { + return contextTemplate.replaceAll("#E", ek.expressionString(rk, qk, gk, sk)); + } + } + + enum GenericKind { + NONE(""), + ONE(""), + TWO(""); + + String typeParameters; + + GenericKind(String typeParameters) { + this.typeParameters = typeParameters; + } + } + + enum QualifierKind { + THIS("this"), + SUPER("super"), + NEW("new Foo()"), + METHOD("m()"), + FIELD("a.f"), + UBOUND_SIMPLE("A"), + UNBOUND_GENERIC1("A"), + UNBOUND_GENERIC2("A"), + UNBOUND_GENERIC3("A"), + UNBOUND_GENERIC4("A"), + NESTED_GENERIC1("A, A>"), + NESTED_GENERIC2("A,A>, A,A>>"); + + String qualifier; + + QualifierKind(String qualifier) { + this.qualifier = qualifier; + } + } + + enum ExprKind { + NONE("#R#S"), + SINGLE_PAREN1("(#R#S)"), + SINGLE_PAREN2("(#R)#S"), + DOUBLE_PAREN1("((#R#S))"), + DOUBLE_PAREN2("((#R)#S)"), + DOUBLE_PAREN3("((#R))#S"); + + String expressionTemplate; + + ExprKind(String expressionTemplate) { + this.expressionTemplate = expressionTemplate; + } + + String expressionString(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk) { + return expressionTemplate + .replaceAll("#R", rk.getReferenceString(qk, gk)) + .replaceAll("#S", sk.subExpression); + } + } + + enum SubExprKind { + NONE(""), + SELECT_FIELD(".f"), + SELECT_METHOD(".f()"), + SELECT_NEW(".new Foo()"), + POSTINC("++"), + POSTDEC("--"); + + String subExpression; + + SubExprKind(String subExpression) { + this.subExpression = subExpression; + } + } + + public static void main(String... args) throws Exception { + + //create default shared JavaCompiler - reused across multiple compilations + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + for (ReferenceKind rk : ReferenceKind.values()) { + for (QualifierKind qk : QualifierKind.values()) { + for (GenericKind gk : GenericKind.values()) { + for (SubExprKind sk : SubExprKind.values()) { + for (ExprKind ek : ExprKind.values()) { + for (ContextKind ck : ContextKind.values()) { + new MethodReferenceParserTest(rk, qk, gk, sk, ek, ck).run(comp, fm); + } + } + } + } + } + } + System.out.println("Total check executed: " + checkCount); + } + + ReferenceKind rk; + QualifierKind qk; + GenericKind gk; + SubExprKind sk; + ExprKind ek; + ContextKind ck; + JavaSource source; + DiagnosticChecker diagChecker; + + MethodReferenceParserTest(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk, ExprKind ek, ContextKind ck) { + this.rk = rk; + this.qk = qk; + this.gk = gk; + this.sk = sk; + this.ek = ek; + this.ck = ck; + this.source = new JavaSource(); + this.diagChecker = new DiagnosticChecker(); + } + + class JavaSource extends SimpleJavaFileObject { + + String template = "class Test {\n" + + " void test() {\n" + + " #C\n" + + " }" + + "}"; + + String source; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = template.replaceAll("#C", ck.contextString(ek, rk, qk, gk, sk)); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, + Arrays.asList("-XDallowMethodReferences"), null, Arrays.asList(source)); + try { + ct.parse(); + } catch (Throwable ex) { + throw new AssertionError("Error thrown when parsing the following source:\n" + source.getCharContent(true)); + } + check(); + } + + void check() { + checkCount++; + + if (diagChecker.errorFound != rk.erroneous()) { + throw new Error("invalid diagnostics for source:\n" + + source.getCharContent(true) + + "\nFound error: " + diagChecker.errorFound + + "\nExpected error: " + rk.erroneous()); + } + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + errorFound = true; + } + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/lib/CompileFail.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lib/CompileFail.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.*; +import java.util.*; +import com.sun.tools.javac.main.Main; + +/* + * Utility class to emulate jtreg @compile/fail, but also checking the specific + * exit code, given as the first arg. + */ +public class CompileFail { + public static void main(String... args) { + if (args.length < 2) + throw new IllegalArgumentException("insufficient args"); + int expected_rc = getReturnCode(args[0]); + + List javacArgs = new ArrayList<>(); + javacArgs.addAll(Arrays.asList( + "-bootclasspath", System.getProperty("sun.boot.class.path"), + "-d", "." + )); + + File testSrc = new File(System.getProperty("test.src")); + for (int i = 1; i < args.length; i++) { // skip first arg + String arg = args[i]; + if (arg.endsWith(".java")) + javacArgs.add(new File(testSrc, arg).getPath()); + else + javacArgs.add(arg); + } + + int rc = com.sun.tools.javac.Main.compile( + javacArgs.toArray(new String[javacArgs.size()])); + + if (rc != expected_rc) + throw new Error("unexpected exit code: " + rc + + ", expected: " + expected_rc); + } + + static int getReturnCode(String name) { + return Main.Result.valueOf(name).exitCode; + } + +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/lib/JavacTestingAbstractProcessor.java --- a/test/tools/javac/lib/JavacTestingAbstractProcessor.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/lib/JavacTestingAbstractProcessor.java Tue May 29 00:27:58 2012 +0100 @@ -25,6 +25,7 @@ import javax.annotation.processing.*; import javax.lang.model.SourceVersion; import javax.lang.model.util.*; +import static javax.lang.model.SourceVersion.*; /** * An abstract annotation processor tailored to javac regression testing. @@ -95,4 +96,164 @@ messager = processingEnv.getMessager(); options = processingEnv.getOptions(); } + + /* + * The set of visitors below will directly extend the most recent + * corresponding platform visitor type. + */ + + @SupportedSourceVersion(RELEASE_8) + public static abstract class AbstractAnnotationValueVisitor extends AbstractAnnotationValueVisitor8 { + + /** + * Constructor for concrete subclasses to call. + */ + protected AbstractAnnotationValueVisitor() { + super(); + } + } + + @SupportedSourceVersion(RELEASE_8) + public static abstract class AbstractElementVisitor extends AbstractElementVisitor8 { + /** + * Constructor for concrete subclasses to call. + */ + protected AbstractElementVisitor(){ + super(); + } + } + + @SupportedSourceVersion(RELEASE_8) + public static abstract class AbstractTypeVisitor extends AbstractTypeVisitor8 { + /** + * Constructor for concrete subclasses to call. + */ + protected AbstractTypeVisitor() { + super(); + } + } + + @SupportedSourceVersion(RELEASE_8) + public static class ElementKindVisitor extends ElementKindVisitor8 { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected ElementKindVisitor() { + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected ElementKindVisitor(R defaultValue) { + super(defaultValue); + } + } + + @SupportedSourceVersion(RELEASE_8) + public static class ElementScanner extends ElementScanner8 { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected ElementScanner(){ + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + */ + protected ElementScanner(R defaultValue){ + super(defaultValue); + } + } + + @SupportedSourceVersion(RELEASE_8) + public static class SimpleAnnotationValueVisitor extends SimpleAnnotationValueVisitor8 { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SimpleAnnotationValueVisitor() { + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SimpleAnnotationValueVisitor(R defaultValue) { + super(defaultValue); + } + } + + @SupportedSourceVersion(RELEASE_8) + public static class SimpleElementVisitor extends SimpleElementVisitor8 { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SimpleElementVisitor(){ + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SimpleElementVisitor(R defaultValue){ + super(defaultValue); + } + } + + @SupportedSourceVersion(RELEASE_8) + public static class SimpleTypeVisitor extends SimpleTypeVisitor8 { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SimpleTypeVisitor(){ + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SimpleTypeVisitor(R defaultValue){ + super(defaultValue); + } + } + + @SupportedSourceVersion(RELEASE_8) + public static class TypeKindVisitor extends TypeKindVisitor8 { + /** + * Constructor for concrete subclasses to call; uses {@code null} + * for the default value. + */ + protected TypeKindVisitor() { + super(null); + } + + /** + * Constructor for concrete subclasses to call; uses the argument + * for the default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected TypeKindVisitor(R defaultValue) { + super(defaultValue); + } + } } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/links/links.sh --- a/test/tools/javac/links/links.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/links/links.sh Tue May 29 00:27:58 2012 +0100 @@ -53,7 +53,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux ) + SunOS | Linux | Darwin ) NULL=/dev/null PS=":" FS="/" diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/multicatch/Neg06.out --- a/test/tools/javac/multicatch/Neg06.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/multicatch/Neg06.out Tue May 29 00:27:58 2012 +0100 @@ -1,3 +1,3 @@ -Neg06.java:14:16: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.String, java.lang.Throwable -Neg06.java:14:25: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Integer, java.lang.Throwable +Neg06.java:14:16: compiler.err.prob.found.req: java.lang.String, java.lang.Throwable +Neg06.java:14:25: compiler.err.prob.found.req: java.lang.Integer, java.lang.Throwable 2 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/multicatch/Neg07.out --- a/test/tools/javac/multicatch/Neg07.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/multicatch/Neg07.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -Neg07.java:14:56: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Class, java.lang.Class +Neg07.java:14:56: compiler.err.prob.found.req: java.lang.Class, java.lang.Class 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/multicatch/model/ModelChecker.java --- a/test/tools/javac/multicatch/model/ModelChecker.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/multicatch/model/ModelChecker.java Tue May 29 00:27:58 2012 +0100 @@ -23,7 +23,7 @@ /* * @test - * @bug 6993963 + * @bug 6993963 7025809 * @summary Project Coin: Use precise exception analysis for effectively final catch parameters * @library ../../lib * @build JavacTestingAbstractProcessor ModelChecker @@ -107,7 +107,7 @@ ; // Expected } - UnionType unionType = new SimpleTypeVisitor7(){ + UnionType unionType = new SimpleTypeVisitor(){ @Override protected UnionType defaultAction(TypeMirror e, Void p) {return null;} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/nativeHeaders/NativeHeaderTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/nativeHeaders/NativeHeaderTest.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,274 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7150368 + * @summary javac should include basic ability to generate native headers + */ + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; + +import com.sun.source.util.JavacTask; +import com.sun.tools.javac.api.JavacTool; + +public class NativeHeaderTest { + public static void main(String... args) throws Exception { + new NativeHeaderTest().run(); + } + + /** How to invoke javac. */ + enum RunKind { + /** Use the command line entry point. */ + CMD, + /** Use the JavaCompiler API. */ + API + }; + + /** Which classes for which to generate headers. */ + enum GenKind { + /** Just classes with native methods or the marker annotation. */ + SIMPLE, + /** All appropriate classes within the top level class. */ + FULL + }; + + // ---------- Test cases, invoked reflectively via run. ---------- + + @Test + void simpleTest(RunKind rk, GenKind gk) throws Exception { + List files = new ArrayList(); + files.add(createFile("p/C.java", + "class C { native void m(); }")); + + Set expect = createSet("C.h"); + + test(rk, gk, files, expect); + } + + @Test + void nestedClassTest(RunKind rk, GenKind gk) throws Exception { + List files = new ArrayList(); + files.add(createFile("p/C.java", + "class C { static class Inner { native void m(); } }")); + + Set expect = createSet("C_Inner.h"); + if (gk == GenKind.FULL) expect.add("C.h"); + + test(rk, gk, files, expect); + } + + @Test + void localClassTest(RunKind rk, GenKind gk) throws Exception { + List files = new ArrayList(); + files.add(createFile("p/C.java", + "class C { native void m(); void m2() { class Local { } } }")); + + Set expect = createSet("C.h"); + + test(rk, gk, files, expect); + } + + @Test + void syntheticClassTest(RunKind rk, GenKind gk) throws Exception { + List files = new ArrayList(); + files.add(createFile("p/C.java", + "class C {\n" + + " private C() { }\n" + + " class Inner extends C { native void m(); }\n" + + "}")); + + Set expect = createSet("C_Inner.h"); + if (gk == GenKind.FULL) expect.add("C.h"); + + test(rk, gk, files, expect); + + // double check the synthetic class was generated + checkEqual("generatedClasses", + createSet("C.class", "C$1.class", "C$Inner.class"), + createSet(classesDir.list())); + } + + @Test + void annoTest(RunKind rk, GenKind gk) throws Exception { + List files = new ArrayList(); + files.add(createFile("p/C.java", + "@javax.tools.annotation.GenerateNativeHeader class C { }")); + + Set expect = createSet("C.h"); + + test(rk, gk, files, expect); + } + + @Test + void annoNestedClassTest(RunKind rk, GenKind gk) throws Exception { + List files = new ArrayList(); + files.add(createFile("p/C.java", + "class C { @javax.tools.annotation.GenerateNativeHeader class Inner { } }")); + + Set expect = createSet("C_Inner.h"); + if (gk == GenKind.FULL) expect.add("C.h"); + + test(rk, gk, files, expect); + } + + /** + * The worker method for each test case. + * Compile the files and verify that exactly the expected set of header files + * is generated. + */ + void test(RunKind rk, GenKind gk, List files, Set expect) throws Exception { + List args = new ArrayList(); + if (gk == GenKind.FULL) + args.add("-XDjavah:full"); + + switch (rk) { + case CMD: + args.add("-d"); + args.add(classesDir.getPath()); + args.add("-h"); + args.add(headersDir.getPath()); + for (File f: files) + args.add(f.getPath()); + int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()])); + if (rc != 0) + throw new Exception("compilation failed, rc=" + rc); + break; + + case API: + fm.setLocation(StandardLocation.SOURCE_PATH, Arrays.asList(srcDir)); + fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(classesDir)); + fm.setLocation(StandardLocation.NATIVE_HEADER_OUTPUT, Arrays.asList(headersDir)); + JavacTask task = javac.getTask(null, fm, null, args, null, + fm.getJavaFileObjectsFromFiles(files)); + if (!task.call()) + throw new Exception("compilation failed"); + break; + } + + Set found = createSet(headersDir.list()); + checkEqual("header files", expect, found); + } + + /** Marker annotation for test cases. */ + @Retention(RetentionPolicy.RUNTIME) + @interface Test { } + + /** Combo test to run all test cases in all modes. */ + void run() throws Exception { + javac = JavacTool.create(); + fm = javac.getStandardFileManager(null, null, null); + + for (RunKind rk: RunKind.values()) { + for (GenKind gk: GenKind.values()) { + for (Method m: getClass().getDeclaredMethods()) { + Annotation a = m.getAnnotation(Test.class); + if (a != null) { + init(rk, gk, m.getName()); + try { + m.invoke(this, new Object[] { rk, gk }); + } catch (InvocationTargetException e) { + Throwable cause = e.getCause(); + throw (cause instanceof Exception) ? ((Exception) cause) : e; + } + System.err.println(); + } + } + } + } + System.err.println(testCount + " tests" + ((errorCount == 0) ? "" : ", " + errorCount + " errors")); + if (errorCount > 0) + throw new Exception(errorCount + " errors found"); + } + + /** + * Init directories for a test case. + */ + void init(RunKind rk, GenKind gk, String name) throws IOException { + System.err.println("Test " + rk + " " + gk + " " + name); + testCount++; + + testDir = new File(rk.toString().toLowerCase() + "_" + gk.toString().toLowerCase() + "-" + name); + srcDir = new File(testDir, "src"); + srcDir.mkdirs(); + classesDir = new File(testDir, "classes"); + classesDir.mkdirs(); + headersDir = new File(testDir, "headers"); + headersDir.mkdirs(); + } + + /** Create a source file with given body text. */ + File createFile(String path, final String body) throws IOException { + File f = new File(srcDir, path); + f.getParentFile().mkdirs(); + try (FileWriter out = new FileWriter(f)) { + out.write(body); + } + return f; + } + + /** Convenience method to create a set of items. */ + Set createSet(T... items) { + return new HashSet(Arrays.asList(items)); + } + + /** Convenience method to check two values are equal, and report an error if not. */ + void checkEqual(String label, T expect, T found) { + if ((found == null) ? (expect == null) : found.equals(expect)) + return; + System.err.println("Error: mismatch"); + System.err.println(" expected: " + expect); + System.err.println(" found: " + found); + errorCount++; + } + + // Shared across API test cases + JavacTool javac; + StandardJavaFileManager fm; + + // Directories set up by init + File testDir; + File srcDir; + File classesDir; + File headersDir; + + // Statistics + int testCount; + int errorCount; +} + diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/nativeHeaders/javahComparison/CompareTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2007,2012 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7150368 + * @summary javac should include basic ability to generate native headers + */ + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class CompareTest { + public static void main(String... args) throws Exception { + new CompareTest().run(); + } + + void run() throws Exception { + File srcDir = new File(System.getProperty("test.src")); + File classesDir = new File("classes"); + classesDir.mkdirs(); + File javacHeaders = new File("headers.javac"); + javacHeaders.mkdirs(); + File javahHeaders = new File("headers.javah"); + javahHeaders.mkdirs(); + + List javacArgs = new ArrayList(); + javacArgs.add("-d"); + javacArgs.add(classesDir.getPath()); + javacArgs.add("-h"); + javacArgs.add(javacHeaders.getPath()); + javacArgs.add("-XDjavah:full"); + + for (File f: srcDir.listFiles()) { + if (f.getName().matches("TestClass[0-9]+\\.java")) { + sourceFileCount++; + javacArgs.add(f.getPath()); + } + } + + int rc = com.sun.tools.javac.Main.compile(javacArgs.toArray(new String[javacArgs.size()])); + if (rc != 0) + throw new Exception("javac failed; rc=" + rc); + + List javahArgs = new ArrayList(); + javahArgs.add("-d"); + javahArgs.add(javahHeaders.getPath()); + + for (File f: classesDir.listFiles()) { + if (f.getName().endsWith(".class")) { + javahArgs.add(inferBinaryName(f)); + } + } + + PrintWriter pw = new PrintWriter(System.out, true); + rc = com.sun.tools.javah.Main.run(javahArgs.toArray(new String[javahArgs.size()]), pw); + if (rc != 0) + throw new Exception("javah failed; rc=" + rc); + + compare(javahHeaders, javacHeaders); + + int javahHeaderCount = javahHeaders.list().length; + int javacHeaderCount = javacHeaders.list().length; + + System.out.println(sourceFileCount + " .java files found"); + System.out.println(javacHeaderCount + " .h files generated by javac"); + System.out.println(javahHeaderCount + " .h files generated by javah"); + System.out.println(compareCount + " header files compared"); + + if (javacHeaderCount != javahHeaderCount || javacHeaderCount != compareCount) + error("inconsistent counts"); + + if (errors > 0) + throw new Exception(errors + " errors occurred"); + } + + String inferBinaryName(File file) { + String name = file.getName(); + return name.substring(0, name.length() - ".class".length()).replace("$", "."); + } + + /** Compare two directories. + * @param f1 The golden directory + * @param f2 The directory to be compared + */ + void compare(File f1, File f2) { + compare(f1, f2, null); + } + + /** Compare two files or directories + * @param f1 The golden directory + * @param f2 The directory to be compared + * @param p An optional path identifying a file within the two directories + */ + void compare(File f1, File f2, String p) { + File f1p = (p == null ? f1 : new File(f1, p)); + File f2p = (p == null ? f2 : new File(f2, p)); + if (f1p.isDirectory() && f2p.isDirectory()) { + Set children = new HashSet(); + children.addAll(Arrays.asList(f1p.list())); + children.addAll(Arrays.asList(f2p.list())); + for (String c: children) { + compare(f1, f2, new File(p, c).getPath()); // null-safe for p + } + } + else if (f1p.isFile() && f2p.isFile()) { + System.out.println("checking " + p); + compareCount++; + String s1 = read(f1p); + String s2 = read(f2p); + if (!s1.equals(s2)) { + System.out.println("File: " + f1p + "\n" + s1); + System.out.println("File: " + f2p + "\n" + s2); + error("Files differ: " + f1p + " " + f2p); + } + } + else if (f1p.exists() && !f2p.exists()) + error("Only in " + f1 + ": " + p); + else if (f2p.exists() && !f1p.exists()) + error("Only in " + f2 + ": " + p); + else + error("Files differ: " + f1p + " " + f2p); + } + + private String read(File f) { + try { + return new String(Files.readAllBytes(f.toPath())); + } catch (IOException e) { + error("error reading " + f + ": " + e); + return ""; + } + } + + private void error(String msg) { + System.out.println(msg); + errors++; + } + + private int errors; + private int compareCount; + private int sourceFileCount; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/nativeHeaders/javahComparison/TestClass1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/nativeHeaders/javahComparison/TestClass1.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,475 @@ +/* + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.List; + +public class TestClass1 { + // simple types + byte b; + short s; + int i; + long l; + float f; + double d; + Object o; + String t; + List g; + + // constants + static final byte bc = 0; + static final short sc = 0; + static final int ic = 0; + static final long lc = 0; + static final float fc = 0; + static final double dc = 0; + static final Object oc = null; + static final String tc = ""; + static final List gc = null; + + // simple arrays + byte[] ba; + short[] sa; // not handled corrected by javah v6 + int[] ia; + long[] la; + float[] fa; + double[] da; + Object[] oa; + String[] ta; + List[] ga; + + // multidimensional arrays + byte[][] baa; + short[][] saa; + int[][] iaa; + long[][] laa; + float[][] faa; + double[][] daa; + Object[][] oaa; + String[][] taa; + List[] gaa; + + // simple Java methods + byte bm() { return 0; } + short sm() { return 0; } + int im() { return 0; } + long lm() { return 0; } + float fm() { return 0; } + double dm() { return 0; } + Object om() { return null; } + String tm() { return ""; } + List gm() { return null; } + void vm() { } + byte[] bam() { return null; } + short[] sam() { return null; } + int[] iam() { return null; } + long[] lam() { return null; } + float[] fam() { return null; } + double[] dam() { return null; } + Object[] oam() { return null; } + String[] tam() { return null; } + List[] gam() { return null; } + byte[][] baam() { return null; } + short[][] saam() { return null; } + int[][] iaam() { return null; } + long[][] laam() { return null; } + float[][] faam() { return null; } + double[][] daam() { return null; } + Object[][] oaam() { return null; } + String[][] taam() { return null; } + List[] gaam() { return null; } + + // simple native methods + native byte bmn(); + native short smn(); + native int imn(); + native long lmn(); + native float fmn(); + native double dmn(); + native Object omn(); + native String tmn(); + native List gmn(); + native void vmn(); + native byte[] bamn(); + native short[] samn(); + native int[] iamn(); + native long[] lamn(); + native float[] famn(); + native double[] damn(); + native Object[] oamn(); + native String[] tamn(); + native List[] gamn(); + native byte[][] baamn(); + native short[][] saamn(); + native int[][] iaamn(); + native long[][] laamn(); + native float[][] faamn(); + native double[][] daamn(); + native Object[][] oaamn(); + native String[][] taamn(); + native List[] gaamn(); + + // overloaded Java methods + byte bm1() { return 0; } + short sm1() { return 0; } + int im1() { return 0; } + long lm1() { return 0; } + float fm1() { return 0; } + double dm1() { return 0; } + Object om1() { return null; } + String tm1() { return ""; } + List gm1() { return null; } + void vm1() { } + + byte bm2(int i) { return 0; } + short sm2(int i) { return 0; } + int im2(int i) { return 0; } + long lm2(int i) { return 0; } + float fm2(int i) { return 0; } + double dm2(int i) { return 0; } + Object om2(int i) { return null; } + String tm2(int i) { return ""; } + List gm2(int i) { return null; } + void vm2(int i) { } + + // overloaded native methods + native byte bmn1(); + native short smn1(); + native int imn1(); + native long lmn1(); + native float fmn1(); + native double dmn1(); + native Object omn1(); + native String tmn1(); + native List gmn1(); + native void vmn1(); + + native byte bmn2(int i); + native short smn2(int i); + native int imn2(int i); + native long lmn2(int i); + native float fmn2(int i); + native double dmn2(int i); + native Object omn2(int i); + native String tmn2(int i); + native List gmn2(int i); + native void vmn2(int i); + + // arg types for Java methods + void mb(byte b) { } + void ms(short s) { } + void mi(int i) { } + void ml(long l) { } + void mf(float f) { } + void md(double d) { } + void mo(Object o) { } + void mt(String t) { } + void mg(List g) { } + + // arg types for native methods + native void mbn(byte b); + native void msn(short s); + native void min(int i); + native void mln(long l); + native void mfn(float f); + native void mdn(double d); + native void mon(Object o); + native void mtn(String t); + native void mgn(List g); + + static class Inner1 { + // simple types + byte b; + short s; + int i; + long l; + float f; + double d; + Object o; + String t; + List g; + + // constants + static final byte bc = 0; + static final short sc = 0; + static final int ic = 0; + static final long lc = 0; + static final float fc = 0; + static final double dc = 0; + static final Object oc = null; + static final String tc = ""; + static final List gc = null; + + // simple arrays + byte[] ba; + // short[] sa; // not handled corrected by javah v6 + int[] ia; + long[] la; + float[] fa; + double[] da; + Object[] oa; + String[] ta; + List[] ga; + + // multidimensional arrays + byte[][] baa; + short[][] saa; + int[][] iaa; + long[][] laa; + float[][] faa; + double[][] daa; + Object[][] oaa; + String[][] taa; + List[] gaa; + + // simple Java methods + byte bm() { return 0; } + short sm() { return 0; } + int im() { return 0; } + long lm() { return 0; } + float fm() { return 0; } + double dm() { return 0; } + Object om() { return null; } + String tm() { return ""; } + List gm() { return null; } + void vm() { } + + // simple native methods + native byte bmn(); + native short smn(); + native int imn(); + native long lmn(); + native float fmn(); + native double dmn(); + native Object omn(); + native String tmn(); + native List gmn(); + native void vmn(); + + // overloaded Java methods + byte bm1() { return 0; } + short sm1() { return 0; } + int im1() { return 0; } + long lm1() { return 0; } + float fm1() { return 0; } + double dm1() { return 0; } + Object om1() { return null; } + String tm1() { return ""; } + List gm1() { return null; } + void vm1() { } + + byte bm2(int i) { return 0; } + short sm2(int i) { return 0; } + int im2(int i) { return 0; } + long lm2(int i) { return 0; } + float fm2(int i) { return 0; } + double dm2(int i) { return 0; } + Object om2(int i) { return null; } + String tm2(int i) { return ""; } + List gm2(int i) { return null; } + void vm2(int i) { } + + // overloaded native methods + native byte bmn1(); + native short smn1(); + native int imn1(); + native long lmn1(); + native float fmn1(); + native double dmn1(); + native Object omn1(); + native String tmn1(); + native List gmn1(); + native void vmn1(); + + native byte bmn2(int i); + native short smn2(int i); + native int imn2(int i); + native long lmn2(int i); + native float fmn2(int i); + native double dmn2(int i); + native Object omn2(int i); + native String tmn2(int i); + native List gmn2(int i); + native void vmn2(int i); + + // arg types for Java methods + void mb(byte b) { } + void ms(short s) { } + void mi(int i) { } + void ml(long l) { } + void mf(float f) { } + void md(double d) { } + void mo(Object o) { } + void mt(String t) { } + void mg(List g) { } + + // arg types for native methods + native void mbn(byte b); + native void msn(short s); + native void min(int i); + native void mln(long l); + native void mfn(float f); + native void mdn(double d); + native void mon(Object o); + native void mtn(String t); + native void mgn(List g); + } + + class Inner2 { + // simple types + byte b; + short s; + int i; + long l; + float f; + double d; + Object o; + String t; + List g; + + // constants + static final byte bc = 0; + static final short sc = 0; + static final int ic = 0; + static final long lc = 0; + static final float fc = 0; + static final double dc = 0; + //static final Object oc = null; + static final String tc = ""; + //static final List gc = null; + + // simple arrays + byte[] ba; + // short[] sa; // not handled corrected by javah v6 + int[] ia; + long[] la; + float[] fa; + double[] da; + Object[] oa; + String[] ta; + List[] ga; + + // multidimensional arrays + byte[][] baa; + short[][] saa; + int[][] iaa; + long[][] laa; + float[][] faa; + double[][] daa; + Object[][] oaa; + String[][] taa; + List[] gaa; + + // simple Java methods + byte bm() { return 0; } + short sm() { return 0; } + int im() { return 0; } + long lm() { return 0; } + float fm() { return 0; } + double dm() { return 0; } + Object om() { return null; } + String tm() { return ""; } + List gm() { return null; } + void vm() { } + + // simple native methods + native byte bmn(); + native short smn(); + native int imn(); + native long lmn(); + native float fmn(); + native double dmn(); + native Object omn(); + native String tmn(); + native List gmn(); + native void vmn(); + + // overloaded Java methods + byte bm1() { return 0; } + short sm1() { return 0; } + int im1() { return 0; } + long lm1() { return 0; } + float fm1() { return 0; } + double dm1() { return 0; } + Object om1() { return null; } + String tm1() { return ""; } + List gm1() { return null; } + void vm1() { } + + byte bm2(int i) { return 0; } + short sm2(int i) { return 0; } + int im2(int i) { return 0; } + long lm2(int i) { return 0; } + float fm2(int i) { return 0; } + double dm2(int i) { return 0; } + Object om2(int i) { return null; } + String tm2(int i) { return ""; } + List gm2(int i) { return null; } + void vm2(int i) { } + + // overloaded native methods + native byte bmn1(); + native short smn1(); + native int imn1(); + native long lmn1(); + native float fmn1(); + native double dmn1(); + native Object omn1(); + native String tmn1(); + native List gmn1(); + native void vmn1(); + + native byte bmn2(int i); + native short smn2(int i); + native int imn2(int i); + native long lmn2(int i); + native float fmn2(int i); + native double dmn2(int i); + native Object omn2(int i); + native String tmn2(int i); + native List gmn2(int i); + native void vmn2(int i); + + // arg types for Java methods + void mb(byte b) { } + void ms(short s) { } + void mi(int i) { } + void ml(long l) { } + void mf(float f) { } + void md(double d) { } + void mo(Object o) { } + void mt(String t) { } + void mg(List g) { } + + // arg types for native methods + native void mbn(byte b); + native void msn(short s); + native void min(int i); + native void mln(long l); + native void mfn(float f); + native void mdn(double d); + native void mon(Object o); + native void mtn(String t); + native void mgn(List g); + } + +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/nativeHeaders/javahComparison/TestClass2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/nativeHeaders/javahComparison/TestClass2.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.tools.annotation.GenerateNativeHeader; + +@GenerateNativeHeader +public class TestClass2 { + byte b; + short s; + int i; + long l; + float f; + double d; + Object o; + String t; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/nativeHeaders/javahComparison/TestClass3.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/nativeHeaders/javahComparison/TestClass3.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.tools.annotation.GenerateNativeHeader; + +@GenerateNativeHeader +public class TestClass3 { + public int tc3; + + public class Inner1 { + public int tc3i1; + + public class Inner1A { + public int tc3i1i1a; + } + + public class Inner1B { + public int tc3i1i1b; + } + } + + public class Inner2 { + public int tc321; + + public class Inner2A { + public int tc3i2i2a; + } + + public class Inner2B { + public int tc3i2i2b; + } + } +} + diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/newlines/Newlines.sh --- a/test/tools/javac/newlines/Newlines.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/newlines/Newlines.sh Tue May 29 00:27:58 2012 +0100 @@ -50,7 +50,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | CYGWIN* ) + SunOS | Linux | Darwin | CYGWIN* ) FS="/" ;; Windows* ) diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/parser/7157165/T7157165.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/parser/7157165/T7157165.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,12 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7157165 + * + * @summary Regression: code with disjunctive type crashes javac + * @compile/fail/ref=T7157165.out -XDrawDiagnostics T7157165.java + * + */ + +class T7157165 { + Foo foo1 = null; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/parser/7157165/T7157165.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/parser/7157165/T7157165.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,4 @@ +T7157165.java:11:20: compiler.err.expected: > +T7157165.java:11:21: compiler.err.expected: ';' +T7157165.java:11:22: compiler.err.illegal.start.of.type +3 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/parser/JavacParserTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/parser/JavacParserTest.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,932 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7073631 7159445 + * @summary tests error and diagnostics positions + * @author Jan Lahoda + */ + +import com.sun.source.tree.BinaryTree; +import com.sun.source.tree.BlockTree; +import com.sun.source.tree.ClassTree; +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.ErroneousTree; +import com.sun.source.tree.ExpressionStatementTree; +import com.sun.source.tree.ExpressionTree; +import com.sun.source.tree.MethodInvocationTree; +import com.sun.source.tree.MethodTree; +import com.sun.source.tree.ModifiersTree; +import com.sun.source.tree.StatementTree; +import com.sun.source.tree.Tree; +import com.sun.source.tree.Tree.Kind; +import com.sun.source.tree.VariableTree; +import com.sun.source.tree.WhileLoopTree; +import com.sun.source.util.SourcePositions; +import com.sun.source.util.TreeScanner; +import com.sun.source.util.Trees; +import com.sun.tools.javac.api.JavacTaskImpl; +import com.sun.tools.javac.tree.JCTree; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticCollector; +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +public class JavacParserTest extends TestCase { + final JavaCompiler tool; + public JavacParserTest(String testName) { + tool = ToolProvider.getSystemJavaCompiler(); + System.out.println("java.home=" + System.getProperty("java.home")); + } + + static class MyFileObject extends SimpleJavaFileObject { + + private String text; + + public MyFileObject(String text) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + this.text = text; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return text; + } + } + /* + * converts Windows to Unix style LFs for comparing strings + */ + private String normalize(String in) { + return in.replace(System.getProperty("line.separator"), "\n"); + } + + public CompilationUnitTree getCompilationUnitTree(String code) throws IOException { + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, + null, Arrays.asList(new MyFileObject(code))); + CompilationUnitTree cut = ct.parse().iterator().next(); + return cut; + } + + public List getErroneousTreeValues(ErroneousTree node) { + + List values = new ArrayList<>(); + if (node.getErrorTrees() != null) { + for (Tree t : node.getErrorTrees()) { + values.add(t.toString()); + } + } else { + throw new RuntimeException("ERROR: No Erroneous tree " + + "has been created."); + } + return values; + } + + public void testPositionForSuperConstructorCalls() throws IOException { + assert tool != null; + + String code = "package test; public class Test {public Test() {super();}}"; + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, + null, Arrays.asList(new MyFileObject(code))); + CompilationUnitTree cut = ct.parse().iterator().next(); + SourcePositions pos = Trees.instance(ct).getSourcePositions(); + + MethodTree method = + (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0); + ExpressionStatementTree es = + (ExpressionStatementTree) method.getBody().getStatements().get(0); + + final int esStartPos = code.indexOf(es.toString()); + final int esEndPos = esStartPos + es.toString().length(); + assertEquals("testPositionForSuperConstructorCalls", + esStartPos, pos.getStartPosition(cut, es)); + assertEquals("testPositionForSuperConstructorCalls", + esEndPos, pos.getEndPosition(cut, es)); + + MethodInvocationTree mit = (MethodInvocationTree) es.getExpression(); + + final int mitStartPos = code.indexOf(mit.toString()); + final int mitEndPos = mitStartPos + mit.toString().length(); + assertEquals("testPositionForSuperConstructorCalls", + mitStartPos, pos.getStartPosition(cut, mit)); + assertEquals("testPositionForSuperConstructorCalls", + mitEndPos, pos.getEndPosition(cut, mit)); + + final int methodStartPos = mitStartPos; + final int methodEndPos = methodStartPos + mit.getMethodSelect().toString().length(); + assertEquals("testPositionForSuperConstructorCalls", + methodStartPos, pos.getStartPosition(cut, mit.getMethodSelect())); + assertEquals("testPositionForSuperConstructorCalls", + methodEndPos, pos.getEndPosition(cut, mit.getMethodSelect())); + + } + + public void testPositionForEnumModifiers() throws IOException { + + String code = "package test; public enum Test {A;}"; + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, + null, Arrays.asList(new MyFileObject(code))); + CompilationUnitTree cut = ct.parse().iterator().next(); + SourcePositions pos = Trees.instance(ct).getSourcePositions(); + + ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0); + ModifiersTree mt = clazz.getModifiers(); + + assertEquals("testPositionForEnumModifiers", + 38 - 24, pos.getStartPosition(cut, mt)); + assertEquals("testPositionForEnumModifiers", + 44 - 24, pos.getEndPosition(cut, mt)); + } + + public void testNewClassWithEnclosing() throws IOException { + + + String code = "package test; class Test { " + + "class d {} private void method() { " + + "Object o = Test.this.new d(); } }"; + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, + null, Arrays.asList(new MyFileObject(code))); + CompilationUnitTree cut = ct.parse().iterator().next(); + SourcePositions pos = Trees.instance(ct).getSourcePositions(); + + ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0); + ExpressionTree est = + ((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer(); + + assertEquals("testNewClassWithEnclosing", + 97 - 24, pos.getStartPosition(cut, est)); + assertEquals("testNewClassWithEnclosing", + 114 - 24, pos.getEndPosition(cut, est)); + } + + public void testPreferredPositionForBinaryOp() throws IOException { + + String code = "package test; public class Test {" + + "private void test() {" + + "Object o = null; boolean b = o != null && o instanceof String;" + + "} private Test() {}}"; + + CompilationUnitTree cut = getCompilationUnitTree(code); + ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0); + MethodTree method = (MethodTree) clazz.getMembers().get(0); + VariableTree condSt = (VariableTree) method.getBody().getStatements().get(1); + BinaryTree cond = (BinaryTree) condSt.getInitializer(); + + JCTree condJC = (JCTree) cond; + int condStartPos = code.indexOf("&&"); + assertEquals("testPreferredPositionForBinaryOp", + condStartPos, condJC.pos); + } + + public void testPositionBrokenSource126732a() throws IOException { + String[] commands = new String[]{ + "return Runnable()", + "do { } while (true)", + "throw UnsupportedOperationException()", + "assert true", + "1 + 1",}; + + for (String command : commands) { + + String code = "package test;\n" + + "public class Test {\n" + + " public static void test() {\n" + + " " + command + " {\n" + + " new Runnable() {\n" + + " };\n" + + " }\n" + + "}"; + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, + null, null, Arrays.asList(new MyFileObject(code))); + CompilationUnitTree cut = ct.parse().iterator().next(); + + ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0); + MethodTree method = (MethodTree) clazz.getMembers().get(0); + List statements = + method.getBody().getStatements(); + + StatementTree ret = statements.get(0); + StatementTree block = statements.get(1); + + Trees t = Trees.instance(ct); + int len = code.indexOf(command + " {") + (command + " ").length(); + assertEquals(command, len, + t.getSourcePositions().getEndPosition(cut, ret)); + assertEquals(command, len, + t.getSourcePositions().getStartPosition(cut, block)); + } + } + + public void testPositionBrokenSource126732b() throws IOException { + String[] commands = new String[]{ + "break", + "break A", + "continue ", + "continue A",}; + + for (String command : commands) { + + String code = "package test;\n" + + "public class Test {\n" + + " public static void test() {\n" + + " while (true) {\n" + + " " + command + " {\n" + + " new Runnable() {\n" + + " };\n" + + " }\n" + + " }\n" + + "}"; + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, + null, null, Arrays.asList(new MyFileObject(code))); + CompilationUnitTree cut = ct.parse().iterator().next(); + + ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0); + MethodTree method = (MethodTree) clazz.getMembers().get(0); + List statements = + ((BlockTree) ((WhileLoopTree) method.getBody().getStatements().get(0)).getStatement()).getStatements(); + + StatementTree ret = statements.get(0); + StatementTree block = statements.get(1); + + Trees t = Trees.instance(ct); + int len = code.indexOf(command + " {") + (command + " ").length(); + assertEquals(command, len, + t.getSourcePositions().getEndPosition(cut, ret)); + assertEquals(command, len, + t.getSourcePositions().getStartPosition(cut, block)); + } + } + + public void testErrorRecoveryForEnhancedForLoop142381() throws IOException { + + String code = "package test; class Test { " + + "private void method() { " + + "java.util.Set s = null; for (a : s) {} } }"; + + final List> errors = + new LinkedList>(); + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, + new DiagnosticListener() { + public void report(Diagnostic diagnostic) { + errors.add(diagnostic); + } + }, null, null, Arrays.asList(new MyFileObject(code))); + + CompilationUnitTree cut = ct.parse().iterator().next(); + + ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0); + StatementTree forStatement = + ((MethodTree) clazz.getMembers().get(0)).getBody().getStatements().get(1); + + assertEquals("testErrorRecoveryForEnhancedForLoop142381", + Kind.ENHANCED_FOR_LOOP, forStatement.getKind()); + assertFalse("testErrorRecoveryForEnhancedForLoop142381", errors.isEmpty()); + } + + public void testPositionAnnotationNoPackage187551() throws IOException { + + String code = "\n@interface Test {}"; + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, + null, Arrays.asList(new MyFileObject(code))); + + CompilationUnitTree cut = ct.parse().iterator().next(); + ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0); + Trees t = Trees.instance(ct); + + assertEquals("testPositionAnnotationNoPackage187551", + 1, t.getSourcePositions().getStartPosition(cut, clazz)); + } + + public void testPositionsSane() throws IOException { + performPositionsSanityTest("package test; class Test { " + + "private void method() { " + + "java.util.List> l; " + + "} }"); + performPositionsSanityTest("package test; class Test { " + + "private void method() { " + + "java.util.List> l; " + + "} }"); + performPositionsSanityTest("package test; class Test { " + + "private void method() { " + + "java.util.List> l; } }"); + } + + private void performPositionsSanityTest(String code) throws IOException { + + final List> errors = + new LinkedList>(); + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, + new DiagnosticListener() { + + public void report(Diagnostic diagnostic) { + errors.add(diagnostic); + } + }, null, null, Arrays.asList(new MyFileObject(code))); + + final CompilationUnitTree cut = ct.parse().iterator().next(); + final Trees trees = Trees.instance(ct); + + new TreeScanner() { + + private long parentStart = 0; + private long parentEnd = Integer.MAX_VALUE; + + @Override + public Void scan(Tree node, Void p) { + if (node == null) { + return null; + } + + long start = trees.getSourcePositions().getStartPosition(cut, node); + + if (start == (-1)) { + return null; //synthetic tree + } + assertTrue(node.toString() + ":" + start + "/" + parentStart, + parentStart <= start); + + long prevParentStart = parentStart; + + parentStart = start; + + long end = trees.getSourcePositions().getEndPosition(cut, node); + + assertTrue(node.toString() + ":" + end + "/" + parentEnd, + end <= parentEnd); + + long prevParentEnd = parentEnd; + + parentEnd = end; + + super.scan(node, p); + + parentStart = prevParentStart; + parentEnd = prevParentEnd; + + return null; + } + + private void assertTrue(String message, boolean b) { + if (!b) fail(message); + } + }.scan(cut, null); + } + + public void testCorrectWilcardPositions() throws IOException { + performWildcardPositionsTest("package test; import java.util.List; " + + "class Test { private void method() { List> l; } }", + + Arrays.asList("List> l;", + "List>", + "List", + "? extends List", + "List", + "List", + "? extends String", + "String")); + performWildcardPositionsTest("package test; import java.util.List; " + + "class Test { private void method() { List> l; } }", + + Arrays.asList("List> l;", + "List>", + "List", + "? super List", + "List", + "List", + "? super String", + "String")); + performWildcardPositionsTest("package test; import java.util.List; " + + "class Test { private void method() { List> l; } }", + + Arrays.asList("List> l;", + "List>", + "List", + "? super List", + "List", + "List", + "?")); + performWildcardPositionsTest("package test; import java.util.List; " + + "class Test { private void method() { " + + "List>> l; } }", + + Arrays.asList("List>> l;", + "List>>", + "List", + "? extends List>", + "List>", + "List", + "? extends List", + "List", + "List", + "? extends String", + "String")); + performWildcardPositionsTest("package test; import java.util.List; " + + "class Test { private void method() { " + + "List>> l; } }", + Arrays.asList("List>> l;", + "List>>", + "List", + "? extends List>", + "List>", + "List", + "? extends List", + "List", + "List", + "? extends String", + "String")); + } + + public void performWildcardPositionsTest(final String code, + List golden) throws IOException { + + final List> errors = + new LinkedList>(); + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, + new DiagnosticListener() { + public void report(Diagnostic diagnostic) { + errors.add(diagnostic); + } + }, null, null, Arrays.asList(new MyFileObject(code))); + + final CompilationUnitTree cut = ct.parse().iterator().next(); + final List content = new LinkedList(); + final Trees trees = Trees.instance(ct); + + new TreeScanner() { + @Override + public Void scan(Tree node, Void p) { + if (node == null) { + return null; + } + long start = trees.getSourcePositions().getStartPosition(cut, node); + + if (start == (-1)) { + return null; //synthetic tree + } + long end = trees.getSourcePositions().getEndPosition(cut, node); + String s = code.substring((int) start, (int) end); + content.add(s); + + return super.scan(node, p); + } + }.scan(((MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0)).getBody().getStatements().get(0), null); + + assertEquals("performWildcardPositionsTest",golden.toString(), + content.toString()); + } + + public void testStartPositionForMethodWithoutModifiers() throws IOException { + + String code = "package t; class Test { void t() {} }"; + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, + null, Arrays.asList(new MyFileObject(code))); + CompilationUnitTree cut = ct.parse().iterator().next(); + ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0); + MethodTree mt = (MethodTree) clazz.getMembers().get(0); + Trees t = Trees.instance(ct); + int start = (int) t.getSourcePositions().getStartPosition(cut, mt); + int end = (int) t.getSourcePositions().getEndPosition(cut, mt); + + assertEquals("testStartPositionForMethodWithoutModifiers", + " void t() {}", code.substring(start, end)); + } + + public void testStartPositionEnumConstantInit() throws IOException { + + String code = "package t; enum Test { AAA; }"; + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, + null, Arrays.asList(new MyFileObject(code))); + CompilationUnitTree cut = ct.parse().iterator().next(); + ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0); + VariableTree enumAAA = (VariableTree) clazz.getMembers().get(0); + Trees t = Trees.instance(ct); + int start = (int) t.getSourcePositions().getStartPosition(cut, + enumAAA.getInitializer()); + + assertEquals("testStartPositionEnumConstantInit", -1, start); + } + + public void testVariableInIfThen1() throws IOException { + + String code = "package t; class Test { " + + "private static void t(String name) { " + + "if (name != null) String nn = name.trim(); } }"; + + DiagnosticCollector coll = + new DiagnosticCollector(); + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null, + null, Arrays.asList(new MyFileObject(code))); + + ct.parse(); + + List codes = new LinkedList(); + + for (Diagnostic d : coll.getDiagnostics()) { + codes.add(d.getCode()); + } + + assertEquals("testVariableInIfThen1", + Arrays.asList("compiler.err.variable.not.allowed"), + codes); + } + + public void testVariableInIfThen2() throws IOException { + + String code = "package t; class Test { " + + "private static void t(String name) { " + + "if (name != null) class X {} } }"; + DiagnosticCollector coll = + new DiagnosticCollector(); + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null, + null, Arrays.asList(new MyFileObject(code))); + + ct.parse(); + + List codes = new LinkedList(); + + for (Diagnostic d : coll.getDiagnostics()) { + codes.add(d.getCode()); + } + + assertEquals("testVariableInIfThen2", + Arrays.asList("compiler.err.class.not.allowed"), codes); + } + + public void testVariableInIfThen3() throws IOException { + + String code = "package t; class Test { "+ + "private static void t() { " + + "if (true) abstract class F {} }}"; + DiagnosticCollector coll = + new DiagnosticCollector(); + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null, + null, Arrays.asList(new MyFileObject(code))); + + ct.parse(); + + List codes = new LinkedList(); + + for (Diagnostic d : coll.getDiagnostics()) { + codes.add(d.getCode()); + } + + assertEquals("testVariableInIfThen3", + Arrays.asList("compiler.err.class.not.allowed"), codes); + } + + public void testVariableInIfThen4() throws IOException { + + String code = "package t; class Test { "+ + "private static void t(String name) { " + + "if (name != null) interface X {} } }"; + DiagnosticCollector coll = + new DiagnosticCollector(); + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null, + null, Arrays.asList(new MyFileObject(code))); + + ct.parse(); + + List codes = new LinkedList(); + + for (Diagnostic d : coll.getDiagnostics()) { + codes.add(d.getCode()); + } + + assertEquals("testVariableInIfThen4", + Arrays.asList("compiler.err.class.not.allowed"), codes); + } + + public void testVariableInIfThen5() throws IOException { + + String code = "package t; class Test { "+ + "private static void t() { " + + "if (true) } }"; + DiagnosticCollector coll = + new DiagnosticCollector(); + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null, + null, Arrays.asList(new MyFileObject(code))); + + ct.parse(); + + List codes = new LinkedList(); + + for (Diagnostic d : coll.getDiagnostics()) { + codes.add(d.getCode()); + } + + assertEquals("testVariableInIfThen5", + Arrays.asList("compiler.err.illegal.start.of.stmt"), + codes); + } + + //see javac bug #6882235, NB bug #98234: + public void testMissingExponent() throws IOException { + + String code = "\nclass Test { { System.err.println(0e); } }"; + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, + null, Arrays.asList(new MyFileObject(code))); + + assertNotNull(ct.parse().iterator().next()); + } + + public void testTryResourcePos() throws IOException { + + final String code = "package t; class Test { " + + "{ try (java.io.InputStream in = null) { } } }"; + + CompilationUnitTree cut = getCompilationUnitTree(code); + + new TreeScanner() { + @Override + public Void visitVariable(VariableTree node, Void p) { + if ("in".contentEquals(node.getName())) { + JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node; + System.out.println(node.getName() + "," + var.pos); + assertEquals("testTryResourcePos", "in = null) { } } }", + code.substring(var.pos)); + } + return super.visitVariable(node, p); + } + }.scan(cut, null); + } + + public void testVarPos() throws IOException { + + final String code = "package t; class Test { " + + "{ java.io.InputStream in = null; } }"; + + CompilationUnitTree cut = getCompilationUnitTree(code); + + new TreeScanner() { + + @Override + public Void visitVariable(VariableTree node, Void p) { + if ("in".contentEquals(node.getName())) { + JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node; + assertEquals("testVarPos","in = null; } }", + code.substring(var.pos)); + } + return super.visitVariable(node, p); + } + }.scan(cut, null); + } + + // expected erroneous tree: int x = y;(ERROR); + public void testOperatorMissingError() throws IOException { + + String code = "package test; public class ErrorTest { " + + "void method() { int x = y z } }"; + CompilationUnitTree cut = getCompilationUnitTree(code); + final List values = new ArrayList<>(); + final List expectedValues = + new ArrayList<>(Arrays.asList("[z]")); + + new TreeScanner() { + + @Override + public Void visitErroneous(ErroneousTree node, Void p) { + + values.add(getErroneousTreeValues(node).toString()); + return null; + + } + }.scan(cut, null); + + assertEquals("testSwitchError: The Erroneous tree " + + "error values: " + values + + " do not match expected error values: " + + expectedValues, values, expectedValues); + } + + //expected erroneous tree: String s = (ERROR); + public void testMissingParenthesisError() throws IOException { + + String code = "package test; public class ErrorTest { " + + "void f() {String s = new String; } }"; + CompilationUnitTree cut = getCompilationUnitTree(code); + final List values = new ArrayList<>(); + final List expectedValues = + new ArrayList<>(Arrays.asList("[new String()]")); + + new TreeScanner() { + + @Override + public Void visitErroneous(ErroneousTree node, Void p) { + + values.add(getErroneousTreeValues(node).toString()); + return null; + } + }.scan(cut, null); + + assertEquals("testSwitchError: The Erroneous tree " + + "error values: " + values + + " do not match expected error values: " + + expectedValues, values, expectedValues); + } + + //expected erroneous tree: package test; (ERROR)(ERROR) + public void testMissingClassError() throws IOException { + + String code = "package Test; clas ErrorTest { " + + "void f() {String s = new String(); } }"; + CompilationUnitTree cut = getCompilationUnitTree(code); + final List values = new ArrayList<>(); + final List expectedValues = + new ArrayList<>(Arrays.asList("[, clas]", "[]")); + + new TreeScanner() { + + @Override + public Void visitErroneous(ErroneousTree node, Void p) { + + values.add(getErroneousTreeValues(node).toString()); + return null; + } + }.scan(cut, null); + + assertEquals("testSwitchError: The Erroneous tree " + + "error values: " + values + + " do not match expected error values: " + + expectedValues, values, expectedValues); + } + + //expected erroneous tree: void m1(int i) {(ERROR);{(ERROR);} + public void testSwitchError() throws IOException { + + String code = "package test; public class ErrorTest { " + + "int numDays; void m1(int i) { switchh {i} { case 1: " + + "numDays = 31; break; } } }"; + CompilationUnitTree cut = getCompilationUnitTree(code); + final List values = new ArrayList<>(); + final List expectedValues = + new ArrayList<>(Arrays.asList("[switchh]", "[i]")); + + new TreeScanner() { + + @Override + public Void visitErroneous(ErroneousTree node, Void p) { + + values.add(getErroneousTreeValues(node).toString()); + return null; + } + }.scan(cut, null); + + assertEquals("testSwitchError: The Erroneous tree " + + "error values: " + values + + " do not match expected error values: " + + expectedValues, values, expectedValues); + } + + //expected erroneous tree: class ErrorTest {(ERROR) + public void testMethodError() throws IOException { + + String code = "package Test; class ErrorTest { " + + "static final void f) {String s = new String(); } }"; + CompilationUnitTree cut = getCompilationUnitTree(code); + final List values = new ArrayList<>(); + final List expectedValues = + new ArrayList<>(Arrays.asList("[\nstatic final void f();]")); + + new TreeScanner() { + + @Override + public Void visitErroneous(ErroneousTree node, Void p) { + + values.add(normalize(getErroneousTreeValues(node).toString())); + return null; + } + }.scan(cut, null); + + assertEquals("testMethodError: The Erroneous tree " + + "error value: " + values + + " does not match expected error values: " + + expectedValues, values, expectedValues); + } + + void testsNotWorking() throws IOException { + + // Fails with nb-javac, needs further investigation + testPositionBrokenSource126732a(); + testPositionBrokenSource126732b(); + + // Fails, these tests yet to be addressed + testPositionForEnumModifiers(); + testStartPositionEnumConstantInit(); + } + void testPositions() throws IOException { + testPositionsSane(); + testCorrectWilcardPositions(); + testPositionAnnotationNoPackage187551(); + testPositionForSuperConstructorCalls(); + testPreferredPositionForBinaryOp(); + testStartPositionForMethodWithoutModifiers(); + testVarPos(); + testVariableInIfThen1(); + testVariableInIfThen2(); + testVariableInIfThen3(); + testVariableInIfThen4(); + testVariableInIfThen5(); + testMissingExponent(); + testTryResourcePos(); + testOperatorMissingError(); + testMissingParenthesisError(); + testMissingClassError(); + testSwitchError(); + testMethodError(); + testErrorRecoveryForEnhancedForLoop142381(); + } + + public static void main(String... args) throws IOException { + JavacParserTest jpt = new JavacParserTest("JavacParserTest"); + jpt.testPositions(); + System.out.println("PASS"); + } +} + +abstract class TestCase { + + void assertEquals(String message, int i, int pos) { + if (i != pos) { + fail(message); + } + } + + void assertFalse(String message, boolean bvalue) { + if (bvalue == true) { + fail(message); + } + } + + void assertEquals(String message, int i, long l) { + if (i != l) { + fail(message + ":" + i + ":" + l); + } + } + + void assertEquals(String message, Object o1, Object o2) { + System.out.println(o1); + System.out.println(o2); + if (o1 != null && o2 != null && !o1.equals(o2)) { + fail(message); + } + if (o1 == null && o2 != null) { + fail(message); + } + } + + void assertNotNull(Object o) { + if (o == null) { + fail(); + } + } + + void fail() { + fail("test failed"); + } + + void fail(String message) { + throw new RuntimeException(message); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/parser/StringFoldingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/parser/StringFoldingTest.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7068902 + * @summary verify that string folding can be enabled or disabled + */ + +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.util.JavacTask; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +public class StringFoldingTest { + final JavaCompiler tool; + final JavaSource source; + + public StringFoldingTest() { + tool = ToolProvider.getSystemJavaCompiler(); + source = new JavaSource(); + } + + static class JavaSource extends SimpleJavaFileObject { + + final static String source = + "class C {String X=\"F\" + \"O\" + \"L\" + \"D\" + \"E\" + \"D\";}"; + + JavaSource() { + super(URI.create("myfo:/C.java"), JavaFileObject.Kind.SOURCE); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + public static void main(String... args) throws IOException { + StringFoldingTest t = new StringFoldingTest(); + t.run(false); + t.run(true); + } + + void run(boolean disableStringFolding) throws IOException { + List argsList = new ArrayList(); + if (disableStringFolding) { + argsList.add("-XDallowStringFolding=false"); + } + JavacTask ct = (JavacTask)tool.getTask(null, null, null, + argsList, + null, + Arrays.asList(source)); + Iterable trees = ct.parse(); + String text = trees.toString(); + System.out.println(text); + + if (disableStringFolding) { + if (text.contains("FOLDED")) { + throw new AssertionError("Expected string folding"); + } + } else { + if (!text.contains("FOLDED")) { + throw new AssertionError("Expected no string folding"); + } + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/parser/T4881269.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/parser/T4881269.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4881269 + * @summary improve diagnostic for ill-formed tokens + * @compile/fail/ref=T4881269.out -XDrawDiagnostics T4881269.java + */ + +public class T4881269 { + java.io..PrintStream s; + void m() { System.err..println(); } + void m(Object.. o) { } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/parser/T4881269.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/parser/T4881269.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,9 @@ +T4881269.java:32:13: compiler.err.illegal.dot +T4881269.java:33:27: compiler.err.illegal.dot +T4881269.java:33:22: compiler.err.not.stmt +T4881269.java:34:19: compiler.err.illegal.dot +T4881269.java:34:20: compiler.err.expected: ';' +T4881269.java:34:22: compiler.err.illegal.start.of.type +T4881269.java:34:23: compiler.err.expected: token.identifier +T4881269.java:34:25: compiler.err.expected: ';' +8 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/TestWarnErrorCount.java --- a/test/tools/javac/processing/TestWarnErrorCount.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/processing/TestWarnErrorCount.java Tue May 29 00:27:58 2012 +0100 @@ -327,7 +327,7 @@ Writer out = fo.openWriter(); try { out.write("class " + name + " {\n" - + (warn ? " int i = (int) 0;\n" : "") + + (warn ? " void m() throws Exception { try (AutoCloseable ac = null) { } }" : "") + (error ? " ERROR\n" : "") + "}\n"); } finally { diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/errors/TestOptionSyntaxErrors.java --- a/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,14 +27,14 @@ * @summary Test that annotation processor options with illegal syntax are rejected * @author Joseph D. Darcy * @library ../../lib - * @build JavacTestingAbstractProcessor + * @build JavacTestingAbstractProcessor CompileFail * @compile TestOptionSyntaxErrors.java - * @compile/fail -A TestOptionSyntaxErrors.java - * @compile/fail -A8adOption TestOptionSyntaxErrors.java - * @compile/fail -A8adOption=1worseOption TestOptionSyntaxErrors.java - * @compile/fail -processor TestOptionSyntaxErrors -proc:only -A TestOptionSyntaxErrors.java - * @compile/fail -processor TestOptionSyntaxErrors -proc:only -A8adOption TestOptionSyntaxErrors.java - * @compile/fail -processor TestOptionSyntaxErrors -proc:only -A8adOption=1worseOption TestOptionSyntaxErrors.java + * @run main CompileFail CMDERR -A TestOptionSyntaxErrors.java + * @run main CompileFail CMDERR -A8adOption TestOptionSyntaxErrors.java + * @run main CompileFail CMDERR -A8adOption=1worseOption TestOptionSyntaxErrors.java + * @run main CompileFail CMDERR -processor TestOptionSyntaxErrors -proc:only -A TestOptionSyntaxErrors.java + * @run main CompileFail CMDERR -processor TestOptionSyntaxErrors -proc:only -A8adOption TestOptionSyntaxErrors.java + * @run main CompileFail CMDERR -processor TestOptionSyntaxErrors -proc:only -A8adOption=1worseOption TestOptionSyntaxErrors.java */ import java.util.Set; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/errors/TestReturnCode.java --- a/test/tools/javac/processing/errors/TestReturnCode.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/processing/errors/TestReturnCode.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,25 +27,25 @@ * @summary Test that an erroneous return code results from raising an error. * @author Joseph D. Darcy * @library ../../lib - * @build JavacTestingAbstractProcessor + * @build JavacTestingAbstractProcessor CompileFail * @compile TestReturnCode.java * - * @compile -processor TestReturnCode -proc:only Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AErrorOnFirst Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AErrorOnLast Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AErrorOnLast -AErrorOnFirst Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnFirst Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnFirst -AErrorOnFirst Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnFirst -AErrorOnLast Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnFirst -AErrorOnLast -AErrorOnFirst Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast -AErrorOnFirst Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast -AErrorOnLast Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast -AErrorOnLast -AErrorOnFirst Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst -AErrorOnFirst Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst -AErrorOnLast Foo.java - * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst -AErrorOnLast -AErrorOnFirst Foo.java + * @compile -processor TestReturnCode -proc:only Foo.java + * @run main CompileFail ERROR -processor TestReturnCode -proc:only -AErrorOnFirst Foo.java + * @run main CompileFail ERROR -processor TestReturnCode -proc:only -AErrorOnLast Foo.java + * @run main CompileFail ERROR -processor TestReturnCode -proc:only -AErrorOnLast -AErrorOnFirst Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnFirst Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnFirst -AErrorOnFirst Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnFirst -AErrorOnLast Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnFirst -AErrorOnLast -AErrorOnFirst Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast -AErrorOnFirst Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast -AErrorOnLast Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast -AErrorOnLast -AErrorOnFirst Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst -AErrorOnFirst Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst -AErrorOnLast Foo.java + * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst -AErrorOnLast -AErrorOnFirst Foo.java */ import java.util.Set; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/errors/TestSuppression.java --- a/test/tools/javac/processing/errors/TestSuppression.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/processing/errors/TestSuppression.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import javax.tools.*; import com.sun.source.util.JavacTask; +import com.sun.tools.javac.api.ClientCodeWrapper; import com.sun.tools.javac.api.JavacTool; import com.sun.tools.javac.util.JCDiagnostic; @@ -171,7 +172,7 @@ public void report(Diagnostic diagnostic) { System.err.println((++total) + ": " - + "resolveError:" + isResolveError((JCDiagnostic) diagnostic) + "\n" + + "resolveError:" + isResolveError(unwrap(diagnostic)) + "\n" + diagnostic); Diagnostic.Kind dk = diagnostic.getKind(); Integer c = counts.get(dk); @@ -181,6 +182,14 @@ private static boolean isResolveError(JCDiagnostic d) { return d.isFlagSet(RESOLVE_ERROR); } + + private JCDiagnostic unwrap(Diagnostic diagnostic) { + if (diagnostic instanceof JCDiagnostic) + return (JCDiagnostic) diagnostic; + if (diagnostic instanceof ClientCodeWrapper.DiagnosticSourceUnwrapper) + return ((ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic).d; + throw new IllegalArgumentException(); + } } @SupportedAnnotationTypes("*") diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/loader/testClose/TestClose.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/loader/testClose/TestClose.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7092965 + * @summary javac should not close processorClassLoader before end of compilation + */ + +import com.sun.source.util.JavacTask; +import com.sun.source.util.TaskEvent; +import com.sun.source.util.TaskListener; +import com.sun.tools.javac.api.ClientCodeWrapper.Trusted; +import com.sun.tools.javac.api.BasicJavacTask; +import com.sun.tools.javac.api.JavacTool; +import com.sun.tools.javac.processing.JavacProcessingEnvironment; +import com.sun.tools.javac.util.Context; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.PrintStream; +import java.lang.reflect.Field; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import javax.annotation.processing.ProcessingEnvironment; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +/* + * The test compiles an annotation processor and a helper class into a + * custom classes directory. + * + * It then uses them while compiling a dummy file, with the custom classes + * directory on the processor path, thus guaranteeing that references to + * these class are satisfied by the processor class loader. + * + * The annotation processor uses the javac TaskListener to run code + * after annotation processing has completed, to verify that the classloader + * is not closed until the end of the compilation. + */ + +@Trusted // avoids use of ClientCodeWrapper +public class TestClose implements TaskListener { + public static final String annoProc = + "import java.util.*;\n" + + "import javax.annotation.processing.*;\n" + + "import javax.lang.model.*;\n" + + "import javax.lang.model.element.*;\n" + + "import com.sun.source.util.*;\n" + + "import com.sun.tools.javac.processing.*;\n" + + "import com.sun.tools.javac.util.*;\n" + + "@SupportedAnnotationTypes(\"*\")\n" + + "public class AnnoProc extends AbstractProcessor {\n" + + " @Override\n" + + " public SourceVersion getSupportedSourceVersion() {\n" + + " return SourceVersion.latest();\n" + + " }\n" + + " @Override\n" + + " public boolean process(Set annotations, RoundEnvironment roundEnv) {\n" + + " System.out.println(\"in AnnoProc.process\");\n" + + " final ClassLoader cl = getClass().getClassLoader();\n" + + " if (roundEnv.processingOver()) {\n" + + " TestClose.add(processingEnv, new Runnable() {\n" + + " public void run() {\n" + + " System.out.println(getClass().getName() + \": run()\");\n" + + " try {\n" + + " cl.loadClass(\"Callback\")\n" + + " .asSubclass(Runnable.class)\n" + + " .newInstance()\n" + + " .run();\n" + + " } catch (ReflectiveOperationException e) {\n" + + " throw new Error(e);\n" + + " }\n" + + " }\n" + + " });\n" + + " }\n" + + " return true;\n" + + " }\n" + + "}\n"; + + public static final String callback = + "public class Callback implements Runnable {\n" + + " public void run() {\n" + + " System.out.println(getClass().getName() + \": run()\");\n" + + " }\n" + + "}"; + + public static void main(String... args) throws Exception { + new TestClose().run(); + } + + void run() throws IOException { + JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + + File classes = new File("classes"); + classes.mkdirs(); + File extraClasses = new File("extraClasses"); + extraClasses.mkdirs(); + + System.out.println("compiling classes to extraClasses"); + { // setup class in extraClasses + fm.setLocation(StandardLocation.CLASS_OUTPUT, + Collections.singleton(extraClasses)); + List files = Arrays.asList( + new MemFile("AnnoProc.java", annoProc), + new MemFile("Callback.java", callback)); + JavacTask task = tool.getTask(null, fm, null, null, null, files); + check(task.call()); + } + + System.out.println("compiling dummy to classes with anno processor"); + { // use that class in a TaskListener after processing has completed + PrintStream prev = System.out; + String out; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (PrintStream ps = new PrintStream(baos)) { + System.setOut(ps); + File testClasses = new File(System.getProperty("test.classes")); + fm.setLocation(StandardLocation.CLASS_OUTPUT, + Collections.singleton(classes)); + fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, + Arrays.asList(extraClasses, testClasses)); + List files = Arrays.asList( + new MemFile("my://dummy", "class Dummy { }")); + List options = Arrays.asList("-processor", "AnnoProc"); + JavacTask task = tool.getTask(null, fm, null, options, null, files); + task.setTaskListener(this); + check(task.call()); + } finally { + System.setOut(prev); + out = baos.toString(); + if (!out.isEmpty()) + System.out.println(out); + } + check(out.contains("AnnoProc$1: run()")); + check(out.contains("Callback: run()")); + } + } + + @Override + public void started(TaskEvent e) { + System.out.println("Started: " + e); + } + + @Override + public void finished(TaskEvent e) { + System.out.println("Finished: " + e); + if (e.getKind() == TaskEvent.Kind.ANALYZE) { + for (Runnable r: runnables) { + System.out.println("running " + r); + r.run(); + } + } + } + + void check(boolean b) { + if (!b) + throw new AssertionError(); + } + + public static void add(ProcessingEnvironment env, Runnable r) { + try { + JavacTask task = JavacTask.instance(env); + TaskListener l = ((BasicJavacTask) task).getTaskListeners().iterator().next(); + // The TaskListener is an instanceof TestClose, but when using the + // default class loaders. the taskListener uses a different + // instance of Class than the anno processor. + // If you try to evaluate + // TestClose tc = (TestClose) (l). + // you get the following somewhat confusing error: + // java.lang.ClassCastException: TestClose cannot be cast to TestClose + // The workaround is to access the fields of TestClose with reflection. + Field f = l.getClass().getField("runnables"); + @SuppressWarnings("unchecked") + List runnables = (List) f.get(l); + runnables.add(r); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + public List runnables = new ArrayList<>(); + + class MemFile extends SimpleJavaFileObject { + public final String text; + + MemFile(String name, String text) { + super(URI.create(name), JavaFileObject.Kind.SOURCE); + this.text = text; + } + + @Override + public String getName() { + return uri.toString(); + } + + @Override + public String getCharContent(boolean ignoreEncodingErrors) { + return text; + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/loader/testClose/TestClose2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/loader/testClose/TestClose2.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7092965 + * @summary javac should not close processorClassLoader before end of compilation + */ + +import com.sun.source.util.JavacTask; +import com.sun.source.util.TaskEvent; +import com.sun.source.util.TaskListener; +import com.sun.tools.javac.api.JavacTool; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.util.Context; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.Messager; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +@SupportedAnnotationTypes("*") +public class TestClose2 extends AbstractProcessor implements TaskListener { + + public static void main(String... args) throws Exception { + new TestClose2().run(); + } + + void run() throws IOException { + File testSrc = new File(System.getProperty("test.src")); + File testClasses = new File(System.getProperty("test.classes")); + + JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler(); + final ClassLoader cl = getClass().getClassLoader(); + Context c = new Context(); + StandardJavaFileManager fm = new JavacFileManager(c, true, null) { + @Override + protected ClassLoader getClassLoader(URL[] urls) { + return new URLClassLoader(urls, cl) { + @Override + public void close() throws IOException { + System.err.println(getClass().getName() + " closing"); + TestClose2.this.closedCount++; + TestClose2.this.closedIsLast = true; + super.close(); + } + }; + } + }; + + fm.setLocation(StandardLocation.CLASS_OUTPUT, + Collections.singleton(new File("."))); + fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, + Collections.singleton(testClasses)); + Iterable files = + fm.getJavaFileObjects(new File(testSrc, TestClose2.class.getName() + ".java")); + List options = Arrays.asList( + "-processor", TestClose2.class.getName()); + + JavacTask task = tool.getTask(null, fm, null, options, null, files); + task.setTaskListener(this); + + if (!task.call()) + throw new Error("compilation failed"); + + if (closedCount == 0) + throw new Error("no closing message"); + else if (closedCount > 1) + throw new Error(closedCount + " closed messages"); + + if (!closedIsLast) + throw new Error("closing message not last"); + } + + // AbstractProcessor methods + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + Messager messager = processingEnv.getMessager(); + messager.printMessage(Diagnostic.Kind.NOTE, "processing"); + return true; + } + + // TaskListener methods + + @Override + public void started(TaskEvent e) { + System.err.println("Started: " + e); + closedIsLast = false; + } + + @Override + public void finished(TaskEvent e) { + System.err.println("Finished: " + e); + closedIsLast = false; + } + + // + + int closedCount = 0; + boolean closedIsLast = false; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/messager/MessagerDiags.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/messager/MessagerDiags.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7166010 + * @summary warnings printed by annotation processors uses incorrect source + */ +import com.sun.source.util.JavacTask; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.Messager; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticCollector; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +import static javax.tools.Diagnostic.Kind.*; +import static javax.tools.JavaFileObject.Kind.*; + +@SupportedSourceVersion(SourceVersion.RELEASE_6) +@SupportedAnnotationTypes("*") +public class MessagerDiags extends AbstractProcessor { + static final String CNAME = "Test"; + static final String TEST_JAVA = CNAME + ".java"; + static final String TEST_JAVA_URI_NAME = "myfo:/" + TEST_JAVA; + static final String WRN_NO_SOURCE = "warning without source"; + static final String WRN_WITH_SOURCE = "warning with source"; + static final String NONE = ""; + static final String[] EXPECTED = { NONE + ":-1--1:" + WRN_NO_SOURCE, + TEST_JAVA + ":0-13:" + WRN_WITH_SOURCE, + NONE + ":-1--1:" + WRN_NO_SOURCE + }; + + @Override + public boolean process(Set annotations, + RoundEnvironment roundEnv) { + Messager messager = processingEnv.getMessager(); + for (Element e : roundEnv.getRootElements()) { + messager.printMessage(WARNING, WRN_NO_SOURCE); + messager.printMessage(WARNING, WRN_WITH_SOURCE, e); + messager.printMessage(WARNING, WRN_NO_SOURCE); + } + return false; + } + + public static void main(String... args) throws IOException { + final String bootPath = System.getProperty("sun.boot.class.path"); + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + assert tool != null; + + DiagnosticCollector dc = new DiagnosticCollector<>(); + List options = new LinkedList<>(); + options.addAll(Arrays.asList("-bootclasspath", bootPath, + "-source", "1.6", "-classpath", + System.getProperty("java.class.path"))); + options.addAll(Arrays.asList("-processor", + MessagerDiags.class.getName())); + JavacTask ct = (JavacTask)tool.getTask(null, null, dc, options, null, + Arrays.asList(new MyFileObject("class " + CNAME + " {}"))); + ct.analyze(); + + List obtainedErrors = new ArrayList<>(); + + for (Diagnostic d : dc.getDiagnostics()) { + String dSource; + if (d.getSource() != null) { + dSource = d.getSource().toUri().getPath(); + dSource = dSource.substring(dSource.lastIndexOf('/') + 1); + } else { + dSource = NONE; + } + obtainedErrors.add(dSource + ":" + d.getStartPosition() + "-" + + d.getEndPosition() + ":" + d.getMessage(null)); + } + List expectedErrors = Arrays.asList(EXPECTED); + if (!expectedErrors.equals(obtainedErrors)) { + System.err.println("Expected: " + expectedErrors); + System.err.println("Obtained: " + obtainedErrors); + throw new AssertionError("Messages don't match"); + } + } + + static class MyFileObject extends SimpleJavaFileObject { + private String text; + public MyFileObject(String text) { + super(URI.create(TEST_JAVA_URI_NAME), SOURCE); + this.text = text; + } + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return text; + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/model/6194785/T6194785.java --- a/test/tools/javac/processing/model/6194785/T6194785.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/processing/model/6194785/T6194785.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6194785 * @summary ParameterDeclaration.getSimpleName does not return actual name from class files @@ -40,9 +40,8 @@ public class T6194785 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, - RoundEnvironment roundEnvironment) - { - class Scan extends ElementScanner7 { + RoundEnvironment roundEnvironment) { + class Scan extends ElementScanner { @Override public Void visitExecutable(ExecutableElement e, Void ignored) { for (VariableElement p : e.getParameters()) diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/model/TestSymtabItems.java --- a/test/tools/javac/processing/model/TestSymtabItems.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/processing/model/TestSymtabItems.java Tue May 29 00:27:58 2012 +0100 @@ -23,7 +23,7 @@ /* * @test - * @bug 7021183 + * @bug 7021183 7025809 * @summary 269: assertion failure getting enclosing element of an undefined name */ @@ -37,9 +37,7 @@ import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.UnknownTypeException; -import javax.lang.model.util.ElementScanner7; -import javax.lang.model.util.SimpleTypeVisitor7; -import javax.lang.model.util.Types; +import javax.lang.model.util.*; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symtab; @@ -112,7 +110,7 @@ int errors; - class ElemPrinter extends ElementScanner7 { + class ElemPrinter extends ElementScanner8 { @Override public Void visitPackage(PackageElement e, Void p) { show("package", e); diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java --- a/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java Tue May 29 00:27:58 2012 +0100 @@ -24,7 +24,7 @@ /* * @test - * @bug 6639645 7026414 + * @bug 6639645 7026414 7025809 * @summary Modeling type implementing missing interfaces * @library ../../../../lib * @build JavacTestingAbstractProcessor TestMissingElement @@ -104,7 +104,7 @@ private String asString(TypeMirror t) { if (t == null) return "[typ:null]"; - return t.accept(new SimpleTypeVisitor7() { + return t.accept(new SimpleTypeVisitor() { @Override public String defaultAction(TypeMirror t, Void ignore) { return "[typ:" + t.toString() + "]"; @@ -135,7 +135,7 @@ private String asString(Element e) { if (e == null) return "[elt:null]"; - return e.accept(new SimpleElementVisitor7() { + return e.accept(new SimpleElementVisitor() { @Override public String defaultAction(Element e, Void ignore) { return "[elt:" + e.getKind() + " " + e.toString() + "]"; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/model/element/TestResourceVariable.java --- a/test/tools/javac/processing/model/element/TestResourceVariable.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/processing/model/element/TestResourceVariable.java Tue May 29 00:27:58 2012 +0100 @@ -23,7 +23,7 @@ /* * @test - * @bug 6911256 6964740 6967842 6961571 + * @bug 6911256 6964740 6967842 6961571 7025809 * @summary Test that the resource variable kind is appropriately set * @author Joseph D. Darcy * @library ../../../lib @@ -44,8 +44,8 @@ /** * Using the tree API, retrieve element representations of the - * resource of an ARM block and verify their kind tags are set - * appropriately. + * resource of a try-with-resources statement and verify their kind + * tags are set appropriately. */ public class TestResourceVariable extends JavacTestingAbstractProcessor implements AutoCloseable { int resourceVariableCount = 0; @@ -82,7 +82,7 @@ /** * Verify that a resource variable modeled as an element behaves - * as expected under 6 and 7 specific visitors. + * as expected under 6 and latest specific visitors. */ private static void testResourceVariable(Element element) { ElementVisitor visitor6 = new ElementKindVisitor6() {}; @@ -94,7 +94,8 @@ ; // Expected. } - ElementKindVisitor7 visitor7 = new ElementKindVisitor7() { + ElementKindVisitor visitorLatest = + new ElementKindVisitor() { @Override public Object visitVariableAsResourceVariable(VariableElement e, Void p) { @@ -102,7 +103,7 @@ } }; - if (visitor7.visit(element) == null) { + if (visitorLatest.visit(element) == null) { throw new RuntimeException("Null result of resource variable visitation."); } } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/model/type/NoTypes.java --- a/test/tools/javac/processing/model/type/NoTypes.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/processing/model/type/NoTypes.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6418666 6423973 6453386 + * @bug 6418666 6423973 6453386 7025809 * @summary Test the NoTypes: VOID, PACKAGE, NONE * @author Scott Seligman * @library ../../../lib @@ -75,7 +75,7 @@ verifyKind(NONE, types.getNoType(NONE)); // The return type of a constructor or void method is VOID. - class Scanner extends ElementScanner7 { + class Scanner extends ElementScanner { @Override public Void visitExecutable(ExecutableElement e, Void p) { verifyKind(VOID, e.getReturnType()); @@ -89,11 +89,11 @@ } /** - * Verify that a NoType instance is of a particular kind, - * and that TypeKindVisitor7 properly dispatches on it. + * Verify that a NoType instance is of a particular kind, and that + * the latest TypeKindVisitor properly dispatches on it. */ private void verifyKind(TypeKind kind, TypeMirror type) { - class Vis extends TypeKindVisitor7 { + class Vis extends TypeKindVisitor { @Override public TypeKind visitNoTypeAsVoid(NoType t, Void p) { return VOID; @@ -111,9 +111,7 @@ throw new AssertionError(); } - // Fodder for the tests - interface I { } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/model/type/TestUnionType.java --- a/test/tools/javac/processing/model/type/TestUnionType.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/processing/model/type/TestUnionType.java Tue May 29 00:27:58 2012 +0100 @@ -23,7 +23,7 @@ /* * @test - * @bug 7029150 + * @bug 7029150 7025809 * @summary Test support for union types * @library ../../../lib */ @@ -39,7 +39,6 @@ import com.sun.source.tree.*; import com.sun.source.util.*; - public class TestUnionType extends JavacTestingAbstractProcessor { enum TestKind { SingleType("E1", "E1", @@ -194,7 +193,7 @@ } } - class TypePrinter extends SimpleTypeVisitor7 { + class TypePrinter extends SimpleTypeVisitor { @Override protected String defaultAction(TypeMirror tm, Void ignore) { return String.valueOf(tm.getKind()); diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/model/util/deprecation/TestDeprecation.java --- a/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ return true; } - private class DeprecationChecker extends ElementScanner7 { + private class DeprecationChecker extends ElementScanner { private Elements elementUtils; private boolean failure; DeprecationChecker() { diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6987384 + * @summary -XprintProcessorRoundsInfo message printed with different timing than previous + * @library ../../../lib + * @build JavacTestingAbstractProcessor Test TestWithXstdout + * @run main TestWithXstdout + */ + +import java.io.*; +import java.nio.charset.*; +import java.nio.file.*; +import java.util.*; + +public class TestWithXstdout { + public static void main(String... args) throws Exception { + File testSrc = new File(System.getProperty("test.src")); + File testClasses = new File(System.getProperty("test.classes")); + File stdout = new File("stdout.out"); + run_javac("-XDrawDiagnostics", + "-XprintProcessorInfo", + "-Werror", + "-proc:only", + "-processor", "Test", + "-Xstdout", stdout.getPath(), + "-classpath", testClasses.getPath(), + new File(testSrc, "Test.java").getPath()); + boolean ok = compare(stdout, new File(testSrc, "Test.out")); + if (!ok) + throw new Exception("differences found"); + } + + static void run_javac(String... args) throws IOException, InterruptedException { + File javaHome = new File(System.getProperty("java.home")); + if (javaHome.getName().equals("jre")) + javaHome = javaHome.getParentFile(); + File javac = new File(new File(javaHome, "bin"), "javac"); + + List opts = new ArrayList<>(); + opts.add(javac.getPath()); + + String toolOpts = System.getProperty("test.tool.vm.opts"); + if (toolOpts != null && !"".equals(toolOpts.trim())) { + opts.addAll(Arrays.asList(toolOpts.trim().split("[\\s]+"))); + } + opts.addAll(Arrays.asList(args)); + System.out.println("exec: " + opts); + ProcessBuilder pb = new ProcessBuilder(opts); + pb.redirectErrorStream(); + Process p = pb.start(); + try (BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()))) { + String line; + while ((line = r.readLine()) != null) + System.out.println(); + } + int rc = p.waitFor(); + if (rc != 0) + System.out.println("javac exited, rc=" + rc); + } + + static boolean compare(File a, File b) throws IOException { + List aLines = Files.readAllLines(a.toPath(), Charset.defaultCharset()); + List bLines = Files.readAllLines(b.toPath(), Charset.defaultCharset()); + System.out.println(a + ": " + aLines.size() + " lines"); + System.out.println(b + ": " + bLines.size() + " lines"); + return aLines.equals(bLines); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/quid/T6999438.out --- a/test/tools/javac/quid/T6999438.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/quid/T6999438.out Tue May 29 00:27:58 2012 +0100 @@ -1,4 +1,4 @@ -T6999438.java:8:9: compiler.err.illegal.char: 35 +T6999438.java:8:8: compiler.err.expected: token.identifier T6999438.java:8:10: compiler.err.illegal.start.of.type T6999438.java:8:25: compiler.err.expected: token.identifier T6999438.java:8:26: compiler.err.expected: ';' diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/Candidate.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/Candidate.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface Candidate { + /** + * the candidate position (line/col of the method call for which this candidate + * is a potential overload candidate) + */ + Pos pos() default @Pos(userDefined=false); + /** + * resolution phases for which this candidate is applicable + */ + Phase[] applicable() default { }; + /** + * is this candidate the most specific (in the resolution phases for which it + * is also applicable) + */ + boolean mostSpecific() default false; + /** + * this candidate inferred signature (in the resolution phases for which it + * is also applicable, in case it corresponds to a generic method) + */ + String sig() default ""; +} + +enum Phase { + BASIC("BASIC"), + BOX("BOX"), + VARARGS("VARARITY"); + + final String javacString; + + private Phase(String javacString) { + this.javacString = javacString; + } + + static Phase fromString(String s) { + for (Phase phase : Phase.values()) { + if (phase.javacString.equals(s)) { + return phase; + } + } + throw new AssertionError("Invalid resolution phase string " + s); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/Pos.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/Pos.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target(ElementType.ANNOTATION_TYPE) +@interface Pos { + long line() default -1; + long col() default -1; + boolean userDefined() default true; +} \ No newline at end of file diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/ResolveHarness.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/ResolveHarness.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,475 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7098660 + * @summary Write better overload resolution/inference tests + * @library ../lib + * @build JavacTestingAbstractProcessor ResolveHarness + * @run main ResolveHarness + */ + +import com.sun.source.util.JavacTask; +import com.sun.tools.javac.api.ClientCodeWrapper.DiagnosticSourceUnwrapper; +import com.sun.tools.javac.code.Type.MethodType; +import com.sun.tools.javac.util.JCDiagnostic; + +import java.io.File; +import java.util.Set; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic; +import javax.tools.Diagnostic.Kind; +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +import static javax.tools.StandardLocation.*; + +public class ResolveHarness implements javax.tools.DiagnosticListener { + + static int nerrors = 0; + + static final JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + public static void main(String[] args) throws Exception { + fm.setLocation(SOURCE_PATH, + Arrays.asList(new File(System.getProperty("test.src"), "tests"))); + for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) { + new ResolveHarness(jfo).check(); + } + if (nerrors > 0) { + throw new AssertionError("Errors were found"); + } + } + + + JavaFileObject jfo; + DiagnosticProcessor[] diagProcessors; + Map candidatesMap = new HashMap(); + Set declaredKeys = new HashSet<>(); + List> diags = new ArrayList<>(); + List seenCandidates = new ArrayList<>(); + + protected ResolveHarness(JavaFileObject jfo) { + this.jfo = jfo; + this.diagProcessors = new DiagnosticProcessor[] { + new VerboseResolutionNoteProcessor(), + new VerboseDeferredInferenceNoteProcessor(), + new ErrorProcessor() + }; + } + + protected void check() throws Exception { + String[] options = { + "-XDshouldStopPolicy=ATTR", + "-XDverboseResolution=success,failure,applicable,inapplicable,deferred-inference" + }; + + AbstractProcessor[] processors = { new ResolveCandidateFinder(), null }; + + @SuppressWarnings("unchecked") + DiagnosticListener[] diagListeners = + new DiagnosticListener[] { new DiagnosticHandler(false), new DiagnosticHandler(true) }; + + for (int i = 0 ; i < options.length ; i ++) { + JavacTask ct = (JavacTask)comp.getTask(null, fm, diagListeners[i], + Arrays.asList(options[i]), null, Arrays.asList(jfo)); + if (processors[i] != null) { + ct.setProcessors(Collections.singleton(processors[i])); + } + ct.analyze(); + } + + //check diags + for (Diagnostic diag : diags) { + for (DiagnosticProcessor proc : diagProcessors) { + if (proc.matches(diag)) { + proc.process(diag); + break; + } + } + } + //check all candidates have been used up + for (Map.Entry entry : candidatesMap.entrySet()) { + if (!seenCandidates.contains(entry.getKey())) { + error("Redundant @Candidate annotation on method " + entry.getKey().elem); + } + } + } + + public void report(Diagnostic diagnostic) { + diags.add(diagnostic); + } + + Candidate getCandidateAtPos(Element methodSym, long line, long col) { + Candidate c = candidatesMap.get(new ElementKey(methodSym)); + if (c != null) { + Pos pos = c.pos(); + if (!pos.userDefined() || + (pos.line() == line && pos.col() == col)) { + seenCandidates.add(new ElementKey(methodSym)); + return c; + } + } else { + error("Missing @Candidate annotation on method " + methodSym); + } + return null; + } + + void checkSig(Candidate c, Element methodSym, MethodType mtype) { + if (c.sig().length() > 0 && !c.sig().equals(mtype.toString())) { + error("Inferred type mismatch for method: " + methodSym); + } + } + + protected void error(String msg) { + nerrors++; + System.err.printf("Error occurred while checking file: %s\nreason: %s\n", jfo.getName(), msg); + } + + /** + * Base class for diagnostic processor. It provides methods for matching and + * processing a given diagnostic object (overridden by subclasses). + */ + abstract class DiagnosticProcessor { + + List codes; + Diagnostic.Kind kind; + + public DiagnosticProcessor(Kind kind, String... codes) { + this.codes = Arrays.asList(codes); + this.kind = kind; + } + + abstract void process(Diagnostic diagnostic); + + boolean matches(Diagnostic diagnostic) { + return (codes.isEmpty() || codes.contains(diagnostic.getCode())) && + diagnostic.getKind() == kind; + } + + JCDiagnostic asJCDiagnostic(Diagnostic diagnostic) { + if (diagnostic instanceof JCDiagnostic) { + return (JCDiagnostic)diagnostic; + } else if (diagnostic instanceof DiagnosticSourceUnwrapper) { + return ((DiagnosticSourceUnwrapper)diagnostic).d; + } else { + throw new AssertionError("Cannot convert diagnostic to JCDiagnostic: " + diagnostic.getClass().getName()); + } + } + + List subDiagnostics(Diagnostic diagnostic) { + JCDiagnostic diag = asJCDiagnostic(diagnostic); + if (diag instanceof JCDiagnostic.MultilineDiagnostic) { + return ((JCDiagnostic.MultilineDiagnostic)diag).getSubdiagnostics(); + } else { + throw new AssertionError("Cannot extract subdiagnostics: " + diag.getClass().getName()); + } + } + } + + /** + * Processor for verbose resolution notes generated by javac. The processor + * checks that the diagnostic is associated with a method declared by + * a class annotated with the special @TraceResolve marker annotation. If + * that's the case, all subdiagnostics (one for each resolution candidate) + * are checked against the corresponding @Candidate annotations, using + * a VerboseCandidateSubdiagProcessor. + */ + class VerboseResolutionNoteProcessor extends DiagnosticProcessor { + + VerboseResolutionNoteProcessor() { + super(Kind.NOTE, + "compiler.note.verbose.resolve.multi", + "compiler.note.verbose.resolve.multi.1"); + } + + @Override + void process(Diagnostic diagnostic) { + Element siteSym = getSiteSym(diagnostic); + if (siteSym.getAnnotation(TraceResolve.class) == null) { + return; + } + int candidateIdx = 0; + for (JCDiagnostic d : subDiagnostics(diagnostic)) { + boolean isMostSpecific = candidateIdx++ == mostSpecific(diagnostic); + VerboseCandidateSubdiagProcessor subProc = + new VerboseCandidateSubdiagProcessor(isMostSpecific, phase(diagnostic), success(diagnostic)); + if (subProc.matches(d)) { + subProc.process(d); + } else { + throw new AssertionError("Bad subdiagnostic: " + d.getCode()); + } + } + } + + Element getSiteSym(Diagnostic diagnostic) { + return (Element)asJCDiagnostic(diagnostic).getArgs()[1]; + } + + int mostSpecific(Diagnostic diagnostic) { + return success(diagnostic) ? + (Integer)asJCDiagnostic(diagnostic).getArgs()[2] : -1; + } + + boolean success(Diagnostic diagnostic) { + return diagnostic.getCode().equals("compiler.note.verbose.resolve.multi"); + } + + Phase phase(Diagnostic diagnostic) { + return Phase.fromString(asJCDiagnostic(diagnostic).getArgs()[3].toString()); + } + } + + /** + * Processor for verbose resolution subdiagnostic notes generated by javac. + * The processor checks that the details of the overload candidate + * match against the info contained in the corresponding @Candidate + * annotation (if any). + */ + class VerboseCandidateSubdiagProcessor extends DiagnosticProcessor { + + boolean mostSpecific; + Phase phase; + boolean success; + + public VerboseCandidateSubdiagProcessor(boolean mostSpecific, Phase phase, boolean success) { + super(Kind.OTHER, + "compiler.misc.applicable.method.found", + "compiler.misc.applicable.method.found.1", + "compiler.misc.not.applicable.method.found"); + this.mostSpecific = mostSpecific; + this.phase = phase; + this.success = success; + } + + @Override + void process(Diagnostic diagnostic) { + Element methodSym = methodSym(diagnostic); + Candidate c = getCandidateAtPos(methodSym, + asJCDiagnostic(diagnostic).getLineNumber(), + asJCDiagnostic(diagnostic).getColumnNumber()); + if (c == null) { + return; //nothing to check + } + + if (c.applicable().length == 0 && c.mostSpecific()) { + error("Inapplicable method cannot be most specific " + methodSym); + } + + if (isApplicable(diagnostic) != Arrays.asList(c.applicable()).contains(phase)) { + error("Invalid candidate's applicability " + methodSym); + } + + if (success) { + for (Phase p : c.applicable()) { + if (phase.ordinal() < p.ordinal()) { + error("Invalid phase " + p + " on method " + methodSym); + } + } + } + + if (Arrays.asList(c.applicable()).contains(phase)) { //applicable + if (c.mostSpecific() != mostSpecific) { + error("Invalid most specific value for method " + methodSym); + } + MethodType mtype = getSig(diagnostic); + if (mtype != null) { + checkSig(c, methodSym, mtype); + } + } + } + + boolean isApplicable(Diagnostic diagnostic) { + return !diagnostic.getCode().equals("compiler.misc.not.applicable.method.found"); + } + + Element methodSym(Diagnostic diagnostic) { + return (Element)asJCDiagnostic(diagnostic).getArgs()[1]; + } + + MethodType getSig(Diagnostic diagnostic) { + JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2]; + if (details == null) { + return null; + } else if (details instanceof JCDiagnostic) { + return details.getCode().equals("compiler.misc.full.inst.sig") ? + (MethodType)details.getArgs()[0] : null; + } else { + throw new AssertionError("Bad diagnostic arg: " + details); + } + } + } + + /** + * Processor for verbose deferred inference notes generated by javac. The + * processor checks that the inferred signature for a given generic method + * call corresponds to the one (if any) declared in the @Candidate annotation. + */ + class VerboseDeferredInferenceNoteProcessor extends DiagnosticProcessor { + + public VerboseDeferredInferenceNoteProcessor() { + super(Kind.NOTE, "compiler.note.deferred.method.inst"); + } + + @Override + void process(Diagnostic diagnostic) { + Element methodSym = methodSym(diagnostic); + Candidate c = getCandidateAtPos(methodSym, + asJCDiagnostic(diagnostic).getLineNumber(), + asJCDiagnostic(diagnostic).getColumnNumber()); + MethodType sig = sig(diagnostic); + if (c != null && sig != null) { + checkSig(c, methodSym, sig); + } + } + + Element methodSym(Diagnostic diagnostic) { + return (Element)asJCDiagnostic(diagnostic).getArgs()[0]; + } + + MethodType sig(Diagnostic diagnostic) { + return (MethodType)asJCDiagnostic(diagnostic).getArgs()[1]; + } + } + + /** + * Processor for all error diagnostics; if the error key is not declared in + * the test file header, the processor reports an error. + */ + class ErrorProcessor extends DiagnosticProcessor { + + public ErrorProcessor() { + super(Diagnostic.Kind.ERROR); + } + + @Override + void process(Diagnostic diagnostic) { + if (!declaredKeys.contains(diagnostic.getCode())) { + error("Unexpected compilation error key '" + diagnostic.getCode() + "'"); + } + } + } + + @SupportedAnnotationTypes({"Candidate","TraceResolve"}) + class ResolveCandidateFinder extends JavacTestingAbstractProcessor { + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) + return true; + + TypeElement traceResolveAnno = elements.getTypeElement("TraceResolve"); + TypeElement candidateAnno = elements.getTypeElement("Candidate"); + + if (!annotations.contains(traceResolveAnno)) { + error("no @TraceResolve annotation found in test class"); + } + + if (!annotations.contains(candidateAnno)) { + error("no @candidate annotation found in test class"); + } + + for (Element elem: roundEnv.getElementsAnnotatedWith(traceResolveAnno)) { + TraceResolve traceResolve = elem.getAnnotation(TraceResolve.class); + declaredKeys.addAll(Arrays.asList(traceResolve.keys())); + } + + for (Element elem: roundEnv.getElementsAnnotatedWith(candidateAnno)) { + candidatesMap.put(new ElementKey(elem), elem.getAnnotation(Candidate.class)); + } + return true; + } + } + + class ElementKey { + + String key; + Element elem; + + public ElementKey(Element elem) { + this.elem = elem; + this.key = computeKey(elem); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof ElementKey) { + ElementKey other = (ElementKey)obj; + return other.key.equals(key); + } + return false; + } + + @Override + public int hashCode() { + return key.hashCode(); + } + + String computeKey(Element e) { + StringBuilder buf = new StringBuilder(); + while (e != null) { + buf.append(e.toString()); + e = e.getEnclosingElement(); + } + buf.append(jfo.getName()); + return buf.toString(); + } + + @Override + public String toString() { + return "Key{"+key+"}"; + } + } + + class DiagnosticHandler implements DiagnosticListener { + + boolean shouldRecordDiags; + + DiagnosticHandler(boolean shouldRecordDiags) { + this.shouldRecordDiags = shouldRecordDiags; + } + + public void report(Diagnostic diagnostic) { + if (shouldRecordDiags) + diags.add(diagnostic); + } + + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/TraceResolve.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/TraceResolve.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@interface TraceResolve { + String[] keys() default {}; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/tests/BoxedReturnTypeInference.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/tests/BoxedReturnTypeInference.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +@TraceResolve +class BoxedReturnTypeInference { + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Byte", mostSpecific=true) + static B m_byte() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Short", mostSpecific=true) + static S m_short() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Integer", mostSpecific=true) + static I m_int() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Long", mostSpecific=true) + static L m_long() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Float", mostSpecific=true) + static F m_float() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Double", mostSpecific=true) + static D m_double() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Character", mostSpecific=true) + static C m_char() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Boolean", mostSpecific=true) + static Z m_bool() { return null; } + + { + Byte b = m_byte(); + Short s = m_short(); + Integer i = m_int(); + Long l = m_long(); + Float f = m_float(); + Double d = m_double(); + Character c= m_char(); + Boolean z = m_bool(); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/tests/PrimitiveOverReferenceOverInferred.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/tests/PrimitiveOverReferenceOverInferred.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +@TraceResolve +class PrimitiveOverReference { + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_byte(byte b) {} + @Candidate + static void m_byte(Byte b) {} + @Candidate + static void m_byte(B b) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_short(short s) {} + @Candidate + static void m_short(Short s) {} + @Candidate + static void m_short(S s) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_int(int i) {} + @Candidate + static void m_int(Integer i) {} + @Candidate + static void m_int(I i) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_long(long l) {} + @Candidate + static void m_long(Long l) {} + @Candidate + static void m_long(L l) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_float(float f) {} + @Candidate + static void m_float(Float f) {} + @Candidate + static void m_float(F f) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_double(double d) {} + @Candidate + static void m_double(Double d) {} + @Candidate + static void m_double(D d) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_char(char c) {} + @Candidate + static void m_char(Character c) {} + @Candidate + static void m_char(C c) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_bool(boolean z) {} + @Candidate + static void m_bool(Boolean z) {} + @Candidate + static void m_bool(Z z) {} + + { + m_byte((byte)0); + m_short((short)0); + m_int(0); + m_long(0L); + m_float(0.0f); + m_double(0.0); + m_char('?'); + m_bool(false); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/tests/PrimitiveOverReferenceOverVarargs.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/tests/PrimitiveOverReferenceOverVarargs.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +@TraceResolve +class PrimitiveOverReference { + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_byte(byte b) {} + @Candidate + static void m_byte(Byte b) {} + @Candidate + static void m_byte(byte... b) {} + @Candidate + static void m_byte(Byte... b) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_short(short s) {} + @Candidate + static void m_short(Short s) {} + @Candidate + static void m_short(short... s) {} + @Candidate + static void m_short(Short... s) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_int(int i) {} + @Candidate + static void m_int(Integer i) {} + @Candidate + static void m_int(int... i) {} + @Candidate + static void m_int(Integer... i) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_long(long l) {} + @Candidate + static void m_long(Long l) {} + @Candidate + static void m_long(long... l) {} + @Candidate + static void m_long(Long... l) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_float(float f) {} + @Candidate + static void m_float(Float f) {} + @Candidate + static void m_float(float... f) {} + @Candidate + static void m_float(Float... f) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_double(double d) {} + @Candidate + static void m_double(Double d) {} + @Candidate + static void m_double(double... d) {} + @Candidate + static void m_double(Double... d) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_char(char c) {} + @Candidate + static void m_char(Character c) {} + @Candidate + static void m_char(char... c) {} + @Candidate + static void m_char(Character... c) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_bool(boolean z) {} + @Candidate + static void m_bool(Boolean z) {} + @Candidate + static void m_bool(boolean... z) {} + @Candidate + static void m_bool(Boolean... z) {} + + { + m_byte((byte)0); + m_short((short)0); + m_int(0); + m_long(0L); + m_float(0.0f); + m_double(0.0); + m_char('?'); + m_bool(false); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +@TraceResolve(keys={"compiler.err.ref.ambiguous"}) +class PrimitiveOverReferenceVarargsAmbiguous { + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_byte(byte... b) {} + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_byte(Byte... b) {} + + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_short(short... s) {} + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_short(Short... s) {} + + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_int(int... i) {} + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_int(Integer... i) {} + + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_long(long... l) {} + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_long(Long... l) {} + + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_float(float... f) {} + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_float(Float... f) {} + + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_double(double... d) {} + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_double(Double... d) {} + + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_char(char... c) {} + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_char(Character... c) {} + + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_bool(boolean... z) {} + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) + static void m_bool(Boolean... z) {} + + { + m_byte((byte)0); + m_short((short)0); + m_int(0); + m_long(0L); + m_float(0.0f); + m_double(0.0); + m_char('?'); + m_bool(false); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/tests/PrimitiveOverload.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/tests/PrimitiveOverload.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +@TraceResolve +class PrimitiveOverload { + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_byte(byte b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_byte(short b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_byte(int b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_byte(long b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_byte(float b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_byte(double b) {} + + @Candidate + static void m_short(byte b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_short(short b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_short(int b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_short(long b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_short(float b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_short(double b) {} + + @Candidate + static void m_int(byte b) {} + @Candidate + static void m_int(short b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_int(int b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_int(long b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_int(float b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_int(double b) {} + + @Candidate + static void m_long(byte b) {} + @Candidate + static void m_long(short b) {} + @Candidate + static void m_long(int b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_long(long b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_long(float b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_long(double b) {} + + @Candidate + static void m_float(byte b) {} + @Candidate + static void m_float(short b) {} + @Candidate + static void m_float(int b) {} + @Candidate + static void m_float(long b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_float(float b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_float(double b) {} + + @Candidate + static void m_double(byte b) {} + @Candidate + static void m_double(short b) {} + @Candidate + static void m_double(int b) {} + @Candidate + static void m_double(long b) {} + @Candidate + static void m_double(float b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_double(double b) {} + + { + m_byte((byte)0); + m_short((short)0); + m_int(0); + m_long(0L); + m_float(0.0f); + m_double(0.0); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/tests/PrimitiveReturnTypeInference.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/tests/PrimitiveReturnTypeInference.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +@TraceResolve +class PrimitiveReturnTypeInference { + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Byte", mostSpecific=true) + static B m_byte() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Short", mostSpecific=true) + static S m_short() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Integer", mostSpecific=true) + static I m_int() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Long", mostSpecific=true) + static L m_long() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Float", mostSpecific=true) + static F m_float() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Double", mostSpecific=true) + static D m_double() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Character", mostSpecific=true) + static C m_char() { return null; } + + @Candidate(applicable=Phase.BASIC, sig="()java.lang.Boolean", mostSpecific=true) + static Z m_bool() { return null; } + + { + byte b = m_byte(); + short s = m_short(); + int i = m_int(); + long l = m_long(); + float f = m_float(); + double d = m_double(); + char c= m_char(); + boolean z = m_bool(); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/tests/ReferenceOverInferred.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/tests/ReferenceOverInferred.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +@TraceResolve +class PrimitiveOverInferred { + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_byte(Byte b) {} + @Candidate(applicable=Phase.BOX, sig="(java.lang.Byte)void") + static void m_byte(B b) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_short(Short s) {} + @Candidate(applicable=Phase.BOX, sig="(java.lang.Short)void") + static void m_short(S s) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_int(Integer i) {} + @Candidate(applicable=Phase.BOX, sig="(java.lang.Integer)void") + static void m_int(I i) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_long(Long l) {} + @Candidate(applicable=Phase.BOX, sig="(java.lang.Long)void") + static void m_long(L l) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_float(Float f) {} + @Candidate(applicable=Phase.BOX, sig="(java.lang.Float)void") + static void m_float(F f) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_double(Double d) {} + @Candidate(applicable=Phase.BOX, sig="(java.lang.Double)void") + static void m_double(D d) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_char(Character c) {} + @Candidate(applicable=Phase.BOX, sig="(java.lang.Character)void") + static void m_char(C c) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_bool(Boolean z) {} + @Candidate(applicable=Phase.BOX, sig="(java.lang.Boolean)void") + static void m_bool(Z z) {} + + { + m_byte((byte)0); + m_short((short)0); + m_int(0); + m_long(0L); + m_float(0.0f); + m_double(0.0); + m_char('?'); + m_bool(false); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/tests/ReferenceOverVarargs.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/tests/ReferenceOverVarargs.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +@TraceResolve +class ReferenceOverVarargs { + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_byte(Byte b) {} + @Candidate + static void m_byte(byte... b) {} + @Candidate + static void m_byte(Byte... b) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_short(Short s) {} + @Candidate + static void m_short(short... s) {} + @Candidate + static void m_short(Short... s) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_int(Integer i) {} + @Candidate + static void m_int(int... i) {} + @Candidate + static void m_int(Integer... i) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_long(Long l) {} + @Candidate + static void m_long(long... l) {} + @Candidate + static void m_long(Long... l) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_float(Float f) {} + @Candidate + static void m_float(float... f) {} + @Candidate + static void m_float(Float... f) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_double(Double d) {} + @Candidate + static void m_double(double... d) {} + @Candidate + static void m_double(Double... d) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_char(Character c) {} + @Candidate + static void m_char(char... c) {} + @Candidate + static void m_char(Character... c) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=true) + static void m_bool(Boolean z) {} + @Candidate + static void m_bool(boolean... z) {} + @Candidate + static void m_bool(Boolean... z) {} + + { + m_byte((byte)0); + m_short((short)0); + m_int(0); + m_long(0L); + m_float(0.0f); + m_double(0.0); + m_char('?'); + m_bool(false); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/resolve/tests/ReferenceOverload.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/tests/ReferenceOverload.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +@TraceResolve +class ReferenceOverload { + + static class A {} + static class B extends A {} + static class C extends B {} + static class D extends C {} + static class E extends D {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_A(A a) {} + @Candidate + static void m_A(B a) {} + @Candidate + static void m_A(C a) {} + @Candidate + static void m_A(D a) {} + @Candidate + static void m_A(E a) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_B(A b) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_B(B b) {} + @Candidate + static void m_B(C b) {} + @Candidate + static void m_B(D b) {} + @Candidate + static void m_B(E b) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_C(A c) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_C(B c) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_C(C c) {} + @Candidate + static void m_C(D c) {} + @Candidate + static void m_C(E c) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_D(A d) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_D(B d) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_D(C d) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_D(D d) {} + @Candidate + static void m_D(E d) {} + + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_E(A e) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_E(B e) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_E(C e) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=false) + static void m_E(D e) {} + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + static void m_E(E e) {} + + { + m_A((A)null); + m_B((B)null); + m_C((C)null); + m_D((D)null); + m_E((E)null); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/stackmap/T4955930.sh --- a/test/tools/javac/stackmap/T4955930.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/stackmap/T4955930.sh Tue May 29 00:27:58 2012 +0100 @@ -41,7 +41,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | CYGWIN* ) + SunOS | Linux | Darwin | CYGWIN* ) FS="/" ;; Windows_95 | Windows_98 | Windows_NT ) diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/tree/AbstractTreeScannerTest.java --- a/test/tools/javac/tree/AbstractTreeScannerTest.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/tree/AbstractTreeScannerTest.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -274,7 +274,7 @@ return fields; } // where - Map> map = new HashMap>(); + Map> map = new HashMap>(); /** Get the line number for the primary position for a tree. * The code is intended to be simple, although not necessarily efficient. diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/tree/DocCommentToplevelTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/tree/DocCommentToplevelTest.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7096014 + * @summary Javac tokens should retain state + */ + +import com.sun.source.tree.*; +import com.sun.source.util.*; +import com.sun.tools.javac.tree.JCTree; + +import java.net.URI; +import java.util.*; +import javax.tools.*; + + +public class DocCommentToplevelTest { + + enum PackageKind { + HAS_PKG("package pkg;"), + NO_PKG(""); + + String pkgStr; + + PackageKind(String pkgStr) { + this.pkgStr = pkgStr; + } + } + + enum ImportKind { + ZERO(""), + ONE("import java.lang.*;"), + TWO("import java.lang.*; import java.util.*;"); + + String importStr; + + ImportKind(String importStr) { + this.importStr = importStr; + } + } + + enum ModifierKind { + DEFAULT(""), + PUBLIC("public"); + + String modStr; + + ModifierKind(String modStr) { + this.modStr = modStr; + } + } + + enum ToplevelDocKind { + HAS_DOC("/** Toplevel! */"), + NO_DOC(""); + + String docStr; + + ToplevelDocKind(String docStr) { + this.docStr = docStr; + } + } + + static int errors; + static int checks; + + public static void main(String... args) throws Exception { + //create default shared JavaCompiler - reused across multiple compilations + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + for (PackageKind pk : PackageKind.values()) { + for (ImportKind ik : ImportKind.values()) { + for (ModifierKind mk1 : ModifierKind.values()) { + for (ModifierKind mk2 : ModifierKind.values()) { + for (ToplevelDocKind tdk : ToplevelDocKind.values()) { + new DocCommentToplevelTest(pk, ik, mk1, mk2, tdk).run(comp, fm); + } + } + } + } + } + + if (errors > 0) + throw new AssertionError(errors + " errors found"); + + System.out.println(checks + " checks were made"); + } + + PackageKind pk; + ImportKind ik; + ModifierKind mk1; + ModifierKind mk2; + ToplevelDocKind tdk; + JavaSource source; + + DocCommentToplevelTest(PackageKind pk, ImportKind ik, ModifierKind mk1, ModifierKind mk2, ToplevelDocKind tdk) { + this.pk = pk; + this.ik = ik; + this.mk1 = mk1; + this.mk2 = mk2; + this.tdk = tdk; + source = new JavaSource(); + } + + void run(JavaCompiler comp, JavaFileManager fm) throws Exception { + JavacTask task = (JavacTask)comp.getTask(null, fm, null, Arrays.asList("-printsource"), null, Arrays.asList(source)); + for (CompilationUnitTree cu: task.parse()) { + check(cu); + } + } + + void check(CompilationUnitTree cu) { + checks++; + + new TreeScanner() { + + Map docComments; + + @Override + public ClassTree visitCompilationUnit(CompilationUnitTree node, Void unused) { + docComments = ((JCTree.JCCompilationUnit)node).docComments; + boolean expectedComment = tdk == ToplevelDocKind.HAS_DOC && + (pk != PackageKind.NO_PKG || ik != ImportKind.ZERO); + boolean foundComment = docComments.get(node) != null; + if (expectedComment != foundComment) { + error("Unexpected comment " + docComments.get(node) + " on toplevel"); + } + return super.visitCompilationUnit(node, null); + } + + @Override + public ClassTree visitClass(ClassTree node, Void unused) { + boolean expectedComment = tdk == ToplevelDocKind.HAS_DOC && + pk == PackageKind.NO_PKG && ik == ImportKind.ZERO && + node.getSimpleName().toString().equals("First"); + boolean foundComment = docComments.get(node) != null; + if (expectedComment != foundComment) { + error("Unexpected comment " + docComments.get(node) + " on class " + node.getSimpleName()); + } + return super.visitClass(node, unused); + } + }.scan(cu, null); + } + + void error(String msg) { + System.err.println("Error: " + msg); + System.err.println("Source: " + source.source); + errors++; + } + + class JavaSource extends SimpleJavaFileObject { + + String template = "#D\n#P\n#I\n" + + "#M1 class First { }\n" + + "#M2 class Second { }\n"; + + String source; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = template.replace("#P", pk.pkgStr) + .replace("#I", ik.importStr) + .replace("#M1", mk1.modStr) + .replace("#M2", mk2.modStr) + .replace("#D", tdk.docStr); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/tree/TestToString.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/tree/TestToString.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7080267 + * @summary Call to toString() from an ExpressionStatementTree doesn't take in + * consideration the ";" at the end + */ + +import com.sun.source.tree.BlockTree; +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.StatementTree; +import com.sun.source.tree.Tree; +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; + +import com.sun.source.util.JavacTask; +import com.sun.source.util.TreeScanner; +import com.sun.tools.javac.api.JavacTool; + +public class TestToString { + String[] statements = { + "i = i + 1;", + "i++;", + "m();", + ";", + "if (i == 0) return;", + "while (i > 0) i--;", + "{ }", + "{ i++; }", + "class C { }" + }; + + public static void main(String... args) throws Exception { + new TestToString().run(); + } + + void run() throws Exception { + for (String s: statements) { + test(s); + } + + if (errors > 0) + throw new Exception(errors + " errors found"); + } + + void test(String stmt) throws IOException { + System.err.println("Test: " + stmt); + List options = Collections.emptyList(); + List files = Arrays.asList(new JavaSource(stmt)); + JavacTask t = tool.getTask(null, fm, null, options, null, files); + checkEqual(scan(t.parse()), stmt); + } + + String scan(Iterable trees) { + class Scanner extends TreeScanner { + String scan(Iterable trees) { + StringBuilder sb = new StringBuilder(); + scan(trees, sb); + return sb.toString(); + } + @Override + public Void scan(Tree tree, StringBuilder sb) { + if (print && tree instanceof StatementTree) { + sb.append(PREFIX); + sb.append(tree); + sb.append(SUFFIX); + return null; + } else { + return super.scan(tree, sb); + } + } + @Override + public Void visitBlock(BlockTree tree, StringBuilder sb) { + print = true; + try { + return super.visitBlock(tree, sb); + } finally { + print = false; + } + } + boolean print = false; + } + return new Scanner().scan(trees); + } + + void checkEqual(String found, String expect) { + boolean match = (found == null) ? (expect == null) : + expect.equals(found + .replaceAll("^\\Q" + PREFIX + "\\E\\s*", "") + .replaceAll("\\s*\\Q" + SUFFIX + "\\E$", "") + .replaceAll("\\s+", " ")); + + if (!match) + error("Mismatch: expected: " + expect + " found: " + found); + } + + + + void error(String msg) { + System.err.println("Error: " + msg); + errors++; + } + + static final String PREFIX = "#<"; + static final String SUFFIX = "#>"; + + JavacTool tool = JavacTool.create(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + int errors = 0; + + static class JavaSource extends SimpleJavaFileObject { + + String source = + "class Test {\n" + + " int i;\n" + + " void m() {\n" + + " #S\n" + + " }\n" + + "}"; + + public JavaSource(String stmt) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = source.replace("#S", stmt); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/tree/TreePosTest.java --- a/test/tools/javac/tree/TreePosTest.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/tree/TreePosTest.java Tue May 29 00:27:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,6 +73,7 @@ import com.sun.source.util.JavacTask; import com.sun.tools.javac.api.JavacTool; import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.parser.EndPosTable; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.tree.JCTree.JCNewClass; @@ -80,6 +81,7 @@ import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.tree.TreeScanner; +import static com.sun.tools.javac.tree.JCTree.Tag.*; import static com.sun.tools.javac.util.Position.NOPOS; /** @@ -291,6 +293,14 @@ errors++; } + /** + * Names for tree tags. + */ + private static String getTagName(JCTree.Tag tag) { + String name = tag.name(); + return (name == null) ? "??" : name; + } + /** Number of files that have been analyzed. */ int fileCount; /** Number of errors reported. */ @@ -312,8 +322,6 @@ Set excludeFiles = new HashSet(); /** Set of tag names to be excluded from analysis. */ Set excludeTags = new HashSet(); - /** Table of printable names for tree tag values. */ - TagNames tagNames = new TagNames(); /** * Main class for testing assertions concerning tree positions for tree nodes. @@ -337,7 +345,7 @@ // there is no corresponding source text. // Redundant semicolons in a class definition can cause empty // initializer blocks with no positions. - if ((self.tag == JCTree.MODIFIERS || self.tag == JCTree.BLOCK) + if ((self.tag == MODIFIERS || self.tag == BLOCK) && self.pos == NOPOS) { // If pos is NOPOS, so should be the start and end positions check("start == NOPOS", encl, self, self.start == NOPOS); @@ -359,15 +367,15 @@ // e.g. int[][] a = new int[2][]; check("encl.start <= start", encl, self, encl.start <= self.start); check("start <= pos", encl, self, self.start <= self.pos); - if (!(self.tag == JCTree.TYPEARRAY - && (encl.tag == JCTree.VARDEF || - encl.tag == JCTree.METHODDEF || - encl.tag == JCTree.TYPEARRAY))) { + if (!(self.tag == TYPEARRAY + && (encl.tag == VARDEF || + encl.tag == METHODDEF || + encl.tag == TYPEARRAY))) { check("encl.pos <= start || end <= encl.pos", encl, self, encl.pos <= self.start || self.end <= encl.pos); } check("pos <= end", encl, self, self.pos <= self.end); - if (!(self.tag == JCTree.TYPEARRAY && encl.tag == JCTree.TYPEARRAY)) { + if (!(self.tag == TYPEARRAY && encl.tag == TYPEARRAY)) { check("end <= encl.end", encl, self, self.end <= encl.end); } } @@ -388,7 +396,7 @@ if ((tree.mods.flags & Flags.ENUM) != 0) { scan(tree.mods); if (tree.init != null) { - if (tree.init.getTag() == JCTree.NEWCLASS) { + if (tree.init.hasTag(NEWCLASS)) { JCNewClass init = (JCNewClass) tree.init; if (init.args != null && init.args.nonEmpty()) { scan(init.args); @@ -404,11 +412,11 @@ boolean check(Info encl, Info self) { if (excludeTags.size() > 0) { - if (encl != null && excludeTags.contains(tagNames.get(encl.tag)) - || excludeTags.contains(tagNames.get(self.tag))) + if (encl != null && excludeTags.contains(getTagName(encl.tag)) + || excludeTags.contains(getTagName(self.tag))) return false; } - return tags.size() == 0 || tags.contains(tagNames.get(self.tag)); + return tags.size() == 0 || tags.contains(getTagName(self.tag)); } void check(String label, Info encl, Info self, boolean ok) { @@ -428,7 +436,7 @@ } JavaFileObject sourcefile; - Map endPosTable; + EndPosTable endPosTable; Info encl; } @@ -439,13 +447,13 @@ private class Info { Info() { tree = null; - tag = JCTree.ERRONEOUS; + tag = ERRONEOUS; start = 0; pos = 0; end = Integer.MAX_VALUE; } - Info(JCTree tree, Map endPosTable) { + Info(JCTree tree, EndPosTable endPosTable) { this.tree = tree; tag = tree.getTag(); start = TreeInfo.getStartPos(tree); @@ -455,46 +463,17 @@ @Override public String toString() { - return tagNames.get(tree.getTag()) + "[start:" + start + ",pos:" + pos + ",end:" + end + "]"; + return getTagName(tree.getTag()) + "[start:" + start + ",pos:" + pos + ",end:" + end + "]"; } final JCTree tree; - final int tag; + final JCTree.Tag tag; final int start; final int pos; final int end; } /** - * Names for tree tags. - * javac does not provide an API to convert tag values to strings, so this class uses - * reflection to determine names of public static final int values in JCTree. - */ - private static class TagNames { - String get(int tag) { - if (map == null) { - map = new HashMap(); - Class c = JCTree.class; - for (Field f : c.getDeclaredFields()) { - if (f.getType().equals(int.class)) { - int mods = f.getModifiers(); - if (Modifier.isPublic(mods) && Modifier.isStatic(mods) && Modifier.isFinal(mods)) { - try { - map.put(f.getInt(null), f.getName()); - } catch (IllegalAccessException e) { - } - } - } - } - } - String name = map.get(tag); - return (name == null) ? "??" : name; - } - - private Map map; - } - - /** * Thrown when errors are found parsing a java file. */ private static class ParseException extends Exception { @@ -719,7 +698,7 @@ void setInfo(Info info) { this.info = info; - tagName.setText(tagNames.get(info.tag)); + tagName.setText(getTagName(info.tag)); start.setText(String.valueOf(info.start)); pos.setText(String.valueOf(info.pos)); end.setText(String.valueOf(info.end)); diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/types/CastObjectToPrimitiveTest.out --- a/test/tools/javac/types/CastObjectToPrimitiveTest.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/types/CastObjectToPrimitiveTest.out Tue May 29 00:27:58 2012 +0100 @@ -1,2 +1,2 @@ -CastObjectToPrimitiveTest.java:36:23: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), java.lang.Object, int +CastObjectToPrimitiveTest.java:36:23: compiler.err.prob.found.req.1: (compiler.misc.inconvertible.types: java.lang.Object, int) 1 error diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/unicode/SupplementaryJavaID6.sh --- a/test/tools/javac/unicode/SupplementaryJavaID6.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/unicode/SupplementaryJavaID6.sh Tue May 29 00:27:58 2012 +0100 @@ -55,7 +55,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux ) + SunOS | Linux | Darwin ) if [ -d /usr/lib/locale/en_US.UTF-8 -o -d /usr/lib/locale/en_US.utf8 ] then ENV="env LANG=en_US.UTF-8" diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/util/T6597678.java --- a/test/tools/javac/util/T6597678.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/util/T6597678.java Tue May 29 00:27:58 2012 +0100 @@ -41,6 +41,7 @@ import com.sun.tools.javac.processing.JavacProcessingEnvironment; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.JavacMessages; +import com.sun.tools.javac.util.Log; @SupportedOptions("WriterString") public class T6597678 extends JavacTestingAbstractProcessor { @@ -78,7 +79,10 @@ @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { Context context = ((JavacProcessingEnvironment) processingEnv).getContext(); - PrintWriter out = ((JavacProcessingEnvironment) processingEnv).getWriter(); + Log log = Log.instance(context); + PrintWriter noteOut = log.getWriter(Log.WriterKind.NOTICE); + PrintWriter warnOut = log.getWriter(Log.WriterKind.WARNING); + PrintWriter errOut = log.getWriter(Log.WriterKind.ERROR); Locale locale = context.get(Locale.class); JavacMessages messages = context.get(JavacMessages.messagesKey); @@ -86,13 +90,20 @@ if (round == 1) { initialLocale = locale; initialMessages = messages; - initialWriter = out; + initialNoteWriter = noteOut; + initialWarnWriter = warnOut; + initialErrWriter = errOut; - checkEqual("writerString", out.toString().intern(), options.get("WriterString").intern()); + String writerStringOpt = options.get("WriterString").intern(); + checkEqual("noteWriterString", noteOut.toString().intern(), writerStringOpt); + checkEqual("warnWriterString", warnOut.toString().intern(), writerStringOpt); + checkEqual("errWriterString", errOut.toString().intern(), writerStringOpt); } else { checkEqual("locale", locale, initialLocale); checkEqual("messages", messages, initialMessages); - checkEqual("writer", out, initialWriter); + checkEqual("noteWriter", noteOut, initialNoteWriter); + checkEqual("warnWriter", warnOut, initialWarnWriter); + checkEqual("errWriter", errOut, initialErrWriter); } return true; @@ -109,5 +120,7 @@ int round = 0; Locale initialLocale; JavacMessages initialMessages; - PrintWriter initialWriter; + PrintWriter initialNoteWriter; + PrintWriter initialWarnWriter; + PrintWriter initialErrWriter; } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/util/context/T7021650.java --- a/test/tools/javac/util/context/T7021650.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/util/context/T7021650.java Tue May 29 00:27:58 2012 +0100 @@ -101,13 +101,13 @@ StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); Main m = new Main("javac", pw); - int rc = m.compile(args, context); + Main.Result res = m.compile(args, context); pw.close(); String out = sw.toString(); if (!out.isEmpty()) System.err.println(out); - if (rc != 0) - throw new Exception("compilation failed unexpectedly: rc=" + rc); + if (!res.isOK()) + throw new Exception("compilation failed unexpectedly: result=" + res); } void checkEqual(String label, int found, int expect) throws Exception { diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/varargs/6313164/T6313164.out --- a/test/tools/javac/varargs/6313164/T6313164.out Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/varargs/6313164/T6313164.out Tue May 29 00:27:58 2012 +0100 @@ -1,6 +1,6 @@ T6313164.java:12:8: compiler.err.cant.apply.symbol.1: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) -T6313164.java:14:13: compiler.err.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) -T6313164.java:15:13: compiler.err.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:14:13: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)) +T6313164.java:15:13: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)) - compiler.note.unchecked.filename: B.java - compiler.note.unchecked.recompile 3 errors diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/varargs/7097436/T7097436.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/7097436/T7097436.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,18 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7097436 + * @summary ClassCastException occurs in assignment expressions without any heap pollutions + * @compile/fail/ref=T7097436.out -Xlint:varargs -Werror -XDrawDiagnostics T7097436.java + */ + +import java.util.List; + +class T7097436 { + @SafeVarargs + static void m(List... ls) { + Object o = ls; //warning + Object[] oArr = ls; //warning + String s = ls; // no warning + Integer[] iArr = ls; // no warning + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/varargs/7097436/T7097436.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/7097436/T7097436.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,6 @@ +T7097436.java:13:20: compiler.warn.varargs.unsafe.use.varargs.param: ls +T7097436.java:14:25: compiler.warn.varargs.unsafe.use.varargs.param: ls +T7097436.java:15:20: compiler.err.prob.found.req: java.util.List[], java.lang.String +T7097436.java:16:26: compiler.err.prob.found.req: java.util.List[], java.lang.Integer[] +2 errors +2 warnings diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/varargs/warning/Warn5.java --- a/test/tools/javac/varargs/warning/Warn5.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/varargs/warning/Warn5.java Tue May 29 00:27:58 2012 +0100 @@ -23,7 +23,7 @@ /** * @test - * @bug 6993978 + * @bug 6993978 7097436 * @summary Project Coin: Annotation to reduce varargs warnings * @author mcimadamore * @run main Warn5 @@ -31,8 +31,8 @@ import com.sun.source.util.JavacTask; import com.sun.tools.javac.api.JavacTool; import java.net.URI; -import java.util.ArrayList; import java.util.Arrays; +import java.util.EnumSet; import javax.tools.Diagnostic; import javax.tools.JavaCompiler; import javax.tools.JavaFileObject; @@ -95,7 +95,6 @@ METHOD("void m"), CONSTRUCTOR("Test"); - String name; MethodKind(String name) { @@ -155,7 +154,124 @@ } } - static class JavaSource extends SimpleJavaFileObject { + enum WarningKind { + UNSAFE_BODY, + UNSAFE_DECL, + MALFORMED_SAFEVARARGS, + REDUNDANT_SAFEVARARGS; + } + + // Create a single file manager and reuse it for each compile to save time. + static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null); + + public static void main(String... args) throws Exception { + for (SourceLevel sourceLevel : SourceLevel.values()) { + for (XlintOption xlint : XlintOption.values()) { + for (TrustMe trustMe : TrustMe.values()) { + for (SuppressLevel suppressLevel : SuppressLevel.values()) { + for (ModifierKind modKind : ModifierKind.values()) { + for (MethodKind methKind : MethodKind.values()) { + for (SignatureKind sig : SignatureKind.values()) { + for (BodyKind body : BodyKind.values()) { + new Warn5(sourceLevel, + xlint, + trustMe, + suppressLevel, + modKind, + methKind, + sig, + body).test(); + } + } + } + } + } + } + } + } + } + + final SourceLevel sourceLevel; + final XlintOption xlint; + final TrustMe trustMe; + final SuppressLevel suppressLevel; + final ModifierKind modKind; + final MethodKind methKind; + final SignatureKind sig; + final BodyKind body; + final JavaSource source; + final DiagnosticChecker dc; + + public Warn5(SourceLevel sourceLevel, XlintOption xlint, TrustMe trustMe, SuppressLevel suppressLevel, ModifierKind modKind, MethodKind methKind, SignatureKind sig, BodyKind body) { + this.sourceLevel = sourceLevel; + this.xlint = xlint; + this.trustMe = trustMe; + this.suppressLevel = suppressLevel; + this.modKind = modKind; + this.methKind = methKind; + this.sig = sig; + this.body = body; + this.source = new JavaSource(); + this.dc = new DiagnosticChecker(); + } + + void test() throws Exception { + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + JavacTask ct = (JavacTask)tool.getTask(null, fm, dc, + Arrays.asList(xlint.getXlintOption(), "-source", sourceLevel.sourceKey), null, Arrays.asList(source)); + ct.analyze(); + check(); + } + + void check() { + + EnumSet expectedWarnings = EnumSet.noneOf(WarningKind.class); + + if (sourceLevel == SourceLevel.JDK_7 && + trustMe == TrustMe.TRUST && + suppressLevel != SuppressLevel.VARARGS && + xlint != XlintOption.NONE && + sig.isVarargs && !sig.isReifiableArg && body.hasAliasing && + (methKind == MethodKind.CONSTRUCTOR || (methKind == MethodKind.METHOD && modKind != ModifierKind.NONE))) { + expectedWarnings.add(WarningKind.UNSAFE_BODY); + } + + if (sourceLevel == SourceLevel.JDK_7 && + trustMe == TrustMe.DONT_TRUST && + sig.isVarargs && + !sig.isReifiableArg && + xlint == XlintOption.ALL) { + expectedWarnings.add(WarningKind.UNSAFE_DECL); + } + + if (sourceLevel == SourceLevel.JDK_7 && + trustMe == TrustMe.TRUST && + (!sig.isVarargs || + (modKind == ModifierKind.NONE && methKind == MethodKind.METHOD))) { + expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS); + } + + if (sourceLevel == SourceLevel.JDK_7 && + trustMe == TrustMe.TRUST && + xlint != XlintOption.NONE && + suppressLevel != SuppressLevel.VARARGS && + (modKind != ModifierKind.NONE || methKind == MethodKind.CONSTRUCTOR) && + sig.isVarargs && + sig.isReifiableArg) { + expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS); + } + + if (!expectedWarnings.containsAll(dc.warnings) || + !dc.warnings.containsAll(expectedWarnings)) { + throw new Error("invalid diagnostics for source:\n" + + source.getCharContent(true) + + "\nOptions: " + xlint.getXlintOption() + + "\nExpected warnings: " + expectedWarnings + + "\nFound warnings: " + dc.warnings); + } + } + + class JavaSource extends SimpleJavaFileObject { String template = "import com.sun.tools.javac.api.*;\n" + "import java.util.List;\n" + @@ -167,12 +283,11 @@ String source; - public JavaSource(TrustMe trustMe, SuppressLevel suppressLevel, ModifierKind modKind, - MethodKind methKind, SignatureKind meth, BodyKind body) { + public JavaSource() { super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); source = template.replace("#T", trustMe.anno). replace("#S", suppressLevel.getSuppressAnno()). - replace("#M", meth.getSignature(modKind, methKind)). + replace("#M", sig.getSignature(modKind, methKind)). replace("#B", body.body); } @@ -182,117 +297,34 @@ } } - public static void main(String... args) throws Exception { - for (SourceLevel sourceLevel : SourceLevel.values()) { - for (XlintOption xlint : XlintOption.values()) { - for (TrustMe trustMe : TrustMe.values()) { - for (SuppressLevel suppressLevel : SuppressLevel.values()) { - for (ModifierKind modKind : ModifierKind.values()) { - for (MethodKind methKind : MethodKind.values()) { - for (SignatureKind sig : SignatureKind.values()) { - for (BodyKind body : BodyKind.values()) { - test(sourceLevel, - xlint, - trustMe, - suppressLevel, - modKind, - methKind, - sig, - body); - } - } - } - } - } - } - } - } - } - - // Create a single file manager and reuse it for each compile to save time. - static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null); - - static void test(SourceLevel sourceLevel, XlintOption xlint, TrustMe trustMe, SuppressLevel suppressLevel, - ModifierKind modKind, MethodKind methKind, SignatureKind sig, BodyKind body) throws Exception { - final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); - JavaSource source = new JavaSource(trustMe, suppressLevel, modKind, methKind, sig, body); - DiagnosticChecker dc = new DiagnosticChecker(); - JavacTask ct = (JavacTask)tool.getTask(null, fm, dc, - Arrays.asList(xlint.getXlintOption(), "-source", sourceLevel.sourceKey), null, Arrays.asList(source)); - ct.analyze(); - check(sourceLevel, dc, source, xlint, trustMe, - suppressLevel, modKind, methKind, sig, body); - } - - static void check(SourceLevel sourceLevel, DiagnosticChecker dc, JavaSource source, - XlintOption xlint, TrustMe trustMe, SuppressLevel suppressLevel, ModifierKind modKind, - MethodKind methKind, SignatureKind meth, BodyKind body) { + class DiagnosticChecker implements javax.tools.DiagnosticListener { - boolean hasPotentiallyUnsafeBody = sourceLevel == SourceLevel.JDK_7 && - trustMe == TrustMe.TRUST && - suppressLevel != SuppressLevel.VARARGS && - xlint != XlintOption.NONE && - meth.isVarargs && !meth.isReifiableArg && body.hasAliasing && - (methKind == MethodKind.CONSTRUCTOR || (methKind == MethodKind.METHOD && modKind != ModifierKind.NONE)); - - boolean hasPotentiallyPollutingDecl = sourceLevel == SourceLevel.JDK_7 && - trustMe == TrustMe.DONT_TRUST && - meth.isVarargs && - !meth.isReifiableArg && - xlint == XlintOption.ALL; - - boolean hasMalformedAnnoInDecl = sourceLevel == SourceLevel.JDK_7 && - trustMe == TrustMe.TRUST && - (!meth.isVarargs || - (modKind == ModifierKind.NONE && methKind == MethodKind.METHOD)); - - boolean hasRedundantAnnoInDecl = sourceLevel == SourceLevel.JDK_7 && - trustMe == TrustMe.TRUST && - xlint != XlintOption.NONE && - suppressLevel != SuppressLevel.VARARGS && - (modKind != ModifierKind.NONE || methKind == MethodKind.CONSTRUCTOR) && - meth.isVarargs && - meth.isReifiableArg; - - if (hasPotentiallyUnsafeBody != dc.hasPotentiallyUnsafeBody || - hasPotentiallyPollutingDecl != dc.hasPotentiallyPollutingDecl || - hasMalformedAnnoInDecl != dc.hasMalformedAnnoInDecl || - hasRedundantAnnoInDecl != dc.hasRedundantAnnoInDecl) { - throw new Error("invalid diagnostics for source:\n" + - source.getCharContent(true) + - "\nOptions: " + xlint.getXlintOption() + - "\nExpected potentially unsafe body warning: " + hasPotentiallyUnsafeBody + - "\nExpected potentially polluting decl warning: " + hasPotentiallyPollutingDecl + - "\nExpected malformed anno error: " + hasMalformedAnnoInDecl + - "\nExpected redundant anno warning: " + hasRedundantAnnoInDecl + - "\nFound potentially unsafe body warning: " + dc.hasPotentiallyUnsafeBody + - "\nFound potentially polluting decl warning: " + dc.hasPotentiallyPollutingDecl + - "\nFound malformed anno error: " + dc.hasMalformedAnnoInDecl + - "\nFound redundant anno warning: " + dc.hasRedundantAnnoInDecl); - } - } - - static class DiagnosticChecker implements javax.tools.DiagnosticListener { - - boolean hasPotentiallyUnsafeBody = false; - boolean hasPotentiallyPollutingDecl = false; - boolean hasMalformedAnnoInDecl = false; - boolean hasRedundantAnnoInDecl = false; + EnumSet warnings = EnumSet.noneOf(WarningKind.class); public void report(Diagnostic diagnostic) { if (diagnostic.getKind() == Diagnostic.Kind.WARNING) { if (diagnostic.getCode().contains("unsafe.use.varargs.param")) { - hasPotentiallyUnsafeBody = true; + setWarning(WarningKind.UNSAFE_BODY); } else if (diagnostic.getCode().contains("redundant.trustme")) { - hasRedundantAnnoInDecl = true; + setWarning(WarningKind.REDUNDANT_SAFEVARARGS); } } else if (diagnostic.getKind() == Diagnostic.Kind.MANDATORY_WARNING && diagnostic.getCode().contains("varargs.non.reifiable.type")) { - hasPotentiallyPollutingDecl = true; + setWarning(WarningKind.UNSAFE_DECL); } else if (diagnostic.getKind() == Diagnostic.Kind.ERROR && diagnostic.getCode().contains("invalid.trustme")) { - hasMalformedAnnoInDecl = true; + setWarning(WarningKind.MALFORMED_SAFEVARARGS); } } + + void setWarning(WarningKind wk) { + if (!warnings.add(wk)) { + throw new AssertionError("Duplicate warning of kind " + wk + " in source:\n" + source); + } + } + + boolean hasWarning(WarningKind wk) { + return warnings.contains(wk); + } } } diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/warnings/7090499/T7090499.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/warnings/7090499/T7090499.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,37 @@ +/** + * @test /nodynamiccopyright/ + * @bug 7094099 + * @summary -Xlint:rawtypes + * @compile/fail/ref=T7090499.out -XDrawDiagnostics -Xlint:rawtypes T7090499.java + */ + + +class T7090499 { + + static class B {} + + class A { + class X {} + class Z {} + } + + T7090499 t = new T7090499() { //raw warning (2) + + A.X x1;//raw warning + A.Z z1;//raw warning + + T7090499.B b1;//ok + T7090499.B b2;//raw warning + + A.X x2;//ok + A.Z z2;//ok + A.Z> z3;//raw warning (2) + + void test(Object arg1, B arg2) {//raw warning + boolean b = arg1 instanceof A;//ok + Object a = (A)arg1;//ok + A a2 = new A() {};//raw warning (2) + a2.new Z() {};//raw warning + } + }; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/warnings/7090499/T7090499.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/warnings/7090499/T7090499.out Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,17 @@ +T7090499.java:18:5: compiler.warn.raw.class.use: T7090499, T7090499 +T7090499.java:18:22: compiler.warn.raw.class.use: T7090499, T7090499 +T7090499.java:20:10: compiler.warn.raw.class.use: T7090499.A.X, T7090499.A.X +T7090499.java:21:10: compiler.warn.raw.class.use: T7090499.A.Z, T7090499.A.Z +T7090499.java:24:17: compiler.warn.raw.class.use: T7090499.B, T7090499.B +T7090499.java:26:10: compiler.err.improperly.formed.type.inner.raw.param +T7090499.java:27:10: compiler.err.improperly.formed.type.inner.raw.param +T7090499.java:28:18: compiler.warn.raw.class.use: T7090499.B, T7090499.B +T7090499.java:28:17: compiler.err.improperly.formed.type.inner.raw.param +T7090499.java:28:11: compiler.warn.raw.class.use: T7090499.B, T7090499.B +T7090499.java:28:10: compiler.err.improperly.formed.type.inner.raw.param +T7090499.java:30:32: compiler.warn.raw.class.use: T7090499.B, T7090499.B +T7090499.java:33:13: compiler.warn.raw.class.use: T7090499.A, T7090499.A +T7090499.java:33:24: compiler.warn.raw.class.use: T7090499.A, T7090499.A +T7090499.java:34:20: compiler.warn.raw.class.use: T7090499.A.Z, T7090499.A.Z +4 errors +11 warnings diff -r 8caec3672381 -r 24540bbb4135 test/tools/javac/warnings/Serial.java --- a/test/tools/javac/warnings/Serial.java Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javac/warnings/Serial.java Tue May 29 00:27:58 2012 +0100 @@ -29,7 +29,6 @@ * @compile -Xlint:all Serial.java * @compile -Werror Serial.java * @compile/fail -Werror -Xlint:serial Serial.java - * @compile/fail -Werror -Xlint:all,-path T4994049/ Serial.java */ import java.io.Serializable; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javadoc/parser/7091528/T7091528.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javadoc/parser/7091528/T7091528.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 7091528 + * @summary javadoc attempts to parse .class files + * @compile p/C1.java p/q/C2.java + * @run main T7091528 + */ + +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; + +public class T7091528 { + public static void main(String... args) { + new T7091528().run(); + } + + void run() { + File testSrc = new File(System.getProperty("test.src")); + File testClasses = new File(System.getProperty("test.classes")); + String[] args = { + "-d", ".", + "-sourcepath", testClasses + File.pathSeparator + testSrc, + "-subpackages", + "p" + }; + + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + String doclet = com.sun.tools.doclets.standard.Standard.class.getName(); + int rc = com.sun.tools.javadoc.Main.execute("javadoc", pw, pw, pw, doclet, args); + pw.close(); + + String out = sw.toString(); + if (!out.isEmpty()) { + System.err.println(out); + } + + if (rc != 0) + System.err.println("javadoc failed: exit code = " + rc); + + if (out.matches("(?s).*p/[^ ]+\\.class.*")) + throw new Error("reading .class files"); + + if (!new File("index.html").exists()) + throw new Error("index.html not found"); + } +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javadoc/parser/7091528/p/C1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javadoc/parser/7091528/p/C1.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p1; + +/** This is class C1. */ +public class C1 { } + diff -r 8caec3672381 -r 24540bbb4135 test/tools/javadoc/parser/7091528/p/q/C2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javadoc/parser/7091528/p/q/C2.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p.q; + +/** This is class p.q.C2. */ +public class C2 { } + diff -r 8caec3672381 -r 24540bbb4135 test/tools/javah/6257087/foo.sh --- a/test/tools/javah/6257087/foo.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javah/6257087/foo.sh Tue May 29 00:27:58 2012 +0100 @@ -41,7 +41,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux ) + SunOS | Linux | Darwin ) PS=":" FS="/" ;; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javah/ConstMacroTest.sh --- a/test/tools/javah/ConstMacroTest.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javah/ConstMacroTest.sh Tue May 29 00:27:58 2012 +0100 @@ -56,7 +56,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux ) + SunOS | Linux | Darwin ) PS=":" FS="/" ;; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javah/MissingParamClassTest.sh --- a/test/tools/javah/MissingParamClassTest.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javah/MissingParamClassTest.sh Tue May 29 00:27:58 2012 +0100 @@ -58,7 +58,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | CYGWIN* ) + SunOS | Linux | Darwin | CYGWIN* ) PS=":" FS="/" ;; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javah/ReadOldClass.sh --- a/test/tools/javah/ReadOldClass.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javah/ReadOldClass.sh Tue May 29 00:27:58 2012 +0100 @@ -43,7 +43,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | CYGWIN* ) + SunOS | Linux | Darwin | CYGWIN* ) PS=":" FS="/" ;; diff -r 8caec3672381 -r 24540bbb4135 test/tools/javah/T7126832/T7126832.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javah/T7126832/T7126832.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7126832 + * @compile java.java + * @summary com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast + * @run main T7126832 + */ + +import java.io.*; +import java.util.*; + +public class T7126832 { + public static void main(String... args) throws Exception { + new T7126832().run(); + } + + void run() throws Exception { + Locale prev = Locale.getDefault(); + Locale.setDefault(Locale.ENGLISH); + try { + // Verify that a .java file is correctly diagnosed + File ff = writeFile(new File("JavahTest.java"), "class JavahTest {}"); + test(Arrays.asList(ff.getPath()), 1, "Could not find class file for 'JavahTest.java'."); + + // Verify that a class named 'xx.java' is accepted. + // Note that ./xx/java.class exists, so this should work ok + test(Arrays.asList("xx.java"), 0, null); + + if (errors > 0) { + throw new Exception(errors + " errors occurred"); + } + } finally { + Locale.setDefault(prev); + } + } + + void test(List args, int expectRC, String expectOut) { + System.err.println("Test: " + args + + " rc:" + expectRC + + ((expectOut != null) ? " out:" + expectOut : "")); + + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = 0; + String out = null; + try { + rc = com.sun.tools.javah.Main.run(args.toArray(new String[args.size()]), pw); + out = sw.toString(); + } catch(Exception ee) { + rc = 1; + out = ee.toString();; + } + pw.close(); + if (!out.isEmpty()) { + System.err.println(out); + } + if (rc != expectRC) { + error("Unexpected exit code: " + rc + "; expected: " + expectRC); + } + if (expectOut != null && !out.contains(expectOut)) { + error("Expected string not found: " + expectOut); + } + + System.err.println(); + } + + File writeFile(File ff, String ss) throws IOException { + if (ff.getParentFile() != null) + ff.getParentFile().mkdirs(); + + try (FileWriter out = new FileWriter(ff)) { + out.write(ss); + } + return ff; + } + + void error(String msg) { + System.err.println(msg); + errors++; + } + + int errors; +} + diff -r 8caec3672381 -r 24540bbb4135 test/tools/javah/T7126832/java.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javah/T7126832/java.java Tue May 29 00:27:58 2012 +0100 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package xx; +class java { + int fred; +} diff -r 8caec3672381 -r 24540bbb4135 test/tools/javap/pathsep.sh --- a/test/tools/javap/pathsep.sh Mon Jul 11 22:31:52 2011 +0100 +++ b/test/tools/javap/pathsep.sh Tue May 29 00:27:58 2012 +0100 @@ -40,7 +40,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | CYGWIN* ) + SunOS | Linux | Darwin | CYGWIN* ) FS="/" ;; Windows* )