--- a/langtools/make/netbeans/langtools/build.xml Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/make/netbeans/langtools/build.xml Mon Oct 04 14:40:38 2010 -0700
@@ -31,44 +31,44 @@
-->
<project name="langtools-netbeans" default="build" basedir="../../..">
-
- <property name="langtools.properties"
+
+ <property name="langtools.properties"
location="make/netbeans/langtools/nbproject/private/langtools.properties"/>
-
- <!--
+
+ <!--
Instead of importing the main build file, we could call it when needed.
That would reduce the list of Ant targets that get displayed for this
- file, but it also complicates the interface between the project build
+ file, but it also complicates the interface between the project build
file and the main build file. For example, some imported targets
would have to be reclared, properties would have to be restructured,
- and it would be harder to run results (e.g. in properties) from nested
+ and it would be harder to run results (e.g. in properties) from nested
targets.
-->
- <import file="../../build.xml"/>
-
+ <import file="../../build.xml"/>
+
<!-- Build project. (action: build; F11)
If langtools.tool.name is set, then just build that tool; otherwise
build all tools.
-->
-
- <target name="build" depends="-get-tool-if-set,-build-tool,-build-all"
+
+ <target name="build" depends="-get-tool-if-set,-build-tool,-build-all"
description="Build one or all langtools tools"
/>
-
+
<target name="-build-tool" if="langtools.tool.name">
<echo level="info" message="Building ${langtools.tool.name}"/>
<echo level="verbose" message="(Unset langtools.tool.name to build all tools)"/>
<antcall target="build-${langtools.tool.name}"/>
</target>
-
+
<target name="-build-all" unless="langtools.tool.name">
<echo level="info" message="Building all tools"/>
<echo level="verbose" message="(Set langtools.tool.name to build a single tool)"/>
<antcall target="build-all-tools"/>
</target>
-
+
<!-- Compile a single file. (action: compile.single; F9) -->
-
+
<target name="compile-single" depends="build-bootstrap-javac">
<fail unless="includes">Must set property 'includes'</fail>
<javac fork="true" executable="${build.bootstrap.dir}/bin/javac"
@@ -78,38 +78,38 @@
sourcepath=""
includeAntRuntime="no"
target="${javac.target}"
- debug="${javac.debug}"
+ debug="${javac.debug}"
debuglevel="${javac.debuglevel}"/>
</target>
-
- <!-- Run tool. (action: run; F6)
+
+ <!-- Run tool. (action: run; F6)
Use langtools.tool.name and langtools.tool.args properties if set; otherwise prompt
the user.
-->
-
- <target name="run" depends="-check-target.java.home,build,-def-run,-get-tool-and-args"
+
+ <target name="run" depends="-check-target.java.home,build,-def-run,-get-tool-and-args"
description="run tool">
<echo level="info" message="Run ${langtools.tool.name} with args ${langtools.tool.args}"/>
<run mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}"/>
</target>
-
+
<!-- Run a selected class. (action: run.single; shift-F6) -->
-
+
<target name="run-single" depends="-check-target.java.home,-def-run">
<fail unless="run.classname">Must set property 'run.classname' </fail>
<echo level="info" message="run ${run.classname}"/>
<run mainclass="${run.classname}" args=""/>
</target>
-
+
<!-- Test project, and display results if tests failed. (action: test; Alt-F6)
If langtools.tool.name is set, then just test that tool; otherwise
test all tools.
-->
-
- <target name="jtreg" depends="-get-tool-if-set,-jtreg-tool,-jtreg-all"
+
+ <target name="jtreg" depends="-get-tool-if-set,-jtreg-tool,-jtreg-all"
description="Test one or all langtools tools"
/>
-
+
<target name="-jtreg-tool" if="langtools.tool.name">
<echo level="info" message="Testing ${langtools.tool.name}"/>
<echo level="verbose" message="(Unset langtools.tool.name to test all tools)"/>
@@ -118,7 +118,7 @@
<target name="-show-jtreg"/>
</antcall>
</target>
-
+
<target name="-jtreg-all" unless="langtools.tool.name">
<echo level="info" message="Testing all tools"/>
<echo level="verbose" message="(Set langtools.tool.name to test a single tool)"/>
@@ -127,36 +127,36 @@
<target name="-show-jtreg"/>
</antcall>
</target>
-
+
<target name="-show-jtreg" if="netbeans.home" unless="jtreg.passed">
<nbbrowse file="${jtreg.report}/report.html"/>
<fail>Some tests failed; see report for details.</fail>
</target>
-
+
<!-- Debug tool in NetBeans. -->
-
+
<target name="debug" depends="-check-target.java.home,-def-run,-def-start-debugger,-get-tool-and-args,build" if="netbeans.home">
<echo level="info" message="Debug ${langtools.tool.name} with args ${langtools.tool.args}"/>
<start-debugger/>
<run mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}" jpda.jvmargs="${jpda.jvmargs}"/>
</target>
-
+
<!-- Debug a selected class . -->
<target name="debug-single" depends="-check-target.java.home,-def-start-debugger,-def-run">
<fail unless="debug.classname">Must set property 'debug.classname'</fail>
<start-debugger/>
<run mainclass="${debug.classname}" default.args="" jpda.jvmargs="${jpda.jvmargs}"/>
</target>
-
+
<!-- Debug a jtreg test. -->
<target name="debug-jtreg" depends="-check-target.java.home,-def-start-debugger,-def-jtreg">
<fail unless="jtreg.tests">Must set property 'jtreg.tests'</fail>
<start-debugger/>
<jtreg-tool name="debug" samevm="false" tests="${jtreg.tests}" jpda.jvmargs="${jpda.jvmargs}"/>
</target>
-
+
<!-- Update a class being debugged. -->
-
+
<target name="debug-fix" if="langtools.tool.name">
<fail unless="class">Must set property 'class'
</fail>
@@ -169,16 +169,16 @@
</fileset>
</nbjpdareload>
</target>
-
+
<!-- Generate javadoc for one or all tools. (action: javadoc; Alt-F6)
If langtools.tool.name is set, then just test that tool; otherwise
test all tools.
-->
-
- <target name="javadoc" depends="-javadoc-tool,-javadoc-all"
+
+ <target name="javadoc" depends="-javadoc-tool,-javadoc-all"
description="Generate javadoc for one or all langtools tools"
/>
-
+
<target name="-javadoc-tool" if="langtools.tool.name">
<echo level="info" message="Generate javadoc for ${langtools.tool.name}"/>
<echo level="verbose" message="(Unset langtools.tool.name to generate javadoc for all tools)"/>
@@ -187,7 +187,7 @@
<target name="-show-javadoc"/>
</antcall>
</target>
-
+
<target name="-javadoc-all" unless="langtools.tool.name">
<echo level="info" message="Generate javadoc for all tools"/>
<echo level="verbose" message="(Set langtools.tool.name to generate javadoc for a single tool)"/>
@@ -196,26 +196,26 @@
<target name="-show-javadoc"/>
</antcall>
</target>
-
+
<target name="-show-javadoc" if="netbeans.home">
<!-- what if doing javadoc for all? -->
<nbbrowse file="${build.javadoc.dir}/${langtools.tool.name}/index.html"/>
</target>
-
+
<!-- Prompt for values. -->
-
+
<target name="-get-tool-if-set" depends="-def-select-tool">
- <select-tool
- toolproperty="langtools.tool.name"
+ <select-tool
+ toolproperty="langtools.tool.name"
propertyfile="${langtools.properties}"
askIfUnset="false"
/>
</target>
-
+
<target name="-get-tool-and-args" depends="-def-select-tool">
- <select-tool
- toolproperty="langtools.tool.name"
- argsproperty="langtools.tool.args"
+ <select-tool
+ toolproperty="langtools.tool.name"
+ argsproperty="langtools.tool.args"
propertyfile="${langtools.properties}"
askIfUnset="true"
/>
@@ -236,7 +236,7 @@
</sequential>
</macrodef>
</target>
-
+
<!-- Macro to start the debugger and set a property containg the args needed by the run task -->
<target name="-def-start-debugger" if="netbeans.home">
<macrodef name="start-debugger">
@@ -251,28 +251,29 @@
<pathelement location="${src.classes.dir}"/>
</sourcepath>
</nbjpdastart>
- <property
- name="@{jpda.jvmargs.property}"
+ <property
+ name="@{jpda.jvmargs.property}"
value="-Xdebug -Xnoagent -Djava.compiler=none -Xrunjdwp:transport=dt_socket,address=${jpda.address}"
/>
</sequential>
</macrodef>
</target>
-
+
<target name="-def-select-tool">
<mkdir dir="${build.toolclasses.dir}"/>
<javac srcdir="${make.tools.dir}/SelectTool"
destdir="${build.toolclasses.dir}/"
- classpath="${ant.home}/lib/ant.jar"
- debug="${javac.debug}"
+ classpath="${ant.core.lib}"
+ includeantruntime="false"
+ debug="${javac.debug}"
debuglevel="${javac.debuglevel}">
<compilerarg line="-Xlint"/>
</javac>
<taskdef name="select-tool"
- classname="SelectToolTask"
+ classname="SelectToolTask"
classpath="${build.toolclasses.dir}/"/>
</target>
-
+
<target name="select-tool" depends="-def-select-tool">
<select-tool propertyfile="${langtools.properties}"/>
</target>
--- a/langtools/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -99,9 +99,6 @@
private static Context preRegister(Context context) {
Bark.preRegister(context);
- // force the use of the scanner that captures Javadoc comments
- DocCommentScanner.Factory.preRegister(context);
-
if (context.get(JavaFileManager.class) == null)
JavacFileManager.preRegister(context);
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -96,9 +96,6 @@
args.getClass();
context.getClass();
fileObjects.getClass();
-
- // force the use of the scanner that captures Javadoc comments
- com.sun.tools.javac.parser.DocCommentScanner.Factory.preRegister(context);
}
JavacTaskImpl(JavacTool tool,
@@ -337,9 +334,13 @@
ListBuffer<TypeElement> elements = new ListBuffer<TypeElement>();
for (JCCompilationUnit unit : units) {
- for (JCTree node : unit.defs)
- if (node.getTag() == JCTree.CLASSDEF)
- elements.append(((JCTree.JCClassDecl) node).sym);
+ for (JCTree node : unit.defs) {
+ if (node.getTag() == JCTree.CLASSDEF) {
+ JCClassDecl cdef = (JCClassDecl) node;
+ if (cdef.sym != null) // maybe null if errors in anno processing
+ elements.append(cdef.sym);
+ }
+ }
}
return elements.toList();
}
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,6 @@
import com.sun.tools.javac.comp.MemberEnter;
import com.sun.tools.javac.comp.Resolve;
import com.sun.tools.javac.model.JavacElements;
-import com.sun.tools.javac.processing.JavacMessager;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.tree.JCTree;
@@ -81,14 +80,15 @@
*/
public class JavacTrees extends Trees {
- private final Resolve resolve;
- private final Enter enter;
- private final Log log;
- private final MemberEnter memberEnter;
- private final Attr attr;
- private final TreeMaker treeMaker;
- private final JavacElements elements;
- private final JavacTaskImpl javacTaskImpl;
+ // in a world of a single context per compilation, these would all be final
+ private Resolve resolve;
+ private Enter enter;
+ private Log log;
+ private MemberEnter memberEnter;
+ private Attr attr;
+ private TreeMaker treeMaker;
+ private JavacElements elements;
+ private JavacTaskImpl javacTaskImpl;
public static JavacTrees instance(JavaCompiler.CompilationTask task) {
if (!(task instanceof JavacTaskImpl))
@@ -111,6 +111,14 @@
private JavacTrees(Context context) {
context.put(JavacTrees.class, this);
+ init(context);
+ }
+
+ public void updateContext(Context context) {
+ init(context);
+ }
+
+ private void init(Context context) {
attr = Attr.instance(context);
enter = Enter.instance(context);
elements = JavacElements.instance(context);
@@ -337,6 +345,7 @@
super(M);
}
+ @Override
public <T extends JCTree> T copy(T t, JCTree leaf) {
T t2 = super.copy(t, leaf);
if (t == leaf)
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Mon Oct 04 14:40:38 2010 -0700
@@ -70,6 +70,45 @@
*/
public int nelems = 0;
+ /** A timestamp - useful to quickly check whether a scope has changed or not
+ */
+ public ScopeCounter scopeCounter;
+
+ static ScopeCounter dummyCounter = new ScopeCounter() {
+ @Override
+ public void inc() {
+ //do nothing
+ }
+ };
+
+ public static class ScopeCounter {
+ protected static final Context.Key<ScopeCounter> scopeCounterKey =
+ new Context.Key<ScopeCounter>();
+
+ public static ScopeCounter instance(Context context) {
+ ScopeCounter instance = context.get(scopeCounterKey);
+ if (instance == null)
+ instance = new ScopeCounter(context);
+ return instance;
+ }
+
+ protected ScopeCounter(Context context) {
+ context.put(scopeCounterKey, this);
+ }
+
+ private ScopeCounter() {};
+
+ private long val = 0;
+
+ public void inc() {
+ val++;
+ }
+
+ public long val() {
+ return val;
+ }
+ }
+
/** Every hash bucket is a list of Entry's which ends in sentinel.
*/
private static final Entry sentinel = new Entry(null, null, null, null);
@@ -80,12 +119,12 @@
/** A value for the empty scope.
*/
- public static final Scope emptyScope = new Scope(null, null, new Entry[]{});
+ public static final Scope emptyScope = new Scope(null, null, new Entry[]{}, dummyCounter);
/** Construct a new scope, within scope next, with given owner, using
* given table. The table's length must be an exponent of 2.
*/
- Scope(Scope next, Symbol owner, Entry[] table) {
+ private Scope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) {
this.next = next;
assert emptyScope == null || owner != null;
this.owner = owner;
@@ -94,13 +133,18 @@
this.elems = null;
this.nelems = 0;
this.shared = 0;
+ this.scopeCounter = scopeCounter;
}
/** Construct a new scope, within scope next, with given owner,
* using a fresh table of length INITIAL_SIZE.
*/
public Scope(Symbol owner) {
- this(null, owner, new Entry[INITIAL_SIZE]);
+ this(owner, dummyCounter);
+ }
+
+ protected Scope(Symbol owner, ScopeCounter scopeCounter) {
+ this(null, owner, new Entry[INITIAL_SIZE], scopeCounter);
for (int i = 0; i < INITIAL_SIZE; i++) table[i] = sentinel;
}
@@ -110,7 +154,7 @@
* of fresh tables.
*/
public Scope dup() {
- Scope result = new Scope(this, this.owner, this.table);
+ Scope result = new Scope(this, this.owner, this.table, scopeCounter);
shared++;
// System.out.println("====> duping scope " + this.hashCode() + " owned by " + this.owner + " to " + result.hashCode());
// new Error().printStackTrace(System.out);
@@ -123,7 +167,7 @@
* of fresh tables.
*/
public Scope dup(Symbol newOwner) {
- Scope result = new Scope(this, newOwner, this.table);
+ Scope result = new Scope(this, newOwner, this.table, scopeCounter);
shared++;
// System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode());
// new Error().printStackTrace(System.out);
@@ -135,7 +179,7 @@
* the table of its outer scope.
*/
public Scope dupUnshared() {
- return new Scope(this, this.owner, this.table.clone());
+ return new Scope(this, this.owner, this.table.clone(), scopeCounter);
}
/** Remove all entries of this scope from its table, if shared
@@ -211,6 +255,7 @@
table[hash] = e;
elems = e;
nelems++;
+ scopeCounter.inc();
}
Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) {
@@ -226,6 +271,8 @@
while (e.scope == this && e.sym != sym) e = e.next();
if (e.scope == null) return;
+ scopeCounter.inc();
+
// remove e from table and shadowed list;
Entry te = table[sym.name.hashCode() & hashMask];
if (te == e)
@@ -472,7 +519,7 @@
public static final Entry[] emptyTable = new Entry[0];
public DelegatedScope(Scope outer) {
- super(outer, outer.owner, emptyTable);
+ super(outer, outer.owner, emptyTable, outer.scopeCounter);
delegatee = outer;
}
public Scope dup() {
@@ -498,10 +545,22 @@
}
}
+ /** A class scope, for which a scope counter should be provided */
+ public static class ClassScope extends Scope {
+
+ ClassScope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) {
+ super(next, owner, table, scopeCounter);
+ }
+
+ public ClassScope(Symbol owner, ScopeCounter scopeCounter) {
+ super(owner, scopeCounter);
+ }
+ }
+
/** An error scope, for which the owner should be an error symbol. */
public static class ErrorScope extends Scope {
ErrorScope(Scope next, Symbol errSymbol, Entry[] table) {
- super(next, /*owner=*/errSymbol, table);
+ super(next, /*owner=*/errSymbol, table, dummyCounter);
}
public ErrorScope(Symbol errSymbol) {
super(errSymbol);
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Mon Oct 04 14:40:38 2010 -0700
@@ -25,11 +25,14 @@
package com.sun.tools.javac.code;
+import java.util.*;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.jvm.Target;
-import javax.lang.model.SourceVersion;
-import static javax.lang.model.SourceVersion.*;
-import java.util.*;
+
+import static com.sun.tools.javac.main.OptionName.*;
/** The source language version accepted.
*
@@ -71,7 +74,7 @@
Source instance = context.get(sourceKey);
if (instance == null) {
Options options = Options.instance(context);
- String sourceString = options.get("-source");
+ String sourceString = options.get(SOURCE);
if (sourceString != null) instance = lookup(sourceString);
if (instance == null) instance = DEFAULT;
context.put(sourceKey, instance);
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -960,6 +960,8 @@
return ElementKind.ENUM_CONSTANT;
} else if (owner.kind == TYP || owner.kind == ERR) {
return ElementKind.FIELD;
+ } else if (isResourceVariable()) {
+ return ElementKind.RESOURCE_VARIABLE;
} else {
return ElementKind.LOCAL_VARIABLE;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Mon Oct 04 14:40:38 2010 -0700
@@ -74,6 +74,7 @@
public final JCNoType voidType = new JCNoType(TypeTags.VOID);
private final Names names;
+ private final Scope.ScopeCounter scopeCounter;
private final ClassReader reader;
private final Target target;
@@ -340,6 +341,7 @@
context.put(symtabKey, this);
names = Names.instance(context);
+ scopeCounter = Scope.ScopeCounter.instance(context);
target = Target.instance(context);
// Create the unknown type
@@ -386,7 +388,7 @@
// Create class to hold all predefined constants and operations.
predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
- Scope scope = new Scope(predefClass);
+ Scope scope = new Scope.ClassScope(predefClass, scopeCounter);
predefClass.members_field = scope;
// Enter symbols for basic types.
@@ -476,7 +478,7 @@
proprietarySymbol.completer = null;
proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
proprietarySymbol.erasure_field = proprietaryType;
- proprietarySymbol.members_field = new Scope(proprietarySymbol);
+ proprietarySymbol.members_field = new Scope.ClassScope(proprietarySymbol, scopeCounter);
proprietaryType.typarams_field = List.nil();
proprietaryType.allparams_field = List.nil();
proprietaryType.supertype_field = annotationType;
@@ -488,7 +490,7 @@
ClassType arrayClassType = (ClassType)arrayClass.type;
arrayClassType.supertype_field = objectType;
arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
- arrayClass.members_field = new Scope(arrayClass);
+ arrayClass.members_field = new Scope.ClassScope(arrayClass, scopeCounter);
lengthVar = new VarSymbol(
PUBLIC | FINAL,
names.length,
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Mon Oct 04 14:40:38 2010 -0700
@@ -69,6 +69,7 @@
new Context.Key<Types>();
final Symtab syms;
+ final Scope.ScopeCounter scopeCounter;
final JavacMessages messages;
final Names names;
final boolean allowBoxing;
@@ -89,6 +90,7 @@
protected Types(Context context) {
context.put(typesKey, this);
syms = Symtab.instance(context);
+ scopeCounter = Scope.ScopeCounter.instance(context);
names = Names.instance(context);
allowBoxing = Source.instance(context).allowBoxing();
reader = ClassReader.instance(context);
@@ -1984,22 +1986,26 @@
final MethodSymbol cachedImpl;
final Filter<Symbol> implFilter;
final boolean checkResult;
+ final Scope.ScopeCounter scopeCounter;
public Entry(MethodSymbol cachedImpl,
Filter<Symbol> scopeFilter,
- boolean checkResult) {
+ boolean checkResult,
+ Scope.ScopeCounter scopeCounter) {
this.cachedImpl = cachedImpl;
this.implFilter = scopeFilter;
this.checkResult = checkResult;
+ this.scopeCounter = scopeCounter;
}
- boolean matches(Filter<Symbol> scopeFilter, boolean checkResult) {
+ boolean matches(Filter<Symbol> scopeFilter, boolean checkResult, Scope.ScopeCounter scopeCounter) {
return this.implFilter == scopeFilter &&
- this.checkResult == checkResult;
+ this.checkResult == checkResult &&
+ this.scopeCounter.val() >= scopeCounter.val();
}
}
- MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
+ MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter, Scope.ScopeCounter scopeCounter) {
SoftReference<Map<TypeSymbol, Entry>> ref_cache = _map.get(ms);
Map<TypeSymbol, Entry> cache = ref_cache != null ? ref_cache.get() : null;
if (cache == null) {
@@ -2008,9 +2014,9 @@
}
Entry e = cache.get(origin);
if (e == null ||
- !e.matches(implFilter, checkResult)) {
+ !e.matches(implFilter, checkResult, scopeCounter)) {
MethodSymbol impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter);
- cache.put(origin, new Entry(impl, implFilter, checkResult));
+ cache.put(origin, new Entry(impl, implFilter, checkResult, scopeCounter));
return impl;
}
else {
@@ -2038,7 +2044,7 @@
private ImplementationCache implCache = new ImplementationCache();
public MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
- return implCache.get(ms, origin, checkResult, implFilter);
+ return implCache.get(ms, origin, checkResult, implFilter, scopeCounter);
}
// </editor-fold>
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Oct 04 14:40:38 2010 -0700
@@ -119,10 +119,10 @@
allowAnonOuterThis = source.allowAnonOuterThis();
allowStringsInSwitch = source.allowStringsInSwitch();
sourceName = source.name;
- relax = (options.get("-retrofit") != null ||
- options.get("-relax") != null);
- useBeforeDeclarationWarning = options.get("useBeforeDeclarationWarning") != null;
- enableSunApiLintControl = options.get("enableSunApiLintControl") != null;
+ relax = (options.isSet("-retrofit") ||
+ options.isSet("-relax"));
+ useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
+ enableSunApiLintControl = options.isSet("enableSunApiLintControl");
}
/** Switch: relax some constraints for retrofit mode.
@@ -1422,7 +1422,8 @@
// Compute the result type.
Type restype = mtype.getReturnType();
- assert restype.tag != WILDCARD : mtype;
+ if (restype.tag == WILDCARD)
+ throw new AssertionError(mtype);
// as a special case, array.clone() has a result that is
// the same as static type of the array being cloned
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Oct 04 14:40:38 2010 -0700
@@ -25,7 +25,6 @@
package com.sun.tools.javac.comp;
-import com.sun.source.tree.AssignmentTree;
import java.util.*;
import java.util.Set;
@@ -46,6 +45,8 @@
import static com.sun.tools.javac.code.Kinds.*;
import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.main.OptionName.*;
+
/** Type checking helper class for the attribution phase.
*
* <p><b>This is NOT part of any supported API.
@@ -60,6 +61,7 @@
private final Names names;
private final Log log;
private final Symtab syms;
+ private final Enter enter;
private final Infer infer;
private final Types types;
private final JCDiagnostic.Factory diags;
@@ -86,6 +88,7 @@
names = Names.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
+ enter = Enter.instance(context);
infer = Infer.instance(context);
this.types = Types.instance(context);
diags = JCDiagnostic.Factory.instance(context);
@@ -97,10 +100,10 @@
allowGenerics = source.allowGenerics();
allowAnnotations = source.allowAnnotations();
allowCovariantReturns = source.allowCovariantReturns();
- complexInference = options.get("-complexinference") != null;
- skipAnnotations = options.get("skipAnnotations") != null;
- warnOnSyntheticConflicts = options.get("warnOnSyntheticConflicts") != null;
- suppressAbortOnBadClassFile = options.get("suppressAbortOnBadClassFile") != null;
+ complexInference = options.isSet(COMPLEXINFERENCE);
+ skipAnnotations = options.isSet("skipAnnotations");
+ warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
+ suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
Target target = Target.instance(context);
syntheticNameChar = target.syntheticNameChar();
@@ -1727,6 +1730,113 @@
return undef;
}
+ void checkNonCyclicDecl(JCClassDecl tree) {
+ CycleChecker cc = new CycleChecker();
+ cc.scan(tree);
+ if (!cc.errorFound && !cc.partialCheck) {
+ tree.sym.flags_field |= ACYCLIC;
+ }
+ }
+
+ class CycleChecker extends TreeScanner {
+
+ List<Symbol> seenClasses = List.nil();
+ boolean errorFound = false;
+ boolean partialCheck = false;
+
+ private void checkSymbol(DiagnosticPosition pos, Symbol sym) {
+ if (sym != null && sym.kind == TYP) {
+ Env<AttrContext> classEnv = enter.getEnv((TypeSymbol)sym);
+ if (classEnv != null) {
+ DiagnosticSource prevSource = log.currentSource();
+ try {
+ log.useSource(classEnv.toplevel.sourcefile);
+ scan(classEnv.tree);
+ }
+ finally {
+ log.useSource(prevSource.getFile());
+ }
+ } else if (sym.kind == TYP) {
+ checkClass(pos, sym, List.<JCTree>nil());
+ }
+ } else {
+ //not completed yet
+ partialCheck = true;
+ }
+ }
+
+ @Override
+ public void visitSelect(JCFieldAccess tree) {
+ super.visitSelect(tree);
+ checkSymbol(tree.pos(), tree.sym);
+ }
+
+ @Override
+ public void visitIdent(JCIdent tree) {
+ checkSymbol(tree.pos(), tree.sym);
+ }
+
+ @Override
+ public void visitTypeApply(JCTypeApply tree) {
+ scan(tree.clazz);
+ }
+
+ @Override
+ public void visitTypeArray(JCArrayTypeTree tree) {
+ scan(tree.elemtype);
+ }
+
+ @Override
+ public void visitClassDef(JCClassDecl tree) {
+ List<JCTree> supertypes = List.nil();
+ if (tree.getExtendsClause() != null) {
+ supertypes = supertypes.prepend(tree.getExtendsClause());
+ }
+ if (tree.getImplementsClause() != null) {
+ for (JCTree intf : tree.getImplementsClause()) {
+ supertypes = supertypes.prepend(intf);
+ }
+ }
+ checkClass(tree.pos(), tree.sym, supertypes);
+ }
+
+ void checkClass(DiagnosticPosition pos, Symbol c, List<JCTree> supertypes) {
+ if ((c.flags_field & ACYCLIC) != 0)
+ return;
+ if (seenClasses.contains(c)) {
+ errorFound = true;
+ noteCyclic(pos, (ClassSymbol)c);
+ } else if (!c.type.isErroneous()) {
+ try {
+ seenClasses = seenClasses.prepend(c);
+ if (c.type.tag == CLASS) {
+ if (supertypes.nonEmpty()) {
+ scan(supertypes);
+ }
+ else {
+ ClassType ct = (ClassType)c.type;
+ if (ct.supertype_field == null ||
+ ct.interfaces_field == null) {
+ //not completed yet
+ partialCheck = true;
+ return;
+ }
+ checkSymbol(pos, ct.supertype_field.tsym);
+ for (Type intf : ct.interfaces_field) {
+ checkSymbol(pos, intf.tsym);
+ }
+ }
+ if (c.owner.kind == TYP) {
+ checkSymbol(pos, c.owner);
+ }
+ }
+ } finally {
+ seenClasses = seenClasses.tail;
+ }
+ }
+ }
+ }
+
/** Check for cyclic references. Issue an error if the
* symbol of the type referred to has a LOCKED flag set.
*
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Mon Oct 04 14:40:38 2010 -0700
@@ -94,6 +94,7 @@
Log log;
Symtab syms;
+ Scope.ScopeCounter scopeCounter;
Check chk;
TreeMaker make;
ClassReader reader;
@@ -121,6 +122,7 @@
reader = ClassReader.instance(context);
make = TreeMaker.instance(context);
syms = Symtab.instance(context);
+ scopeCounter = Scope.ScopeCounter.instance(context);
chk = Check.instance(context);
memberEnter = MemberEnter.instance(context);
types = Types.instance(context);
@@ -189,7 +191,7 @@
*/
public Env<AttrContext> classEnv(JCClassDecl tree, Env<AttrContext> env) {
Env<AttrContext> localEnv =
- env.dup(tree, env.info.dup(new Scope(tree.sym)));
+ env.dup(tree, env.info.dup(new Scope.ClassScope(tree.sym, scopeCounter)));
localEnv.enclClass = tree;
localEnv.outer = env;
localEnv.info.isSelfCall = false;
@@ -325,7 +327,7 @@
c.flatname = names.fromString(tree.packge + "." + name);
c.sourcefile = tree.sourcefile;
c.completer = null;
- c.members_field = new Scope(c);
+ c.members_field = new Scope.ClassScope(c, scopeCounter);
tree.packge.package_info = c;
}
classEnter(tree.defs, topEnv);
@@ -393,7 +395,7 @@
c.completer = memberEnter;
c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree);
c.sourcefile = env.toplevel.sourcefile;
- c.members_field = new Scope(c);
+ c.members_field = new Scope.ClassScope(c, scopeCounter);
ClassType ct = (ClassType)c.type;
if (owner.kind != PCK && (c.flags_field & STATIC) == 0) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Mon Oct 04 14:40:38 2010 -0700
@@ -80,25 +80,12 @@
}
- public static class InferenceException extends RuntimeException {
+ public static class InferenceException extends Resolve.InapplicableMethodException {
private static final long serialVersionUID = 0;
- JCDiagnostic diagnostic;
- JCDiagnostic.Factory diags;
-
InferenceException(JCDiagnostic.Factory diags) {
- this.diagnostic = null;
- this.diags = diags;
+ super(diags);
}
-
- InferenceException setMessage(String key, Object... args) {
- this.diagnostic = diags.fragment(key, args);
- return this;
- }
-
- public JCDiagnostic getDiagnostic() {
- return diagnostic;
- }
}
public static class NoInstanceException extends InferenceException {
@@ -320,7 +307,7 @@
Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
if (!types.isSubtype(qtype1, to)) {
throw unambiguousNoInstanceException
- .setMessage("no.conforming.instance.exists",
+ .setMessage("infer.no.conforming.instance.exists",
that.tvars, that.qtype, to);
}
for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail)
@@ -378,6 +365,11 @@
// instantiate all polymorphic argument types and
// set up lower bounds constraints for undetvars
Type varargsFormal = useVarargs ? formals.last() : null;
+ if (varargsFormal == null &&
+ actuals.size() != formals.size()) {
+ throw unambiguousNoInstanceException
+ .setMessage("infer.arg.length.mismatch");
+ }
while (actuals.nonEmpty() && formals.head != varargsFormal) {
Type formal = formals.head;
Type actual = actuals.head.baseType();
@@ -390,19 +382,16 @@
: types.isSubtypeUnchecked(actual, undetFormal, warn);
if (!works) {
throw unambiguousNoInstanceException
- .setMessage("no.conforming.assignment.exists",
+ .setMessage("infer.no.conforming.assignment.exists",
tvars, actualNoCapture, formal);
}
formals = formals.tail;
actuals = actuals.tail;
actualsNoCapture = actualsNoCapture.tail;
}
- if (formals.head != varargsFormal || // not enough args
- !useVarargs && actuals.nonEmpty()) { // too many args
- // argument lists differ in length
- throw unambiguousNoInstanceException
- .setMessage("arg.length.mismatch");
- }
+
+ if (formals.head != varargsFormal) // not enough args
+ throw unambiguousNoInstanceException.setMessage("infer.arg.length.mismatch");
// for varargs arguments as well
if (useVarargs) {
@@ -416,7 +405,7 @@
boolean works = types.isConvertible(actual, elemUndet, warn);
if (!works) {
throw unambiguousNoInstanceException
- .setMessage("no.conforming.assignment.exists",
+ .setMessage("infer.no.conforming.assignment.exists",
tvars, actualNoCapture, elemType);
}
actuals = actuals.tail;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon Oct 04 14:40:38 2010 -0700
@@ -68,6 +68,7 @@
private Names names;
private Log log;
private Symtab syms;
+ private Scope.ScopeCounter scopeCounter;
private Resolve rs;
private Check chk;
private Attr attr;
@@ -90,6 +91,7 @@
names = Names.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
+ scopeCounter = Scope.ScopeCounter.instance(context);
rs = Resolve.instance(context);
chk = Check.instance(context);
attr = Attr.instance(context);
@@ -107,7 +109,7 @@
types = Types.instance(context);
Options options = Options.instance(context);
- debugLower = options.get("debuglower") != null;
+ debugLower = options.isSet("debuglower");
pkginfoOpt = PkgInfo.get(options);
}
@@ -569,7 +571,7 @@
c.flatname = chk.localClassName(c);
c.sourcefile = owner.sourcefile;
c.completer = null;
- c.members_field = new Scope(c);
+ c.members_field = new Scope.ClassScope(c, scopeCounter);
c.flags_field = flags;
ClassType ctype = (ClassType) c.type;
ctype.supertype_field = syms.objectType;
@@ -2677,7 +2679,8 @@
}
//where
private JCTree convert(JCTree tree, Type pt) {
- if (tree.type == pt) return tree;
+ if (tree.type == pt || tree.type.tag == TypeTags.BOT)
+ return tree;
JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree);
result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt)
: pt;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Mon Oct 04 14:40:38 2010 -0700
@@ -67,6 +67,7 @@
private final Check chk;
private final Attr attr;
private final Symtab syms;
+ private final Scope.ScopeCounter scopeCounter;
private final TreeMaker make;
private final ClassReader reader;
private final Todo todo;
@@ -92,6 +93,7 @@
chk = Check.instance(context);
attr = Attr.instance(context);
syms = Symtab.instance(context);
+ scopeCounter = Scope.ScopeCounter.instance(context);
make = TreeMaker.instance(context);
reader = ClassReader.instance(context);
todo = Todo.instance(context);
@@ -100,7 +102,7 @@
diags = JCDiagnostic.Factory.instance(context);
target = Target.instance(context);
Options options = Options.instance(context);
- skipAnnotations = options.get("skipAnnotations") != null;
+ skipAnnotations = options.isSet("skipAnnotations");
}
/** A queue for classes whose members still need to be entered into the
@@ -925,7 +927,7 @@
tp.accept(new TypeAnnotate(baseEnv));
tree.accept(new TypeAnnotate(env));
- chk.checkNonCyclic(tree.pos(), c.type);
+ chk.checkNonCyclicDecl(tree);
attr.attribTypeVariables(tree.typarams, baseEnv);
@@ -1087,7 +1089,7 @@
private Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) {
- Scope baseScope = new Scope(tree.sym);
+ Scope baseScope = new Scope.ClassScope(tree.sym, scopeCounter);
//import already entered local classes into base scope
for (Scope.Entry e = env.outer.info.scope.elems ; e != null ; e = e.sibling) {
if (e.sym.isLocal()) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Oct 04 14:40:38 2010 -0700
@@ -110,15 +110,17 @@
boxingEnabled = source.allowBoxing();
varargsEnabled = source.allowVarargs();
Options options = Options.instance(context);
- debugResolve = options.get("debugresolve") != null;
- allowTransitionalJSR292 = options.get("allowTransitionalJSR292") != null;
+ debugResolve = options.isSet("debugresolve");
+ allowTransitionalJSR292 = options.isSet("allowTransitionalJSR292");
Target target = Target.instance(context);
allowMethodHandles = allowTransitionalJSR292 ||
target.hasMethodHandles();
allowInvokeDynamic = (allowTransitionalJSR292 ||
target.hasInvokedynamic()) &&
- options.get("invokedynamic") != null;
+ options.isSet("invokedynamic");
polymorphicSignatureScope = new Scope(syms.noSymbol);
+
+ inapplicableMethodException = new InapplicableMethodException(diags);
}
/** error symbols, which are returned when resolution fails
@@ -318,7 +320,8 @@
throws Infer.InferenceException {
boolean polymorphicSignature = (m.isPolymorphicSignatureGeneric() && allowMethodHandles) ||
isTransitionalDynamicCallSite(site, m);
- if (useVarargs && (m.flags() & VARARGS) == 0) return null;
+ if (useVarargs && (m.flags() & VARARGS) == 0)
+ throw inapplicableMethodException.setMessage(null);
Type mt = types.memberType(site, m);
// tvars is the list of formal type variables for which type arguments
@@ -334,7 +337,7 @@
} else if (mt.tag == FORALL && typeargtypes.nonEmpty()) {
ForAll pmt = (ForAll) mt;
if (typeargtypes.length() != pmt.tvars.length())
- return null;
+ throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
// Check type arguments are within bounds
List<Type> formals = pmt.tvars;
List<Type> actuals = typeargtypes;
@@ -343,7 +346,7 @@
pmt.tvars, typeargtypes);
for (; bounds.nonEmpty(); bounds = bounds.tail)
if (!types.isSubtypeUnchecked(actuals.head, bounds.head, warn))
- return null;
+ throw inapplicableMethodException.setMessage("explicit.param.do.not.conform.to.bounds",actuals.head, bounds);
formals = formals.tail;
actuals = actuals.tail;
}
@@ -375,11 +378,10 @@
allowBoxing,
useVarargs,
warn);
- return
- argumentsAcceptable(argtypes, mt.getParameterTypes(),
- allowBoxing, useVarargs, warn)
- ? mt
- : null;
+
+ checkRawArgumentsAcceptable(argtypes, mt.getParameterTypes(),
+ allowBoxing, useVarargs, warn);
+ return mt;
}
boolean isTransitionalDynamicCallSite(Type site, Symbol sym) {
@@ -403,7 +405,7 @@
try {
return rawInstantiate(env, site, m, argtypes, typeargtypes,
allowBoxing, useVarargs, warn);
- } catch (Infer.InferenceException ex) {
+ } catch (InapplicableMethodException ex) {
return null;
}
}
@@ -415,26 +417,76 @@
boolean allowBoxing,
boolean useVarargs,
Warner warn) {
+ try {
+ checkRawArgumentsAcceptable(argtypes, formals, allowBoxing, useVarargs, warn);
+ return true;
+ } catch (InapplicableMethodException ex) {
+ return false;
+ }
+ }
+ void checkRawArgumentsAcceptable(List<Type> argtypes,
+ List<Type> formals,
+ boolean allowBoxing,
+ boolean useVarargs,
+ Warner warn) {
Type varargsFormal = useVarargs ? formals.last() : null;
+ if (varargsFormal == null &&
+ argtypes.size() != formals.size()) {
+ throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
+ }
+
while (argtypes.nonEmpty() && formals.head != varargsFormal) {
boolean works = allowBoxing
? types.isConvertible(argtypes.head, formals.head, warn)
: types.isSubtypeUnchecked(argtypes.head, formals.head, warn);
- if (!works) return false;
+ if (!works)
+ throw inapplicableMethodException.setMessage("no.conforming.assignment.exists",
+ argtypes.head,
+ formals.head);
argtypes = argtypes.tail;
formals = formals.tail;
}
- if (formals.head != varargsFormal) return false; // not enough args
- if (!useVarargs)
- return argtypes.isEmpty();
- Type elt = types.elemtype(varargsFormal);
- while (argtypes.nonEmpty()) {
- if (!types.isConvertible(argtypes.head, elt, warn))
- return false;
- argtypes = argtypes.tail;
+
+ if (formals.head != varargsFormal)
+ throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
+
+ if (useVarargs) {
+ Type elt = types.elemtype(varargsFormal);
+ while (argtypes.nonEmpty()) {
+ if (!types.isConvertible(argtypes.head, elt, warn))
+ throw inapplicableMethodException.setMessage("varargs.argument.mismatch",
+ argtypes.head,
+ elt);
+ argtypes = argtypes.tail;
+ }
}
- return true;
+ return;
}
+ // where
+ public static class InapplicableMethodException extends RuntimeException {
+ private static final long serialVersionUID = 0;
+
+ JCDiagnostic diagnostic;
+ JCDiagnostic.Factory diags;
+
+ InapplicableMethodException(JCDiagnostic.Factory diags) {
+ this.diagnostic = null;
+ this.diags = diags;
+ }
+ InapplicableMethodException setMessage(String key) {
+ this.diagnostic = key != null ? diags.fragment(key) : null;
+ return this;
+ }
+ InapplicableMethodException setMessage(String key, Object... args) {
+ this.diagnostic = key != null ? diags.fragment(key, args) : null;
+ return this;
+ }
+
+ public JCDiagnostic getDiagnostic() {
+ return diagnostic;
+ }
+ }
+ private final InapplicableMethodException inapplicableMethodException;
/* ***************************************************************************
* Symbol lookup
@@ -595,6 +647,7 @@
* @param allowBoxing Allow boxing conversions of arguments.
* @param useVarargs Box trailing arguments into an array for varargs.
*/
+ @SuppressWarnings("fallthrough")
Symbol selectBest(Env<AttrContext> env,
Type site,
List<Type> argtypes,
@@ -608,21 +661,16 @@
if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar;
assert sym.kind < AMBIGUOUS;
try {
- if (rawInstantiate(env, site, sym, argtypes, typeargtypes,
- allowBoxing, useVarargs, Warner.noWarnings) == null) {
- // inapplicable
- switch (bestSoFar.kind) {
- case ABSENT_MTH: return wrongMethod.setWrongSym(sym);
- case WRONG_MTH: return wrongMethods;
- default: return bestSoFar;
- }
- }
- } catch (Infer.InferenceException ex) {
+ rawInstantiate(env, site, sym, argtypes, typeargtypes,
+ allowBoxing, useVarargs, Warner.noWarnings);
+ } catch (InapplicableMethodException ex) {
switch (bestSoFar.kind) {
case ABSENT_MTH:
return wrongMethod.setWrongSym(sym, ex.getDiagnostic());
case WRONG_MTH:
- return wrongMethods;
+ wrongMethods.addCandidate(currentStep, wrongMethod.sym, wrongMethod.explanation);
+ case WRONG_MTHS:
+ return wrongMethods.addCandidate(currentStep, sym, ex.getDiagnostic());
default:
return bestSoFar;
}
@@ -631,7 +679,7 @@
return (bestSoFar.kind == ABSENT_MTH)
? new AccessError(env, site, sym)
: bestSoFar;
- }
+ }
return (bestSoFar.kind > AMBIGUOUS)
? sym
: mostSpecific(sym, bestSoFar, env, site,
@@ -1253,11 +1301,12 @@
Name name,
List<Type> argtypes,
List<Type> typeargtypes) {
- Symbol sym = methodNotFound;
+ Symbol sym = startResolution();
List<MethodResolutionPhase> steps = methodResolutionSteps;
while (steps.nonEmpty() &&
steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
sym.kind >= ERRONEOUS) {
+ currentStep = steps.head;
sym = findFun(env, name, argtypes, typeargtypes,
steps.head.isBoxingRequired,
env.info.varArgs = steps.head.isVarargsRequired);
@@ -1274,6 +1323,12 @@
return sym;
}
+ private Symbol startResolution() {
+ wrongMethod.clear();
+ wrongMethods.clear();
+ return methodNotFound;
+ }
+
/** Resolve a qualified method identifier
* @param pos The position to use for error reporting.
* @param env The environment current at the method invocation.
@@ -1286,11 +1341,12 @@
Symbol resolveQualifiedMethod(DiagnosticPosition pos, Env<AttrContext> env,
Type site, Name name, List<Type> argtypes,
List<Type> typeargtypes) {
- Symbol sym = methodNotFound;
+ Symbol sym = startResolution();
List<MethodResolutionPhase> steps = methodResolutionSteps;
while (steps.nonEmpty() &&
steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
sym.kind >= ERRONEOUS) {
+ currentStep = steps.head;
sym = findMethod(env, site, name, argtypes, typeargtypes,
steps.head.isBoxingRequired(),
env.info.varArgs = steps.head.isVarargsRequired(), false);
@@ -1404,11 +1460,12 @@
Type site,
List<Type> argtypes,
List<Type> typeargtypes) {
- Symbol sym = methodNotFound;
+ Symbol sym = startResolution();
List<MethodResolutionPhase> steps = methodResolutionSteps;
while (steps.nonEmpty() &&
steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
sym.kind >= ERRONEOUS) {
+ currentStep = steps.head;
sym = resolveConstructor(pos, env, site, argtypes, typeargtypes,
steps.head.isBoxingRequired(),
env.info.varArgs = steps.head.isVarargsRequired());
@@ -1439,26 +1496,22 @@
Type site,
List<Type> argtypes,
List<Type> typeargtypes) {
- Symbol sym = methodNotFound;
- JCDiagnostic explanation = null;
+ Symbol sym = startResolution();
List<MethodResolutionPhase> steps = methodResolutionSteps;
while (steps.nonEmpty() &&
steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
sym.kind >= ERRONEOUS) {
+ currentStep = steps.head;
sym = resolveConstructor(pos, env, site, argtypes, typeargtypes,
steps.head.isBoxingRequired(),
env.info.varArgs = steps.head.isVarargsRequired());
methodResolutionCache.put(steps.head, sym);
- if (sym.kind == WRONG_MTH &&
- ((InapplicableSymbolError)sym).explanation != null) {
- //if the symbol is an inapplicable method symbol, then the
- //explanation contains the reason for which inference failed
- explanation = ((InapplicableSymbolError)sym).explanation;
- }
steps = steps.tail;
}
if (sym.kind >= AMBIGUOUS) {
- final JCDiagnostic details = explanation;
+ final JCDiagnostic details = sym.kind == WRONG_MTH ?
+ ((InapplicableSymbolError)sym).explanation :
+ null;
Symbol errSym = new ResolveError(WRONG_MTH, "diamond error") {
@Override
JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
@@ -1860,7 +1913,8 @@
*/
InapplicableSymbolError setWrongSym(Symbol sym, JCDiagnostic explanation) {
this.sym = sym;
- this.explanation = explanation;
+ if (this.sym == sym && explanation != null)
+ this.explanation = explanation; //update the details
return this;
}
@@ -1868,7 +1922,6 @@
*/
InapplicableSymbolError setWrongSym(Symbol sym) {
this.sym = sym;
- this.explanation = null;
return this;
}
@@ -1905,6 +1958,10 @@
}
}
+ void clear() {
+ explanation = null;
+ }
+
@Override
public Symbol access(Name name, TypeSymbol location) {
return types.createErrorType(name, location, syms.errSymbol.type).tsym;
@@ -1917,6 +1974,9 @@
* given an actual arguments/type argument list.
*/
class InapplicableSymbolsError extends ResolveError {
+
+ private List<Candidate> candidates = List.nil();
+
InapplicableSymbolsError(Symbol sym) {
super(WRONG_MTHS, "inapplicable symbols");
}
@@ -1928,8 +1988,85 @@
Name name,
List<Type> argtypes,
List<Type> typeargtypes) {
- return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos,
+ if (candidates.nonEmpty()) {
+ JCDiagnostic err = diags.create(dkind,
+ log.currentSource(),
+ pos,
+ "cant.apply.symbols",
+ name == names.init ? KindName.CONSTRUCTOR : absentKind(kind),
+ getName(),
+ argtypes);
+ return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(site));
+ } else {
+ return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos,
site, name, argtypes, typeargtypes);
+ }
+ }
+
+ //where
+ List<JCDiagnostic> candidateDetails(Type site) {
+ List<JCDiagnostic> details = List.nil();
+ for (Candidate c : candidates)
+ details = details.prepend(c.getDiagnostic(site));
+ return details.reverse();
+ }
+
+ Symbol addCandidate(MethodResolutionPhase currentStep, Symbol sym, JCDiagnostic details) {
+ Candidate c = new Candidate(currentStep, sym, details);
+ if (c.isValid() && !candidates.contains(c))
+ candidates = candidates.append(c);
+ return this;
+ }
+
+ void clear() {
+ candidates = List.nil();
+ }
+
+ private Name getName() {
+ Symbol sym = candidates.head.sym;
+ return sym.name == names.init ?
+ sym.owner.name :
+ sym.name;
+ }
+
+ private class Candidate {
+
+ final MethodResolutionPhase step;
+ final Symbol sym;
+ final JCDiagnostic details;
+
+ private Candidate(MethodResolutionPhase step, Symbol sym, JCDiagnostic details) {
+ this.step = step;
+ this.sym = sym;
+ this.details = details;
+ }
+
+ JCDiagnostic getDiagnostic(Type site) {
+ return diags.fragment("inapplicable.method",
+ Kinds.kindName(sym),
+ sym.location(site, types),
+ sym.asMemberOf(site, types),
+ details);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof Candidate) {
+ Symbol s1 = this.sym;
+ Symbol s2 = ((Candidate)o).sym;
+ if ((s1 != s2 &&
+ (s1.overrides(s2, s1.owner.type.tsym, types, false) ||
+ (s2.overrides(s1, s2.owner.type.tsym, types, false)))) ||
+ ((s1.isConstructor() || s2.isConstructor()) && s1.owner != s2.owner))
+ return true;
+ }
+ return false;
+ }
+
+ boolean isValid() {
+ return (((sym.flags() & VARARGS) != 0 && step == VARARITY) ||
+ (sym.flags() & VARARGS) == 0 && step == (boxingEnabled ? BOX : BASIC));
+ }
}
}
@@ -2093,6 +2230,8 @@
final List<MethodResolutionPhase> methodResolutionSteps = List.of(BASIC, BOX, VARARITY);
+ private MethodResolutionPhase currentStep = null;
+
private MethodResolutionPhase firstErroneousResolutionPhase() {
MethodResolutionPhase bestSoFar = BASIC;
Symbol sym = methodNotFound;
--- a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -150,8 +150,8 @@
useZipFileIndex = System.getProperty("useJavaUtilZip") == null;// TODO: options.get("useJavaUtilZip") == null;
- mmappedIO = options.get("mmappedIO") != null;
- ignoreSymbolFile = options.get("ignore.symbol.file") != null;
+ mmappedIO = options.isSet("mmappedIO");
+ ignoreSymbolFile = options.isSet("ignore.symbol.file");
}
public JavaFileObject getFileForInput(String name) {
@@ -435,7 +435,7 @@
zdir = new ZipFile(zipFileName);
}
else {
- usePreindexedCache = options.get("usezipindex") != null;
+ usePreindexedCache = options.isSet("usezipindex");
preindexCacheLocation = options.get("java.io.tmpdir");
String optCacheLoc = options.get("cachezipindexdir");
@@ -469,7 +469,7 @@
null,
usePreindexedCache,
preindexCacheLocation,
- options.get("writezipindexfiles") != null));
+ options.isSet("writezipindexfiles")));
}
}
else {
@@ -482,7 +482,7 @@
symbolFilePrefix,
usePreindexedCache,
preindexCacheLocation,
- options.get("writezipindexfiles") != null));
+ options.isSet("writezipindexfiles")));
}
}
} catch (FileNotFoundException ex) {
@@ -605,7 +605,7 @@
nullCheck(className);
nullCheck(kind);
if (!sourceOrClass.contains(kind))
- throw new IllegalArgumentException("Invalid kind " + kind);
+ throw new IllegalArgumentException("Invalid kind: " + kind);
return getFileForInput(location, RelativeFile.forClass(className, kind));
}
@@ -658,7 +658,7 @@
nullCheck(className);
nullCheck(kind);
if (!sourceOrClass.contains(kind))
- throw new IllegalArgumentException("Invalid kind " + kind);
+ throw new IllegalArgumentException("Invalid kind: " + kind);
return getFileForOutput(location, RelativeFile.forClass(className, kind), sibling);
}
@@ -672,7 +672,7 @@
// validatePackageName(packageName);
nullCheck(packageName);
if (!isRelativeUri(relativeName))
- throw new IllegalArgumentException("relativeName is invalid");
+ throw new IllegalArgumentException("Invalid relative name: " + relativeName);
RelativeFile name = packageName.length() == 0
? new RelativeFile(relativeName)
: new RelativeFile(RelativeDirectory.forPackage(packageName), relativeName);
@@ -806,6 +806,8 @@
String path = uri.normalize().getPath();
if (path.length() == 0 /* isEmpty() is mustang API */)
return false;
+ if (!path.equals(uri.getPath())) // implicitly checks for embedded . and ..
+ return false;
char first = path.charAt(0);
return first != '.' && first != '/';
}
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Oct 04 14:40:38 2010 -0700
@@ -56,6 +56,8 @@
import static com.sun.tools.javac.jvm.ClassFile.*;
import static com.sun.tools.javac.jvm.ClassFile.Version.*;
+import static com.sun.tools.javac.main.OptionName.*;
+
/** This class provides operations to read a classfile into an internal
* representation. The internal representation is anchored in a
* ClassSymbol which contains in its scope symbol representations
@@ -122,6 +124,9 @@
/** The symbol table. */
Symtab syms;
+ /** The scope counter */
+ Scope.ScopeCounter scopeCounter;
+
Types types;
/** The name table. */
@@ -244,6 +249,7 @@
names = Names.instance(context);
syms = Symtab.instance(context);
+ scopeCounter = Scope.ScopeCounter.instance(context);
types = Types.instance(context);
fileManager = context.get(JavaFileManager.class);
if (fileManager == null)
@@ -255,23 +261,23 @@
Options options = Options.instance(context);
annotate = Annotate.instance(context);
- verbose = options.get("-verbose") != null;
- checkClassFile = options.get("-checkclassfile") != null;
+ verbose = options.isSet(VERBOSE);
+ checkClassFile = options.isSet("-checkclassfile");
Source source = Source.instance(context);
allowGenerics = source.allowGenerics();
allowVarargs = source.allowVarargs();
allowAnnotations = source.allowAnnotations();
- saveParameterNames = options.get("save-parameter-names") != null;
- cacheCompletionFailure = options.get("dev") == null;
+ saveParameterNames = options.isSet("save-parameter-names");
+ cacheCompletionFailure = options.isUnset("dev");
preferSource = "source".equals(options.get("-Xprefer"));
completionFailureName =
- (options.get("failcomplete") != null)
+ options.isSet("failcomplete")
? names.fromString(options.get("failcomplete"))
: null;
typevars = new Scope(syms.noSymbol);
- debugJSR308 = options.get("TA:reader") != null;
+ debugJSR308 = options.isSet("TA:reader");
initAttributeReaders();
}
@@ -1984,7 +1990,7 @@
ClassType ct = (ClassType)c.type;
// allocate scope for members
- c.members_field = new Scope(c);
+ c.members_field = new Scope.ClassScope(c, scopeCounter);
// prepare type variable table
typevars = typevars.dup(currentOwner);
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Mon Oct 04 14:40:38 2010 -0700
@@ -45,8 +45,10 @@
import static com.sun.tools.javac.code.Kinds.*;
import static com.sun.tools.javac.code.TypeTags.*;
import static com.sun.tools.javac.jvm.UninitializedType.*;
+import static com.sun.tools.javac.main.OptionName.*;
import static javax.tools.StandardLocation.CLASS_OUTPUT;
+
/** This class provides operations to map an internal symbol table graph
* rooted in a ClassSymbol into a classfile.
*
@@ -178,15 +180,16 @@
types = Types.instance(context);
fileManager = context.get(JavaFileManager.class);
- debugJSR308 = options.get("TA:writer") != null;
- verbose = options.get("-verbose") != null;
- scramble = options.get("-scramble") != null;
- scrambleAll = options.get("-scrambleAll") != null;
- retrofit = options.get("-retrofit") != null;
- genCrt = options.get("-Xjcov") != null;
- debugstackmap = options.get("debugstackmap") != null;
+ debugJSR308 = options.isSet("TA:writer");
+ verbose = options.isSet(VERBOSE);
+ scramble = options.isSet("-scramble");
+ scrambleAll = options.isSet("-scrambleAll");
+ retrofit = options.isSet("-retrofit");
+ genCrt = options.isSet(XJCOV);
+ debugstackmap = options.isSet("debugstackmap");
- emitSourceFile = options.get("-g:")==null || options.get("-g:source")!=null;
+ emitSourceFile = options.isUnset(G_CUSTOM) ||
+ options.isSet(G_CUSTOM, "source");
String dumpModFlags = options.get("dumpmodifiers");
dumpClassModifiers =
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Mon Oct 04 14:40:38 2010 -0700
@@ -46,6 +46,7 @@
import static com.sun.tools.javac.code.TypeTags.*;
import static com.sun.tools.javac.jvm.ByteCodes.*;
import static com.sun.tools.javac.jvm.CRTFlags.*;
+import static com.sun.tools.javac.main.OptionName.*;
/** This pass maps flat Java (i.e. without inner classes) to bytecodes.
*
@@ -113,19 +114,19 @@
Options options = Options.instance(context);
lineDebugInfo =
- options.get("-g:") == null ||
- options.get("-g:lines") != null;
+ options.isUnset(G_CUSTOM) ||
+ options.isSet(G_CUSTOM, "lines");
varDebugInfo =
- options.get("-g:") == null
- ? options.get("-g") != null
- : options.get("-g:vars") != null;
- genCrt = options.get("-Xjcov") != null;
- debugCode = options.get("debugcode") != null;
- allowInvokedynamic = target.hasInvokedynamic() || options.get("invokedynamic") != null;
+ options.isUnset(G_CUSTOM)
+ ? options.isSet(G)
+ : options.isSet(G_CUSTOM, "vars");
+ genCrt = options.isSet(XJCOV);
+ debugCode = options.isSet("debugcode");
+ allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic");
generateIproxies =
target.requiresIproxy() ||
- options.get("miranda") != null;
+ options.isSet("miranda");
if (target.generateStackMapTable()) {
// ignore cldc because we cannot have both stackmap formats
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java Mon Oct 04 14:40:38 2010 -0700
@@ -31,6 +31,8 @@
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.util.*;
+import static com.sun.tools.javac.main.OptionName.*;
+
/** The classfile version target.
*
* <p><b>This is NOT part of any supported API.
@@ -73,7 +75,7 @@
Target instance = context.get(targetKey);
if (instance == null) {
Options options = Options.instance(context);
- String targetString = options.get("-target");
+ String targetString = options.get(TARGET);
if (targetString != null) instance = lookup(targetString);
if (instance == null) instance = DEFAULT;
context.put(targetKey, instance);
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,48 +26,44 @@
package com.sun.tools.javac.main;
import java.io.*;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.MissingResourceException;
+import java.util.Queue;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.annotation.processing.Processor;
+import javax.lang.model.SourceVersion;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.DiagnosticListener;
-import com.sun.tools.javac.file.JavacFileManager;
import com.sun.source.util.TaskEvent;
import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.tree.*;
+import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.parser.*;
import com.sun.tools.javac.comp.*;
import com.sun.tools.javac.jvm.*;
-
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.tree.JCTree.*;
-
import com.sun.tools.javac.processing.*;
-import javax.annotation.processing.Processor;
import static javax.tools.StandardLocation.CLASS_OUTPUT;
+import static com.sun.tools.javac.main.OptionName.*;
import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
import static com.sun.tools.javac.util.ListBuffer.lb;
-// TEMP, until we have a more efficient way to save doc comment info
-import com.sun.tools.javac.parser.DocCommentScanner;
-
-import java.util.HashMap;
-import java.util.Queue;
-import javax.lang.model.SourceVersion;
/** This class could be the main entry point for GJC when GJC is used as a
* component in a larger software system. It provides operations to
@@ -359,22 +355,22 @@
Options options = Options.instance(context);
- verbose = options.get("-verbose") != null;
- sourceOutput = options.get("-printsource") != null; // used to be -s
- stubOutput = options.get("-stubs") != null;
- relax = options.get("-relax") != null;
- printFlat = options.get("-printflat") != null;
- attrParseOnly = options.get("-attrparseonly") != null;
- encoding = options.get("-encoding");
- lineDebugInfo = options.get("-g:") == null ||
- options.get("-g:lines") != null;
- genEndPos = options.get("-Xjcov") != null ||
+ verbose = options.isSet(VERBOSE);
+ sourceOutput = options.isSet(PRINTSOURCE); // used to be -s
+ stubOutput = options.isSet("-stubs");
+ relax = options.isSet("-relax");
+ printFlat = options.isSet("-printflat");
+ attrParseOnly = options.isSet("-attrparseonly");
+ encoding = options.get(ENCODING);
+ lineDebugInfo = options.isUnset(G_CUSTOM) ||
+ options.isSet(G_CUSTOM, "lines");
+ genEndPos = options.isSet(XJCOV) ||
context.get(DiagnosticListener.class) != null;
- devVerbose = options.get("dev") != null;
- processPcks = options.get("process.packages") != null;
- werror = options.get("-Werror") != null;
+ devVerbose = options.isSet("dev");
+ processPcks = options.isSet("process.packages");
+ werror = options.isSet(WERROR);
- verboseCompilePolicy = options.get("verboseCompilePolicy") != null;
+ verboseCompilePolicy = options.isSet("verboseCompilePolicy");
if (attrParseOnly)
compilePolicy = CompilePolicy.ATTR_ONLY;
@@ -384,15 +380,15 @@
implicitSourcePolicy = ImplicitSourcePolicy.decode(options.get("-implicit"));
completionFailureName =
- (options.get("failcomplete") != null)
+ options.isSet("failcomplete")
? names.fromString(options.get("failcomplete"))
: null;
shouldStopPolicy =
- (options.get("shouldStopPolicy") != null)
+ options.isSet("shouldStopPolicy")
? CompileState.valueOf(options.get("shouldStopPolicy"))
: null;
- if (options.get("oldDiags") == null)
+ if (options.isUnset("oldDiags"))
log.setDiagnosticFormatter(RichDiagnosticFormatter.instance(context));
}
@@ -957,18 +953,17 @@
// Process annotations if processing is not disabled and there
// is at least one Processor available.
Options options = Options.instance(context);
- if (options.get("-proc:none") != null) {
+ if (options.isSet(PROC, "none")) {
processAnnotations = false;
} else if (procEnvImpl == null) {
procEnvImpl = new JavacProcessingEnvironment(context, processors);
processAnnotations = procEnvImpl.atLeastOneProcessor();
if (processAnnotations) {
- if (context.get(Scanner.Factory.scannerFactoryKey) == null)
- DocCommentScanner.Factory.preRegister(context);
options.put("save-parameter-names", "save-parameter-names");
reader.saveParameterNames = true;
keepComments = true;
+ genEndPos = true;
if (taskListener != null)
taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
log.deferDiagnostics = true;
@@ -1017,7 +1012,7 @@
// annotation processing is to occur with compilation,
// emit a warning.
Options options = Options.instance(context);
- if (options.get("-proc:only") != null) {
+ if (options.isSet(PROC, "only")) {
log.warning("proc.proc-only.requested.no.procs");
todo.clear();
}
@@ -1105,10 +1100,10 @@
Options options = Options.instance(context);
return
explicitAnnotationProcessingRequested ||
- options.get("-processor") != null ||
- options.get("-processorpath") != null ||
- options.get("-proc:only") != null ||
- options.get("-Xprint") != null;
+ options.isSet(PROCESSOR) ||
+ options.isSet(PROCESSORPATH) ||
+ options.isSet(PROC, "only") ||
+ options.isSet(XPRINT);
}
/**
@@ -1587,6 +1582,7 @@
}
public void initRound(JavaCompiler prev) {
+ genEndPos = prev.genEndPos;
keepComments = prev.keepComments;
start_msec = prev.start_msec;
hasBeenUsed = true;
--- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java Mon Oct 04 14:40:38 2010 -0700
@@ -32,6 +32,9 @@
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.util.MissingResourceException;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.annotation.processing.Processor;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.file.CacheFSInfo;
@@ -41,9 +44,8 @@
import com.sun.tools.javac.main.RecognizedOptions.OptionHelper;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.processing.AnnotationProcessingError;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.annotation.processing.Processor;
+
+import static com.sun.tools.javac.main.OptionName.*;
/** This class provides a commandline interface to the GJC compiler.
*
@@ -239,16 +241,16 @@
}
}
- if (!checkDirectory("-d"))
+ if (!checkDirectory(D))
return null;
- if (!checkDirectory("-s"))
+ if (!checkDirectory(S))
return null;
- String sourceString = options.get("-source");
+ String sourceString = options.get(SOURCE);
Source source = (sourceString != null)
? Source.lookup(sourceString)
: Source.DEFAULT;
- String targetString = options.get("-target");
+ String targetString = options.get(TARGET);
Target target = (targetString != null)
? Target.lookup(targetString)
: Target.DEFAULT;
@@ -285,7 +287,7 @@
// phase this out with JSR 292 PFD
if ("no".equals(options.get("allowTransitionalJSR292"))) {
options.put("allowTransitionalJSR292", null);
- } else if (target.hasInvokedynamic() && options.get("allowTransitionalJSR292") == null) {
+ } else if (target.hasInvokedynamic() && options.isUnset("allowTransitionalJSR292")) {
options.put("allowTransitionalJSR292", "allowTransitionalJSR292");
}
@@ -300,7 +302,7 @@
return filenames.toList();
}
// where
- private boolean checkDirectory(String optName) {
+ private boolean checkDirectory(OptionName optName) {
String value = options.get(optName);
if (value == null)
return true;
@@ -367,10 +369,10 @@
return EXIT_CMDERR;
} else if (files.isEmpty() && fileObjects.isEmpty() && classnames.isEmpty()) {
// it is allowed to compile nothing if just asking for help or version info
- if (options.get("-help") != null
- || options.get("-X") != null
- || options.get("-version") != null
- || options.get("-fullversion") != null)
+ if (options.isSet(HELP)
+ || options.isSet(X)
+ || options.isSet(VERSION)
+ || options.isSet(FULLVERSION))
return EXIT_OK;
error("err.no.source.files");
return EXIT_CMDERR;
@@ -382,7 +384,7 @@
return EXIT_SYSERR;
}
- boolean forceStdOut = options.get("stdout") != null;
+ boolean forceStdOut = options.isSet("stdout");
if (forceStdOut) {
out.flush();
out = new PrintWriter(System.out, true);
@@ -391,7 +393,7 @@
context.put(Log.outKey, out);
// allow System property in following line as a Mustang legacy
- boolean batchMode = (options.get("nonBatchMode") == null
+ boolean batchMode = (options.isUnset("nonBatchMode")
&& System.getProperty("nonBatchMode") == null);
if (batchMode)
CacheFSInfo.preRegister(context);
@@ -455,7 +457,7 @@
// for buggy compiler error recovery by swallowing thrown
// exceptions.
if (comp == null || comp.errorCount() == 0 ||
- options == null || options.get("dev") != null)
+ options == null || options.isSet("dev"))
bugMessage(ex);
return EXIT_ABNORMAL;
} finally {
@@ -478,7 +480,7 @@
*/
void feMessage(Throwable ex) {
Log.printLines(out, ex.getMessage());
- if (ex.getCause() != null && options.get("dev") != null) {
+ if (ex.getCause() != null && options.isSet("dev")) {
ex.getCause().printStackTrace(out);
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Mon Oct 04 14:40:38 2010 -0700
@@ -366,11 +366,11 @@
// }
// }
int maxDepth = (recurse ? Integer.MAX_VALUE : 1);
- Set<FileVisitOption> opts = EnumSet.of(DETECT_CYCLES, FOLLOW_LINKS);
+ Set<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS);
Files.walkFileTree(packageDir, opts, maxDepth,
new SimpleFileVisitor<Path>() {
@Override
- public FileVisitResult preVisitDirectory(Path dir) {
+ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
if (SourceVersion.isIdentifier(dir.getName().toString())) // JSR 292?
return FileVisitResult.CONTINUE;
else
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,50 +42,17 @@
*/
public class DocCommentScanner extends Scanner {
- /** A factory for creating scanners. */
- public static class Factory extends Scanner.Factory {
-
- public static void preRegister(final Context context) {
- context.put(scannerFactoryKey, new Context.Factory<Scanner.Factory>() {
- public Factory make() {
- return new Factory(context);
- }
- });
- }
-
- /** Create a new scanner factory. */
- protected Factory(Context context) {
- super(context);
- }
-
- @Override
- public Scanner newScanner(CharSequence input) {
- if (input instanceof CharBuffer) {
- return new DocCommentScanner(this, (CharBuffer)input);
- } else {
- char[] array = input.toString().toCharArray();
- return newScanner(array, array.length);
- }
- }
-
- @Override
- public Scanner newScanner(char[] input, int inputLength) {
- return new DocCommentScanner(this, input, inputLength);
- }
- }
-
-
/** Create a scanner from the input buffer. buffer must implement
* array() and compact(), and remaining() must be less than limit().
*/
- protected DocCommentScanner(Factory fac, CharBuffer buffer) {
+ protected DocCommentScanner(ScannerFactory fac, CharBuffer buffer) {
super(fac, buffer);
}
/** Create a scanner from the input array. The array must have at
* least a single character of extra space.
*/
- protected DocCommentScanner(Factory fac, char[] input, int inputLength) {
+ protected DocCommentScanner(ScannerFactory fac, char[] input, int inputLength) {
super(fac, input, inputLength);
}
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -2473,6 +2473,11 @@
defs.append(importDeclaration());
} else {
JCTree def = typeDeclaration(mods);
+ if (keepDocComments && dc != null && docComments.get(def) == dc) {
+ // If the first type declaration has consumed the first doc
+ // comment, then don't use it for the top level comment as well.
+ dc = null;
+ }
if (def instanceof JCExpressionStatement)
def = ((JCExpressionStatement)def).expr;
defs.append(def);
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,7 @@
final Source source;
final Names names;
final Options options;
- final Scanner.Factory scannerFactory;
+ final ScannerFactory scannerFactory;
protected ParserFactory(Context context) {
super();
@@ -70,11 +70,11 @@
this.keywords = Keywords.instance(context);
this.source = Source.instance(context);
this.options = Options.instance(context);
- this.scannerFactory = Scanner.Factory.instance(context);
+ this.scannerFactory = ScannerFactory.instance(context);
}
public Parser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) {
- Lexer lexer = scannerFactory.newScanner(input);
+ Lexer lexer = scannerFactory.newScanner(input, keepDocComments);
if (keepEndPos) {
return new EndPosParser(this, lexer, keepDocComments, keepLineMap);
} else {
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,48 +47,6 @@
private static boolean scannerDebug = false;
- /** A factory for creating scanners. */
- public static class Factory {
- /** The context key for the scanner factory. */
- public static final Context.Key<Scanner.Factory> scannerFactoryKey =
- new Context.Key<Scanner.Factory>();
-
- /** Get the Factory instance for this context. */
- public static Factory instance(Context context) {
- Factory instance = context.get(scannerFactoryKey);
- if (instance == null)
- instance = new Factory(context);
- return instance;
- }
-
- final Log log;
- final Names names;
- final Source source;
- final Keywords keywords;
-
- /** Create a new scanner factory. */
- protected Factory(Context context) {
- context.put(scannerFactoryKey, this);
- this.log = Log.instance(context);
- this.names = Names.instance(context);
- this.source = Source.instance(context);
- this.keywords = Keywords.instance(context);
- }
-
- public Scanner newScanner(CharSequence input) {
- if (input instanceof CharBuffer) {
- return new Scanner(this, (CharBuffer)input);
- } else {
- char[] array = input.toString().toCharArray();
- return newScanner(array, array.length);
- }
- }
-
- public Scanner newScanner(char[] input, int inputLength) {
- return new Scanner(this, input, inputLength);
- }
- }
-
/* Output variables; set by nextToken():
*/
@@ -177,7 +135,7 @@
private final Keywords keywords;
/** Common code for constructors. */
- private Scanner(Factory fac) {
+ private Scanner(ScannerFactory fac) {
log = fac.log;
names = fac.names;
keywords = fac.keywords;
@@ -201,7 +159,7 @@
/** Create a scanner from the input buffer. buffer must implement
* array() and compact(), and remaining() must be less than limit().
*/
- protected Scanner(Factory fac, CharBuffer buffer) {
+ protected Scanner(ScannerFactory fac, CharBuffer buffer) {
this(fac, JavacFileManager.toArray(buffer), buffer.limit());
}
@@ -216,7 +174,7 @@
* @param inputLength the size of the input.
* Must be positive and less than or equal to input.length.
*/
- protected Scanner(Factory fac, char[] input, int inputLength) {
+ protected Scanner(ScannerFactory fac, char[] input, int inputLength) {
this(fac);
eofPos = inputLength;
if (inputLength == input.length) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/ScannerFactory.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.parser;
+
+import java.nio.CharBuffer;
+
+import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Names;
+
+
+/**
+ * A factory for creating scanners.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own
+ * risk. This code and its internal interfaces are subject to change
+ * or deletion without notice.</b>
+ */
+public class ScannerFactory {
+ /** The context key for the scanner factory. */
+ public static final Context.Key<ScannerFactory> scannerFactoryKey =
+ new Context.Key<ScannerFactory>();
+
+ /** Get the Factory instance for this context. */
+ public static ScannerFactory instance(Context context) {
+ ScannerFactory instance = context.get(scannerFactoryKey);
+ if (instance == null)
+ instance = new ScannerFactory(context);
+ return instance;
+ }
+
+ final Log log;
+ final Names names;
+ final Source source;
+ final Keywords keywords;
+
+ /** Create a new scanner factory. */
+ protected ScannerFactory(Context context) {
+ context.put(scannerFactoryKey, this);
+ this.log = Log.instance(context);
+ this.names = Names.instance(context);
+ this.source = Source.instance(context);
+ this.keywords = Keywords.instance(context);
+ }
+
+ public Scanner newScanner(CharSequence input, boolean keepDocComments) {
+ if (input instanceof CharBuffer) {
+ CharBuffer buf = (CharBuffer) input;
+ if (keepDocComments)
+ return new DocCommentScanner(this, buf);
+ else
+ return new Scanner(this, buf);
+ } else {
+ char[] array = input.toString().toCharArray();
+ return newScanner(array, array.length, keepDocComments);
+ }
+ }
+
+ public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) {
+ if (keepDocComments)
+ return new DocCommentScanner(this, input, inputLength);
+ else
+ return new Scanner(this, input, inputLength);
+ }
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java Mon Oct 04 14:40:38 2010 -0700
@@ -25,14 +25,6 @@
package com.sun.tools.javac.processing;
-import com.sun.tools.javac.util.*;
-import javax.annotation.processing.*;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.NestingKind;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Element;
-import java.util.*;
-
import java.io.Closeable;
import java.io.FileNotFoundException;
import java.io.InputStream;
@@ -43,14 +35,26 @@
import java.io.FilterWriter;
import java.io.PrintWriter;
import java.io.IOException;
+import java.util.*;
-import javax.tools.*;
import static java.util.Collections.*;
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.NestingKind;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.Element;
+import javax.tools.*;
import javax.tools.JavaFileManager.Location;
+
import static javax.tools.StandardLocation.SOURCE_OUTPUT;
import static javax.tools.StandardLocation.CLASS_OUTPUT;
+import com.sun.tools.javac.code.Lint;
+import com.sun.tools.javac.util.*;
+
+import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING;
+
/**
* The FilerImplementation class must maintain a number of
* constraints. First, multiple attempts to open the same path within
@@ -366,7 +370,7 @@
aggregateGeneratedSourceNames = new LinkedHashSet<String>();
aggregateGeneratedClassNames = new LinkedHashSet<String>();
- lint = (Options.instance(context)).lint("processing");
+ lint = (Lint.instance(context)).isEnabled(PROCESSING);
}
public JavaFileObject createSourceFile(CharSequence name,
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -49,6 +49,7 @@
import javax.tools.JavaFileObject;
import javax.tools.DiagnosticListener;
+import com.sun.tools.javac.api.JavacTrees;
import com.sun.source.util.AbstractTypeProcessor;
import com.sun.source.util.TaskEvent;
import com.sun.source.util.TaskListener;
@@ -78,6 +79,8 @@
import static javax.tools.StandardLocation.*;
import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
+import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING;
/**
* Objects of this class hold and manage the state needed to support
@@ -159,15 +162,14 @@
source = Source.instance(context);
diags = JCDiagnostic.Factory.instance(context);
options = Options.instance(context);
- printProcessorInfo = options.get("-XprintProcessorInfo") != null;
- printRounds = options.get("-XprintRounds") != null;
- verbose = options.get("-verbose") != null;
- lint = options.lint("processing");
- procOnly = options.get("-proc:only") != null ||
- options.get("-Xprint") != null;
- fatalErrors = options.get("fatalEnterError") != null;
- showResolveErrors = options.get("showResolveErrors") != null;
- werror = options.get("-Werror") != null;
+ printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
+ printRounds = options.isSet(XPRINTROUNDS);
+ verbose = options.isSet(VERBOSE);
+ lint = Lint.instance(context).isEnabled(PROCESSING);
+ procOnly = options.isSet(PROC, "only") || options.isSet(XPRINT);
+ fatalErrors = options.isSet("fatalEnterError");
+ showResolveErrors = options.isSet("showResolveErrors");
+ werror = options.isSet(WERROR);
platformAnnotations = initPlatformAnnotations();
foundTypeProcessors = false;
@@ -199,7 +201,7 @@
Log log = Log.instance(context);
Iterator<? extends Processor> processorIterator;
- if (options.get("-Xprint") != null) {
+ if (options.isSet(XPRINT)) {
try {
Processor processor = PrintingProcessor.class.newInstance();
processorIterator = List.of(processor).iterator();
@@ -212,7 +214,7 @@
} else if (processors != null) {
processorIterator = processors.iterator();
} else {
- String processorNames = options.get("-processor");
+ String processorNames = options.get(PROCESSOR);
JavaFileManager fileManager = context.get(JavaFileManager.class);
try {
// If processorpath is not explicitly set, use the classpath.
@@ -263,7 +265,7 @@
? standardFileManager.getLocation(ANNOTATION_PROCESSOR_PATH)
: standardFileManager.getLocation(CLASS_PATH);
- if (needClassLoader(options.get("-processor"), workingPath) )
+ if (needClassLoader(options.get(PROCESSOR), workingPath) )
handleException(key, e);
} else {
@@ -744,7 +746,7 @@
psi.runContributingProcs(renv);
// Debugging
- if (options.get("displayFilerState") != null)
+ if (options.isSet("displayFilerState"))
filer.displayState();
}
@@ -1104,6 +1106,12 @@
task.updateContext(next);
}
+ JavacTrees trees = context.get(JavacTrees.class);
+ if (trees != null) {
+ next.put(JavacTrees.class, trees);
+ trees.updateContext(next);
+ }
+
context.clear();
return next;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Oct 04 14:40:38 2010 -0700
@@ -93,6 +93,8 @@
required: {2}\n\
found: {3}\n\
reason: {6}
+compiler.err.cant.apply.symbols=\
+ no suitable {0} found for {1}({2})
compiler.err.cant.assign.val.to.final.var=\
cannot assign a value to final variable {0}
compiler.err.cant.deref=\
@@ -1075,11 +1077,11 @@
no unique maximal instance exists for type variable {0} with upper bounds {1}
compiler.misc.no.unique.minimal.instance.exists=\
no unique minimal instance exists for type variable {0} with lower bounds {1}
-compiler.misc.no.conforming.instance.exists=\
+compiler.misc.infer.no.conforming.instance.exists=\
no instance(s) of type variable(s) {0} exist so that {1} conforms to {2}
-compiler.misc.no.conforming.assignment.exists=\
+compiler.misc.infer.no.conforming.assignment.exists=\
no instance(s) of type variable(s) {0} exist so that argument type {1} conforms to formal parameter type {2}
-compiler.misc.arg.length.mismatch=\
+compiler.misc.infer.arg.length.mismatch=\
cannot instantiate from arguments because actual and formal argument lists differ in length
compiler.misc.inferred.do.not.conform.to.bounds=\
inferred type does not conform to declared bound(s)\n\
@@ -1095,6 +1097,16 @@
type argument {0} inferred for {1} is not allowed in this context
compiler.misc.diamond.invalid.args=\
type arguments {0} inferred for {1} are not allowed in this context
+
+compiler.misc.explicit.param.do.not.conform.to.bounds=\
+ explicit type argument {0} does not conform to declared bound(s) {1}
+
+compiler.misc.arg.length.mismatch=\
+ actual and formal argument lists differ in length
+compiler.misc.no.conforming.assignment.exists=\
+ actual argument {0} cannot be converted to {1} by method invocation conversion
+compiler.misc.varargs.argument.mismatch=\
+ argument type {0} does not conform to vararg element type {1}
#####
## The first argument ({0}) is a "kindname".
@@ -1232,6 +1244,10 @@
compiler.misc.non.denotable.type=\
Non-denotable type {0} not allowed here
+compiler.misc.inapplicable.method=\
+ {0} {1}.{2} is not applicable\n\
+ ({3})
+
########################################
# Diagnostics for language feature changes
########################################
--- a/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java Mon Oct 04 14:40:38 2010 -0700
@@ -65,8 +65,6 @@
*/
public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
- protected int currentIndentation = 0;
-
/**
* Create a basic formatter based on the supplied options.
*
@@ -107,33 +105,28 @@
}
public String formatMessage(JCDiagnostic d, Locale l) {
- int prevIndentation = currentIndentation;
- try {
- StringBuilder buf = new StringBuilder();
- Collection<String> args = formatArguments(d, l);
- String msg = localize(l, d.getCode(), args.toArray());
- String[] lines = msg.split("\n");
- if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) {
- currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY);
- buf.append(indent(lines[0], currentIndentation)); //summary
+ int currentIndentation = 0;
+ StringBuilder buf = new StringBuilder();
+ Collection<String> args = formatArguments(d, l);
+ String msg = localize(l, d.getCode(), args.toArray());
+ String[] lines = msg.split("\n");
+ if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) {
+ currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY);
+ buf.append(indent(lines[0], currentIndentation)); //summary
+ }
+ if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) {
+ currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS);
+ for (int i = 1;i < lines.length; i++) {
+ buf.append("\n" + indent(lines[i], currentIndentation));
}
- if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) {
- currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS);
- for (int i = 1;i < lines.length; i++) {
- buf.append("\n" + indent(lines[i], currentIndentation));
- }
- }
- if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) {
- currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS);
+ }
+ if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) {
+ currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS);
for (String sub : formatSubdiagnostics(d, l)) {
- buf.append("\n" + sub);
- }
+ buf.append("\n" + indent(sub, currentIndentation));
}
- return buf.toString();
}
- finally {
- currentIndentation = prevIndentation;
- }
+ return buf.toString();
}
protected String addSourceLineIfNeeded(JCDiagnostic d, String msg) {
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java Mon Oct 04 14:40:38 2010 -0700
@@ -35,11 +35,14 @@
import javax.tools.DiagnosticListener;
import javax.tools.JavaFileObject;
+import com.sun.tools.javac.api.DiagnosticFormatter;
+import com.sun.tools.javac.main.OptionName;
import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.api.DiagnosticFormatter;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
+import static com.sun.tools.javac.main.OptionName.*;
+
/** A class for error logs. Reports errors and warnings, and
* keeps track of error numbers and positions.
*
@@ -129,14 +132,14 @@
this.noticeWriter = noticeWriter;
Options options = Options.instance(context);
- this.dumpOnError = options.get("-doe") != null;
- this.promptOnError = options.get("-prompt") != null;
- this.emitWarnings = options.get("-Xlint:none") == null;
- this.suppressNotes = options.get("suppressNotes") != null;
- this.MaxErrors = getIntOption(options, "-Xmaxerrs", getDefaultMaxErrors());
- this.MaxWarnings = getIntOption(options, "-Xmaxwarns", getDefaultMaxWarnings());
+ this.dumpOnError = options.isSet(DOE);
+ this.promptOnError = options.isSet(PROMPT);
+ this.emitWarnings = options.isUnset(XLINT_CUSTOM, "none");
+ this.suppressNotes = options.isSet("suppressNotes");
+ this.MaxErrors = getIntOption(options, XMAXERRS, getDefaultMaxErrors());
+ this.MaxWarnings = getIntOption(options, XMAXWARNS, getDefaultMaxWarnings());
- boolean rawDiagnostics = options.get("rawDiagnostics") != null;
+ boolean rawDiagnostics = options.isSet("rawDiagnostics");
messages = JavacMessages.instance(context);
this.diagFormatter = rawDiagnostics ? new RawDiagnosticFormatter(options) :
new BasicDiagnosticFormatter(options, messages);
@@ -150,7 +153,7 @@
expectDiagKeys = new HashSet<String>(Arrays.asList(ek.split(", *")));
}
// where
- private int getIntOption(Options options, String optionName, int defaultValue) {
+ private int getIntOption(Options options, OptionName optionName, int defaultValue) {
String s = options.get(optionName);
try {
if (s != null) {
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Names.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Names.java Mon Oct 04 14:40:38 2010 -0700
@@ -271,7 +271,7 @@
}
protected Name.Table createTable(Options options) {
- boolean useUnsharedTable = options.get("useUnsharedTable") != null;
+ boolean useUnsharedTable = options.isSet("useUnsharedTable");
if (useUnsharedTable)
return new UnsharedNameTable(this);
else
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Options.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Options.java Mon Oct 04 14:40:38 2010 -0700
@@ -25,8 +25,9 @@
package com.sun.tools.javac.util;
+import java.util.*;
import com.sun.tools.javac.main.OptionName;
-import java.util.*;
+import static com.sun.tools.javac.main.OptionName.*;
/** A table of all command-line options.
* If an option has an argument, the option name is mapped to the argument.
@@ -60,14 +61,62 @@
context.put(optionsKey, this);
}
+ /**
+ * Get the value for an undocumented option.
+ */
public String get(String name) {
return values.get(name);
}
+ /**
+ * Get the value for an option.
+ */
public String get(OptionName name) {
return values.get(name.optionName);
}
+ /**
+ * Check if the value for an undocumented option has been set.
+ */
+ public boolean isSet(String name) {
+ return (values.get(name) != null);
+ }
+
+ /**
+ * Check if the value for an option has been set.
+ */
+ public boolean isSet(OptionName name) {
+ return (values.get(name.optionName) != null);
+ }
+
+ /**
+ * Check if the value for a choice option has been set to a specific value.
+ */
+ public boolean isSet(OptionName name, String value) {
+ return (values.get(name.optionName + value) != null);
+ }
+
+ /**
+ * Check if the value for an undocumented option has not been set.
+ */
+ public boolean isUnset(String name) {
+ return (values.get(name) == null);
+ }
+
+ /**
+ * Check if the value for an option has not been set.
+ */
+ public boolean isUnset(OptionName name) {
+ return (values.get(name.optionName) == null);
+ }
+
+ /**
+ * Check if the value for a choice option has not been set to a specific value.
+ */
+ public boolean isUnset(OptionName name, String value) {
+ return (values.get(name.optionName + value) == null);
+ }
+
public void put(String name, String value) {
values.put(name, value);
}
@@ -92,16 +141,14 @@
return values.size();
}
- static final String LINT = "-Xlint";
-
/** Check for a lint suboption. */
public boolean lint(String s) {
// return true if either the specific option is enabled, or
// they are all enabled without the specific one being
// disabled
return
- get(LINT + ":" + s)!=null ||
- (get(LINT)!=null || get(LINT + ":all")!=null) &&
- get(LINT+":-"+s)==null;
+ isSet(XLINT_CUSTOM, s) ||
+ (isSet(XLINT) || isSet(XLINT_CUSTOM, "all")) &&
+ isUnset(XLINT_CUSTOM, "-" + s);
}
}
--- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -107,9 +107,6 @@
// force the use of Messager as a Log
messager = Messager.instance0(context);
- // force the use of the scanner that captures Javadoc comments
- DocCommentScanner.Factory.preRegister(context);
-
return new JavadocTool(context);
} catch (CompletionFailure ex) {
messager.error(Position.NOPOS, ex.getMessage());
--- a/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -526,15 +526,17 @@
}
private void showVersion(boolean full) {
- log.println(version(full ? "full" : "release"));
+ log.println(version(full));
}
private static final String versionRBName = "com.sun.tools.javah.resources.version";
private static ResourceBundle versionRB;
- private String version(String key) {
- // key=version: mm.nn.oo[-milestone]
- // key=full: mm.mm.oo[-milestone]-build
+ private String version(boolean full) {
+ String msgKey = (full ? "javah.fullVersion" : "javah.version");
+ String versionKey = (full ? "full" : "release");
+ // versionKey=product: mm.nn.oo[-milestone]
+ // versionKey=full: mm.mm.oo[-milestone]-build
if (versionRB == null) {
try {
versionRB = ResourceBundle.getBundle(versionRBName);
@@ -543,7 +545,7 @@
}
}
try {
- return versionRB.getString(key);
+ return getMessage(msgKey, "javah", versionRB.getString(versionKey));
}
catch (MissingResourceException e) {
return getMessage("version.unknown", System.getProperty("java.version"));
--- a/langtools/src/share/classes/com/sun/tools/javah/resources/l10n.properties Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javah/resources/l10n.properties Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -113,7 +113,8 @@
#
# Version string.
#
-javah.version=javah version "{0}"
+javah.version={0} version "{1}"
+javah.fullVersion={0} full version "{1}"
#
# These should have better diagnostics.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javah/resources/version.properties-template Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,28 @@
+#
+# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+jdk=$(JDK_VERSION)
+full=$(FULL_VERSION)
+release=$(RELEASE)
--- a/langtools/test/tools/javac/6302184/T6302184.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/6302184/T6302184.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,4 +1,7 @@
+/**
+ * This is a test that uses ISO 8859 encoding.
+ */
class T6302184 {
T6302184() {
--- a/langtools/test/tools/javac/6304921/TestLog.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/6304921/TestLog.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.parser.Parser;
import com.sun.tools.javac.parser.ParserFactory;
-import com.sun.tools.javac.parser.Scanner;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeScanner;
import com.sun.tools.javac.util.Context;
@@ -60,7 +59,6 @@
log.multipleErrors = true;
JavacFileManager.preRegister(context);
- Scanner.Factory sfac = Scanner.Factory.instance(context);
ParserFactory pfac = ParserFactory.instance(context);
final String text =
--- a/langtools/test/tools/javac/6758789/T6758789a.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/6758789/T6758789a.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,3 +1,3 @@
-T6758789a.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, null
-T6758789a.java:15:9: compiler.err.cant.apply.symbol: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, null
+T6758789a.java:14:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch)
+T6758789a.java:15:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch)
2 errors
--- a/langtools/test/tools/javac/6840059/T6840059.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/6840059/T6840059.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,3 +1,3 @@
-T6840059.java:15:9: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, null
-T6840059.java:15:25: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, compiler.misc.no.args, kindname.class, T6840059, null
+T6840059.java:15:9: compiler.err.cant.apply.symbol.1: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, (compiler.misc.no.conforming.assignment.exists: java.lang.String, java.lang.Integer)
+T6840059.java:15:25: compiler.err.cant.apply.symbol.1: kindname.constructor, T6840059, java.lang.Integer, compiler.misc.no.args, kindname.class, T6840059, (compiler.misc.arg.length.mismatch)
2 errors
--- a/langtools/test/tools/javac/6857948/T6857948.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/6857948/T6857948.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,3 +1,3 @@
T6857948.java:16:32: compiler.err.cant.resolve.location.args: kindname.method, nosuchfunction, , , kindname.class, Test
-T6857948.java:16:50: compiler.err.cant.apply.symbol: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, null
+T6857948.java:16:50: compiler.err.cant.apply.symbol.1: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, (compiler.misc.arg.length.mismatch)
2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6863465/T6863465a.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,14 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 6863465
+ * @summary javac doesn't detect circular subclass dependencies via qualified names
+ * @author Maurizio Cimadamore
+ * @compile/fail/ref=T6863465a.out -XDrawDiagnostics T6863465a.java
+ */
+
+class T6863465a {
+ static class a { static interface b {} }
+ static class c extends a implements z.y {}
+ static class x { static interface y {} }
+ static class z extends x implements c.b {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6863465/T6863465a.out Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,2 @@
+T6863465a.java:11:12: compiler.err.cyclic.inheritance: T6863465a.c
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6863465/T6863465b.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,14 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 6863465
+ * @summary javac doesn't detect circular subclass dependencies via qualified names
+ * @author Maurizio Cimadamore
+ * @compile/fail/ref=T6863465b.out -XDrawDiagnostics T6863465b.java
+ */
+
+class T6863465b {
+ static class a { static interface b { static interface d {} } }
+ static class c extends a implements z.y, z.d {}
+ static class x { static interface y {} }
+ static class z extends x implements c.b {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6863465/T6863465b.out Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,2 @@
+T6863465b.java:11:12: compiler.err.cyclic.inheritance: T6863465b.c
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6863465/T6863465c.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,14 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 6863465
+ * @summary javac doesn't detect circular subclass dependencies via qualified names
+ * @author Maurizio Cimadamore
+ * @compile/fail/ref=T6863465c.out -XDrawDiagnostics T6863465c.java
+ */
+
+class T6863465c {
+ static class x { static interface y {} }
+ static class z extends x implements c.b {}
+ static class a { static interface b { static interface d {} } }
+ static class c extends a implements z.y, z.d {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6863465/T6863465c.out Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,3 @@
+T6863465c.java:13:47: compiler.err.cant.resolve.location: kindname.class, d, , , kindname.class, T6863465c.z
+T6863465c.java:11:12: compiler.err.cyclic.inheritance: T6863465c.z
+2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6863465/T6863465d.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,14 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 6863465
+ * @summary javac doesn't detect circular subclass dependencies via qualified names
+ * @author Maurizio Cimadamore
+ * @compile/fail/ref=T6863465d.out -XDrawDiagnostics T6863465d.java
+ */
+
+class T6863465d {
+ static class a { static interface b { static interface d {} } }
+ static class c extends a implements z.y, z.d {}
+ static class x { static interface y { static interface w {} } }
+ static class z extends x implements c.b, c.w {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6863465/T6863465d.out Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,3 @@
+T6863465d.java:13:47: compiler.err.cant.resolve.location: kindname.class, w, , , kindname.class, T6863465d.c
+T6863465d.java:11:12: compiler.err.cyclic.inheritance: T6863465d.c
+2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6863465/TestCircularClassfile.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6863465
+ * @summary javac doesn't detect circular subclass dependencies via qualified names
+ * @run main TestCircularClassfile
+ */
+
+import java.io.*;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import java.util.EnumSet;
+
+public class TestCircularClassfile {
+
+ enum ClassName {
+ A("A"),
+ B("B"),
+ C("C"),
+ OBJECT("Object");
+
+ String name;
+
+ ClassName(String name) {
+ this.name = name;
+ }
+ }
+
+ static class JavaSource extends SimpleJavaFileObject {
+
+ final static String sourceStub = "class #C extends #S {}";
+
+ String source;
+
+ public JavaSource(ClassName clazz, ClassName sup) {
+ super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+ source = sourceStub.replace("#C", clazz.name).replace("#S", sup.name);
+ }
+
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ return source;
+ }
+ }
+
+ public static void main(String... args) throws Exception {
+ int count = 0;
+ for (ClassName clazz : EnumSet.of(ClassName.A, ClassName.B, ClassName.C)) {
+ for (ClassName sup : EnumSet.of(ClassName.A, ClassName.B, ClassName.C)) {
+ if (sup.ordinal() < clazz.ordinal()) continue;
+ check("sub_"+count++, clazz, sup);
+ }
+ }
+ }
+
+ static JavaSource[] initialSources = new JavaSource[] {
+ new JavaSource(ClassName.A, ClassName.OBJECT),
+ new JavaSource(ClassName.B, ClassName.A),
+ new JavaSource(ClassName.C, ClassName.B)
+ };
+
+ static String workDir = System.getProperty("user.dir");
+
+ static void check(String destPath, ClassName clazz, ClassName sup) throws Exception {
+ File destDir = new File(workDir, destPath); destDir.mkdir();
+ final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+ JavacTask ct = (JavacTask)tool.getTask(null, null, null,
+ Arrays.asList("-d", destPath), null, Arrays.asList(initialSources));
+ ct.generate();
+ File fileToRemove = new File(destPath, clazz.name + ".class");
+ fileToRemove.delete();
+ JavaSource newSource = new JavaSource(clazz, sup);
+ DiagnosticChecker checker = new DiagnosticChecker();
+ ct = (JavacTask)tool.getTask(null, null, checker,
+ Arrays.asList("-cp", destPath), null, Arrays.asList(newSource));
+ ct.analyze();
+ if (!checker.errorFound) {
+ throw new AssertionError(newSource.source);
+ }
+ }
+
+ static class DiagnosticChecker implements DiagnosticListener<JavaFileObject> {
+
+ boolean errorFound = false;
+
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
+ diagnostic.getCode().equals("compiler.err.cyclic.inheritance")) {
+ errorFound = true;
+ }
+ }
+ }
+}
--- a/langtools/test/tools/javac/CyclicInheritance.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/CyclicInheritance.out Mon Oct 04 14:40:38 2010 -0700
@@ -4,6 +4,6 @@
CyclicInheritance.java:22:1: compiler.err.cyclic.inheritance: I11
CyclicInheritance.java:27:1: compiler.err.cyclic.inheritance: C211
CyclicInheritance.java:31:1: compiler.err.cyclic.inheritance: C212
-CyclicInheritance.java:36:27: compiler.err.report.access: C221.I, private, C221
-CyclicInheritance.java:40:24: compiler.err.report.access: C222.C, private, C222
+CyclicInheritance.java:36:1: compiler.err.cyclic.inheritance: C221
+CyclicInheritance.java:40:1: compiler.err.cyclic.inheritance: C222
8 errors
--- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234a_1.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234a_1.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,2 +1,2 @@
-T6722234a.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, null
+T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1)
1 error
--- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234a_2.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234a_2.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,3 +1,3 @@
-T6722234a.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, null
+T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1)
- compiler.misc.where.description.typevar.1: compiler.misc.type.var: T, 1,compiler.misc.type.var: T, 2,{(compiler.misc.where.typevar: compiler.misc.type.var: T, 1, java.lang.String, kindname.class, T6722234a),(compiler.misc.where.typevar: compiler.misc.type.var: T, 2, java.lang.Integer, kindname.method, <compiler.misc.type.var: T, 2>test(compiler.misc.type.var: T, 2))}
1 error
--- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234b_1.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234b_1.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,2 +1,2 @@
-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
+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>)
1 error
--- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234b_2.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234b_2.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,4 +1,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
+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>)
- compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, Object, kindname.method, <T>m(List<T>,List<T>))}
- compiler.misc.where.description.captured.1: compiler.misc.captured.type: 1,compiler.misc.captured.type: 2,{(compiler.misc.where.captured.1: compiler.misc.captured.type: 1, T6722234b, compiler.misc.type.null, ? extends T6722234b),(compiler.misc.where.captured.1: compiler.misc.captured.type: 2, T6722234b, compiler.misc.type.null, ? extends T6722234b)}
1 error
--- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,2 +1,2 @@
-T6722234c.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, null
+T6722234c.java:14:9: compiler.err.cant.apply.symbol.1: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, (compiler.misc.infer.no.conforming.assignment.exists: T, java.lang.String, T6722234c.String)
1 error
--- a/langtools/test/tools/javac/Diagnostics/6799605/T6799605.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/Diagnostics/6799605/T6799605.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,4 +1,4 @@
-T6799605.java:17:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>, kindname.class, T6799605<X>
-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>
-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>
+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, ?>))}
+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))}
+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))}
3 errors
--- a/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,3 +1,3 @@
-T6862608a.java:19:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, java.util.Comparator<T>, java.util.Comparator<java.lang.String>)), <T>java.util.Comparator<T>, java.util.Comparator<java.lang.String>
+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>
- 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>>))}
1 error
--- a/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,3 +1,3 @@
-T6862608b.java:11:7: compiler.err.cant.apply.symbol: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b<compiler.misc.type.var: T, 1,compiler.misc.type.var: S, 2>, null
+T6862608b.java:11:7: compiler.err.cant.apply.symbol.1: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b<compiler.misc.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)
- 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)}
1 error
--- a/langtools/test/tools/javac/NameCollision.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/NameCollision.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,2 +1,3 @@
NameCollision.java:13:31: compiler.err.intf.expected.here
-1 error
+NameCollision.java:13:5: compiler.err.cyclic.inheritance: NameCollision.Runnable
+2 errors
--- a/langtools/test/tools/javac/T6326754.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/T6326754.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,7 +1,7 @@
T6326754.java:44:12: compiler.err.name.clash.same.erasure: TestConstructor(T), TestConstructor(K)
T6326754.java:52:17: compiler.err.name.clash.same.erasure: setT(K), setT(T)
T6326754.java:64:18: compiler.err.prob.found.req: (compiler.misc.incompatible.types), T, T
-T6326754.java:70:11: compiler.err.cant.apply.symbol: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC<T>, null
+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)
- compiler.note.unchecked.filename: T6326754.java
- compiler.note.unchecked.recompile
4 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T6587674.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6587674
+ * @summary NoClassdefFound when anonymously extending a class.
+ */
+
+import java.util.Vector;
+
+public class T6587674 {
+ private static final Vector<String> list =
+ true ? null : new Vector<String>() { };
+
+ public static void main(String[] args) {
+ System.out.println("T6587674 runs fine!");
+ }
+}
--- a/langtools/test/tools/javac/api/TestJavacTaskScanner.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,8 +31,8 @@
*/
import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.parser.*; // XXX
-import com.sun.tools.javac.util.*; // XXX
+import com.sun.tools.javac.parser.*;
+import com.sun.tools.javac.util.*;
import java.io.*;
import java.net.*;
import java.nio.*;
@@ -65,7 +65,7 @@
fm.getJavaFileObjects(new File[] {file});
StandardJavaFileManager fm = getLocalFileManager(tool, null, null);
task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, compilationUnits);
- task.getContext().put(Scanner.Factory.scannerFactoryKey,
+ task.getContext().put(ScannerFactory.scannerFactoryKey,
new MyScanner.Factory(task.getContext(), this));
elements = task.getElements();
types = task.getTypes();
@@ -170,34 +170,36 @@
class MyScanner extends Scanner {
- public static class Factory extends Scanner.Factory {
+ public static class Factory extends ScannerFactory {
public Factory(Context context, TestJavacTaskScanner test) {
super(context);
this.test = test;
}
@Override
- public Scanner newScanner(CharSequence input) {
+ public Scanner newScanner(CharSequence input, boolean keepDocComments) {
+ assert !keepDocComments;
if (input instanceof CharBuffer) {
return new MyScanner(this, (CharBuffer)input, test);
} else {
char[] array = input.toString().toCharArray();
- return newScanner(array, array.length);
+ return newScanner(array, array.length, keepDocComments);
}
}
@Override
- public Scanner newScanner(char[] input, int inputLength) {
+ public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) {
+ assert !keepDocComments;
return new MyScanner(this, input, inputLength, test);
}
private TestJavacTaskScanner test;
}
- protected MyScanner(Factory fac, CharBuffer buffer, TestJavacTaskScanner test) {
+ protected MyScanner(ScannerFactory fac, CharBuffer buffer, TestJavacTaskScanner test) {
super(fac, buffer);
this.test = test;
}
- protected MyScanner(Factory fac, char[] input, int inputLength, TestJavacTaskScanner test) {
+ protected MyScanner(ScannerFactory fac, char[] input, int inputLength, TestJavacTaskScanner test) {
super(fac, input, inputLength);
this.test = test;
}
--- a/langtools/test/tools/javac/diags/Example.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/diags/Example.java Mon Oct 04 14:40:38 2010 -0700
@@ -401,7 +401,7 @@
}
}
for (JCDiagnostic sd: d.getSubdiagnostics())
- scanForKeys(d, keys);
+ scanForKeys(sd, keys);
}
}
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt Mon Oct 04 14:40:38 2010 -0700
@@ -3,7 +3,7 @@
compiler.err.annotation.value.not.allowable.type # cannot happen: precluded by complete type-specific tests
compiler.err.assignment.from.super-bound # DEAD
compiler.err.assignment.to.extends-bound # DEAD
-compiler.err.cant.apply.symbol.1
+compiler.err.cant.apply.symbol
compiler.err.cant.read.file # (apt.JavaCompiler?)
compiler.err.cant.select.static.class.from.param.type
compiler.err.illegal.char.for.encoding
@@ -43,7 +43,6 @@
compiler.err.unexpected.type
compiler.err.unknown.enum.constant # in bad class file
compiler.err.unsupported.cross.fp.lit # Scanner: host system dependent
-compiler.misc.arg.length.mismatch
compiler.misc.assignment.from.super-bound
compiler.misc.assignment.to.extends-bound
compiler.misc.bad.class.file.header # bad class file
@@ -73,7 +72,6 @@
compiler.misc.kindname.type.variable
compiler.misc.kindname.type.variable.bound
compiler.misc.kindname.value
-compiler.misc.no.conforming.assignment.exists
compiler.misc.non.denotable.type
compiler.misc.no.unique.minimal.instance.exists
compiler.misc.resume.abort # prompt for a response
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ExplicitParamsDoNotConformToBounds.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.explicit.param.do.not.conform.to.bounds
+
+class ExplicitParamsDoNotConformToBounds {
+ <X extends Number> void m() {}
+ { this.<String>m(); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/InapplicableSymbols.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbols
+// key: compiler.misc.arg.length.mismatch
+// key: compiler.misc.inapplicable.method
+
+class ExplicitParamsDoNotConformToBounds {
+ void m(int i1) {}
+ void m(int i1, int i2) {}
+ { this.m(); }
+}
--- a/langtools/test/tools/javac/diags/examples/IncompatibleTypes1.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleTypes1.java Mon Oct 04 14:40:38 2010 -0700
@@ -22,7 +22,7 @@
*/
// key: compiler.misc.incompatible.types.1
-// key: compiler.misc.no.conforming.instance.exists
+// key: compiler.misc.infer.no.conforming.instance.exists
// key: compiler.err.prob.found.req
class IncompatibleTypes1<V> {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/InferArgsLengthMismatch.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.infer.arg.length.mismatch
+
+class InferArgsLengthMismatch {
+ <X extends Number> void m(X x1, X x2) {}
+ { this.m(1); }
+}
--- a/langtools/test/tools/javac/diags/examples/KindnameConstructor.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/KindnameConstructor.java Mon Oct 04 14:40:38 2010 -0700
@@ -24,7 +24,9 @@
// key: compiler.misc.kindname.constructor
// key: compiler.misc.kindname.class
// key: compiler.misc.no.args
-// key: compiler.err.cant.apply.symbol
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.arg.length.mismatch
+// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.count.error.plural
// run: backdoor
--- a/langtools/test/tools/javac/diags/examples/NoArgs.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/NoArgs.java Mon Oct 04 14:40:38 2010 -0700
@@ -22,7 +22,8 @@
*/
// key: compiler.misc.no.args
-// key: compiler.err.cant.apply.symbol
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.arg.length.mismatch
// run: simple
class X {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/VarargsArgumentMismatch.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.varargs.argument.mismatch
+
+class VarargsArgumentMismatch {
+ void m(String s, Integer... is) {}
+ { this.m("1", "2", "3"); }
+}
--- a/langtools/test/tools/javac/diags/examples/WhereCaptured.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/WhereCaptured.java Mon Oct 04 14:40:38 2010 -0700
@@ -25,7 +25,8 @@
// key: compiler.misc.where.description.captured.1
// key: compiler.misc.where.description.typevar
// key: compiler.misc.where.typevar
-// key: compiler.err.cant.apply.symbol
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.infer.no.conforming.assignment.exists
// key: compiler.misc.captured.type
// options: -XDdiags=where,simpleNames
// run: simple
--- a/langtools/test/tools/javac/diags/examples/WhereCaptured1.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/WhereCaptured1.java Mon Oct 04 14:40:38 2010 -0700
@@ -25,7 +25,8 @@
// key: compiler.misc.where.description.captured.1
// key: compiler.misc.where.description.typevar
// key: compiler.misc.where.typevar
-// key: compiler.err.cant.apply.symbol
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.infer.no.conforming.assignment.exists
// key: compiler.misc.captured.type
// key: compiler.misc.type.null
// options: -XDdiags=where,simpleNames
--- a/langtools/test/tools/javac/diags/examples/WhereTypeVar.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/WhereTypeVar.java Mon Oct 04 14:40:38 2010 -0700
@@ -24,7 +24,8 @@
// key: compiler.misc.where.typevar
// key: compiler.misc.where.description.typevar.1
// key: compiler.misc.type.var
-// key: compiler.err.cant.apply.symbol
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.no.conforming.assignment.exists
// options: -XDdiags=where,disambiguateTvars
// run: simple
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,4 +1,4 @@
-Neg06.java:18:36: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.IFoo<X>, Neg06.ISuperFoo<java.lang.String>)
-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>)
-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>)
+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>)
+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>)
+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>)
3 errors
--- a/langtools/test/tools/javac/generics/inference/6315770/T6315770.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/generics/inference/6315770/T6315770.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,3 +1,3 @@
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)
-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>
+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>
2 errors
--- a/langtools/test/tools/javac/generics/inference/6611449/T6611449.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/generics/inference/6611449/T6611449.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
-T6611449.java:18:9: compiler.err.cant.resolve.location.args: kindname.constructor, T6611449, , int, kindname.class, T6611449<S>
-T6611449.java:19:9: compiler.err.cant.resolve.location.args: kindname.constructor, T6611449, , int,int, kindname.class, T6611449<S>
-T6611449.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m1, T, int, kindname.class, T6611449<S>, null
-T6611449.java:21:9: compiler.err.cant.apply.symbol: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, null
+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))}
+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))}
+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)
+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)
4 errors
--- a/langtools/test/tools/javac/generics/inference/6638712/T6638712a.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712a.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,2 +1,2 @@
-T6638712a.java:16:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, java.util.Comparator<T>, java.util.Comparator<java.lang.String>)), <T>java.util.Comparator<T>, java.util.Comparator<java.lang.String>
+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>
1 error
--- a/langtools/test/tools/javac/generics/inference/6638712/T6638712b.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712b.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,2 +1,2 @@
-T6638712b.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, T, java.lang.String)), <T>T, java.lang.String
+T6638712b.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, T, java.lang.String)), <T>T, java.lang.String
1 error
--- a/langtools/test/tools/javac/generics/inference/6638712/T6638712c.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712c.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,2 +1,2 @@
-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
+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<?>>)
1 error
--- a/langtools/test/tools/javac/generics/inference/6638712/T6638712d.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712d.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,2 +1,2 @@
-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
+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>>)
1 error
--- a/langtools/test/tools/javac/generics/inference/6638712/T6638712e.out Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712e.out Mon Oct 04 14:40:38 2010 -0700
@@ -1,2 +1,2 @@
-T6638712e.java:17:27: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: X, T6638712e.Foo<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>
+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>
1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+
+/**
+ * An abstract annotation processor tailored to javac regression testing.
+ */
+public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
+ private static final Set<String> allAnnotations;
+
+ static {
+ Set<String> tmp = new HashSet<>();
+ tmp.add("*");
+ allAnnotations = Collections.unmodifiableSet(tmp);
+ }
+
+ protected Elements eltUtils;
+ protected Elements elements;
+ protected Types typeUtils;
+ protected Types types;
+ protected Filer filer;
+ protected Messager messager;
+ protected Map<String, String> options;
+
+ /**
+ * Constructor for subclasses to call.
+ */
+ protected JavacTestingAbstractProcessor() {
+ super();
+ }
+
+ /**
+ * Return the latest source version. Unless this method is
+ * overridden, an {@code IllegalStateException} will be thrown if a
+ * subclass has a {@code SupportedSourceVersion} annotation.
+ */
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ SupportedSourceVersion ssv = this.getClass().getAnnotation(SupportedSourceVersion.class);
+ if (ssv != null)
+ throw new IllegalStateException("SupportedSourceVersion annotation not supported here.");
+
+ return SourceVersion.latest();
+ }
+
+ /**
+ * If the processor class is annotated with {@link
+ * SupportedAnnotationTypes}, return an unmodifiable set with the
+ * same set of strings as the annotation. If the class is not so
+ * annotated, a one-element set containing {@code "*"} is returned
+ * to indicate all annotations are processed.
+ *
+ * @return the names of the annotation types supported by this
+ * processor, or an empty set if none
+ */
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ SupportedAnnotationTypes sat = this.getClass().getAnnotation(SupportedAnnotationTypes.class);
+ if (sat != null)
+ return super.getSupportedAnnotationTypes();
+ else
+ return allAnnotations;
+ }
+
+ @Override
+ public void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ elements = eltUtils = processingEnv.getElementUtils();
+ types = typeUtils = processingEnv.getTypeUtils();
+ filer = processingEnv.getFiler();
+ messager = processingEnv.getMessager();
+ options = processingEnv.getOptions();
+ }
+}
--- a/langtools/test/tools/javac/processing/6348499/A.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6348499/A.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,10 +27,8 @@
import javax.lang.model.*;
import javax.lang.model.element.*;
-@SupportedAnnotationTypes("*")
-public class A extends AbstractProcessor {
+public class A extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
- Filer filer = processingEnv.getFiler();
try {
OutputStream out = filer.createClassFile(getClass().getName()+"_0").openOutputStream();
out.close();
@@ -39,8 +37,4 @@
}
return true;
}
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/6348499/T6348499.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6348499/T6348499.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,8 @@
* @test
* @bug 6441871
* @summary javac crashes at com.sun.tools.javac.jvm.ClassReader$BadClassFile
- * @build A
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor A
* @run main T6348499
*/
@@ -54,7 +55,6 @@
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
Iterable<String> opts = Arrays.asList("-proc:only",
"-processor", "A",
- "-source", "1.6",
"-processorpath", testClasses);
StringWriter out = new StringWriter();
JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
--- a/langtools/test/tools/javac/processing/6359313/T6359313.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6359313/T6359313.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6359313
* @summary error compiling annotated package
* @author Peter von der Ah\u00e9
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile T6359313.java
* @compile -processor T6359313 package-info.java Foo.java
*/
@@ -37,7 +39,7 @@
import javax.lang.model.element.TypeElement;
@SupportedAnnotationTypes("Foo")
-public class T6359313 extends AbstractProcessor {
+public class T6359313 extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
return true;
--- a/langtools/test/tools/javac/processing/6365040/ProcBar.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6365040/ProcBar.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,13 +31,11 @@
/**
* Second of several processors to run.
*/
-@SupportedAnnotationTypes("*")
-public class ProcBar extends AbstractProcessor {
+public class ProcBar extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
if (!roundEnvironment.processingOver())
- processingEnv.getMessager().printMessage(NOTE,
- "Hello from ProcBar");
+ messager.printMessage(NOTE, "Hello from ProcBar");
return false;
}
}
--- a/langtools/test/tools/javac/processing/6365040/ProcFoo.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6365040/ProcFoo.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,13 +31,11 @@
/**
* First of several processors to run.
*/
-@SupportedAnnotationTypes("*")
-public class ProcFoo extends AbstractProcessor {
+public class ProcFoo extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
if (!roundEnvironment.processingOver())
- processingEnv.getMessager().printMessage(NOTE,
- "Hello from ProcFoo");
+ messager.printMessage(NOTE, "Hello from ProcFoo");
return false;
}
}
--- a/langtools/test/tools/javac/processing/6365040/T6365040.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6365040/T6365040.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6365040 6358129
* @summary Test -processor foo,bar,baz
* @author Joseph D. Darcy
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile ProcFoo.java
* @compile ProcBar.java
* @compile T6365040.java
@@ -43,13 +45,11 @@
import javax.lang.model.element.TypeElement;
import static javax.tools.Diagnostic.Kind.*;
-@SupportedAnnotationTypes("*")
-public class T6365040 extends AbstractProcessor {
+public class T6365040 extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
if (!roundEnvironment.processingOver())
- processingEnv.getMessager().printMessage(NOTE,
- "Hello from T6365040");
+ messager.printMessage(NOTE, "Hello from T6365040");
return true;
}
}
--- a/langtools/test/tools/javac/processing/6413690/T6413690.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6413690/T6413690.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6413690 6380018
* @summary JavacProcessingEnvironment does not enter trees from preceding rounds
* @author Peter von der Ah\u00e9
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile T6413690.java
* @compile -XDfatalEnterError -verbose -processor T6413690 src/Super.java TestMe.java
*/
@@ -42,11 +44,9 @@
import javax.lang.model.util.Elements;
@SupportedAnnotationTypes("TestMe")
-public class T6413690 extends AbstractProcessor {
+public class T6413690 extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
- Elements elements = processingEnv.getElementUtils();
- Filer filer = processingEnv.getFiler();
TypeElement testMe = elements.getTypeElement(TestMe.class.getName());
Set<? extends Element> supers = roundEnvironment.getElementsAnnotatedWith(testMe);
try {
--- a/langtools/test/tools/javac/processing/6414633/A.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6414633/A.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,9 +29,8 @@
import javax.lang.model.element.*;
import javax.tools.*;
-@SupportedAnnotationTypes("*")
-public class A extends AbstractProcessor {
-
+@SuppressWarnings("")
+public class A extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
Messager m = processingEnv.getMessager();
for (TypeElement anno: annotations) {
@@ -42,8 +41,6 @@
return true;
}
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
+ @SuppressWarnings("")
+ private void foo() {}
}
--- a/langtools/test/tools/javac/processing/6414633/T6414633.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6414633/T6414633.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,8 @@
* @test
* @bug 6414633 6440109
* @summary Only the first processor message at a source location is reported
- * @build A T6414633
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor A T6414633
* @run main T6414633
*/
@@ -55,8 +56,7 @@
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java")));
String[] opts = { "-proc:only",
"-processor", A.class.getName(),
- "-source", "1.6",
- "-classpath", testClasses };
+ "-classpath", testClasses + System.getProperty("path.separator") + "../../lib" };
JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files);
task.call();
--- a/langtools/test/tools/javac/processing/6430209/T6430209.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6430209/T6430209.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,8 @@
* @test
* @bug 6441871
* @summary spurious compiler error elicited by packageElement.getEnclosedElements()
- * @build b6341534
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor b6341534
* @run main T6430209
*/
@@ -54,7 +55,7 @@
// run annotation processor b6341534 so we can check diagnostics
// -proc:only -processor b6341534 -cp . ./src/*.java
String testSrc = System.getProperty("test.src", ".");
- String testClasses = System.getProperty("test.classes");
+ String testClasses = System.getProperty("test.classes") + System.getProperty("path.separator") + "../../lib";
JavacTool tool = JavacTool.create();
MyDiagListener dl = new MyDiagListener();
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
--- a/langtools/test/tools/javac/processing/6430209/b6341534.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6430209/b6341534.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,16 +30,9 @@
import java.util.*;
import java.util.Set;
-@SupportedAnnotationTypes({"*"})
-public class b6341534 extends AbstractProcessor {
+public class b6341534 extends JavacTestingAbstractProcessor {
static int r = 0;
- static Elements E = null;
- static Messager msgr = null;
- public void init(ProcessingEnvironment penv) {
- processingEnv = penv;
- msgr = penv.getMessager();
- E = penv.getElementUtils();
- }
+
//Create directory 'dir1' and a test class in dir1
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv)
{
@@ -49,13 +42,13 @@
System.out.println("Round"+r+ ": " + t.toString());
try {
- PackageElement PE = E.getPackageElement("dir1");
+ PackageElement PE = eltUtils.getPackageElement("dir1");
List<? extends Element> LEE = PE.getEnclosedElements(); /* <=This line elicits the error message. */
for(Element e : LEE)
System.out.println("found " + e.toString() + " in dir1.");
}
catch(NullPointerException npe) {
- msgr.printMessage(ERROR,npe.toString());
+ messager.printMessage(ERROR,npe.toString());
//npe.printStackTrace();
return false;
}
@@ -63,13 +56,8 @@
// on round 1, expect errorRaised == false && processingOver == false
// on round 2, expect errorRaised == true && processingOver == true
if( renv.errorRaised() != renv.processingOver()) {
- msgr.printMessage(ERROR, "FAILED");
+ messager.printMessage(ERROR, "FAILED");
}
return true;
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/6499119/ClassProcessor.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6499119/ClassProcessor.java Mon Oct 04 14:40:38 2010 -0700
@@ -32,20 +32,17 @@
* @test
* @bug 6499119
* @summary Created package-info class file modeled improperly
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile ClassProcessor.java package-info.java
* @compile/process -cp . -processor ClassProcessor -Akind=java java.lang.Object
* @compile/process -cp . -processor ClassProcessor -Akind=class java.lang.Object
*/
@SupportedOptions({ "gen", "expect" })
-@SupportedAnnotationTypes({"*"})
-public class ClassProcessor extends AbstractProcessor {
+public class ClassProcessor extends JavacTestingAbstractProcessor {
int round = 1;
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (round == 1) {
System.out.println("-- Round 1 --");
@@ -71,8 +68,6 @@
}
private void createPackageFile() {
- Filer filer = processingEnv.getFiler();
-
String kind = processingEnv.getOptions().get("kind");
File pkgInfo;
@@ -125,7 +120,6 @@
}
private void error(String msg) {
- Messager messager = processingEnv.getMessager();
messager.printMessage(Kind.ERROR, msg);
}
}
--- a/langtools/test/tools/javac/processing/6511613/DummyProcessor.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6511613/DummyProcessor.java Mon Oct 04 14:40:38 2010 -0700
@@ -26,15 +26,10 @@
import javax.lang.model.element.*;
import java.util.Set;
-@SupportedAnnotationTypes("*")
-public class DummyProcessor extends AbstractProcessor {
+public class DummyProcessor extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
return true;
}
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/6511613/clss41701.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6511613/clss41701.java Mon Oct 04 14:40:38 2010 -0700
@@ -26,7 +26,8 @@
* @bug 6511613
* @summary javac unexpectedly doesn't fail in some cases if an annotation processor specified
*
- * @build DummyProcessor
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor DummyProcessor
* @compile/fail clss41701.java
* @compile/fail -processor DummyProcessor clss41701.java
*/
--- a/langtools/test/tools/javac/processing/6512707/T6512707.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6512707/T6512707.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,9 @@
* @bug 6512707
* @summary "incompatible types" after (unrelated) annotation processing
* @author Peter Runge
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile T6512707.java
- *
* @compile -processor T6512707 TestAnnotation.java
*/
@@ -41,16 +42,10 @@
* Dummy processor to force bug 6512707 to show - it does not matter what
* the annotation processor does for this bug.
*/
-@SupportedAnnotationTypes("*")
-public class T6512707 extends AbstractProcessor {
+public class T6512707 extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
- return(false);
- }
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
+ return false;
}
}
--- a/langtools/test/tools/javac/processing/6634138/T6634138.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/6634138/T6634138.java Mon Oct 04 14:40:38 2010 -0700
@@ -26,6 +26,8 @@
* @bug 6634138
* @author Joseph D. Darcy
* @summary Verify source files output after processing is over are compiled
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile T6634138.java
* @compile -processor T6634138 Dummy.java
* @run main ExerciseDependency
@@ -44,10 +46,7 @@
import javax.lang.model.element.*;
import javax.lang.model.util.*;
-@SupportedAnnotationTypes("*")
-public class T6634138 extends AbstractProcessor {
- private Filer filer;
-
+public class T6634138 extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
// Write out files *after* processing is over.
@@ -77,16 +76,6 @@
}
return true;
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- public void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- filer = processingEnv.getFiler();
- }
}
--- a/langtools/test/tools/javac/processing/T6439826.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/T6439826.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -48,8 +48,7 @@
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
Iterable<? extends JavaFileObject> files =
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6439826.class.getName()+".java")));
- Iterable<String> opts = Arrays.asList("-source","1.6",
- "-proc:only",
+ Iterable<String> opts = Arrays.asList("-proc:only",
"-processor", "T6439826",
"-processorpath", testClasses);
StringWriter out = new StringWriter();
--- a/langtools/test/tools/javac/processing/T6920317.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/T6920317.java Mon Oct 04 14:40:38 2010 -0700
@@ -25,6 +25,7 @@
* @test
* @bug 6920317
* @summary package-info.java file has to be specified on the javac cmdline, else it will not be avail
+ * @library ../lib
*/
import java.io.*;
@@ -349,12 +350,7 @@
/** Annotation processor used to verify the expected value for the
package annotations found by javac. */
@SupportedOptions({ "gen", "expect" })
- @SupportedAnnotationTypes({"*"})
- public static class Processor extends AbstractProcessor {
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
+ public static class Processor extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annots, RoundEnvironment renv) {
round++;
System.err.println("Round " + round + " annots:" + annots + " rootElems:" + renv.getRootElements());
--- a/langtools/test/tools/javac/processing/Xprint.java Wed Jul 05 17:23:40 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 6266828
- * @summary JSR 269: Java Language Model API
- * @author Peter von der Ah\u00e9
- */
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-
-public class Xprint {
- public static void main(String[] args) {
- JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
- javac.run(System.in, null, null,
- "-Xprint",
- "com.sun.tools.javac.code.Types",
- "com.sun.tools.javac.parser.Parser",
- "java.util.EnumSet");
- }
-}
--- a/langtools/test/tools/javac/processing/environment/TestSourceVersion.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/environment/TestSourceVersion.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6402506
* @summary Test that getSourceVersion works properly
* @author Joseph D. Darcy
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile TestSourceVersion.java
* @compile -processor TestSourceVersion -proc:only -source 1.2 -AExpectedVersion=RELEASE_2 HelloWorld.java
* @compile -processor TestSourceVersion -proc:only -source 1.3 -AExpectedVersion=RELEASE_3 HelloWorld.java
@@ -52,9 +54,8 @@
* This processor checks that ProcessingEnvironment.getSourceVersion()
* is consistent with the setting of the -source option.
*/
-@SupportedAnnotationTypes("*")
@SupportedOptions("ExpectedVersion")
-public class TestSourceVersion extends AbstractProcessor {
+public class TestSourceVersion extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
@@ -68,9 +69,4 @@
return true;
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854
* @summary Tests that getElementsAnnotatedWith works properly.
* @author Joseph D. Darcy
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor
* @compile TestElementsAnnotatedWith.java
* @compile InheritedAnnotation.java
* @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java
@@ -57,16 +59,13 @@
* getElementsAnnotatedWith is consistent with the expected results
* stored in an AnnotatedElementInfo annotation.
*/
-@SupportedAnnotationTypes("*")
@AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", expectedSize=0, names={})
-public class TestElementsAnnotatedWith extends AbstractProcessor {
+public class TestElementsAnnotatedWith extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
- Elements elementUtils = processingEnv.getElementUtils();
-
TypeElement annotatedElementInfoElement =
- elementUtils.getTypeElement("AnnotatedElementInfo");
+ elements.getTypeElement("AnnotatedElementInfo");
Set<? extends Element> resultsMeta = Collections.emptySet();
Set<? extends Element> resultsBase = Collections.emptySet();
@@ -93,9 +92,7 @@
resultsMeta =
roundEnvironment.
- getElementsAnnotatedWith(elementUtils.
- getTypeElement(annotatedElementInfo.
- annotationName())) ;
+ getElementsAnnotatedWith(elements.getTypeElement(annotatedElementInfo.annotationName()));
System.err.println("Results: " + resultsMeta);
@@ -167,9 +164,4 @@
throw new RuntimeException("Illegal argument exception not thrown");
} catch(IllegalArgumentException iae) {}
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,9 @@
* @bug 6403459
* @summary Test that generating programs with syntax errors is a fatal condition
* @author Joseph D. Darcy
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
+ * @compile TestReturnCode.java
* @compile TestFatalityOfParseErrors.java
* @compile/fail -XprintRounds -processor TestFatalityOfParseErrors -proc:only TestFatalityOfParseErrors.java
*/
@@ -45,11 +48,8 @@
* Write out an incomplete source file and observe that the next round
* is marked as an error.
*/
-@SupportedAnnotationTypes("*")
-public class TestFatalityOfParseErrors extends AbstractProcessor {
+public class TestFatalityOfParseErrors extends JavacTestingAbstractProcessor {
int round = 0;
- Messager messager;
- Filer filer;
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
@@ -87,14 +87,4 @@
}
return true;
}
-
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- public void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- messager = processingEnv.getMessager();
- filer = processingEnv.getFiler();
- }
}
--- a/langtools/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6406212
* @summary Test that annotation processor options with illegal syntax are rejected
* @author Joseph D. Darcy
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile TestOptionSyntaxErrors.java
* @compile/fail -A TestOptionSyntaxErrors.java
* @compile/fail -A8adOption TestOptionSyntaxErrors.java
@@ -46,14 +48,9 @@
/**
* No-op processor; should not be run.
*/
-@SupportedAnnotationTypes("*")
-public class TestOptionSyntaxErrors extends AbstractProcessor {
+public class TestOptionSyntaxErrors extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
return true;
}
-
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/errors/TestReturnCode.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/errors/TestReturnCode.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6403468
* @summary Test that an erroneous return code results from raising an error.
* @author Joseph D. Darcy
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile TestReturnCode.java
*
* @compile -processor TestReturnCode -proc:only Foo.java
@@ -60,20 +62,17 @@
* This processor raises errors or throws exceptions on different
* rounds to allow the return code to be test.
*/
-@SupportedAnnotationTypes("*")
@SupportedOptions({"ErrorOnFirst",
"ErrorOnLast",
"ExceptionOnFirst",
"ExceptionOnLast"})
-public class TestReturnCode extends AbstractProcessor {
+public class TestReturnCode extends JavacTestingAbstractProcessor {
private boolean errorOnFirst;
private boolean errorOnLast;
private boolean exceptionOnFirst;
private boolean exceptionOnLast;
- private Messager messager;
-
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) {
@@ -103,11 +102,5 @@
errorOnLast = keySet.contains("ErrorOnLast");
exceptionOnFirst = keySet.contains("ExceptionOnFirst");
exceptionOnLast = keySet.contains("ExceptionOnLast");
- messager = processingEnv.getMessager();
- }
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
}
}
--- a/langtools/test/tools/javac/processing/filer/TestFilerConstraints.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/filer/TestFilerConstraints.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
* @bug 6380018 6453386 6457283
* @summary Test that the constraints guaranteed by the Filer and maintained
* @author Joseph D. Darcy
+ * @library ../../lib
* @build TestFilerConstraints
* @compile -encoding iso-8859-1 -processor TestFilerConstraints -proc:only TestFilerConstraints.java
*/
@@ -69,11 +70,8 @@
*
* </ul>
*/
-@SupportedAnnotationTypes("*")
-public class TestFilerConstraints extends AbstractProcessor {
+public class TestFilerConstraints extends JavacTestingAbstractProcessor {
private int round = 0;
- private Messager messager;
- private Filer filer;
private PrintWriter pw_src1 = null;
private PrintWriter pw_src2 = null;
@@ -167,17 +165,6 @@
return true;
}
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- public void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- messager = processingEnv.getMessager();
- filer = processingEnv.getFiler();
-
- }
-
/**
* Test that the single expected expected type, name, is the root
* element.
--- a/langtools/test/tools/javac/processing/filer/TestGetResource.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/filer/TestGetResource.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6380018 6449798
* @summary Test Filer.getResource
* @author Joseph D. Darcy
- * @build TestGetResource
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor TestGetResource
* @compile -processor TestGetResource -proc:only -Aphase=write TestGetResource.java
* @compile -processor TestGetResource -proc:only -Aphase=read TestGetResource.java
*/
@@ -49,13 +50,8 @@
* first run of the annotation processor, write out a resource file
* and on the second run read it in.
*/
-@SupportedAnnotationTypes("*")
@SupportedOptions("phase")
-public class TestGetResource extends AbstractProcessor {
- private Messager messager;
- private Filer filer;
- private Map<String,String> options;
-
+public class TestGetResource extends JavacTestingAbstractProcessor {
private static String CONTENTS = "Hello World.";
private static String PKG = "";
private static String RESOURCE_NAME = "Resource1";
@@ -92,15 +88,4 @@
}
return false;
}
-
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- public void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- messager = processingEnv.getMessager();
- filer = processingEnv.getFiler();
- options = processingEnv.getOptions();
- }
}
--- a/langtools/test/tools/javac/processing/filer/TestGetResource2.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/filer/TestGetResource2.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/* @test
* @bug 6929404
* @summary Filer.getResource(SOURCE_PATH, ...) does not work when -sourcepath contains >1 entry
+ * @library ../../lib
*/
import java.io.*;
@@ -114,8 +115,7 @@
throw new Exception(errors + " errors occurred");
}
- @SupportedAnnotationTypes("*")
- static class AnnoProc extends AbstractProcessor {
+ static class AnnoProc extends JavacTestingAbstractProcessor {
public @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
@@ -123,27 +123,23 @@
}
try {
- FileObject resource = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt");
+ FileObject resource = filer.getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt");
try {
resource.openInputStream().close();
- processingEnv.getMessager().printMessage(Kind.NOTE, "found: " + resource.toUri());
+ messager.printMessage(Kind.NOTE, "found: " + resource.toUri());
return true;
} catch (IOException x) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "could not read: " + resource.toUri());
+ messager.printMessage(Kind.ERROR, "could not read: " + resource.toUri());
x.printStackTrace();
}
} catch (IOException x) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "did not find resource");
+ messager.printMessage(Kind.ERROR, "did not find resource");
x.printStackTrace();
}
return false;
}
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
private File write(File dir, String path, String contents) throws IOException {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/filer/TestInvalidRelativeNames.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6502392
+ * @summary Invalid relative names for Filer.createResource and Filer.getResource
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
+ * @compile TestInvalidRelativeNames.java
+ * @compile/process -processor TestInvalidRelativeNames java.lang.Object
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.tools.Diagnostic;
+import javax.tools.StandardLocation;
+
+public class TestInvalidRelativeNames extends JavacTestingAbstractProcessor {
+ enum Kind { CREATE_WRITER, GET_READER, CREATE_OUTPUT_STREAM, GET_INPUT_STREAM };
+
+ static final String[] invalidRelativeNames = {
+ "/boo", "goo/../hoo", "./ioo", ""
+ };
+
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (roundEnv.processingOver()) {
+ for (String relative: invalidRelativeNames) {
+ for (Kind kind: Kind.values()) {
+ test(relative, kind);
+ }
+ }
+ }
+ return true;
+ }
+
+ void test(String relative, Kind kind) {
+ System.out.println("test relative path: " + relative + ", kind: " + kind);
+ try {
+ switch (kind) {
+ case CREATE_WRITER:
+ Writer writer = filer.createResource(
+ StandardLocation.SOURCE_OUTPUT, "", relative).openWriter();
+ writer.close();
+ break;
+
+ case GET_READER:
+ Reader reader = filer.getResource(
+ StandardLocation.SOURCE_OUTPUT, "", relative).openReader(true);
+ reader.close();
+ break;
+
+ case CREATE_OUTPUT_STREAM:
+ OutputStream out = filer.createResource(
+ StandardLocation.SOURCE_OUTPUT, "", relative).openOutputStream();
+ out.close();
+ break;
+
+ case GET_INPUT_STREAM:
+ InputStream in = filer.createResource(
+ StandardLocation.SOURCE_OUTPUT, "", relative).openInputStream();
+ in.close();
+ break;
+ }
+ } catch (IllegalArgumentException expected) {
+ System.out.println("expected exception thrown: " + expected);
+ return;
+ } catch (Exception e) {
+ messager.printMessage(Diagnostic.Kind.ERROR,
+ "relative path: " + relative + ", kind: " + kind + ", unexpected exception: " + e);
+ return;
+ }
+ messager.printMessage(Diagnostic.Kind.ERROR,
+ "relative path: " + relative + ", kind: " + kind + ", no exception thrown");
+ }
+}
+
--- a/langtools/test/tools/javac/processing/filer/TestLastRound.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/filer/TestLastRound.java Mon Oct 04 14:40:38 2010 -0700
@@ -24,6 +24,8 @@
/*
* @test 6966604
* @summary JavacFiler not correctly notified of lastRound
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile TestLastRound.java
* @compile/fail/ref=TestLastRound.out -XDrawDiagnostics -Werror -proc:only -processor TestLastRound TestLastRound.java
*/
@@ -35,12 +37,10 @@
import javax.lang.model.element.*;
import javax.tools.*;
-@SupportedAnnotationTypes("*")
-public class TestLastRound extends AbstractProcessor {
+public class TestLastRound extends JavacTestingAbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
- Filer filer = processingEnv.getFiler();
if (roundEnv.processingOver()) {
try {
JavaFileObject fo = filer.createSourceFile("LastRound.java");
@@ -52,9 +52,4 @@
}
return true;
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/filer/TestPackageInfo.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/filer/TestPackageInfo.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6380018 6392177
* @summary Test the ability to create and process package-info.java files
* @author Joseph D. Darcy
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile TestPackageInfo.java
* @compile -processor TestPackageInfo -proc:only foo/bar/package-info.java TestPackageInfo.java
*/
@@ -49,13 +51,7 @@
* 1) Visibility of package-info files from the command line
* 2) Visibility of generated package-info.java source files
*/
-@SupportedAnnotationTypes("*")
-public class TestPackageInfo extends AbstractProcessor {
- private Elements eltUtils;
- private Messager messager;
- private Filer filer;
- private Map<String,String> options;
-
+public class TestPackageInfo extends JavacTestingAbstractProcessor {
private int round = 0;
public boolean process(Set<? extends TypeElement> annotations,
@@ -64,11 +60,7 @@
// Verify annotations are as expected
Set<TypeElement> expectedAnnotations = new HashSet<TypeElement>();
- if (round == 1)
- expectedAnnotations.add(eltUtils.
- getTypeElement("javax.annotation.processing.SupportedAnnotationTypes"));
- expectedAnnotations.add(eltUtils.
- getTypeElement("java.lang.SuppressWarnings"));
+ expectedAnnotations.add(eltUtils.getTypeElement("java.lang.SuppressWarnings"));
if (!roundEnv.processingOver()) {
System.out.println("\nRound " + round);
@@ -127,16 +119,4 @@
}
return false;
}
-
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- public void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- eltUtils = processingEnv.getElementUtils();
- messager = processingEnv.getMessager();
- filer = processingEnv.getFiler();
- options = processingEnv.getOptions();
- }
}
--- a/langtools/test/tools/javac/processing/messager/6362067/T6362067.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/messager/6362067/T6362067.java Mon Oct 04 14:40:38 2010 -0700
@@ -2,39 +2,34 @@
* @test /nodynamiccopyright/
* @bug 6362067
* @summary Messager methods do not print out source position information
- * @build T6362067
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor T6362067
* @compile -processor T6362067 -proc:only T6362067.java
* @compile/ref=T6362067.out -XDrawDiagnostics -processor T6362067 -proc:only T6362067.java
*/
-
import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import static javax.tools.Diagnostic.Kind.*;
-@Deprecated // convenient test annotation
-@SupportedAnnotationTypes("*")
-public class T6362067 extends AbstractProcessor {
+@Deprecated // convenient test annotations
+@SuppressWarnings({""})
+public class T6362067 extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annos,
RoundEnvironment roundEnv) {
- Messager msgr = processingEnv.getMessager();
+
for (Element e: roundEnv.getRootElements()) {
- msgr.printMessage(NOTE, "note:elem", e);
+ messager.printMessage(NOTE, "note:elem", e);
for (AnnotationMirror a: e.getAnnotationMirrors()) {
- msgr.printMessage(NOTE, "note:anno", e, a);
+ messager.printMessage(NOTE, "note:anno", e, a);
for (AnnotationValue v: a.getElementValues().values()) {
- msgr.printMessage(NOTE, "note:value", e, a, v);
+ messager.printMessage(NOTE, "note:value", e, a, v);
}
-
}
}
+
if (roundEnv.processingOver())
- msgr.printMessage(NOTE, "note:nopos");
+ messager.printMessage(NOTE, "note:nopos");
return true;
}
-
- @Override
- public javax.lang.model.SourceVersion getSupportedSourceVersion() {
- return javax.lang.model.SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/messager/MessagerBasics.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/messager/MessagerBasics.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6341173 6341072
* @summary Test presence of Messager methods
* @author Joseph D. Darcy
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile MessagerBasics.java
* @compile -processor MessagerBasics -proc:only MessagerBasics.java
* @compile/fail -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java
@@ -39,18 +41,16 @@
import javax.lang.model.util.*;
import static javax.tools.Diagnostic.Kind.*;
-@SupportedAnnotationTypes("*")
@SupportedOptions("finalError")
-public class MessagerBasics extends AbstractProcessor {
+public class MessagerBasics extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
- Messager m = processingEnv.getMessager();
if (roundEnv.processingOver()) {
if (processingEnv.getOptions().containsKey("finalError"))
- m.printMessage(ERROR, "Does not compute");
+ messager.printMessage(ERROR, "Does not compute");
else {
- m.printMessage(NOTE, "Post no bills");
- m.printMessage(WARNING, "Beware the ides of March!");
+ messager.printMessage(NOTE, "Post no bills");
+ messager.printMessage(WARNING, "Beware the ides of March!");
}
}
return true;
--- a/langtools/test/tools/javac/processing/model/6194785/T6194785.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/6194785/T6194785.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6194785
* @summary ParameterDeclaration.getSimpleName does not return actual name from class files
* @author Peter von der Ah\u00e9
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor
* @compile -g T6194785.java T6194785a.java
* @compile -processor T6194785 foo.T6194785a T6194785.java
*/
@@ -36,13 +38,10 @@
import javax.lang.model.util.*;
import static javax.tools.Diagnostic.Kind.*;
-@SupportedAnnotationTypes("*")
-public class T6194785 extends AbstractProcessor {
+public class T6194785 extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment)
{
- final Messager log = processingEnv.getMessager();
- final Elements elements = processingEnv.getElementUtils();
class Scan extends ElementScanner7<Void,Void> {
@Override
public Void visitExecutable(ExecutableElement e, Void ignored) {
--- a/langtools/test/tools/javac/processing/model/6341534/T6341534.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/6341534/T6341534.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary PackageElement.getEnclosedElements results in NullPointerException from parse(JavaCompiler.java:429)
* @author Steve Sides
* @author Peter von der Ahe
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor
* @compile T6341534.java
* @compile -proc:only -processor T6341534 dir/package-info.java
* @compile -processor T6341534 dir/package-info.java
@@ -40,20 +42,11 @@
import java.util.Set;
import static javax.tools.Diagnostic.Kind.*;
-@SupportedAnnotationTypes("*")
-public class T6341534 extends AbstractProcessor {
- Elements elements;
- Messager messager;
- public void init(ProcessingEnvironment penv) {
- super.init(penv);
- elements = penv.getElementUtils();
- messager = processingEnv.getMessager();
- }
-
+public class T6341534 extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
messager.printMessage(NOTE,
- String.valueOf(elements.getPackageElement("no.such.package")));
- PackageElement dir = elements.getPackageElement("dir");
+ String.valueOf(eltUtils.getPackageElement("no.such.package")));
+ PackageElement dir = eltUtils.getPackageElement("dir");
messager.printMessage(NOTE, dir.getQualifiedName().toString());
for (Element e : dir.getEnclosedElements())
messager.printMessage(NOTE, e.toString());
--- a/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java Mon Oct 04 14:40:38 2010 -0700
@@ -26,7 +26,8 @@
* @bug 6449781
* @summary Test that reported names of anonymous classes are non-null.
* @author Joseph D. Darcy
- * @build TestAnonSourceNames
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TestAnonSourceNames
* @compile -processor TestAnonSourceNames TestAnonClassNames.java
* @run main TestAnonClassNames
*/
@@ -141,8 +142,7 @@
/**
* Probe at the various kinds of names of a type element.
*/
-@SupportedAnnotationTypes("*")
-class ClassNameProber extends AbstractProcessor {
+class ClassNameProber extends JavacTestingAbstractProcessor {
public ClassNameProber(){super();}
private boolean classesFound=false;
@@ -174,8 +174,4 @@
}
return true;
}
-
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/model/element/TestAnonSourceNames.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/element/TestAnonSourceNames.java Mon Oct 04 14:40:38 2010 -0700
@@ -36,8 +36,7 @@
* Using the tree API, retrieve element representations of anonymous
* classes and verify their names are as specified.
*/
-@SupportedAnnotationTypes("*")
-public class TestAnonSourceNames extends AbstractProcessor {
+public class TestAnonSourceNames extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
@@ -84,9 +83,4 @@
return super.visitClass(node, cu);
}
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/model/element/TestElement.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/element/TestElement.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6453386
* @summary Test basic properties of javax.lang.element.Element
* @author Joseph D. Darcy
- * @build TestElement
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TestElement
* @compile -processor TestElement -proc:only TestElement.java
*/
@@ -43,8 +44,7 @@
/**
* Test basic workings of javax.lang.element.Element
*/
-@SupportedAnnotationTypes("*")
-public class TestElement extends AbstractProcessor {
+public class TestElement extends JavacTestingAbstractProcessor {
/**
* For now, just check that constructors have a simple name of
* "<init>".
@@ -66,9 +66,4 @@
}
return true;
}
-
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
}
--- a/langtools/test/tools/javac/processing/model/element/TestNames.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/element/TestNames.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6380016
* @summary Test that the constraints guaranteed by the Filer and maintained
* @author Joseph D. Darcy
- * @build TestNames
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TestNames
* @compile -processor TestNames -proc:only TestNames.java
*/
@@ -45,11 +46,8 @@
/**
* Basic tests of semantics of javax.lang.model.element.Name
*/
-@SupportedAnnotationTypes("*")
-public class TestNames extends AbstractProcessor {
+public class TestNames extends JavacTestingAbstractProcessor {
private int round = 0;
- private Filer filer;
- private Elements eltUtils;
String stringStringName = "java.lang.String";
Name stringName = null;
@@ -106,16 +104,6 @@
return true;
}
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- public void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- filer = processingEnv.getFiler();
- eltUtils = processingEnv.getElementUtils();
- }
-
private static class Pseudonym implements Name {
private String name;
--- a/langtools/test/tools/javac/processing/model/element/TestPackageElement.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/element/TestPackageElement.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6449798 6399404
* @summary Test basic workings of PackageElement
* @author Joseph D. Darcy
- * @build TestPackageElement
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TestPackageElement
* @compile -processor TestPackageElement -proc:only TestPackageElement.java
*/
@@ -43,11 +44,7 @@
/**
* Test basic workings of PackageElement.
*/
-@SupportedAnnotationTypes("*")
-public class TestPackageElement extends AbstractProcessor {
- private Filer filer;
- private Elements eltUtils;
-
+public class TestPackageElement extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) {
@@ -71,15 +68,4 @@
}
return true;
}
-
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- public void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- filer = processingEnv.getFiler();
- eltUtils = processingEnv.getElementUtils();
- }
-
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/element/TestResourceElement.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6967842
+ * @summary Element not returned from tree API for ARM resource variables.
+ * @author A. Sundararajan
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TestResourceElement
+ * @compile -processor TestResourceElement -proc:only TestResourceElement.java
+ */
+
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import java.util.*;
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+
+public class TestResourceElement extends JavacTestingAbstractProcessor implements AutoCloseable {
+ public boolean process(Set<? extends TypeElement> annotations,
+ RoundEnvironment roundEnv) {
+ if (!roundEnv.processingOver()) {
+ Trees trees = Trees.instance(processingEnv);
+
+ for(Element rootElement : roundEnv.getRootElements()) {
+ TreePath treePath = trees.getPath(rootElement);
+
+ VariableScanner varScanner = new VariableScanner(trees);
+ varScanner.scan(trees.getTree(rootElement),
+ treePath.getCompilationUnit());
+ if (varScanner.getTrvElement() == null) {
+ throw new AssertionError("Element is null for 'trv'");
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void close() {}
+
+ private void test1() {
+ // The resource variable "trv"'s Element is checked.
+ // Do not change the name of the variable.
+ try(TestResourceElement trv = this) {}
+ }
+
+ class VariableScanner extends TreeScanner<Void, CompilationUnitTree> {
+ private Trees trees;
+ private Element trvElement;
+
+ public VariableScanner(Trees trees) {
+ super();
+ this.trees = trees;
+ }
+ @Override
+ public Void visitVariable(VariableTree node, CompilationUnitTree cu) {
+ // if this is "trv", get it's element.
+ if (node.getName().contentEquals("trv")) {
+ trvElement = trees.getElement(trees.getPath(cu, node));
+ }
+ return super.visitVariable(node, cu);
+ }
+
+ Element getTrvElement() {
+ return trvElement;
+ }
+ }
+}
--- a/langtools/test/tools/javac/processing/model/element/TestResourceVariable.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/element/TestResourceVariable.java Mon Oct 04 14:40:38 2010 -0700
@@ -23,11 +23,12 @@
/*
* @test
- * @bug 6911256 6964740
+ * @bug 6911256 6964740 6967842
* @summary Test that the resource variable kind is appropriately set
* @author Joseph D. Darcy
- * @build TestResourceVariable
- * @compile/fail -processor TestResourceVariable -proc:only TestResourceVariable.java
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TestResourceVariable
+ * @compile -processor TestResourceVariable -proc:only TestResourceVariable.java
*/
// Bug should be filed for this misbehavior
@@ -48,8 +49,7 @@
* resource of an ARM block and verify their kind tags are set
* appropriately.
*/
-@SupportedAnnotationTypes("*")
-public class TestResourceVariable extends AbstractProcessor implements AutoCloseable {
+public class TestResourceVariable extends JavacTestingAbstractProcessor implements AutoCloseable {
int resourceVariableCount = 0;
public boolean process(Set<? extends TypeElement> annotations,
@@ -105,9 +105,4 @@
return super.visitVariable(node, cu);
}
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/model/element/TypeParamBounds.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/element/TypeParamBounds.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6423972
* @summary Tests TypeParameter.getBounds.
* @author Scott Seligman
- * @build TypeParamBounds
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TypeParamBounds
* @compile -processor TypeParamBounds -proc:only TypeParamBounds.java
*/
@@ -40,18 +41,7 @@
import javax.lang.model.type.*;
import javax.lang.model.util.*;
-@SupportedAnnotationTypes("*")
-public class TypeParamBounds extends AbstractProcessor {
-
- Elements elements;
- Types types;
-
- public void init(ProcessingEnvironment penv) {
- super.init(penv);
- elements = penv.getElementUtils();
- types = penv.getTypeUtils();
- }
-
+public class TypeParamBounds extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
if (!round.processingOver())
@@ -59,11 +49,6 @@
return true;
}
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
TypeElement gen = elements.getTypeElement("TypeParamBounds.Gen");
@@ -91,7 +76,6 @@
// Fodder for the processor
-
static class Gen<T, U extends Object, V extends Number, W extends U,
X extends Runnable, Y extends CharSequence & Runnable,
Z extends Object & Runnable> {
--- a/langtools/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6362178
* @summary MirroredType[s]Exception shouldn't be created too eagerly
* @author Scott Seligman
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor
* @compile -g OverEager.java
* @compile -processor OverEager -proc:only OverEager.java
*/
@@ -40,17 +42,7 @@
@SupportedAnnotationTypes("IAm")
@IAm(OverEager.class)
-public class OverEager extends AbstractProcessor {
-
- Elements elements;
- Types types;
-
- public void init(ProcessingEnvironment penv) {
- super.init(penv);
- elements = penv.getElementUtils();
- types = penv.getTypeUtils();
- }
-
+public class OverEager extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
if (!round.processingOver())
@@ -58,11 +50,6 @@
return true;
}
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
for (TypeElement t : typesIn(round.getRootElements())) {
--- a/langtools/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java Mon Oct 04 14:40:38 2010 -0700
@@ -25,6 +25,8 @@
* @test
* @bug 6519115
* @summary Verify MirroredTypeException vs MirroredTypesException is thrown
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor
* @compile Plurality.java
* @compile -processor Plurality -proc:only Plurality.java
* @author Joseph D. Darcy
@@ -38,25 +40,13 @@
import javax.lang.model.type.*;
import javax.lang.model.util.*;
-@SupportedAnnotationTypes("*")
@P0
@P1
@P2
@S1
-public class Plurality extends AbstractProcessor {
+public class Plurality extends JavacTestingAbstractProcessor {
private boolean executed = false;
- Elements elements;
- Types types;
-
- @Override
- public void init(ProcessingEnvironment penv) {
- super.init(penv);
- elements = penv.getElementUtils();
- types = penv.getTypeUtils();
- }
-
-
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) {
@@ -164,11 +154,6 @@
toStringName);
}
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
@Retention(RetentionPolicy.RUNTIME)
--- a/langtools/test/tools/javac/processing/model/type/NoTypes.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/type/NoTypes.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6418666 6423973 6453386
* @summary Test the NoTypes: VOID, PACKAGE, NONE
* @author Scott Seligman
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor
* @compile -g NoTypes.java
* @compile -processor NoTypes -proc:only NoTypes.java
*/
@@ -39,18 +41,7 @@
import static javax.lang.model.type.TypeKind.*;
-@SupportedAnnotationTypes("*")
-public class NoTypes extends AbstractProcessor {
-
- Elements elements;
- Types types;
-
- public void init(ProcessingEnvironment penv) {
- super.init(penv);
- elements = penv.getElementUtils();
- types = penv.getTypeUtils();
- }
-
+public class NoTypes extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
if (!round.processingOver())
@@ -58,11 +49,6 @@
return true;
}
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
--- a/langtools/test/tools/javac/processing/model/util/BinaryName.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/util/BinaryName.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6346251
* @summary Test Elements.getBinaryName
* @author Scott Seligman
- * @build BinaryName
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor BinaryName
* @compile -processor BinaryName -proc:only BinaryName.java
*/
@@ -38,17 +39,8 @@
import static javax.lang.model.util.ElementFilter.typesIn;
-@SupportedAnnotationTypes("*")
@HelloIm("BinaryName")
-public class BinaryName extends AbstractProcessor {
-
- Elements elements;
-
- public void init(ProcessingEnvironment penv) {
- super.init(penv);
- elements = penv.getElementUtils();
- }
-
+public class BinaryName extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> tes,
RoundEnvironment round) {
if (round.processingOver()) return true;
--- a/langtools/test/tools/javac/processing/model/util/GetTypeElemBadArg.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/util/GetTypeElemBadArg.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6346506 6408241
* @summary getTypeElement should tolerate a type that can't be found
* @author Scott Seligman
- * @build GetTypeElemBadArg
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor GetTypeElemBadArg
* @compile -processor GetTypeElemBadArg -proc:only GetTypeElemBadArg.java
*/
@@ -37,16 +38,7 @@
import javax.lang.model.type.*;
import javax.lang.model.util.*;
-@SupportedAnnotationTypes("*")
-public class GetTypeElemBadArg extends AbstractProcessor {
-
- Elements elements;
-
- public void init(ProcessingEnvironment penv) {
- super.init(penv);
- elements = penv.getElementUtils();
- }
-
+public class GetTypeElemBadArg extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> tes,
RoundEnvironment round) {
if (round.processingOver()) return true;
@@ -63,12 +55,6 @@
return true;
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
private static void tellAbout(TypeElement t) {
System.out.println(t);
System.out.println(t.getClass());
--- a/langtools/test/tools/javac/processing/model/util/NoSupers.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/util/NoSupers.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6346453
* @summary directSupertypes should return empty list if arg has no supertypes
* @author Scott Seligman
- * @build NoSupers
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor NoSupers
* @compile -processor NoSupers -proc:only NoSupers.java
*/
@@ -36,16 +37,7 @@
import javax.lang.model.type.*;
import javax.lang.model.util.*;
-@SupportedAnnotationTypes("*")
-public class NoSupers extends AbstractProcessor {
-
- Types types;
-
- public void init(ProcessingEnvironment penv) {
- super.init(penv);
- types = penv.getTypeUtils();
- }
-
+public class NoSupers extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> tes,
RoundEnvironment round) {
if (round.processingOver()) return true;
--- a/langtools/test/tools/javac/processing/model/util/OverridesSpecEx.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/util/OverridesSpecEx.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6453386
* @summary Verify that example code in Elements.overrides works as spec'ed.
* @author Scott Seligman
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor
* @compile -g OverridesSpecEx.java
* @compile -processor OverridesSpecEx -proc:only OverridesSpecEx.java
*/
@@ -39,19 +41,7 @@
import static javax.lang.model.util.ElementFilter.*;
-
-@SupportedAnnotationTypes("*")
-public class OverridesSpecEx extends AbstractProcessor {
-
- Elements elements;
- Types types;
-
- public void init(ProcessingEnvironment penv) {
- super.init(penv);
- elements = penv.getElementUtils();
- types = penv.getTypeUtils();
- }
-
+public class OverridesSpecEx extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
if (!round.processingOver())
@@ -59,11 +49,6 @@
return true;
}
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
TypeElement string = elements.getTypeElement("java.lang.String");
@@ -113,9 +98,7 @@
throw new AssertionError("Bogus result");
}
-
// Fodder for the processor
-
class A {
public void m() {}
}
--- a/langtools/test/tools/javac/processing/model/util/TypesBadArg.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/util/TypesBadArg.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6345812
* @summary Validate argument kinds in Types utilities
* @author Scott Seligman
- * @build TypesBadArg
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TypesBadArg
* @compile -processor TypesBadArg -proc:only TypesBadArg.java
*/
@@ -36,15 +37,9 @@
import javax.lang.model.type.*;
import javax.lang.model.util.*;
-@SupportedAnnotationTypes("*")
-public class TypesBadArg extends AbstractProcessor {
-
+public class TypesBadArg extends JavacTestingAbstractProcessor {
boolean success = true;
- public void init(ProcessingEnvironment penv) {
- super.init(penv);
- }
-
public boolean process(Set<? extends TypeElement> tes,
RoundEnvironment round) {
if (round.processingOver()) return true;
--- a/langtools/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6392818
* @summary Tests Elements.isDeprecated(Element)
* @author Joseph D. Darcy
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor
* @compile TestDeprecation.java
* @compile -processor TestDeprecation -proc:only Dep1.java
* @compile Dep1.java
@@ -47,8 +49,7 @@
* getElementsAnnotatedWith is consistent with the expected results
* stored in an AnnotatedElementInfo annotation.
*/
-@SupportedAnnotationTypes("*")
-public class TestDeprecation extends AbstractProcessor {
+public class TestDeprecation extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
@@ -98,9 +99,4 @@
return failure;
}
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- a/langtools/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6346973
* @summary directSupertypes(t) should not return t
* @author Scott Seligman
- * @build DirectSupersOfErr
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor DirectSupersOfErr
* @compile -processor DirectSupersOfErr -proc:only C1.java
*/
@@ -37,16 +38,7 @@
import javax.lang.model.util.*;
import static javax.lang.model.util.ElementFilter.*;
-@SupportedAnnotationTypes("*")
-public class DirectSupersOfErr extends AbstractProcessor {
-
- Types types;
-
- public void init(ProcessingEnvironment penv) {
- super.init(penv);
- types = penv.getTypeUtils();
- }
-
+public class DirectSupersOfErr extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> tes,
RoundEnvironment round) {
if (round.processingOver()) return true;
--- a/langtools/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6471577 6517779
* @summary Test Elements.getConstantExpression
* @author Joseph D. Darcy
- * @build TestGetConstantExpression
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor TestGetConstantExpression
* @compile -processor TestGetConstantExpression Foo.java
*/
@@ -44,10 +45,7 @@
/**
* Test basic workings of Elements.getConstantExpression.
*/
-@SupportedAnnotationTypes("*")
-public class TestGetConstantExpression extends AbstractProcessor {
- private Elements eltUtils;
- private Filer filer;
+public class TestGetConstantExpression extends JavacTestingAbstractProcessor {
private int round = 1;
/**
@@ -130,14 +128,4 @@
return 0;
}
}
-
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- public void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- eltUtils = processingEnv.getElementUtils();
- filer = processingEnv.getFiler();
- }
}
--- a/langtools/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 6453386
* @summary Test Elements.getPackageOf
* @author Joseph D. Darcy
- * @build TestGetPackageOf
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor TestGetPackageOf
* @compile -processor TestGetPackageOf -proc:only TestGetPackageOf.java
*/
@@ -43,10 +44,7 @@
/**
* Test basic workings of Elements.getPackageOf
*/
-@SupportedAnnotationTypes("*")
-public class TestGetPackageOf extends AbstractProcessor {
- private Elements eltUtils;
-
+public class TestGetPackageOf extends JavacTestingAbstractProcessor {
/**
* Check expected behavior on classes and packages.
*/
@@ -69,13 +67,4 @@
}
return true;
}
-
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- public void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- eltUtils = processingEnv.getElementUtils();
- }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,310 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6877202 6986246
+ * @summary Elements.getDocComment() is not getting JavaDocComments
+ */
+
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+import javax.tools.*;
+
+/*
+ * For a mixture of pre-existing and generated source files, ensure that we can
+ * get the doc comments.
+ * The test uses both a standard ElementScanner to find all the elements being
+ * processed, and a TreeScanner to find all the local and anonymous inner classes
+ * as well.
+ * And, because the relevant code paths in the compiler are different for
+ * command line and JSR 199 invocation, the test covers both ways of invoking the
+ * compiler.
+ */
+
+@SupportedOptions("scan")
+@SupportedAnnotationTypes("*")
+public class TestDocComments extends AbstractProcessor {
+ enum CompileKind { API, CMD };
+ enum ScanKind { TREE, ELEMENT };
+
+ // ----- Main test driver: invoke compiler for the various test cases ------
+
+ public static void main(String... args) throws Exception {
+ for (CompileKind ck: CompileKind.values()) {
+ for (ScanKind sk: ScanKind.values()) {
+ try {
+ test(ck, sk);
+ } catch (IOException e) {
+ error(e.toString());
+ }
+ }
+ }
+
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
+ }
+
+ static void test(CompileKind ck, ScanKind sk) throws IOException {
+ String testClasses = System.getProperty("test.classes");
+ String testSrc = System.getProperty("test.src");
+ File testDir = new File("test." + ck + "." + sk);
+ testDir.mkdirs();
+ String[] opts = {
+ "-d", testDir.getPath(),
+ "-implicit:none",
+ "-processor", TestDocComments.class.getName(),
+ "-processorpath", testClasses,
+ //"-XprintRounds",
+ "-Ascan=" + sk
+ };
+ File[] files = {
+ new File(testSrc, "a/First.java")
+ };
+
+ if (ck == CompileKind.API)
+ test_javac_api(opts, files);
+ else
+ test_javac_cmd(opts, files);
+ }
+
+ static void test_javac_api(String[] opts, File[] files) throws IOException {
+ System.err.println("test javac api: " + Arrays.asList(opts) + " " + Arrays.asList(files));
+ DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() {
+ public void report(Diagnostic diagnostic) {
+ error(diagnostic.toString());
+ }
+ };
+ JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+ StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+ Iterable<? extends JavaFileObject> units = fm.getJavaFileObjects(files);
+ JavacTask t = (JavacTask) c.getTask(null, fm, dl, Arrays.asList(opts), null, units);
+ t.parse();
+ t.analyze();
+ }
+
+ static void test_javac_cmd(String[] opts, File[] files) {
+ System.err.println("test javac cmd: " + Arrays.asList(opts) + " " + Arrays.asList(files));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ List<String> args = new ArrayList<String>(Arrays.asList(opts));
+ for (File f: files)
+ args.add(f.getPath());
+ int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw);
+ pw.close();
+ String out = sw.toString();
+ if (out.length() > 0)
+ System.err.println(out);
+ if (rc > 0)
+ error("Compilation failed: rc=" + rc);
+ }
+
+ static void error(String msg) {
+ System.err.println(msg);
+ errors++;
+ //throw new Error(msg);
+ }
+
+ static int errors;
+
+ // ----- Annotation processor: scan for elements and check doc comments ----
+
+ Map<String,String> options;
+ Filer filer;
+ Messager messager;
+ Elements elements;
+ Trees trees;
+ ScanKind skind;
+
+ int round = 0;
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
+ @Override
+ public void init(ProcessingEnvironment pEnv) {
+ super.init(pEnv);
+ options = pEnv.getOptions();
+ filer = pEnv.getFiler();
+ messager = pEnv.getMessager();
+ elements = pEnv.getElementUtils();
+ trees = Trees.instance(processingEnv);
+ skind = ScanKind.valueOf(options.get("scan"));
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ round++;
+
+ // Scan elements using an appropriate scanner, and for each element found,
+ // call check(Element e) to verify the doc comment on that element
+ for (Element e: roundEnv.getRootElements()) {
+ System.err.println("scan " + skind + " " + e.getKind() + " " + e.getSimpleName());
+ if (skind == ScanKind.TREE) {
+ new TestTreeScanner().scan(trees.getPath(e), trees);
+ } else
+ new TestElementScanner().scan(e);
+ }
+
+ // For a few rounds, generate new source files, so that we can check whether
+ // doc comments are correctly handled in subsequent processing rounds
+ final int MAX_ROUNDS = 3;
+ if (round <= MAX_ROUNDS) {
+ String pkg = "p";
+ String currClass = "Gen" + round;
+ String curr = pkg + "." + currClass;
+ String next = (round < MAX_ROUNDS) ? (pkg + ".Gen" + (round + 1)) : "z.Last";
+ StringBuilder text = new StringBuilder();
+ text.append("package ").append(pkg).append(";\n");
+ text.append("/** CLASS ").append(currClass).append(" */\n");
+ text.append("public class ").append(currClass).append(" {\n");
+ text.append(" /** CONSTRUCTOR <init> **/\n");
+ text.append(" ").append(currClass).append("() { }\n");
+ text.append(" /** FIELD x */\n");
+ text.append(" ").append(next).append(" x;\n");
+ text.append(" /** METHOD m */\n");
+ text.append(" void m() { }\n");
+ text.append("}\n");
+
+ try {
+ JavaFileObject fo = filer.createSourceFile(curr);
+ Writer out = fo.openWriter();
+ try {
+ out.write(text.toString());
+ } finally {
+ out.close();
+ }
+ } catch (IOException e) {
+ throw new Error(e);
+ }
+ }
+
+ return true;
+ }
+
+ /*
+ * Check that the doc comment on an element is as expected.
+ * This method is invoked for each element found by the scanners run by process.
+ */
+ void check(Element e) {
+ System.err.println("Checking " + e);
+
+ String dc = elements.getDocComment(e);
+ System.err.println(" found " + dc);
+
+ String expect = (e.getKind() + " " + e.getSimpleName()); // default
+
+ Name name = e.getSimpleName();
+ Element encl = e.getEnclosingElement();
+ Name enclName = encl.getSimpleName();
+ ElementKind enclKind = encl.getKind();
+ switch (e.getKind()) {
+ case PARAMETER:
+ case LOCAL_VARIABLE:
+ // doc comments not retained for these elements
+ expect = null;
+ break;
+
+ case CONSTRUCTOR:
+ if (enclName.length() == 0 || enclKind == ElementKind.ENUM) {
+ // Enum constructor is synthetic
+ expect = null;
+ }
+ break;
+
+ case METHOD:
+ if (enclKind == ElementKind.ENUM
+ && (name.contentEquals("values") || name.contentEquals("valueOf"))) {
+ // synthetic enum methods
+ expect = null;
+ }
+ break;
+
+ case CLASS:
+ if (e.getSimpleName().length() == 0) {
+ // anon inner class
+ expect = null;
+ }
+ break;
+ }
+
+ System.err.println(" expect " + expect);
+
+ if (dc == null ? expect == null : dc.trim().equals(expect))
+ return;
+
+ if (dc == null)
+ messager.printMessage(Diagnostic.Kind.ERROR, "doc comment is null", e);
+ else {
+ messager.printMessage(Diagnostic.Kind.ERROR,
+ "unexpected comment: \"" + dc + "\", expected \"" + expect + "\"", e);
+ }
+ }
+
+ // ----- Scanners to find elements -----------------------------------------
+
+ class TestElementScanner extends ElementScanner7<Void, Void> {
+ @Override
+ public Void visitExecutable(ExecutableElement e, Void _) {
+ check(e);
+ return super.visitExecutable(e, _);
+ }
+ @Override
+ public Void visitType(TypeElement e, Void _) {
+ check(e);
+ return super.visitType(e, _);
+ }
+ @Override
+ public Void visitVariable(VariableElement e, Void _) {
+ check(e);
+ return super.visitVariable(e, _);
+ }
+ }
+
+ class TestTreeScanner extends TreePathScanner<Void,Trees> {
+ @Override
+ public Void visitClass(ClassTree tree, Trees trees) {
+ check(trees.getElement(getCurrentPath()));
+ return super.visitClass(tree, trees);
+ }
+ @Override
+ public Void visitMethod(MethodTree tree, Trees trees) {
+ check(trees.getElement(getCurrentPath()));
+ return super.visitMethod(tree, trees);
+ }
+ @Override
+ public Void visitVariable(VariableTree tree, Trees trees) {
+ check(trees.getElement(getCurrentPath()));
+ return super.visitVariable(tree, trees);
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/a/First.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package a;
+
+/** CLASS First */
+public class First {
+ /** CONSTRUCTOR <init> */
+ First() { }
+
+ /** FIELD x */
+ p.Gen1 x;
+
+ /** METHOD m **/
+ void m(int i) {
+ /** CLASS Local */
+ class Local {
+ /** CONSTRUCTOR <init> */
+ Local() { }
+ }
+
+ Runnable r = new Runnable() {
+ /** METHOD run **/
+ public void run() { }
+ };
+
+ }
+
+ /** ENUM E */
+ enum E {
+ /** ENUM_CONSTANT e1 */
+ e1
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/z/Last.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package z;
+
+// This class should be read last, implicitly. Therefore it should not
+// be subject to anno processing. If it is, the lack of doc comments should
+// be detected and will flag an error.
+public class Last {
+}
--- a/langtools/test/tools/javac/processing/model/util/filter/TestIterables.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/util/filter/TestIterables.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6406164
* @summary Test that ElementFilter iterable methods behave properly.
* @author Joseph D. Darcy
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor
* @compile TestIterables.java
* @compile -processor TestIterables -proc:only Foo1.java
* @compile Foo1.java
@@ -51,9 +53,8 @@
* results.
*/
@SupportedAnnotationTypes("ExpectedElementCounts")
-@ExpectedElementCounts(methods=3)
-public class TestIterables extends AbstractProcessor {
-
+@ExpectedElementCounts(methods=2)
+public class TestIterables extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) {
@@ -118,10 +119,4 @@
return count1;
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/options/Xprint.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6266828
+ * @summary JSR 269: Java Language Model API
+ * @author Peter von der Ah\u00e9
+ */
+import javax.tools.JavaCompiler;
+import javax.tools.ToolProvider;
+
+public class Xprint {
+ public static void main(String[] args) {
+ JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
+ javac.run(System.in, null, null,
+ "-Xprint",
+ "com.sun.tools.javac.code.Types",
+ "com.sun.tools.javac.parser.Parser",
+ "java.util.EnumSet");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/options/XprintDocComments.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6861094
+ * @summary javac -Xprint <file> does not print comments
+ * @compile/ref=XprintDocComments.out -Xprint XprintDocComments.java
+ */
+
+/**
+ * CLASS XprintDocComments
+ */
+class XPrintDocComments {
+ /**
+ * FIELD i;
+ */
+ int i;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/options/XprintDocComments.out Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,12 @@
+
+/**
+ * CLASS XprintDocComments
+ */
+class XPrintDocComments {
+
+ XPrintDocComments();
+ /**
+ * FIELD i;
+ */
+ int i;
+}
--- a/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java Mon Oct 04 14:40:38 2010 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,8 @@
/**
* This processor returns the supported source level as indicated by
- * the "SourceLevel" option.
+ * the "SourceLevel" option; therefore, don't use
+ * JavacTestingAbstractProcessor which returns the latest source level.
*/
@SupportedAnnotationTypes("*")
@SupportedOptions("SourceVersion")
--- a/langtools/test/tools/javac/processing/werror/WError1.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/werror/WError1.java Mon Oct 04 14:40:38 2010 -0700
@@ -24,6 +24,8 @@
/*
* @test 6403456
* @summary -Werror should work with annotation processing
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile WError1.java
* @compile -proc:only -processor WError1 WError1.java
* @compile/fail/ref=WError1.out -XDrawDiagnostics -Werror -proc:only -processor WError1 WError1.java
@@ -36,22 +38,15 @@
import javax.lang.model.element.*;
import javax.tools.*;
-@SupportedAnnotationTypes("*")
-public class WError1 extends AbstractProcessor {
+public class WError1 extends JavacTestingAbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
- Messager messager = processingEnv.getMessager();
if (++round == 1) {
messager.printMessage(Diagnostic.Kind.WARNING, "round 1");
}
return true;
}
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
int round = 0;
}
--- a/langtools/test/tools/javac/processing/werror/WErrorGen.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/werror/WErrorGen.java Mon Oct 04 14:40:38 2010 -0700
@@ -24,6 +24,8 @@
/*
* @test 6403456
* @summary -Werror should work with annotation processing
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile WErrorGen.java
* @compile -proc:only -processor WErrorGen WErrorGen.java
* @compile/fail/ref=WErrorGen.out -XDrawDiagnostics -Werror -Xlint:rawtypes -processor WErrorGen WErrorGen.java
@@ -36,12 +38,10 @@
import javax.lang.model.element.*;
import javax.tools.*;
-@SupportedAnnotationTypes("*")
-public class WErrorGen extends AbstractProcessor {
+public class WErrorGen extends JavacTestingAbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
- Filer filer = processingEnv.getFiler();
if (++round == 1) {
try {
JavaFileObject fo = filer.createSourceFile("Gen");
@@ -54,10 +54,5 @@
return true;
}
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
int round = 0;
}
--- a/langtools/test/tools/javac/processing/werror/WErrorLast.java Wed Jul 05 17:23:40 2017 +0200
+++ b/langtools/test/tools/javac/processing/werror/WErrorLast.java Mon Oct 04 14:40:38 2010 -0700
@@ -24,6 +24,8 @@
/*
* @test 6403456
* @summary -Werror should work with annotation processing
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
* @compile WErrorLast.java
* @compile -proc:only -processor WErrorLast WErrorLast.java
* @compile/fail/ref=WErrorLast.out -XDrawDiagnostics -Werror -proc:only -processor WErrorLast WErrorLast.java
@@ -36,20 +38,13 @@
import javax.lang.model.element.*;
import javax.tools.*;
-@SupportedAnnotationTypes("*")
-public class WErrorLast extends AbstractProcessor {
+public class WErrorLast extends JavacTestingAbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
- Messager messager = processingEnv.getMessager();
if (roundEnv.processingOver()) {
messager.printMessage(Diagnostic.Kind.WARNING, "last round");
}
return true;
}
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/tree/TreePosRoundsTest.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6985205 6986246
+ * @summary access to tree positions and doc comments may be lost across annotation processing rounds
+ * @build TreePosRoundsTest
+ * @compile -proc:only -processor TreePosRoundsTest TreePosRoundsTest.java
+ * @run main TreePosRoundsTest
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.tools.*;
+
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+import javax.tools.JavaCompiler.CompilationTask;
+
+// This test is an annotation processor that performs multiple rounds of
+// processing, and on each round, it checks that source positions are
+// available and correct.
+//
+// The test can be run directly as a processor from the javac command line
+// or via JSR 199 by invoking the main program.
+
+@SupportedAnnotationTypes("*")
+public class TreePosRoundsTest extends AbstractProcessor {
+ public static void main(String... args) throws Exception {
+ String testSrc = System.getProperty("test.src");
+ String testClasses = System.getProperty("test.classes");
+ JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+ StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+ String thisName = TreePosRoundsTest.class.getName();
+ File thisFile = new File(testSrc, thisName + ".java");
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
+ List<String> options = Arrays.asList(
+ "-proc:only",
+ "-processor", thisName,
+ "-processorpath", testClasses);
+ CompilationTask t = c.getTask(null, fm, null, options, null, files);
+ boolean ok = t.call();
+ if (!ok)
+ throw new Exception("processing failed");
+ }
+
+ Filer filer;
+ Messager messager;
+ Trees trees;
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
+ @Override
+ public void init(ProcessingEnvironment pEnv) {
+ super.init(pEnv);
+ filer = pEnv.getFiler();
+ messager = pEnv.getMessager();
+ trees = Trees.instance(pEnv);
+ }
+
+ int round = 0;
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ round++;
+
+ // Scan trees for elements, verifying source tree positions
+ for (Element e: roundEnv.getRootElements()) {
+ try {
+ TreePath p = trees.getPath(e);
+ new TestTreeScanner(p.getCompilationUnit(), trees).scan(trees.getPath(e), null);
+ } catch (IOException ex) {
+ messager.printMessage(Diagnostic.Kind.ERROR,
+ "Cannot get source: " + ex, e);
+ }
+ }
+
+ final int MAXROUNDS = 3;
+ if (round < MAXROUNDS)
+ generateSource("Gen" + round);
+
+ return true;
+ }
+
+ void generateSource(String name) {
+ StringBuilder text = new StringBuilder();
+ text.append("class ").append(name).append("{\n");
+ text.append(" int one = 1;\n");
+ text.append(" int two = 2;\n");
+ text.append(" int three = one + two;\n");
+ text.append("}\n");
+
+ try {
+ JavaFileObject fo = filer.createSourceFile(name);
+ Writer out = fo.openWriter();
+ try {
+ out.write(text.toString());
+ } finally {
+ out.close();
+ }
+ } catch (IOException e) {
+ throw new Error(e);
+ }
+ }
+
+ class TestTreeScanner extends TreePathScanner<Void,Void> {
+ TestTreeScanner(CompilationUnitTree unit, Trees trees) throws IOException {
+ this.unit = unit;
+ JavaFileObject sf = unit.getSourceFile();
+ source = sf.getCharContent(true).toString();
+ sourcePositions = trees.getSourcePositions();
+ }
+
+ @Override
+ public Void visitVariable(VariableTree tree, Void _) {
+ check(getCurrentPath());
+ return super.visitVariable(tree, _);
+ }
+
+ void check(TreePath tp) {
+ Tree tree = tp.getLeaf();
+
+ String expect = tree.toString();
+ if (tree.getKind() == Tree.Kind.VARIABLE) {
+ // tree.toString() does not know enough context to add ";",
+ // so deal with that manually...
+ Tree.Kind enclKind = tp.getParentPath().getLeaf().getKind();
+ //System.err.println(" encl: " +enclKind);
+ if (enclKind == Tree.Kind.CLASS || enclKind == Tree.Kind.BLOCK)
+ expect += ";";
+ }
+ //System.err.println("expect: " + expect);
+
+ int start = (int)sourcePositions.getStartPosition(unit, tree);
+ if (start == Diagnostic.NOPOS) {
+ messager.printMessage(Diagnostic.Kind.ERROR, "start pos not set for " + trim(tree));
+ return;
+ }
+
+ int end = (int)sourcePositions.getEndPosition(unit, tree);
+ if (end == Diagnostic.NOPOS) {
+ messager.printMessage(Diagnostic.Kind.ERROR, "end pos not set for " + trim(tree));
+ return;
+ }
+
+ String found = source.substring(start, end);
+ //System.err.println(" found: " + found);
+
+ // allow for long lines, in which case just compare beginning and
+ // end of the strings
+ boolean equal;
+ if (found.contains("\n")) {
+ String head = found.substring(0, found.indexOf("\n"));
+ String tail = found.substring(found.lastIndexOf("\n")).trim();
+ equal = expect.startsWith(head) && expect.endsWith(tail);
+ } else {
+ equal = expect.equals(found);
+ }
+
+ if (!equal) {
+ messager.printMessage(Diagnostic.Kind.ERROR,
+ "unexpected value found: '" + found + "'; expected: '" + expect + "'");
+ }
+ }
+
+ String trim(Tree tree) {
+ final int MAXLEN = 32;
+ String s = tree.toString().replaceAll("\\s+", " ").trim();
+ return (s.length() < MAXLEN) ? s : s.substring(0, MAXLEN);
+
+ }
+
+ CompilationUnitTree unit;
+ SourcePositions sourcePositions;
+ String source;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javah/VersionTest.java Mon Oct 04 14:40:38 2010 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6890226
+ * @summary javah -version is broken
+ */
+
+import java.io.*;
+import java.util.Locale;
+
+public class VersionTest {
+ public static void main(String... args) {
+ Locale prev = Locale.getDefault();
+ try {
+ Locale.setDefault(Locale.ENGLISH);
+ System.err.println(Locale.getDefault());
+ test("-version", "\\S+ version \"\\S+\"");
+ test("-fullversion", "\\S+ full version \"\\S+\"");
+ } finally {
+ Locale.setDefault(prev);
+ }
+ }
+
+ static void test(String option, String regex) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String[] args = { option };
+ int rc = com.sun.tools.javah.Main.run(args, pw);
+ pw.close();
+ if (rc != 0)
+ throw new Error("javah failed: rc=" + rc);
+ String out = sw.toString().trim();
+ System.err.println(out);
+ if (!out.matches(regex))
+ throw new Error("output does not match pattern: " + regex);
+ }
+}