Tue, 12 Oct 2010 12:52:49 -0700
Merge
test/tools/javac/processing/Xprint.java | file | annotate | diff | comparison | revisions |
1.1 --- a/make/netbeans/langtools/build.xml Thu Oct 07 15:12:31 2010 -0700 1.2 +++ b/make/netbeans/langtools/build.xml Tue Oct 12 12:52:49 2010 -0700 1.3 @@ -31,44 +31,44 @@ 1.4 --> 1.5 1.6 <project name="langtools-netbeans" default="build" basedir="../../.."> 1.7 - 1.8 - <property name="langtools.properties" 1.9 + 1.10 + <property name="langtools.properties" 1.11 location="make/netbeans/langtools/nbproject/private/langtools.properties"/> 1.12 - 1.13 - <!-- 1.14 + 1.15 + <!-- 1.16 Instead of importing the main build file, we could call it when needed. 1.17 That would reduce the list of Ant targets that get displayed for this 1.18 - file, but it also complicates the interface between the project build 1.19 + file, but it also complicates the interface between the project build 1.20 file and the main build file. For example, some imported targets 1.21 would have to be reclared, properties would have to be restructured, 1.22 - and it would be harder to run results (e.g. in properties) from nested 1.23 + and it would be harder to run results (e.g. in properties) from nested 1.24 targets. 1.25 --> 1.26 - <import file="../../build.xml"/> 1.27 - 1.28 + <import file="../../build.xml"/> 1.29 + 1.30 <!-- Build project. (action: build; F11) 1.31 If langtools.tool.name is set, then just build that tool; otherwise 1.32 build all tools. 1.33 --> 1.34 - 1.35 - <target name="build" depends="-get-tool-if-set,-build-tool,-build-all" 1.36 + 1.37 + <target name="build" depends="-get-tool-if-set,-build-tool,-build-all" 1.38 description="Build one or all langtools tools" 1.39 /> 1.40 - 1.41 + 1.42 <target name="-build-tool" if="langtools.tool.name"> 1.43 <echo level="info" message="Building ${langtools.tool.name}"/> 1.44 <echo level="verbose" message="(Unset langtools.tool.name to build all tools)"/> 1.45 <antcall target="build-${langtools.tool.name}"/> 1.46 </target> 1.47 - 1.48 + 1.49 <target name="-build-all" unless="langtools.tool.name"> 1.50 <echo level="info" message="Building all tools"/> 1.51 <echo level="verbose" message="(Set langtools.tool.name to build a single tool)"/> 1.52 <antcall target="build-all-tools"/> 1.53 </target> 1.54 - 1.55 + 1.56 <!-- Compile a single file. (action: compile.single; F9) --> 1.57 - 1.58 + 1.59 <target name="compile-single" depends="build-bootstrap-javac"> 1.60 <fail unless="includes">Must set property 'includes'</fail> 1.61 <javac fork="true" executable="${build.bootstrap.dir}/bin/javac" 1.62 @@ -78,38 +78,38 @@ 1.63 sourcepath="" 1.64 includeAntRuntime="no" 1.65 target="${javac.target}" 1.66 - debug="${javac.debug}" 1.67 + debug="${javac.debug}" 1.68 debuglevel="${javac.debuglevel}"/> 1.69 </target> 1.70 - 1.71 - <!-- Run tool. (action: run; F6) 1.72 + 1.73 + <!-- Run tool. (action: run; F6) 1.74 Use langtools.tool.name and langtools.tool.args properties if set; otherwise prompt 1.75 the user. 1.76 --> 1.77 - 1.78 - <target name="run" depends="-check-target.java.home,build,-def-run,-get-tool-and-args" 1.79 + 1.80 + <target name="run" depends="-check-target.java.home,build,-def-run,-get-tool-and-args" 1.81 description="run tool"> 1.82 <echo level="info" message="Run ${langtools.tool.name} with args ${langtools.tool.args}"/> 1.83 <run mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}"/> 1.84 </target> 1.85 - 1.86 + 1.87 <!-- Run a selected class. (action: run.single; shift-F6) --> 1.88 - 1.89 + 1.90 <target name="run-single" depends="-check-target.java.home,-def-run"> 1.91 <fail unless="run.classname">Must set property 'run.classname' </fail> 1.92 <echo level="info" message="run ${run.classname}"/> 1.93 <run mainclass="${run.classname}" args=""/> 1.94 </target> 1.95 - 1.96 + 1.97 <!-- Test project, and display results if tests failed. (action: test; Alt-F6) 1.98 If langtools.tool.name is set, then just test that tool; otherwise 1.99 test all tools. 1.100 --> 1.101 - 1.102 - <target name="jtreg" depends="-get-tool-if-set,-jtreg-tool,-jtreg-all" 1.103 + 1.104 + <target name="jtreg" depends="-get-tool-if-set,-jtreg-tool,-jtreg-all" 1.105 description="Test one or all langtools tools" 1.106 /> 1.107 - 1.108 + 1.109 <target name="-jtreg-tool" if="langtools.tool.name"> 1.110 <echo level="info" message="Testing ${langtools.tool.name}"/> 1.111 <echo level="verbose" message="(Unset langtools.tool.name to test all tools)"/> 1.112 @@ -118,7 +118,7 @@ 1.113 <target name="-show-jtreg"/> 1.114 </antcall> 1.115 </target> 1.116 - 1.117 + 1.118 <target name="-jtreg-all" unless="langtools.tool.name"> 1.119 <echo level="info" message="Testing all tools"/> 1.120 <echo level="verbose" message="(Set langtools.tool.name to test a single tool)"/> 1.121 @@ -127,36 +127,36 @@ 1.122 <target name="-show-jtreg"/> 1.123 </antcall> 1.124 </target> 1.125 - 1.126 + 1.127 <target name="-show-jtreg" if="netbeans.home" unless="jtreg.passed"> 1.128 <nbbrowse file="${jtreg.report}/report.html"/> 1.129 <fail>Some tests failed; see report for details.</fail> 1.130 </target> 1.131 - 1.132 + 1.133 <!-- Debug tool in NetBeans. --> 1.134 - 1.135 + 1.136 <target name="debug" depends="-check-target.java.home,-def-run,-def-start-debugger,-get-tool-and-args,build" if="netbeans.home"> 1.137 <echo level="info" message="Debug ${langtools.tool.name} with args ${langtools.tool.args}"/> 1.138 <start-debugger/> 1.139 <run mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}" jpda.jvmargs="${jpda.jvmargs}"/> 1.140 </target> 1.141 - 1.142 + 1.143 <!-- Debug a selected class . --> 1.144 <target name="debug-single" depends="-check-target.java.home,-def-start-debugger,-def-run"> 1.145 <fail unless="debug.classname">Must set property 'debug.classname'</fail> 1.146 <start-debugger/> 1.147 <run mainclass="${debug.classname}" default.args="" jpda.jvmargs="${jpda.jvmargs}"/> 1.148 </target> 1.149 - 1.150 + 1.151 <!-- Debug a jtreg test. --> 1.152 <target name="debug-jtreg" depends="-check-target.java.home,-def-start-debugger,-def-jtreg"> 1.153 <fail unless="jtreg.tests">Must set property 'jtreg.tests'</fail> 1.154 <start-debugger/> 1.155 <jtreg-tool name="debug" samevm="false" tests="${jtreg.tests}" jpda.jvmargs="${jpda.jvmargs}"/> 1.156 </target> 1.157 - 1.158 + 1.159 <!-- Update a class being debugged. --> 1.160 - 1.161 + 1.162 <target name="debug-fix" if="langtools.tool.name"> 1.163 <fail unless="class">Must set property 'class' 1.164 </fail> 1.165 @@ -169,16 +169,16 @@ 1.166 </fileset> 1.167 </nbjpdareload> 1.168 </target> 1.169 - 1.170 + 1.171 <!-- Generate javadoc for one or all tools. (action: javadoc; Alt-F6) 1.172 If langtools.tool.name is set, then just test that tool; otherwise 1.173 test all tools. 1.174 --> 1.175 - 1.176 - <target name="javadoc" depends="-javadoc-tool,-javadoc-all" 1.177 + 1.178 + <target name="javadoc" depends="-javadoc-tool,-javadoc-all" 1.179 description="Generate javadoc for one or all langtools tools" 1.180 /> 1.181 - 1.182 + 1.183 <target name="-javadoc-tool" if="langtools.tool.name"> 1.184 <echo level="info" message="Generate javadoc for ${langtools.tool.name}"/> 1.185 <echo level="verbose" message="(Unset langtools.tool.name to generate javadoc for all tools)"/> 1.186 @@ -187,7 +187,7 @@ 1.187 <target name="-show-javadoc"/> 1.188 </antcall> 1.189 </target> 1.190 - 1.191 + 1.192 <target name="-javadoc-all" unless="langtools.tool.name"> 1.193 <echo level="info" message="Generate javadoc for all tools"/> 1.194 <echo level="verbose" message="(Set langtools.tool.name to generate javadoc for a single tool)"/> 1.195 @@ -196,26 +196,26 @@ 1.196 <target name="-show-javadoc"/> 1.197 </antcall> 1.198 </target> 1.199 - 1.200 + 1.201 <target name="-show-javadoc" if="netbeans.home"> 1.202 <!-- what if doing javadoc for all? --> 1.203 <nbbrowse file="${build.javadoc.dir}/${langtools.tool.name}/index.html"/> 1.204 </target> 1.205 - 1.206 + 1.207 <!-- Prompt for values. --> 1.208 - 1.209 + 1.210 <target name="-get-tool-if-set" depends="-def-select-tool"> 1.211 - <select-tool 1.212 - toolproperty="langtools.tool.name" 1.213 + <select-tool 1.214 + toolproperty="langtools.tool.name" 1.215 propertyfile="${langtools.properties}" 1.216 askIfUnset="false" 1.217 /> 1.218 </target> 1.219 - 1.220 + 1.221 <target name="-get-tool-and-args" depends="-def-select-tool"> 1.222 - <select-tool 1.223 - toolproperty="langtools.tool.name" 1.224 - argsproperty="langtools.tool.args" 1.225 + <select-tool 1.226 + toolproperty="langtools.tool.name" 1.227 + argsproperty="langtools.tool.args" 1.228 propertyfile="${langtools.properties}" 1.229 askIfUnset="true" 1.230 /> 1.231 @@ -236,7 +236,7 @@ 1.232 </sequential> 1.233 </macrodef> 1.234 </target> 1.235 - 1.236 + 1.237 <!-- Macro to start the debugger and set a property containg the args needed by the run task --> 1.238 <target name="-def-start-debugger" if="netbeans.home"> 1.239 <macrodef name="start-debugger"> 1.240 @@ -251,28 +251,29 @@ 1.241 <pathelement location="${src.classes.dir}"/> 1.242 </sourcepath> 1.243 </nbjpdastart> 1.244 - <property 1.245 - name="@{jpda.jvmargs.property}" 1.246 + <property 1.247 + name="@{jpda.jvmargs.property}" 1.248 value="-Xdebug -Xnoagent -Djava.compiler=none -Xrunjdwp:transport=dt_socket,address=${jpda.address}" 1.249 /> 1.250 </sequential> 1.251 </macrodef> 1.252 </target> 1.253 - 1.254 + 1.255 <target name="-def-select-tool"> 1.256 <mkdir dir="${build.toolclasses.dir}"/> 1.257 <javac srcdir="${make.tools.dir}/SelectTool" 1.258 destdir="${build.toolclasses.dir}/" 1.259 - classpath="${ant.home}/lib/ant.jar" 1.260 - debug="${javac.debug}" 1.261 + classpath="${ant.core.lib}" 1.262 + includeantruntime="false" 1.263 + debug="${javac.debug}" 1.264 debuglevel="${javac.debuglevel}"> 1.265 <compilerarg line="-Xlint"/> 1.266 </javac> 1.267 <taskdef name="select-tool" 1.268 - classname="SelectToolTask" 1.269 + classname="SelectToolTask" 1.270 classpath="${build.toolclasses.dir}/"/> 1.271 </target> 1.272 - 1.273 + 1.274 <target name="select-tool" depends="-def-select-tool"> 1.275 <select-tool propertyfile="${langtools.properties}"/> 1.276 </target>
2.1 --- a/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java Thu Oct 07 15:12:31 2010 -0700 2.2 +++ b/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java Tue Oct 12 12:52:49 2010 -0700 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -99,9 +99,6 @@ 2.11 private static Context preRegister(Context context) { 2.12 Bark.preRegister(context); 2.13 2.14 - // force the use of the scanner that captures Javadoc comments 2.15 - DocCommentScanner.Factory.preRegister(context); 2.16 - 2.17 if (context.get(JavaFileManager.class) == null) 2.18 JavacFileManager.preRegister(context); 2.19
3.1 --- a/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Thu Oct 07 15:12:31 2010 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Tue Oct 12 12:52:49 2010 -0700 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -96,9 +96,6 @@ 3.11 args.getClass(); 3.12 context.getClass(); 3.13 fileObjects.getClass(); 3.14 - 3.15 - // force the use of the scanner that captures Javadoc comments 3.16 - com.sun.tools.javac.parser.DocCommentScanner.Factory.preRegister(context); 3.17 } 3.18 3.19 JavacTaskImpl(JavacTool tool, 3.20 @@ -337,9 +334,13 @@ 3.21 3.22 ListBuffer<TypeElement> elements = new ListBuffer<TypeElement>(); 3.23 for (JCCompilationUnit unit : units) { 3.24 - for (JCTree node : unit.defs) 3.25 - if (node.getTag() == JCTree.CLASSDEF) 3.26 - elements.append(((JCTree.JCClassDecl) node).sym); 3.27 + for (JCTree node : unit.defs) { 3.28 + if (node.getTag() == JCTree.CLASSDEF) { 3.29 + JCClassDecl cdef = (JCClassDecl) node; 3.30 + if (cdef.sym != null) // maybe null if errors in anno processing 3.31 + elements.append(cdef.sym); 3.32 + } 3.33 + } 3.34 } 3.35 return elements.toList(); 3.36 }
4.1 --- a/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Thu Oct 07 15:12:31 2010 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Tue Oct 12 12:52:49 2010 -0700 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -56,7 +56,6 @@ 4.11 import com.sun.tools.javac.comp.MemberEnter; 4.12 import com.sun.tools.javac.comp.Resolve; 4.13 import com.sun.tools.javac.model.JavacElements; 4.14 -import com.sun.tools.javac.processing.JavacMessager; 4.15 import com.sun.tools.javac.processing.JavacProcessingEnvironment; 4.16 import com.sun.tools.javac.tree.JCTree.*; 4.17 import com.sun.tools.javac.tree.JCTree; 4.18 @@ -81,14 +80,15 @@ 4.19 */ 4.20 public class JavacTrees extends Trees { 4.21 4.22 - private final Resolve resolve; 4.23 - private final Enter enter; 4.24 - private final Log log; 4.25 - private final MemberEnter memberEnter; 4.26 - private final Attr attr; 4.27 - private final TreeMaker treeMaker; 4.28 - private final JavacElements elements; 4.29 - private final JavacTaskImpl javacTaskImpl; 4.30 + // in a world of a single context per compilation, these would all be final 4.31 + private Resolve resolve; 4.32 + private Enter enter; 4.33 + private Log log; 4.34 + private MemberEnter memberEnter; 4.35 + private Attr attr; 4.36 + private TreeMaker treeMaker; 4.37 + private JavacElements elements; 4.38 + private JavacTaskImpl javacTaskImpl; 4.39 4.40 public static JavacTrees instance(JavaCompiler.CompilationTask task) { 4.41 if (!(task instanceof JavacTaskImpl)) 4.42 @@ -111,6 +111,14 @@ 4.43 4.44 private JavacTrees(Context context) { 4.45 context.put(JavacTrees.class, this); 4.46 + init(context); 4.47 + } 4.48 + 4.49 + public void updateContext(Context context) { 4.50 + init(context); 4.51 + } 4.52 + 4.53 + private void init(Context context) { 4.54 attr = Attr.instance(context); 4.55 enter = Enter.instance(context); 4.56 elements = JavacElements.instance(context); 4.57 @@ -337,6 +345,7 @@ 4.58 super(M); 4.59 } 4.60 4.61 + @Override 4.62 public <T extends JCTree> T copy(T t, JCTree leaf) { 4.63 T t2 = super.copy(t, leaf); 4.64 if (t == leaf)
5.1 --- a/src/share/classes/com/sun/tools/javac/code/Scope.java Thu Oct 07 15:12:31 2010 -0700 5.2 +++ b/src/share/classes/com/sun/tools/javac/code/Scope.java Tue Oct 12 12:52:49 2010 -0700 5.3 @@ -70,6 +70,45 @@ 5.4 */ 5.5 public int nelems = 0; 5.6 5.7 + /** A timestamp - useful to quickly check whether a scope has changed or not 5.8 + */ 5.9 + public ScopeCounter scopeCounter; 5.10 + 5.11 + static ScopeCounter dummyCounter = new ScopeCounter() { 5.12 + @Override 5.13 + public void inc() { 5.14 + //do nothing 5.15 + } 5.16 + }; 5.17 + 5.18 + public static class ScopeCounter { 5.19 + protected static final Context.Key<ScopeCounter> scopeCounterKey = 5.20 + new Context.Key<ScopeCounter>(); 5.21 + 5.22 + public static ScopeCounter instance(Context context) { 5.23 + ScopeCounter instance = context.get(scopeCounterKey); 5.24 + if (instance == null) 5.25 + instance = new ScopeCounter(context); 5.26 + return instance; 5.27 + } 5.28 + 5.29 + protected ScopeCounter(Context context) { 5.30 + context.put(scopeCounterKey, this); 5.31 + } 5.32 + 5.33 + private ScopeCounter() {}; 5.34 + 5.35 + private long val = 0; 5.36 + 5.37 + public void inc() { 5.38 + val++; 5.39 + } 5.40 + 5.41 + public long val() { 5.42 + return val; 5.43 + } 5.44 + } 5.45 + 5.46 /** Every hash bucket is a list of Entry's which ends in sentinel. 5.47 */ 5.48 private static final Entry sentinel = new Entry(null, null, null, null); 5.49 @@ -80,12 +119,12 @@ 5.50 5.51 /** A value for the empty scope. 5.52 */ 5.53 - public static final Scope emptyScope = new Scope(null, null, new Entry[]{}); 5.54 + public static final Scope emptyScope = new Scope(null, null, new Entry[]{}, dummyCounter); 5.55 5.56 /** Construct a new scope, within scope next, with given owner, using 5.57 * given table. The table's length must be an exponent of 2. 5.58 */ 5.59 - Scope(Scope next, Symbol owner, Entry[] table) { 5.60 + private Scope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) { 5.61 this.next = next; 5.62 assert emptyScope == null || owner != null; 5.63 this.owner = owner; 5.64 @@ -94,13 +133,18 @@ 5.65 this.elems = null; 5.66 this.nelems = 0; 5.67 this.shared = 0; 5.68 + this.scopeCounter = scopeCounter; 5.69 } 5.70 5.71 /** Construct a new scope, within scope next, with given owner, 5.72 * using a fresh table of length INITIAL_SIZE. 5.73 */ 5.74 public Scope(Symbol owner) { 5.75 - this(null, owner, new Entry[INITIAL_SIZE]); 5.76 + this(owner, dummyCounter); 5.77 + } 5.78 + 5.79 + protected Scope(Symbol owner, ScopeCounter scopeCounter) { 5.80 + this(null, owner, new Entry[INITIAL_SIZE], scopeCounter); 5.81 for (int i = 0; i < INITIAL_SIZE; i++) table[i] = sentinel; 5.82 } 5.83 5.84 @@ -110,7 +154,7 @@ 5.85 * of fresh tables. 5.86 */ 5.87 public Scope dup() { 5.88 - Scope result = new Scope(this, this.owner, this.table); 5.89 + Scope result = new Scope(this, this.owner, this.table, scopeCounter); 5.90 shared++; 5.91 // System.out.println("====> duping scope " + this.hashCode() + " owned by " + this.owner + " to " + result.hashCode()); 5.92 // new Error().printStackTrace(System.out); 5.93 @@ -123,7 +167,7 @@ 5.94 * of fresh tables. 5.95 */ 5.96 public Scope dup(Symbol newOwner) { 5.97 - Scope result = new Scope(this, newOwner, this.table); 5.98 + Scope result = new Scope(this, newOwner, this.table, scopeCounter); 5.99 shared++; 5.100 // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode()); 5.101 // new Error().printStackTrace(System.out); 5.102 @@ -135,7 +179,7 @@ 5.103 * the table of its outer scope. 5.104 */ 5.105 public Scope dupUnshared() { 5.106 - return new Scope(this, this.owner, this.table.clone()); 5.107 + return new Scope(this, this.owner, this.table.clone(), scopeCounter); 5.108 } 5.109 5.110 /** Remove all entries of this scope from its table, if shared 5.111 @@ -211,6 +255,7 @@ 5.112 table[hash] = e; 5.113 elems = e; 5.114 nelems++; 5.115 + scopeCounter.inc(); 5.116 } 5.117 5.118 Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) { 5.119 @@ -226,6 +271,8 @@ 5.120 while (e.scope == this && e.sym != sym) e = e.next(); 5.121 if (e.scope == null) return; 5.122 5.123 + scopeCounter.inc(); 5.124 + 5.125 // remove e from table and shadowed list; 5.126 Entry te = table[sym.name.hashCode() & hashMask]; 5.127 if (te == e) 5.128 @@ -472,7 +519,7 @@ 5.129 public static final Entry[] emptyTable = new Entry[0]; 5.130 5.131 public DelegatedScope(Scope outer) { 5.132 - super(outer, outer.owner, emptyTable); 5.133 + super(outer, outer.owner, emptyTable, outer.scopeCounter); 5.134 delegatee = outer; 5.135 } 5.136 public Scope dup() { 5.137 @@ -498,10 +545,22 @@ 5.138 } 5.139 } 5.140 5.141 + /** A class scope, for which a scope counter should be provided */ 5.142 + public static class ClassScope extends Scope { 5.143 + 5.144 + ClassScope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) { 5.145 + super(next, owner, table, scopeCounter); 5.146 + } 5.147 + 5.148 + public ClassScope(Symbol owner, ScopeCounter scopeCounter) { 5.149 + super(owner, scopeCounter); 5.150 + } 5.151 + } 5.152 + 5.153 /** An error scope, for which the owner should be an error symbol. */ 5.154 public static class ErrorScope extends Scope { 5.155 ErrorScope(Scope next, Symbol errSymbol, Entry[] table) { 5.156 - super(next, /*owner=*/errSymbol, table); 5.157 + super(next, /*owner=*/errSymbol, table, dummyCounter); 5.158 } 5.159 public ErrorScope(Symbol errSymbol) { 5.160 super(errSymbol);
6.1 --- a/src/share/classes/com/sun/tools/javac/code/Source.java Thu Oct 07 15:12:31 2010 -0700 6.2 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java Tue Oct 12 12:52:49 2010 -0700 6.3 @@ -25,11 +25,14 @@ 6.4 6.5 package com.sun.tools.javac.code; 6.6 6.7 +import java.util.*; 6.8 +import javax.lang.model.SourceVersion; 6.9 +import static javax.lang.model.SourceVersion.*; 6.10 + 6.11 import com.sun.tools.javac.util.*; 6.12 import com.sun.tools.javac.jvm.Target; 6.13 -import javax.lang.model.SourceVersion; 6.14 -import static javax.lang.model.SourceVersion.*; 6.15 -import java.util.*; 6.16 + 6.17 +import static com.sun.tools.javac.main.OptionName.*; 6.18 6.19 /** The source language version accepted. 6.20 * 6.21 @@ -71,7 +74,7 @@ 6.22 Source instance = context.get(sourceKey); 6.23 if (instance == null) { 6.24 Options options = Options.instance(context); 6.25 - String sourceString = options.get("-source"); 6.26 + String sourceString = options.get(SOURCE); 6.27 if (sourceString != null) instance = lookup(sourceString); 6.28 if (instance == null) instance = DEFAULT; 6.29 context.put(sourceKey, instance);
7.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Oct 07 15:12:31 2010 -0700 7.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Oct 12 12:52:49 2010 -0700 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -960,6 +960,8 @@ 7.11 return ElementKind.ENUM_CONSTANT; 7.12 } else if (owner.kind == TYP || owner.kind == ERR) { 7.13 return ElementKind.FIELD; 7.14 + } else if (isResourceVariable()) { 7.15 + return ElementKind.RESOURCE_VARIABLE; 7.16 } else { 7.17 return ElementKind.LOCAL_VARIABLE; 7.18 }
8.1 --- a/src/share/classes/com/sun/tools/javac/code/Symtab.java Thu Oct 07 15:12:31 2010 -0700 8.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java Tue Oct 12 12:52:49 2010 -0700 8.3 @@ -74,6 +74,7 @@ 8.4 public final JCNoType voidType = new JCNoType(TypeTags.VOID); 8.5 8.6 private final Names names; 8.7 + private final Scope.ScopeCounter scopeCounter; 8.8 private final ClassReader reader; 8.9 private final Target target; 8.10 8.11 @@ -340,6 +341,7 @@ 8.12 context.put(symtabKey, this); 8.13 8.14 names = Names.instance(context); 8.15 + scopeCounter = Scope.ScopeCounter.instance(context); 8.16 target = Target.instance(context); 8.17 8.18 // Create the unknown type 8.19 @@ -386,7 +388,7 @@ 8.20 8.21 // Create class to hold all predefined constants and operations. 8.22 predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage); 8.23 - Scope scope = new Scope(predefClass); 8.24 + Scope scope = new Scope.ClassScope(predefClass, scopeCounter); 8.25 predefClass.members_field = scope; 8.26 8.27 // Enter symbols for basic types. 8.28 @@ -476,7 +478,7 @@ 8.29 proprietarySymbol.completer = null; 8.30 proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE; 8.31 proprietarySymbol.erasure_field = proprietaryType; 8.32 - proprietarySymbol.members_field = new Scope(proprietarySymbol); 8.33 + proprietarySymbol.members_field = new Scope.ClassScope(proprietarySymbol, scopeCounter); 8.34 proprietaryType.typarams_field = List.nil(); 8.35 proprietaryType.allparams_field = List.nil(); 8.36 proprietaryType.supertype_field = annotationType; 8.37 @@ -488,7 +490,7 @@ 8.38 ClassType arrayClassType = (ClassType)arrayClass.type; 8.39 arrayClassType.supertype_field = objectType; 8.40 arrayClassType.interfaces_field = List.of(cloneableType, serializableType); 8.41 - arrayClass.members_field = new Scope(arrayClass); 8.42 + arrayClass.members_field = new Scope.ClassScope(arrayClass, scopeCounter); 8.43 lengthVar = new VarSymbol( 8.44 PUBLIC | FINAL, 8.45 names.length,
9.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Thu Oct 07 15:12:31 2010 -0700 9.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Tue Oct 12 12:52:49 2010 -0700 9.3 @@ -69,6 +69,7 @@ 9.4 new Context.Key<Types>(); 9.5 9.6 final Symtab syms; 9.7 + final Scope.ScopeCounter scopeCounter; 9.8 final JavacMessages messages; 9.9 final Names names; 9.10 final boolean allowBoxing; 9.11 @@ -89,6 +90,7 @@ 9.12 protected Types(Context context) { 9.13 context.put(typesKey, this); 9.14 syms = Symtab.instance(context); 9.15 + scopeCounter = Scope.ScopeCounter.instance(context); 9.16 names = Names.instance(context); 9.17 allowBoxing = Source.instance(context).allowBoxing(); 9.18 reader = ClassReader.instance(context); 9.19 @@ -1984,22 +1986,26 @@ 9.20 final MethodSymbol cachedImpl; 9.21 final Filter<Symbol> implFilter; 9.22 final boolean checkResult; 9.23 + final Scope.ScopeCounter scopeCounter; 9.24 9.25 public Entry(MethodSymbol cachedImpl, 9.26 Filter<Symbol> scopeFilter, 9.27 - boolean checkResult) { 9.28 + boolean checkResult, 9.29 + Scope.ScopeCounter scopeCounter) { 9.30 this.cachedImpl = cachedImpl; 9.31 this.implFilter = scopeFilter; 9.32 this.checkResult = checkResult; 9.33 + this.scopeCounter = scopeCounter; 9.34 } 9.35 9.36 - boolean matches(Filter<Symbol> scopeFilter, boolean checkResult) { 9.37 + boolean matches(Filter<Symbol> scopeFilter, boolean checkResult, Scope.ScopeCounter scopeCounter) { 9.38 return this.implFilter == scopeFilter && 9.39 - this.checkResult == checkResult; 9.40 + this.checkResult == checkResult && 9.41 + this.scopeCounter.val() >= scopeCounter.val(); 9.42 } 9.43 } 9.44 9.45 - MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) { 9.46 + MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter, Scope.ScopeCounter scopeCounter) { 9.47 SoftReference<Map<TypeSymbol, Entry>> ref_cache = _map.get(ms); 9.48 Map<TypeSymbol, Entry> cache = ref_cache != null ? ref_cache.get() : null; 9.49 if (cache == null) { 9.50 @@ -2008,9 +2014,9 @@ 9.51 } 9.52 Entry e = cache.get(origin); 9.53 if (e == null || 9.54 - !e.matches(implFilter, checkResult)) { 9.55 + !e.matches(implFilter, checkResult, scopeCounter)) { 9.56 MethodSymbol impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter); 9.57 - cache.put(origin, new Entry(impl, implFilter, checkResult)); 9.58 + cache.put(origin, new Entry(impl, implFilter, checkResult, scopeCounter)); 9.59 return impl; 9.60 } 9.61 else { 9.62 @@ -2038,7 +2044,7 @@ 9.63 private ImplementationCache implCache = new ImplementationCache(); 9.64 9.65 public MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) { 9.66 - return implCache.get(ms, origin, checkResult, implFilter); 9.67 + return implCache.get(ms, origin, checkResult, implFilter, scopeCounter); 9.68 } 9.69 // </editor-fold> 9.70
10.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Oct 07 15:12:31 2010 -0700 10.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Oct 12 12:52:49 2010 -0700 10.3 @@ -119,10 +119,10 @@ 10.4 allowAnonOuterThis = source.allowAnonOuterThis(); 10.5 allowStringsInSwitch = source.allowStringsInSwitch(); 10.6 sourceName = source.name; 10.7 - relax = (options.get("-retrofit") != null || 10.8 - options.get("-relax") != null); 10.9 - useBeforeDeclarationWarning = options.get("useBeforeDeclarationWarning") != null; 10.10 - enableSunApiLintControl = options.get("enableSunApiLintControl") != null; 10.11 + relax = (options.isSet("-retrofit") || 10.12 + options.isSet("-relax")); 10.13 + useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning"); 10.14 + enableSunApiLintControl = options.isSet("enableSunApiLintControl"); 10.15 } 10.16 10.17 /** Switch: relax some constraints for retrofit mode. 10.18 @@ -1422,7 +1422,8 @@ 10.19 10.20 // Compute the result type. 10.21 Type restype = mtype.getReturnType(); 10.22 - assert restype.tag != WILDCARD : mtype; 10.23 + if (restype.tag == WILDCARD) 10.24 + throw new AssertionError(mtype); 10.25 10.26 // as a special case, array.clone() has a result that is 10.27 // the same as static type of the array being cloned
11.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Oct 07 15:12:31 2010 -0700 11.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Oct 12 12:52:49 2010 -0700 11.3 @@ -25,7 +25,6 @@ 11.4 11.5 package com.sun.tools.javac.comp; 11.6 11.7 -import com.sun.source.tree.AssignmentTree; 11.8 import java.util.*; 11.9 import java.util.Set; 11.10 11.11 @@ -46,6 +45,8 @@ 11.12 import static com.sun.tools.javac.code.Kinds.*; 11.13 import static com.sun.tools.javac.code.TypeTags.*; 11.14 11.15 +import static com.sun.tools.javac.main.OptionName.*; 11.16 + 11.17 /** Type checking helper class for the attribution phase. 11.18 * 11.19 * <p><b>This is NOT part of any supported API. 11.20 @@ -60,6 +61,7 @@ 11.21 private final Names names; 11.22 private final Log log; 11.23 private final Symtab syms; 11.24 + private final Enter enter; 11.25 private final Infer infer; 11.26 private final Types types; 11.27 private final JCDiagnostic.Factory diags; 11.28 @@ -86,6 +88,7 @@ 11.29 names = Names.instance(context); 11.30 log = Log.instance(context); 11.31 syms = Symtab.instance(context); 11.32 + enter = Enter.instance(context); 11.33 infer = Infer.instance(context); 11.34 this.types = Types.instance(context); 11.35 diags = JCDiagnostic.Factory.instance(context); 11.36 @@ -97,10 +100,10 @@ 11.37 allowGenerics = source.allowGenerics(); 11.38 allowAnnotations = source.allowAnnotations(); 11.39 allowCovariantReturns = source.allowCovariantReturns(); 11.40 - complexInference = options.get("-complexinference") != null; 11.41 - skipAnnotations = options.get("skipAnnotations") != null; 11.42 - warnOnSyntheticConflicts = options.get("warnOnSyntheticConflicts") != null; 11.43 - suppressAbortOnBadClassFile = options.get("suppressAbortOnBadClassFile") != null; 11.44 + complexInference = options.isSet(COMPLEXINFERENCE); 11.45 + skipAnnotations = options.isSet("skipAnnotations"); 11.46 + warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); 11.47 + suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); 11.48 11.49 Target target = Target.instance(context); 11.50 syntheticNameChar = target.syntheticNameChar(); 11.51 @@ -1727,6 +1730,113 @@ 11.52 return undef; 11.53 } 11.54 11.55 + void checkNonCyclicDecl(JCClassDecl tree) { 11.56 + CycleChecker cc = new CycleChecker(); 11.57 + cc.scan(tree); 11.58 + if (!cc.errorFound && !cc.partialCheck) { 11.59 + tree.sym.flags_field |= ACYCLIC; 11.60 + } 11.61 + } 11.62 + 11.63 + class CycleChecker extends TreeScanner { 11.64 + 11.65 + List<Symbol> seenClasses = List.nil(); 11.66 + boolean errorFound = false; 11.67 + boolean partialCheck = false; 11.68 + 11.69 + private void checkSymbol(DiagnosticPosition pos, Symbol sym) { 11.70 + if (sym != null && sym.kind == TYP) { 11.71 + Env<AttrContext> classEnv = enter.getEnv((TypeSymbol)sym); 11.72 + if (classEnv != null) { 11.73 + DiagnosticSource prevSource = log.currentSource(); 11.74 + try { 11.75 + log.useSource(classEnv.toplevel.sourcefile); 11.76 + scan(classEnv.tree); 11.77 + } 11.78 + finally { 11.79 + log.useSource(prevSource.getFile()); 11.80 + } 11.81 + } else if (sym.kind == TYP) { 11.82 + checkClass(pos, sym, List.<JCTree>nil()); 11.83 + } 11.84 + } else { 11.85 + //not completed yet 11.86 + partialCheck = true; 11.87 + } 11.88 + } 11.89 + 11.90 + @Override 11.91 + public void visitSelect(JCFieldAccess tree) { 11.92 + super.visitSelect(tree); 11.93 + checkSymbol(tree.pos(), tree.sym); 11.94 + } 11.95 + 11.96 + @Override 11.97 + public void visitIdent(JCIdent tree) { 11.98 + checkSymbol(tree.pos(), tree.sym); 11.99 + } 11.100 + 11.101 + @Override 11.102 + public void visitTypeApply(JCTypeApply tree) { 11.103 + scan(tree.clazz); 11.104 + } 11.105 + 11.106 + @Override 11.107 + public void visitTypeArray(JCArrayTypeTree tree) { 11.108 + scan(tree.elemtype); 11.109 + } 11.110 + 11.111 + @Override 11.112 + public void visitClassDef(JCClassDecl tree) { 11.113 + List<JCTree> supertypes = List.nil(); 11.114 + if (tree.getExtendsClause() != null) { 11.115 + supertypes = supertypes.prepend(tree.getExtendsClause()); 11.116 + } 11.117 + if (tree.getImplementsClause() != null) { 11.118 + for (JCTree intf : tree.getImplementsClause()) { 11.119 + supertypes = supertypes.prepend(intf); 11.120 + } 11.121 + } 11.122 + checkClass(tree.pos(), tree.sym, supertypes); 11.123 + } 11.124 + 11.125 + void checkClass(DiagnosticPosition pos, Symbol c, List<JCTree> supertypes) { 11.126 + if ((c.flags_field & ACYCLIC) != 0) 11.127 + return; 11.128 + if (seenClasses.contains(c)) { 11.129 + errorFound = true; 11.130 + noteCyclic(pos, (ClassSymbol)c); 11.131 + } else if (!c.type.isErroneous()) { 11.132 + try { 11.133 + seenClasses = seenClasses.prepend(c); 11.134 + if (c.type.tag == CLASS) { 11.135 + if (supertypes.nonEmpty()) { 11.136 + scan(supertypes); 11.137 + } 11.138 + else { 11.139 + ClassType ct = (ClassType)c.type; 11.140 + if (ct.supertype_field == null || 11.141 + ct.interfaces_field == null) { 11.142 + //not completed yet 11.143 + partialCheck = true; 11.144 + return; 11.145 + } 11.146 + checkSymbol(pos, ct.supertype_field.tsym); 11.147 + for (Type intf : ct.interfaces_field) { 11.148 + checkSymbol(pos, intf.tsym); 11.149 + } 11.150 + } 11.151 + if (c.owner.kind == TYP) { 11.152 + checkSymbol(pos, c.owner); 11.153 + } 11.154 + } 11.155 + } finally { 11.156 + seenClasses = seenClasses.tail; 11.157 + } 11.158 + } 11.159 + } 11.160 + } 11.161 + 11.162 /** Check for cyclic references. Issue an error if the 11.163 * symbol of the type referred to has a LOCKED flag set. 11.164 *
12.1 --- a/src/share/classes/com/sun/tools/javac/comp/Enter.java Thu Oct 07 15:12:31 2010 -0700 12.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java Tue Oct 12 12:52:49 2010 -0700 12.3 @@ -94,6 +94,7 @@ 12.4 12.5 Log log; 12.6 Symtab syms; 12.7 + Scope.ScopeCounter scopeCounter; 12.8 Check chk; 12.9 TreeMaker make; 12.10 ClassReader reader; 12.11 @@ -121,6 +122,7 @@ 12.12 reader = ClassReader.instance(context); 12.13 make = TreeMaker.instance(context); 12.14 syms = Symtab.instance(context); 12.15 + scopeCounter = Scope.ScopeCounter.instance(context); 12.16 chk = Check.instance(context); 12.17 memberEnter = MemberEnter.instance(context); 12.18 types = Types.instance(context); 12.19 @@ -189,7 +191,7 @@ 12.20 */ 12.21 public Env<AttrContext> classEnv(JCClassDecl tree, Env<AttrContext> env) { 12.22 Env<AttrContext> localEnv = 12.23 - env.dup(tree, env.info.dup(new Scope(tree.sym))); 12.24 + env.dup(tree, env.info.dup(new Scope.ClassScope(tree.sym, scopeCounter))); 12.25 localEnv.enclClass = tree; 12.26 localEnv.outer = env; 12.27 localEnv.info.isSelfCall = false; 12.28 @@ -325,7 +327,7 @@ 12.29 c.flatname = names.fromString(tree.packge + "." + name); 12.30 c.sourcefile = tree.sourcefile; 12.31 c.completer = null; 12.32 - c.members_field = new Scope(c); 12.33 + c.members_field = new Scope.ClassScope(c, scopeCounter); 12.34 tree.packge.package_info = c; 12.35 } 12.36 classEnter(tree.defs, topEnv); 12.37 @@ -393,7 +395,7 @@ 12.38 c.completer = memberEnter; 12.39 c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree); 12.40 c.sourcefile = env.toplevel.sourcefile; 12.41 - c.members_field = new Scope(c); 12.42 + c.members_field = new Scope.ClassScope(c, scopeCounter); 12.43 12.44 ClassType ct = (ClassType)c.type; 12.45 if (owner.kind != PCK && (c.flags_field & STATIC) == 0) {
13.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Oct 07 15:12:31 2010 -0700 13.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Oct 12 12:52:49 2010 -0700 13.3 @@ -80,25 +80,12 @@ 13.4 13.5 } 13.6 13.7 - public static class InferenceException extends RuntimeException { 13.8 + public static class InferenceException extends Resolve.InapplicableMethodException { 13.9 private static final long serialVersionUID = 0; 13.10 13.11 - JCDiagnostic diagnostic; 13.12 - JCDiagnostic.Factory diags; 13.13 - 13.14 InferenceException(JCDiagnostic.Factory diags) { 13.15 - this.diagnostic = null; 13.16 - this.diags = diags; 13.17 + super(diags); 13.18 } 13.19 - 13.20 - InferenceException setMessage(String key, Object... args) { 13.21 - this.diagnostic = diags.fragment(key, args); 13.22 - return this; 13.23 - } 13.24 - 13.25 - public JCDiagnostic getDiagnostic() { 13.26 - return diagnostic; 13.27 - } 13.28 } 13.29 13.30 public static class NoInstanceException extends InferenceException { 13.31 @@ -320,7 +307,7 @@ 13.32 Type qtype1 = types.subst(that.qtype, that.tvars, undetvars); 13.33 if (!types.isSubtype(qtype1, to)) { 13.34 throw unambiguousNoInstanceException 13.35 - .setMessage("no.conforming.instance.exists", 13.36 + .setMessage("infer.no.conforming.instance.exists", 13.37 that.tvars, that.qtype, to); 13.38 } 13.39 for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail) 13.40 @@ -378,6 +365,11 @@ 13.41 // instantiate all polymorphic argument types and 13.42 // set up lower bounds constraints for undetvars 13.43 Type varargsFormal = useVarargs ? formals.last() : null; 13.44 + if (varargsFormal == null && 13.45 + actuals.size() != formals.size()) { 13.46 + throw unambiguousNoInstanceException 13.47 + .setMessage("infer.arg.length.mismatch"); 13.48 + } 13.49 while (actuals.nonEmpty() && formals.head != varargsFormal) { 13.50 Type formal = formals.head; 13.51 Type actual = actuals.head.baseType(); 13.52 @@ -390,19 +382,16 @@ 13.53 : types.isSubtypeUnchecked(actual, undetFormal, warn); 13.54 if (!works) { 13.55 throw unambiguousNoInstanceException 13.56 - .setMessage("no.conforming.assignment.exists", 13.57 + .setMessage("infer.no.conforming.assignment.exists", 13.58 tvars, actualNoCapture, formal); 13.59 } 13.60 formals = formals.tail; 13.61 actuals = actuals.tail; 13.62 actualsNoCapture = actualsNoCapture.tail; 13.63 } 13.64 - if (formals.head != varargsFormal || // not enough args 13.65 - !useVarargs && actuals.nonEmpty()) { // too many args 13.66 - // argument lists differ in length 13.67 - throw unambiguousNoInstanceException 13.68 - .setMessage("arg.length.mismatch"); 13.69 - } 13.70 + 13.71 + if (formals.head != varargsFormal) // not enough args 13.72 + throw unambiguousNoInstanceException.setMessage("infer.arg.length.mismatch"); 13.73 13.74 // for varargs arguments as well 13.75 if (useVarargs) { 13.76 @@ -416,7 +405,7 @@ 13.77 boolean works = types.isConvertible(actual, elemUndet, warn); 13.78 if (!works) { 13.79 throw unambiguousNoInstanceException 13.80 - .setMessage("no.conforming.assignment.exists", 13.81 + .setMessage("infer.no.conforming.assignment.exists", 13.82 tvars, actualNoCapture, elemType); 13.83 } 13.84 actuals = actuals.tail;
14.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Oct 07 15:12:31 2010 -0700 14.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Oct 12 12:52:49 2010 -0700 14.3 @@ -68,6 +68,7 @@ 14.4 private Names names; 14.5 private Log log; 14.6 private Symtab syms; 14.7 + private Scope.ScopeCounter scopeCounter; 14.8 private Resolve rs; 14.9 private Check chk; 14.10 private Attr attr; 14.11 @@ -90,6 +91,7 @@ 14.12 names = Names.instance(context); 14.13 log = Log.instance(context); 14.14 syms = Symtab.instance(context); 14.15 + scopeCounter = Scope.ScopeCounter.instance(context); 14.16 rs = Resolve.instance(context); 14.17 chk = Check.instance(context); 14.18 attr = Attr.instance(context); 14.19 @@ -107,7 +109,7 @@ 14.20 14.21 types = Types.instance(context); 14.22 Options options = Options.instance(context); 14.23 - debugLower = options.get("debuglower") != null; 14.24 + debugLower = options.isSet("debuglower"); 14.25 pkginfoOpt = PkgInfo.get(options); 14.26 } 14.27 14.28 @@ -569,7 +571,7 @@ 14.29 c.flatname = chk.localClassName(c); 14.30 c.sourcefile = owner.sourcefile; 14.31 c.completer = null; 14.32 - c.members_field = new Scope(c); 14.33 + c.members_field = new Scope.ClassScope(c, scopeCounter); 14.34 c.flags_field = flags; 14.35 ClassType ctype = (ClassType) c.type; 14.36 ctype.supertype_field = syms.objectType; 14.37 @@ -2677,7 +2679,8 @@ 14.38 } 14.39 //where 14.40 private JCTree convert(JCTree tree, Type pt) { 14.41 - if (tree.type == pt) return tree; 14.42 + if (tree.type == pt || tree.type.tag == TypeTags.BOT) 14.43 + return tree; 14.44 JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree); 14.45 result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt) 14.46 : pt;
15.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Oct 07 15:12:31 2010 -0700 15.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Oct 12 12:52:49 2010 -0700 15.3 @@ -67,6 +67,7 @@ 15.4 private final Check chk; 15.5 private final Attr attr; 15.6 private final Symtab syms; 15.7 + private final Scope.ScopeCounter scopeCounter; 15.8 private final TreeMaker make; 15.9 private final ClassReader reader; 15.10 private final Todo todo; 15.11 @@ -92,6 +93,7 @@ 15.12 chk = Check.instance(context); 15.13 attr = Attr.instance(context); 15.14 syms = Symtab.instance(context); 15.15 + scopeCounter = Scope.ScopeCounter.instance(context); 15.16 make = TreeMaker.instance(context); 15.17 reader = ClassReader.instance(context); 15.18 todo = Todo.instance(context); 15.19 @@ -100,7 +102,7 @@ 15.20 diags = JCDiagnostic.Factory.instance(context); 15.21 target = Target.instance(context); 15.22 Options options = Options.instance(context); 15.23 - skipAnnotations = options.get("skipAnnotations") != null; 15.24 + skipAnnotations = options.isSet("skipAnnotations"); 15.25 } 15.26 15.27 /** A queue for classes whose members still need to be entered into the 15.28 @@ -925,7 +927,7 @@ 15.29 tp.accept(new TypeAnnotate(baseEnv)); 15.30 tree.accept(new TypeAnnotate(env)); 15.31 15.32 - chk.checkNonCyclic(tree.pos(), c.type); 15.33 + chk.checkNonCyclicDecl(tree); 15.34 15.35 attr.attribTypeVariables(tree.typarams, baseEnv); 15.36 15.37 @@ -1087,7 +1089,7 @@ 15.38 15.39 15.40 private Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) { 15.41 - Scope baseScope = new Scope(tree.sym); 15.42 + Scope baseScope = new Scope.ClassScope(tree.sym, scopeCounter); 15.43 //import already entered local classes into base scope 15.44 for (Scope.Entry e = env.outer.info.scope.elems ; e != null ; e = e.sibling) { 15.45 if (e.sym.isLocal()) {
16.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Oct 07 15:12:31 2010 -0700 16.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Oct 12 12:52:49 2010 -0700 16.3 @@ -110,15 +110,17 @@ 16.4 boxingEnabled = source.allowBoxing(); 16.5 varargsEnabled = source.allowVarargs(); 16.6 Options options = Options.instance(context); 16.7 - debugResolve = options.get("debugresolve") != null; 16.8 - allowTransitionalJSR292 = options.get("allowTransitionalJSR292") != null; 16.9 + debugResolve = options.isSet("debugresolve"); 16.10 + allowTransitionalJSR292 = options.isSet("allowTransitionalJSR292"); 16.11 Target target = Target.instance(context); 16.12 allowMethodHandles = allowTransitionalJSR292 || 16.13 target.hasMethodHandles(); 16.14 allowInvokeDynamic = (allowTransitionalJSR292 || 16.15 target.hasInvokedynamic()) && 16.16 - options.get("invokedynamic") != null; 16.17 + options.isSet("invokedynamic"); 16.18 polymorphicSignatureScope = new Scope(syms.noSymbol); 16.19 + 16.20 + inapplicableMethodException = new InapplicableMethodException(diags); 16.21 } 16.22 16.23 /** error symbols, which are returned when resolution fails 16.24 @@ -318,7 +320,8 @@ 16.25 throws Infer.InferenceException { 16.26 boolean polymorphicSignature = (m.isPolymorphicSignatureGeneric() && allowMethodHandles) || 16.27 isTransitionalDynamicCallSite(site, m); 16.28 - if (useVarargs && (m.flags() & VARARGS) == 0) return null; 16.29 + if (useVarargs && (m.flags() & VARARGS) == 0) 16.30 + throw inapplicableMethodException.setMessage(null); 16.31 Type mt = types.memberType(site, m); 16.32 16.33 // tvars is the list of formal type variables for which type arguments 16.34 @@ -334,7 +337,7 @@ 16.35 } else if (mt.tag == FORALL && typeargtypes.nonEmpty()) { 16.36 ForAll pmt = (ForAll) mt; 16.37 if (typeargtypes.length() != pmt.tvars.length()) 16.38 - return null; 16.39 + throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args 16.40 // Check type arguments are within bounds 16.41 List<Type> formals = pmt.tvars; 16.42 List<Type> actuals = typeargtypes; 16.43 @@ -343,7 +346,7 @@ 16.44 pmt.tvars, typeargtypes); 16.45 for (; bounds.nonEmpty(); bounds = bounds.tail) 16.46 if (!types.isSubtypeUnchecked(actuals.head, bounds.head, warn)) 16.47 - return null; 16.48 + throw inapplicableMethodException.setMessage("explicit.param.do.not.conform.to.bounds",actuals.head, bounds); 16.49 formals = formals.tail; 16.50 actuals = actuals.tail; 16.51 } 16.52 @@ -375,11 +378,10 @@ 16.53 allowBoxing, 16.54 useVarargs, 16.55 warn); 16.56 - return 16.57 - argumentsAcceptable(argtypes, mt.getParameterTypes(), 16.58 - allowBoxing, useVarargs, warn) 16.59 - ? mt 16.60 - : null; 16.61 + 16.62 + checkRawArgumentsAcceptable(argtypes, mt.getParameterTypes(), 16.63 + allowBoxing, useVarargs, warn); 16.64 + return mt; 16.65 } 16.66 16.67 boolean isTransitionalDynamicCallSite(Type site, Symbol sym) { 16.68 @@ -403,7 +405,7 @@ 16.69 try { 16.70 return rawInstantiate(env, site, m, argtypes, typeargtypes, 16.71 allowBoxing, useVarargs, warn); 16.72 - } catch (Infer.InferenceException ex) { 16.73 + } catch (InapplicableMethodException ex) { 16.74 return null; 16.75 } 16.76 } 16.77 @@ -415,26 +417,76 @@ 16.78 boolean allowBoxing, 16.79 boolean useVarargs, 16.80 Warner warn) { 16.81 + try { 16.82 + checkRawArgumentsAcceptable(argtypes, formals, allowBoxing, useVarargs, warn); 16.83 + return true; 16.84 + } catch (InapplicableMethodException ex) { 16.85 + return false; 16.86 + } 16.87 + } 16.88 + void checkRawArgumentsAcceptable(List<Type> argtypes, 16.89 + List<Type> formals, 16.90 + boolean allowBoxing, 16.91 + boolean useVarargs, 16.92 + Warner warn) { 16.93 Type varargsFormal = useVarargs ? formals.last() : null; 16.94 + if (varargsFormal == null && 16.95 + argtypes.size() != formals.size()) { 16.96 + throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args 16.97 + } 16.98 + 16.99 while (argtypes.nonEmpty() && formals.head != varargsFormal) { 16.100 boolean works = allowBoxing 16.101 ? types.isConvertible(argtypes.head, formals.head, warn) 16.102 : types.isSubtypeUnchecked(argtypes.head, formals.head, warn); 16.103 - if (!works) return false; 16.104 + if (!works) 16.105 + throw inapplicableMethodException.setMessage("no.conforming.assignment.exists", 16.106 + argtypes.head, 16.107 + formals.head); 16.108 argtypes = argtypes.tail; 16.109 formals = formals.tail; 16.110 } 16.111 - if (formals.head != varargsFormal) return false; // not enough args 16.112 - if (!useVarargs) 16.113 - return argtypes.isEmpty(); 16.114 - Type elt = types.elemtype(varargsFormal); 16.115 - while (argtypes.nonEmpty()) { 16.116 - if (!types.isConvertible(argtypes.head, elt, warn)) 16.117 - return false; 16.118 - argtypes = argtypes.tail; 16.119 + 16.120 + if (formals.head != varargsFormal) 16.121 + throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args 16.122 + 16.123 + if (useVarargs) { 16.124 + Type elt = types.elemtype(varargsFormal); 16.125 + while (argtypes.nonEmpty()) { 16.126 + if (!types.isConvertible(argtypes.head, elt, warn)) 16.127 + throw inapplicableMethodException.setMessage("varargs.argument.mismatch", 16.128 + argtypes.head, 16.129 + elt); 16.130 + argtypes = argtypes.tail; 16.131 + } 16.132 } 16.133 - return true; 16.134 + return; 16.135 } 16.136 + // where 16.137 + public static class InapplicableMethodException extends RuntimeException { 16.138 + private static final long serialVersionUID = 0; 16.139 + 16.140 + JCDiagnostic diagnostic; 16.141 + JCDiagnostic.Factory diags; 16.142 + 16.143 + InapplicableMethodException(JCDiagnostic.Factory diags) { 16.144 + this.diagnostic = null; 16.145 + this.diags = diags; 16.146 + } 16.147 + InapplicableMethodException setMessage(String key) { 16.148 + this.diagnostic = key != null ? diags.fragment(key) : null; 16.149 + return this; 16.150 + } 16.151 + InapplicableMethodException setMessage(String key, Object... args) { 16.152 + this.diagnostic = key != null ? diags.fragment(key, args) : null; 16.153 + return this; 16.154 + } 16.155 + 16.156 + public JCDiagnostic getDiagnostic() { 16.157 + return diagnostic; 16.158 + } 16.159 + } 16.160 + private final InapplicableMethodException inapplicableMethodException; 16.161 16.162 /* *************************************************************************** 16.163 * Symbol lookup 16.164 @@ -595,6 +647,7 @@ 16.165 * @param allowBoxing Allow boxing conversions of arguments. 16.166 * @param useVarargs Box trailing arguments into an array for varargs. 16.167 */ 16.168 + @SuppressWarnings("fallthrough") 16.169 Symbol selectBest(Env<AttrContext> env, 16.170 Type site, 16.171 List<Type> argtypes, 16.172 @@ -608,21 +661,16 @@ 16.173 if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar; 16.174 assert sym.kind < AMBIGUOUS; 16.175 try { 16.176 - if (rawInstantiate(env, site, sym, argtypes, typeargtypes, 16.177 - allowBoxing, useVarargs, Warner.noWarnings) == null) { 16.178 - // inapplicable 16.179 - switch (bestSoFar.kind) { 16.180 - case ABSENT_MTH: return wrongMethod.setWrongSym(sym); 16.181 - case WRONG_MTH: return wrongMethods; 16.182 - default: return bestSoFar; 16.183 - } 16.184 - } 16.185 - } catch (Infer.InferenceException ex) { 16.186 + rawInstantiate(env, site, sym, argtypes, typeargtypes, 16.187 + allowBoxing, useVarargs, Warner.noWarnings); 16.188 + } catch (InapplicableMethodException ex) { 16.189 switch (bestSoFar.kind) { 16.190 case ABSENT_MTH: 16.191 return wrongMethod.setWrongSym(sym, ex.getDiagnostic()); 16.192 case WRONG_MTH: 16.193 - return wrongMethods; 16.194 + wrongMethods.addCandidate(currentStep, wrongMethod.sym, wrongMethod.explanation); 16.195 + case WRONG_MTHS: 16.196 + return wrongMethods.addCandidate(currentStep, sym, ex.getDiagnostic()); 16.197 default: 16.198 return bestSoFar; 16.199 } 16.200 @@ -631,7 +679,7 @@ 16.201 return (bestSoFar.kind == ABSENT_MTH) 16.202 ? new AccessError(env, site, sym) 16.203 : bestSoFar; 16.204 - } 16.205 + } 16.206 return (bestSoFar.kind > AMBIGUOUS) 16.207 ? sym 16.208 : mostSpecific(sym, bestSoFar, env, site, 16.209 @@ -1253,11 +1301,12 @@ 16.210 Name name, 16.211 List<Type> argtypes, 16.212 List<Type> typeargtypes) { 16.213 - Symbol sym = methodNotFound; 16.214 + Symbol sym = startResolution(); 16.215 List<MethodResolutionPhase> steps = methodResolutionSteps; 16.216 while (steps.nonEmpty() && 16.217 steps.head.isApplicable(boxingEnabled, varargsEnabled) && 16.218 sym.kind >= ERRONEOUS) { 16.219 + currentStep = steps.head; 16.220 sym = findFun(env, name, argtypes, typeargtypes, 16.221 steps.head.isBoxingRequired, 16.222 env.info.varArgs = steps.head.isVarargsRequired); 16.223 @@ -1274,6 +1323,12 @@ 16.224 return sym; 16.225 } 16.226 16.227 + private Symbol startResolution() { 16.228 + wrongMethod.clear(); 16.229 + wrongMethods.clear(); 16.230 + return methodNotFound; 16.231 + } 16.232 + 16.233 /** Resolve a qualified method identifier 16.234 * @param pos The position to use for error reporting. 16.235 * @param env The environment current at the method invocation. 16.236 @@ -1286,11 +1341,12 @@ 16.237 Symbol resolveQualifiedMethod(DiagnosticPosition pos, Env<AttrContext> env, 16.238 Type site, Name name, List<Type> argtypes, 16.239 List<Type> typeargtypes) { 16.240 - Symbol sym = methodNotFound; 16.241 + Symbol sym = startResolution(); 16.242 List<MethodResolutionPhase> steps = methodResolutionSteps; 16.243 while (steps.nonEmpty() && 16.244 steps.head.isApplicable(boxingEnabled, varargsEnabled) && 16.245 sym.kind >= ERRONEOUS) { 16.246 + currentStep = steps.head; 16.247 sym = findMethod(env, site, name, argtypes, typeargtypes, 16.248 steps.head.isBoxingRequired(), 16.249 env.info.varArgs = steps.head.isVarargsRequired(), false); 16.250 @@ -1404,11 +1460,12 @@ 16.251 Type site, 16.252 List<Type> argtypes, 16.253 List<Type> typeargtypes) { 16.254 - Symbol sym = methodNotFound; 16.255 + Symbol sym = startResolution(); 16.256 List<MethodResolutionPhase> steps = methodResolutionSteps; 16.257 while (steps.nonEmpty() && 16.258 steps.head.isApplicable(boxingEnabled, varargsEnabled) && 16.259 sym.kind >= ERRONEOUS) { 16.260 + currentStep = steps.head; 16.261 sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, 16.262 steps.head.isBoxingRequired(), 16.263 env.info.varArgs = steps.head.isVarargsRequired()); 16.264 @@ -1439,26 +1496,22 @@ 16.265 Type site, 16.266 List<Type> argtypes, 16.267 List<Type> typeargtypes) { 16.268 - Symbol sym = methodNotFound; 16.269 - JCDiagnostic explanation = null; 16.270 + Symbol sym = startResolution(); 16.271 List<MethodResolutionPhase> steps = methodResolutionSteps; 16.272 while (steps.nonEmpty() && 16.273 steps.head.isApplicable(boxingEnabled, varargsEnabled) && 16.274 sym.kind >= ERRONEOUS) { 16.275 + currentStep = steps.head; 16.276 sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, 16.277 steps.head.isBoxingRequired(), 16.278 env.info.varArgs = steps.head.isVarargsRequired()); 16.279 methodResolutionCache.put(steps.head, sym); 16.280 - if (sym.kind == WRONG_MTH && 16.281 - ((InapplicableSymbolError)sym).explanation != null) { 16.282 - //if the symbol is an inapplicable method symbol, then the 16.283 - //explanation contains the reason for which inference failed 16.284 - explanation = ((InapplicableSymbolError)sym).explanation; 16.285 - } 16.286 steps = steps.tail; 16.287 } 16.288 if (sym.kind >= AMBIGUOUS) { 16.289 - final JCDiagnostic details = explanation; 16.290 + final JCDiagnostic details = sym.kind == WRONG_MTH ? 16.291 + ((InapplicableSymbolError)sym).explanation : 16.292 + null; 16.293 Symbol errSym = new ResolveError(WRONG_MTH, "diamond error") { 16.294 @Override 16.295 JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) { 16.296 @@ -1860,7 +1913,8 @@ 16.297 */ 16.298 InapplicableSymbolError setWrongSym(Symbol sym, JCDiagnostic explanation) { 16.299 this.sym = sym; 16.300 - this.explanation = explanation; 16.301 + if (this.sym == sym && explanation != null) 16.302 + this.explanation = explanation; //update the details 16.303 return this; 16.304 } 16.305 16.306 @@ -1868,7 +1922,6 @@ 16.307 */ 16.308 InapplicableSymbolError setWrongSym(Symbol sym) { 16.309 this.sym = sym; 16.310 - this.explanation = null; 16.311 return this; 16.312 } 16.313 16.314 @@ -1905,6 +1958,10 @@ 16.315 } 16.316 } 16.317 16.318 + void clear() { 16.319 + explanation = null; 16.320 + } 16.321 + 16.322 @Override 16.323 public Symbol access(Name name, TypeSymbol location) { 16.324 return types.createErrorType(name, location, syms.errSymbol.type).tsym; 16.325 @@ -1917,6 +1974,9 @@ 16.326 * given an actual arguments/type argument list. 16.327 */ 16.328 class InapplicableSymbolsError extends ResolveError { 16.329 + 16.330 + private List<Candidate> candidates = List.nil(); 16.331 + 16.332 InapplicableSymbolsError(Symbol sym) { 16.333 super(WRONG_MTHS, "inapplicable symbols"); 16.334 } 16.335 @@ -1928,8 +1988,85 @@ 16.336 Name name, 16.337 List<Type> argtypes, 16.338 List<Type> typeargtypes) { 16.339 - return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos, 16.340 + if (candidates.nonEmpty()) { 16.341 + JCDiagnostic err = diags.create(dkind, 16.342 + log.currentSource(), 16.343 + pos, 16.344 + "cant.apply.symbols", 16.345 + name == names.init ? KindName.CONSTRUCTOR : absentKind(kind), 16.346 + getName(), 16.347 + argtypes); 16.348 + return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(site)); 16.349 + } else { 16.350 + return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos, 16.351 site, name, argtypes, typeargtypes); 16.352 + } 16.353 + } 16.354 + 16.355 + //where 16.356 + List<JCDiagnostic> candidateDetails(Type site) { 16.357 + List<JCDiagnostic> details = List.nil(); 16.358 + for (Candidate c : candidates) 16.359 + details = details.prepend(c.getDiagnostic(site)); 16.360 + return details.reverse(); 16.361 + } 16.362 + 16.363 + Symbol addCandidate(MethodResolutionPhase currentStep, Symbol sym, JCDiagnostic details) { 16.364 + Candidate c = new Candidate(currentStep, sym, details); 16.365 + if (c.isValid() && !candidates.contains(c)) 16.366 + candidates = candidates.append(c); 16.367 + return this; 16.368 + } 16.369 + 16.370 + void clear() { 16.371 + candidates = List.nil(); 16.372 + } 16.373 + 16.374 + private Name getName() { 16.375 + Symbol sym = candidates.head.sym; 16.376 + return sym.name == names.init ? 16.377 + sym.owner.name : 16.378 + sym.name; 16.379 + } 16.380 + 16.381 + private class Candidate { 16.382 + 16.383 + final MethodResolutionPhase step; 16.384 + final Symbol sym; 16.385 + final JCDiagnostic details; 16.386 + 16.387 + private Candidate(MethodResolutionPhase step, Symbol sym, JCDiagnostic details) { 16.388 + this.step = step; 16.389 + this.sym = sym; 16.390 + this.details = details; 16.391 + } 16.392 + 16.393 + JCDiagnostic getDiagnostic(Type site) { 16.394 + return diags.fragment("inapplicable.method", 16.395 + Kinds.kindName(sym), 16.396 + sym.location(site, types), 16.397 + sym.asMemberOf(site, types), 16.398 + details); 16.399 + } 16.400 + 16.401 + @Override 16.402 + public boolean equals(Object o) { 16.403 + if (o instanceof Candidate) { 16.404 + Symbol s1 = this.sym; 16.405 + Symbol s2 = ((Candidate)o).sym; 16.406 + if ((s1 != s2 && 16.407 + (s1.overrides(s2, s1.owner.type.tsym, types, false) || 16.408 + (s2.overrides(s1, s2.owner.type.tsym, types, false)))) || 16.409 + ((s1.isConstructor() || s2.isConstructor()) && s1.owner != s2.owner)) 16.410 + return true; 16.411 + } 16.412 + return false; 16.413 + } 16.414 + 16.415 + boolean isValid() { 16.416 + return (((sym.flags() & VARARGS) != 0 && step == VARARITY) || 16.417 + (sym.flags() & VARARGS) == 0 && step == (boxingEnabled ? BOX : BASIC)); 16.418 + } 16.419 } 16.420 } 16.421 16.422 @@ -2093,6 +2230,8 @@ 16.423 16.424 final List<MethodResolutionPhase> methodResolutionSteps = List.of(BASIC, BOX, VARARITY); 16.425 16.426 + private MethodResolutionPhase currentStep = null; 16.427 + 16.428 private MethodResolutionPhase firstErroneousResolutionPhase() { 16.429 MethodResolutionPhase bestSoFar = BASIC; 16.430 Symbol sym = methodNotFound;
17.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Thu Oct 07 15:12:31 2010 -0700 17.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Tue Oct 12 12:52:49 2010 -0700 17.3 @@ -1,5 +1,5 @@ 17.4 /* 17.5 - * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. 17.6 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 17.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.8 * 17.9 * This code is free software; you can redistribute it and/or modify it 17.10 @@ -150,8 +150,8 @@ 17.11 17.12 useZipFileIndex = System.getProperty("useJavaUtilZip") == null;// TODO: options.get("useJavaUtilZip") == null; 17.13 17.14 - mmappedIO = options.get("mmappedIO") != null; 17.15 - ignoreSymbolFile = options.get("ignore.symbol.file") != null; 17.16 + mmappedIO = options.isSet("mmappedIO"); 17.17 + ignoreSymbolFile = options.isSet("ignore.symbol.file"); 17.18 } 17.19 17.20 public JavaFileObject getFileForInput(String name) { 17.21 @@ -435,7 +435,7 @@ 17.22 zdir = new ZipFile(zipFileName); 17.23 } 17.24 else { 17.25 - usePreindexedCache = options.get("usezipindex") != null; 17.26 + usePreindexedCache = options.isSet("usezipindex"); 17.27 preindexCacheLocation = options.get("java.io.tmpdir"); 17.28 String optCacheLoc = options.get("cachezipindexdir"); 17.29 17.30 @@ -469,7 +469,7 @@ 17.31 null, 17.32 usePreindexedCache, 17.33 preindexCacheLocation, 17.34 - options.get("writezipindexfiles") != null)); 17.35 + options.isSet("writezipindexfiles"))); 17.36 } 17.37 } 17.38 else { 17.39 @@ -482,7 +482,7 @@ 17.40 symbolFilePrefix, 17.41 usePreindexedCache, 17.42 preindexCacheLocation, 17.43 - options.get("writezipindexfiles") != null)); 17.44 + options.isSet("writezipindexfiles"))); 17.45 } 17.46 } 17.47 } catch (FileNotFoundException ex) { 17.48 @@ -605,7 +605,7 @@ 17.49 nullCheck(className); 17.50 nullCheck(kind); 17.51 if (!sourceOrClass.contains(kind)) 17.52 - throw new IllegalArgumentException("Invalid kind " + kind); 17.53 + throw new IllegalArgumentException("Invalid kind: " + kind); 17.54 return getFileForInput(location, RelativeFile.forClass(className, kind)); 17.55 } 17.56 17.57 @@ -658,7 +658,7 @@ 17.58 nullCheck(className); 17.59 nullCheck(kind); 17.60 if (!sourceOrClass.contains(kind)) 17.61 - throw new IllegalArgumentException("Invalid kind " + kind); 17.62 + throw new IllegalArgumentException("Invalid kind: " + kind); 17.63 return getFileForOutput(location, RelativeFile.forClass(className, kind), sibling); 17.64 } 17.65 17.66 @@ -672,7 +672,7 @@ 17.67 // validatePackageName(packageName); 17.68 nullCheck(packageName); 17.69 if (!isRelativeUri(relativeName)) 17.70 - throw new IllegalArgumentException("relativeName is invalid"); 17.71 + throw new IllegalArgumentException("Invalid relative name: " + relativeName); 17.72 RelativeFile name = packageName.length() == 0 17.73 ? new RelativeFile(relativeName) 17.74 : new RelativeFile(RelativeDirectory.forPackage(packageName), relativeName); 17.75 @@ -806,6 +806,8 @@ 17.76 String path = uri.normalize().getPath(); 17.77 if (path.length() == 0 /* isEmpty() is mustang API */) 17.78 return false; 17.79 + if (!path.equals(uri.getPath())) // implicitly checks for embedded . and .. 17.80 + return false; 17.81 char first = path.charAt(0); 17.82 return first != '.' && first != '/'; 17.83 }
18.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Oct 07 15:12:31 2010 -0700 18.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Oct 12 12:52:49 2010 -0700 18.3 @@ -56,6 +56,8 @@ 18.4 import static com.sun.tools.javac.jvm.ClassFile.*; 18.5 import static com.sun.tools.javac.jvm.ClassFile.Version.*; 18.6 18.7 +import static com.sun.tools.javac.main.OptionName.*; 18.8 + 18.9 /** This class provides operations to read a classfile into an internal 18.10 * representation. The internal representation is anchored in a 18.11 * ClassSymbol which contains in its scope symbol representations 18.12 @@ -122,6 +124,9 @@ 18.13 /** The symbol table. */ 18.14 Symtab syms; 18.15 18.16 + /** The scope counter */ 18.17 + Scope.ScopeCounter scopeCounter; 18.18 + 18.19 Types types; 18.20 18.21 /** The name table. */ 18.22 @@ -244,6 +249,7 @@ 18.23 18.24 names = Names.instance(context); 18.25 syms = Symtab.instance(context); 18.26 + scopeCounter = Scope.ScopeCounter.instance(context); 18.27 types = Types.instance(context); 18.28 fileManager = context.get(JavaFileManager.class); 18.29 if (fileManager == null) 18.30 @@ -255,23 +261,23 @@ 18.31 18.32 Options options = Options.instance(context); 18.33 annotate = Annotate.instance(context); 18.34 - verbose = options.get("-verbose") != null; 18.35 - checkClassFile = options.get("-checkclassfile") != null; 18.36 + verbose = options.isSet(VERBOSE); 18.37 + checkClassFile = options.isSet("-checkclassfile"); 18.38 Source source = Source.instance(context); 18.39 allowGenerics = source.allowGenerics(); 18.40 allowVarargs = source.allowVarargs(); 18.41 allowAnnotations = source.allowAnnotations(); 18.42 - saveParameterNames = options.get("save-parameter-names") != null; 18.43 - cacheCompletionFailure = options.get("dev") == null; 18.44 + saveParameterNames = options.isSet("save-parameter-names"); 18.45 + cacheCompletionFailure = options.isUnset("dev"); 18.46 preferSource = "source".equals(options.get("-Xprefer")); 18.47 18.48 completionFailureName = 18.49 - (options.get("failcomplete") != null) 18.50 + options.isSet("failcomplete") 18.51 ? names.fromString(options.get("failcomplete")) 18.52 : null; 18.53 18.54 typevars = new Scope(syms.noSymbol); 18.55 - debugJSR308 = options.get("TA:reader") != null; 18.56 + debugJSR308 = options.isSet("TA:reader"); 18.57 18.58 initAttributeReaders(); 18.59 } 18.60 @@ -1984,7 +1990,7 @@ 18.61 ClassType ct = (ClassType)c.type; 18.62 18.63 // allocate scope for members 18.64 - c.members_field = new Scope(c); 18.65 + c.members_field = new Scope.ClassScope(c, scopeCounter); 18.66 18.67 // prepare type variable table 18.68 typevars = typevars.dup(currentOwner);
19.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Thu Oct 07 15:12:31 2010 -0700 19.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Oct 12 12:52:49 2010 -0700 19.3 @@ -45,8 +45,10 @@ 19.4 import static com.sun.tools.javac.code.Kinds.*; 19.5 import static com.sun.tools.javac.code.TypeTags.*; 19.6 import static com.sun.tools.javac.jvm.UninitializedType.*; 19.7 +import static com.sun.tools.javac.main.OptionName.*; 19.8 import static javax.tools.StandardLocation.CLASS_OUTPUT; 19.9 19.10 + 19.11 /** This class provides operations to map an internal symbol table graph 19.12 * rooted in a ClassSymbol into a classfile. 19.13 * 19.14 @@ -178,15 +180,16 @@ 19.15 types = Types.instance(context); 19.16 fileManager = context.get(JavaFileManager.class); 19.17 19.18 - debugJSR308 = options.get("TA:writer") != null; 19.19 - verbose = options.get("-verbose") != null; 19.20 - scramble = options.get("-scramble") != null; 19.21 - scrambleAll = options.get("-scrambleAll") != null; 19.22 - retrofit = options.get("-retrofit") != null; 19.23 - genCrt = options.get("-Xjcov") != null; 19.24 - debugstackmap = options.get("debugstackmap") != null; 19.25 + debugJSR308 = options.isSet("TA:writer"); 19.26 + verbose = options.isSet(VERBOSE); 19.27 + scramble = options.isSet("-scramble"); 19.28 + scrambleAll = options.isSet("-scrambleAll"); 19.29 + retrofit = options.isSet("-retrofit"); 19.30 + genCrt = options.isSet(XJCOV); 19.31 + debugstackmap = options.isSet("debugstackmap"); 19.32 19.33 - emitSourceFile = options.get("-g:")==null || options.get("-g:source")!=null; 19.34 + emitSourceFile = options.isUnset(G_CUSTOM) || 19.35 + options.isSet(G_CUSTOM, "source"); 19.36 19.37 String dumpModFlags = options.get("dumpmodifiers"); 19.38 dumpClassModifiers =
20.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Oct 07 15:12:31 2010 -0700 20.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Oct 12 12:52:49 2010 -0700 20.3 @@ -46,6 +46,7 @@ 20.4 import static com.sun.tools.javac.code.TypeTags.*; 20.5 import static com.sun.tools.javac.jvm.ByteCodes.*; 20.6 import static com.sun.tools.javac.jvm.CRTFlags.*; 20.7 +import static com.sun.tools.javac.main.OptionName.*; 20.8 20.9 /** This pass maps flat Java (i.e. without inner classes) to bytecodes. 20.10 * 20.11 @@ -113,19 +114,19 @@ 20.12 20.13 Options options = Options.instance(context); 20.14 lineDebugInfo = 20.15 - options.get("-g:") == null || 20.16 - options.get("-g:lines") != null; 20.17 + options.isUnset(G_CUSTOM) || 20.18 + options.isSet(G_CUSTOM, "lines"); 20.19 varDebugInfo = 20.20 - options.get("-g:") == null 20.21 - ? options.get("-g") != null 20.22 - : options.get("-g:vars") != null; 20.23 - genCrt = options.get("-Xjcov") != null; 20.24 - debugCode = options.get("debugcode") != null; 20.25 - allowInvokedynamic = target.hasInvokedynamic() || options.get("invokedynamic") != null; 20.26 + options.isUnset(G_CUSTOM) 20.27 + ? options.isSet(G) 20.28 + : options.isSet(G_CUSTOM, "vars"); 20.29 + genCrt = options.isSet(XJCOV); 20.30 + debugCode = options.isSet("debugcode"); 20.31 + allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic"); 20.32 20.33 generateIproxies = 20.34 target.requiresIproxy() || 20.35 - options.get("miranda") != null; 20.36 + options.isSet("miranda"); 20.37 20.38 if (target.generateStackMapTable()) { 20.39 // ignore cldc because we cannot have both stackmap formats
21.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Target.java Thu Oct 07 15:12:31 2010 -0700 21.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Target.java Tue Oct 12 12:52:49 2010 -0700 21.3 @@ -31,6 +31,8 @@ 21.4 import com.sun.tools.javac.code.Symbol; 21.5 import com.sun.tools.javac.util.*; 21.6 21.7 +import static com.sun.tools.javac.main.OptionName.*; 21.8 + 21.9 /** The classfile version target. 21.10 * 21.11 * <p><b>This is NOT part of any supported API. 21.12 @@ -73,7 +75,7 @@ 21.13 Target instance = context.get(targetKey); 21.14 if (instance == null) { 21.15 Options options = Options.instance(context); 21.16 - String targetString = options.get("-target"); 21.17 + String targetString = options.get(TARGET); 21.18 if (targetString != null) instance = lookup(targetString); 21.19 if (instance == null) instance = DEFAULT; 21.20 context.put(targetKey, instance);
22.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Thu Oct 07 15:12:31 2010 -0700 22.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Tue Oct 12 12:52:49 2010 -0700 22.3 @@ -1,5 +1,5 @@ 22.4 /* 22.5 - * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. 22.6 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 22.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.8 * 22.9 * This code is free software; you can redistribute it and/or modify it 22.10 @@ -26,48 +26,44 @@ 22.11 package com.sun.tools.javac.main; 22.12 22.13 import java.io.*; 22.14 +import java.util.HashMap; 22.15 import java.util.HashSet; 22.16 import java.util.LinkedHashSet; 22.17 import java.util.LinkedHashMap; 22.18 import java.util.Map; 22.19 import java.util.MissingResourceException; 22.20 +import java.util.Queue; 22.21 import java.util.ResourceBundle; 22.22 import java.util.Set; 22.23 import java.util.logging.Handler; 22.24 import java.util.logging.Level; 22.25 import java.util.logging.Logger; 22.26 22.27 +import javax.annotation.processing.Processor; 22.28 +import javax.lang.model.SourceVersion; 22.29 import javax.tools.JavaFileManager; 22.30 import javax.tools.JavaFileObject; 22.31 import javax.tools.DiagnosticListener; 22.32 22.33 -import com.sun.tools.javac.file.JavacFileManager; 22.34 import com.sun.source.util.TaskEvent; 22.35 import com.sun.source.util.TaskListener; 22.36 22.37 +import com.sun.tools.javac.file.JavacFileManager; 22.38 import com.sun.tools.javac.util.*; 22.39 import com.sun.tools.javac.code.*; 22.40 +import com.sun.tools.javac.code.Symbol.*; 22.41 import com.sun.tools.javac.tree.*; 22.42 +import com.sun.tools.javac.tree.JCTree.*; 22.43 import com.sun.tools.javac.parser.*; 22.44 import com.sun.tools.javac.comp.*; 22.45 import com.sun.tools.javac.jvm.*; 22.46 - 22.47 -import com.sun.tools.javac.code.Symbol.*; 22.48 -import com.sun.tools.javac.tree.JCTree.*; 22.49 - 22.50 import com.sun.tools.javac.processing.*; 22.51 -import javax.annotation.processing.Processor; 22.52 22.53 import static javax.tools.StandardLocation.CLASS_OUTPUT; 22.54 +import static com.sun.tools.javac.main.OptionName.*; 22.55 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*; 22.56 import static com.sun.tools.javac.util.ListBuffer.lb; 22.57 22.58 -// TEMP, until we have a more efficient way to save doc comment info 22.59 -import com.sun.tools.javac.parser.DocCommentScanner; 22.60 - 22.61 -import java.util.HashMap; 22.62 -import java.util.Queue; 22.63 -import javax.lang.model.SourceVersion; 22.64 22.65 /** This class could be the main entry point for GJC when GJC is used as a 22.66 * component in a larger software system. It provides operations to 22.67 @@ -359,22 +355,22 @@ 22.68 22.69 Options options = Options.instance(context); 22.70 22.71 - verbose = options.get("-verbose") != null; 22.72 - sourceOutput = options.get("-printsource") != null; // used to be -s 22.73 - stubOutput = options.get("-stubs") != null; 22.74 - relax = options.get("-relax") != null; 22.75 - printFlat = options.get("-printflat") != null; 22.76 - attrParseOnly = options.get("-attrparseonly") != null; 22.77 - encoding = options.get("-encoding"); 22.78 - lineDebugInfo = options.get("-g:") == null || 22.79 - options.get("-g:lines") != null; 22.80 - genEndPos = options.get("-Xjcov") != null || 22.81 + verbose = options.isSet(VERBOSE); 22.82 + sourceOutput = options.isSet(PRINTSOURCE); // used to be -s 22.83 + stubOutput = options.isSet("-stubs"); 22.84 + relax = options.isSet("-relax"); 22.85 + printFlat = options.isSet("-printflat"); 22.86 + attrParseOnly = options.isSet("-attrparseonly"); 22.87 + encoding = options.get(ENCODING); 22.88 + lineDebugInfo = options.isUnset(G_CUSTOM) || 22.89 + options.isSet(G_CUSTOM, "lines"); 22.90 + genEndPos = options.isSet(XJCOV) || 22.91 context.get(DiagnosticListener.class) != null; 22.92 - devVerbose = options.get("dev") != null; 22.93 - processPcks = options.get("process.packages") != null; 22.94 - werror = options.get("-Werror") != null; 22.95 + devVerbose = options.isSet("dev"); 22.96 + processPcks = options.isSet("process.packages"); 22.97 + werror = options.isSet(WERROR); 22.98 22.99 - verboseCompilePolicy = options.get("verboseCompilePolicy") != null; 22.100 + verboseCompilePolicy = options.isSet("verboseCompilePolicy"); 22.101 22.102 if (attrParseOnly) 22.103 compilePolicy = CompilePolicy.ATTR_ONLY; 22.104 @@ -384,15 +380,15 @@ 22.105 implicitSourcePolicy = ImplicitSourcePolicy.decode(options.get("-implicit")); 22.106 22.107 completionFailureName = 22.108 - (options.get("failcomplete") != null) 22.109 + options.isSet("failcomplete") 22.110 ? names.fromString(options.get("failcomplete")) 22.111 : null; 22.112 22.113 shouldStopPolicy = 22.114 - (options.get("shouldStopPolicy") != null) 22.115 + options.isSet("shouldStopPolicy") 22.116 ? CompileState.valueOf(options.get("shouldStopPolicy")) 22.117 : null; 22.118 - if (options.get("oldDiags") == null) 22.119 + if (options.isUnset("oldDiags")) 22.120 log.setDiagnosticFormatter(RichDiagnosticFormatter.instance(context)); 22.121 } 22.122 22.123 @@ -957,18 +953,17 @@ 22.124 // Process annotations if processing is not disabled and there 22.125 // is at least one Processor available. 22.126 Options options = Options.instance(context); 22.127 - if (options.get("-proc:none") != null) { 22.128 + if (options.isSet(PROC, "none")) { 22.129 processAnnotations = false; 22.130 } else if (procEnvImpl == null) { 22.131 procEnvImpl = new JavacProcessingEnvironment(context, processors); 22.132 processAnnotations = procEnvImpl.atLeastOneProcessor(); 22.133 22.134 if (processAnnotations) { 22.135 - if (context.get(Scanner.Factory.scannerFactoryKey) == null) 22.136 - DocCommentScanner.Factory.preRegister(context); 22.137 options.put("save-parameter-names", "save-parameter-names"); 22.138 reader.saveParameterNames = true; 22.139 keepComments = true; 22.140 + genEndPos = true; 22.141 if (taskListener != null) 22.142 taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING)); 22.143 log.deferDiagnostics = true; 22.144 @@ -1017,7 +1012,7 @@ 22.145 // annotation processing is to occur with compilation, 22.146 // emit a warning. 22.147 Options options = Options.instance(context); 22.148 - if (options.get("-proc:only") != null) { 22.149 + if (options.isSet(PROC, "only")) { 22.150 log.warning("proc.proc-only.requested.no.procs"); 22.151 todo.clear(); 22.152 } 22.153 @@ -1105,10 +1100,10 @@ 22.154 Options options = Options.instance(context); 22.155 return 22.156 explicitAnnotationProcessingRequested || 22.157 - options.get("-processor") != null || 22.158 - options.get("-processorpath") != null || 22.159 - options.get("-proc:only") != null || 22.160 - options.get("-Xprint") != null; 22.161 + options.isSet(PROCESSOR) || 22.162 + options.isSet(PROCESSORPATH) || 22.163 + options.isSet(PROC, "only") || 22.164 + options.isSet(XPRINT); 22.165 } 22.166 22.167 /** 22.168 @@ -1587,6 +1582,7 @@ 22.169 } 22.170 22.171 public void initRound(JavaCompiler prev) { 22.172 + genEndPos = prev.genEndPos; 22.173 keepComments = prev.keepComments; 22.174 start_msec = prev.start_msec; 22.175 hasBeenUsed = true;
23.1 --- a/src/share/classes/com/sun/tools/javac/main/Main.java Thu Oct 07 15:12:31 2010 -0700 23.2 +++ b/src/share/classes/com/sun/tools/javac/main/Main.java Tue Oct 12 12:52:49 2010 -0700 23.3 @@ -32,6 +32,9 @@ 23.4 import java.security.DigestInputStream; 23.5 import java.security.MessageDigest; 23.6 import java.util.MissingResourceException; 23.7 +import javax.tools.JavaFileManager; 23.8 +import javax.tools.JavaFileObject; 23.9 +import javax.annotation.processing.Processor; 23.10 23.11 import com.sun.tools.javac.code.Source; 23.12 import com.sun.tools.javac.file.CacheFSInfo; 23.13 @@ -41,9 +44,8 @@ 23.14 import com.sun.tools.javac.main.RecognizedOptions.OptionHelper; 23.15 import com.sun.tools.javac.util.*; 23.16 import com.sun.tools.javac.processing.AnnotationProcessingError; 23.17 -import javax.tools.JavaFileManager; 23.18 -import javax.tools.JavaFileObject; 23.19 -import javax.annotation.processing.Processor; 23.20 + 23.21 +import static com.sun.tools.javac.main.OptionName.*; 23.22 23.23 /** This class provides a commandline interface to the GJC compiler. 23.24 * 23.25 @@ -239,16 +241,16 @@ 23.26 } 23.27 } 23.28 23.29 - if (!checkDirectory("-d")) 23.30 + if (!checkDirectory(D)) 23.31 return null; 23.32 - if (!checkDirectory("-s")) 23.33 + if (!checkDirectory(S)) 23.34 return null; 23.35 23.36 - String sourceString = options.get("-source"); 23.37 + String sourceString = options.get(SOURCE); 23.38 Source source = (sourceString != null) 23.39 ? Source.lookup(sourceString) 23.40 : Source.DEFAULT; 23.41 - String targetString = options.get("-target"); 23.42 + String targetString = options.get(TARGET); 23.43 Target target = (targetString != null) 23.44 ? Target.lookup(targetString) 23.45 : Target.DEFAULT; 23.46 @@ -285,7 +287,7 @@ 23.47 // phase this out with JSR 292 PFD 23.48 if ("no".equals(options.get("allowTransitionalJSR292"))) { 23.49 options.put("allowTransitionalJSR292", null); 23.50 - } else if (target.hasInvokedynamic() && options.get("allowTransitionalJSR292") == null) { 23.51 + } else if (target.hasInvokedynamic() && options.isUnset("allowTransitionalJSR292")) { 23.52 options.put("allowTransitionalJSR292", "allowTransitionalJSR292"); 23.53 } 23.54 23.55 @@ -300,7 +302,7 @@ 23.56 return filenames.toList(); 23.57 } 23.58 // where 23.59 - private boolean checkDirectory(String optName) { 23.60 + private boolean checkDirectory(OptionName optName) { 23.61 String value = options.get(optName); 23.62 if (value == null) 23.63 return true; 23.64 @@ -367,10 +369,10 @@ 23.65 return EXIT_CMDERR; 23.66 } else if (files.isEmpty() && fileObjects.isEmpty() && classnames.isEmpty()) { 23.67 // it is allowed to compile nothing if just asking for help or version info 23.68 - if (options.get("-help") != null 23.69 - || options.get("-X") != null 23.70 - || options.get("-version") != null 23.71 - || options.get("-fullversion") != null) 23.72 + if (options.isSet(HELP) 23.73 + || options.isSet(X) 23.74 + || options.isSet(VERSION) 23.75 + || options.isSet(FULLVERSION)) 23.76 return EXIT_OK; 23.77 error("err.no.source.files"); 23.78 return EXIT_CMDERR; 23.79 @@ -382,7 +384,7 @@ 23.80 return EXIT_SYSERR; 23.81 } 23.82 23.83 - boolean forceStdOut = options.get("stdout") != null; 23.84 + boolean forceStdOut = options.isSet("stdout"); 23.85 if (forceStdOut) { 23.86 out.flush(); 23.87 out = new PrintWriter(System.out, true); 23.88 @@ -391,7 +393,7 @@ 23.89 context.put(Log.outKey, out); 23.90 23.91 // allow System property in following line as a Mustang legacy 23.92 - boolean batchMode = (options.get("nonBatchMode") == null 23.93 + boolean batchMode = (options.isUnset("nonBatchMode") 23.94 && System.getProperty("nonBatchMode") == null); 23.95 if (batchMode) 23.96 CacheFSInfo.preRegister(context); 23.97 @@ -455,7 +457,7 @@ 23.98 // for buggy compiler error recovery by swallowing thrown 23.99 // exceptions. 23.100 if (comp == null || comp.errorCount() == 0 || 23.101 - options == null || options.get("dev") != null) 23.102 + options == null || options.isSet("dev")) 23.103 bugMessage(ex); 23.104 return EXIT_ABNORMAL; 23.105 } finally { 23.106 @@ -478,7 +480,7 @@ 23.107 */ 23.108 void feMessage(Throwable ex) { 23.109 Log.printLines(out, ex.getMessage()); 23.110 - if (ex.getCause() != null && options.get("dev") != null) { 23.111 + if (ex.getCause() != null && options.isSet("dev")) { 23.112 ex.getCause().printStackTrace(out); 23.113 } 23.114 }
24.1 --- a/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Thu Oct 07 15:12:31 2010 -0700 24.2 +++ b/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Tue Oct 12 12:52:49 2010 -0700 24.3 @@ -366,11 +366,11 @@ 24.4 // } 24.5 // } 24.6 int maxDepth = (recurse ? Integer.MAX_VALUE : 1); 24.7 - Set<FileVisitOption> opts = EnumSet.of(DETECT_CYCLES, FOLLOW_LINKS); 24.8 + Set<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS); 24.9 Files.walkFileTree(packageDir, opts, maxDepth, 24.10 new SimpleFileVisitor<Path>() { 24.11 @Override 24.12 - public FileVisitResult preVisitDirectory(Path dir) { 24.13 + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { 24.14 if (SourceVersion.isIdentifier(dir.getName().toString())) // JSR 292? 24.15 return FileVisitResult.CONTINUE; 24.16 else
25.1 --- a/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java Thu Oct 07 15:12:31 2010 -0700 25.2 +++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java Tue Oct 12 12:52:49 2010 -0700 25.3 @@ -1,5 +1,5 @@ 25.4 /* 25.5 - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. 25.6 + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 25.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.8 * 25.9 * This code is free software; you can redistribute it and/or modify it 25.10 @@ -42,50 +42,17 @@ 25.11 */ 25.12 public class DocCommentScanner extends Scanner { 25.13 25.14 - /** A factory for creating scanners. */ 25.15 - public static class Factory extends Scanner.Factory { 25.16 - 25.17 - public static void preRegister(final Context context) { 25.18 - context.put(scannerFactoryKey, new Context.Factory<Scanner.Factory>() { 25.19 - public Factory make() { 25.20 - return new Factory(context); 25.21 - } 25.22 - }); 25.23 - } 25.24 - 25.25 - /** Create a new scanner factory. */ 25.26 - protected Factory(Context context) { 25.27 - super(context); 25.28 - } 25.29 - 25.30 - @Override 25.31 - public Scanner newScanner(CharSequence input) { 25.32 - if (input instanceof CharBuffer) { 25.33 - return new DocCommentScanner(this, (CharBuffer)input); 25.34 - } else { 25.35 - char[] array = input.toString().toCharArray(); 25.36 - return newScanner(array, array.length); 25.37 - } 25.38 - } 25.39 - 25.40 - @Override 25.41 - public Scanner newScanner(char[] input, int inputLength) { 25.42 - return new DocCommentScanner(this, input, inputLength); 25.43 - } 25.44 - } 25.45 - 25.46 - 25.47 /** Create a scanner from the input buffer. buffer must implement 25.48 * array() and compact(), and remaining() must be less than limit(). 25.49 */ 25.50 - protected DocCommentScanner(Factory fac, CharBuffer buffer) { 25.51 + protected DocCommentScanner(ScannerFactory fac, CharBuffer buffer) { 25.52 super(fac, buffer); 25.53 } 25.54 25.55 /** Create a scanner from the input array. The array must have at 25.56 * least a single character of extra space. 25.57 */ 25.58 - protected DocCommentScanner(Factory fac, char[] input, int inputLength) { 25.59 + protected DocCommentScanner(ScannerFactory fac, char[] input, int inputLength) { 25.60 super(fac, input, inputLength); 25.61 } 25.62
26.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu Oct 07 15:12:31 2010 -0700 26.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Oct 12 12:52:49 2010 -0700 26.3 @@ -1,5 +1,5 @@ 26.4 /* 26.5 - * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. 26.6 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 26.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 26.8 * 26.9 * This code is free software; you can redistribute it and/or modify it 26.10 @@ -2473,6 +2473,11 @@ 26.11 defs.append(importDeclaration()); 26.12 } else { 26.13 JCTree def = typeDeclaration(mods); 26.14 + if (keepDocComments && dc != null && docComments.get(def) == dc) { 26.15 + // If the first type declaration has consumed the first doc 26.16 + // comment, then don't use it for the top level comment as well. 26.17 + dc = null; 26.18 + } 26.19 if (def instanceof JCExpressionStatement) 26.20 def = ((JCExpressionStatement)def).expr; 26.21 defs.append(def);
27.1 --- a/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java Thu Oct 07 15:12:31 2010 -0700 27.2 +++ b/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java Tue Oct 12 12:52:49 2010 -0700 27.3 @@ -1,5 +1,5 @@ 27.4 /* 27.5 - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 27.6 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 27.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 27.8 * 27.9 * This code is free software; you can redistribute it and/or modify it 27.10 @@ -59,7 +59,7 @@ 27.11 final Source source; 27.12 final Names names; 27.13 final Options options; 27.14 - final Scanner.Factory scannerFactory; 27.15 + final ScannerFactory scannerFactory; 27.16 27.17 protected ParserFactory(Context context) { 27.18 super(); 27.19 @@ -70,11 +70,11 @@ 27.20 this.keywords = Keywords.instance(context); 27.21 this.source = Source.instance(context); 27.22 this.options = Options.instance(context); 27.23 - this.scannerFactory = Scanner.Factory.instance(context); 27.24 + this.scannerFactory = ScannerFactory.instance(context); 27.25 } 27.26 27.27 public Parser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) { 27.28 - Lexer lexer = scannerFactory.newScanner(input); 27.29 + Lexer lexer = scannerFactory.newScanner(input, keepDocComments); 27.30 if (keepEndPos) { 27.31 return new EndPosParser(this, lexer, keepDocComments, keepLineMap); 27.32 } else {
28.1 --- a/src/share/classes/com/sun/tools/javac/parser/Scanner.java Thu Oct 07 15:12:31 2010 -0700 28.2 +++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java Tue Oct 12 12:52:49 2010 -0700 28.3 @@ -1,5 +1,5 @@ 28.4 /* 28.5 - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 28.6 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 28.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 28.8 * 28.9 * This code is free software; you can redistribute it and/or modify it 28.10 @@ -47,48 +47,6 @@ 28.11 28.12 private static boolean scannerDebug = false; 28.13 28.14 - /** A factory for creating scanners. */ 28.15 - public static class Factory { 28.16 - /** The context key for the scanner factory. */ 28.17 - public static final Context.Key<Scanner.Factory> scannerFactoryKey = 28.18 - new Context.Key<Scanner.Factory>(); 28.19 - 28.20 - /** Get the Factory instance for this context. */ 28.21 - public static Factory instance(Context context) { 28.22 - Factory instance = context.get(scannerFactoryKey); 28.23 - if (instance == null) 28.24 - instance = new Factory(context); 28.25 - return instance; 28.26 - } 28.27 - 28.28 - final Log log; 28.29 - final Names names; 28.30 - final Source source; 28.31 - final Keywords keywords; 28.32 - 28.33 - /** Create a new scanner factory. */ 28.34 - protected Factory(Context context) { 28.35 - context.put(scannerFactoryKey, this); 28.36 - this.log = Log.instance(context); 28.37 - this.names = Names.instance(context); 28.38 - this.source = Source.instance(context); 28.39 - this.keywords = Keywords.instance(context); 28.40 - } 28.41 - 28.42 - public Scanner newScanner(CharSequence input) { 28.43 - if (input instanceof CharBuffer) { 28.44 - return new Scanner(this, (CharBuffer)input); 28.45 - } else { 28.46 - char[] array = input.toString().toCharArray(); 28.47 - return newScanner(array, array.length); 28.48 - } 28.49 - } 28.50 - 28.51 - public Scanner newScanner(char[] input, int inputLength) { 28.52 - return new Scanner(this, input, inputLength); 28.53 - } 28.54 - } 28.55 - 28.56 /* Output variables; set by nextToken(): 28.57 */ 28.58 28.59 @@ -177,7 +135,7 @@ 28.60 private final Keywords keywords; 28.61 28.62 /** Common code for constructors. */ 28.63 - private Scanner(Factory fac) { 28.64 + private Scanner(ScannerFactory fac) { 28.65 log = fac.log; 28.66 names = fac.names; 28.67 keywords = fac.keywords; 28.68 @@ -201,7 +159,7 @@ 28.69 /** Create a scanner from the input buffer. buffer must implement 28.70 * array() and compact(), and remaining() must be less than limit(). 28.71 */ 28.72 - protected Scanner(Factory fac, CharBuffer buffer) { 28.73 + protected Scanner(ScannerFactory fac, CharBuffer buffer) { 28.74 this(fac, JavacFileManager.toArray(buffer), buffer.limit()); 28.75 } 28.76 28.77 @@ -216,7 +174,7 @@ 28.78 * @param inputLength the size of the input. 28.79 * Must be positive and less than or equal to input.length. 28.80 */ 28.81 - protected Scanner(Factory fac, char[] input, int inputLength) { 28.82 + protected Scanner(ScannerFactory fac, char[] input, int inputLength) { 28.83 this(fac); 28.84 eofPos = inputLength; 28.85 if (inputLength == input.length) {
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/src/share/classes/com/sun/tools/javac/parser/ScannerFactory.java Tue Oct 12 12:52:49 2010 -0700 29.3 @@ -0,0 +1,90 @@ 29.4 +/* 29.5 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.7 + * 29.8 + * This code is free software; you can redistribute it and/or modify it 29.9 + * under the terms of the GNU General Public License version 2 only, as 29.10 + * published by the Free Software Foundation. Oracle designates this 29.11 + * particular file as subject to the "Classpath" exception as provided 29.12 + * by Oracle in the LICENSE file that accompanied this code. 29.13 + * 29.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 29.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 29.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 29.17 + * version 2 for more details (a copy is included in the LICENSE file that 29.18 + * accompanied this code). 29.19 + * 29.20 + * You should have received a copy of the GNU General Public License version 29.21 + * 2 along with this work; if not, write to the Free Software Foundation, 29.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 29.23 + * 29.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 29.25 + * or visit www.oracle.com if you need additional information or have any 29.26 + * questions. 29.27 + */ 29.28 + 29.29 +package com.sun.tools.javac.parser; 29.30 + 29.31 +import java.nio.CharBuffer; 29.32 + 29.33 +import com.sun.tools.javac.code.Source; 29.34 +import com.sun.tools.javac.util.Context; 29.35 +import com.sun.tools.javac.util.Log; 29.36 +import com.sun.tools.javac.util.Names; 29.37 + 29.38 + 29.39 +/** 29.40 + * A factory for creating scanners. 29.41 + * 29.42 + * <p><b>This is NOT part of any supported API. 29.43 + * If you write code that depends on this, you do so at your own 29.44 + * risk. This code and its internal interfaces are subject to change 29.45 + * or deletion without notice.</b> 29.46 + */ 29.47 +public class ScannerFactory { 29.48 + /** The context key for the scanner factory. */ 29.49 + public static final Context.Key<ScannerFactory> scannerFactoryKey = 29.50 + new Context.Key<ScannerFactory>(); 29.51 + 29.52 + /** Get the Factory instance for this context. */ 29.53 + public static ScannerFactory instance(Context context) { 29.54 + ScannerFactory instance = context.get(scannerFactoryKey); 29.55 + if (instance == null) 29.56 + instance = new ScannerFactory(context); 29.57 + return instance; 29.58 + } 29.59 + 29.60 + final Log log; 29.61 + final Names names; 29.62 + final Source source; 29.63 + final Keywords keywords; 29.64 + 29.65 + /** Create a new scanner factory. */ 29.66 + protected ScannerFactory(Context context) { 29.67 + context.put(scannerFactoryKey, this); 29.68 + this.log = Log.instance(context); 29.69 + this.names = Names.instance(context); 29.70 + this.source = Source.instance(context); 29.71 + this.keywords = Keywords.instance(context); 29.72 + } 29.73 + 29.74 + public Scanner newScanner(CharSequence input, boolean keepDocComments) { 29.75 + if (input instanceof CharBuffer) { 29.76 + CharBuffer buf = (CharBuffer) input; 29.77 + if (keepDocComments) 29.78 + return new DocCommentScanner(this, buf); 29.79 + else 29.80 + return new Scanner(this, buf); 29.81 + } else { 29.82 + char[] array = input.toString().toCharArray(); 29.83 + return newScanner(array, array.length, keepDocComments); 29.84 + } 29.85 + } 29.86 + 29.87 + public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) { 29.88 + if (keepDocComments) 29.89 + return new DocCommentScanner(this, input, inputLength); 29.90 + else 29.91 + return new Scanner(this, input, inputLength); 29.92 + } 29.93 +}
30.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java Thu Oct 07 15:12:31 2010 -0700 30.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java Tue Oct 12 12:52:49 2010 -0700 30.3 @@ -25,14 +25,6 @@ 30.4 30.5 package com.sun.tools.javac.processing; 30.6 30.7 -import com.sun.tools.javac.util.*; 30.8 -import javax.annotation.processing.*; 30.9 -import javax.lang.model.SourceVersion; 30.10 -import javax.lang.model.element.NestingKind; 30.11 -import javax.lang.model.element.Modifier; 30.12 -import javax.lang.model.element.Element; 30.13 -import java.util.*; 30.14 - 30.15 import java.io.Closeable; 30.16 import java.io.FileNotFoundException; 30.17 import java.io.InputStream; 30.18 @@ -43,14 +35,26 @@ 30.19 import java.io.FilterWriter; 30.20 import java.io.PrintWriter; 30.21 import java.io.IOException; 30.22 +import java.util.*; 30.23 30.24 -import javax.tools.*; 30.25 import static java.util.Collections.*; 30.26 30.27 +import javax.annotation.processing.*; 30.28 +import javax.lang.model.SourceVersion; 30.29 +import javax.lang.model.element.NestingKind; 30.30 +import javax.lang.model.element.Modifier; 30.31 +import javax.lang.model.element.Element; 30.32 +import javax.tools.*; 30.33 import javax.tools.JavaFileManager.Location; 30.34 + 30.35 import static javax.tools.StandardLocation.SOURCE_OUTPUT; 30.36 import static javax.tools.StandardLocation.CLASS_OUTPUT; 30.37 30.38 +import com.sun.tools.javac.code.Lint; 30.39 +import com.sun.tools.javac.util.*; 30.40 + 30.41 +import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING; 30.42 + 30.43 /** 30.44 * The FilerImplementation class must maintain a number of 30.45 * constraints. First, multiple attempts to open the same path within 30.46 @@ -366,7 +370,7 @@ 30.47 aggregateGeneratedSourceNames = new LinkedHashSet<String>(); 30.48 aggregateGeneratedClassNames = new LinkedHashSet<String>(); 30.49 30.50 - lint = (Options.instance(context)).lint("processing"); 30.51 + lint = (Lint.instance(context)).isEnabled(PROCESSING); 30.52 } 30.53 30.54 public JavaFileObject createSourceFile(CharSequence name,
31.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Thu Oct 07 15:12:31 2010 -0700 31.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Oct 12 12:52:49 2010 -0700 31.3 @@ -1,5 +1,5 @@ 31.4 /* 31.5 - * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. 31.6 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 31.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.8 * 31.9 * This code is free software; you can redistribute it and/or modify it 31.10 @@ -49,6 +49,7 @@ 31.11 import javax.tools.JavaFileObject; 31.12 import javax.tools.DiagnosticListener; 31.13 31.14 +import com.sun.tools.javac.api.JavacTrees; 31.15 import com.sun.source.util.AbstractTypeProcessor; 31.16 import com.sun.source.util.TaskEvent; 31.17 import com.sun.source.util.TaskListener; 31.18 @@ -78,6 +79,8 @@ 31.19 31.20 import static javax.tools.StandardLocation.*; 31.21 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*; 31.22 +import static com.sun.tools.javac.main.OptionName.*; 31.23 +import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING; 31.24 31.25 /** 31.26 * Objects of this class hold and manage the state needed to support 31.27 @@ -159,15 +162,14 @@ 31.28 source = Source.instance(context); 31.29 diags = JCDiagnostic.Factory.instance(context); 31.30 options = Options.instance(context); 31.31 - printProcessorInfo = options.get("-XprintProcessorInfo") != null; 31.32 - printRounds = options.get("-XprintRounds") != null; 31.33 - verbose = options.get("-verbose") != null; 31.34 - lint = options.lint("processing"); 31.35 - procOnly = options.get("-proc:only") != null || 31.36 - options.get("-Xprint") != null; 31.37 - fatalErrors = options.get("fatalEnterError") != null; 31.38 - showResolveErrors = options.get("showResolveErrors") != null; 31.39 - werror = options.get("-Werror") != null; 31.40 + printProcessorInfo = options.isSet(XPRINTPROCESSORINFO); 31.41 + printRounds = options.isSet(XPRINTROUNDS); 31.42 + verbose = options.isSet(VERBOSE); 31.43 + lint = Lint.instance(context).isEnabled(PROCESSING); 31.44 + procOnly = options.isSet(PROC, "only") || options.isSet(XPRINT); 31.45 + fatalErrors = options.isSet("fatalEnterError"); 31.46 + showResolveErrors = options.isSet("showResolveErrors"); 31.47 + werror = options.isSet(WERROR); 31.48 platformAnnotations = initPlatformAnnotations(); 31.49 foundTypeProcessors = false; 31.50 31.51 @@ -199,7 +201,7 @@ 31.52 Log log = Log.instance(context); 31.53 Iterator<? extends Processor> processorIterator; 31.54 31.55 - if (options.get("-Xprint") != null) { 31.56 + if (options.isSet(XPRINT)) { 31.57 try { 31.58 Processor processor = PrintingProcessor.class.newInstance(); 31.59 processorIterator = List.of(processor).iterator(); 31.60 @@ -212,7 +214,7 @@ 31.61 } else if (processors != null) { 31.62 processorIterator = processors.iterator(); 31.63 } else { 31.64 - String processorNames = options.get("-processor"); 31.65 + String processorNames = options.get(PROCESSOR); 31.66 JavaFileManager fileManager = context.get(JavaFileManager.class); 31.67 try { 31.68 // If processorpath is not explicitly set, use the classpath. 31.69 @@ -263,7 +265,7 @@ 31.70 ? standardFileManager.getLocation(ANNOTATION_PROCESSOR_PATH) 31.71 : standardFileManager.getLocation(CLASS_PATH); 31.72 31.73 - if (needClassLoader(options.get("-processor"), workingPath) ) 31.74 + if (needClassLoader(options.get(PROCESSOR), workingPath) ) 31.75 handleException(key, e); 31.76 31.77 } else { 31.78 @@ -744,7 +746,7 @@ 31.79 psi.runContributingProcs(renv); 31.80 31.81 // Debugging 31.82 - if (options.get("displayFilerState") != null) 31.83 + if (options.isSet("displayFilerState")) 31.84 filer.displayState(); 31.85 } 31.86 31.87 @@ -1104,6 +1106,12 @@ 31.88 task.updateContext(next); 31.89 } 31.90 31.91 + JavacTrees trees = context.get(JavacTrees.class); 31.92 + if (trees != null) { 31.93 + next.put(JavacTrees.class, trees); 31.94 + trees.updateContext(next); 31.95 + } 31.96 + 31.97 context.clear(); 31.98 return next; 31.99 }
32.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Oct 07 15:12:31 2010 -0700 32.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Oct 12 12:52:49 2010 -0700 32.3 @@ -93,6 +93,8 @@ 32.4 required: {2}\n\ 32.5 found: {3}\n\ 32.6 reason: {6} 32.7 +compiler.err.cant.apply.symbols=\ 32.8 + no suitable {0} found for {1}({2}) 32.9 compiler.err.cant.assign.val.to.final.var=\ 32.10 cannot assign a value to final variable {0} 32.11 compiler.err.cant.deref=\ 32.12 @@ -1075,11 +1077,11 @@ 32.13 no unique maximal instance exists for type variable {0} with upper bounds {1} 32.14 compiler.misc.no.unique.minimal.instance.exists=\ 32.15 no unique minimal instance exists for type variable {0} with lower bounds {1} 32.16 -compiler.misc.no.conforming.instance.exists=\ 32.17 +compiler.misc.infer.no.conforming.instance.exists=\ 32.18 no instance(s) of type variable(s) {0} exist so that {1} conforms to {2} 32.19 -compiler.misc.no.conforming.assignment.exists=\ 32.20 +compiler.misc.infer.no.conforming.assignment.exists=\ 32.21 no instance(s) of type variable(s) {0} exist so that argument type {1} conforms to formal parameter type {2} 32.22 -compiler.misc.arg.length.mismatch=\ 32.23 +compiler.misc.infer.arg.length.mismatch=\ 32.24 cannot instantiate from arguments because actual and formal argument lists differ in length 32.25 compiler.misc.inferred.do.not.conform.to.bounds=\ 32.26 inferred type does not conform to declared bound(s)\n\ 32.27 @@ -1095,6 +1097,16 @@ 32.28 type argument {0} inferred for {1} is not allowed in this context 32.29 compiler.misc.diamond.invalid.args=\ 32.30 type arguments {0} inferred for {1} are not allowed in this context 32.31 + 32.32 +compiler.misc.explicit.param.do.not.conform.to.bounds=\ 32.33 + explicit type argument {0} does not conform to declared bound(s) {1} 32.34 + 32.35 +compiler.misc.arg.length.mismatch=\ 32.36 + actual and formal argument lists differ in length 32.37 +compiler.misc.no.conforming.assignment.exists=\ 32.38 + actual argument {0} cannot be converted to {1} by method invocation conversion 32.39 +compiler.misc.varargs.argument.mismatch=\ 32.40 + argument type {0} does not conform to vararg element type {1} 32.41 ##### 32.42 32.43 ## The first argument ({0}) is a "kindname". 32.44 @@ -1232,6 +1244,10 @@ 32.45 compiler.misc.non.denotable.type=\ 32.46 Non-denotable type {0} not allowed here 32.47 32.48 +compiler.misc.inapplicable.method=\ 32.49 + {0} {1}.{2} is not applicable\n\ 32.50 + ({3}) 32.51 + 32.52 ######################################## 32.53 # Diagnostics for language feature changes 32.54 ########################################
33.1 --- a/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java Thu Oct 07 15:12:31 2010 -0700 33.2 +++ b/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java Tue Oct 12 12:52:49 2010 -0700 33.3 @@ -65,8 +65,6 @@ 33.4 */ 33.5 public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter { 33.6 33.7 - protected int currentIndentation = 0; 33.8 - 33.9 /** 33.10 * Create a basic formatter based on the supplied options. 33.11 * 33.12 @@ -107,33 +105,28 @@ 33.13 } 33.14 33.15 public String formatMessage(JCDiagnostic d, Locale l) { 33.16 - int prevIndentation = currentIndentation; 33.17 - try { 33.18 - StringBuilder buf = new StringBuilder(); 33.19 - Collection<String> args = formatArguments(d, l); 33.20 - String msg = localize(l, d.getCode(), args.toArray()); 33.21 - String[] lines = msg.split("\n"); 33.22 - if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) { 33.23 - currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY); 33.24 - buf.append(indent(lines[0], currentIndentation)); //summary 33.25 + int currentIndentation = 0; 33.26 + StringBuilder buf = new StringBuilder(); 33.27 + Collection<String> args = formatArguments(d, l); 33.28 + String msg = localize(l, d.getCode(), args.toArray()); 33.29 + String[] lines = msg.split("\n"); 33.30 + if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) { 33.31 + currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY); 33.32 + buf.append(indent(lines[0], currentIndentation)); //summary 33.33 + } 33.34 + if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) { 33.35 + currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS); 33.36 + for (int i = 1;i < lines.length; i++) { 33.37 + buf.append("\n" + indent(lines[i], currentIndentation)); 33.38 } 33.39 - if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) { 33.40 - currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS); 33.41 - for (int i = 1;i < lines.length; i++) { 33.42 - buf.append("\n" + indent(lines[i], currentIndentation)); 33.43 - } 33.44 + } 33.45 + if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) { 33.46 + currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS); 33.47 + for (String sub : formatSubdiagnostics(d, l)) { 33.48 + buf.append("\n" + indent(sub, currentIndentation)); 33.49 } 33.50 - if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) { 33.51 - currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS); 33.52 - for (String sub : formatSubdiagnostics(d, l)) { 33.53 - buf.append("\n" + sub); 33.54 - } 33.55 - } 33.56 - return buf.toString(); 33.57 } 33.58 - finally { 33.59 - currentIndentation = prevIndentation; 33.60 - } 33.61 + return buf.toString(); 33.62 } 33.63 33.64 protected String addSourceLineIfNeeded(JCDiagnostic d, String msg) {
34.1 --- a/src/share/classes/com/sun/tools/javac/util/Log.java Thu Oct 07 15:12:31 2010 -0700 34.2 +++ b/src/share/classes/com/sun/tools/javac/util/Log.java Tue Oct 12 12:52:49 2010 -0700 34.3 @@ -35,11 +35,14 @@ 34.4 import javax.tools.DiagnosticListener; 34.5 import javax.tools.JavaFileObject; 34.6 34.7 +import com.sun.tools.javac.api.DiagnosticFormatter; 34.8 +import com.sun.tools.javac.main.OptionName; 34.9 import com.sun.tools.javac.tree.JCTree; 34.10 -import com.sun.tools.javac.api.DiagnosticFormatter; 34.11 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 34.12 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType; 34.13 34.14 +import static com.sun.tools.javac.main.OptionName.*; 34.15 + 34.16 /** A class for error logs. Reports errors and warnings, and 34.17 * keeps track of error numbers and positions. 34.18 * 34.19 @@ -129,14 +132,14 @@ 34.20 this.noticeWriter = noticeWriter; 34.21 34.22 Options options = Options.instance(context); 34.23 - this.dumpOnError = options.get("-doe") != null; 34.24 - this.promptOnError = options.get("-prompt") != null; 34.25 - this.emitWarnings = options.get("-Xlint:none") == null; 34.26 - this.suppressNotes = options.get("suppressNotes") != null; 34.27 - this.MaxErrors = getIntOption(options, "-Xmaxerrs", getDefaultMaxErrors()); 34.28 - this.MaxWarnings = getIntOption(options, "-Xmaxwarns", getDefaultMaxWarnings()); 34.29 + this.dumpOnError = options.isSet(DOE); 34.30 + this.promptOnError = options.isSet(PROMPT); 34.31 + this.emitWarnings = options.isUnset(XLINT_CUSTOM, "none"); 34.32 + this.suppressNotes = options.isSet("suppressNotes"); 34.33 + this.MaxErrors = getIntOption(options, XMAXERRS, getDefaultMaxErrors()); 34.34 + this.MaxWarnings = getIntOption(options, XMAXWARNS, getDefaultMaxWarnings()); 34.35 34.36 - boolean rawDiagnostics = options.get("rawDiagnostics") != null; 34.37 + boolean rawDiagnostics = options.isSet("rawDiagnostics"); 34.38 messages = JavacMessages.instance(context); 34.39 this.diagFormatter = rawDiagnostics ? new RawDiagnosticFormatter(options) : 34.40 new BasicDiagnosticFormatter(options, messages); 34.41 @@ -150,7 +153,7 @@ 34.42 expectDiagKeys = new HashSet<String>(Arrays.asList(ek.split(", *"))); 34.43 } 34.44 // where 34.45 - private int getIntOption(Options options, String optionName, int defaultValue) { 34.46 + private int getIntOption(Options options, OptionName optionName, int defaultValue) { 34.47 String s = options.get(optionName); 34.48 try { 34.49 if (s != null) {
35.1 --- a/src/share/classes/com/sun/tools/javac/util/Names.java Thu Oct 07 15:12:31 2010 -0700 35.2 +++ b/src/share/classes/com/sun/tools/javac/util/Names.java Tue Oct 12 12:52:49 2010 -0700 35.3 @@ -271,7 +271,7 @@ 35.4 } 35.5 35.6 protected Name.Table createTable(Options options) { 35.7 - boolean useUnsharedTable = options.get("useUnsharedTable") != null; 35.8 + boolean useUnsharedTable = options.isSet("useUnsharedTable"); 35.9 if (useUnsharedTable) 35.10 return new UnsharedNameTable(this); 35.11 else
36.1 --- a/src/share/classes/com/sun/tools/javac/util/Options.java Thu Oct 07 15:12:31 2010 -0700 36.2 +++ b/src/share/classes/com/sun/tools/javac/util/Options.java Tue Oct 12 12:52:49 2010 -0700 36.3 @@ -25,8 +25,9 @@ 36.4 36.5 package com.sun.tools.javac.util; 36.6 36.7 +import java.util.*; 36.8 import com.sun.tools.javac.main.OptionName; 36.9 -import java.util.*; 36.10 +import static com.sun.tools.javac.main.OptionName.*; 36.11 36.12 /** A table of all command-line options. 36.13 * If an option has an argument, the option name is mapped to the argument. 36.14 @@ -60,14 +61,62 @@ 36.15 context.put(optionsKey, this); 36.16 } 36.17 36.18 + /** 36.19 + * Get the value for an undocumented option. 36.20 + */ 36.21 public String get(String name) { 36.22 return values.get(name); 36.23 } 36.24 36.25 + /** 36.26 + * Get the value for an option. 36.27 + */ 36.28 public String get(OptionName name) { 36.29 return values.get(name.optionName); 36.30 } 36.31 36.32 + /** 36.33 + * Check if the value for an undocumented option has been set. 36.34 + */ 36.35 + public boolean isSet(String name) { 36.36 + return (values.get(name) != null); 36.37 + } 36.38 + 36.39 + /** 36.40 + * Check if the value for an option has been set. 36.41 + */ 36.42 + public boolean isSet(OptionName name) { 36.43 + return (values.get(name.optionName) != null); 36.44 + } 36.45 + 36.46 + /** 36.47 + * Check if the value for a choice option has been set to a specific value. 36.48 + */ 36.49 + public boolean isSet(OptionName name, String value) { 36.50 + return (values.get(name.optionName + value) != null); 36.51 + } 36.52 + 36.53 + /** 36.54 + * Check if the value for an undocumented option has not been set. 36.55 + */ 36.56 + public boolean isUnset(String name) { 36.57 + return (values.get(name) == null); 36.58 + } 36.59 + 36.60 + /** 36.61 + * Check if the value for an option has not been set. 36.62 + */ 36.63 + public boolean isUnset(OptionName name) { 36.64 + return (values.get(name.optionName) == null); 36.65 + } 36.66 + 36.67 + /** 36.68 + * Check if the value for a choice option has not been set to a specific value. 36.69 + */ 36.70 + public boolean isUnset(OptionName name, String value) { 36.71 + return (values.get(name.optionName + value) == null); 36.72 + } 36.73 + 36.74 public void put(String name, String value) { 36.75 values.put(name, value); 36.76 } 36.77 @@ -92,16 +141,14 @@ 36.78 return values.size(); 36.79 } 36.80 36.81 - static final String LINT = "-Xlint"; 36.82 - 36.83 /** Check for a lint suboption. */ 36.84 public boolean lint(String s) { 36.85 // return true if either the specific option is enabled, or 36.86 // they are all enabled without the specific one being 36.87 // disabled 36.88 return 36.89 - get(LINT + ":" + s)!=null || 36.90 - (get(LINT)!=null || get(LINT + ":all")!=null) && 36.91 - get(LINT+":-"+s)==null; 36.92 + isSet(XLINT_CUSTOM, s) || 36.93 + (isSet(XLINT) || isSet(XLINT_CUSTOM, "all")) && 36.94 + isUnset(XLINT_CUSTOM, "-" + s); 36.95 } 36.96 }
37.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Thu Oct 07 15:12:31 2010 -0700 37.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Tue Oct 12 12:52:49 2010 -0700 37.3 @@ -1,5 +1,5 @@ 37.4 /* 37.5 - * Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved. 37.6 + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 37.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 37.8 * 37.9 * This code is free software; you can redistribute it and/or modify it 37.10 @@ -107,9 +107,6 @@ 37.11 // force the use of Messager as a Log 37.12 messager = Messager.instance0(context); 37.13 37.14 - // force the use of the scanner that captures Javadoc comments 37.15 - DocCommentScanner.Factory.preRegister(context); 37.16 - 37.17 return new JavadocTool(context); 37.18 } catch (CompletionFailure ex) { 37.19 messager.error(Position.NOPOS, ex.getMessage());
38.1 --- a/src/share/classes/com/sun/tools/javah/JavahTask.java Thu Oct 07 15:12:31 2010 -0700 38.2 +++ b/src/share/classes/com/sun/tools/javah/JavahTask.java Tue Oct 12 12:52:49 2010 -0700 38.3 @@ -1,5 +1,5 @@ 38.4 /* 38.5 - * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved. 38.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 38.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 38.8 * 38.9 * This code is free software; you can redistribute it and/or modify it 38.10 @@ -526,15 +526,17 @@ 38.11 } 38.12 38.13 private void showVersion(boolean full) { 38.14 - log.println(version(full ? "full" : "release")); 38.15 + log.println(version(full)); 38.16 } 38.17 38.18 private static final String versionRBName = "com.sun.tools.javah.resources.version"; 38.19 private static ResourceBundle versionRB; 38.20 38.21 - private String version(String key) { 38.22 - // key=version: mm.nn.oo[-milestone] 38.23 - // key=full: mm.mm.oo[-milestone]-build 38.24 + private String version(boolean full) { 38.25 + String msgKey = (full ? "javah.fullVersion" : "javah.version"); 38.26 + String versionKey = (full ? "full" : "release"); 38.27 + // versionKey=product: mm.nn.oo[-milestone] 38.28 + // versionKey=full: mm.mm.oo[-milestone]-build 38.29 if (versionRB == null) { 38.30 try { 38.31 versionRB = ResourceBundle.getBundle(versionRBName); 38.32 @@ -543,7 +545,7 @@ 38.33 } 38.34 } 38.35 try { 38.36 - return versionRB.getString(key); 38.37 + return getMessage(msgKey, "javah", versionRB.getString(versionKey)); 38.38 } 38.39 catch (MissingResourceException e) { 38.40 return getMessage("version.unknown", System.getProperty("java.version"));
39.1 --- a/src/share/classes/com/sun/tools/javah/resources/l10n.properties Thu Oct 07 15:12:31 2010 -0700 39.2 +++ b/src/share/classes/com/sun/tools/javah/resources/l10n.properties Tue Oct 12 12:52:49 2010 -0700 39.3 @@ -1,5 +1,5 @@ 39.4 # 39.5 -# Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. 39.6 +# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 39.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 39.8 # 39.9 # This code is free software; you can redistribute it and/or modify it 39.10 @@ -113,7 +113,8 @@ 39.11 # 39.12 # Version string. 39.13 # 39.14 -javah.version=javah version "{0}" 39.15 +javah.version={0} version "{1}" 39.16 +javah.fullVersion={0} full version "{1}" 39.17 39.18 # 39.19 # These should have better diagnostics.
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 40.2 +++ b/src/share/classes/com/sun/tools/javah/resources/version.properties-template Tue Oct 12 12:52:49 2010 -0700 40.3 @@ -0,0 +1,28 @@ 40.4 +# 40.5 +# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. 40.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 40.7 +# 40.8 +# This code is free software; you can redistribute it and/or modify it 40.9 +# under the terms of the GNU General Public License version 2 only, as 40.10 +# published by the Free Software Foundation. Oracle designates this 40.11 +# particular file as subject to the "Classpath" exception as provided 40.12 +# by Oracle in the LICENSE file that accompanied this code. 40.13 +# 40.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 40.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 40.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 40.17 +# version 2 for more details (a copy is included in the LICENSE file that 40.18 +# accompanied this code). 40.19 +# 40.20 +# You should have received a copy of the GNU General Public License version 40.21 +# 2 along with this work; if not, write to the Free Software Foundation, 40.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 40.23 +# 40.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 40.25 +# or visit www.oracle.com if you need additional information or have any 40.26 +# questions. 40.27 +# 40.28 + 40.29 +jdk=$(JDK_VERSION) 40.30 +full=$(FULL_VERSION) 40.31 +release=$(RELEASE)
41.1 --- a/test/tools/javac/6302184/T6302184.out Thu Oct 07 15:12:31 2010 -0700 41.2 +++ b/test/tools/javac/6302184/T6302184.out Tue Oct 12 12:52:49 2010 -0700 41.3 @@ -1,4 +1,7 @@ 41.4 41.5 +/** 41.6 + * This is a test that uses ISO 8859 encoding. 41.7 + */ 41.8 class T6302184 { 41.9 41.10 T6302184() {
42.1 --- a/test/tools/javac/6304921/TestLog.java Thu Oct 07 15:12:31 2010 -0700 42.2 +++ b/test/tools/javac/6304921/TestLog.java Tue Oct 12 12:52:49 2010 -0700 42.3 @@ -1,5 +1,5 @@ 42.4 /* 42.5 - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. 42.6 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 42.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 42.8 * 42.9 * This code is free software; you can redistribute it and/or modify it 42.10 @@ -35,7 +35,6 @@ 42.11 import com.sun.tools.javac.file.JavacFileManager; 42.12 import com.sun.tools.javac.parser.Parser; 42.13 import com.sun.tools.javac.parser.ParserFactory; 42.14 -import com.sun.tools.javac.parser.Scanner; 42.15 import com.sun.tools.javac.tree.JCTree; 42.16 import com.sun.tools.javac.tree.TreeScanner; 42.17 import com.sun.tools.javac.util.Context; 42.18 @@ -60,7 +59,6 @@ 42.19 log.multipleErrors = true; 42.20 42.21 JavacFileManager.preRegister(context); 42.22 - Scanner.Factory sfac = Scanner.Factory.instance(context); 42.23 ParserFactory pfac = ParserFactory.instance(context); 42.24 42.25 final String text =
43.1 --- a/test/tools/javac/6758789/T6758789a.out Thu Oct 07 15:12:31 2010 -0700 43.2 +++ b/test/tools/javac/6758789/T6758789a.out Tue Oct 12 12:52:49 2010 -0700 43.3 @@ -1,3 +1,3 @@ 43.4 -T6758789a.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, null 43.5 -T6758789a.java:15:9: compiler.err.cant.apply.symbol: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, null 43.6 +T6758789a.java:14:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch) 43.7 +T6758789a.java:15:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch) 43.8 2 errors
44.1 --- a/test/tools/javac/6840059/T6840059.out Thu Oct 07 15:12:31 2010 -0700 44.2 +++ b/test/tools/javac/6840059/T6840059.out Tue Oct 12 12:52:49 2010 -0700 44.3 @@ -1,3 +1,3 @@ 44.4 -T6840059.java:15:9: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, null 44.5 -T6840059.java:15:25: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, compiler.misc.no.args, kindname.class, T6840059, null 44.6 +T6840059.java:15:9: compiler.err.cant.apply.symbol.1: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, (compiler.misc.no.conforming.assignment.exists: java.lang.String, java.lang.Integer) 44.7 +T6840059.java:15:25: compiler.err.cant.apply.symbol.1: kindname.constructor, T6840059, java.lang.Integer, compiler.misc.no.args, kindname.class, T6840059, (compiler.misc.arg.length.mismatch) 44.8 2 errors
45.1 --- a/test/tools/javac/6857948/T6857948.out Thu Oct 07 15:12:31 2010 -0700 45.2 +++ b/test/tools/javac/6857948/T6857948.out Tue Oct 12 12:52:49 2010 -0700 45.3 @@ -1,3 +1,3 @@ 45.4 T6857948.java:16:32: compiler.err.cant.resolve.location.args: kindname.method, nosuchfunction, , , kindname.class, Test 45.5 -T6857948.java:16:50: compiler.err.cant.apply.symbol: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, null 45.6 +T6857948.java:16:50: compiler.err.cant.apply.symbol.1: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, (compiler.misc.arg.length.mismatch) 45.7 2 errors
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 46.2 +++ b/test/tools/javac/6863465/T6863465a.java Tue Oct 12 12:52:49 2010 -0700 46.3 @@ -0,0 +1,14 @@ 46.4 +/** 46.5 + * @test /nodynamiccopyright/ 46.6 + * @bug 6863465 46.7 + * @summary javac doesn't detect circular subclass dependencies via qualified names 46.8 + * @author Maurizio Cimadamore 46.9 + * @compile/fail/ref=T6863465a.out -XDrawDiagnostics T6863465a.java 46.10 + */ 46.11 + 46.12 +class T6863465a { 46.13 + static class a { static interface b {} } 46.14 + static class c extends a implements z.y {} 46.15 + static class x { static interface y {} } 46.16 + static class z extends x implements c.b {} 46.17 +}
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 47.2 +++ b/test/tools/javac/6863465/T6863465a.out Tue Oct 12 12:52:49 2010 -0700 47.3 @@ -0,0 +1,2 @@ 47.4 +T6863465a.java:11:12: compiler.err.cyclic.inheritance: T6863465a.c 47.5 +1 error
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 48.2 +++ b/test/tools/javac/6863465/T6863465b.java Tue Oct 12 12:52:49 2010 -0700 48.3 @@ -0,0 +1,14 @@ 48.4 +/** 48.5 + * @test /nodynamiccopyright/ 48.6 + * @bug 6863465 48.7 + * @summary javac doesn't detect circular subclass dependencies via qualified names 48.8 + * @author Maurizio Cimadamore 48.9 + * @compile/fail/ref=T6863465b.out -XDrawDiagnostics T6863465b.java 48.10 + */ 48.11 + 48.12 +class T6863465b { 48.13 + static class a { static interface b { static interface d {} } } 48.14 + static class c extends a implements z.y, z.d {} 48.15 + static class x { static interface y {} } 48.16 + static class z extends x implements c.b {} 48.17 +}
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 49.2 +++ b/test/tools/javac/6863465/T6863465b.out Tue Oct 12 12:52:49 2010 -0700 49.3 @@ -0,0 +1,2 @@ 49.4 +T6863465b.java:11:12: compiler.err.cyclic.inheritance: T6863465b.c 49.5 +1 error
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/test/tools/javac/6863465/T6863465c.java Tue Oct 12 12:52:49 2010 -0700 50.3 @@ -0,0 +1,14 @@ 50.4 +/** 50.5 + * @test /nodynamiccopyright/ 50.6 + * @bug 6863465 50.7 + * @summary javac doesn't detect circular subclass dependencies via qualified names 50.8 + * @author Maurizio Cimadamore 50.9 + * @compile/fail/ref=T6863465c.out -XDrawDiagnostics T6863465c.java 50.10 + */ 50.11 + 50.12 +class T6863465c { 50.13 + static class x { static interface y {} } 50.14 + static class z extends x implements c.b {} 50.15 + static class a { static interface b { static interface d {} } } 50.16 + static class c extends a implements z.y, z.d {} 50.17 +}
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/test/tools/javac/6863465/T6863465c.out Tue Oct 12 12:52:49 2010 -0700 51.3 @@ -0,0 +1,3 @@ 51.4 +T6863465c.java:13:47: compiler.err.cant.resolve.location: kindname.class, d, , , kindname.class, T6863465c.z 51.5 +T6863465c.java:11:12: compiler.err.cyclic.inheritance: T6863465c.z 51.6 +2 errors
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 52.2 +++ b/test/tools/javac/6863465/T6863465d.java Tue Oct 12 12:52:49 2010 -0700 52.3 @@ -0,0 +1,14 @@ 52.4 +/** 52.5 + * @test /nodynamiccopyright/ 52.6 + * @bug 6863465 52.7 + * @summary javac doesn't detect circular subclass dependencies via qualified names 52.8 + * @author Maurizio Cimadamore 52.9 + * @compile/fail/ref=T6863465d.out -XDrawDiagnostics T6863465d.java 52.10 + */ 52.11 + 52.12 +class T6863465d { 52.13 + static class a { static interface b { static interface d {} } } 52.14 + static class c extends a implements z.y, z.d {} 52.15 + static class x { static interface y { static interface w {} } } 52.16 + static class z extends x implements c.b, c.w {} 52.17 +}
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 53.2 +++ b/test/tools/javac/6863465/T6863465d.out Tue Oct 12 12:52:49 2010 -0700 53.3 @@ -0,0 +1,3 @@ 53.4 +T6863465d.java:13:47: compiler.err.cant.resolve.location: kindname.class, w, , , kindname.class, T6863465d.c 53.5 +T6863465d.java:11:12: compiler.err.cyclic.inheritance: T6863465d.c 53.6 +2 errors
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 54.2 +++ b/test/tools/javac/6863465/TestCircularClassfile.java Tue Oct 12 12:52:49 2010 -0700 54.3 @@ -0,0 +1,123 @@ 54.4 +/* 54.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 54.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 54.7 + * 54.8 + * This code is free software; you can redistribute it and/or modify it 54.9 + * under the terms of the GNU General Public License version 2 only, as 54.10 + * published by the Free Software Foundation. 54.11 + * 54.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 54.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 54.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 54.15 + * version 2 for more details (a copy is included in the LICENSE file that 54.16 + * accompanied this code). 54.17 + * 54.18 + * You should have received a copy of the GNU General Public License version 54.19 + * 2 along with this work; if not, write to the Free Software Foundation, 54.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 54.21 + * 54.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 54.23 + * or visit www.oracle.com if you need additional information or have any 54.24 + * questions. 54.25 + */ 54.26 + 54.27 +/* 54.28 + * @test 54.29 + * @bug 6863465 54.30 + * @summary javac doesn't detect circular subclass dependencies via qualified names 54.31 + * @run main TestCircularClassfile 54.32 + */ 54.33 + 54.34 +import java.io.*; 54.35 +import java.net.URI; 54.36 +import java.util.Arrays; 54.37 +import javax.tools.Diagnostic; 54.38 +import javax.tools.DiagnosticListener; 54.39 +import javax.tools.JavaCompiler; 54.40 +import javax.tools.JavaFileObject; 54.41 +import javax.tools.SimpleJavaFileObject; 54.42 +import javax.tools.ToolProvider; 54.43 + 54.44 +import com.sun.source.util.JavacTask; 54.45 +import java.util.EnumSet; 54.46 + 54.47 +public class TestCircularClassfile { 54.48 + 54.49 + enum ClassName { 54.50 + A("A"), 54.51 + B("B"), 54.52 + C("C"), 54.53 + OBJECT("Object"); 54.54 + 54.55 + String name; 54.56 + 54.57 + ClassName(String name) { 54.58 + this.name = name; 54.59 + } 54.60 + } 54.61 + 54.62 + static class JavaSource extends SimpleJavaFileObject { 54.63 + 54.64 + final static String sourceStub = "class #C extends #S {}"; 54.65 + 54.66 + String source; 54.67 + 54.68 + public JavaSource(ClassName clazz, ClassName sup) { 54.69 + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 54.70 + source = sourceStub.replace("#C", clazz.name).replace("#S", sup.name); 54.71 + } 54.72 + 54.73 + @Override 54.74 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 54.75 + return source; 54.76 + } 54.77 + } 54.78 + 54.79 + public static void main(String... args) throws Exception { 54.80 + int count = 0; 54.81 + for (ClassName clazz : EnumSet.of(ClassName.A, ClassName.B, ClassName.C)) { 54.82 + for (ClassName sup : EnumSet.of(ClassName.A, ClassName.B, ClassName.C)) { 54.83 + if (sup.ordinal() < clazz.ordinal()) continue; 54.84 + check("sub_"+count++, clazz, sup); 54.85 + } 54.86 + } 54.87 + } 54.88 + 54.89 + static JavaSource[] initialSources = new JavaSource[] { 54.90 + new JavaSource(ClassName.A, ClassName.OBJECT), 54.91 + new JavaSource(ClassName.B, ClassName.A), 54.92 + new JavaSource(ClassName.C, ClassName.B) 54.93 + }; 54.94 + 54.95 + static String workDir = System.getProperty("user.dir"); 54.96 + 54.97 + static void check(String destPath, ClassName clazz, ClassName sup) throws Exception { 54.98 + File destDir = new File(workDir, destPath); destDir.mkdir(); 54.99 + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); 54.100 + JavacTask ct = (JavacTask)tool.getTask(null, null, null, 54.101 + Arrays.asList("-d", destPath), null, Arrays.asList(initialSources)); 54.102 + ct.generate(); 54.103 + File fileToRemove = new File(destPath, clazz.name + ".class"); 54.104 + fileToRemove.delete(); 54.105 + JavaSource newSource = new JavaSource(clazz, sup); 54.106 + DiagnosticChecker checker = new DiagnosticChecker(); 54.107 + ct = (JavacTask)tool.getTask(null, null, checker, 54.108 + Arrays.asList("-cp", destPath), null, Arrays.asList(newSource)); 54.109 + ct.analyze(); 54.110 + if (!checker.errorFound) { 54.111 + throw new AssertionError(newSource.source); 54.112 + } 54.113 + } 54.114 + 54.115 + static class DiagnosticChecker implements DiagnosticListener<JavaFileObject> { 54.116 + 54.117 + boolean errorFound = false; 54.118 + 54.119 + public void report(Diagnostic<? extends JavaFileObject> diagnostic) { 54.120 + if (diagnostic.getKind() == Diagnostic.Kind.ERROR && 54.121 + diagnostic.getCode().equals("compiler.err.cyclic.inheritance")) { 54.122 + errorFound = true; 54.123 + } 54.124 + } 54.125 + } 54.126 +}
55.1 --- a/test/tools/javac/CyclicInheritance.out Thu Oct 07 15:12:31 2010 -0700 55.2 +++ b/test/tools/javac/CyclicInheritance.out Tue Oct 12 12:52:49 2010 -0700 55.3 @@ -4,6 +4,6 @@ 55.4 CyclicInheritance.java:22:1: compiler.err.cyclic.inheritance: I11 55.5 CyclicInheritance.java:27:1: compiler.err.cyclic.inheritance: C211 55.6 CyclicInheritance.java:31:1: compiler.err.cyclic.inheritance: C212 55.7 -CyclicInheritance.java:36:27: compiler.err.report.access: C221.I, private, C221 55.8 -CyclicInheritance.java:40:24: compiler.err.report.access: C222.C, private, C222 55.9 +CyclicInheritance.java:36:1: compiler.err.cyclic.inheritance: C221 55.10 +CyclicInheritance.java:40:1: compiler.err.cyclic.inheritance: C222 55.11 8 errors
56.1 --- a/test/tools/javac/Diagnostics/6722234/T6722234a_1.out Thu Oct 07 15:12:31 2010 -0700 56.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234a_1.out Tue Oct 12 12:52:49 2010 -0700 56.3 @@ -1,2 +1,2 @@ 56.4 -T6722234a.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, null 56.5 +T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1) 56.6 1 error
57.1 --- a/test/tools/javac/Diagnostics/6722234/T6722234a_2.out Thu Oct 07 15:12:31 2010 -0700 57.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234a_2.out Tue Oct 12 12:52:49 2010 -0700 57.3 @@ -1,3 +1,3 @@ 57.4 -T6722234a.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, null 57.5 +T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1) 57.6 - compiler.misc.where.description.typevar.1: compiler.misc.type.var: T, 1,compiler.misc.type.var: T, 2,{(compiler.misc.where.typevar: compiler.misc.type.var: T, 1, java.lang.String, kindname.class, T6722234a),(compiler.misc.where.typevar: compiler.misc.type.var: T, 2, java.lang.Integer, kindname.method, <compiler.misc.type.var: T, 2>test(compiler.misc.type.var: T, 2))} 57.7 1 error
58.1 --- a/test/tools/javac/Diagnostics/6722234/T6722234b_1.out Thu Oct 07 15:12:31 2010 -0700 58.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234b_1.out Tue Oct 12 12:52:49 2010 -0700 58.3 @@ -1,2 +1,2 @@ 58.4 -T6722234b.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, List<T>,List<T>, List<compiler.misc.type.captureof: 1, ? extends T6722234b>,List<compiler.misc.type.captureof: 2, ? extends T6722234b>, kindname.class, T6722234b, null 58.5 +T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.type.captureof: 1, ? extends T6722234b>,List<compiler.misc.type.captureof: 2, ? extends T6722234b>, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List<compiler.misc.type.captureof: 2, ? extends T6722234b>, List<T>) 58.6 1 error
59.1 --- a/test/tools/javac/Diagnostics/6722234/T6722234b_2.out Thu Oct 07 15:12:31 2010 -0700 59.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234b_2.out Tue Oct 12 12:52:49 2010 -0700 59.3 @@ -1,4 +1,4 @@ 59.4 -T6722234b.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, List<T>,List<T>, List<compiler.misc.captured.type: 1>,List<compiler.misc.captured.type: 2>, kindname.class, T6722234b, null 59.5 +T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.captured.type: 1>,List<compiler.misc.captured.type: 2>, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List<compiler.misc.captured.type: 2>, List<T>) 59.6 - compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, Object, kindname.method, <T>m(List<T>,List<T>))} 59.7 - 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)} 59.8 1 error
60.1 --- a/test/tools/javac/Diagnostics/6722234/T6722234c.out Thu Oct 07 15:12:31 2010 -0700 60.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234c.out Tue Oct 12 12:52:49 2010 -0700 60.3 @@ -1,2 +1,2 @@ 60.4 -T6722234c.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, null 60.5 +T6722234c.java:14:9: compiler.err.cant.apply.symbol.1: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, (compiler.misc.infer.no.conforming.assignment.exists: T, java.lang.String, T6722234c.String) 60.6 1 error
61.1 --- a/test/tools/javac/Diagnostics/6799605/T6799605.out Thu Oct 07 15:12:31 2010 -0700 61.2 +++ b/test/tools/javac/Diagnostics/6799605/T6799605.out Tue Oct 12 12:52:49 2010 -0700 61.3 @@ -1,4 +1,4 @@ 61.4 -T6799605.java:17:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>, kindname.class, T6799605<X> 61.5 -T6799605.java:18:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>, kindname.class, T6799605<X> 61.6 -T6799605.java:19:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>, kindname.class, T6799605<X> 61.7 +T6799605.java:17:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.inferred.do.not.conform.to.bounds: compiler.misc.type.captureof: 1, ?, T6799605<compiler.misc.type.captureof: 1, ?>))} 61.8 +T6799605.java:18:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605<compiler.misc.type.captureof: 2, ?>, T6799605<T>)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch))} 61.9 +T6799605.java:19:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605<compiler.misc.type.captureof: 2, ?>, T6799605<T>)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch))} 61.10 3 errors
62.1 --- a/test/tools/javac/Diagnostics/6862608/T6862608a.out Thu Oct 07 15:12:31 2010 -0700 62.2 +++ b/test/tools/javac/Diagnostics/6862608/T6862608a.out Tue Oct 12 12:52:49 2010 -0700 62.3 @@ -1,3 +1,3 @@ 62.4 -T6862608a.java:19:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, java.util.Comparator<T>, java.util.Comparator<java.lang.String>)), <T>java.util.Comparator<T>, java.util.Comparator<java.lang.String> 62.5 +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<T>, java.util.Comparator<java.lang.String>)), <T>java.util.Comparator<T>, java.util.Comparator<java.lang.String> 62.6 - compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, java.lang.Object, kindname.method, <T>compound(java.lang.Iterable<? extends java.util.Comparator<? super T>>))} 62.7 1 error
63.1 --- a/test/tools/javac/Diagnostics/6862608/T6862608b.out Thu Oct 07 15:12:31 2010 -0700 63.2 +++ b/test/tools/javac/Diagnostics/6862608/T6862608b.out Tue Oct 12 12:52:49 2010 -0700 63.3 @@ -1,3 +1,3 @@ 63.4 -T6862608b.java:11:7: compiler.err.cant.apply.symbol: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b<compiler.misc.type.var: T, 1,compiler.misc.type.var: S, 2>, null 63.5 +T6862608b.java:11:7: compiler.err.cant.apply.symbol.1: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b<compiler.misc.type.var: T, 1,compiler.misc.type.var: S, 2>, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1) 63.6 - compiler.misc.where.description.typevar.1: compiler.misc.type.var: T, 1,compiler.misc.type.var: T, 2,compiler.misc.type.var: S, 1,compiler.misc.type.var: S, 2,{(compiler.misc.where.typevar: compiler.misc.type.var: T, 1, java.lang.String, kindname.class, T66862608b),(compiler.misc.where.typevar: compiler.misc.type.var: T, 2, compiler.misc.type.var: S, 1, kindname.method, <compiler.misc.type.var: S, 1,compiler.misc.type.var: T, 2>foo(compiler.misc.type.var: T, 2)),(compiler.misc.where.typevar: compiler.misc.type.var: S, 1, java.lang.Object, kindname.method, <compiler.misc.type.var: S, 1,compiler.misc.type.var: T, 2>foo(compiler.misc.type.var: T, 2)),(compiler.misc.where.typevar: compiler.misc.type.var: S, 2, java.lang.Object, kindname.class, T66862608b)} 63.7 1 error
64.1 --- a/test/tools/javac/NameCollision.out Thu Oct 07 15:12:31 2010 -0700 64.2 +++ b/test/tools/javac/NameCollision.out Tue Oct 12 12:52:49 2010 -0700 64.3 @@ -1,2 +1,3 @@ 64.4 NameCollision.java:13:31: compiler.err.intf.expected.here 64.5 -1 error 64.6 +NameCollision.java:13:5: compiler.err.cyclic.inheritance: NameCollision.Runnable 64.7 +2 errors
65.1 --- a/test/tools/javac/T6326754.out Thu Oct 07 15:12:31 2010 -0700 65.2 +++ b/test/tools/javac/T6326754.out Tue Oct 12 12:52:49 2010 -0700 65.3 @@ -1,7 +1,7 @@ 65.4 T6326754.java:44:12: compiler.err.name.clash.same.erasure: TestConstructor(T), TestConstructor(K) 65.5 T6326754.java:52:17: compiler.err.name.clash.same.erasure: setT(K), setT(T) 65.6 T6326754.java:64:18: compiler.err.prob.found.req: (compiler.misc.incompatible.types), T, T 65.7 -T6326754.java:70:11: compiler.err.cant.apply.symbol: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC<T>, null 65.8 +T6326754.java:70:11: compiler.err.cant.apply.symbol.1: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC<T>, (compiler.misc.arg.length.mismatch) 65.9 - compiler.note.unchecked.filename: T6326754.java 65.10 - compiler.note.unchecked.recompile 65.11 4 errors
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 66.2 +++ b/test/tools/javac/T6587674.java Tue Oct 12 12:52:49 2010 -0700 66.3 @@ -0,0 +1,39 @@ 66.4 +/* 66.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 66.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 66.7 + * 66.8 + * This code is free software; you can redistribute it and/or modify it 66.9 + * under the terms of the GNU General Public License version 2 only, as 66.10 + * published by the Free Software Foundation. 66.11 + * 66.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 66.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 66.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 66.15 + * version 2 for more details (a copy is included in the LICENSE file that 66.16 + * accompanied this code). 66.17 + * 66.18 + * You should have received a copy of the GNU General Public License version 66.19 + * 2 along with this work; if not, write to the Free Software Foundation, 66.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 66.21 + * 66.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 66.23 + * or visit www.oracle.com if you need additional information or have any 66.24 + * questions. 66.25 + */ 66.26 + 66.27 +/* 66.28 + * @test 66.29 + * @bug 6587674 66.30 + * @summary NoClassdefFound when anonymously extending a class. 66.31 + */ 66.32 + 66.33 +import java.util.Vector; 66.34 + 66.35 +public class T6587674 { 66.36 + private static final Vector<String> list = 66.37 + true ? null : new Vector<String>() { }; 66.38 + 66.39 + public static void main(String[] args) { 66.40 + System.out.println("T6587674 runs fine!"); 66.41 + } 66.42 +}
67.1 --- a/test/tools/javac/api/TestJavacTaskScanner.java Thu Oct 07 15:12:31 2010 -0700 67.2 +++ b/test/tools/javac/api/TestJavacTaskScanner.java Tue Oct 12 12:52:49 2010 -0700 67.3 @@ -1,5 +1,5 @@ 67.4 /* 67.5 - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 67.6 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 67.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 67.8 * 67.9 * This code is free software; you can redistribute it and/or modify it 67.10 @@ -31,8 +31,8 @@ 67.11 */ 67.12 67.13 import com.sun.tools.javac.api.JavacTaskImpl; 67.14 -import com.sun.tools.javac.parser.*; // XXX 67.15 -import com.sun.tools.javac.util.*; // XXX 67.16 +import com.sun.tools.javac.parser.*; 67.17 +import com.sun.tools.javac.util.*; 67.18 import java.io.*; 67.19 import java.net.*; 67.20 import java.nio.*; 67.21 @@ -65,7 +65,7 @@ 67.22 fm.getJavaFileObjects(new File[] {file}); 67.23 StandardJavaFileManager fm = getLocalFileManager(tool, null, null); 67.24 task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, compilationUnits); 67.25 - task.getContext().put(Scanner.Factory.scannerFactoryKey, 67.26 + task.getContext().put(ScannerFactory.scannerFactoryKey, 67.27 new MyScanner.Factory(task.getContext(), this)); 67.28 elements = task.getElements(); 67.29 types = task.getTypes(); 67.30 @@ -170,34 +170,36 @@ 67.31 67.32 class MyScanner extends Scanner { 67.33 67.34 - public static class Factory extends Scanner.Factory { 67.35 + public static class Factory extends ScannerFactory { 67.36 public Factory(Context context, TestJavacTaskScanner test) { 67.37 super(context); 67.38 this.test = test; 67.39 } 67.40 67.41 @Override 67.42 - public Scanner newScanner(CharSequence input) { 67.43 + public Scanner newScanner(CharSequence input, boolean keepDocComments) { 67.44 + assert !keepDocComments; 67.45 if (input instanceof CharBuffer) { 67.46 return new MyScanner(this, (CharBuffer)input, test); 67.47 } else { 67.48 char[] array = input.toString().toCharArray(); 67.49 - return newScanner(array, array.length); 67.50 + return newScanner(array, array.length, keepDocComments); 67.51 } 67.52 } 67.53 67.54 @Override 67.55 - public Scanner newScanner(char[] input, int inputLength) { 67.56 + public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) { 67.57 + assert !keepDocComments; 67.58 return new MyScanner(this, input, inputLength, test); 67.59 } 67.60 67.61 private TestJavacTaskScanner test; 67.62 } 67.63 - protected MyScanner(Factory fac, CharBuffer buffer, TestJavacTaskScanner test) { 67.64 + protected MyScanner(ScannerFactory fac, CharBuffer buffer, TestJavacTaskScanner test) { 67.65 super(fac, buffer); 67.66 this.test = test; 67.67 } 67.68 - protected MyScanner(Factory fac, char[] input, int inputLength, TestJavacTaskScanner test) { 67.69 + protected MyScanner(ScannerFactory fac, char[] input, int inputLength, TestJavacTaskScanner test) { 67.70 super(fac, input, inputLength); 67.71 this.test = test; 67.72 }
68.1 --- a/test/tools/javac/diags/Example.java Thu Oct 07 15:12:31 2010 -0700 68.2 +++ b/test/tools/javac/diags/Example.java Tue Oct 12 12:52:49 2010 -0700 68.3 @@ -401,7 +401,7 @@ 68.4 } 68.5 } 68.6 for (JCDiagnostic sd: d.getSubdiagnostics()) 68.7 - scanForKeys(d, keys); 68.8 + scanForKeys(sd, keys); 68.9 } 68.10 } 68.11
69.1 --- a/test/tools/javac/diags/examples.not-yet.txt Thu Oct 07 15:12:31 2010 -0700 69.2 +++ b/test/tools/javac/diags/examples.not-yet.txt Tue Oct 12 12:52:49 2010 -0700 69.3 @@ -3,7 +3,7 @@ 69.4 compiler.err.annotation.value.not.allowable.type # cannot happen: precluded by complete type-specific tests 69.5 compiler.err.assignment.from.super-bound # DEAD 69.6 compiler.err.assignment.to.extends-bound # DEAD 69.7 -compiler.err.cant.apply.symbol.1 69.8 +compiler.err.cant.apply.symbol 69.9 compiler.err.cant.read.file # (apt.JavaCompiler?) 69.10 compiler.err.cant.select.static.class.from.param.type 69.11 compiler.err.illegal.char.for.encoding 69.12 @@ -43,7 +43,6 @@ 69.13 compiler.err.unexpected.type 69.14 compiler.err.unknown.enum.constant # in bad class file 69.15 compiler.err.unsupported.cross.fp.lit # Scanner: host system dependent 69.16 -compiler.misc.arg.length.mismatch 69.17 compiler.misc.assignment.from.super-bound 69.18 compiler.misc.assignment.to.extends-bound 69.19 compiler.misc.bad.class.file.header # bad class file 69.20 @@ -73,7 +72,6 @@ 69.21 compiler.misc.kindname.type.variable 69.22 compiler.misc.kindname.type.variable.bound 69.23 compiler.misc.kindname.value 69.24 -compiler.misc.no.conforming.assignment.exists 69.25 compiler.misc.non.denotable.type 69.26 compiler.misc.no.unique.minimal.instance.exists 69.27 compiler.misc.resume.abort # prompt for a response
70.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 70.2 +++ b/test/tools/javac/diags/examples/ExplicitParamsDoNotConformToBounds.java Tue Oct 12 12:52:49 2010 -0700 70.3 @@ -0,0 +1,30 @@ 70.4 +/* 70.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 70.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 70.7 + * 70.8 + * This code is free software; you can redistribute it and/or modify it 70.9 + * under the terms of the GNU General Public License version 2 only, as 70.10 + * published by the Free Software Foundation. 70.11 + * 70.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 70.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 70.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 70.15 + * version 2 for more details (a copy is included in the LICENSE file that 70.16 + * accompanied this code). 70.17 + * 70.18 + * You should have received a copy of the GNU General Public License version 70.19 + * 2 along with this work; if not, write to the Free Software Foundation, 70.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 70.21 + * 70.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 70.23 + * or visit www.oracle.com if you need additional information or have any 70.24 + * questions. 70.25 + */ 70.26 + 70.27 +// key: compiler.err.cant.apply.symbol.1 70.28 +// key: compiler.misc.explicit.param.do.not.conform.to.bounds 70.29 + 70.30 +class ExplicitParamsDoNotConformToBounds { 70.31 + <X extends Number> void m() {} 70.32 + { this.<String>m(); } 70.33 +}
71.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 71.2 +++ b/test/tools/javac/diags/examples/InapplicableSymbols.java Tue Oct 12 12:52:49 2010 -0700 71.3 @@ -0,0 +1,32 @@ 71.4 +/* 71.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 71.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 71.7 + * 71.8 + * This code is free software; you can redistribute it and/or modify it 71.9 + * under the terms of the GNU General Public License version 2 only, as 71.10 + * published by the Free Software Foundation. 71.11 + * 71.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 71.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 71.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 71.15 + * version 2 for more details (a copy is included in the LICENSE file that 71.16 + * accompanied this code). 71.17 + * 71.18 + * You should have received a copy of the GNU General Public License version 71.19 + * 2 along with this work; if not, write to the Free Software Foundation, 71.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 71.21 + * 71.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 71.23 + * or visit www.oracle.com if you need additional information or have any 71.24 + * questions. 71.25 + */ 71.26 + 71.27 +// key: compiler.err.cant.apply.symbols 71.28 +// key: compiler.misc.arg.length.mismatch 71.29 +// key: compiler.misc.inapplicable.method 71.30 + 71.31 +class ExplicitParamsDoNotConformToBounds { 71.32 + void m(int i1) {} 71.33 + void m(int i1, int i2) {} 71.34 + { this.m(); } 71.35 +}
72.1 --- a/test/tools/javac/diags/examples/IncompatibleTypes1.java Thu Oct 07 15:12:31 2010 -0700 72.2 +++ b/test/tools/javac/diags/examples/IncompatibleTypes1.java Tue Oct 12 12:52:49 2010 -0700 72.3 @@ -22,7 +22,7 @@ 72.4 */ 72.5 72.6 // key: compiler.misc.incompatible.types.1 72.7 -// key: compiler.misc.no.conforming.instance.exists 72.8 +// key: compiler.misc.infer.no.conforming.instance.exists 72.9 // key: compiler.err.prob.found.req 72.10 72.11 class IncompatibleTypes1<V> {
73.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 73.2 +++ b/test/tools/javac/diags/examples/InferArgsLengthMismatch.java Tue Oct 12 12:52:49 2010 -0700 73.3 @@ -0,0 +1,30 @@ 73.4 +/* 73.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 73.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 73.7 + * 73.8 + * This code is free software; you can redistribute it and/or modify it 73.9 + * under the terms of the GNU General Public License version 2 only, as 73.10 + * published by the Free Software Foundation. 73.11 + * 73.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 73.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 73.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 73.15 + * version 2 for more details (a copy is included in the LICENSE file that 73.16 + * accompanied this code). 73.17 + * 73.18 + * You should have received a copy of the GNU General Public License version 73.19 + * 2 along with this work; if not, write to the Free Software Foundation, 73.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 73.21 + * 73.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 73.23 + * or visit www.oracle.com if you need additional information or have any 73.24 + * questions. 73.25 + */ 73.26 + 73.27 +// key: compiler.err.cant.apply.symbol.1 73.28 +// key: compiler.misc.infer.arg.length.mismatch 73.29 + 73.30 +class InferArgsLengthMismatch { 73.31 + <X extends Number> void m(X x1, X x2) {} 73.32 + { this.m(1); } 73.33 +}
74.1 --- a/test/tools/javac/diags/examples/KindnameConstructor.java Thu Oct 07 15:12:31 2010 -0700 74.2 +++ b/test/tools/javac/diags/examples/KindnameConstructor.java Tue Oct 12 12:52:49 2010 -0700 74.3 @@ -24,7 +24,9 @@ 74.4 // key: compiler.misc.kindname.constructor 74.5 // key: compiler.misc.kindname.class 74.6 // key: compiler.misc.no.args 74.7 -// key: compiler.err.cant.apply.symbol 74.8 +// key: compiler.err.cant.apply.symbol.1 74.9 +// key: compiler.misc.arg.length.mismatch 74.10 +// key: compiler.misc.no.conforming.assignment.exists 74.11 // key: compiler.misc.count.error.plural 74.12 // run: backdoor 74.13
75.1 --- a/test/tools/javac/diags/examples/NoArgs.java Thu Oct 07 15:12:31 2010 -0700 75.2 +++ b/test/tools/javac/diags/examples/NoArgs.java Tue Oct 12 12:52:49 2010 -0700 75.3 @@ -22,7 +22,8 @@ 75.4 */ 75.5 75.6 // key: compiler.misc.no.args 75.7 -// key: compiler.err.cant.apply.symbol 75.8 +// key: compiler.err.cant.apply.symbol.1 75.9 +// key: compiler.misc.arg.length.mismatch 75.10 // run: simple 75.11 75.12 class X {
76.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 76.2 +++ b/test/tools/javac/diags/examples/VarargsArgumentMismatch.java Tue Oct 12 12:52:49 2010 -0700 76.3 @@ -0,0 +1,30 @@ 76.4 +/* 76.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 76.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 76.7 + * 76.8 + * This code is free software; you can redistribute it and/or modify it 76.9 + * under the terms of the GNU General Public License version 2 only, as 76.10 + * published by the Free Software Foundation. 76.11 + * 76.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 76.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 76.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 76.15 + * version 2 for more details (a copy is included in the LICENSE file that 76.16 + * accompanied this code). 76.17 + * 76.18 + * You should have received a copy of the GNU General Public License version 76.19 + * 2 along with this work; if not, write to the Free Software Foundation, 76.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 76.21 + * 76.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 76.23 + * or visit www.oracle.com if you need additional information or have any 76.24 + * questions. 76.25 + */ 76.26 + 76.27 +// key: compiler.err.cant.apply.symbol.1 76.28 +// key: compiler.misc.varargs.argument.mismatch 76.29 + 76.30 +class VarargsArgumentMismatch { 76.31 + void m(String s, Integer... is) {} 76.32 + { this.m("1", "2", "3"); } 76.33 +}
77.1 --- a/test/tools/javac/diags/examples/WhereCaptured.java Thu Oct 07 15:12:31 2010 -0700 77.2 +++ b/test/tools/javac/diags/examples/WhereCaptured.java Tue Oct 12 12:52:49 2010 -0700 77.3 @@ -25,7 +25,8 @@ 77.4 // key: compiler.misc.where.description.captured.1 77.5 // key: compiler.misc.where.description.typevar 77.6 // key: compiler.misc.where.typevar 77.7 -// key: compiler.err.cant.apply.symbol 77.8 +// key: compiler.err.cant.apply.symbol.1 77.9 +// key: compiler.misc.infer.no.conforming.assignment.exists 77.10 // key: compiler.misc.captured.type 77.11 // options: -XDdiags=where,simpleNames 77.12 // run: simple
78.1 --- a/test/tools/javac/diags/examples/WhereCaptured1.java Thu Oct 07 15:12:31 2010 -0700 78.2 +++ b/test/tools/javac/diags/examples/WhereCaptured1.java Tue Oct 12 12:52:49 2010 -0700 78.3 @@ -25,7 +25,8 @@ 78.4 // key: compiler.misc.where.description.captured.1 78.5 // key: compiler.misc.where.description.typevar 78.6 // key: compiler.misc.where.typevar 78.7 -// key: compiler.err.cant.apply.symbol 78.8 +// key: compiler.err.cant.apply.symbol.1 78.9 +// key: compiler.misc.infer.no.conforming.assignment.exists 78.10 // key: compiler.misc.captured.type 78.11 // key: compiler.misc.type.null 78.12 // options: -XDdiags=where,simpleNames
79.1 --- a/test/tools/javac/diags/examples/WhereTypeVar.java Thu Oct 07 15:12:31 2010 -0700 79.2 +++ b/test/tools/javac/diags/examples/WhereTypeVar.java Tue Oct 12 12:52:49 2010 -0700 79.3 @@ -24,7 +24,8 @@ 79.4 // key: compiler.misc.where.typevar 79.5 // key: compiler.misc.where.description.typevar.1 79.6 // key: compiler.misc.type.var 79.7 -// key: compiler.err.cant.apply.symbol 79.8 +// key: compiler.err.cant.apply.symbol.1 79.9 +// key: compiler.misc.no.conforming.assignment.exists 79.10 // options: -XDdiags=where,disambiguateTvars 79.11 // run: simple 79.12
80.1 --- a/test/tools/javac/generics/diamond/neg/Neg06.out Thu Oct 07 15:12:31 2010 -0700 80.2 +++ b/test/tools/javac/generics/diamond/neg/Neg06.out Tue Oct 12 12:52:49 2010 -0700 80.3 @@ -1,4 +1,4 @@ 80.4 -Neg06.java:18:36: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.IFoo<X>, Neg06.ISuperFoo<java.lang.String>) 80.5 -Neg06.java:19:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>) 80.6 -Neg06.java:20:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>) 80.7 +Neg06.java:18:36: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.IFoo<X>, Neg06.ISuperFoo<java.lang.String>) 80.8 +Neg06.java:19:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>) 80.9 +Neg06.java:20:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>) 80.10 3 errors
81.1 --- a/test/tools/javac/generics/inference/6315770/T6315770.out Thu Oct 07 15:12:31 2010 -0700 81.2 +++ b/test/tools/javac/generics/inference/6315770/T6315770.out Tue Oct 12 12:52:49 2010 -0700 81.3 @@ -1,3 +1,3 @@ 81.4 T6315770.java:16:42: compiler.err.undetermined.type.1: <T>T6315770<T>, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable) 81.5 -T6315770.java:17:40: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, T6315770<T>, T6315770<? super java.lang.String>)), <T>T6315770<T>, T6315770<? super java.lang.String> 81.6 +T6315770.java:17:40: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, T6315770<T>, T6315770<? super java.lang.String>)), <T>T6315770<T>, T6315770<? super java.lang.String> 81.7 2 errors
82.1 --- a/test/tools/javac/generics/inference/6611449/T6611449.out Thu Oct 07 15:12:31 2010 -0700 82.2 +++ b/test/tools/javac/generics/inference/6611449/T6611449.out Tue Oct 12 12:52:49 2010 -0700 82.3 @@ -1,5 +1,5 @@ 82.4 -T6611449.java:18:9: compiler.err.cant.resolve.location.args: kindname.constructor, T6611449, , int, kindname.class, T6611449<S> 82.5 -T6611449.java:19:9: compiler.err.cant.resolve.location.args: kindname.constructor, T6611449, , int,int, kindname.class, T6611449<S> 82.6 -T6611449.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m1, T, int, kindname.class, T6611449<S>, null 82.7 -T6611449.java:21:9: compiler.err.cant.apply.symbol: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, null 82.8 +T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S))} 82.9 +T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.infer.arg.length.mismatch))} 82.10 +T6611449.java:20:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, T, int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S) 82.11 +T6611449.java:21:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S) 82.12 4 errors
83.1 --- a/test/tools/javac/generics/inference/6638712/T6638712a.out Thu Oct 07 15:12:31 2010 -0700 83.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712a.out Tue Oct 12 12:52:49 2010 -0700 83.3 @@ -1,2 +1,2 @@ 83.4 -T6638712a.java:16:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, java.util.Comparator<T>, java.util.Comparator<java.lang.String>)), <T>java.util.Comparator<T>, java.util.Comparator<java.lang.String> 83.5 +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<T>, java.util.Comparator<java.lang.String>)), <T>java.util.Comparator<T>, java.util.Comparator<java.lang.String> 83.6 1 error
84.1 --- a/test/tools/javac/generics/inference/6638712/T6638712b.out Thu Oct 07 15:12:31 2010 -0700 84.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712b.out Tue Oct 12 12:52:49 2010 -0700 84.3 @@ -1,2 +1,2 @@ 84.4 -T6638712b.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, T, java.lang.String)), <T>T, java.lang.String 84.5 +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>T, java.lang.String 84.6 1 error
85.1 --- a/test/tools/javac/generics/inference/6638712/T6638712c.out Thu Oct 07 15:12:31 2010 -0700 85.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712c.out Tue Oct 12 12:52:49 2010 -0700 85.3 @@ -1,2 +1,2 @@ 85.4 -T6638712c.java:16:9: compiler.err.cant.apply.symbol: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, null 85.5 +T6638712c.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, (compiler.misc.inferred.do.not.conform.to.params: java.lang.Enum[],java.util.Comparator<? super java.lang.Enum>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>) 85.6 1 error
86.1 --- a/test/tools/javac/generics/inference/6638712/T6638712d.out Thu Oct 07 15:12:31 2010 -0700 86.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712d.out Tue Oct 12 12:52:49 2010 -0700 86.3 @@ -1,2 +1,2 @@ 86.4 -T6638712d.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, null 86.5 +T6638712d.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, (compiler.misc.inferred.do.not.conform.to.params: java.lang.String,java.util.List<java.util.List<java.lang.String>>, int,java.util.List<java.util.List<java.lang.String>>) 86.6 1 error
87.1 --- a/test/tools/javac/generics/inference/6638712/T6638712e.out Thu Oct 07 15:12:31 2010 -0700 87.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712e.out Tue Oct 12 12:52:49 2010 -0700 87.3 @@ -1,2 +1,2 @@ 87.4 -T6638712e.java:17:27: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: X, T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String>)), <X>T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String> 87.5 +T6638712e.java:17:27: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: X, T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String>)), <X>T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String> 87.6 1 error
88.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 88.2 +++ b/test/tools/javac/lib/JavacTestingAbstractProcessor.java Tue Oct 12 12:52:49 2010 -0700 88.3 @@ -0,0 +1,100 @@ 88.4 +/* 88.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 88.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 88.7 + * 88.8 + * This code is free software; you can redistribute it and/or modify it 88.9 + * under the terms of the GNU General Public License version 2 only, as 88.10 + * published by the Free Software Foundation. 88.11 + * 88.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 88.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 88.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 88.15 + * version 2 for more details (a copy is included in the LICENSE file that 88.16 + * accompanied this code). 88.17 + * 88.18 + * You should have received a copy of the GNU General Public License version 88.19 + * 2 along with this work; if not, write to the Free Software Foundation, 88.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 88.21 + * 88.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 88.23 + * or visit www.oracle.com if you need additional information or have any 88.24 + * questions. 88.25 + */ 88.26 + 88.27 +import java.util.*; 88.28 +import javax.annotation.processing.*; 88.29 +import javax.lang.model.SourceVersion; 88.30 +import static javax.lang.model.SourceVersion.*; 88.31 +import javax.lang.model.element.*; 88.32 +import javax.lang.model.util.*; 88.33 + 88.34 +/** 88.35 + * An abstract annotation processor tailored to javac regression testing. 88.36 + */ 88.37 +public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { 88.38 + private static final Set<String> allAnnotations; 88.39 + 88.40 + static { 88.41 + Set<String> tmp = new HashSet<>(); 88.42 + tmp.add("*"); 88.43 + allAnnotations = Collections.unmodifiableSet(tmp); 88.44 + } 88.45 + 88.46 + protected Elements eltUtils; 88.47 + protected Elements elements; 88.48 + protected Types typeUtils; 88.49 + protected Types types; 88.50 + protected Filer filer; 88.51 + protected Messager messager; 88.52 + protected Map<String, String> options; 88.53 + 88.54 + /** 88.55 + * Constructor for subclasses to call. 88.56 + */ 88.57 + protected JavacTestingAbstractProcessor() { 88.58 + super(); 88.59 + } 88.60 + 88.61 + /** 88.62 + * Return the latest source version. Unless this method is 88.63 + * overridden, an {@code IllegalStateException} will be thrown if a 88.64 + * subclass has a {@code SupportedSourceVersion} annotation. 88.65 + */ 88.66 + @Override 88.67 + public SourceVersion getSupportedSourceVersion() { 88.68 + SupportedSourceVersion ssv = this.getClass().getAnnotation(SupportedSourceVersion.class); 88.69 + if (ssv != null) 88.70 + throw new IllegalStateException("SupportedSourceVersion annotation not supported here."); 88.71 + 88.72 + return SourceVersion.latest(); 88.73 + } 88.74 + 88.75 + /** 88.76 + * If the processor class is annotated with {@link 88.77 + * SupportedAnnotationTypes}, return an unmodifiable set with the 88.78 + * same set of strings as the annotation. If the class is not so 88.79 + * annotated, a one-element set containing {@code "*"} is returned 88.80 + * to indicate all annotations are processed. 88.81 + * 88.82 + * @return the names of the annotation types supported by this 88.83 + * processor, or an empty set if none 88.84 + */ 88.85 + @Override 88.86 + public Set<String> getSupportedAnnotationTypes() { 88.87 + SupportedAnnotationTypes sat = this.getClass().getAnnotation(SupportedAnnotationTypes.class); 88.88 + if (sat != null) 88.89 + return super.getSupportedAnnotationTypes(); 88.90 + else 88.91 + return allAnnotations; 88.92 + } 88.93 + 88.94 + @Override 88.95 + public void init(ProcessingEnvironment processingEnv) { 88.96 + super.init(processingEnv); 88.97 + elements = eltUtils = processingEnv.getElementUtils(); 88.98 + types = typeUtils = processingEnv.getTypeUtils(); 88.99 + filer = processingEnv.getFiler(); 88.100 + messager = processingEnv.getMessager(); 88.101 + options = processingEnv.getOptions(); 88.102 + } 88.103 +}
89.1 --- a/test/tools/javac/processing/6348499/A.java Thu Oct 07 15:12:31 2010 -0700 89.2 +++ b/test/tools/javac/processing/6348499/A.java Tue Oct 12 12:52:49 2010 -0700 89.3 @@ -1,5 +1,5 @@ 89.4 /* 89.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 89.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 89.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 89.8 * 89.9 * This code is free software; you can redistribute it and/or modify it 89.10 @@ -27,10 +27,8 @@ 89.11 import javax.lang.model.*; 89.12 import javax.lang.model.element.*; 89.13 89.14 -@SupportedAnnotationTypes("*") 89.15 -public class A extends AbstractProcessor { 89.16 +public class A extends JavacTestingAbstractProcessor { 89.17 public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) { 89.18 - Filer filer = processingEnv.getFiler(); 89.19 try { 89.20 OutputStream out = filer.createClassFile(getClass().getName()+"_0").openOutputStream(); 89.21 out.close(); 89.22 @@ -39,8 +37,4 @@ 89.23 } 89.24 return true; 89.25 } 89.26 - @Override 89.27 - public SourceVersion getSupportedSourceVersion() { 89.28 - return SourceVersion.latest(); 89.29 - } 89.30 }
90.1 --- a/test/tools/javac/processing/6348499/T6348499.java Thu Oct 07 15:12:31 2010 -0700 90.2 +++ b/test/tools/javac/processing/6348499/T6348499.java Tue Oct 12 12:52:49 2010 -0700 90.3 @@ -1,5 +1,5 @@ 90.4 /* 90.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 90.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 90.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 90.8 * 90.9 * This code is free software; you can redistribute it and/or modify it 90.10 @@ -25,7 +25,8 @@ 90.11 * @test 90.12 * @bug 6441871 90.13 * @summary javac crashes at com.sun.tools.javac.jvm.ClassReader$BadClassFile 90.14 - * @build A 90.15 + * @library ../../lib 90.16 + * @build JavacTestingAbstractProcessor A 90.17 * @run main T6348499 90.18 */ 90.19 90.20 @@ -54,7 +55,6 @@ 90.21 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java"))); 90.22 Iterable<String> opts = Arrays.asList("-proc:only", 90.23 "-processor", "A", 90.24 - "-source", "1.6", 90.25 "-processorpath", testClasses); 90.26 StringWriter out = new StringWriter(); 90.27 JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
91.1 --- a/test/tools/javac/processing/6359313/T6359313.java Thu Oct 07 15:12:31 2010 -0700 91.2 +++ b/test/tools/javac/processing/6359313/T6359313.java Tue Oct 12 12:52:49 2010 -0700 91.3 @@ -1,5 +1,5 @@ 91.4 /* 91.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 91.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 91.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 91.8 * 91.9 * This code is free software; you can redistribute it and/or modify it 91.10 @@ -26,6 +26,8 @@ 91.11 * @bug 6359313 91.12 * @summary error compiling annotated package 91.13 * @author Peter von der Ah\u00e9 91.14 + * @library ../../lib 91.15 + * @build JavacTestingAbstractProcessor 91.16 * @compile T6359313.java 91.17 * @compile -processor T6359313 package-info.java Foo.java 91.18 */ 91.19 @@ -37,7 +39,7 @@ 91.20 import javax.lang.model.element.TypeElement; 91.21 91.22 @SupportedAnnotationTypes("Foo") 91.23 -public class T6359313 extends AbstractProcessor { 91.24 +public class T6359313 extends JavacTestingAbstractProcessor { 91.25 public boolean process(Set<? extends TypeElement> annotations, 91.26 RoundEnvironment roundEnvironment) { 91.27 return true;
92.1 --- a/test/tools/javac/processing/6365040/ProcBar.java Thu Oct 07 15:12:31 2010 -0700 92.2 +++ b/test/tools/javac/processing/6365040/ProcBar.java Tue Oct 12 12:52:49 2010 -0700 92.3 @@ -1,5 +1,5 @@ 92.4 /* 92.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 92.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 92.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 92.8 * 92.9 * This code is free software; you can redistribute it and/or modify it 92.10 @@ -31,13 +31,11 @@ 92.11 /** 92.12 * Second of several processors to run. 92.13 */ 92.14 -@SupportedAnnotationTypes("*") 92.15 -public class ProcBar extends AbstractProcessor { 92.16 +public class ProcBar extends JavacTestingAbstractProcessor { 92.17 public boolean process(Set<? extends TypeElement> annotations, 92.18 RoundEnvironment roundEnvironment) { 92.19 if (!roundEnvironment.processingOver()) 92.20 - processingEnv.getMessager().printMessage(NOTE, 92.21 - "Hello from ProcBar"); 92.22 + messager.printMessage(NOTE, "Hello from ProcBar"); 92.23 return false; 92.24 } 92.25 }
93.1 --- a/test/tools/javac/processing/6365040/ProcFoo.java Thu Oct 07 15:12:31 2010 -0700 93.2 +++ b/test/tools/javac/processing/6365040/ProcFoo.java Tue Oct 12 12:52:49 2010 -0700 93.3 @@ -1,5 +1,5 @@ 93.4 /* 93.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 93.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 93.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 93.8 * 93.9 * This code is free software; you can redistribute it and/or modify it 93.10 @@ -31,13 +31,11 @@ 93.11 /** 93.12 * First of several processors to run. 93.13 */ 93.14 -@SupportedAnnotationTypes("*") 93.15 -public class ProcFoo extends AbstractProcessor { 93.16 +public class ProcFoo extends JavacTestingAbstractProcessor { 93.17 public boolean process(Set<? extends TypeElement> annotations, 93.18 RoundEnvironment roundEnvironment) { 93.19 if (!roundEnvironment.processingOver()) 93.20 - processingEnv.getMessager().printMessage(NOTE, 93.21 - "Hello from ProcFoo"); 93.22 + messager.printMessage(NOTE, "Hello from ProcFoo"); 93.23 return false; 93.24 } 93.25 }
94.1 --- a/test/tools/javac/processing/6365040/T6365040.java Thu Oct 07 15:12:31 2010 -0700 94.2 +++ b/test/tools/javac/processing/6365040/T6365040.java Tue Oct 12 12:52:49 2010 -0700 94.3 @@ -1,5 +1,5 @@ 94.4 /* 94.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 94.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 94.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 94.8 * 94.9 * This code is free software; you can redistribute it and/or modify it 94.10 @@ -26,6 +26,8 @@ 94.11 * @bug 6365040 6358129 94.12 * @summary Test -processor foo,bar,baz 94.13 * @author Joseph D. Darcy 94.14 + * @library ../../lib 94.15 + * @build JavacTestingAbstractProcessor 94.16 * @compile ProcFoo.java 94.17 * @compile ProcBar.java 94.18 * @compile T6365040.java 94.19 @@ -43,13 +45,11 @@ 94.20 import javax.lang.model.element.TypeElement; 94.21 import static javax.tools.Diagnostic.Kind.*; 94.22 94.23 -@SupportedAnnotationTypes("*") 94.24 -public class T6365040 extends AbstractProcessor { 94.25 +public class T6365040 extends JavacTestingAbstractProcessor { 94.26 public boolean process(Set<? extends TypeElement> annotations, 94.27 RoundEnvironment roundEnvironment) { 94.28 if (!roundEnvironment.processingOver()) 94.29 - processingEnv.getMessager().printMessage(NOTE, 94.30 - "Hello from T6365040"); 94.31 + messager.printMessage(NOTE, "Hello from T6365040"); 94.32 return true; 94.33 } 94.34 }
95.1 --- a/test/tools/javac/processing/6413690/T6413690.java Thu Oct 07 15:12:31 2010 -0700 95.2 +++ b/test/tools/javac/processing/6413690/T6413690.java Tue Oct 12 12:52:49 2010 -0700 95.3 @@ -1,5 +1,5 @@ 95.4 /* 95.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 95.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 95.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 95.8 * 95.9 * This code is free software; you can redistribute it and/or modify it 95.10 @@ -26,6 +26,8 @@ 95.11 * @bug 6413690 6380018 95.12 * @summary JavacProcessingEnvironment does not enter trees from preceding rounds 95.13 * @author Peter von der Ah\u00e9 95.14 + * @library ../../lib 95.15 + * @build JavacTestingAbstractProcessor 95.16 * @compile T6413690.java 95.17 * @compile -XDfatalEnterError -verbose -processor T6413690 src/Super.java TestMe.java 95.18 */ 95.19 @@ -42,11 +44,9 @@ 95.20 import javax.lang.model.util.Elements; 95.21 95.22 @SupportedAnnotationTypes("TestMe") 95.23 -public class T6413690 extends AbstractProcessor { 95.24 +public class T6413690 extends JavacTestingAbstractProcessor { 95.25 public boolean process(Set<? extends TypeElement> annotations, 95.26 RoundEnvironment roundEnvironment) { 95.27 - Elements elements = processingEnv.getElementUtils(); 95.28 - Filer filer = processingEnv.getFiler(); 95.29 TypeElement testMe = elements.getTypeElement(TestMe.class.getName()); 95.30 Set<? extends Element> supers = roundEnvironment.getElementsAnnotatedWith(testMe); 95.31 try {
96.1 --- a/test/tools/javac/processing/6414633/A.java Thu Oct 07 15:12:31 2010 -0700 96.2 +++ b/test/tools/javac/processing/6414633/A.java Tue Oct 12 12:52:49 2010 -0700 96.3 @@ -1,5 +1,5 @@ 96.4 /* 96.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 96.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 96.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 96.8 * 96.9 * This code is free software; you can redistribute it and/or modify it 96.10 @@ -29,9 +29,8 @@ 96.11 import javax.lang.model.element.*; 96.12 import javax.tools.*; 96.13 96.14 -@SupportedAnnotationTypes("*") 96.15 -public class A extends AbstractProcessor { 96.16 - 96.17 +@SuppressWarnings("") 96.18 +public class A extends JavacTestingAbstractProcessor { 96.19 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 96.20 Messager m = processingEnv.getMessager(); 96.21 for (TypeElement anno: annotations) { 96.22 @@ -42,8 +41,6 @@ 96.23 return true; 96.24 } 96.25 96.26 - @Override 96.27 - public SourceVersion getSupportedSourceVersion() { 96.28 - return SourceVersion.latest(); 96.29 - } 96.30 + @SuppressWarnings("") 96.31 + private void foo() {} 96.32 }
97.1 --- a/test/tools/javac/processing/6414633/T6414633.java Thu Oct 07 15:12:31 2010 -0700 97.2 +++ b/test/tools/javac/processing/6414633/T6414633.java Tue Oct 12 12:52:49 2010 -0700 97.3 @@ -1,5 +1,5 @@ 97.4 /* 97.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 97.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 97.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 97.8 * 97.9 * This code is free software; you can redistribute it and/or modify it 97.10 @@ -25,7 +25,8 @@ 97.11 * @test 97.12 * @bug 6414633 6440109 97.13 * @summary Only the first processor message at a source location is reported 97.14 - * @build A T6414633 97.15 + * @library ../../lib 97.16 + * @build JavacTestingAbstractProcessor A T6414633 97.17 * @run main T6414633 97.18 */ 97.19 97.20 @@ -55,8 +56,7 @@ 97.21 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java"))); 97.22 String[] opts = { "-proc:only", 97.23 "-processor", A.class.getName(), 97.24 - "-source", "1.6", 97.25 - "-classpath", testClasses }; 97.26 + "-classpath", testClasses + System.getProperty("path.separator") + "../../lib" }; 97.27 JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files); 97.28 task.call(); 97.29
98.1 --- a/test/tools/javac/processing/6430209/T6430209.java Thu Oct 07 15:12:31 2010 -0700 98.2 +++ b/test/tools/javac/processing/6430209/T6430209.java Tue Oct 12 12:52:49 2010 -0700 98.3 @@ -1,5 +1,5 @@ 98.4 /* 98.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 98.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 98.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 98.8 * 98.9 * This code is free software; you can redistribute it and/or modify it 98.10 @@ -25,7 +25,8 @@ 98.11 * @test 98.12 * @bug 6441871 98.13 * @summary spurious compiler error elicited by packageElement.getEnclosedElements() 98.14 - * @build b6341534 98.15 + * @library ../../lib 98.16 + * @build JavacTestingAbstractProcessor b6341534 98.17 * @run main T6430209 98.18 */ 98.19 98.20 @@ -54,7 +55,7 @@ 98.21 // run annotation processor b6341534 so we can check diagnostics 98.22 // -proc:only -processor b6341534 -cp . ./src/*.java 98.23 String testSrc = System.getProperty("test.src", "."); 98.24 - String testClasses = System.getProperty("test.classes"); 98.25 + String testClasses = System.getProperty("test.classes") + System.getProperty("path.separator") + "../../lib"; 98.26 JavacTool tool = JavacTool.create(); 98.27 MyDiagListener dl = new MyDiagListener(); 98.28 StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
99.1 --- a/test/tools/javac/processing/6430209/b6341534.java Thu Oct 07 15:12:31 2010 -0700 99.2 +++ b/test/tools/javac/processing/6430209/b6341534.java Tue Oct 12 12:52:49 2010 -0700 99.3 @@ -1,5 +1,5 @@ 99.4 /* 99.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 99.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 99.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 99.8 * 99.9 * This code is free software; you can redistribute it and/or modify it 99.10 @@ -30,16 +30,9 @@ 99.11 import java.util.*; 99.12 import java.util.Set; 99.13 99.14 -@SupportedAnnotationTypes({"*"}) 99.15 -public class b6341534 extends AbstractProcessor { 99.16 +public class b6341534 extends JavacTestingAbstractProcessor { 99.17 static int r = 0; 99.18 - static Elements E = null; 99.19 - static Messager msgr = null; 99.20 - public void init(ProcessingEnvironment penv) { 99.21 - processingEnv = penv; 99.22 - msgr = penv.getMessager(); 99.23 - E = penv.getElementUtils(); 99.24 - } 99.25 + 99.26 //Create directory 'dir1' and a test class in dir1 99.27 public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) 99.28 { 99.29 @@ -49,13 +42,13 @@ 99.30 System.out.println("Round"+r+ ": " + t.toString()); 99.31 99.32 try { 99.33 - PackageElement PE = E.getPackageElement("dir1"); 99.34 + PackageElement PE = eltUtils.getPackageElement("dir1"); 99.35 List<? extends Element> LEE = PE.getEnclosedElements(); /* <=This line elicits the error message. */ 99.36 for(Element e : LEE) 99.37 System.out.println("found " + e.toString() + " in dir1."); 99.38 } 99.39 catch(NullPointerException npe) { 99.40 - msgr.printMessage(ERROR,npe.toString()); 99.41 + messager.printMessage(ERROR,npe.toString()); 99.42 //npe.printStackTrace(); 99.43 return false; 99.44 } 99.45 @@ -63,13 +56,8 @@ 99.46 // on round 1, expect errorRaised == false && processingOver == false 99.47 // on round 2, expect errorRaised == true && processingOver == true 99.48 if( renv.errorRaised() != renv.processingOver()) { 99.49 - msgr.printMessage(ERROR, "FAILED"); 99.50 + messager.printMessage(ERROR, "FAILED"); 99.51 } 99.52 return true; 99.53 } 99.54 - 99.55 - @Override 99.56 - public SourceVersion getSupportedSourceVersion() { 99.57 - return SourceVersion.latest(); 99.58 - } 99.59 }
100.1 --- a/test/tools/javac/processing/6499119/ClassProcessor.java Thu Oct 07 15:12:31 2010 -0700 100.2 +++ b/test/tools/javac/processing/6499119/ClassProcessor.java Tue Oct 12 12:52:49 2010 -0700 100.3 @@ -32,20 +32,17 @@ 100.4 * @test 100.5 * @bug 6499119 100.6 * @summary Created package-info class file modeled improperly 100.7 + * @library ../../lib 100.8 + * @build JavacTestingAbstractProcessor 100.9 * @compile ClassProcessor.java package-info.java 100.10 * @compile/process -cp . -processor ClassProcessor -Akind=java java.lang.Object 100.11 * @compile/process -cp . -processor ClassProcessor -Akind=class java.lang.Object 100.12 */ 100.13 100.14 @SupportedOptions({ "gen", "expect" }) 100.15 -@SupportedAnnotationTypes({"*"}) 100.16 -public class ClassProcessor extends AbstractProcessor { 100.17 +public class ClassProcessor extends JavacTestingAbstractProcessor { 100.18 int round = 1; 100.19 100.20 - public SourceVersion getSupportedSourceVersion() { 100.21 - return SourceVersion.latest(); 100.22 - } 100.23 - 100.24 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 100.25 if (round == 1) { 100.26 System.out.println("-- Round 1 --"); 100.27 @@ -71,8 +68,6 @@ 100.28 } 100.29 100.30 private void createPackageFile() { 100.31 - Filer filer = processingEnv.getFiler(); 100.32 - 100.33 String kind = processingEnv.getOptions().get("kind"); 100.34 100.35 File pkgInfo; 100.36 @@ -125,7 +120,6 @@ 100.37 } 100.38 100.39 private void error(String msg) { 100.40 - Messager messager = processingEnv.getMessager(); 100.41 messager.printMessage(Kind.ERROR, msg); 100.42 } 100.43 }
101.1 --- a/test/tools/javac/processing/6511613/DummyProcessor.java Thu Oct 07 15:12:31 2010 -0700 101.2 +++ b/test/tools/javac/processing/6511613/DummyProcessor.java Tue Oct 12 12:52:49 2010 -0700 101.3 @@ -26,15 +26,10 @@ 101.4 import javax.lang.model.element.*; 101.5 import java.util.Set; 101.6 101.7 -@SupportedAnnotationTypes("*") 101.8 -public class DummyProcessor extends AbstractProcessor { 101.9 +public class DummyProcessor extends JavacTestingAbstractProcessor { 101.10 public boolean process(Set<? extends TypeElement> annotations, 101.11 RoundEnvironment roundEnv) { 101.12 return true; 101.13 } 101.14 - @Override 101.15 - public SourceVersion getSupportedSourceVersion() { 101.16 - return SourceVersion.latest(); 101.17 - } 101.18 } 101.19
102.1 --- a/test/tools/javac/processing/6511613/clss41701.java Thu Oct 07 15:12:31 2010 -0700 102.2 +++ b/test/tools/javac/processing/6511613/clss41701.java Tue Oct 12 12:52:49 2010 -0700 102.3 @@ -26,7 +26,8 @@ 102.4 * @bug 6511613 102.5 * @summary javac unexpectedly doesn't fail in some cases if an annotation processor specified 102.6 * 102.7 - * @build DummyProcessor 102.8 + * @library ../../lib 102.9 + * @build JavacTestingAbstractProcessor DummyProcessor 102.10 * @compile/fail clss41701.java 102.11 * @compile/fail -processor DummyProcessor clss41701.java 102.12 */
103.1 --- a/test/tools/javac/processing/6512707/T6512707.java Thu Oct 07 15:12:31 2010 -0700 103.2 +++ b/test/tools/javac/processing/6512707/T6512707.java Tue Oct 12 12:52:49 2010 -0700 103.3 @@ -1,5 +1,5 @@ 103.4 /* 103.5 - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. 103.6 + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 103.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 103.8 * 103.9 * This code is free software; you can redistribute it and/or modify it 103.10 @@ -26,8 +26,9 @@ 103.11 * @bug 6512707 103.12 * @summary "incompatible types" after (unrelated) annotation processing 103.13 * @author Peter Runge 103.14 + * @library ../../lib 103.15 + * @build JavacTestingAbstractProcessor 103.16 * @compile T6512707.java 103.17 - * 103.18 * @compile -processor T6512707 TestAnnotation.java 103.19 */ 103.20 103.21 @@ -41,16 +42,10 @@ 103.22 * Dummy processor to force bug 6512707 to show - it does not matter what 103.23 * the annotation processor does for this bug. 103.24 */ 103.25 -@SupportedAnnotationTypes("*") 103.26 -public class T6512707 extends AbstractProcessor { 103.27 +public class T6512707 extends JavacTestingAbstractProcessor { 103.28 103.29 public boolean process(Set<? extends TypeElement> annotations, 103.30 RoundEnvironment roundEnv) { 103.31 - return(false); 103.32 - } 103.33 - 103.34 - @Override 103.35 - public SourceVersion getSupportedSourceVersion() { 103.36 - return SourceVersion.latest(); 103.37 + return false; 103.38 } 103.39 }
104.1 --- a/test/tools/javac/processing/6634138/T6634138.java Thu Oct 07 15:12:31 2010 -0700 104.2 +++ b/test/tools/javac/processing/6634138/T6634138.java Tue Oct 12 12:52:49 2010 -0700 104.3 @@ -26,6 +26,8 @@ 104.4 * @bug 6634138 104.5 * @author Joseph D. Darcy 104.6 * @summary Verify source files output after processing is over are compiled 104.7 + * @library ../../lib 104.8 + * @build JavacTestingAbstractProcessor 104.9 * @compile T6634138.java 104.10 * @compile -processor T6634138 Dummy.java 104.11 * @run main ExerciseDependency 104.12 @@ -44,10 +46,7 @@ 104.13 import javax.lang.model.element.*; 104.14 import javax.lang.model.util.*; 104.15 104.16 -@SupportedAnnotationTypes("*") 104.17 -public class T6634138 extends AbstractProcessor { 104.18 - private Filer filer; 104.19 - 104.20 +public class T6634138 extends JavacTestingAbstractProcessor { 104.21 public boolean process(Set<? extends TypeElement> annotations, 104.22 RoundEnvironment roundEnvironment) { 104.23 // Write out files *after* processing is over. 104.24 @@ -77,16 +76,6 @@ 104.25 } 104.26 return true; 104.27 } 104.28 - 104.29 - @Override 104.30 - public SourceVersion getSupportedSourceVersion() { 104.31 - return SourceVersion.latest(); 104.32 - } 104.33 - 104.34 - public void init(ProcessingEnvironment processingEnv) { 104.35 - super.init(processingEnv); 104.36 - filer = processingEnv.getFiler(); 104.37 - } 104.38 } 104.39 104.40
105.1 --- a/test/tools/javac/processing/T6439826.java Thu Oct 07 15:12:31 2010 -0700 105.2 +++ b/test/tools/javac/processing/T6439826.java Tue Oct 12 12:52:49 2010 -0700 105.3 @@ -1,5 +1,5 @@ 105.4 /* 105.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 105.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 105.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 105.8 * 105.9 * This code is free software; you can redistribute it and/or modify it 105.10 @@ -48,8 +48,7 @@ 105.11 StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null); 105.12 Iterable<? extends JavaFileObject> files = 105.13 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6439826.class.getName()+".java"))); 105.14 - Iterable<String> opts = Arrays.asList("-source","1.6", 105.15 - "-proc:only", 105.16 + Iterable<String> opts = Arrays.asList("-proc:only", 105.17 "-processor", "T6439826", 105.18 "-processorpath", testClasses); 105.19 StringWriter out = new StringWriter();
106.1 --- a/test/tools/javac/processing/T6920317.java Thu Oct 07 15:12:31 2010 -0700 106.2 +++ b/test/tools/javac/processing/T6920317.java Tue Oct 12 12:52:49 2010 -0700 106.3 @@ -25,6 +25,7 @@ 106.4 * @test 106.5 * @bug 6920317 106.6 * @summary package-info.java file has to be specified on the javac cmdline, else it will not be avail 106.7 + * @library ../lib 106.8 */ 106.9 106.10 import java.io.*; 106.11 @@ -349,12 +350,7 @@ 106.12 /** Annotation processor used to verify the expected value for the 106.13 package annotations found by javac. */ 106.14 @SupportedOptions({ "gen", "expect" }) 106.15 - @SupportedAnnotationTypes({"*"}) 106.16 - public static class Processor extends AbstractProcessor { 106.17 - public SourceVersion getSupportedSourceVersion() { 106.18 - return SourceVersion.latest(); 106.19 - } 106.20 - 106.21 + public static class Processor extends JavacTestingAbstractProcessor { 106.22 public boolean process(Set<? extends TypeElement> annots, RoundEnvironment renv) { 106.23 round++; 106.24 System.err.println("Round " + round + " annots:" + annots + " rootElems:" + renv.getRootElements());
107.1 --- a/test/tools/javac/processing/Xprint.java Thu Oct 07 15:12:31 2010 -0700 107.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 107.3 @@ -1,42 +0,0 @@ 107.4 -/* 107.5 - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 107.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 107.7 - * 107.8 - * This code is free software; you can redistribute it and/or modify it 107.9 - * under the terms of the GNU General Public License version 2 only, as 107.10 - * published by the Free Software Foundation. 107.11 - * 107.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 107.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 107.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 107.15 - * version 2 for more details (a copy is included in the LICENSE file that 107.16 - * accompanied this code). 107.17 - * 107.18 - * You should have received a copy of the GNU General Public License version 107.19 - * 2 along with this work; if not, write to the Free Software Foundation, 107.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 107.21 - * 107.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 107.23 - * or visit www.oracle.com if you need additional information or have any 107.24 - * questions. 107.25 - */ 107.26 - 107.27 -/* 107.28 - * @test 107.29 - * @bug 6266828 107.30 - * @summary JSR 269: Java Language Model API 107.31 - * @author Peter von der Ah\u00e9 107.32 - */ 107.33 -import javax.tools.JavaCompiler; 107.34 -import javax.tools.ToolProvider; 107.35 - 107.36 -public class Xprint { 107.37 - public static void main(String[] args) { 107.38 - JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); 107.39 - javac.run(System.in, null, null, 107.40 - "-Xprint", 107.41 - "com.sun.tools.javac.code.Types", 107.42 - "com.sun.tools.javac.parser.Parser", 107.43 - "java.util.EnumSet"); 107.44 - } 107.45 -}
108.1 --- a/test/tools/javac/processing/environment/TestSourceVersion.java Thu Oct 07 15:12:31 2010 -0700 108.2 +++ b/test/tools/javac/processing/environment/TestSourceVersion.java Tue Oct 12 12:52:49 2010 -0700 108.3 @@ -1,5 +1,5 @@ 108.4 /* 108.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 108.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 108.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 108.8 * 108.9 * This code is free software; you can redistribute it and/or modify it 108.10 @@ -26,6 +26,8 @@ 108.11 * @bug 6402506 108.12 * @summary Test that getSourceVersion works properly 108.13 * @author Joseph D. Darcy 108.14 + * @library ../../lib 108.15 + * @build JavacTestingAbstractProcessor 108.16 * @compile TestSourceVersion.java 108.17 * @compile -processor TestSourceVersion -proc:only -source 1.2 -AExpectedVersion=RELEASE_2 HelloWorld.java 108.18 * @compile -processor TestSourceVersion -proc:only -source 1.3 -AExpectedVersion=RELEASE_3 HelloWorld.java 108.19 @@ -52,9 +54,8 @@ 108.20 * This processor checks that ProcessingEnvironment.getSourceVersion() 108.21 * is consistent with the setting of the -source option. 108.22 */ 108.23 -@SupportedAnnotationTypes("*") 108.24 @SupportedOptions("ExpectedVersion") 108.25 -public class TestSourceVersion extends AbstractProcessor { 108.26 +public class TestSourceVersion extends JavacTestingAbstractProcessor { 108.27 108.28 public boolean process(Set<? extends TypeElement> annotations, 108.29 RoundEnvironment roundEnvironment) { 108.30 @@ -68,9 +69,4 @@ 108.31 108.32 return true; 108.33 } 108.34 - 108.35 - @Override 108.36 - public SourceVersion getSupportedSourceVersion() { 108.37 - return SourceVersion.latest(); 108.38 - } 108.39 }
109.1 --- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Thu Oct 07 15:12:31 2010 -0700 109.2 +++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Tue Oct 12 12:52:49 2010 -0700 109.3 @@ -1,5 +1,5 @@ 109.4 /* 109.5 - * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved. 109.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 109.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 109.8 * 109.9 * This code is free software; you can redistribute it and/or modify it 109.10 @@ -26,6 +26,8 @@ 109.11 * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 109.12 * @summary Tests that getElementsAnnotatedWith works properly. 109.13 * @author Joseph D. Darcy 109.14 + * @library ../../../lib 109.15 + * @build JavacTestingAbstractProcessor 109.16 * @compile TestElementsAnnotatedWith.java 109.17 * @compile InheritedAnnotation.java 109.18 * @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java 109.19 @@ -57,16 +59,13 @@ 109.20 * getElementsAnnotatedWith is consistent with the expected results 109.21 * stored in an AnnotatedElementInfo annotation. 109.22 */ 109.23 -@SupportedAnnotationTypes("*") 109.24 @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", expectedSize=0, names={}) 109.25 -public class TestElementsAnnotatedWith extends AbstractProcessor { 109.26 +public class TestElementsAnnotatedWith extends JavacTestingAbstractProcessor { 109.27 109.28 public boolean process(Set<? extends TypeElement> annotations, 109.29 RoundEnvironment roundEnvironment) { 109.30 - Elements elementUtils = processingEnv.getElementUtils(); 109.31 - 109.32 TypeElement annotatedElementInfoElement = 109.33 - elementUtils.getTypeElement("AnnotatedElementInfo"); 109.34 + elements.getTypeElement("AnnotatedElementInfo"); 109.35 Set<? extends Element> resultsMeta = Collections.emptySet(); 109.36 Set<? extends Element> resultsBase = Collections.emptySet(); 109.37 109.38 @@ -93,9 +92,7 @@ 109.39 109.40 resultsMeta = 109.41 roundEnvironment. 109.42 - getElementsAnnotatedWith(elementUtils. 109.43 - getTypeElement(annotatedElementInfo. 109.44 - annotationName())) ; 109.45 + getElementsAnnotatedWith(elements.getTypeElement(annotatedElementInfo.annotationName())); 109.46 109.47 System.err.println("Results: " + resultsMeta); 109.48 109.49 @@ -167,9 +164,4 @@ 109.50 throw new RuntimeException("Illegal argument exception not thrown"); 109.51 } catch(IllegalArgumentException iae) {} 109.52 } 109.53 - 109.54 - @Override 109.55 - public SourceVersion getSupportedSourceVersion() { 109.56 - return SourceVersion.latest(); 109.57 - } 109.58 }
110.1 --- a/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java Thu Oct 07 15:12:31 2010 -0700 110.2 +++ b/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java Tue Oct 12 12:52:49 2010 -0700 110.3 @@ -1,5 +1,5 @@ 110.4 /* 110.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 110.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 110.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 110.8 * 110.9 * This code is free software; you can redistribute it and/or modify it 110.10 @@ -26,6 +26,9 @@ 110.11 * @bug 6403459 110.12 * @summary Test that generating programs with syntax errors is a fatal condition 110.13 * @author Joseph D. Darcy 110.14 + * @library ../../lib 110.15 + * @build JavacTestingAbstractProcessor 110.16 + * @compile TestReturnCode.java 110.17 * @compile TestFatalityOfParseErrors.java 110.18 * @compile/fail -XprintRounds -processor TestFatalityOfParseErrors -proc:only TestFatalityOfParseErrors.java 110.19 */ 110.20 @@ -45,11 +48,8 @@ 110.21 * Write out an incomplete source file and observe that the next round 110.22 * is marked as an error. 110.23 */ 110.24 -@SupportedAnnotationTypes("*") 110.25 -public class TestFatalityOfParseErrors extends AbstractProcessor { 110.26 +public class TestFatalityOfParseErrors extends JavacTestingAbstractProcessor { 110.27 int round = 0; 110.28 - Messager messager; 110.29 - Filer filer; 110.30 110.31 public boolean process(Set<? extends TypeElement> annotations, 110.32 RoundEnvironment roundEnvironment) { 110.33 @@ -87,14 +87,4 @@ 110.34 } 110.35 return true; 110.36 } 110.37 - 110.38 - public SourceVersion getSupportedSourceVersion() { 110.39 - return SourceVersion.latest(); 110.40 - } 110.41 - 110.42 - public void init(ProcessingEnvironment processingEnv) { 110.43 - super.init(processingEnv); 110.44 - messager = processingEnv.getMessager(); 110.45 - filer = processingEnv.getFiler(); 110.46 - } 110.47 }
111.1 --- a/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java Thu Oct 07 15:12:31 2010 -0700 111.2 +++ b/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java Tue Oct 12 12:52:49 2010 -0700 111.3 @@ -1,5 +1,5 @@ 111.4 /* 111.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 111.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 111.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 111.8 * 111.9 * This code is free software; you can redistribute it and/or modify it 111.10 @@ -26,6 +26,8 @@ 111.11 * @bug 6406212 111.12 * @summary Test that annotation processor options with illegal syntax are rejected 111.13 * @author Joseph D. Darcy 111.14 + * @library ../../lib 111.15 + * @build JavacTestingAbstractProcessor 111.16 * @compile TestOptionSyntaxErrors.java 111.17 * @compile/fail -A TestOptionSyntaxErrors.java 111.18 * @compile/fail -A8adOption TestOptionSyntaxErrors.java 111.19 @@ -46,14 +48,9 @@ 111.20 /** 111.21 * No-op processor; should not be run. 111.22 */ 111.23 -@SupportedAnnotationTypes("*") 111.24 -public class TestOptionSyntaxErrors extends AbstractProcessor { 111.25 +public class TestOptionSyntaxErrors extends JavacTestingAbstractProcessor { 111.26 public boolean process(Set<? extends TypeElement> annotations, 111.27 RoundEnvironment roundEnvironment) { 111.28 return true; 111.29 } 111.30 - 111.31 - public SourceVersion getSupportedSourceVersion() { 111.32 - return SourceVersion.latest(); 111.33 - } 111.34 }
112.1 --- a/test/tools/javac/processing/errors/TestReturnCode.java Thu Oct 07 15:12:31 2010 -0700 112.2 +++ b/test/tools/javac/processing/errors/TestReturnCode.java Tue Oct 12 12:52:49 2010 -0700 112.3 @@ -1,5 +1,5 @@ 112.4 /* 112.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 112.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 112.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 112.8 * 112.9 * This code is free software; you can redistribute it and/or modify it 112.10 @@ -26,6 +26,8 @@ 112.11 * @bug 6403468 112.12 * @summary Test that an erroneous return code results from raising an error. 112.13 * @author Joseph D. Darcy 112.14 + * @library ../../lib 112.15 + * @build JavacTestingAbstractProcessor 112.16 * @compile TestReturnCode.java 112.17 * 112.18 * @compile -processor TestReturnCode -proc:only Foo.java 112.19 @@ -60,20 +62,17 @@ 112.20 * This processor raises errors or throws exceptions on different 112.21 * rounds to allow the return code to be test. 112.22 */ 112.23 -@SupportedAnnotationTypes("*") 112.24 @SupportedOptions({"ErrorOnFirst", 112.25 "ErrorOnLast", 112.26 "ExceptionOnFirst", 112.27 "ExceptionOnLast"}) 112.28 -public class TestReturnCode extends AbstractProcessor { 112.29 +public class TestReturnCode extends JavacTestingAbstractProcessor { 112.30 112.31 private boolean errorOnFirst; 112.32 private boolean errorOnLast; 112.33 private boolean exceptionOnFirst; 112.34 private boolean exceptionOnLast; 112.35 112.36 - private Messager messager; 112.37 - 112.38 public boolean process(Set<? extends TypeElement> annotations, 112.39 RoundEnvironment roundEnv) { 112.40 if (!roundEnv.processingOver()) { 112.41 @@ -103,11 +102,5 @@ 112.42 errorOnLast = keySet.contains("ErrorOnLast"); 112.43 exceptionOnFirst = keySet.contains("ExceptionOnFirst"); 112.44 exceptionOnLast = keySet.contains("ExceptionOnLast"); 112.45 - messager = processingEnv.getMessager(); 112.46 - } 112.47 - 112.48 - @Override 112.49 - public SourceVersion getSupportedSourceVersion() { 112.50 - return SourceVersion.latest(); 112.51 } 112.52 }
113.1 --- a/test/tools/javac/processing/filer/TestFilerConstraints.java Thu Oct 07 15:12:31 2010 -0700 113.2 +++ b/test/tools/javac/processing/filer/TestFilerConstraints.java Tue Oct 12 12:52:49 2010 -0700 113.3 @@ -1,5 +1,5 @@ 113.4 /* 113.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 113.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 113.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 113.8 * 113.9 * This code is free software; you can redistribute it and/or modify it 113.10 @@ -26,6 +26,7 @@ 113.11 * @bug 6380018 6453386 6457283 113.12 * @summary Test that the constraints guaranteed by the Filer and maintained 113.13 * @author Joseph D. Darcy 113.14 + * @library ../../lib 113.15 * @build TestFilerConstraints 113.16 * @compile -encoding iso-8859-1 -processor TestFilerConstraints -proc:only TestFilerConstraints.java 113.17 */ 113.18 @@ -69,11 +70,8 @@ 113.19 * 113.20 * </ul> 113.21 */ 113.22 -@SupportedAnnotationTypes("*") 113.23 -public class TestFilerConstraints extends AbstractProcessor { 113.24 +public class TestFilerConstraints extends JavacTestingAbstractProcessor { 113.25 private int round = 0; 113.26 - private Messager messager; 113.27 - private Filer filer; 113.28 113.29 private PrintWriter pw_src1 = null; 113.30 private PrintWriter pw_src2 = null; 113.31 @@ -167,17 +165,6 @@ 113.32 return true; 113.33 } 113.34 113.35 - public SourceVersion getSupportedSourceVersion() { 113.36 - return SourceVersion.latest(); 113.37 - } 113.38 - 113.39 - public void init(ProcessingEnvironment processingEnv) { 113.40 - super.init(processingEnv); 113.41 - messager = processingEnv.getMessager(); 113.42 - filer = processingEnv.getFiler(); 113.43 - 113.44 - } 113.45 - 113.46 /** 113.47 * Test that the single expected expected type, name, is the root 113.48 * element.
114.1 --- a/test/tools/javac/processing/filer/TestGetResource.java Thu Oct 07 15:12:31 2010 -0700 114.2 +++ b/test/tools/javac/processing/filer/TestGetResource.java Tue Oct 12 12:52:49 2010 -0700 114.3 @@ -1,5 +1,5 @@ 114.4 /* 114.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 114.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 114.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 114.8 * 114.9 * This code is free software; you can redistribute it and/or modify it 114.10 @@ -26,7 +26,8 @@ 114.11 * @bug 6380018 6449798 114.12 * @summary Test Filer.getResource 114.13 * @author Joseph D. Darcy 114.14 - * @build TestGetResource 114.15 + * @library ../../lib 114.16 + * @build JavacTestingAbstractProcessor TestGetResource 114.17 * @compile -processor TestGetResource -proc:only -Aphase=write TestGetResource.java 114.18 * @compile -processor TestGetResource -proc:only -Aphase=read TestGetResource.java 114.19 */ 114.20 @@ -49,13 +50,8 @@ 114.21 * first run of the annotation processor, write out a resource file 114.22 * and on the second run read it in. 114.23 */ 114.24 -@SupportedAnnotationTypes("*") 114.25 @SupportedOptions("phase") 114.26 -public class TestGetResource extends AbstractProcessor { 114.27 - private Messager messager; 114.28 - private Filer filer; 114.29 - private Map<String,String> options; 114.30 - 114.31 +public class TestGetResource extends JavacTestingAbstractProcessor { 114.32 private static String CONTENTS = "Hello World."; 114.33 private static String PKG = ""; 114.34 private static String RESOURCE_NAME = "Resource1"; 114.35 @@ -92,15 +88,4 @@ 114.36 } 114.37 return false; 114.38 } 114.39 - 114.40 - public SourceVersion getSupportedSourceVersion() { 114.41 - return SourceVersion.latest(); 114.42 - } 114.43 - 114.44 - public void init(ProcessingEnvironment processingEnv) { 114.45 - super.init(processingEnv); 114.46 - messager = processingEnv.getMessager(); 114.47 - filer = processingEnv.getFiler(); 114.48 - options = processingEnv.getOptions(); 114.49 - } 114.50 }
115.1 --- a/test/tools/javac/processing/filer/TestGetResource2.java Thu Oct 07 15:12:31 2010 -0700 115.2 +++ b/test/tools/javac/processing/filer/TestGetResource2.java Tue Oct 12 12:52:49 2010 -0700 115.3 @@ -1,5 +1,5 @@ 115.4 /* 115.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 115.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 115.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 115.8 * 115.9 * This code is free software; you can redistribute it and/or modify it 115.10 @@ -24,6 +24,7 @@ 115.11 /* @test 115.12 * @bug 6929404 115.13 * @summary Filer.getResource(SOURCE_PATH, ...) does not work when -sourcepath contains >1 entry 115.14 + * @library ../../lib 115.15 */ 115.16 115.17 import java.io.*; 115.18 @@ -114,8 +115,7 @@ 115.19 throw new Exception(errors + " errors occurred"); 115.20 } 115.21 115.22 - @SupportedAnnotationTypes("*") 115.23 - static class AnnoProc extends AbstractProcessor { 115.24 + static class AnnoProc extends JavacTestingAbstractProcessor { 115.25 115.26 public @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 115.27 if (roundEnv.processingOver()) { 115.28 @@ -123,27 +123,23 @@ 115.29 } 115.30 115.31 try { 115.32 - FileObject resource = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt"); 115.33 + FileObject resource = filer.getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt"); 115.34 try { 115.35 resource.openInputStream().close(); 115.36 - processingEnv.getMessager().printMessage(Kind.NOTE, "found: " + resource.toUri()); 115.37 + messager.printMessage(Kind.NOTE, "found: " + resource.toUri()); 115.38 return true; 115.39 } catch (IOException x) { 115.40 - processingEnv.getMessager().printMessage(Kind.ERROR, "could not read: " + resource.toUri()); 115.41 + messager.printMessage(Kind.ERROR, "could not read: " + resource.toUri()); 115.42 x.printStackTrace(); 115.43 } 115.44 } catch (IOException x) { 115.45 - processingEnv.getMessager().printMessage(Kind.ERROR, "did not find resource"); 115.46 + messager.printMessage(Kind.ERROR, "did not find resource"); 115.47 x.printStackTrace(); 115.48 } 115.49 115.50 return false; 115.51 } 115.52 115.53 - @Override 115.54 - public SourceVersion getSupportedSourceVersion() { 115.55 - return SourceVersion.latest(); 115.56 - } 115.57 } 115.58 115.59 private File write(File dir, String path, String contents) throws IOException {
116.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 116.2 +++ b/test/tools/javac/processing/filer/TestInvalidRelativeNames.java Tue Oct 12 12:52:49 2010 -0700 116.3 @@ -0,0 +1,100 @@ 116.4 +/* 116.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 116.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 116.7 + * 116.8 + * This code is free software; you can redistribute it and/or modify it 116.9 + * under the terms of the GNU General Public License version 2 only, as 116.10 + * published by the Free Software Foundation. 116.11 + * 116.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 116.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 116.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 116.15 + * version 2 for more details (a copy is included in the LICENSE file that 116.16 + * accompanied this code). 116.17 + * 116.18 + * You should have received a copy of the GNU General Public License version 116.19 + * 2 along with this work; if not, write to the Free Software Foundation, 116.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 116.21 + * 116.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 116.23 + * or visit www.oracle.com if you need additional information or have any 116.24 + * questions. 116.25 + */ 116.26 + 116.27 +/* 116.28 + * @test 116.29 + * @bug 6502392 116.30 + * @summary Invalid relative names for Filer.createResource and Filer.getResource 116.31 + * @library ../../lib 116.32 + * @build JavacTestingAbstractProcessor 116.33 + * @compile TestInvalidRelativeNames.java 116.34 + * @compile/process -processor TestInvalidRelativeNames java.lang.Object 116.35 + */ 116.36 + 116.37 +import java.io.*; 116.38 +import java.util.*; 116.39 +import javax.annotation.processing.*; 116.40 +import javax.lang.model.*; 116.41 +import javax.lang.model.element.*; 116.42 +import javax.tools.Diagnostic; 116.43 +import javax.tools.StandardLocation; 116.44 + 116.45 +public class TestInvalidRelativeNames extends JavacTestingAbstractProcessor { 116.46 + enum Kind { CREATE_WRITER, GET_READER, CREATE_OUTPUT_STREAM, GET_INPUT_STREAM }; 116.47 + 116.48 + static final String[] invalidRelativeNames = { 116.49 + "/boo", "goo/../hoo", "./ioo", "" 116.50 + }; 116.51 + 116.52 + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 116.53 + if (roundEnv.processingOver()) { 116.54 + for (String relative: invalidRelativeNames) { 116.55 + for (Kind kind: Kind.values()) { 116.56 + test(relative, kind); 116.57 + } 116.58 + } 116.59 + } 116.60 + return true; 116.61 + } 116.62 + 116.63 + void test(String relative, Kind kind) { 116.64 + System.out.println("test relative path: " + relative + ", kind: " + kind); 116.65 + try { 116.66 + switch (kind) { 116.67 + case CREATE_WRITER: 116.68 + Writer writer = filer.createResource( 116.69 + StandardLocation.SOURCE_OUTPUT, "", relative).openWriter(); 116.70 + writer.close(); 116.71 + break; 116.72 + 116.73 + case GET_READER: 116.74 + Reader reader = filer.getResource( 116.75 + StandardLocation.SOURCE_OUTPUT, "", relative).openReader(true); 116.76 + reader.close(); 116.77 + break; 116.78 + 116.79 + case CREATE_OUTPUT_STREAM: 116.80 + OutputStream out = filer.createResource( 116.81 + StandardLocation.SOURCE_OUTPUT, "", relative).openOutputStream(); 116.82 + out.close(); 116.83 + break; 116.84 + 116.85 + case GET_INPUT_STREAM: 116.86 + InputStream in = filer.createResource( 116.87 + StandardLocation.SOURCE_OUTPUT, "", relative).openInputStream(); 116.88 + in.close(); 116.89 + break; 116.90 + } 116.91 + } catch (IllegalArgumentException expected) { 116.92 + System.out.println("expected exception thrown: " + expected); 116.93 + return; 116.94 + } catch (Exception e) { 116.95 + messager.printMessage(Diagnostic.Kind.ERROR, 116.96 + "relative path: " + relative + ", kind: " + kind + ", unexpected exception: " + e); 116.97 + return; 116.98 + } 116.99 + messager.printMessage(Diagnostic.Kind.ERROR, 116.100 + "relative path: " + relative + ", kind: " + kind + ", no exception thrown"); 116.101 + } 116.102 +} 116.103 +
117.1 --- a/test/tools/javac/processing/filer/TestLastRound.java Thu Oct 07 15:12:31 2010 -0700 117.2 +++ b/test/tools/javac/processing/filer/TestLastRound.java Tue Oct 12 12:52:49 2010 -0700 117.3 @@ -24,6 +24,8 @@ 117.4 /* 117.5 * @test 6966604 117.6 * @summary JavacFiler not correctly notified of lastRound 117.7 + * @library ../../lib 117.8 + * @build JavacTestingAbstractProcessor 117.9 * @compile TestLastRound.java 117.10 * @compile/fail/ref=TestLastRound.out -XDrawDiagnostics -Werror -proc:only -processor TestLastRound TestLastRound.java 117.11 */ 117.12 @@ -35,12 +37,10 @@ 117.13 import javax.lang.model.element.*; 117.14 import javax.tools.*; 117.15 117.16 -@SupportedAnnotationTypes("*") 117.17 -public class TestLastRound extends AbstractProcessor { 117.18 +public class TestLastRound extends JavacTestingAbstractProcessor { 117.19 @Override 117.20 public boolean process(Set<? extends TypeElement> annotations, 117.21 RoundEnvironment roundEnv) { 117.22 - Filer filer = processingEnv.getFiler(); 117.23 if (roundEnv.processingOver()) { 117.24 try { 117.25 JavaFileObject fo = filer.createSourceFile("LastRound.java"); 117.26 @@ -52,9 +52,4 @@ 117.27 } 117.28 return true; 117.29 } 117.30 - 117.31 - @Override 117.32 - public SourceVersion getSupportedSourceVersion() { 117.33 - return SourceVersion.latest(); 117.34 - } 117.35 }
118.1 --- a/test/tools/javac/processing/filer/TestPackageInfo.java Thu Oct 07 15:12:31 2010 -0700 118.2 +++ b/test/tools/javac/processing/filer/TestPackageInfo.java Tue Oct 12 12:52:49 2010 -0700 118.3 @@ -1,5 +1,5 @@ 118.4 /* 118.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 118.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 118.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 118.8 * 118.9 * This code is free software; you can redistribute it and/or modify it 118.10 @@ -26,6 +26,8 @@ 118.11 * @bug 6380018 6392177 118.12 * @summary Test the ability to create and process package-info.java files 118.13 * @author Joseph D. Darcy 118.14 + * @library ../../lib 118.15 + * @build JavacTestingAbstractProcessor 118.16 * @compile TestPackageInfo.java 118.17 * @compile -processor TestPackageInfo -proc:only foo/bar/package-info.java TestPackageInfo.java 118.18 */ 118.19 @@ -49,13 +51,7 @@ 118.20 * 1) Visibility of package-info files from the command line 118.21 * 2) Visibility of generated package-info.java source files 118.22 */ 118.23 -@SupportedAnnotationTypes("*") 118.24 -public class TestPackageInfo extends AbstractProcessor { 118.25 - private Elements eltUtils; 118.26 - private Messager messager; 118.27 - private Filer filer; 118.28 - private Map<String,String> options; 118.29 - 118.30 +public class TestPackageInfo extends JavacTestingAbstractProcessor { 118.31 private int round = 0; 118.32 118.33 public boolean process(Set<? extends TypeElement> annotations, 118.34 @@ -64,11 +60,7 @@ 118.35 118.36 // Verify annotations are as expected 118.37 Set<TypeElement> expectedAnnotations = new HashSet<TypeElement>(); 118.38 - if (round == 1) 118.39 - expectedAnnotations.add(eltUtils. 118.40 - getTypeElement("javax.annotation.processing.SupportedAnnotationTypes")); 118.41 - expectedAnnotations.add(eltUtils. 118.42 - getTypeElement("java.lang.SuppressWarnings")); 118.43 + expectedAnnotations.add(eltUtils.getTypeElement("java.lang.SuppressWarnings")); 118.44 118.45 if (!roundEnv.processingOver()) { 118.46 System.out.println("\nRound " + round); 118.47 @@ -127,16 +119,4 @@ 118.48 } 118.49 return false; 118.50 } 118.51 - 118.52 - public SourceVersion getSupportedSourceVersion() { 118.53 - return SourceVersion.latest(); 118.54 - } 118.55 - 118.56 - public void init(ProcessingEnvironment processingEnv) { 118.57 - super.init(processingEnv); 118.58 - eltUtils = processingEnv.getElementUtils(); 118.59 - messager = processingEnv.getMessager(); 118.60 - filer = processingEnv.getFiler(); 118.61 - options = processingEnv.getOptions(); 118.62 - } 118.63 }
119.1 --- a/test/tools/javac/processing/messager/6362067/T6362067.java Thu Oct 07 15:12:31 2010 -0700 119.2 +++ b/test/tools/javac/processing/messager/6362067/T6362067.java Tue Oct 12 12:52:49 2010 -0700 119.3 @@ -2,39 +2,34 @@ 119.4 * @test /nodynamiccopyright/ 119.5 * @bug 6362067 119.6 * @summary Messager methods do not print out source position information 119.7 - * @build T6362067 119.8 + * @library ../../../lib 119.9 + * @build JavacTestingAbstractProcessor T6362067 119.10 * @compile -processor T6362067 -proc:only T6362067.java 119.11 * @compile/ref=T6362067.out -XDrawDiagnostics -processor T6362067 -proc:only T6362067.java 119.12 */ 119.13 - 119.14 import java.util.Set; 119.15 import javax.annotation.processing.*; 119.16 import javax.lang.model.element.*; 119.17 import static javax.tools.Diagnostic.Kind.*; 119.18 119.19 -@Deprecated // convenient test annotation 119.20 -@SupportedAnnotationTypes("*") 119.21 -public class T6362067 extends AbstractProcessor { 119.22 +@Deprecated // convenient test annotations 119.23 +@SuppressWarnings({""}) 119.24 +public class T6362067 extends JavacTestingAbstractProcessor { 119.25 public boolean process(Set<? extends TypeElement> annos, 119.26 RoundEnvironment roundEnv) { 119.27 - Messager msgr = processingEnv.getMessager(); 119.28 + 119.29 for (Element e: roundEnv.getRootElements()) { 119.30 - msgr.printMessage(NOTE, "note:elem", e); 119.31 + messager.printMessage(NOTE, "note:elem", e); 119.32 for (AnnotationMirror a: e.getAnnotationMirrors()) { 119.33 - msgr.printMessage(NOTE, "note:anno", e, a); 119.34 + messager.printMessage(NOTE, "note:anno", e, a); 119.35 for (AnnotationValue v: a.getElementValues().values()) { 119.36 - msgr.printMessage(NOTE, "note:value", e, a, v); 119.37 + messager.printMessage(NOTE, "note:value", e, a, v); 119.38 } 119.39 - 119.40 } 119.41 } 119.42 + 119.43 if (roundEnv.processingOver()) 119.44 - msgr.printMessage(NOTE, "note:nopos"); 119.45 + messager.printMessage(NOTE, "note:nopos"); 119.46 return true; 119.47 } 119.48 - 119.49 - @Override 119.50 - public javax.lang.model.SourceVersion getSupportedSourceVersion() { 119.51 - return javax.lang.model.SourceVersion.latest(); 119.52 - } 119.53 }
120.1 --- a/test/tools/javac/processing/messager/MessagerBasics.java Thu Oct 07 15:12:31 2010 -0700 120.2 +++ b/test/tools/javac/processing/messager/MessagerBasics.java Tue Oct 12 12:52:49 2010 -0700 120.3 @@ -1,5 +1,5 @@ 120.4 /* 120.5 - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 120.6 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 120.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 120.8 * 120.9 * This code is free software; you can redistribute it and/or modify it 120.10 @@ -26,6 +26,8 @@ 120.11 * @bug 6341173 6341072 120.12 * @summary Test presence of Messager methods 120.13 * @author Joseph D. Darcy 120.14 + * @library ../../lib 120.15 + * @build JavacTestingAbstractProcessor 120.16 * @compile MessagerBasics.java 120.17 * @compile -processor MessagerBasics -proc:only MessagerBasics.java 120.18 * @compile/fail -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java 120.19 @@ -39,18 +41,16 @@ 120.20 import javax.lang.model.util.*; 120.21 import static javax.tools.Diagnostic.Kind.*; 120.22 120.23 -@SupportedAnnotationTypes("*") 120.24 @SupportedOptions("finalError") 120.25 -public class MessagerBasics extends AbstractProcessor { 120.26 +public class MessagerBasics extends JavacTestingAbstractProcessor { 120.27 public boolean process(Set<? extends TypeElement> annotations, 120.28 RoundEnvironment roundEnv) { 120.29 - Messager m = processingEnv.getMessager(); 120.30 if (roundEnv.processingOver()) { 120.31 if (processingEnv.getOptions().containsKey("finalError")) 120.32 - m.printMessage(ERROR, "Does not compute"); 120.33 + messager.printMessage(ERROR, "Does not compute"); 120.34 else { 120.35 - m.printMessage(NOTE, "Post no bills"); 120.36 - m.printMessage(WARNING, "Beware the ides of March!"); 120.37 + messager.printMessage(NOTE, "Post no bills"); 120.38 + messager.printMessage(WARNING, "Beware the ides of March!"); 120.39 } 120.40 } 120.41 return true;
121.1 --- a/test/tools/javac/processing/model/6194785/T6194785.java Thu Oct 07 15:12:31 2010 -0700 121.2 +++ b/test/tools/javac/processing/model/6194785/T6194785.java Tue Oct 12 12:52:49 2010 -0700 121.3 @@ -1,5 +1,5 @@ 121.4 /* 121.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 121.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 121.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 121.8 * 121.9 * This code is free software; you can redistribute it and/or modify it 121.10 @@ -26,6 +26,8 @@ 121.11 * @bug 6194785 121.12 * @summary ParameterDeclaration.getSimpleName does not return actual name from class files 121.13 * @author Peter von der Ah\u00e9 121.14 + * @library ../../../lib 121.15 + * @build JavacTestingAbstractProcessor 121.16 * @compile -g T6194785.java T6194785a.java 121.17 * @compile -processor T6194785 foo.T6194785a T6194785.java 121.18 */ 121.19 @@ -36,13 +38,10 @@ 121.20 import javax.lang.model.util.*; 121.21 import static javax.tools.Diagnostic.Kind.*; 121.22 121.23 -@SupportedAnnotationTypes("*") 121.24 -public class T6194785 extends AbstractProcessor { 121.25 +public class T6194785 extends JavacTestingAbstractProcessor { 121.26 public boolean process(Set<? extends TypeElement> annotations, 121.27 RoundEnvironment roundEnvironment) 121.28 { 121.29 - final Messager log = processingEnv.getMessager(); 121.30 - final Elements elements = processingEnv.getElementUtils(); 121.31 class Scan extends ElementScanner7<Void,Void> { 121.32 @Override 121.33 public Void visitExecutable(ExecutableElement e, Void ignored) {
122.1 --- a/test/tools/javac/processing/model/6341534/T6341534.java Thu Oct 07 15:12:31 2010 -0700 122.2 +++ b/test/tools/javac/processing/model/6341534/T6341534.java Tue Oct 12 12:52:49 2010 -0700 122.3 @@ -1,5 +1,5 @@ 122.4 /* 122.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 122.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 122.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 122.8 * 122.9 * This code is free software; you can redistribute it and/or modify it 122.10 @@ -27,6 +27,8 @@ 122.11 * @summary PackageElement.getEnclosedElements results in NullPointerException from parse(JavaCompiler.java:429) 122.12 * @author Steve Sides 122.13 * @author Peter von der Ahe 122.14 + * @library ../../../lib 122.15 + * @build JavacTestingAbstractProcessor 122.16 * @compile T6341534.java 122.17 * @compile -proc:only -processor T6341534 dir/package-info.java 122.18 * @compile -processor T6341534 dir/package-info.java 122.19 @@ -40,20 +42,11 @@ 122.20 import java.util.Set; 122.21 import static javax.tools.Diagnostic.Kind.*; 122.22 122.23 -@SupportedAnnotationTypes("*") 122.24 -public class T6341534 extends AbstractProcessor { 122.25 - Elements elements; 122.26 - Messager messager; 122.27 - public void init(ProcessingEnvironment penv) { 122.28 - super.init(penv); 122.29 - elements = penv.getElementUtils(); 122.30 - messager = processingEnv.getMessager(); 122.31 - } 122.32 - 122.33 +public class T6341534 extends JavacTestingAbstractProcessor { 122.34 public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) { 122.35 messager.printMessage(NOTE, 122.36 - String.valueOf(elements.getPackageElement("no.such.package"))); 122.37 - PackageElement dir = elements.getPackageElement("dir"); 122.38 + String.valueOf(eltUtils.getPackageElement("no.such.package"))); 122.39 + PackageElement dir = eltUtils.getPackageElement("dir"); 122.40 messager.printMessage(NOTE, dir.getQualifiedName().toString()); 122.41 for (Element e : dir.getEnclosedElements()) 122.42 messager.printMessage(NOTE, e.toString());
123.1 --- a/test/tools/javac/processing/model/element/TestAnonClassNames.java Thu Oct 07 15:12:31 2010 -0700 123.2 +++ b/test/tools/javac/processing/model/element/TestAnonClassNames.java Tue Oct 12 12:52:49 2010 -0700 123.3 @@ -26,7 +26,8 @@ 123.4 * @bug 6449781 123.5 * @summary Test that reported names of anonymous classes are non-null. 123.6 * @author Joseph D. Darcy 123.7 - * @build TestAnonSourceNames 123.8 + * @library ../../../lib 123.9 + * @build JavacTestingAbstractProcessor TestAnonSourceNames 123.10 * @compile -processor TestAnonSourceNames TestAnonClassNames.java 123.11 * @run main TestAnonClassNames 123.12 */ 123.13 @@ -141,8 +142,7 @@ 123.14 /** 123.15 * Probe at the various kinds of names of a type element. 123.16 */ 123.17 -@SupportedAnnotationTypes("*") 123.18 -class ClassNameProber extends AbstractProcessor { 123.19 +class ClassNameProber extends JavacTestingAbstractProcessor { 123.20 public ClassNameProber(){super();} 123.21 123.22 private boolean classesFound=false; 123.23 @@ -174,8 +174,4 @@ 123.24 } 123.25 return true; 123.26 } 123.27 - 123.28 - public SourceVersion getSupportedSourceVersion() { 123.29 - return SourceVersion.latest(); 123.30 - } 123.31 }
124.1 --- a/test/tools/javac/processing/model/element/TestAnonSourceNames.java Thu Oct 07 15:12:31 2010 -0700 124.2 +++ b/test/tools/javac/processing/model/element/TestAnonSourceNames.java Tue Oct 12 12:52:49 2010 -0700 124.3 @@ -36,8 +36,7 @@ 124.4 * Using the tree API, retrieve element representations of anonymous 124.5 * classes and verify their names are as specified. 124.6 */ 124.7 -@SupportedAnnotationTypes("*") 124.8 -public class TestAnonSourceNames extends AbstractProcessor { 124.9 +public class TestAnonSourceNames extends JavacTestingAbstractProcessor { 124.10 124.11 public boolean process(Set<? extends TypeElement> annotations, 124.12 RoundEnvironment roundEnv) { 124.13 @@ -84,9 +83,4 @@ 124.14 return super.visitClass(node, cu); 124.15 } 124.16 } 124.17 - 124.18 - @Override 124.19 - public SourceVersion getSupportedSourceVersion() { 124.20 - return SourceVersion.latest(); 124.21 - } 124.22 }
125.1 --- a/test/tools/javac/processing/model/element/TestElement.java Thu Oct 07 15:12:31 2010 -0700 125.2 +++ b/test/tools/javac/processing/model/element/TestElement.java Tue Oct 12 12:52:49 2010 -0700 125.3 @@ -1,5 +1,5 @@ 125.4 /* 125.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 125.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 125.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 125.8 * 125.9 * This code is free software; you can redistribute it and/or modify it 125.10 @@ -26,7 +26,8 @@ 125.11 * @bug 6453386 125.12 * @summary Test basic properties of javax.lang.element.Element 125.13 * @author Joseph D. Darcy 125.14 - * @build TestElement 125.15 + * @library ../../../lib 125.16 + * @build JavacTestingAbstractProcessor TestElement 125.17 * @compile -processor TestElement -proc:only TestElement.java 125.18 */ 125.19 125.20 @@ -43,8 +44,7 @@ 125.21 /** 125.22 * Test basic workings of javax.lang.element.Element 125.23 */ 125.24 -@SupportedAnnotationTypes("*") 125.25 -public class TestElement extends AbstractProcessor { 125.26 +public class TestElement extends JavacTestingAbstractProcessor { 125.27 /** 125.28 * For now, just check that constructors have a simple name of 125.29 * "<init>". 125.30 @@ -66,9 +66,4 @@ 125.31 } 125.32 return true; 125.33 } 125.34 - 125.35 - public SourceVersion getSupportedSourceVersion() { 125.36 - return SourceVersion.latest(); 125.37 - } 125.38 - 125.39 }
126.1 --- a/test/tools/javac/processing/model/element/TestNames.java Thu Oct 07 15:12:31 2010 -0700 126.2 +++ b/test/tools/javac/processing/model/element/TestNames.java Tue Oct 12 12:52:49 2010 -0700 126.3 @@ -1,5 +1,5 @@ 126.4 /* 126.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 126.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 126.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 126.8 * 126.9 * This code is free software; you can redistribute it and/or modify it 126.10 @@ -26,7 +26,8 @@ 126.11 * @bug 6380016 126.12 * @summary Test that the constraints guaranteed by the Filer and maintained 126.13 * @author Joseph D. Darcy 126.14 - * @build TestNames 126.15 + * @library ../../../lib 126.16 + * @build JavacTestingAbstractProcessor TestNames 126.17 * @compile -processor TestNames -proc:only TestNames.java 126.18 */ 126.19 126.20 @@ -45,11 +46,8 @@ 126.21 /** 126.22 * Basic tests of semantics of javax.lang.model.element.Name 126.23 */ 126.24 -@SupportedAnnotationTypes("*") 126.25 -public class TestNames extends AbstractProcessor { 126.26 +public class TestNames extends JavacTestingAbstractProcessor { 126.27 private int round = 0; 126.28 - private Filer filer; 126.29 - private Elements eltUtils; 126.30 126.31 String stringStringName = "java.lang.String"; 126.32 Name stringName = null; 126.33 @@ -106,16 +104,6 @@ 126.34 return true; 126.35 } 126.36 126.37 - public SourceVersion getSupportedSourceVersion() { 126.38 - return SourceVersion.latest(); 126.39 - } 126.40 - 126.41 - public void init(ProcessingEnvironment processingEnv) { 126.42 - super.init(processingEnv); 126.43 - filer = processingEnv.getFiler(); 126.44 - eltUtils = processingEnv.getElementUtils(); 126.45 - } 126.46 - 126.47 private static class Pseudonym implements Name { 126.48 private String name; 126.49
127.1 --- a/test/tools/javac/processing/model/element/TestPackageElement.java Thu Oct 07 15:12:31 2010 -0700 127.2 +++ b/test/tools/javac/processing/model/element/TestPackageElement.java Tue Oct 12 12:52:49 2010 -0700 127.3 @@ -1,5 +1,5 @@ 127.4 /* 127.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 127.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 127.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 127.8 * 127.9 * This code is free software; you can redistribute it and/or modify it 127.10 @@ -26,7 +26,8 @@ 127.11 * @bug 6449798 6399404 127.12 * @summary Test basic workings of PackageElement 127.13 * @author Joseph D. Darcy 127.14 - * @build TestPackageElement 127.15 + * @library ../../../lib 127.16 + * @build JavacTestingAbstractProcessor TestPackageElement 127.17 * @compile -processor TestPackageElement -proc:only TestPackageElement.java 127.18 */ 127.19 127.20 @@ -43,11 +44,7 @@ 127.21 /** 127.22 * Test basic workings of PackageElement. 127.23 */ 127.24 -@SupportedAnnotationTypes("*") 127.25 -public class TestPackageElement extends AbstractProcessor { 127.26 - private Filer filer; 127.27 - private Elements eltUtils; 127.28 - 127.29 +public class TestPackageElement extends JavacTestingAbstractProcessor { 127.30 public boolean process(Set<? extends TypeElement> annotations, 127.31 RoundEnvironment roundEnv) { 127.32 if (!roundEnv.processingOver()) { 127.33 @@ -71,15 +68,4 @@ 127.34 } 127.35 return true; 127.36 } 127.37 - 127.38 - public SourceVersion getSupportedSourceVersion() { 127.39 - return SourceVersion.latest(); 127.40 - } 127.41 - 127.42 - public void init(ProcessingEnvironment processingEnv) { 127.43 - super.init(processingEnv); 127.44 - filer = processingEnv.getFiler(); 127.45 - eltUtils = processingEnv.getElementUtils(); 127.46 - } 127.47 - 127.48 }
128.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 128.2 +++ b/test/tools/javac/processing/model/element/TestResourceElement.java Tue Oct 12 12:52:49 2010 -0700 128.3 @@ -0,0 +1,91 @@ 128.4 +/* 128.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 128.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 128.7 + * 128.8 + * This code is free software; you can redistribute it and/or modify it 128.9 + * under the terms of the GNU General Public License version 2 only, as 128.10 + * published by the Free Software Foundation. 128.11 + * 128.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 128.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 128.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 128.15 + * version 2 for more details (a copy is included in the LICENSE file that 128.16 + * accompanied this code). 128.17 + * 128.18 + * You should have received a copy of the GNU General Public License version 128.19 + * 2 along with this work; if not, write to the Free Software Foundation, 128.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 128.21 + * 128.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 128.23 + * or visit www.oracle.com if you need additional information or have any 128.24 + * questions. 128.25 + */ 128.26 + 128.27 +/* 128.28 + * @test 128.29 + * @bug 6967842 128.30 + * @summary Element not returned from tree API for ARM resource variables. 128.31 + * @author A. Sundararajan 128.32 + * @library ../../../lib 128.33 + * @build JavacTestingAbstractProcessor TestResourceElement 128.34 + * @compile -processor TestResourceElement -proc:only TestResourceElement.java 128.35 + */ 128.36 + 128.37 +import javax.annotation.processing.*; 128.38 +import javax.lang.model.*; 128.39 +import javax.lang.model.element.*; 128.40 +import java.util.*; 128.41 +import com.sun.source.tree.*; 128.42 +import com.sun.source.util.*; 128.43 + 128.44 +public class TestResourceElement extends JavacTestingAbstractProcessor implements AutoCloseable { 128.45 + public boolean process(Set<? extends TypeElement> annotations, 128.46 + RoundEnvironment roundEnv) { 128.47 + if (!roundEnv.processingOver()) { 128.48 + Trees trees = Trees.instance(processingEnv); 128.49 + 128.50 + for(Element rootElement : roundEnv.getRootElements()) { 128.51 + TreePath treePath = trees.getPath(rootElement); 128.52 + 128.53 + VariableScanner varScanner = new VariableScanner(trees); 128.54 + varScanner.scan(trees.getTree(rootElement), 128.55 + treePath.getCompilationUnit()); 128.56 + if (varScanner.getTrvElement() == null) { 128.57 + throw new AssertionError("Element is null for 'trv'"); 128.58 + } 128.59 + } 128.60 + } 128.61 + return true; 128.62 + } 128.63 + 128.64 + @Override 128.65 + public void close() {} 128.66 + 128.67 + private void test1() { 128.68 + // The resource variable "trv"'s Element is checked. 128.69 + // Do not change the name of the variable. 128.70 + try(TestResourceElement trv = this) {} 128.71 + } 128.72 + 128.73 + class VariableScanner extends TreeScanner<Void, CompilationUnitTree> { 128.74 + private Trees trees; 128.75 + private Element trvElement; 128.76 + 128.77 + public VariableScanner(Trees trees) { 128.78 + super(); 128.79 + this.trees = trees; 128.80 + } 128.81 + @Override 128.82 + public Void visitVariable(VariableTree node, CompilationUnitTree cu) { 128.83 + // if this is "trv", get it's element. 128.84 + if (node.getName().contentEquals("trv")) { 128.85 + trvElement = trees.getElement(trees.getPath(cu, node)); 128.86 + } 128.87 + return super.visitVariable(node, cu); 128.88 + } 128.89 + 128.90 + Element getTrvElement() { 128.91 + return trvElement; 128.92 + } 128.93 + } 128.94 +}
129.1 --- a/test/tools/javac/processing/model/element/TestResourceVariable.java Thu Oct 07 15:12:31 2010 -0700 129.2 +++ b/test/tools/javac/processing/model/element/TestResourceVariable.java Tue Oct 12 12:52:49 2010 -0700 129.3 @@ -23,11 +23,12 @@ 129.4 129.5 /* 129.6 * @test 129.7 - * @bug 6911256 6964740 129.8 + * @bug 6911256 6964740 6967842 129.9 * @summary Test that the resource variable kind is appropriately set 129.10 * @author Joseph D. Darcy 129.11 - * @build TestResourceVariable 129.12 - * @compile/fail -processor TestResourceVariable -proc:only TestResourceVariable.java 129.13 + * @library ../../../lib 129.14 + * @build JavacTestingAbstractProcessor TestResourceVariable 129.15 + * @compile -processor TestResourceVariable -proc:only TestResourceVariable.java 129.16 */ 129.17 129.18 // Bug should be filed for this misbehavior 129.19 @@ -48,8 +49,7 @@ 129.20 * resource of an ARM block and verify their kind tags are set 129.21 * appropriately. 129.22 */ 129.23 -@SupportedAnnotationTypes("*") 129.24 -public class TestResourceVariable extends AbstractProcessor implements AutoCloseable { 129.25 +public class TestResourceVariable extends JavacTestingAbstractProcessor implements AutoCloseable { 129.26 int resourceVariableCount = 0; 129.27 129.28 public boolean process(Set<? extends TypeElement> annotations, 129.29 @@ -105,9 +105,4 @@ 129.30 return super.visitVariable(node, cu); 129.31 } 129.32 } 129.33 - 129.34 - @Override 129.35 - public SourceVersion getSupportedSourceVersion() { 129.36 - return SourceVersion.latest(); 129.37 - } 129.38 }
130.1 --- a/test/tools/javac/processing/model/element/TypeParamBounds.java Thu Oct 07 15:12:31 2010 -0700 130.2 +++ b/test/tools/javac/processing/model/element/TypeParamBounds.java Tue Oct 12 12:52:49 2010 -0700 130.3 @@ -1,5 +1,5 @@ 130.4 /* 130.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 130.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 130.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 130.8 * 130.9 * This code is free software; you can redistribute it and/or modify it 130.10 @@ -26,7 +26,8 @@ 130.11 * @bug 6423972 130.12 * @summary Tests TypeParameter.getBounds. 130.13 * @author Scott Seligman 130.14 - * @build TypeParamBounds 130.15 + * @library ../../../lib 130.16 + * @build JavacTestingAbstractProcessor TypeParamBounds 130.17 * @compile -processor TypeParamBounds -proc:only TypeParamBounds.java 130.18 */ 130.19 130.20 @@ -40,18 +41,7 @@ 130.21 import javax.lang.model.type.*; 130.22 import javax.lang.model.util.*; 130.23 130.24 -@SupportedAnnotationTypes("*") 130.25 -public class TypeParamBounds extends AbstractProcessor { 130.26 - 130.27 - Elements elements; 130.28 - Types types; 130.29 - 130.30 - public void init(ProcessingEnvironment penv) { 130.31 - super.init(penv); 130.32 - elements = penv.getElementUtils(); 130.33 - types = penv.getTypeUtils(); 130.34 - } 130.35 - 130.36 +public class TypeParamBounds extends JavacTestingAbstractProcessor { 130.37 public boolean process(Set<? extends TypeElement> annoTypes, 130.38 RoundEnvironment round) { 130.39 if (!round.processingOver()) 130.40 @@ -59,11 +49,6 @@ 130.41 return true; 130.42 } 130.43 130.44 - @Override 130.45 - public SourceVersion getSupportedSourceVersion() { 130.46 - return SourceVersion.latest(); 130.47 - } 130.48 - 130.49 private void doit(Set<? extends TypeElement> annoTypes, 130.50 RoundEnvironment round) { 130.51 TypeElement gen = elements.getTypeElement("TypeParamBounds.Gen"); 130.52 @@ -91,7 +76,6 @@ 130.53 130.54 130.55 // Fodder for the processor 130.56 - 130.57 static class Gen<T, U extends Object, V extends Number, W extends U, 130.58 X extends Runnable, Y extends CharSequence & Runnable, 130.59 Z extends Object & Runnable> {
131.1 --- a/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java Thu Oct 07 15:12:31 2010 -0700 131.2 +++ b/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java Tue Oct 12 12:52:49 2010 -0700 131.3 @@ -1,5 +1,5 @@ 131.4 /* 131.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 131.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 131.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 131.8 * 131.9 * This code is free software; you can redistribute it and/or modify it 131.10 @@ -26,6 +26,8 @@ 131.11 * @bug 6362178 131.12 * @summary MirroredType[s]Exception shouldn't be created too eagerly 131.13 * @author Scott Seligman 131.14 + * @library ../../../../lib 131.15 + * @build JavacTestingAbstractProcessor 131.16 * @compile -g OverEager.java 131.17 * @compile -processor OverEager -proc:only OverEager.java 131.18 */ 131.19 @@ -40,17 +42,7 @@ 131.20 131.21 @SupportedAnnotationTypes("IAm") 131.22 @IAm(OverEager.class) 131.23 -public class OverEager extends AbstractProcessor { 131.24 - 131.25 - Elements elements; 131.26 - Types types; 131.27 - 131.28 - public void init(ProcessingEnvironment penv) { 131.29 - super.init(penv); 131.30 - elements = penv.getElementUtils(); 131.31 - types = penv.getTypeUtils(); 131.32 - } 131.33 - 131.34 +public class OverEager extends JavacTestingAbstractProcessor { 131.35 public boolean process(Set<? extends TypeElement> annoTypes, 131.36 RoundEnvironment round) { 131.37 if (!round.processingOver()) 131.38 @@ -58,11 +50,6 @@ 131.39 return true; 131.40 } 131.41 131.42 - @Override 131.43 - public SourceVersion getSupportedSourceVersion() { 131.44 - return SourceVersion.latest(); 131.45 - } 131.46 - 131.47 private void doit(Set<? extends TypeElement> annoTypes, 131.48 RoundEnvironment round) { 131.49 for (TypeElement t : typesIn(round.getRootElements())) {
132.1 --- a/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java Thu Oct 07 15:12:31 2010 -0700 132.2 +++ b/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java Tue Oct 12 12:52:49 2010 -0700 132.3 @@ -25,6 +25,8 @@ 132.4 * @test 132.5 * @bug 6519115 132.6 * @summary Verify MirroredTypeException vs MirroredTypesException is thrown 132.7 + * @library ../../../../lib 132.8 + * @build JavacTestingAbstractProcessor 132.9 * @compile Plurality.java 132.10 * @compile -processor Plurality -proc:only Plurality.java 132.11 * @author Joseph D. Darcy 132.12 @@ -38,25 +40,13 @@ 132.13 import javax.lang.model.type.*; 132.14 import javax.lang.model.util.*; 132.15 132.16 -@SupportedAnnotationTypes("*") 132.17 @P0 132.18 @P1 132.19 @P2 132.20 @S1 132.21 -public class Plurality extends AbstractProcessor { 132.22 +public class Plurality extends JavacTestingAbstractProcessor { 132.23 private boolean executed = false; 132.24 132.25 - Elements elements; 132.26 - Types types; 132.27 - 132.28 - @Override 132.29 - public void init(ProcessingEnvironment penv) { 132.30 - super.init(penv); 132.31 - elements = penv.getElementUtils(); 132.32 - types = penv.getTypeUtils(); 132.33 - } 132.34 - 132.35 - 132.36 public boolean process(Set<? extends TypeElement> annotations, 132.37 RoundEnvironment roundEnv) { 132.38 if (!roundEnv.processingOver()) { 132.39 @@ -164,11 +154,6 @@ 132.40 toStringName); 132.41 } 132.42 } 132.43 - 132.44 - @Override 132.45 - public SourceVersion getSupportedSourceVersion() { 132.46 - return SourceVersion.latest(); 132.47 - } 132.48 } 132.49 132.50 @Retention(RetentionPolicy.RUNTIME)
133.1 --- a/test/tools/javac/processing/model/type/NoTypes.java Thu Oct 07 15:12:31 2010 -0700 133.2 +++ b/test/tools/javac/processing/model/type/NoTypes.java Tue Oct 12 12:52:49 2010 -0700 133.3 @@ -1,5 +1,5 @@ 133.4 /* 133.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 133.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 133.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 133.8 * 133.9 * This code is free software; you can redistribute it and/or modify it 133.10 @@ -26,6 +26,8 @@ 133.11 * @bug 6418666 6423973 6453386 133.12 * @summary Test the NoTypes: VOID, PACKAGE, NONE 133.13 * @author Scott Seligman 133.14 + * @library ../../../lib 133.15 + * @build JavacTestingAbstractProcessor 133.16 * @compile -g NoTypes.java 133.17 * @compile -processor NoTypes -proc:only NoTypes.java 133.18 */ 133.19 @@ -39,18 +41,7 @@ 133.20 133.21 import static javax.lang.model.type.TypeKind.*; 133.22 133.23 -@SupportedAnnotationTypes("*") 133.24 -public class NoTypes extends AbstractProcessor { 133.25 - 133.26 - Elements elements; 133.27 - Types types; 133.28 - 133.29 - public void init(ProcessingEnvironment penv) { 133.30 - super.init(penv); 133.31 - elements = penv.getElementUtils(); 133.32 - types = penv.getTypeUtils(); 133.33 - } 133.34 - 133.35 +public class NoTypes extends JavacTestingAbstractProcessor { 133.36 public boolean process(Set<? extends TypeElement> annoTypes, 133.37 RoundEnvironment round) { 133.38 if (!round.processingOver()) 133.39 @@ -58,11 +49,6 @@ 133.40 return true; 133.41 } 133.42 133.43 - @Override 133.44 - public SourceVersion getSupportedSourceVersion() { 133.45 - return SourceVersion.latest(); 133.46 - } 133.47 - 133.48 private void doit(Set<? extends TypeElement> annoTypes, 133.49 RoundEnvironment round) { 133.50
134.1 --- a/test/tools/javac/processing/model/util/BinaryName.java Thu Oct 07 15:12:31 2010 -0700 134.2 +++ b/test/tools/javac/processing/model/util/BinaryName.java Tue Oct 12 12:52:49 2010 -0700 134.3 @@ -1,5 +1,5 @@ 134.4 /* 134.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 134.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 134.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 134.8 * 134.9 * This code is free software; you can redistribute it and/or modify it 134.10 @@ -26,7 +26,8 @@ 134.11 * @bug 6346251 134.12 * @summary Test Elements.getBinaryName 134.13 * @author Scott Seligman 134.14 - * @build BinaryName 134.15 + * @library ../../../lib 134.16 + * @build JavacTestingAbstractProcessor BinaryName 134.17 * @compile -processor BinaryName -proc:only BinaryName.java 134.18 */ 134.19 134.20 @@ -38,17 +39,8 @@ 134.21 134.22 import static javax.lang.model.util.ElementFilter.typesIn; 134.23 134.24 -@SupportedAnnotationTypes("*") 134.25 @HelloIm("BinaryName") 134.26 -public class BinaryName extends AbstractProcessor { 134.27 - 134.28 - Elements elements; 134.29 - 134.30 - public void init(ProcessingEnvironment penv) { 134.31 - super.init(penv); 134.32 - elements = penv.getElementUtils(); 134.33 - } 134.34 - 134.35 +public class BinaryName extends JavacTestingAbstractProcessor { 134.36 public boolean process(Set<? extends TypeElement> tes, 134.37 RoundEnvironment round) { 134.38 if (round.processingOver()) return true;
135.1 --- a/test/tools/javac/processing/model/util/GetTypeElemBadArg.java Thu Oct 07 15:12:31 2010 -0700 135.2 +++ b/test/tools/javac/processing/model/util/GetTypeElemBadArg.java Tue Oct 12 12:52:49 2010 -0700 135.3 @@ -1,5 +1,5 @@ 135.4 /* 135.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 135.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 135.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 135.8 * 135.9 * This code is free software; you can redistribute it and/or modify it 135.10 @@ -26,7 +26,8 @@ 135.11 * @bug 6346506 6408241 135.12 * @summary getTypeElement should tolerate a type that can't be found 135.13 * @author Scott Seligman 135.14 - * @build GetTypeElemBadArg 135.15 + * @library ../../../lib 135.16 + * @build JavacTestingAbstractProcessor GetTypeElemBadArg 135.17 * @compile -processor GetTypeElemBadArg -proc:only GetTypeElemBadArg.java 135.18 */ 135.19 135.20 @@ -37,16 +38,7 @@ 135.21 import javax.lang.model.type.*; 135.22 import javax.lang.model.util.*; 135.23 135.24 -@SupportedAnnotationTypes("*") 135.25 -public class GetTypeElemBadArg extends AbstractProcessor { 135.26 - 135.27 - Elements elements; 135.28 - 135.29 - public void init(ProcessingEnvironment penv) { 135.30 - super.init(penv); 135.31 - elements = penv.getElementUtils(); 135.32 - } 135.33 - 135.34 +public class GetTypeElemBadArg extends JavacTestingAbstractProcessor { 135.35 public boolean process(Set<? extends TypeElement> tes, 135.36 RoundEnvironment round) { 135.37 if (round.processingOver()) return true; 135.38 @@ -63,12 +55,6 @@ 135.39 return true; 135.40 } 135.41 135.42 - 135.43 - @Override 135.44 - public SourceVersion getSupportedSourceVersion() { 135.45 - return SourceVersion.latest(); 135.46 - } 135.47 - 135.48 private static void tellAbout(TypeElement t) { 135.49 System.out.println(t); 135.50 System.out.println(t.getClass());
136.1 --- a/test/tools/javac/processing/model/util/NoSupers.java Thu Oct 07 15:12:31 2010 -0700 136.2 +++ b/test/tools/javac/processing/model/util/NoSupers.java Tue Oct 12 12:52:49 2010 -0700 136.3 @@ -1,5 +1,5 @@ 136.4 /* 136.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 136.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 136.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 136.8 * 136.9 * This code is free software; you can redistribute it and/or modify it 136.10 @@ -26,7 +26,8 @@ 136.11 * @bug 6346453 136.12 * @summary directSupertypes should return empty list if arg has no supertypes 136.13 * @author Scott Seligman 136.14 - * @build NoSupers 136.15 + * @library ../../../lib 136.16 + * @build JavacTestingAbstractProcessor NoSupers 136.17 * @compile -processor NoSupers -proc:only NoSupers.java 136.18 */ 136.19 136.20 @@ -36,16 +37,7 @@ 136.21 import javax.lang.model.type.*; 136.22 import javax.lang.model.util.*; 136.23 136.24 -@SupportedAnnotationTypes("*") 136.25 -public class NoSupers extends AbstractProcessor { 136.26 - 136.27 - Types types; 136.28 - 136.29 - public void init(ProcessingEnvironment penv) { 136.30 - super.init(penv); 136.31 - types = penv.getTypeUtils(); 136.32 - } 136.33 - 136.34 +public class NoSupers extends JavacTestingAbstractProcessor { 136.35 public boolean process(Set<? extends TypeElement> tes, 136.36 RoundEnvironment round) { 136.37 if (round.processingOver()) return true;
137.1 --- a/test/tools/javac/processing/model/util/OverridesSpecEx.java Thu Oct 07 15:12:31 2010 -0700 137.2 +++ b/test/tools/javac/processing/model/util/OverridesSpecEx.java Tue Oct 12 12:52:49 2010 -0700 137.3 @@ -1,5 +1,5 @@ 137.4 /* 137.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 137.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 137.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 137.8 * 137.9 * This code is free software; you can redistribute it and/or modify it 137.10 @@ -26,6 +26,8 @@ 137.11 * @bug 6453386 137.12 * @summary Verify that example code in Elements.overrides works as spec'ed. 137.13 * @author Scott Seligman 137.14 + * @library ../../../lib 137.15 + * @build JavacTestingAbstractProcessor 137.16 * @compile -g OverridesSpecEx.java 137.17 * @compile -processor OverridesSpecEx -proc:only OverridesSpecEx.java 137.18 */ 137.19 @@ -39,19 +41,7 @@ 137.20 137.21 import static javax.lang.model.util.ElementFilter.*; 137.22 137.23 - 137.24 -@SupportedAnnotationTypes("*") 137.25 -public class OverridesSpecEx extends AbstractProcessor { 137.26 - 137.27 - Elements elements; 137.28 - Types types; 137.29 - 137.30 - public void init(ProcessingEnvironment penv) { 137.31 - super.init(penv); 137.32 - elements = penv.getElementUtils(); 137.33 - types = penv.getTypeUtils(); 137.34 - } 137.35 - 137.36 +public class OverridesSpecEx extends JavacTestingAbstractProcessor { 137.37 public boolean process(Set<? extends TypeElement> annoTypes, 137.38 RoundEnvironment round) { 137.39 if (!round.processingOver()) 137.40 @@ -59,11 +49,6 @@ 137.41 return true; 137.42 } 137.43 137.44 - @Override 137.45 - public SourceVersion getSupportedSourceVersion() { 137.46 - return SourceVersion.latest(); 137.47 - } 137.48 - 137.49 private void doit(Set<? extends TypeElement> annoTypes, 137.50 RoundEnvironment round) { 137.51 TypeElement string = elements.getTypeElement("java.lang.String"); 137.52 @@ -113,9 +98,7 @@ 137.53 throw new AssertionError("Bogus result"); 137.54 } 137.55 137.56 - 137.57 // Fodder for the processor 137.58 - 137.59 class A { 137.60 public void m() {} 137.61 }
138.1 --- a/test/tools/javac/processing/model/util/TypesBadArg.java Thu Oct 07 15:12:31 2010 -0700 138.2 +++ b/test/tools/javac/processing/model/util/TypesBadArg.java Tue Oct 12 12:52:49 2010 -0700 138.3 @@ -1,5 +1,5 @@ 138.4 /* 138.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 138.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 138.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 138.8 * 138.9 * This code is free software; you can redistribute it and/or modify it 138.10 @@ -26,7 +26,8 @@ 138.11 * @bug 6345812 138.12 * @summary Validate argument kinds in Types utilities 138.13 * @author Scott Seligman 138.14 - * @build TypesBadArg 138.15 + * @library ../../../lib 138.16 + * @build JavacTestingAbstractProcessor TypesBadArg 138.17 * @compile -processor TypesBadArg -proc:only TypesBadArg.java 138.18 */ 138.19 138.20 @@ -36,15 +37,9 @@ 138.21 import javax.lang.model.type.*; 138.22 import javax.lang.model.util.*; 138.23 138.24 -@SupportedAnnotationTypes("*") 138.25 -public class TypesBadArg extends AbstractProcessor { 138.26 - 138.27 +public class TypesBadArg extends JavacTestingAbstractProcessor { 138.28 boolean success = true; 138.29 138.30 - public void init(ProcessingEnvironment penv) { 138.31 - super.init(penv); 138.32 - } 138.33 - 138.34 public boolean process(Set<? extends TypeElement> tes, 138.35 RoundEnvironment round) { 138.36 if (round.processingOver()) return true;
139.1 --- a/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java Thu Oct 07 15:12:31 2010 -0700 139.2 +++ b/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java Tue Oct 12 12:52:49 2010 -0700 139.3 @@ -1,5 +1,5 @@ 139.4 /* 139.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 139.6 + * Copyright (c) 2006, 2010 Oracle and/or its affiliates. All rights reserved. 139.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 139.8 * 139.9 * This code is free software; you can redistribute it and/or modify it 139.10 @@ -26,6 +26,8 @@ 139.11 * @bug 6392818 139.12 * @summary Tests Elements.isDeprecated(Element) 139.13 * @author Joseph D. Darcy 139.14 + * @library ../../../../lib 139.15 + * @build JavacTestingAbstractProcessor 139.16 * @compile TestDeprecation.java 139.17 * @compile -processor TestDeprecation -proc:only Dep1.java 139.18 * @compile Dep1.java 139.19 @@ -47,8 +49,7 @@ 139.20 * getElementsAnnotatedWith is consistent with the expected results 139.21 * stored in an AnnotatedElementInfo annotation. 139.22 */ 139.23 -@SupportedAnnotationTypes("*") 139.24 -public class TestDeprecation extends AbstractProcessor { 139.25 +public class TestDeprecation extends JavacTestingAbstractProcessor { 139.26 139.27 public boolean process(Set<? extends TypeElement> annotations, 139.28 RoundEnvironment roundEnv) { 139.29 @@ -98,9 +99,4 @@ 139.30 return failure; 139.31 } 139.32 } 139.33 - 139.34 - @Override 139.35 - public SourceVersion getSupportedSourceVersion() { 139.36 - return SourceVersion.latest(); 139.37 - } 139.38 }
140.1 --- a/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java Thu Oct 07 15:12:31 2010 -0700 140.2 +++ b/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java Tue Oct 12 12:52:49 2010 -0700 140.3 @@ -1,5 +1,5 @@ 140.4 /* 140.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 140.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 140.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 140.8 * 140.9 * This code is free software; you can redistribute it and/or modify it 140.10 @@ -26,7 +26,8 @@ 140.11 * @bug 6346973 140.12 * @summary directSupertypes(t) should not return t 140.13 * @author Scott Seligman 140.14 - * @build DirectSupersOfErr 140.15 + * @library ../../../../lib 140.16 + * @build JavacTestingAbstractProcessor DirectSupersOfErr 140.17 * @compile -processor DirectSupersOfErr -proc:only C1.java 140.18 */ 140.19 140.20 @@ -37,16 +38,7 @@ 140.21 import javax.lang.model.util.*; 140.22 import static javax.lang.model.util.ElementFilter.*; 140.23 140.24 -@SupportedAnnotationTypes("*") 140.25 -public class DirectSupersOfErr extends AbstractProcessor { 140.26 - 140.27 - Types types; 140.28 - 140.29 - public void init(ProcessingEnvironment penv) { 140.30 - super.init(penv); 140.31 - types = penv.getTypeUtils(); 140.32 - } 140.33 - 140.34 +public class DirectSupersOfErr extends JavacTestingAbstractProcessor { 140.35 public boolean process(Set<? extends TypeElement> tes, 140.36 RoundEnvironment round) { 140.37 if (round.processingOver()) return true;
141.1 --- a/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java Thu Oct 07 15:12:31 2010 -0700 141.2 +++ b/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java Tue Oct 12 12:52:49 2010 -0700 141.3 @@ -1,5 +1,5 @@ 141.4 /* 141.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 141.6 + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 141.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 141.8 * 141.9 * This code is free software; you can redistribute it and/or modify it 141.10 @@ -26,7 +26,8 @@ 141.11 * @bug 6471577 6517779 141.12 * @summary Test Elements.getConstantExpression 141.13 * @author Joseph D. Darcy 141.14 - * @build TestGetConstantExpression 141.15 + * @library ../../../../lib 141.16 + * @build JavacTestingAbstractProcessor TestGetConstantExpression 141.17 * @compile -processor TestGetConstantExpression Foo.java 141.18 */ 141.19 141.20 @@ -44,10 +45,7 @@ 141.21 /** 141.22 * Test basic workings of Elements.getConstantExpression. 141.23 */ 141.24 -@SupportedAnnotationTypes("*") 141.25 -public class TestGetConstantExpression extends AbstractProcessor { 141.26 - private Elements eltUtils; 141.27 - private Filer filer; 141.28 +public class TestGetConstantExpression extends JavacTestingAbstractProcessor { 141.29 private int round = 1; 141.30 141.31 /** 141.32 @@ -130,14 +128,4 @@ 141.33 return 0; 141.34 } 141.35 } 141.36 - 141.37 - public SourceVersion getSupportedSourceVersion() { 141.38 - return SourceVersion.latest(); 141.39 - } 141.40 - 141.41 - public void init(ProcessingEnvironment processingEnv) { 141.42 - super.init(processingEnv); 141.43 - eltUtils = processingEnv.getElementUtils(); 141.44 - filer = processingEnv.getFiler(); 141.45 - } 141.46 }
142.1 --- a/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java Thu Oct 07 15:12:31 2010 -0700 142.2 +++ b/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java Tue Oct 12 12:52:49 2010 -0700 142.3 @@ -1,5 +1,5 @@ 142.4 /* 142.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 142.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 142.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 142.8 * 142.9 * This code is free software; you can redistribute it and/or modify it 142.10 @@ -26,7 +26,8 @@ 142.11 * @bug 6453386 142.12 * @summary Test Elements.getPackageOf 142.13 * @author Joseph D. Darcy 142.14 - * @build TestGetPackageOf 142.15 + * @library ../../../../lib 142.16 + * @build JavacTestingAbstractProcessor TestGetPackageOf 142.17 * @compile -processor TestGetPackageOf -proc:only TestGetPackageOf.java 142.18 */ 142.19 142.20 @@ -43,10 +44,7 @@ 142.21 /** 142.22 * Test basic workings of Elements.getPackageOf 142.23 */ 142.24 -@SupportedAnnotationTypes("*") 142.25 -public class TestGetPackageOf extends AbstractProcessor { 142.26 - private Elements eltUtils; 142.27 - 142.28 +public class TestGetPackageOf extends JavacTestingAbstractProcessor { 142.29 /** 142.30 * Check expected behavior on classes and packages. 142.31 */ 142.32 @@ -69,13 +67,4 @@ 142.33 } 142.34 return true; 142.35 } 142.36 - 142.37 - public SourceVersion getSupportedSourceVersion() { 142.38 - return SourceVersion.latest(); 142.39 - } 142.40 - 142.41 - public void init(ProcessingEnvironment processingEnv) { 142.42 - super.init(processingEnv); 142.43 - eltUtils = processingEnv.getElementUtils(); 142.44 - } 142.45 }
143.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 143.2 +++ b/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java Tue Oct 12 12:52:49 2010 -0700 143.3 @@ -0,0 +1,310 @@ 143.4 +/* 143.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 143.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 143.7 + * 143.8 + * This code is free software; you can redistribute it and/or modify it 143.9 + * under the terms of the GNU General Public License version 2 only, as 143.10 + * published by the Free Software Foundation. 143.11 + * 143.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 143.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 143.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 143.15 + * version 2 for more details (a copy is included in the LICENSE file that 143.16 + * accompanied this code). 143.17 + * 143.18 + * You should have received a copy of the GNU General Public License version 143.19 + * 2 along with this work; if not, write to the Free Software Foundation, 143.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 143.21 + * 143.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 143.23 + * or visit www.oracle.com if you need additional information or have any 143.24 + * questions. 143.25 + */ 143.26 + 143.27 +/* 143.28 + * @test 143.29 + * @bug 6877202 6986246 143.30 + * @summary Elements.getDocComment() is not getting JavaDocComments 143.31 + */ 143.32 + 143.33 +import com.sun.source.tree.*; 143.34 +import com.sun.source.util.*; 143.35 +import java.io.*; 143.36 +import java.util.*; 143.37 +import javax.annotation.processing.*; 143.38 +import javax.lang.model.*; 143.39 +import javax.lang.model.element.*; 143.40 +import javax.lang.model.util.*; 143.41 +import javax.tools.*; 143.42 + 143.43 +/* 143.44 + * For a mixture of pre-existing and generated source files, ensure that we can 143.45 + * get the doc comments. 143.46 + * The test uses both a standard ElementScanner to find all the elements being 143.47 + * processed, and a TreeScanner to find all the local and anonymous inner classes 143.48 + * as well. 143.49 + * And, because the relevant code paths in the compiler are different for 143.50 + * command line and JSR 199 invocation, the test covers both ways of invoking the 143.51 + * compiler. 143.52 + */ 143.53 + 143.54 +@SupportedOptions("scan") 143.55 +@SupportedAnnotationTypes("*") 143.56 +public class TestDocComments extends AbstractProcessor { 143.57 + enum CompileKind { API, CMD }; 143.58 + enum ScanKind { TREE, ELEMENT }; 143.59 + 143.60 + // ----- Main test driver: invoke compiler for the various test cases ------ 143.61 + 143.62 + public static void main(String... args) throws Exception { 143.63 + for (CompileKind ck: CompileKind.values()) { 143.64 + for (ScanKind sk: ScanKind.values()) { 143.65 + try { 143.66 + test(ck, sk); 143.67 + } catch (IOException e) { 143.68 + error(e.toString()); 143.69 + } 143.70 + } 143.71 + } 143.72 + 143.73 + if (errors > 0) 143.74 + throw new Exception(errors + " errors occurred"); 143.75 + } 143.76 + 143.77 + static void test(CompileKind ck, ScanKind sk) throws IOException { 143.78 + String testClasses = System.getProperty("test.classes"); 143.79 + String testSrc = System.getProperty("test.src"); 143.80 + File testDir = new File("test." + ck + "." + sk); 143.81 + testDir.mkdirs(); 143.82 + String[] opts = { 143.83 + "-d", testDir.getPath(), 143.84 + "-implicit:none", 143.85 + "-processor", TestDocComments.class.getName(), 143.86 + "-processorpath", testClasses, 143.87 + //"-XprintRounds", 143.88 + "-Ascan=" + sk 143.89 + }; 143.90 + File[] files = { 143.91 + new File(testSrc, "a/First.java") 143.92 + }; 143.93 + 143.94 + if (ck == CompileKind.API) 143.95 + test_javac_api(opts, files); 143.96 + else 143.97 + test_javac_cmd(opts, files); 143.98 + } 143.99 + 143.100 + static void test_javac_api(String[] opts, File[] files) throws IOException { 143.101 + System.err.println("test javac api: " + Arrays.asList(opts) + " " + Arrays.asList(files)); 143.102 + DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() { 143.103 + public void report(Diagnostic diagnostic) { 143.104 + error(diagnostic.toString()); 143.105 + } 143.106 + }; 143.107 + JavaCompiler c = ToolProvider.getSystemJavaCompiler(); 143.108 + StandardJavaFileManager fm = c.getStandardFileManager(null, null, null); 143.109 + Iterable<? extends JavaFileObject> units = fm.getJavaFileObjects(files); 143.110 + JavacTask t = (JavacTask) c.getTask(null, fm, dl, Arrays.asList(opts), null, units); 143.111 + t.parse(); 143.112 + t.analyze(); 143.113 + } 143.114 + 143.115 + static void test_javac_cmd(String[] opts, File[] files) { 143.116 + System.err.println("test javac cmd: " + Arrays.asList(opts) + " " + Arrays.asList(files)); 143.117 + StringWriter sw = new StringWriter(); 143.118 + PrintWriter pw = new PrintWriter(sw); 143.119 + List<String> args = new ArrayList<String>(Arrays.asList(opts)); 143.120 + for (File f: files) 143.121 + args.add(f.getPath()); 143.122 + int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw); 143.123 + pw.close(); 143.124 + String out = sw.toString(); 143.125 + if (out.length() > 0) 143.126 + System.err.println(out); 143.127 + if (rc > 0) 143.128 + error("Compilation failed: rc=" + rc); 143.129 + } 143.130 + 143.131 + static void error(String msg) { 143.132 + System.err.println(msg); 143.133 + errors++; 143.134 + //throw new Error(msg); 143.135 + } 143.136 + 143.137 + static int errors; 143.138 + 143.139 + // ----- Annotation processor: scan for elements and check doc comments ---- 143.140 + 143.141 + Map<String,String> options; 143.142 + Filer filer; 143.143 + Messager messager; 143.144 + Elements elements; 143.145 + Trees trees; 143.146 + ScanKind skind; 143.147 + 143.148 + int round = 0; 143.149 + 143.150 + @Override 143.151 + public SourceVersion getSupportedSourceVersion() { 143.152 + return SourceVersion.latest(); 143.153 + } 143.154 + 143.155 + @Override 143.156 + public void init(ProcessingEnvironment pEnv) { 143.157 + super.init(pEnv); 143.158 + options = pEnv.getOptions(); 143.159 + filer = pEnv.getFiler(); 143.160 + messager = pEnv.getMessager(); 143.161 + elements = pEnv.getElementUtils(); 143.162 + trees = Trees.instance(processingEnv); 143.163 + skind = ScanKind.valueOf(options.get("scan")); 143.164 + } 143.165 + 143.166 + @Override 143.167 + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 143.168 + round++; 143.169 + 143.170 + // Scan elements using an appropriate scanner, and for each element found, 143.171 + // call check(Element e) to verify the doc comment on that element 143.172 + for (Element e: roundEnv.getRootElements()) { 143.173 + System.err.println("scan " + skind + " " + e.getKind() + " " + e.getSimpleName()); 143.174 + if (skind == ScanKind.TREE) { 143.175 + new TestTreeScanner().scan(trees.getPath(e), trees); 143.176 + } else 143.177 + new TestElementScanner().scan(e); 143.178 + } 143.179 + 143.180 + // For a few rounds, generate new source files, so that we can check whether 143.181 + // doc comments are correctly handled in subsequent processing rounds 143.182 + final int MAX_ROUNDS = 3; 143.183 + if (round <= MAX_ROUNDS) { 143.184 + String pkg = "p"; 143.185 + String currClass = "Gen" + round; 143.186 + String curr = pkg + "." + currClass; 143.187 + String next = (round < MAX_ROUNDS) ? (pkg + ".Gen" + (round + 1)) : "z.Last"; 143.188 + StringBuilder text = new StringBuilder(); 143.189 + text.append("package ").append(pkg).append(";\n"); 143.190 + text.append("/** CLASS ").append(currClass).append(" */\n"); 143.191 + text.append("public class ").append(currClass).append(" {\n"); 143.192 + text.append(" /** CONSTRUCTOR <init> **/\n"); 143.193 + text.append(" ").append(currClass).append("() { }\n"); 143.194 + text.append(" /** FIELD x */\n"); 143.195 + text.append(" ").append(next).append(" x;\n"); 143.196 + text.append(" /** METHOD m */\n"); 143.197 + text.append(" void m() { }\n"); 143.198 + text.append("}\n"); 143.199 + 143.200 + try { 143.201 + JavaFileObject fo = filer.createSourceFile(curr); 143.202 + Writer out = fo.openWriter(); 143.203 + try { 143.204 + out.write(text.toString()); 143.205 + } finally { 143.206 + out.close(); 143.207 + } 143.208 + } catch (IOException e) { 143.209 + throw new Error(e); 143.210 + } 143.211 + } 143.212 + 143.213 + return true; 143.214 + } 143.215 + 143.216 + /* 143.217 + * Check that the doc comment on an element is as expected. 143.218 + * This method is invoked for each element found by the scanners run by process. 143.219 + */ 143.220 + void check(Element e) { 143.221 + System.err.println("Checking " + e); 143.222 + 143.223 + String dc = elements.getDocComment(e); 143.224 + System.err.println(" found " + dc); 143.225 + 143.226 + String expect = (e.getKind() + " " + e.getSimpleName()); // default 143.227 + 143.228 + Name name = e.getSimpleName(); 143.229 + Element encl = e.getEnclosingElement(); 143.230 + Name enclName = encl.getSimpleName(); 143.231 + ElementKind enclKind = encl.getKind(); 143.232 + switch (e.getKind()) { 143.233 + case PARAMETER: 143.234 + case LOCAL_VARIABLE: 143.235 + // doc comments not retained for these elements 143.236 + expect = null; 143.237 + break; 143.238 + 143.239 + case CONSTRUCTOR: 143.240 + if (enclName.length() == 0 || enclKind == ElementKind.ENUM) { 143.241 + // Enum constructor is synthetic 143.242 + expect = null; 143.243 + } 143.244 + break; 143.245 + 143.246 + case METHOD: 143.247 + if (enclKind == ElementKind.ENUM 143.248 + && (name.contentEquals("values") || name.contentEquals("valueOf"))) { 143.249 + // synthetic enum methods 143.250 + expect = null; 143.251 + } 143.252 + break; 143.253 + 143.254 + case CLASS: 143.255 + if (e.getSimpleName().length() == 0) { 143.256 + // anon inner class 143.257 + expect = null; 143.258 + } 143.259 + break; 143.260 + } 143.261 + 143.262 + System.err.println(" expect " + expect); 143.263 + 143.264 + if (dc == null ? expect == null : dc.trim().equals(expect)) 143.265 + return; 143.266 + 143.267 + if (dc == null) 143.268 + messager.printMessage(Diagnostic.Kind.ERROR, "doc comment is null", e); 143.269 + else { 143.270 + messager.printMessage(Diagnostic.Kind.ERROR, 143.271 + "unexpected comment: \"" + dc + "\", expected \"" + expect + "\"", e); 143.272 + } 143.273 + } 143.274 + 143.275 + // ----- Scanners to find elements ----------------------------------------- 143.276 + 143.277 + class TestElementScanner extends ElementScanner7<Void, Void> { 143.278 + @Override 143.279 + public Void visitExecutable(ExecutableElement e, Void _) { 143.280 + check(e); 143.281 + return super.visitExecutable(e, _); 143.282 + } 143.283 + @Override 143.284 + public Void visitType(TypeElement e, Void _) { 143.285 + check(e); 143.286 + return super.visitType(e, _); 143.287 + } 143.288 + @Override 143.289 + public Void visitVariable(VariableElement e, Void _) { 143.290 + check(e); 143.291 + return super.visitVariable(e, _); 143.292 + } 143.293 + } 143.294 + 143.295 + class TestTreeScanner extends TreePathScanner<Void,Trees> { 143.296 + @Override 143.297 + public Void visitClass(ClassTree tree, Trees trees) { 143.298 + check(trees.getElement(getCurrentPath())); 143.299 + return super.visitClass(tree, trees); 143.300 + } 143.301 + @Override 143.302 + public Void visitMethod(MethodTree tree, Trees trees) { 143.303 + check(trees.getElement(getCurrentPath())); 143.304 + return super.visitMethod(tree, trees); 143.305 + } 143.306 + @Override 143.307 + public Void visitVariable(VariableTree tree, Trees trees) { 143.308 + check(trees.getElement(getCurrentPath())); 143.309 + return super.visitVariable(tree, trees); 143.310 + } 143.311 + } 143.312 + 143.313 +}
144.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 144.2 +++ b/test/tools/javac/processing/model/util/elements/doccomments/a/First.java Tue Oct 12 12:52:49 2010 -0700 144.3 @@ -0,0 +1,54 @@ 144.4 +/* 144.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 144.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 144.7 + * 144.8 + * This code is free software; you can redistribute it and/or modify it 144.9 + * under the terms of the GNU General Public License version 2 only, as 144.10 + * published by the Free Software Foundation. 144.11 + * 144.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 144.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 144.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 144.15 + * version 2 for more details (a copy is included in the LICENSE file that 144.16 + * accompanied this code). 144.17 + * 144.18 + * You should have received a copy of the GNU General Public License version 144.19 + * 2 along with this work; if not, write to the Free Software Foundation, 144.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 144.21 + * 144.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 144.23 + * or visit www.oracle.com if you need additional information or have any 144.24 + * questions. 144.25 + */ 144.26 + 144.27 +package a; 144.28 + 144.29 +/** CLASS First */ 144.30 +public class First { 144.31 + /** CONSTRUCTOR <init> */ 144.32 + First() { } 144.33 + 144.34 + /** FIELD x */ 144.35 + p.Gen1 x; 144.36 + 144.37 + /** METHOD m **/ 144.38 + void m(int i) { 144.39 + /** CLASS Local */ 144.40 + class Local { 144.41 + /** CONSTRUCTOR <init> */ 144.42 + Local() { } 144.43 + } 144.44 + 144.45 + Runnable r = new Runnable() { 144.46 + /** METHOD run **/ 144.47 + public void run() { } 144.48 + }; 144.49 + 144.50 + } 144.51 + 144.52 + /** ENUM E */ 144.53 + enum E { 144.54 + /** ENUM_CONSTANT e1 */ 144.55 + e1 144.56 + } 144.57 +}
145.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 145.2 +++ b/test/tools/javac/processing/model/util/elements/doccomments/z/Last.java Tue Oct 12 12:52:49 2010 -0700 145.3 @@ -0,0 +1,30 @@ 145.4 +/* 145.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 145.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 145.7 + * 145.8 + * This code is free software; you can redistribute it and/or modify it 145.9 + * under the terms of the GNU General Public License version 2 only, as 145.10 + * published by the Free Software Foundation. 145.11 + * 145.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 145.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 145.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 145.15 + * version 2 for more details (a copy is included in the LICENSE file that 145.16 + * accompanied this code). 145.17 + * 145.18 + * You should have received a copy of the GNU General Public License version 145.19 + * 2 along with this work; if not, write to the Free Software Foundation, 145.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 145.21 + * 145.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 145.23 + * or visit www.oracle.com if you need additional information or have any 145.24 + * questions. 145.25 + */ 145.26 + 145.27 +package z; 145.28 + 145.29 +// This class should be read last, implicitly. Therefore it should not 145.30 +// be subject to anno processing. If it is, the lack of doc comments should 145.31 +// be detected and will flag an error. 145.32 +public class Last { 145.33 +}
146.1 --- a/test/tools/javac/processing/model/util/filter/TestIterables.java Thu Oct 07 15:12:31 2010 -0700 146.2 +++ b/test/tools/javac/processing/model/util/filter/TestIterables.java Tue Oct 12 12:52:49 2010 -0700 146.3 @@ -1,5 +1,5 @@ 146.4 /* 146.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 146.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 146.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 146.8 * 146.9 * This code is free software; you can redistribute it and/or modify it 146.10 @@ -26,6 +26,8 @@ 146.11 * @bug 6406164 146.12 * @summary Test that ElementFilter iterable methods behave properly. 146.13 * @author Joseph D. Darcy 146.14 + * @library ../../../../lib 146.15 + * @build JavacTestingAbstractProcessor 146.16 * @compile TestIterables.java 146.17 * @compile -processor TestIterables -proc:only Foo1.java 146.18 * @compile Foo1.java 146.19 @@ -51,9 +53,8 @@ 146.20 * results. 146.21 */ 146.22 @SupportedAnnotationTypes("ExpectedElementCounts") 146.23 -@ExpectedElementCounts(methods=3) 146.24 -public class TestIterables extends AbstractProcessor { 146.25 - 146.26 +@ExpectedElementCounts(methods=2) 146.27 +public class TestIterables extends JavacTestingAbstractProcessor { 146.28 public boolean process(Set<? extends TypeElement> annotations, 146.29 RoundEnvironment roundEnv) { 146.30 if (!roundEnv.processingOver()) { 146.31 @@ -118,10 +119,4 @@ 146.32 146.33 return count1; 146.34 } 146.35 - 146.36 - @Override 146.37 - public SourceVersion getSupportedSourceVersion() { 146.38 - return SourceVersion.latest(); 146.39 - } 146.40 - 146.41 }
147.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 147.2 +++ b/test/tools/javac/processing/options/Xprint.java Tue Oct 12 12:52:49 2010 -0700 147.3 @@ -0,0 +1,42 @@ 147.4 +/* 147.5 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 147.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 147.7 + * 147.8 + * This code is free software; you can redistribute it and/or modify it 147.9 + * under the terms of the GNU General Public License version 2 only, as 147.10 + * published by the Free Software Foundation. 147.11 + * 147.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 147.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 147.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 147.15 + * version 2 for more details (a copy is included in the LICENSE file that 147.16 + * accompanied this code). 147.17 + * 147.18 + * You should have received a copy of the GNU General Public License version 147.19 + * 2 along with this work; if not, write to the Free Software Foundation, 147.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 147.21 + * 147.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 147.23 + * or visit www.oracle.com if you need additional information or have any 147.24 + * questions. 147.25 + */ 147.26 + 147.27 +/* 147.28 + * @test 147.29 + * @bug 6266828 147.30 + * @summary JSR 269: Java Language Model API 147.31 + * @author Peter von der Ah\u00e9 147.32 + */ 147.33 +import javax.tools.JavaCompiler; 147.34 +import javax.tools.ToolProvider; 147.35 + 147.36 +public class Xprint { 147.37 + public static void main(String[] args) { 147.38 + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); 147.39 + javac.run(System.in, null, null, 147.40 + "-Xprint", 147.41 + "com.sun.tools.javac.code.Types", 147.42 + "com.sun.tools.javac.parser.Parser", 147.43 + "java.util.EnumSet"); 147.44 + } 147.45 +}
148.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 148.2 +++ b/test/tools/javac/processing/options/XprintDocComments.java Tue Oct 12 12:52:49 2010 -0700 148.3 @@ -0,0 +1,39 @@ 148.4 +/* 148.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 148.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 148.7 + * 148.8 + * This code is free software; you can redistribute it and/or modify it 148.9 + * under the terms of the GNU General Public License version 2 only, as 148.10 + * published by the Free Software Foundation. 148.11 + * 148.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 148.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 148.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 148.15 + * version 2 for more details (a copy is included in the LICENSE file that 148.16 + * accompanied this code). 148.17 + * 148.18 + * You should have received a copy of the GNU General Public License version 148.19 + * 2 along with this work; if not, write to the Free Software Foundation, 148.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 148.21 + * 148.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 148.23 + * or visit www.oracle.com if you need additional information or have any 148.24 + * questions. 148.25 + */ 148.26 + 148.27 +/* 148.28 + * @test 148.29 + * @bug 6861094 148.30 + * @summary javac -Xprint <file> does not print comments 148.31 + * @compile/ref=XprintDocComments.out -Xprint XprintDocComments.java 148.32 + */ 148.33 + 148.34 +/** 148.35 + * CLASS XprintDocComments 148.36 + */ 148.37 +class XPrintDocComments { 148.38 + /** 148.39 + * FIELD i; 148.40 + */ 148.41 + int i; 148.42 +}
149.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 149.2 +++ b/test/tools/javac/processing/options/XprintDocComments.out Tue Oct 12 12:52:49 2010 -0700 149.3 @@ -0,0 +1,12 @@ 149.4 + 149.5 +/** 149.6 + * CLASS XprintDocComments 149.7 + */ 149.8 +class XPrintDocComments { 149.9 + 149.10 + XPrintDocComments(); 149.11 + /** 149.12 + * FIELD i; 149.13 + */ 149.14 + int i; 149.15 +}
150.1 --- a/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java Thu Oct 07 15:12:31 2010 -0700 150.2 +++ b/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java Tue Oct 12 12:52:49 2010 -0700 150.3 @@ -1,5 +1,5 @@ 150.4 /* 150.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 150.6 + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 150.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 150.8 * 150.9 * This code is free software; you can redistribute it and/or modify it 150.10 @@ -50,7 +50,8 @@ 150.11 150.12 /** 150.13 * This processor returns the supported source level as indicated by 150.14 - * the "SourceLevel" option. 150.15 + * the "SourceLevel" option; therefore, don't use 150.16 + * JavacTestingAbstractProcessor which returns the latest source level. 150.17 */ 150.18 @SupportedAnnotationTypes("*") 150.19 @SupportedOptions("SourceVersion")
151.1 --- a/test/tools/javac/processing/werror/WError1.java Thu Oct 07 15:12:31 2010 -0700 151.2 +++ b/test/tools/javac/processing/werror/WError1.java Tue Oct 12 12:52:49 2010 -0700 151.3 @@ -24,6 +24,8 @@ 151.4 /* 151.5 * @test 6403456 151.6 * @summary -Werror should work with annotation processing 151.7 + * @library ../../lib 151.8 + * @build JavacTestingAbstractProcessor 151.9 * @compile WError1.java 151.10 * @compile -proc:only -processor WError1 WError1.java 151.11 * @compile/fail/ref=WError1.out -XDrawDiagnostics -Werror -proc:only -processor WError1 WError1.java 151.12 @@ -36,22 +38,15 @@ 151.13 import javax.lang.model.element.*; 151.14 import javax.tools.*; 151.15 151.16 -@SupportedAnnotationTypes("*") 151.17 -public class WError1 extends AbstractProcessor { 151.18 +public class WError1 extends JavacTestingAbstractProcessor { 151.19 @Override 151.20 public boolean process(Set<? extends TypeElement> annotations, 151.21 RoundEnvironment roundEnv) { 151.22 - Messager messager = processingEnv.getMessager(); 151.23 if (++round == 1) { 151.24 messager.printMessage(Diagnostic.Kind.WARNING, "round 1"); 151.25 } 151.26 return true; 151.27 } 151.28 151.29 - @Override 151.30 - public SourceVersion getSupportedSourceVersion() { 151.31 - return SourceVersion.latest(); 151.32 - } 151.33 - 151.34 int round = 0; 151.35 }
152.1 --- a/test/tools/javac/processing/werror/WErrorGen.java Thu Oct 07 15:12:31 2010 -0700 152.2 +++ b/test/tools/javac/processing/werror/WErrorGen.java Tue Oct 12 12:52:49 2010 -0700 152.3 @@ -24,6 +24,8 @@ 152.4 /* 152.5 * @test 6403456 152.6 * @summary -Werror should work with annotation processing 152.7 + * @library ../../lib 152.8 + * @build JavacTestingAbstractProcessor 152.9 * @compile WErrorGen.java 152.10 * @compile -proc:only -processor WErrorGen WErrorGen.java 152.11 * @compile/fail/ref=WErrorGen.out -XDrawDiagnostics -Werror -Xlint:rawtypes -processor WErrorGen WErrorGen.java 152.12 @@ -36,12 +38,10 @@ 152.13 import javax.lang.model.element.*; 152.14 import javax.tools.*; 152.15 152.16 -@SupportedAnnotationTypes("*") 152.17 -public class WErrorGen extends AbstractProcessor { 152.18 +public class WErrorGen extends JavacTestingAbstractProcessor { 152.19 @Override 152.20 public boolean process(Set<? extends TypeElement> annotations, 152.21 RoundEnvironment roundEnv) { 152.22 - Filer filer = processingEnv.getFiler(); 152.23 if (++round == 1) { 152.24 try { 152.25 JavaFileObject fo = filer.createSourceFile("Gen"); 152.26 @@ -54,10 +54,5 @@ 152.27 return true; 152.28 } 152.29 152.30 - @Override 152.31 - public SourceVersion getSupportedSourceVersion() { 152.32 - return SourceVersion.latest(); 152.33 - } 152.34 - 152.35 int round = 0; 152.36 }
153.1 --- a/test/tools/javac/processing/werror/WErrorLast.java Thu Oct 07 15:12:31 2010 -0700 153.2 +++ b/test/tools/javac/processing/werror/WErrorLast.java Tue Oct 12 12:52:49 2010 -0700 153.3 @@ -24,6 +24,8 @@ 153.4 /* 153.5 * @test 6403456 153.6 * @summary -Werror should work with annotation processing 153.7 + * @library ../../lib 153.8 + * @build JavacTestingAbstractProcessor 153.9 * @compile WErrorLast.java 153.10 * @compile -proc:only -processor WErrorLast WErrorLast.java 153.11 * @compile/fail/ref=WErrorLast.out -XDrawDiagnostics -Werror -proc:only -processor WErrorLast WErrorLast.java 153.12 @@ -36,20 +38,13 @@ 153.13 import javax.lang.model.element.*; 153.14 import javax.tools.*; 153.15 153.16 -@SupportedAnnotationTypes("*") 153.17 -public class WErrorLast extends AbstractProcessor { 153.18 +public class WErrorLast extends JavacTestingAbstractProcessor { 153.19 @Override 153.20 public boolean process(Set<? extends TypeElement> annotations, 153.21 RoundEnvironment roundEnv) { 153.22 - Messager messager = processingEnv.getMessager(); 153.23 if (roundEnv.processingOver()) { 153.24 messager.printMessage(Diagnostic.Kind.WARNING, "last round"); 153.25 } 153.26 return true; 153.27 } 153.28 - 153.29 - @Override 153.30 - public SourceVersion getSupportedSourceVersion() { 153.31 - return SourceVersion.latest(); 153.32 - } 153.33 }
154.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 154.2 +++ b/test/tools/javac/tree/TreePosRoundsTest.java Tue Oct 12 12:52:49 2010 -0700 154.3 @@ -0,0 +1,205 @@ 154.4 +/* 154.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 154.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 154.7 + * 154.8 + * This code is free software; you can redistribute it and/or modify it 154.9 + * under the terms of the GNU General Public License version 2 only, as 154.10 + * published by the Free Software Foundation. 154.11 + * 154.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 154.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 154.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 154.15 + * version 2 for more details (a copy is included in the LICENSE file that 154.16 + * accompanied this code). 154.17 + * 154.18 + * You should have received a copy of the GNU General Public License version 154.19 + * 2 along with this work; if not, write to the Free Software Foundation, 154.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 154.21 + * 154.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 154.23 + * or visit www.oracle.com if you need additional information or have any 154.24 + * questions. 154.25 + */ 154.26 + 154.27 +/* 154.28 + * @test 154.29 + * @bug 6985205 6986246 154.30 + * @summary access to tree positions and doc comments may be lost across annotation processing rounds 154.31 + * @build TreePosRoundsTest 154.32 + * @compile -proc:only -processor TreePosRoundsTest TreePosRoundsTest.java 154.33 + * @run main TreePosRoundsTest 154.34 + */ 154.35 + 154.36 +import java.io.*; 154.37 +import java.util.*; 154.38 +import javax.annotation.processing.*; 154.39 +import javax.lang.model.*; 154.40 +import javax.lang.model.element.*; 154.41 +import javax.tools.*; 154.42 + 154.43 +import com.sun.source.tree.*; 154.44 +import com.sun.source.util.*; 154.45 +import javax.tools.JavaCompiler.CompilationTask; 154.46 + 154.47 +// This test is an annotation processor that performs multiple rounds of 154.48 +// processing, and on each round, it checks that source positions are 154.49 +// available and correct. 154.50 +// 154.51 +// The test can be run directly as a processor from the javac command line 154.52 +// or via JSR 199 by invoking the main program. 154.53 + 154.54 +@SupportedAnnotationTypes("*") 154.55 +public class TreePosRoundsTest extends AbstractProcessor { 154.56 + public static void main(String... args) throws Exception { 154.57 + String testSrc = System.getProperty("test.src"); 154.58 + String testClasses = System.getProperty("test.classes"); 154.59 + JavaCompiler c = ToolProvider.getSystemJavaCompiler(); 154.60 + StandardJavaFileManager fm = c.getStandardFileManager(null, null, null); 154.61 + String thisName = TreePosRoundsTest.class.getName(); 154.62 + File thisFile = new File(testSrc, thisName + ".java"); 154.63 + Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile); 154.64 + List<String> options = Arrays.asList( 154.65 + "-proc:only", 154.66 + "-processor", thisName, 154.67 + "-processorpath", testClasses); 154.68 + CompilationTask t = c.getTask(null, fm, null, options, null, files); 154.69 + boolean ok = t.call(); 154.70 + if (!ok) 154.71 + throw new Exception("processing failed"); 154.72 + } 154.73 + 154.74 + Filer filer; 154.75 + Messager messager; 154.76 + Trees trees; 154.77 + 154.78 + @Override 154.79 + public SourceVersion getSupportedSourceVersion() { 154.80 + return SourceVersion.latest(); 154.81 + } 154.82 + 154.83 + @Override 154.84 + public void init(ProcessingEnvironment pEnv) { 154.85 + super.init(pEnv); 154.86 + filer = pEnv.getFiler(); 154.87 + messager = pEnv.getMessager(); 154.88 + trees = Trees.instance(pEnv); 154.89 + } 154.90 + 154.91 + int round = 0; 154.92 + 154.93 + @Override 154.94 + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 154.95 + round++; 154.96 + 154.97 + // Scan trees for elements, verifying source tree positions 154.98 + for (Element e: roundEnv.getRootElements()) { 154.99 + try { 154.100 + TreePath p = trees.getPath(e); 154.101 + new TestTreeScanner(p.getCompilationUnit(), trees).scan(trees.getPath(e), null); 154.102 + } catch (IOException ex) { 154.103 + messager.printMessage(Diagnostic.Kind.ERROR, 154.104 + "Cannot get source: " + ex, e); 154.105 + } 154.106 + } 154.107 + 154.108 + final int MAXROUNDS = 3; 154.109 + if (round < MAXROUNDS) 154.110 + generateSource("Gen" + round); 154.111 + 154.112 + return true; 154.113 + } 154.114 + 154.115 + void generateSource(String name) { 154.116 + StringBuilder text = new StringBuilder(); 154.117 + text.append("class ").append(name).append("{\n"); 154.118 + text.append(" int one = 1;\n"); 154.119 + text.append(" int two = 2;\n"); 154.120 + text.append(" int three = one + two;\n"); 154.121 + text.append("}\n"); 154.122 + 154.123 + try { 154.124 + JavaFileObject fo = filer.createSourceFile(name); 154.125 + Writer out = fo.openWriter(); 154.126 + try { 154.127 + out.write(text.toString()); 154.128 + } finally { 154.129 + out.close(); 154.130 + } 154.131 + } catch (IOException e) { 154.132 + throw new Error(e); 154.133 + } 154.134 + } 154.135 + 154.136 + class TestTreeScanner extends TreePathScanner<Void,Void> { 154.137 + TestTreeScanner(CompilationUnitTree unit, Trees trees) throws IOException { 154.138 + this.unit = unit; 154.139 + JavaFileObject sf = unit.getSourceFile(); 154.140 + source = sf.getCharContent(true).toString(); 154.141 + sourcePositions = trees.getSourcePositions(); 154.142 + } 154.143 + 154.144 + @Override 154.145 + public Void visitVariable(VariableTree tree, Void _) { 154.146 + check(getCurrentPath()); 154.147 + return super.visitVariable(tree, _); 154.148 + } 154.149 + 154.150 + void check(TreePath tp) { 154.151 + Tree tree = tp.getLeaf(); 154.152 + 154.153 + String expect = tree.toString(); 154.154 + if (tree.getKind() == Tree.Kind.VARIABLE) { 154.155 + // tree.toString() does not know enough context to add ";", 154.156 + // so deal with that manually... 154.157 + Tree.Kind enclKind = tp.getParentPath().getLeaf().getKind(); 154.158 + //System.err.println(" encl: " +enclKind); 154.159 + if (enclKind == Tree.Kind.CLASS || enclKind == Tree.Kind.BLOCK) 154.160 + expect += ";"; 154.161 + } 154.162 + //System.err.println("expect: " + expect); 154.163 + 154.164 + int start = (int)sourcePositions.getStartPosition(unit, tree); 154.165 + if (start == Diagnostic.NOPOS) { 154.166 + messager.printMessage(Diagnostic.Kind.ERROR, "start pos not set for " + trim(tree)); 154.167 + return; 154.168 + } 154.169 + 154.170 + int end = (int)sourcePositions.getEndPosition(unit, tree); 154.171 + if (end == Diagnostic.NOPOS) { 154.172 + messager.printMessage(Diagnostic.Kind.ERROR, "end pos not set for " + trim(tree)); 154.173 + return; 154.174 + } 154.175 + 154.176 + String found = source.substring(start, end); 154.177 + //System.err.println(" found: " + found); 154.178 + 154.179 + // allow for long lines, in which case just compare beginning and 154.180 + // end of the strings 154.181 + boolean equal; 154.182 + if (found.contains("\n")) { 154.183 + String head = found.substring(0, found.indexOf("\n")); 154.184 + String tail = found.substring(found.lastIndexOf("\n")).trim(); 154.185 + equal = expect.startsWith(head) && expect.endsWith(tail); 154.186 + } else { 154.187 + equal = expect.equals(found); 154.188 + } 154.189 + 154.190 + if (!equal) { 154.191 + messager.printMessage(Diagnostic.Kind.ERROR, 154.192 + "unexpected value found: '" + found + "'; expected: '" + expect + "'"); 154.193 + } 154.194 + } 154.195 + 154.196 + String trim(Tree tree) { 154.197 + final int MAXLEN = 32; 154.198 + String s = tree.toString().replaceAll("\\s+", " ").trim(); 154.199 + return (s.length() < MAXLEN) ? s : s.substring(0, MAXLEN); 154.200 + 154.201 + } 154.202 + 154.203 + CompilationUnitTree unit; 154.204 + SourcePositions sourcePositions; 154.205 + String source; 154.206 + } 154.207 + 154.208 +}
155.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 155.2 +++ b/test/tools/javah/VersionTest.java Tue Oct 12 12:52:49 2010 -0700 155.3 @@ -0,0 +1,59 @@ 155.4 +/* 155.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 155.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 155.7 + * 155.8 + * This code is free software; you can redistribute it and/or modify it 155.9 + * under the terms of the GNU General Public License version 2 only, as 155.10 + * published by the Free Software Foundation. 155.11 + * 155.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 155.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 155.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 155.15 + * version 2 for more details (a copy is included in the LICENSE file that 155.16 + * accompanied this code). 155.17 + * 155.18 + * You should have received a copy of the GNU General Public License version 155.19 + * 2 along with this work; if not, write to the Free Software Foundation, 155.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 155.21 + * 155.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 155.23 + * or visit www.oracle.com if you need additional information or have any 155.24 + * questions. 155.25 + */ 155.26 + 155.27 +/* 155.28 + * @test 155.29 + * @bug 6890226 155.30 + * @summary javah -version is broken 155.31 + */ 155.32 + 155.33 +import java.io.*; 155.34 +import java.util.Locale; 155.35 + 155.36 +public class VersionTest { 155.37 + public static void main(String... args) { 155.38 + Locale prev = Locale.getDefault(); 155.39 + try { 155.40 + Locale.setDefault(Locale.ENGLISH); 155.41 + System.err.println(Locale.getDefault()); 155.42 + test("-version", "\\S+ version \"\\S+\""); 155.43 + test("-fullversion", "\\S+ full version \"\\S+\""); 155.44 + } finally { 155.45 + Locale.setDefault(prev); 155.46 + } 155.47 + } 155.48 + 155.49 + static void test(String option, String regex) { 155.50 + StringWriter sw = new StringWriter(); 155.51 + PrintWriter pw = new PrintWriter(sw); 155.52 + String[] args = { option }; 155.53 + int rc = com.sun.tools.javah.Main.run(args, pw); 155.54 + pw.close(); 155.55 + if (rc != 0) 155.56 + throw new Error("javah failed: rc=" + rc); 155.57 + String out = sw.toString().trim(); 155.58 + System.err.println(out); 155.59 + if (!out.matches(regex)) 155.60 + throw new Error("output does not match pattern: " + regex); 155.61 + } 155.62 +}