--- a/langtools/make/build.xml Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/make/build.xml Mon Feb 14 16:31:21 2011 -0800
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -331,7 +331,7 @@
executable="${dist.bin.dir}/javac"
srcdir="test/tools/javac/diags"
destdir="${build.dir}/diag-examples/classes"
- includes="Example.java,FileManager.java,HTMLWriter.java,RunExamples.java"
+ includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java"
sourcepath=""
classpath="${dist.lib.dir}/javac.jar"
includeAntRuntime="no"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/DeferredLintHandler.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. 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.code;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+
+/**
+ *
+ * <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 DeferredLintHandler {
+ protected static final Context.Key<DeferredLintHandler> deferredLintHandlerKey =
+ new Context.Key<DeferredLintHandler>();
+
+ public static DeferredLintHandler instance(Context context) {
+ DeferredLintHandler instance = context.get(deferredLintHandlerKey);
+ if (instance == null)
+ instance = new DeferredLintHandler(context);
+ return instance;
+ }
+
+ protected DeferredLintHandler(Context context) {
+ context.put(deferredLintHandlerKey, this);
+ }
+
+ private DeferredLintHandler() {}
+
+ public interface LintLogger {
+ void report();
+ }
+
+ private DiagnosticPosition currentPos;
+ private Map<DiagnosticPosition, ListBuffer<LintLogger>> loggersQueue = new HashMap<DiagnosticPosition, ListBuffer<LintLogger>>();
+
+ public void report(LintLogger logger) {
+ ListBuffer<LintLogger> loggers = loggersQueue.get(currentPos);
+ Assert.checkNonNull(loggers);
+ loggers.append(logger);
+ }
+
+ public void flush(DiagnosticPosition pos) {
+ ListBuffer<LintLogger> loggers = loggersQueue.get(pos);
+ if (loggers != null) {
+ for (LintLogger lintLogger : loggers) {
+ lintLogger.report();
+ }
+ loggersQueue.remove(pos);
+ }
+ }
+
+ public DeferredLintHandler setPos(DiagnosticPosition currentPos) {
+ this.currentPos = currentPos;
+ loggersQueue.put(currentPos, ListBuffer.<LintLogger>lb());
+ return this;
+ }
+
+ public static final DeferredLintHandler immediateHandler = new DeferredLintHandler() {
+ @Override
+ public void report(LintLogger logger) {
+ logger.report();
+ }
+ };
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -237,7 +237,7 @@
/**
* Flag that marks a signature-polymorphic invoke method.
- * (These occur inside java.dyn.MethodHandle.)
+ * (These occur inside java.lang.invoke.MethodHandle.)
*/
public static final long POLYMORPHIC_SIGNATURE = 1L<<40;
@@ -252,6 +252,11 @@
*/
public static final long EFFECTIVELY_FINAL = 1L<<42;
+ /**
+ * Flag that marks non-override equivalent methods with the same signature
+ */
+ public static final long CLASH = 1L<<43;
+
/** Modifier masks.
*/
public static final int
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -106,7 +106,7 @@
}
/**
- * * Get a localized string represenation for all the symbols in the input list.
+ * * Get a localized string representation for all the symbols in the input list.
*
* @param ts symbols to be displayed
* @param locale the locale in which the string is to be rendered
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Mon Feb 14 16:31:21 2011 -0800
@@ -72,49 +72,10 @@
*/
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
- }
- };
-
/** A list of scopes to be notified if items are to be removed from this scope.
*/
List<Scope> listeners = List.nil();
- 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;
- }
- }
-
/** Use as a "not-found" result for lookup.
* Also used to mark deleted entries in the table.
*/
@@ -126,35 +87,30 @@
/** A value for the empty scope.
*/
- public static final Scope emptyScope = new Scope(null, null, new Entry[]{}, dummyCounter);
+ public static final Scope emptyScope = new Scope(null, null, new Entry[]{});
/** Construct a new scope, within scope next, with given owner, using
* given table. The table's length must be an exponent of 2.
*/
- private Scope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) {
+ private Scope(Scope next, Symbol owner, Entry[] table) {
this.next = next;
Assert.check(emptyScope == null || owner != null);
this.owner = owner;
this.table = table;
this.hashMask = table.length - 1;
- this.scopeCounter = scopeCounter;
}
/** Convenience constructor used for dup and dupUnshared. */
- private Scope(Scope next, Symbol owner, Entry[] table) {
- this(next, owner, table, next.scopeCounter);
- this.nelems = next.nelems;
+ private Scope(Scope next, Symbol owner, Entry[] table, int nelems) {
+ this(next, owner, table);
+ this.nelems = nelems;
}
/** Construct a new scope, within scope next, with given owner,
* using a fresh table of length INITIAL_SIZE.
*/
public Scope(Symbol owner) {
- this(owner, dummyCounter);
- }
-
- protected Scope(Symbol owner, ScopeCounter scopeCounter) {
- this(null, owner, new Entry[INITIAL_SIZE], scopeCounter);
+ this(null, owner, new Entry[INITIAL_SIZE]);
}
/** Construct a fresh scope within this scope, with same owner,
@@ -172,7 +128,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, this.nelems);
shared++;
// System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode());
// new Error().printStackTrace(System.out);
@@ -184,7 +140,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(), this.nelems);
}
/** Remove all entries of this scope from its table, if shared
@@ -263,7 +219,6 @@
Entry e = makeEntry(sym, old, elems, s, origin);
table[hash] = e;
elems = e;
- scopeCounter.inc();
}
Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) {
@@ -278,8 +233,6 @@
Entry e = lookup(sym.name);
if (e.scope == null) return;
- scopeCounter.inc();
-
// remove e from table and shadowed list;
int i = getIndex(sym.name);
Entry te = table[i];
@@ -559,7 +512,7 @@
public static final Entry[] emptyTable = new Entry[0];
public DelegatedScope(Scope outer) {
- super(outer, outer.owner, emptyTable, outer.scopeCounter);
+ super(outer, outer.owner, emptyTable);
delegatee = outer;
}
public Scope dup() {
@@ -585,22 +538,10 @@
}
}
- /** 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, dummyCounter);
+ super(next, /*owner=*/errSymbol, table);
}
public ErrorScope(Symbol errSymbol) {
super(errSymbol);
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Mon Feb 14 16:31:21 2011 -0800
@@ -729,6 +729,10 @@
*/
public Pool pool;
+ /** members closure cache (set by Types.membersClosure)
+ */
+ Scope membersClosure;
+
public ClassSymbol(long flags, Name name, Type type, Symbol owner) {
super(flags, name, type, owner);
this.members_field = null;
@@ -961,22 +965,12 @@
}
public void setLazyConstValue(final Env<AttrContext> env,
- final Log log,
final Attr attr,
final JCTree.JCExpression initializer)
{
setData(new Callable<Object>() {
public Object call() {
- JavaFileObject source = log.useSource(env.toplevel.sourcefile);
- try {
- Type itype = attr.attribExpr(initializer, env, type);
- if (itype.constValue() != null)
- return attr.coerce(itype, type).constValue();
- else
- return null;
- } finally {
- log.useSource(source);
- }
+ return attr.attribLazyConstantValue(env, initializer, type);
}
});
}
@@ -1010,6 +1004,7 @@
try {
data = eval.call();
} catch (Exception ex) {
+ ex.printStackTrace();
throw new AssertionError(ex);
}
}
@@ -1231,7 +1226,7 @@
};
public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
- MethodSymbol res = types.implementation(this, origin, types, checkResult, implFilter);
+ MethodSymbol res = types.implementation(this, origin, checkResult, implFilter);
if (res != null)
return res;
// if origin is derived from a raw type, we might have missed
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Mon Feb 14 16:31:21 2011 -0800
@@ -74,7 +74,6 @@
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;
@@ -124,7 +123,9 @@
public final Type stringBuilderType;
public final Type cloneableType;
public final Type serializableType;
+ public final Type transientMethodHandleType; // transient - 292
public final Type methodHandleType;
+ public final Type transientPolymorphicSignatureType; // transient - 292
public final Type polymorphicSignatureType;
public final Type throwableType;
public final Type errorType;
@@ -341,7 +342,6 @@
context.put(symtabKey, this);
names = Names.instance(context);
- scopeCounter = Scope.ScopeCounter.instance(context);
target = Target.instance(context);
// Create the unknown type
@@ -388,7 +388,7 @@
// Create class to hold all predefined constants and operations.
predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
- Scope scope = new Scope.ClassScope(predefClass, scopeCounter);
+ Scope scope = new Scope(predefClass);
predefClass.members_field = scope;
// Enter symbols for basic types.
@@ -419,8 +419,10 @@
cloneableType = enterClass("java.lang.Cloneable");
throwableType = enterClass("java.lang.Throwable");
serializableType = enterClass("java.io.Serializable");
- methodHandleType = enterClass("java.dyn.MethodHandle");
- polymorphicSignatureType = enterClass("java.dyn.MethodHandle$PolymorphicSignature");
+ transientMethodHandleType = enterClass("java.dyn.MethodHandle"); // transient - 292
+ methodHandleType = enterClass("java.lang.invoke.MethodHandle");
+ transientPolymorphicSignatureType = enterClass("java.dyn.MethodHandle$PolymorphicSignature"); // transient - 292
+ polymorphicSignatureType = enterClass("java.lang.invoke.MethodHandle$PolymorphicSignature");
errorType = enterClass("java.lang.Error");
illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
exceptionType = enterClass("java.lang.Exception");
@@ -464,6 +466,7 @@
synthesizeEmptyInterfaceIfMissing(cloneableType);
synthesizeEmptyInterfaceIfMissing(serializableType);
+ synthesizeEmptyInterfaceIfMissing(transientPolymorphicSignatureType); // transient - 292
synthesizeEmptyInterfaceIfMissing(polymorphicSignatureType);
synthesizeBoxTypeIfMissing(doubleType);
synthesizeBoxTypeIfMissing(floatType);
@@ -478,7 +481,7 @@
proprietarySymbol.completer = null;
proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
proprietarySymbol.erasure_field = proprietaryType;
- proprietarySymbol.members_field = new Scope.ClassScope(proprietarySymbol, scopeCounter);
+ proprietarySymbol.members_field = new Scope(proprietarySymbol);
proprietaryType.typarams_field = List.nil();
proprietaryType.allparams_field = List.nil();
proprietaryType.supertype_field = annotationType;
@@ -490,7 +493,7 @@
ClassType arrayClassType = (ClassType)arrayClass.type;
arrayClassType.supertype_field = objectType;
arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
- arrayClass.members_field = new Scope.ClassScope(arrayClass, scopeCounter);
+ arrayClass.members_field = new Scope(arrayClass);
lengthVar = new VarSymbol(
PUBLIC | FINAL,
names.length,
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Mon Feb 14 16:31:21 2011 -0800
@@ -36,6 +36,7 @@
import com.sun.tools.javac.code.Lint.LintCategory;
import com.sun.tools.javac.comp.Check;
+import static com.sun.tools.javac.code.Scope.*;
import static com.sun.tools.javac.code.Type.*;
import static com.sun.tools.javac.code.TypeTags.*;
import static com.sun.tools.javac.code.Symbol.*;
@@ -70,7 +71,6 @@
new Context.Key<Types>();
final Symtab syms;
- final Scope.ScopeCounter scopeCounter;
final JavacMessages messages;
final Names names;
final boolean allowBoxing;
@@ -91,7 +91,6 @@
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);
@@ -2024,26 +2023,22 @@
final MethodSymbol cachedImpl;
final Filter<Symbol> implFilter;
final boolean checkResult;
- final Scope.ScopeCounter scopeCounter;
public Entry(MethodSymbol cachedImpl,
Filter<Symbol> scopeFilter,
- boolean checkResult,
- Scope.ScopeCounter scopeCounter) {
+ boolean checkResult) {
this.cachedImpl = cachedImpl;
this.implFilter = scopeFilter;
this.checkResult = checkResult;
- this.scopeCounter = scopeCounter;
}
- boolean matches(Filter<Symbol> scopeFilter, boolean checkResult, Scope.ScopeCounter scopeCounter) {
+ boolean matches(Filter<Symbol> scopeFilter, boolean checkResult) {
return this.implFilter == scopeFilter &&
- this.checkResult == checkResult &&
- this.scopeCounter.val() >= scopeCounter.val();
+ this.checkResult == checkResult;
}
}
- MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter, Scope.ScopeCounter scopeCounter) {
+ MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
SoftReference<Map<TypeSymbol, Entry>> ref_cache = _map.get(ms);
Map<TypeSymbol, Entry> cache = ref_cache != null ? ref_cache.get() : null;
if (cache == null) {
@@ -2052,9 +2047,9 @@
}
Entry e = cache.get(origin);
if (e == null ||
- !e.matches(implFilter, checkResult, scopeCounter)) {
+ !e.matches(implFilter, checkResult)) {
MethodSymbol impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter);
- cache.put(origin, new Entry(impl, implFilter, checkResult, scopeCounter));
+ cache.put(origin, new Entry(impl, implFilter, checkResult));
return impl;
}
else {
@@ -2081,9 +2076,53 @@
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, scopeCounter);
+ public MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
+ return implCache.get(ms, origin, checkResult, implFilter);
+ }
+ // </editor-fold>
+
+ // <editor-fold defaultstate="collapsed" desc="compute transitive closure of all members in given site">
+ public Scope membersClosure(Type site) {
+ return membersClosure.visit(site);
}
+
+ UnaryVisitor<Scope> membersClosure = new UnaryVisitor<Scope>() {
+
+ public Scope visitType(Type t, Void s) {
+ return null;
+ }
+
+ @Override
+ public Scope visitClassType(ClassType t, Void s) {
+ ClassSymbol csym = (ClassSymbol)t.tsym;
+ if (csym.membersClosure == null) {
+ Scope membersClosure = new Scope(csym);
+ for (Type i : interfaces(t)) {
+ enterAll(visit(i), membersClosure);
+ }
+ enterAll(visit(supertype(t)), membersClosure);
+ enterAll(csym.members(), membersClosure);
+ csym.membersClosure = membersClosure;
+ }
+ return csym.membersClosure;
+ }
+
+ @Override
+ public Scope visitTypeVar(TypeVar t, Void s) {
+ return visit(t.getUpperBound());
+ }
+
+ public void enterAll(Scope s, Scope to) {
+ if (s == null) return;
+ List<Symbol> syms = List.nil();
+ for (Scope.Entry e = s.elems ; e != null ; e = e.sibling) {
+ syms = syms.prepend(e.sym);
+ }
+ for (Symbol sym : syms) {
+ to.enter(sym);
+ }
+ }
+ };
// </editor-fold>
/**
@@ -2259,6 +2298,13 @@
@Override
public Type visitForAll(ForAll t, Void ignored) {
+ if (Type.containsAny(to, t.tvars)) {
+ //perform alpha-renaming of free-variables in 't'
+ //if 'to' types contain variables that are free in 't'
+ List<Type> freevars = newInstances(t.tvars);
+ t = new ForAll(freevars,
+ Types.this.subst(t.qtype, t.tvars, freevars));
+ }
List<Type> tvars1 = substBounds(t.tvars, from, to);
Type qtype1 = subst(t.qtype);
if (tvars1 == t.tvars && qtype1 == t.qtype) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Feb 14 16:31:21 2011 -0800
@@ -83,6 +83,7 @@
final Types types;
final JCDiagnostic.Factory diags;
final Annotate annotate;
+ final DeferredLintHandler deferredLintHandler;
public static Attr instance(Context context) {
Attr instance = context.get(attrKey);
@@ -108,6 +109,7 @@
types = Types.instance(context);
diags = JCDiagnostic.Factory.instance(context);
annotate = Annotate.instance(context);
+ deferredLintHandler = DeferredLintHandler.instance(context);
Options options = Options.instance(context);
@@ -125,7 +127,6 @@
findDiamonds = options.get("findDiamond") != null &&
source.allowDiamond();
useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
- enableSunApiLintControl = options.isSet("enableSunApiLintControl");
}
/** Switch: relax some constraints for retrofit mode.
@@ -174,12 +175,6 @@
boolean useBeforeDeclarationWarning;
/**
- * Switch: allow lint infrastructure to control proprietary
- * API warnings.
- */
- boolean enableSunApiLintControl;
-
- /**
* Switch: allow strings in switch?
*/
boolean allowStringsInSwitch;
@@ -581,6 +576,41 @@
}
}
+ /**
+ * Attribute a "lazy constant value".
+ * @param env The env for the const value
+ * @param initializer The initializer for the const value
+ * @param type The expected type, or null
+ * @see VarSymbol#setlazyConstValue
+ */
+ public Object attribLazyConstantValue(Env<AttrContext> env,
+ JCTree.JCExpression initializer,
+ Type type) {
+
+ // in case no lint value has been set up for this env, scan up
+ // env stack looking for smallest enclosing env for which it is set.
+ Env<AttrContext> lintEnv = env;
+ while (lintEnv.info.lint == null)
+ lintEnv = lintEnv.next;
+
+ // Having found the enclosing lint value, we can initialize the lint value for this class
+ env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.attributes_field, env.info.enclVar.flags());
+
+ Lint prevLint = chk.setLint(env.info.lint);
+ JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile);
+
+ try {
+ Type itype = attribExpr(initializer, env, type);
+ if (itype.constValue() != null)
+ return coerce(itype, type).constValue();
+ else
+ return null;
+ } finally {
+ env.info.lint = prevLint;
+ log.useSource(prevSource);
+ }
+ }
+
/** Attribute type reference in an `extends' or `implements' clause.
* Supertypes of anonymous inner classes are usually already attributed.
*
@@ -672,13 +702,18 @@
Lint prevLint = chk.setLint(lint);
MethodSymbol prevMethod = chk.setMethod(m);
try {
+ deferredLintHandler.flush(tree.pos());
chk.checkDeprecatedAnnotation(tree.pos(), m);
attribBounds(tree.typarams);
// If we override any other methods, check that we do so properly.
// JLS ???
- chk.checkClashes(tree.pos(), env.enclClass.type, m);
+ if (m.isStatic()) {
+ chk.checkHideClashes(tree.pos(), env.enclClass.type, m);
+ } else {
+ chk.checkOverrideClashes(tree.pos(), env.enclClass.type, m);
+ }
chk.checkOverride(tree, m);
// Create a new environment with local scope
@@ -814,6 +849,7 @@
// Check that the variable's declared type is well-formed.
chk.validate(tree.vartype, env);
+ deferredLintHandler.flush(tree.pos());
try {
chk.checkDeprecatedAnnotation(tree.pos(), v);
@@ -1959,7 +1995,9 @@
tree.pos(), tree.getTag() - JCTree.ASGOffset, env,
owntype, operand);
- if (operator.kind == MTH) {
+ if (operator.kind == MTH &&
+ !owntype.isErroneous() &&
+ !operand.isErroneous()) {
chk.checkOperator(tree.pos(),
(OperatorSymbol)operator,
tree.getTag() - JCTree.ASGOffset,
@@ -1984,7 +2022,8 @@
rs.resolveUnaryOperator(tree.pos(), tree.getTag(), env, argtype);
Type owntype = types.createErrorType(tree.type);
- if (operator.kind == MTH) {
+ if (operator.kind == MTH &&
+ !argtype.isErroneous()) {
owntype = (JCTree.PREINC <= tree.getTag() && tree.getTag() <= JCTree.POSTDEC)
? tree.arg.type
: operator.type.getReturnType();
@@ -2020,7 +2059,9 @@
rs.resolveBinaryOperator(tree.pos(), tree.getTag(), env, left, right);
Type owntype = types.createErrorType(tree.type);
- if (operator.kind == MTH) {
+ if (operator.kind == MTH &&
+ !left.isErroneous() &&
+ !right.isErroneous()) {
owntype = operator.type.getReturnType();
int opc = chk.checkOperator(tree.lhs.pos(),
(OperatorSymbol)operator,
@@ -2337,7 +2378,6 @@
int pkind) {
DiagnosticPosition pos = tree.pos();
Name name = tree.name;
-
switch (site.tag) {
case PACKAGE:
return rs.access(
@@ -2543,17 +2583,10 @@
// Test (1): emit a `deprecation' warning if symbol is deprecated.
// (for constructors, the error was given when the constructor was
// resolved)
- if (sym.name != names.init &&
- (sym.flags() & DEPRECATED) != 0 &&
- (env.info.scope.owner.flags() & DEPRECATED) == 0 &&
- sym.outermostClass() != env.info.scope.owner.outermostClass())
- chk.warnDeprecated(tree.pos(), sym);
-
- if ((sym.flags() & PROPRIETARY) != 0) {
- if (enableSunApiLintControl)
- chk.warnSunApi(tree.pos(), "sun.proprietary", sym);
- else
- log.strictWarning(tree.pos(), "sun.proprietary", sym);
+
+ if (sym.name != names.init) {
+ chk.checkDeprecated(tree.pos(), env.info.scope.owner, sym);
+ chk.checkSunAPI(tree.pos(), sym);
}
// Test (3): if symbol is a variable, check that its type and
@@ -3156,7 +3189,7 @@
if (sym == null ||
sym.kind != VAR ||
((VarSymbol) sym).getConstValue() == null)
- log.error(l.head.pos(), "icls.cant.have.static.decl", sym.location());
+ log.error(l.head.pos(), "icls.cant.have.static.decl", c);
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Feb 14 16:31:21 2011 -0800
@@ -68,6 +68,7 @@
private final boolean skipAnnotations;
private boolean warnOnSyntheticConflicts;
private boolean suppressAbortOnBadClassFile;
+ private boolean enableSunApiLintControl;
private final TreeInfo treeinfo;
// The set of lint options currently in effect. It is initialized
@@ -109,13 +110,13 @@
skipAnnotations = options.isSet("skipAnnotations");
warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
+ enableSunApiLintControl = options.isSet("enableSunApiLintControl");
Target target = Target.instance(context);
syntheticNameChar = target.syntheticNameChar();
boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION);
boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED);
- boolean verboseVarargs = lint.isEnabled(LintCategory.VARARGS);
boolean verboseSunApi = lint.isEnabled(LintCategory.SUNAPI);
boolean enforceMandatoryWarnings = source.enforceMandatoryWarnings();
@@ -123,10 +124,10 @@
enforceMandatoryWarnings, "deprecated", LintCategory.DEPRECATION);
uncheckedHandler = new MandatoryWarningHandler(log, verboseUnchecked,
enforceMandatoryWarnings, "unchecked", LintCategory.UNCHECKED);
- unsafeVarargsHandler = new MandatoryWarningHandler(log, verboseVarargs,
- enforceMandatoryWarnings, "varargs", LintCategory.VARARGS);
sunApiHandler = new MandatoryWarningHandler(log, verboseSunApi,
enforceMandatoryWarnings, "sunapi", null);
+
+ deferredLintHandler = DeferredLintHandler.immediateHandler;
}
/** Switch: generics enabled?
@@ -166,14 +167,14 @@
*/
private MandatoryWarningHandler uncheckedHandler;
- /** A handler for messages about unchecked or unsafe vararg method decl.
- */
- private MandatoryWarningHandler unsafeVarargsHandler;
-
/** A handler for messages about using proprietary API.
*/
private MandatoryWarningHandler sunApiHandler;
+ /** A handler for deferred lint warnings.
+ */
+ private DeferredLintHandler deferredLintHandler;
+
/* *************************************************************************
* Errors and Warnings
**************************************************************************/
@@ -184,6 +185,12 @@
return prev;
}
+ DeferredLintHandler setDeferredLintHandler(DeferredLintHandler newDeferredLintHandler) {
+ DeferredLintHandler prev = deferredLintHandler;
+ deferredLintHandler = newDeferredLintHandler;
+ return prev;
+ }
+
MethodSymbol setMethod(MethodSymbol newMethod) {
MethodSymbol prev = method;
method = newMethod;
@@ -800,8 +807,9 @@
Type actual = types.subst(args.head,
type.tsym.type.getTypeArguments(),
tvars_buf.toList());
- if (!checkExtends(actual, (TypeVar)tvars.head) &&
- !tvars.head.getUpperBound().isErroneous()) {
+ if (!isTypeArgErroneous(actual) &&
+ !tvars.head.getUpperBound().isErroneous() &&
+ !checkExtends(actual, (TypeVar)tvars.head)) {
return args.head;
}
args = args.tail;
@@ -814,14 +822,39 @@
for (Type arg : types.capture(type).getTypeArguments()) {
if (arg.tag == TYPEVAR &&
arg.getUpperBound().isErroneous() &&
- !tvars.head.getUpperBound().isErroneous()) {
+ !tvars.head.getUpperBound().isErroneous() &&
+ !isTypeArgErroneous(args.head)) {
return args.head;
}
tvars = tvars.tail;
+ args = args.tail;
}
return null;
}
+ //where
+ boolean isTypeArgErroneous(Type t) {
+ return isTypeArgErroneous.visit(t);
+ }
+
+ Types.UnaryVisitor<Boolean> isTypeArgErroneous = new Types.UnaryVisitor<Boolean>() {
+ public Boolean visitType(Type t, Void s) {
+ return t.isErroneous();
+ }
+ @Override
+ public Boolean visitTypeVar(TypeVar t, Void s) {
+ return visit(t.getUpperBound());
+ }
+ @Override
+ public Boolean visitCapturedType(CapturedType t, Void s) {
+ return visit(t.getUpperBound()) ||
+ visit(t.getLowerBound());
+ }
+ @Override
+ public Boolean visitWildcardType(WildcardType t, Void s) {
+ return visit(t.type);
+ }
+ };
/** Check that given modifiers are legal for given symbol and
* return modifiers together with any implicit modififiers for that symbol.
@@ -1094,6 +1127,7 @@
log.error(tree.pos(), "improperly.formed.type.param.missing");
}
}
+
public void visitSelectInternal(JCFieldAccess tree) {
if (tree.type.tsym.isStatic() &&
tree.selected.type.isParameterized()) {
@@ -1463,11 +1497,8 @@
}
// Warn if a deprecated method overridden by a non-deprecated one.
- if ((other.flags() & DEPRECATED) != 0
- && (m.flags() & DEPRECATED) == 0
- && m.outermostClass() != other.outermostClass()
- && !isDeprecatedOverrideIgnorable(other, origin)) {
- warnDeprecated(TreeInfo.diagnosticPositionFor(m, tree), other);
+ if (!isDeprecatedOverrideIgnorable(other, origin)) {
+ checkDeprecated(TreeInfo.diagnosticPositionFor(m, tree), m, other);
}
}
// where
@@ -1648,7 +1679,7 @@
"(" + types.memberType(t2, s2).getParameterTypes() + ")");
return s2;
}
- } else if (!checkNameClash((ClassSymbol)site.tsym, s1, s2)) {
+ } else if (checkNameClash((ClassSymbol)site.tsym, s1, s2)) {
log.error(pos,
"name.clash.same.erasure.no.override",
s1, s1.location(),
@@ -1730,18 +1761,10 @@
}
private boolean checkNameClash(ClassSymbol origin, Symbol s1, Symbol s2) {
- if (s1.kind == MTH &&
- s1.isInheritedIn(origin, types) &&
- (s1.flags() & SYNTHETIC) == 0 &&
- !s2.isConstructor()) {
- Type er1 = s2.erasure(types);
- Type er2 = s1.erasure(types);
- if (types.isSameTypes(er1.getParameterTypes(),
- er2.getParameterTypes())) {
- return false;
- }
- }
- return true;
+ ClashFilter cf = new ClashFilter(origin.type);
+ return (cf.accepts(s1) &&
+ cf.accepts(s2) &&
+ types.hasSameArgs(s1.erasure(types), s2.erasure(types)));
}
@@ -2080,52 +2103,82 @@
* @param site The class whose methods are checked.
* @param sym The method symbol to be checked.
*/
- void checkClashes(DiagnosticPosition pos, Type site, Symbol sym) {
- List<Type> supertypes = types.closure(site);
- for (List<Type> l = supertypes; l.nonEmpty(); l = l.tail) {
- for (List<Type> m = supertypes; m.nonEmpty(); m = m.tail) {
- checkClashes(pos, l.head, m.head, site, sym);
+ void checkOverrideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) {
+ ClashFilter cf = new ClashFilter(site);
+ //for each method m1 that is a member of 'site'...
+ for (Scope.Entry e1 = types.membersClosure(site).lookup(sym.name, cf) ;
+ e1.scope != null ; e1 = e1.next(cf)) {
+ //...find another method m2 that is overridden (directly or indirectly)
+ //by method 'sym' in 'site'
+ for (Scope.Entry e2 = types.membersClosure(site).lookup(sym.name, cf) ;
+ e2.scope != null ; e2 = e2.next(cf)) {
+ if (e1.sym == e2.sym || !sym.overrides(e2.sym, site.tsym, types, false)) continue;
+ //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
+ //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error
+ if (!types.isSubSignature(sym.type, types.memberType(site, e1.sym)) &&
+ types.hasSameArgs(e1.sym.erasure(types), e2.sym.erasure(types))) {
+ sym.flags_field |= CLASH;
+ String key = e2.sym == sym ?
+ "name.clash.same.erasure.no.override" :
+ "name.clash.same.erasure.no.override.1";
+ log.error(pos,
+ key,
+ sym, sym.location(),
+ e1.sym, e1.sym.location(),
+ e2.sym, e2.sym.location());
+ return;
+ }
}
}
}
- /** Reports an error whenever 'sym' seen as a member of type 't1' clashes with
- * some unrelated method defined in 't2'.
+ /** Check that all static methods accessible from 'site' are
+ * mutually compatible (JLS 8.4.8).
+ *
+ * @param pos Position to be used for error reporting.
+ * @param site The class whose methods are checked.
+ * @param sym The method symbol to be checked.
*/
- private void checkClashes(DiagnosticPosition pos, Type t1, Type t2, Type site, Symbol s1) {
+ void checkHideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) {
ClashFilter cf = new ClashFilter(site);
- s1 = ((MethodSymbol)s1).implementedIn(t1.tsym, types);
- if (s1 == null) return;
- Type st1 = types.memberType(site, s1);
- for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name, cf); e2.scope != null; e2 = e2.next(cf)) {
- Symbol s2 = e2.sym;
- if (s1 == s2) continue;
- Type st2 = types.memberType(site, s2);
- if (!types.overrideEquivalent(st1, st2) &&
- !checkNameClash((ClassSymbol)site.tsym, s1, s2)) {
+ //for each method m1 that is a member of 'site'...
+ for (Scope.Entry e = types.membersClosure(site).lookup(sym.name, cf) ;
+ e.scope != null ; e = e.next(cf)) {
+ //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
+ //a member of 'site') and (ii) 'sym' has the same erasure as m1, issue an error
+ if (!types.isSubSignature(sym.type, types.memberType(site, e.sym)) &&
+ types.hasSameArgs(e.sym.erasure(types), sym.erasure(types))) {
log.error(pos,
- "name.clash.same.erasure.no.override",
- s1, s1.location(),
- s2, s2.location());
- }
- }
- }
- //where
- private class ClashFilter implements Filter<Symbol> {
+ "name.clash.same.erasure.no.hide",
+ sym, sym.location(),
+ e.sym, e.sym.location());
+ return;
+ }
+ }
+ }
- Type site;
+ //where
+ private class ClashFilter implements Filter<Symbol> {
+
+ Type site;
- ClashFilter(Type site) {
- this.site = site;
- }
+ ClashFilter(Type site) {
+ this.site = site;
+ }
+
+ boolean shouldSkip(Symbol s) {
+ return (s.flags() & CLASH) != 0 &&
+ s.owner == site.tsym;
+ }
- public boolean accepts(Symbol s) {
- return s.kind == MTH &&
- (s.flags() & SYNTHETIC) == 0 &&
- s.isInheritedIn(site.tsym, types) &&
- !s.isConstructor();
- }
- }
+ public boolean accepts(Symbol s) {
+ return s.kind == MTH &&
+ (s.flags() & SYNTHETIC) == 0 &&
+ !shouldSkip(s) &&
+ s.isInheritedIn(site.tsym, types) &&
+ !s.isConstructor();
+ }
+ }
/** Report a conflict between a user symbol and a synthetic symbol.
*/
@@ -2410,6 +2463,32 @@
}
}
+ void checkDeprecated(final DiagnosticPosition pos, final Symbol other, final Symbol s) {
+ if ((s.flags() & DEPRECATED) != 0 &&
+ (other.flags() & DEPRECATED) == 0 &&
+ s.outermostClass() != other.outermostClass()) {
+ deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
+ @Override
+ public void report() {
+ warnDeprecated(pos, s);
+ }
+ });
+ };
+ }
+
+ void checkSunAPI(final DiagnosticPosition pos, final Symbol s) {
+ if ((s.flags() & PROPRIETARY) != 0) {
+ deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
+ public void report() {
+ if (enableSunApiLintControl)
+ warnSunApi(pos, "sun.proprietary", s);
+ else
+ log.strictWarning(pos, "sun.proprietary", s);
+ }
+ });
+ }
+ }
+
/* *************************************************************************
* Check for recursive annotation elements.
**************************************************************************/
@@ -2535,9 +2614,9 @@
Type right) {
if (operator.opcode == ByteCodes.error) {
log.error(pos,
- "operator.cant.be.applied",
+ "operator.cant.be.applied.1",
treeinfo.operatorName(tag),
- List.of(left, right));
+ left, right);
}
return operator.opcode;
}
@@ -2581,21 +2660,35 @@
if (sym.owner.name == names.any) return false;
for (Scope.Entry e = s.lookup(sym.name); e.scope == s; e = e.next()) {
if (sym != e.sym &&
- sym.kind == e.sym.kind &&
- sym.name != names.error &&
- (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) {
- if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS))
+ (e.sym.flags() & CLASH) == 0 &&
+ sym.kind == e.sym.kind &&
+ sym.name != names.error &&
+ (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) {
+ if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) {
varargsDuplicateError(pos, sym, e.sym);
- else if (sym.kind == MTH && !types.overrideEquivalent(sym.type, e.sym.type))
+ return true;
+ } else if (sym.kind == MTH && !hasSameSignature(sym.type, e.sym.type)) {
duplicateErasureError(pos, sym, e.sym);
- else
+ sym.flags_field |= CLASH;
+ return true;
+ } else {
duplicateError(pos, e.sym);
- return false;
+ return false;
+ }
}
}
return true;
}
//where
+ boolean hasSameSignature(Type mt1, Type mt2) {
+ if (mt1.tag == FORALL && mt2.tag == FORALL) {
+ ForAll fa1 = (ForAll)mt1;
+ ForAll fa2 = (ForAll)mt2;
+ mt2 = types.subst(fa2, fa2.tvars, fa1.tvars);
+ }
+ return types.hasSameArgs(mt1.asMethodType(), mt2.asMethodType());
+ }
+
/** Report duplicate declaration error.
*/
void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Mon Feb 14 16:31:21 2011 -0800
@@ -95,7 +95,6 @@
Log log;
Symtab syms;
- Scope.ScopeCounter scopeCounter;
Check chk;
TreeMaker make;
ClassReader reader;
@@ -123,7 +122,6 @@
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);
@@ -192,7 +190,7 @@
*/
public Env<AttrContext> classEnv(JCClassDecl tree, Env<AttrContext> env) {
Env<AttrContext> localEnv =
- env.dup(tree, env.info.dup(new Scope.ClassScope(tree.sym, scopeCounter)));
+ env.dup(tree, env.info.dup(new Scope(tree.sym)));
localEnv.enclClass = tree;
localEnv.outer = env;
localEnv.info.isSelfCall = false;
@@ -328,7 +326,7 @@
c.flatname = names.fromString(tree.packge + "." + name);
c.sourcefile = tree.sourcefile;
c.completer = null;
- c.members_field = new Scope.ClassScope(c, scopeCounter);
+ c.members_field = new Scope(c);
tree.packge.package_info = c;
}
classEnter(tree.defs, topEnv);
@@ -396,7 +394,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.ClassScope(c, scopeCounter);
+ c.members_field = new Scope(c);
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 Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -485,11 +485,8 @@
@Override
public Type inst(List<Type> inferred, Types types) throws NoInstanceException {
List<Type> formals = types.subst(mt2.argtypes, tvars, inferred);
- if (!rs.argumentsAcceptable(capturedArgs, formals,
- allowBoxing, useVarargs, warn)) {
- // inferred method is not applicable
- throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", formals, argtypes);
- }
+ // check that actuals conform to inferred formals
+ checkArgumentsAcceptable(env, capturedArgs, formals, allowBoxing, useVarargs, warn);
// check that inferred bounds conform to their bounds
checkWithinBounds(all_tvars,
types.subst(inferredTypes, tvars, inferred), warn);
@@ -500,17 +497,27 @@
}};
return mt2;
}
- else if (!rs.argumentsAcceptable(capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn)) {
- // inferred method is not applicable
- throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", mt.getParameterTypes(), argtypes);
- }
else {
+ // check that actuals conform to inferred formals
+ checkArgumentsAcceptable(env, capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn);
// return instantiated version of method type
return mt;
}
}
//where
+ private void checkArgumentsAcceptable(Env<AttrContext> env, List<Type> actuals, List<Type> formals,
+ boolean allowBoxing, boolean useVarargs, Warner warn) {
+ try {
+ rs.checkRawArgumentsAcceptable(env, actuals, formals,
+ allowBoxing, useVarargs, warn);
+ }
+ catch (Resolve.InapplicableMethodException ex) {
+ // inferred method is not applicable
+ throw invalidInstanceException.setMessage(ex.getDiagnostic());
+ }
+ }
+
/** Try to instantiate argument type `that' to given type `to'.
* If this fails, try to insantiate `that' to `to' where
* every occurrence of a type variable in `tvars' is replaced
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon Feb 14 16:31:21 2011 -0800
@@ -68,7 +68,6 @@
private Names names;
private Log log;
private Symtab syms;
- private Scope.ScopeCounter scopeCounter;
private Resolve rs;
private Check chk;
private Attr attr;
@@ -91,7 +90,6 @@
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);
@@ -571,7 +569,7 @@
c.flatname = chk.localClassName(c);
c.sourcefile = owner.sourcefile;
c.completer = null;
- c.members_field = new Scope.ClassScope(c, scopeCounter);
+ c.members_field = new Scope(c);
c.flags_field = flags;
ClassType ctype = (ClassType) c.type;
ctype.supertype_field = syms.objectType;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Mon Feb 14 16:31:21 2011 -0800
@@ -67,7 +67,6 @@
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;
@@ -75,9 +74,9 @@
private final Types types;
private final JCDiagnostic.Factory diags;
private final Target target;
+ private final DeferredLintHandler deferredLintHandler;
private final boolean skipAnnotations;
- private final boolean allowSimplifiedVarargs;
public static MemberEnter instance(Context context) {
MemberEnter instance = context.get(memberEnterKey);
@@ -94,7 +93,6 @@
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);
@@ -102,10 +100,9 @@
types = Types.instance(context);
diags = JCDiagnostic.Factory.instance(context);
target = Target.instance(context);
+ deferredLintHandler = DeferredLintHandler.instance(context);
Options options = Options.instance(context);
skipAnnotations = options.isSet("skipAnnotations");
- Source source = Source.instance(context);
- allowSimplifiedVarargs = source.allowSimplifiedVarargs();
}
/** A queue for classes whose members still need to be entered into the
@@ -571,10 +568,16 @@
tree.sym = m;
Env<AttrContext> localEnv = methodEnv(tree, env);
- // Compute the method type
- m.type = signature(tree.typarams, tree.params,
- tree.restype, tree.thrown,
- localEnv);
+ DeferredLintHandler prevLintHandler =
+ chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos()));
+ try {
+ // Compute the method type
+ m.type = signature(tree.typarams, tree.params,
+ tree.restype, tree.thrown,
+ localEnv);
+ } finally {
+ chk.setDeferredLintHandler(prevLintHandler);
+ }
// Set m.params
ListBuffer<VarSymbol> params = new ListBuffer<VarSymbol>();
@@ -618,7 +621,14 @@
localEnv = env.dup(tree, env.info.dup());
localEnv.info.staticLevel++;
}
- attr.attribType(tree.vartype, localEnv);
+ DeferredLintHandler prevLintHandler =
+ chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos()));
+ try {
+ attr.attribType(tree.vartype, localEnv);
+ } finally {
+ chk.setDeferredLintHandler(prevLintHandler);
+ }
+
if ((tree.mods.flags & VARARGS) != 0) {
//if we are entering a varargs parameter, we need to replace its type
//(a plain array type) with the more precise VarargsType --- we need
@@ -637,7 +647,7 @@
if ((v.flags_field & FINAL) != 0 && tree.init.getTag() != JCTree.NEWCLASS) {
Env<AttrContext> initEnv = getInitEnv(tree, env);
initEnv.info.enclVar = v;
- v.setLazyConstValue(initEnv(tree, initEnv), log, attr, tree.init);
+ v.setLazyConstValue(initEnv(tree, initEnv), attr, tree.init);
}
}
if (chk.checkUnique(tree.pos(), v, enclScope)) {
@@ -775,10 +785,11 @@
&& s.owner.kind != MTH
&& types.isSameType(c.type, syms.deprecatedType))
s.flags_field |= Flags.DEPRECATED;
- // Internally to java.dyn, a @PolymorphicSignature annotation
+ // Internally to java.lang.invoke, a @PolymorphicSignature annotation
// acts like a classfile attribute.
if (!c.type.isErroneous() &&
- types.isSameType(c.type, syms.polymorphicSignatureType)) {
+ (types.isSameType(c.type, syms.polymorphicSignatureType) ||
+ types.isSameType(c.type, syms.transientPolymorphicSignatureType))) {
if (!target.hasMethodHandles()) {
// Somebody is compiling JDK7 source code to a JDK6 target.
// Make it an error, since it is unlikely but important.
@@ -1010,7 +1021,7 @@
}
private Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) {
- Scope baseScope = new Scope.ClassScope(tree.sym, scopeCounter);
+ Scope baseScope = new Scope(tree.sym);
//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 Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Feb 14 16:31:21 2011 -0800
@@ -278,7 +278,7 @@
return true;
else {
Symbol s2 = ((MethodSymbol)sym).implementation(site.tsym, types, true);
- return (s2 == null || s2 == sym ||
+ return (s2 == null || s2 == sym || sym.owner == s2.owner ||
s2.isPolymorphicSignatureGeneric() ||
!types.isSubSignature(types.memberType(site, s2), types.memberType(site, sym)));
}
@@ -331,7 +331,7 @@
throws Infer.InferenceException {
boolean polymorphicSignature = m.isPolymorphicSignatureGeneric() && allowMethodHandles;
if (useVarargs && (m.flags() & VARARGS) == 0)
- throw inapplicableMethodException.setMessage(null);
+ throw inapplicableMethodException.setMessage();
Type mt = types.memberType(site, m);
// tvars is the list of formal type variables for which type arguments
@@ -386,7 +386,7 @@
useVarargs,
warn);
- checkRawArgumentsAcceptable(argtypes, mt.getParameterTypes(),
+ checkRawArgumentsAcceptable(env, argtypes, mt.getParameterTypes(),
allowBoxing, useVarargs, warn);
return mt;
}
@@ -411,19 +411,21 @@
/** Check if a parameter list accepts a list of args.
*/
- boolean argumentsAcceptable(List<Type> argtypes,
+ boolean argumentsAcceptable(Env<AttrContext> env,
+ List<Type> argtypes,
List<Type> formals,
boolean allowBoxing,
boolean useVarargs,
Warner warn) {
try {
- checkRawArgumentsAcceptable(argtypes, formals, allowBoxing, useVarargs, warn);
+ checkRawArgumentsAcceptable(env, argtypes, formals, allowBoxing, useVarargs, warn);
return true;
} catch (InapplicableMethodException ex) {
return false;
}
}
- void checkRawArgumentsAcceptable(List<Type> argtypes,
+ void checkRawArgumentsAcceptable(Env<AttrContext> env,
+ List<Type> argtypes,
List<Type> formals,
boolean allowBoxing,
boolean useVarargs,
@@ -460,6 +462,14 @@
elt);
argtypes = argtypes.tail;
}
+ //check varargs element type accessibility
+ if (!isAccessible(env, elt)) {
+ Symbol location = env.enclClass.sym;
+ throw inapplicableMethodException.setMessage("inaccessible.varargs.type",
+ elt,
+ Kinds.kindName(location),
+ location);
+ }
}
return;
}
@@ -474,6 +484,10 @@
this.diagnostic = null;
this.diags = diags;
}
+ InapplicableMethodException setMessage() {
+ this.diagnostic = null;
+ return this;
+ }
InapplicableMethodException setMessage(String key) {
this.diagnostic = key != null ? diags.fragment(key) : null;
return this;
@@ -482,6 +496,10 @@
this.diagnostic = key != null ? diags.fragment(key, args) : null;
return this;
}
+ InapplicableMethodException setMessage(JCDiagnostic diag) {
+ this.diagnostic = diag;
+ return this;
+ }
public JCDiagnostic getDiagnostic() {
return diagnostic;
@@ -712,13 +730,14 @@
Type mt1 = types.memberType(site, m1);
Type mt2 = types.memberType(site, m2);
if (!types.overrideEquivalent(mt1, mt2))
- return new AmbiguityError(m1, m2);
+ return ambiguityError(m1, m2);
+
// same signature; select (a) the non-bridge method, or
// (b) the one that overrides the other, or (c) the concrete
// one, or (d) merge both abstract signatures
- if ((m1.flags() & BRIDGE) != (m2.flags() & BRIDGE)) {
+ if ((m1.flags() & BRIDGE) != (m2.flags() & BRIDGE))
return ((m1.flags() & BRIDGE) != 0) ? m2 : m1;
- }
+
// if one overrides or hides the other, use it
TypeSymbol m1Owner = (TypeSymbol)m1.owner;
TypeSymbol m2Owner = (TypeSymbol)m2.owner;
@@ -738,24 +757,24 @@
if (m2Abstract && !m1Abstract) return m1;
// both abstract or both concrete
if (!m1Abstract && !m2Abstract)
- return new AmbiguityError(m1, m2);
+ return ambiguityError(m1, m2);
// check that both signatures have the same erasure
if (!types.isSameTypes(m1.erasure(types).getParameterTypes(),
m2.erasure(types).getParameterTypes()))
- return new AmbiguityError(m1, m2);
+ return ambiguityError(m1, m2);
// both abstract, neither overridden; merge throws clause and result type
Symbol mostSpecific;
Type result2 = mt2.getReturnType();
if (mt2.tag == FORALL)
result2 = types.subst(result2, ((ForAll)mt2).tvars, ((ForAll)mt1).tvars);
- if (types.isSubtype(mt1.getReturnType(), result2)) {
+ if (types.isSubtype(mt1.getReturnType(), result2))
mostSpecific = m1;
- } else if (types.isSubtype(result2, mt1.getReturnType())) {
+ else if (types.isSubtype(result2, mt1.getReturnType()))
mostSpecific = m2;
- } else {
+ else {
// Theoretically, this can't happen, but it is possible
// due to error recovery or mixing incompatible class files
- return new AmbiguityError(m1, m2);
+ return ambiguityError(m1, m2);
}
MethodSymbol result = new MethodSymbol(
mostSpecific.flags(),
@@ -777,7 +796,7 @@
}
if (m1SignatureMoreSpecific) return m1;
if (m2SignatureMoreSpecific) return m2;
- return new AmbiguityError(m1, m2);
+ return ambiguityError(m1, m2);
case AMBIGUOUS:
AmbiguityError e = (AmbiguityError)m2;
Symbol err1 = mostSpecific(m1, e.sym, env, site, allowBoxing, useVarargs);
@@ -787,9 +806,9 @@
if (err1 instanceof AmbiguityError &&
err2 instanceof AmbiguityError &&
((AmbiguityError)err1).sym == ((AmbiguityError)err2).sym)
- return new AmbiguityError(m1, m2);
+ return ambiguityError(m1, m2);
else
- return new AmbiguityError(err1, err2);
+ return ambiguityError(err1, err2);
default:
throw new AssertionError();
}
@@ -844,6 +863,14 @@
return to;
}
}
+ //where
+ Symbol ambiguityError(Symbol m1, Symbol m2) {
+ if (((m1.flags() | m2.flags()) & CLASH) != 0) {
+ return (m1.flags() & CLASH) == 0 ? m1 : m2;
+ } else {
+ return new AmbiguityError(m1, m2);
+ }
+ }
/** Find best qualified method matching given name, type and value
* arguments.
@@ -1611,10 +1638,7 @@
names.init, argtypes,
typeargtypes, allowBoxing,
useVarargs, false);
- if ((sym.flags() & DEPRECATED) != 0 &&
- (env.info.scope.owner.flags() & DEPRECATED) == 0 &&
- env.info.scope.owner.outermostClass() != sym.outermostClass())
- chk.warnDeprecated(pos, sym);
+ chk.checkDeprecated(pos, env.info.scope.owner, sym);
return sym;
}
@@ -1928,6 +1952,9 @@
key, name, first, second);
}
boolean hasLocation = false;
+ if (location == null) {
+ location = site.tsym;
+ }
if (!location.name.isEmpty()) {
if (location.kind == PCK && !site.tsym.exists()) {
return diags.create(dkind, log.currentSource(), pos,
@@ -1945,7 +1972,7 @@
return diags.create(dkind, log.currentSource(), pos,
errKey, kindname, idname, //symbol kindname, name
typeargtypes, argtypes, //type parameters and arguments (if any)
- getLocationDiag(location)); //location kindname, type
+ getLocationDiag(location, site)); //location kindname, type
}
else {
return diags.create(dkind, log.currentSource(), pos,
@@ -1966,15 +1993,18 @@
}
return key + suffix;
}
- private JCDiagnostic getLocationDiag(Symbol location) {
- boolean isVar = location.kind == VAR;
- String key = isVar ?
- "location.1" :
- "location";
- return diags.fragment(key,
+ private JCDiagnostic getLocationDiag(Symbol location, Type site) {
+ if (location.kind == VAR) {
+ return diags.fragment("location.1",
kindName(location),
location,
- isVar ? location.type : null);
+ location.type);
+ } else {
+ return diags.fragment("location",
+ typeKindName(site),
+ site,
+ null);
+ }
}
}
@@ -2025,8 +2055,14 @@
return null;
if (isOperator(name)) {
- return diags.create(dkind, log.currentSource(),
- pos, "operator.cant.be.applied", name, argtypes);
+ boolean isUnaryOp = argtypes.size() == 1;
+ String key = argtypes.size() == 1 ?
+ "operator.cant.be.applied" :
+ "operator.cant.be.applied.1";
+ Type first = argtypes.head;
+ Type second = !isUnaryOp ? argtypes.tail.head : null;
+ return diags.create(dkind, log.currentSource(), pos,
+ key, name, first, second);
}
else {
Symbol ws = sym.asMemberOf(site, types);
--- a/langtools/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,10 +28,10 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import com.sun.tools.javac.util.Context;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
/**
* Caching implementation of FSInfo.
--- a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Mon Feb 14 16:31:21 2011 -0800
@@ -76,8 +76,6 @@
*/
public class JavacFileManager extends BaseFileManager implements StandardJavaFileManager {
- boolean useZipFileIndex;
-
public static char[] toArray(CharBuffer buffer) {
if (buffer.hasArray())
return ((CharBuffer)buffer.compact().flip()).array();
@@ -91,6 +89,9 @@
private FSInfo fsInfo;
+ private boolean useZipFileIndex;
+ private ZipFileIndexCache zipFileIndexCache;
+
private final File uninited = new File("U N I N I T E D");
private final Set<JavaFileObject.Kind> sourceOrClass =
@@ -163,7 +164,11 @@
fsInfo = FSInfo.instance(context);
- useZipFileIndex = System.getProperty("useJavaUtilZip") == null;// TODO: options.get("useJavaUtilZip") == null;
+ // retain check for system property for compatibility
+ useZipFileIndex = options.isUnset("useJavaUtilZip")
+ && System.getProperty("useJavaUtilZip") == null;
+ if (useZipFileIndex)
+ zipFileIndexCache = ZipFileIndexCache.getSharedInstance();
mmappedIO = options.isSet("mmappedIO");
ignoreSymbolFile = options.isSet("ignore.symbol.file");
@@ -526,7 +531,7 @@
archive = new ZipArchive(this, zdir);
} else {
archive = new ZipFileIndexArchive(this,
- ZipFileIndex.getZipFileIndex(zipFileName,
+ zipFileIndexCache.getZipFileIndex(zipFileName,
null,
usePreindexedCache,
preindexCacheLocation,
@@ -538,7 +543,7 @@
}
else {
archive = new ZipFileIndexArchive(this,
- ZipFileIndex.getZipFileIndex(zipFileName,
+ zipFileIndexCache.getZipFileIndex(zipFileName,
symbolFilePrefix,
usePreindexedCache,
preindexCacheLocation,
--- a/langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,11 +38,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.locks.ReentrantLock;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import java.util.zip.ZipException;
@@ -50,24 +48,28 @@
import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
import com.sun.tools.javac.file.RelativePath.RelativeFile;
-/** This class implements building of index of a zip archive and access to it's context.
- * It also uses prebuild index if available. It supports invocations where it will
- * serialize an optimized zip index file to disk.
+/**
+ * This class implements the building of index of a zip archive and access to
+ * its context. It also uses a prebuilt index if available.
+ * It supports invocations where it will serialize an optimized zip index file
+ * to disk.
*
- * In oreder to use secondary index file make sure the option "usezipindex" is in the Options object,
- * when JavacFileManager is invoked. (You can pass "-XDusezipindex" on the command line.
+ * In order to use a secondary index file, set "usezipindex" in the Options
+ * object when JavacFileManager is invoked. (You can pass "-XDusezipindex" on
+ * the command line.)
*
- * Location where to look for/generate optimized zip index files can be provided using
- * "-XDcachezipindexdir=<directory>". If this flag is not provided, the dfault location is
- * the value of the "java.io.tmpdir" system property.
+ * Location where to look for/generate optimized zip index files can be
+ * provided using "-XDcachezipindexdir=<directory>". If this flag is not
+ * provided, the default location is the value of the "java.io.tmpdir" system
+ * property.
*
- * If key "-XDwritezipindexfiles" is specified, there will be new optimized index file
- * created for each archive, used by the compiler for compilation, at location,
- * specified by "cachezipindexdir" option.
+ * If "-XDwritezipindexfiles" is specified, there will be new optimized index
+ * file created for each archive, used by the compiler for compilation, at the
+ * location specified by the "cachezipindexdir" option.
*
- * If nonBatchMode option is specified (-XDnonBatchMode) the compiler will use timestamp
- * checking to reindex the zip files if it is needed. In batch mode the timestamps are not checked
- * and the compiler uses the cached indexes.
+ * If system property nonBatchMode option is specified the compiler will use
+ * timestamp checking to reindex the zip files if it is needed. In batch mode
+ * the timestamps are not checked and the compiler uses the cached indexes.
*
* <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.
@@ -80,18 +82,18 @@
public final static long NOT_MODIFIED = Long.MIN_VALUE;
- private static Map<File, ZipFileIndex> zipFileIndexCache = new HashMap<File, ZipFileIndex>();
- private static ReentrantLock lock = new ReentrantLock();
private static boolean NON_BATCH_MODE = System.getProperty("nonBatchMode") != null;// TODO: Use -XD compiler switch for this.
- private Map<RelativeDirectory, DirectoryEntry> directories = Collections.<RelativeDirectory, DirectoryEntry>emptyMap();
- private Set<RelativeDirectory> allDirs = Collections.<RelativeDirectory>emptySet();
+ private Map<RelativeDirectory, DirectoryEntry> directories =
+ Collections.<RelativeDirectory, DirectoryEntry>emptyMap();
+ private Set<RelativeDirectory> allDirs =
+ Collections.<RelativeDirectory>emptySet();
// ZipFileIndex data entries
- private File zipFile;
+ final File zipFile;
private Reference<File> absFileRef;
- private long zipFileLastModified = NOT_MODIFIED;
+ long zipFileLastModified = NOT_MODIFIED;
private RandomAccessFile zipRandomFile;
private Entry[] entries;
@@ -99,156 +101,24 @@
private File zipIndexFile = null;
private boolean triedToReadIndex = false;
final RelativeDirectory symbolFilePrefix;
- private int symbolFilePrefixLength = 0;
+ private final int symbolFilePrefixLength;
private boolean hasPopulatedData = false;
- private long lastReferenceTimeStamp = NOT_MODIFIED;
+ long lastReferenceTimeStamp = NOT_MODIFIED;
- private boolean usePreindexedCache = false;
- private String preindexedCacheLocation = null;
+ private final boolean usePreindexedCache;
+ private final String preindexedCacheLocation;
private boolean writeIndex = false;
- private Map <String, SoftReference<RelativeDirectory>> relativeDirectoryCache =
+ private Map<String, SoftReference<RelativeDirectory>> relativeDirectoryCache =
new HashMap<String, SoftReference<RelativeDirectory>>();
- /**
- * Returns a list of all ZipFileIndex entries
- *
- * @return A list of ZipFileIndex entries, or an empty list
- */
- public static List<ZipFileIndex> getZipFileIndexes() {
- return getZipFileIndexes(false);
- }
- /**
- * Returns a list of all ZipFileIndex entries
- *
- * @param openedOnly If true it returns a list of only opened ZipFileIndex entries, otherwise
- * all ZipFileEntry(s) are included into the list.
- * @return A list of ZipFileIndex entries, or an empty list
- */
- public static List<ZipFileIndex> getZipFileIndexes(boolean openedOnly) {
- List<ZipFileIndex> zipFileIndexes = new ArrayList<ZipFileIndex>();
- lock.lock();
- try {
- zipFileIndexes.addAll(zipFileIndexCache.values());
-
- if (openedOnly) {
- for(ZipFileIndex elem : zipFileIndexes) {
- if (!elem.isOpen()) {
- zipFileIndexes.remove(elem);
- }
- }
- }
- }
- finally {
- lock.unlock();
- }
- return zipFileIndexes;
- }
-
- public boolean isOpen() {
- lock.lock();
- try {
- return zipRandomFile != null;
- }
- finally {
- lock.unlock();
- }
- }
-
- public static ZipFileIndex getZipFileIndex(File zipFile,
- RelativeDirectory symbolFilePrefix,
- boolean useCache, String cacheLocation,
- boolean writeIndex) throws IOException {
- ZipFileIndex zi = null;
- lock.lock();
- try {
- zi = getExistingZipIndex(zipFile);
-
- if (zi == null || (zi != null && zipFile.lastModified() != zi.zipFileLastModified)) {
- zi = new ZipFileIndex(zipFile, symbolFilePrefix, writeIndex,
- useCache, cacheLocation);
- zipFileIndexCache.put(zipFile, zi);
- }
- }
- finally {
- lock.unlock();
- }
- return zi;
+ public synchronized boolean isOpen() {
+ return (zipRandomFile != null);
}
- public static ZipFileIndex getExistingZipIndex(File zipFile) {
- lock.lock();
- try {
- return zipFileIndexCache.get(zipFile);
- }
- finally {
- lock.unlock();
- }
- }
-
- public static void clearCache() {
- lock.lock();
- try {
- zipFileIndexCache.clear();
- }
- finally {
- lock.unlock();
- }
- }
-
- public static void clearCache(long timeNotUsed) {
- lock.lock();
- try {
- Iterator<File> cachedFileIterator = zipFileIndexCache.keySet().iterator();
- while (cachedFileIterator.hasNext()) {
- File cachedFile = cachedFileIterator.next();
- ZipFileIndex cachedZipIndex = zipFileIndexCache.get(cachedFile);
- if (cachedZipIndex != null) {
- long timeToTest = cachedZipIndex.lastReferenceTimeStamp + timeNotUsed;
- if (timeToTest < cachedZipIndex.lastReferenceTimeStamp || // Overflow...
- System.currentTimeMillis() > timeToTest) {
- zipFileIndexCache.remove(cachedFile);
- }
- }
- }
- }
- finally {
- lock.unlock();
- }
- }
-
- public static void removeFromCache(File file) {
- lock.lock();
- try {
- zipFileIndexCache.remove(file);
- }
- finally {
- lock.unlock();
- }
- }
-
- /** Sets already opened list of ZipFileIndexes from an outside client
- * of the compiler. This functionality should be used in a non-batch clients of the compiler.
- */
- public static void setOpenedIndexes(List<ZipFileIndex>indexes) throws IllegalStateException {
- lock.lock();
- try {
- if (zipFileIndexCache.isEmpty()) {
- throw new IllegalStateException("Setting opened indexes should be called only when the ZipFileCache is empty. Call JavacFileManager.flush() before calling this method.");
- }
-
- for (ZipFileIndex zfi : indexes) {
- zipFileIndexCache.put(zfi.zipFile, zfi);
- }
- }
- finally {
- lock.unlock();
- }
- }
-
- private ZipFileIndex(File zipFile, RelativeDirectory symbolFilePrefix, boolean writeIndex,
+ ZipFileIndex(File zipFile, RelativeDirectory symbolFilePrefix, boolean writeIndex,
boolean useCache, String cacheLocation) throws IOException {
this.zipFile = zipFile;
this.symbolFilePrefix = symbolFilePrefix;
@@ -266,19 +136,22 @@
checkIndex();
}
+ @Override
public String toString() {
return "ZipFileIndex[" + zipFile + "]";
}
// Just in case...
- protected void finalize() {
+ @Override
+ protected void finalize() throws Throwable {
closeFile();
+ super.finalize();
}
private boolean isUpToDate() {
- if (zipFile != null &&
- ((!NON_BATCH_MODE) || zipFileLastModified == zipFile.lastModified()) &&
- hasPopulatedData) {
+ if (zipFile != null
+ && ((!NON_BATCH_MODE) || zipFileLastModified == zipFile.lastModified())
+ && hasPopulatedData) {
return true;
}
@@ -339,15 +212,9 @@
allDirs = Collections.<RelativeDirectory>emptySet();
}
- public void close() {
- lock.lock();
- try {
- writeIndex();
- closeFile();
- }
- finally {
- lock.unlock();
- }
+ public synchronized void close() {
+ writeIndex();
+ closeFile();
}
private void closeFile() {
@@ -361,29 +228,24 @@
}
/**
- * Returns the ZipFileIndexEntry for an absolute path, if there is one.
+ * Returns the ZipFileIndexEntry for a path, if there is one.
*/
- Entry getZipIndexEntry(RelativePath path) {
- lock.lock();
+ synchronized Entry getZipIndexEntry(RelativePath path) {
try {
checkIndex();
DirectoryEntry de = directories.get(path.dirname());
String lookFor = path.basename();
- return de == null ? null : de.getEntry(lookFor);
+ return (de == null) ? null : de.getEntry(lookFor);
}
catch (IOException e) {
return null;
}
- finally {
- lock.unlock();
- }
}
/**
- * Returns a javac List of filenames within an absolute path in the ZipFileIndex.
+ * Returns a javac List of filenames within a directory in the ZipFileIndex.
*/
- public com.sun.tools.javac.util.List<String> getFiles(RelativeDirectory path) {
- lock.lock();
+ public synchronized com.sun.tools.javac.util.List<String> getFiles(RelativeDirectory path) {
try {
checkIndex();
@@ -398,13 +260,9 @@
catch (IOException e) {
return com.sun.tools.javac.util.List.<String>nil();
}
- finally {
- lock.unlock();
- }
}
- public List<String> getDirectories(RelativeDirectory path) {
- lock.lock();
+ public synchronized List<String> getDirectories(RelativeDirectory path) {
try {
checkIndex();
@@ -420,13 +278,9 @@
catch (IOException e) {
return com.sun.tools.javac.util.List.<String>nil();
}
- finally {
- lock.unlock();
- }
}
- public Set<RelativeDirectory> getAllDirectories() {
- lock.lock();
+ public synchronized Set<RelativeDirectory> getAllDirectories() {
try {
checkIndex();
if (allDirs == Collections.EMPTY_SET) {
@@ -438,9 +292,6 @@
catch (IOException e) {
return Collections.<RelativeDirectory>emptySet();
}
- finally {
- lock.unlock();
- }
}
/**
@@ -450,8 +301,7 @@
* @param path A path within the zip.
* @return True if the path is a file or dir, false otherwise.
*/
- public boolean contains(RelativePath path) {
- lock.lock();
+ public synchronized boolean contains(RelativePath path) {
try {
checkIndex();
return getZipIndexEntry(path) != null;
@@ -459,114 +309,69 @@
catch (IOException e) {
return false;
}
- finally {
- lock.unlock();
+ }
+
+ public synchronized boolean isDirectory(RelativePath path) throws IOException {
+ // The top level in a zip file is always a directory.
+ if (path.getPath().length() == 0) {
+ lastReferenceTimeStamp = System.currentTimeMillis();
+ return true;
}
+
+ checkIndex();
+ return directories.get(path) != null;
}
- public boolean isDirectory(RelativePath path) throws IOException {
- lock.lock();
- try {
- // The top level in a zip file is always a directory.
- if (path.getPath().length() == 0) {
- lastReferenceTimeStamp = System.currentTimeMillis();
- return true;
- }
-
- checkIndex();
- return directories.get(path) != null;
- }
- finally {
- lock.unlock();
- }
+ public synchronized long getLastModified(RelativeFile path) throws IOException {
+ Entry entry = getZipIndexEntry(path);
+ if (entry == null)
+ throw new FileNotFoundException();
+ return entry.getLastModified();
}
- public long getLastModified(RelativeFile path) throws IOException {
- lock.lock();
- try {
- Entry entry = getZipIndexEntry(path);
- if (entry == null)
- throw new FileNotFoundException();
- return entry.getLastModified();
+ public synchronized int length(RelativeFile path) throws IOException {
+ Entry entry = getZipIndexEntry(path);
+ if (entry == null)
+ throw new FileNotFoundException();
+
+ if (entry.isDir) {
+ return 0;
}
- finally {
- lock.unlock();
+
+ byte[] header = getHeader(entry);
+ // entry is not compressed?
+ if (get2ByteLittleEndian(header, 8) == 0) {
+ return entry.compressedSize;
+ } else {
+ return entry.size;
}
}
- public int length(RelativeFile path) throws IOException {
- lock.lock();
- try {
- Entry entry = getZipIndexEntry(path);
- if (entry == null)
- throw new FileNotFoundException();
-
- if (entry.isDir) {
- return 0;
- }
-
- byte[] header = getHeader(entry);
- // entry is not compressed?
- if (get2ByteLittleEndian(header, 8) == 0) {
- return entry.compressedSize;
- } else {
- return entry.size;
- }
- }
- finally {
- lock.unlock();
- }
- }
-
- public byte[] read(RelativeFile path) throws IOException {
- lock.lock();
- try {
- Entry entry = getZipIndexEntry(path);
- if (entry == null)
- throw new FileNotFoundException("Path not found in ZIP: " + path.path);
- return read(entry);
- }
- finally {
- lock.unlock();
- }
+ public synchronized byte[] read(RelativeFile path) throws IOException {
+ Entry entry = getZipIndexEntry(path);
+ if (entry == null)
+ throw new FileNotFoundException("Path not found in ZIP: " + path.path);
+ return read(entry);
}
- byte[] read(Entry entry) throws IOException {
- lock.lock();
- try {
- openFile();
- byte[] result = readBytes(entry);
- closeFile();
- return result;
- }
- finally {
- lock.unlock();
- }
+ synchronized byte[] read(Entry entry) throws IOException {
+ openFile();
+ byte[] result = readBytes(entry);
+ closeFile();
+ return result;
}
- public int read(RelativeFile path, byte[] buffer) throws IOException {
- lock.lock();
- try {
- Entry entry = getZipIndexEntry(path);
- if (entry == null)
- throw new FileNotFoundException();
- return read(entry, buffer);
- }
- finally {
- lock.unlock();
- }
+ public synchronized int read(RelativeFile path, byte[] buffer) throws IOException {
+ Entry entry = getZipIndexEntry(path);
+ if (entry == null)
+ throw new FileNotFoundException();
+ return read(entry, buffer);
}
- int read(Entry entry, byte[] buffer)
+ synchronized int read(Entry entry, byte[] buffer)
throws IOException {
- lock.lock();
- try {
- int result = readBytes(entry, buffer);
- return result;
- }
- finally {
- lock.unlock();
- }
+ int result = readBytes(entry, buffer);
+ return result;
}
private byte[] readBytes(Entry entry) throws IOException {
@@ -638,21 +443,20 @@
/*
* Inflate using the java.util.zip.Inflater class
*/
- private static Inflater inflater;
+ private SoftReference<Inflater> inflaterRef;
private int inflate(byte[] src, byte[] dest) {
+ Inflater inflater = (inflaterRef == null ? null : inflaterRef.get());
// construct the inflater object or reuse an existing one
if (inflater == null)
- inflater = new Inflater(true);
+ inflaterRef = new SoftReference<Inflater>(inflater = new Inflater(true));
- synchronized (inflater) {
- inflater.reset();
- inflater.setInput(src);
- try {
- return inflater.inflate(dest);
- } catch (DataFormatException ex) {
- return -1;
- }
+ inflater.reset();
+ inflater.setInput(src);
+ try {
+ return inflater.inflate(dest);
+ } catch (DataFormatException ex) {
+ return -1;
}
}
@@ -855,14 +659,10 @@
* @return long
*/
public long getZipFileLastModified() throws IOException {
- lock.lock();
- try {
+ synchronized (this) {
checkIndex();
return zipFileLastModified;
}
- finally {
- lock.unlock();
- }
}
/** ------------------------------------------------------------------------
@@ -1028,8 +828,7 @@
}
boolean ret = false;
- lock.lock();
- try {
+ synchronized (this) {
triedToReadIndex = true;
RandomAccessFile raf = null;
try {
@@ -1071,9 +870,6 @@
readFromIndex = true;
}
}
- finally {
- lock.unlock();
- }
return ret;
}
@@ -1144,8 +940,8 @@
raf.seek(currFP);
// Now write each of the files in the DirectoryEntry
- List<Entry> entries = de.getEntriesAsCollection();
- for (Entry zfie : entries) {
+ List<Entry> list = de.getEntriesAsCollection();
+ for (Entry zfie : list) {
// Write the name bytes
byte [] zfieNameBytes = zfie.name.getBytes("UTF-8");
int zfieNameBytesLen = zfieNameBytes.length;
@@ -1191,13 +987,9 @@
}
public boolean writeZipIndex() {
- lock.lock();
- try {
+ synchronized (this) {
return writeIndex();
}
- finally {
- lock.unlock();
- }
}
private File getIndexFile() {
@@ -1328,7 +1120,7 @@
return hash;
}
-
+ @Override
public String toString() {
return isDir ? ("Dir:" + dir + " : " + name) :
(dir + ":" + name);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndexCache.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.file;
+
+import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
+import com.sun.tools.javac.util.Context;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+
+/** A cache for ZipFileIndex objects. */
+public class ZipFileIndexCache {
+
+ private final Map<File, ZipFileIndex> map =
+ new HashMap<File, ZipFileIndex>();
+
+ /** Get a shared instance of the cache. */
+ private static ZipFileIndexCache sharedInstance;
+ public synchronized static ZipFileIndexCache getSharedInstance() {
+ if (sharedInstance == null)
+ sharedInstance = new ZipFileIndexCache();
+ return sharedInstance;
+ }
+
+ /** Get a context-specific instance of a cache. */
+ public static ZipFileIndexCache instance(Context context) {
+ ZipFileIndexCache instance = context.get(ZipFileIndexCache.class);
+ if (instance == null)
+ context.put(ZipFileIndexCache.class, instance = new ZipFileIndexCache());
+ return instance;
+ }
+
+ /**
+ * Returns a list of all ZipFileIndex entries
+ *
+ * @return A list of ZipFileIndex entries, or an empty list
+ */
+ public List<ZipFileIndex> getZipFileIndexes() {
+ return getZipFileIndexes(false);
+ }
+
+ /**
+ * Returns a list of all ZipFileIndex entries
+ *
+ * @param openedOnly If true it returns a list of only opened ZipFileIndex entries, otherwise
+ * all ZipFileEntry(s) are included into the list.
+ * @return A list of ZipFileIndex entries, or an empty list
+ */
+ public synchronized List<ZipFileIndex> getZipFileIndexes(boolean openedOnly) {
+ List<ZipFileIndex> zipFileIndexes = new ArrayList<ZipFileIndex>();
+
+ zipFileIndexes.addAll(map.values());
+
+ if (openedOnly) {
+ for(ZipFileIndex elem : zipFileIndexes) {
+ if (!elem.isOpen()) {
+ zipFileIndexes.remove(elem);
+ }
+ }
+ }
+
+ return zipFileIndexes;
+ }
+
+ public synchronized ZipFileIndex getZipFileIndex(File zipFile,
+ RelativeDirectory symbolFilePrefix,
+ boolean useCache, String cacheLocation,
+ boolean writeIndex) throws IOException {
+ ZipFileIndex zi = getExistingZipIndex(zipFile);
+
+ if (zi == null || (zi != null && zipFile.lastModified() != zi.zipFileLastModified)) {
+ zi = new ZipFileIndex(zipFile, symbolFilePrefix, writeIndex,
+ useCache, cacheLocation);
+ map.put(zipFile, zi);
+ }
+ return zi;
+ }
+
+ public synchronized ZipFileIndex getExistingZipIndex(File zipFile) {
+ return map.get(zipFile);
+ }
+
+ public synchronized void clearCache() {
+ map.clear();
+ }
+
+ public synchronized void clearCache(long timeNotUsed) {
+ Iterator<File> cachedFileIterator = map.keySet().iterator();
+ while (cachedFileIterator.hasNext()) {
+ File cachedFile = cachedFileIterator.next();
+ ZipFileIndex cachedZipIndex = map.get(cachedFile);
+ if (cachedZipIndex != null) {
+ long timeToTest = cachedZipIndex.lastReferenceTimeStamp + timeNotUsed;
+ if (timeToTest < cachedZipIndex.lastReferenceTimeStamp || // Overflow...
+ System.currentTimeMillis() > timeToTest) {
+ map.remove(cachedFile);
+ }
+ }
+ }
+ }
+
+ public synchronized void removeFromCache(File file) {
+ map.remove(file);
+ }
+
+ /** Sets already opened list of ZipFileIndexes from an outside client
+ * of the compiler. This functionality should be used in a non-batch clients of the compiler.
+ */
+ public synchronized void setOpenedIndexes(List<ZipFileIndex>indexes) throws IllegalStateException {
+ if (map.isEmpty()) {
+ String msg =
+ "Setting opened indexes should be called only when the ZipFileCache is empty. "
+ + "Call JavacFileManager.flush() before calling this method.";
+ throw new IllegalStateException(msg);
+ }
+
+ for (ZipFileIndex zfi : indexes) {
+ map.put(zfi.zipFile, zfi);
+ }
+ }
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Feb 14 16:31:21 2011 -0800
@@ -138,9 +138,6 @@
/** The symbol table. */
Symtab syms;
- /** The scope counter */
- Scope.ScopeCounter scopeCounter;
-
Types types;
/** The name table. */
@@ -264,7 +261,6 @@
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)
@@ -1321,7 +1317,9 @@
sym.flags_field |= PROPRIETARY;
else
proxies.append(proxy);
- if (majorVersion >= V51.major && proxy.type.tsym == syms.polymorphicSignatureType.tsym) {
+ if (majorVersion >= V51.major &&
+ (proxy.type.tsym == syms.polymorphicSignatureType.tsym ||
+ proxy.type.tsym == syms.transientPolymorphicSignatureType.tsym)) {
sym.flags_field |= POLYMORPHIC_SIGNATURE;
}
}
@@ -1879,7 +1877,7 @@
ClassType ct = (ClassType)c.type;
// allocate scope for members
- c.members_field = new Scope.ClassScope(c, scopeCounter);
+ c.members_field = new Scope(c);
// prepare type variable table
typevars = typevars.dup(currentOwner);
--- a/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Mon Feb 14 16:31:21 2011 -0800
@@ -39,7 +39,6 @@
import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.Attributes;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
@@ -223,9 +222,7 @@
Path path = pathIter.next();
if (pathIter.hasNext())
throw new IllegalArgumentException("path too long for directory");
- if (!path.exists())
- throw new FileNotFoundException(path + ": does not exist");
- else if (!isDirectory(path))
+ if (!isDirectory(path))
throw new IOException(path + ": not a directory");
}
@@ -326,7 +323,7 @@
private void list(Path path, String packageName, final Set<Kind> kinds,
boolean recurse, final ListBuffer<JavaFileObject> results)
throws IOException {
- if (!path.exists())
+ if (!Files.exists(path))
return;
final Path pathDir;
@@ -341,7 +338,7 @@
String sep = path.getFileSystem().getSeparator();
Path packageDir = packageName.isEmpty() ? pathDir
: pathDir.resolve(packageName.replace(".", sep));
- if (!packageDir.exists())
+ if (!Files.exists(packageDir))
return;
/* Alternate impl of list, superceded by use of Files.walkFileTree */
@@ -353,7 +350,7 @@
// DirectoryStream<Path> ds = dir.newDirectoryStream();
// try {
// for (Path p: ds) {
-// String name = p.getName().toString();
+// String name = p.getFileName().toString();
// if (isDirectory(p)) {
// if (recurse && SourceVersion.isIdentifier(name)) {
// queue.add(p);
@@ -376,7 +373,7 @@
new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
- Path name = dir.getName();
+ Path name = dir.getFileName();
if (name == null || SourceVersion.isIdentifier(name.toString())) // JSR 292?
return FileVisitResult.CONTINUE;
else
@@ -385,7 +382,7 @@
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
- if (attrs.isRegularFile() && kinds.contains(getKind(file.getName().toString()))) {
+ if (attrs.isRegularFile() && kinds.contains(getKind(file.getFileName().toString()))) {
JavaFileObject fe =
PathFileObject.createDirectoryPathFileObject(
JavacPathFileManager.this, file, pathDir);
@@ -431,13 +428,13 @@
for (Path p: getLocation(location)) {
if (isDirectory(p)) {
Path f = resolve(p, relativePath);
- if (f.exists())
+ if (Files.exists(f))
return PathFileObject.createDirectoryPathFileObject(this, f, p);
} else {
FileSystem fs = getFileSystem(p);
if (fs != null) {
Path file = getPath(fs, relativePath);
- if (file.exists())
+ if (Files.exists(file))
return PathFileObject.createJarPathFileObject(this, file);
}
}
@@ -504,7 +501,7 @@
private FileSystem getFileSystem(Path p) throws IOException {
FileSystem fs = fileSystems.get(p);
if (fs == null) {
- fs = FileSystems.newFileSystem(p, Collections.<String,Void>emptyMap(), null);
+ fs = FileSystems.newFileSystem(p, null);
fileSystems.put(p, fs);
}
return fs;
@@ -530,7 +527,7 @@
}
private static boolean isDirectory(Path path) throws IOException {
- BasicFileAttributes attrs = Attributes.readBasicFileAttributes(path);
+ BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
return attrs.isDirectory();
}
--- a/langtools/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java Mon Feb 14 16:31:21 2011 -0800
@@ -38,7 +38,6 @@
import java.nio.charset.CharsetDecoder;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.attribute.Attributes;
import java.nio.file.attribute.BasicFileAttributes;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
@@ -153,7 +152,7 @@
@Override
public Kind getKind() {
- return BaseFileManager.getKind(path.getName().toString());
+ return BaseFileManager.getKind(path.getFileName().toString());
}
@Override
@@ -164,14 +163,14 @@
return false;
}
String sn = simpleName + kind.extension;
- String pn = path.getName().toString();
+ String pn = path.getFileName().toString();
if (pn.equals(sn)) {
return true;
}
if (pn.equalsIgnoreCase(sn)) {
try {
// allow for Windows
- return path.toRealPath(false).getName().toString().equals(sn);
+ return path.toRealPath(false).getFileName().toString().equals(sn);
} catch (IOException e) {
}
}
@@ -200,13 +199,13 @@
@Override
public InputStream openInputStream() throws IOException {
- return path.newInputStream();
+ return Files.newInputStream(path);
}
@Override
public OutputStream openOutputStream() throws IOException {
ensureParentDirectoriesExist();
- return path.newOutputStream();
+ return Files.newOutputStream(path);
}
@Override
@@ -242,14 +241,13 @@
@Override
public Writer openWriter() throws IOException {
ensureParentDirectoriesExist();
- return new OutputStreamWriter(path.newOutputStream(), fileManager.getEncodingName());
+ return new OutputStreamWriter(Files.newOutputStream(path), fileManager.getEncodingName());
}
@Override
public long getLastModified() {
try {
- BasicFileAttributes attrs = Attributes.readBasicFileAttributes(path);
- return attrs.lastModifiedTime().toMillis();
+ return Files.getLastModifiedTime(path).toMillis();
} catch (IOException e) {
return -1;
}
@@ -258,7 +256,7 @@
@Override
public boolean delete() {
try {
- path.delete();
+ Files.delete(path);
return true;
} catch (IOException e) {
return false;
@@ -267,7 +265,7 @@
public boolean isSameFile(PathFileObject other) {
try {
- return path.isSameFile(other.path);
+ return Files.isSameFile(path, other.path);
} catch (IOException e) {
return false;
}
@@ -296,8 +294,7 @@
private long size() {
try {
- BasicFileAttributes attrs = Attributes.readBasicFileAttributes(path);
- return attrs.size();
+ return Files.size(path);
} catch (IOException e) {
return -1;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Feb 14 16:31:21 2011 -0800
@@ -142,7 +142,7 @@
*/
boolean allowAnnotations;
- /** Switch: should we recognize automatic resource management?
+ /** Switch: should we recognize try-with-resources?
*/
boolean allowTWR;
@@ -1639,7 +1639,7 @@
* | WHILE ParExpression Statement
* | DO Statement WHILE ParExpression ";"
* | TRY Block ( Catches | [Catches] FinallyPart )
- * | TRY "(" ResourceSpecification ")" Block [Catches] [FinallyPart]
+ * | TRY "(" ResourceSpecification ";"opt ")" Block [Catches] [FinallyPart]
* | SWITCH ParExpression "{" SwitchBlockStatementGroups "}"
* | SYNCHRONIZED ParExpression Block
* | RETURN [Expression] ";"
@@ -2182,31 +2182,24 @@
ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
defs.append(resource());
while (S.token() == SEMI) {
- // All but last of multiple declarators subsume a semicolon
+ // All but last of multiple declarators must subsume a semicolon
storeEnd(defs.elems.last(), S.endPos());
+ int semiColonPos = S.pos();
S.nextToken();
+ if (S.token() == RPAREN) { // Optional trailing semicolon
+ // after last resource
+ break;
+ }
defs.append(resource());
}
return defs.toList();
}
- /** Resource =
- * VariableModifiers Type VariableDeclaratorId = Expression
- * | Expression
+ /** Resource = VariableModifiersOpt Type VariableDeclaratorId = Expression
*/
JCTree resource() {
- int pos = S.pos();
- if (S.token() == FINAL || S.token() == MONKEYS_AT) {
- return variableDeclaratorRest(pos, optFinal(0), parseType(),
- ident(), true, null);
- } else {
- JCExpression t = term(EXPR | TYPE);
- if ((lastmode & TYPE) != 0 && S.token() == IDENTIFIER)
- return variableDeclaratorRest(pos, toP(F.at(pos).Modifiers(Flags.FINAL)), t,
- ident(), true, null);
- else
- return t;
- }
+ return variableDeclaratorRest(S.pos(), optFinal(Flags.FINAL),
+ parseType(), ident(), true, null);
}
/** CompilationUnit = [ { "@" Annotation } PACKAGE Qualident ";"] {ImportDeclaration} {TypeDeclaration}
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Mon Feb 14 16:31:21 2011 -0800
@@ -138,7 +138,7 @@
source = fac.source;
allowBinaryLiterals = source.allowBinaryLiterals();
allowHexFloats = source.allowHexFloats();
- allowUnderscoresInLiterals = source.allowBinaryLiterals();
+ allowUnderscoresInLiterals = source.allowUnderscoresInLiterals();
}
private static final boolean hexFloatsWork = hexFloatsWork();
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Feb 14 16:31:21 2011 -0800
@@ -23,258 +23,437 @@
# questions.
#
+# Messages in this file which use "placeholders" for values (e.g. {0}, {1})
+# are preceded by a stylized comment describing the type of the corresponding
+# values.
+# The types currently in use are
+#
+# boolean true or false
+# file name the name of an input file; e.g. MyFile.java
+# message segment a sub-message; see compiler.misc.*
+# modifier a Java modifier; e.g. public, private, protected
+# name a name, typically a Java identifier
+# number an integer
+# option name the name of a command line option
+# source version a source version number, such as 1.5, 1.6, 1.7
+# string a general string
+# symbol the name of a declared type
+# symbol kind a description of the kind of a declaration; see compiler.misc.kindname.*
+# token the name of a non-terminal in source code; see compiler.misc.token.*
+# type a Java type; e.g. int, X, X<T>
+# unused the value is not used in this message
+#
+# list of X a comma-separated list of items; e.g. list of type
+# X or Y alternation; e.g. message segment or type
+# set of X a comma-separated collection of items; e.g. set of modifier
+#
+# These may be composed: e.g. list of type or message segment
+#
+# These comments are verified by the jtreg test test/tools/javac/diags/MessageInfo,
+# using info derived from the collected set of examples in test/tools/javac/diags/examples.
+# MessageInfo can also be run as a standalone utility providing more facilities
+# for manipulating this file. For more details, see MessageInfo.java.
+
##
## errors
##
+# 0: symbol
compiler.err.abstract.cant.be.instantiated=\
{0} is abstract; cannot be instantiated
+
compiler.err.abstract.meth.cant.have.body=\
abstract methods cannot have a body
+
compiler.err.already.annotated=\
{0} {1} has already been annotated
+
+# 0: symbol, 1: symbol
compiler.err.already.defined=\
{0} is already defined in {1}
+
+# 0: string
compiler.err.already.defined.single.import=\
{0} is already defined in a single-type import
+
+# 0: string
compiler.err.already.defined.static.single.import=\
{0} is already defined in a static single-type import
+
compiler.err.already.defined.this.unit=\
{0} is already defined in this compilation unit
+
+# 0: type, 1: list of name
compiler.err.annotation.missing.default.value=\
annotation {0} is missing value for the attribute {1}
+
+# 0: type, 1: list of name
compiler.err.annotation.missing.default.value.1=\
annotation {0} is missing values for attributes {1}
+
+# 0: type
compiler.err.annotation.not.valid.for.type=\
annotation not valid for a value of type {0}
+
compiler.err.annotation.type.not.applicable=\
annotation type not applicable to this kind of declaration
+
compiler.err.annotation.value.must.be.annotation=\
annotation value must be an annotation
+
compiler.err.annotation.value.must.be.class.literal=\
annotation value must be a class literal
+
compiler.err.annotation.value.must.be.name.value=\
annotation values must be of the form ''name=value''
+
compiler.err.annotation.value.not.allowable.type=\
annotation value not of an allowable type
+
compiler.err.anon.class.impl.intf.no.args=\
anonymous class implements interface; cannot have arguments
+
compiler.err.anon.class.impl.intf.no.typeargs=\
anonymous class implements interface; cannot have type arguments
+
compiler.err.anon.class.impl.intf.no.qual.for.new=\
anonymous class implements interface; cannot have qualifier for new
+
+# 0: symbol, 1: symbol, 2: symbol
compiler.err.array.and.varargs=\
cannot declare both {0} and {1} in {2}
+
compiler.err.array.dimension.missing=\
array dimension missing
+
+# 0: type
compiler.err.array.req.but.found=\
array required, but {0} found
compiler.err.assignment.from.super-bound=\
assigning from wildcard {0}
+
compiler.err.assignment.to.extends-bound=\
assigning to wildcard {0}
+
compiler.err.attribute.value.must.be.constant=\
attribute value must be constant
compiler.err.break.outside.switch.loop=\
break outside switch or loop
+# 0: name
compiler.err.call.must.be.first.stmt.in.ctor=\
call to {0} must be first statement in constructor
+
compiler.err.cant.apply.symbol=\
{0} {1} in {4} {5} cannot be applied to given types\n\
required: {2}\n\
found: {3}
+
+# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment
compiler.err.cant.apply.symbol.1=\
{0} {1} in {4} {5} cannot be applied to given types;\n\
required: {2}\n\
found: {3}\n\
reason: {6}
+
+# 0: symbol kind, 1: name, 2: list of type
compiler.err.cant.apply.symbols=\
no suitable {0} found for {1}({2})
+
+# 0: symbol
compiler.err.cant.assign.val.to.final.var=\
cannot assign a value to final variable {0}
+
+# 0: type
compiler.err.cant.deref=\
{0} cannot be dereferenced
+
compiler.err.cant.extend.intf.annotation=\
''extends'' not allowed for @interfaces
+
+# 0: symbol
compiler.err.cant.inherit.from.final=\
cannot inherit from final {0}
+
+# 0: symbol
compiler.err.cant.ref.before.ctor.called=\
cannot reference {0} before supertype constructor has been called
+
compiler.err.cant.ret.val.from.meth.decl.void=\
cannot return a value from method whose result type is void
+
compiler.err.cant.select.static.class.from.param.type=\
cannot select a static class from a parameterized type
+
+# 0: symbol, 1: string, 2: string
compiler.err.cant.inherit.diff.arg=\
{0} cannot be inherited with different arguments: <{1}> and <{2}>
+
compiler.err.catch.without.try=\
''catch'' without ''try''
+
+# 0: symbol kind, 1: symbol
compiler.err.clash.with.pkg.of.same.name=\
{0} {1} clashes with package of same name
+
compiler.err.const.expr.req=\
constant expression required
+
compiler.err.cont.outside.loop=\
continue outside of loop
+
+# 0: symbol
compiler.err.cyclic.inheritance=\
cyclic inheritance involving {0}
+
compiler.err.cyclic.annotation.element=\
cyclic annotation element type
+
+# 0: unused
compiler.err.call.to.super.not.allowed.in.enum.ctor=\
call to super not allowed in enum constructor
+
+# 0: type
compiler.err.no.superclass=\
{0} has no superclass
compiler.err.wrong.target.for.polymorphic.signature.definition=\
MethodHandle API building requires -target 7 runtimes or better; current is -target {0}
+# 0: symbol, 1: type, 2: symbol, 3: type, 4: unused
compiler.err.concrete.inheritance.conflict=\
methods {0} from {1} and {2} from {3} are inherited with the same signature
compiler.err.default.allowed.in.intf.annotation.member=\
default value only allowed in an @interface member
+
+# 0: symbol
compiler.err.doesnt.exist=\
package {0} does not exist
+
compiler.err.duplicate.annotation=\
duplicate annotation
+
+# 0: name, 1: type
compiler.err.duplicate.annotation.member.value=\
duplicate annotation member value {0} in {1}
+
+# 0: name
compiler.err.duplicate.class=\
duplicate class: {0}
+
compiler.err.duplicate.case.label=\
duplicate case label
+
compiler.err.duplicate.default.label=\
duplicate default label
compiler.err.else.without.if=\
''else'' without ''if''
+
compiler.err.empty.char.lit=\
empty character literal
+
+# 0: symbol
compiler.err.encl.class.required=\
an enclosing instance that contains {0} is required
+
compiler.err.enum.annotation.must.be.enum.constant=\
an enum annotation value must be an enum constant
compiler.err.enum.cant.be.instantiated=\
enum types may not be instantiated
+
compiler.err.enum.label.must.be.unqualified.enum=\
an enum switch case label must be the unqualified name of an enumeration constant
+
compiler.err.enum.no.subclassing=\
classes cannot directly extend java.lang.Enum
+
compiler.err.enum.types.not.extensible=\
enum types are not extensible
+
compiler.err.enum.no.finalize=\
enums cannot have finalize methods
+
+# 0: file name, 1: string
compiler.err.error.reading.file=\
error reading {0}; {1}
+
+# 0: type
compiler.err.except.already.caught=\
exception {0} has already been caught
+
+# 0: type
compiler.err.except.never.thrown.in.try=\
exception {0} is never thrown in body of corresponding try statement
+# 0: symbol
compiler.err.final.parameter.may.not.be.assigned=\
final parameter {0} may not be assigned
+
+# 0: symbol
compiler.err.try.resource.may.not.be.assigned=\
auto-closeable resource {0} may not be assigned
+
+# 0: symbol
compiler.err.multicatch.parameter.may.not.be.assigned=\
multi-catch parameter {0} may not be assigned
+
compiler.err.finally.without.try=\
''finally'' without ''try''
+
+# 0: type, 1: message segment
compiler.err.foreach.not.applicable.to.type=\
for-each not applicable to expression type\n\
required: {1}\n\
found: {0}
+
compiler.err.fp.number.too.large=\
floating point number too large
+
compiler.err.fp.number.too.small=\
floating point number too small
compiler.err.generic.array.creation=\
generic array creation
+
compiler.err.generic.throwable=\
a generic class may not extend java.lang.Throwable
+# 0: symbol
compiler.err.icls.cant.have.static.decl=\
Illegal static declaration in inner class {0}\n\
modifier \''static\'' is only allowed in constant variable declarations
+
+# 0: string
compiler.err.illegal.char=\
illegal character: \\{0}
+
compiler.err.illegal.char.for.encoding=\
unmappable character for encoding {0}
+
+# 0: set of modifier, 1: set of modifier
compiler.err.illegal.combination.of.modifiers=\
illegal combination of modifiers: {0} and {1}
+
compiler.err.illegal.enum.static.ref=\
illegal reference to static field from initializer
+
compiler.err.illegal.esc.char=\
illegal escape character
+
compiler.err.illegal.forward.ref=\
illegal forward reference
+
+# 0: symbol
compiler.warn.forward.ref=\
reference to variable ''{0}'' before it has been initialized
+
compiler.err.illegal.self.ref=\
self-reference in initializer
+
+# 0: symbol
compiler.warn.self.ref=\
self-reference in initializer of variable ''{0}''
+
compiler.err.illegal.generic.type.for.instof=\
illegal generic type for instanceof
+
+# 0: type
compiler.err.illegal.initializer.for.type=\
illegal initializer for {0}
+
compiler.err.illegal.line.end.in.char.lit=\
illegal line end in character literal
+
compiler.err.illegal.nonascii.digit=\
illegal non-ASCII digit
+
compiler.err.illegal.underscore=\
illegal underscore
+
+# 0: symbol
compiler.err.illegal.qual.not.icls=\
illegal qualifier; {0} is not an inner class
+
compiler.err.illegal.start.of.expr=\
illegal start of expression
+
compiler.err.illegal.start.of.type=\
illegal start of type
+
compiler.err.illegal.unicode.esc=\
illegal unicode escape
+
+# 0: symbol
compiler.err.import.requires.canonical=\
import requires canonical name for {0}
+
compiler.err.improperly.formed.type.param.missing=\
improperly formed type, some parameters are missing
+
compiler.err.improperly.formed.type.inner.raw.param=\
improperly formed type, type arguments given on a raw type
+
+# 0: type, 1: type
compiler.err.incomparable.types=\
incomparable types: {0} and {1}
+
+# 0: number
compiler.err.int.number.too.large=\
integer number too large: {0}
+
compiler.err.internal.error.cant.instantiate=\
internal error; cannot instantiate {0} at {1} to ({2})
+
compiler.err.intf.annotation.members.cant.have.params=\
@interface members may not have parameters
+
compiler.err.intf.annotation.cant.have.type.params=\
@interface may not have type parameters
+
compiler.err.intf.annotation.members.cant.have.type.params=\
@interface members may not have type parameters
+
+# 0: symbol, 1: type
compiler.err.intf.annotation.member.clash=\
@interface member clashes with method ''{0}'' in {1}
+
compiler.err.intf.expected.here=\
interface expected here
+
compiler.err.intf.meth.cant.have.body=\
interface methods cannot have body
+
compiler.err.invalid.annotation.member.type=\
invalid type for annotation member
+
compiler.err.invalid.binary.number=\
binary numbers must contain at least one binary digit
+
compiler.err.invalid.hex.number=\
hexadecimal numbers must contain at least one hexadecimal digit
+
compiler.err.invalid.meth.decl.ret.type.req=\
invalid method declaration; return type required
+
compiler.err.varargs.and.old.array.syntax=\
legacy array notation not allowed on variable-arity parameter
+# 0: name
compiler.err.label.already.in.use=\
label {0} already in use
+
+# 0: symbol
compiler.err.local.var.accessed.from.icls.needs.final=\
local variable {0} is accessed from within inner class; needs to be declared final
+
compiler.err.local.enum=\
enum types must not be local
+
compiler.err.cannot.create.array.with.type.arguments=\
cannot create array with type arguments
@@ -285,79 +464,131 @@
#
compiler.err.limit.code=\
code too large
+
compiler.err.limit.code.too.large.for.try.stmt=\
code too large for try statement
+
compiler.err.limit.dimensions=\
array type has too many dimensions
+
compiler.err.limit.locals=\
too many local variables
+
compiler.err.limit.parameters=\
too many parameters
+
compiler.err.limit.pool=\
too many constants
+
compiler.err.limit.pool.in.class=\
too many constants in class {0}
+
compiler.err.limit.stack=\
code requires too much stack
+
compiler.err.limit.string=\
constant string too long
+
compiler.err.limit.string.overflow=\
UTF8 representation for string \"{0}...\" is too long for the constant pool
compiler.err.malformed.fp.lit=\
malformed floating point literal
+
compiler.err.method.does.not.override.superclass=\
method does not override or implement a method from a supertype
+
compiler.err.missing.meth.body.or.decl.abstract=\
missing method body, or declare abstract
+
compiler.err.missing.ret.stmt=\
missing return statement
+
compiler.err.missing.ret.val=\
missing return value
+
+# 0: set of modifier
compiler.err.mod.not.allowed.here=\
modifier {0} not allowed here
+
compiler.err.intf.not.allowed.here=\
interface not allowed here
+
compiler.err.enums.must.be.static=\
enum declarations allowed only in static contexts
+# 0: symbol, 1: symbol
compiler.err.name.clash.same.erasure=\
name clash: {0} and {1} have the same erasure
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: unused, 5: unused
compiler.err.name.clash.same.erasure.no.override=\
name clash: {0} in {1} and {2} in {3} have the same erasure, yet neither overrides the other
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: symbol, 5: symbol
+compiler.err.name.clash.same.erasure.no.override.1=\
+ name clash: {0} in {1} overrides a method whose erasure is the same as another method, yet neither overrides the other\n\
+ first method: {2} in {3}\n\
+ second method: {4} in {5}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.err.name.clash.same.erasure.no.hide=\
+ name clash: {0} in {1} and {2} in {3} have the same erasure, yet neither hides the other
+
compiler.err.name.reserved.for.internal.use=\
{0} is reserved for internal use
+
compiler.err.native.meth.cant.have.body=\
native methods cannot have a body
+
+# 0: type, 1: type
compiler.err.neither.conditional.subtype=\
-incompatible types for ?: neither is a subtype of the other\n\
-second operand: {0}\n\
-third operand : {1}
+ incompatible types for ?: neither is a subtype of the other\n\
+ second operand: {0}\n\
+ third operand : {1}
+
compiler.err.new.not.allowed.in.annotation=\
''new'' not allowed in an annotation
+
compiler.err.no.annotation.member=\
no annotation member {0} in {1}
+
compiler.err.no.encl.instance.of.type.in.scope=\
no enclosing instance of type {0} is in scope
+
compiler.err.no.intf.expected.here=\
no interface expected here
+
compiler.err.no.match.entry=\
{0} has no match in entry in {1}; required {2}
+
compiler.err.not.annotation.type=\
{0} is not an annotation type
+
+# 0: symbol, 1: symbol
compiler.err.not.def.access.class.intf.cant.access=\
{0} in {1} is defined in an inaccessible class or interface
+
+# 0: symbol, 1: symbol
compiler.err.not.def.public.cant.access=\
{0} is not public in {1}; cannot be accessed from outside package
+
+# 0: name
compiler.err.not.loop.label=\
not a loop label: {0}
+
compiler.err.not.stmt=\
not a statement
+
+# 0: symbol
compiler.err.not.encl.class=\
not an enclosing class: {0}
+# 0: name, 1: type, 2: unused
compiler.err.operator.cant.be.applied=\
bad operand type {1} for unary operator ''{0}''
+
+# 0: name, 1: type, 2: type
compiler.err.operator.cant.be.applied.1=\
bad operand types for binary operator ''{0}''\n\
first type: {1}\n\
@@ -365,6 +596,8 @@
compiler.err.pkg.annotations.sb.in.package-info.java=\
package annotations should be in file package-info.java
+
+# 0: symbol
compiler.err.pkg.clashes.with.class.of.same.name=\
package {0} clashes with class of same name
@@ -374,18 +607,21 @@
# Errors related to annotation processing
compiler.err.proc.cant.access=\
-cannot access {0}\n\
-{1}\n\
-Consult the following stack trace for details.\n\
-{2}
-
+ cannot access {0}\n\
+ {1}\n\
+ Consult the following stack trace for details.\n\
+ {2}
+
+# 0: string
compiler.err.proc.cant.find.class=\
Could not find class file for ''{0}''.
# Print a client-generated error message; assumed to be localized, no translation required
+# 0: string
compiler.err.proc.messager=\
{0}
+# 0: list of string
compiler.err.proc.no.explicit.annotation.processing.requested=\
Class names, ''{0}'', are only accepted if annotation processing is explicitly requested
@@ -396,15 +632,18 @@
compiler.err.proc.processor.bad.option.name=\
Bad option name ''{0}'' provided by processor ''{1}''
+# 0: string
compiler.err.proc.processor.cant.instantiate=\
Could not instantiate an instance of processor ''{0}''
compiler.err.proc.processor.constructor.error=\
Exception thrown while constructing Processor object: {0}
+# 0: string
compiler.err.proc.processor.not.found=\
Annotation processor ''{0}'' not found
+# 0: string
compiler.err.proc.processor.wrong.type=\
Annotation processor ''{0}'' does not implement javax.annotation.processing.Processor
@@ -417,127 +656,201 @@
compiler.err.proc.cant.create.loader=\
Could not create class loader for annotation processors: {0}
+# 0: unused
compiler.err.qualified.new.of.static.class=\
qualified new of static class
compiler.err.recursive.ctor.invocation=\
recursive constructor invocation
+
+# 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol
compiler.err.ref.ambiguous=\
reference to {0} is ambiguous, both {1} {2} in {3} and {4} {5} in {6} match
+
compiler.err.repeated.annotation.target=\
repeated annotation target
+
compiler.err.repeated.interface=\
repeated interface
+
compiler.err.repeated.modifier=\
repeated modifier
+
+# 0: symbol, 1: set of modifier, 2: symbol
compiler.err.report.access=\
{0} has {1} access in {2}
+
compiler.err.ret.outside.meth=\
return outside method
compiler.err.signature.doesnt.match.supertype=\
signature does not match {0}; incompatible supertype
+
compiler.err.signature.doesnt.match.intf=\
signature does not match {0}; incompatible interfaces
+
+# 0: symbol, 1: symbol, 2: symbol
compiler.err.does.not.override.abstract=\
{0} is not abstract and does not override abstract method {1} in {2}
+
compiler.err.source.cant.overwrite.input.file=\
error writing source; cannot overwrite input file {0}
+
compiler.err.stack.sim.error=\
Internal error: stack sim error on {0}
+
compiler.err.static.imp.only.classes.and.interfaces=\
static import only from classes and interfaces
+
compiler.err.string.const.req=\
constant string expression required
+
+# 0: symbol, 1: symbol
compiler.err.synthetic.name.conflict=\
the symbol {0} conflicts with a compiler-synthesized symbol in {1}
+
+# 0: symbol, 1: symbol
compiler.warn.synthetic.name.conflict=\
the symbol {0} conflicts with a compiler-synthesized symbol in {1}
compiler.err.throws.not.allowed.in.intf.annotation=\
throws clause not allowed in @interface members
+
compiler.err.try.without.catch.or.finally=\
''try'' without ''catch'' or ''finally''
+
compiler.err.try.without.catch.finally.or.resource.decls=\
''try'' without ''catch'', ''finally'' or resource declarations
+
+# 0: symbol
compiler.err.type.doesnt.take.params=\
type {0} does not take parameters
+
compiler.err.type.var.cant.be.deref=\
cannot select from a type variable
+
compiler.err.type.var.may.not.be.followed.by.other.bounds=\
a type variable may not be followed by other bounds
+
compiler.err.type.var.more.than.once=\
type variable {0} occurs more than once in result type of {1}; cannot be left uninstantiated
+
compiler.err.type.var.more.than.once.in.result=\
type variable {0} occurs more than once in type of {1}; cannot be left uninstantiated
+
+# 0: type, 1: type, 2: string
compiler.err.types.incompatible.diff.ret=\
types {0} and {1} are incompatible; both define {2}, but with unrelated return types
compiler.err.unclosed.char.lit=\
unclosed character literal
+
compiler.err.unclosed.comment=\
unclosed comment
+
compiler.err.unclosed.str.lit=\
unclosed string literal
+
compiler.err.unknown.enum.constant=\
in class file {0}: unknown enum constant {1}.{2}
+
+# 0: name
compiler.err.unsupported.encoding=\
unsupported encoding: {0}
+
compiler.err.io.exception=\
error reading source file: {0}
+
+# 0: name
compiler.err.undef.label=\
undefined label: {0}
+
compiler.err.undetermined.type=\
cannot infer type arguments for {0}
+
+# 0: type, 1: message segment
compiler.err.undetermined.type.1=\
cannot infer type arguments for {0};\n\
reason: {1}
+
+# 0: list of type, 1: message segment
compiler.err.invalid.inferred.types=\
invalid inferred types for {0}; {1}
+
+# 0: message segment, 1: unused
compiler.err.cant.apply.diamond=\
cannot infer type arguments for {0}
+
+# 0: message segment, 1: message segment
compiler.err.cant.apply.diamond.1=\
cannot infer type arguments for {0};\n\
reason: {1}
+
compiler.err.unreachable.stmt=\
unreachable statement
+
compiler.err.initializer.must.be.able.to.complete.normally=\
initializer must be able to complete normally
+
+# 0: type
compiler.err.unreported.exception.need.to.catch.or.throw=\
unreported exception {0}; must be caught or declared to be thrown
+
+# 0: type
compiler.err.unreported.exception.default.constructor=\
unreported exception {0} in default constructor
+
compiler.err.unsupported.cross.fp.lit=\
hexadecimal floating-point literals are not supported on this VM
+
compiler.err.void.not.allowed.here=\
''void'' type not allowed here
+# 0: string
compiler.err.wrong.number.type.args=\
wrong number of type arguments; required {0}
+# 0: symbol
compiler.err.var.might.already.be.assigned=\
variable {0} might already have been assigned
+
+# 0: symbol
compiler.err.var.might.not.have.been.initialized=\
variable {0} might not have been initialized
+
+# 0: symbol
compiler.err.var.might.be.assigned.in.loop=\
variable {0} might be assigned in loop
+# 0: symbol, 1: message segment
compiler.err.varargs.invalid.trustme.anno=\
Invalid {0} annotation. {1}
+
+# 0: type
compiler.misc.varargs.trustme.on.reifiable.varargs=\
Varargs element type {0} is reifiable.
+
+# 0: symbol
compiler.misc.varargs.trustme.on.non.varargs.meth=\
Method {0} is not a varargs method.
+
+# 0: symbol
compiler.misc.varargs.trustme.on.virtual.varargs=\
Instance method {0} is not final.
+# 0: type, 1: kind, 2: symbol
+compiler.misc.inaccessible.varargs.type=\
+ formal varargs element type {0} is not accessible from {1} {2}
+
# In the following string, {1} will always be the detail message from
# java.io.IOException.
+# 0: symbol, 1: string
compiler.err.class.cant.write=\
error while writing {0}: {1}
# In the following string, {0} is the name of the class in the Java source.
# It really should be used two times..
+# 0: name
compiler.err.class.public.should.be.in.file=\
class {0} is public, should be declared in a file named {0}.java
@@ -556,12 +869,16 @@
compiler.misc.fatal.err.no.java.lang=\
Fatal Error: Unable to find package java.lang in classpath or bootclasspath
+
compiler.misc.fatal.err.cant.locate.meth=\
Fatal Error: Unable to find method {0}
+
compiler.misc.fatal.err.cant.locate.field=\
Fatal Error: Unable to find field {0}
+
compiler.misc.fatal.err.cant.locate.ctor=\
Fatal Error: Unable to find constructor for {0}
+
compiler.misc.fatal.err.cant.close.loader=\
Fatal Error: Cannot close class loader for annotation processors
@@ -573,10 +890,15 @@
compiler.misc.source.unavailable=\
(source unavailable)
+
compiler.misc.base.membership=\
all your base class are belong to us
+
+# 0: string, 1: string, 2: boolean
compiler.misc.x.print.processor.info=\
Processor {0} matches {1} and returns {2}.
+
+# 0: number, 1: string, 2: set of symbol, 3: boolean
compiler.misc.x.print.rounds=\
Round {0}:\n\tinput files: {1}\n\tannotations: {2}\n\tlast round: {3}
@@ -587,61 +909,84 @@
compiler.note.note=\
Note:\u0020
+# 0: file name
compiler.note.deprecated.filename=\
{0} uses or overrides a deprecated API.
+
compiler.note.deprecated.plural=\
Some input files use or override a deprecated API.
+
# The following string may appear after one of the above deprecation
# messages.
compiler.note.deprecated.recompile=\
Recompile with -Xlint:deprecation for details.
+# 0: file name
compiler.note.deprecated.filename.additional=\
{0} has additional uses or overrides of a deprecated API.
+
compiler.note.deprecated.plural.additional=\
Some input files additionally use or override a deprecated API.
+# 0: file name
compiler.note.unchecked.filename=\
{0} uses unchecked or unsafe operations.
+
compiler.note.unchecked.plural=\
Some input files use unchecked or unsafe operations.
+
# The following string may appear after one of the above deprecation
# messages.
compiler.note.unchecked.recompile=\
Recompile with -Xlint:unchecked for details.
+# 0: file name
compiler.note.unchecked.filename.additional=\
{0} has additional unchecked or unsafe operations.
+
compiler.note.unchecked.plural.additional=\
Some input files additionally use unchecked or unsafe operations.
+# 0: file name
compiler.note.sunapi.filename=\
{0} uses internal proprietary API that may be removed in a future release.
+
compiler.note.sunapi.plural=\
Some input files use internal proprietary API that may be removed in a future release.
+
# The following string may appear after one of the above sunapi messages.
compiler.note.sunapi.recompile=\
Recompile with -Xlint:sunapi for details.
+# 0: file name
compiler.note.sunapi.filename.additional=\
{0} uses additional internal proprietary API that may be removed in a future release.
+
compiler.note.sunapi.plural.additional=\
Some input files additionally use internal proprietary API that may be removed in a future release.
# Notes related to annotation processing
# Print a client-generated note; assumed to be localized, no translation required
+# 0: string
compiler.note.proc.messager=\
{0}
#####
+# 0: number
compiler.misc.count.error=\
{0} error
+
+# 0: number
compiler.misc.count.error.plural=\
{0} errors
+
+# 0: number
compiler.misc.count.warn=\
{0} warning
+
+# 0: number
compiler.misc.count.warn.plural=\
{0} warnings
@@ -650,38 +995,53 @@
## extra output when using -verbose (JavaCompiler)
+# 0: symbol
compiler.misc.verbose.checking.attribution=\
[checking {0}]
+
+# 0: string
compiler.misc.verbose.parsing.done=\
[parsing completed {0}ms]
+
+# 0: file name
compiler.misc.verbose.parsing.started=\
[parsing started {0}]
+
+# 0: string
compiler.misc.verbose.total=\
[total {0}ms]
+
+# 0: file name
compiler.misc.verbose.wrote.file=\
[wrote {0}]
## extra output when using -verbose (Retro)
compiler.misc.verbose.retro=\
[retrofitting {0}]
+
compiler.misc.verbose.retro.with=\
\tretrofitting {0} with {1}
+
compiler.misc.verbose.retro.with.list=\
\tretrofitting {0} with type parameters {1}, supertype {2}, interfaces {3}
## extra output when using -verbose (code/ClassReader)
+# 0: string
compiler.misc.verbose.loading=\
[loading {0}]
+# 0: string
compiler.misc.verbose.sourcepath=\
[search path for source files: {0}]
+# 0: string
compiler.misc.verbose.classpath=\
[search path for class files: {0}]
## extra output when using -checkclassfile (code/ClassReader)
compiler.misc.ccf.found.later.version=\
class file has later version than expected: {0}
+
compiler.misc.ccf.unrecognized.attribute=\
unrecognized attribute: {0}
@@ -701,103 +1061,135 @@
## Warning messages may also include the following prefix to identify a
## lint option
+# 0: option name
compiler.warn.lintOption=\
[{0}]\u0020
+# 0: symbol
compiler.warn.constant.SVUID=\
serialVersionUID must be constant in class {0}
+# 0: file name
compiler.warn.dir.path.element.not.found=\
bad path element "{0}": no such directory
compiler.warn.finally.cannot.complete=\
finally clause cannot complete normally
+# 0: symbol, 1: symbol
compiler.warn.has.been.deprecated=\
{0} in {1} has been deprecated
+# 0: symbol
compiler.warn.sun.proprietary=\
{0} is internal proprietary API and may be removed in a future release
compiler.warn.illegal.char.for.encoding=\
unmappable character for encoding {0}
+# 0: symbol
compiler.warn.improper.SVUID=\
serialVersionUID must be declared static final in class {0}
+# 0: type, 1: type
compiler.warn.inexact.non-varargs.call=\
-non-varargs call of varargs method with inexact argument type for last parameter;\n\
-cast to {0} for a varargs call\n\
-cast to {1} for a non-varargs call and to suppress this warning
-
+ non-varargs call of varargs method with inexact argument type for last parameter;\n\
+ cast to {0} for a varargs call\n\
+ cast to {1} for a non-varargs call and to suppress this warning
+
+# 0: symbol
compiler.warn.long.SVUID=\
serialVersionUID must be of type long in class {0}
+# 0: symbol
compiler.warn.missing.SVUID=\
serializable class {0} has no definition of serialVersionUID
+# 0: message segment
compiler.warn.override.varargs.missing=\
{0}; overridden method has no ''...''
+
+# 0: message segment
compiler.warn.override.varargs.extra=\
{0}; overriding method is missing ''...''
+
compiler.warn.override.bridge=\
{0}; overridden method is a bridge method
+# 0: symbol
compiler.warn.pkg-info.already.seen=\
a package-info.java file has already been seen for package {0}
+# 0: file name
compiler.warn.path.element.not.found=\
bad path element "{0}": no such file or directory
compiler.warn.possible.fall-through.into.case=\
possible fall-through into case
+# 0: type
compiler.warn.redundant.cast=\
redundant cast to {0}
+# 0: number
compiler.warn.position.overflow=\
Position encoding overflows at line {0}
+# 0: file name, 1: number, 2: number
compiler.warn.big.major.version=\
{0}: major version {1} is newer than {2}, the highest major version supported by this compiler.\n\
It is recommended that the compiler be upgraded.
+# 0: symbol kind, 1: symbol
compiler.warn.static.not.qualified.by.type=\
static {0} should be qualified by type name, {1}, instead of by an expression
+# 0: string
compiler.warn.source.no.bootclasspath=\
bootstrap class path not set in conjunction with -source {0}
+# 0: name, 1: number, 2: number, 3: number, 4: number
compiler.warn.future.attr=\
{0} attribute introduced in version {1}.{2} class files is ignored in version {3}.{4} class files
# Warnings related to annotation processing
+# 0: name
compiler.warn.proc.package.does.not.exist=\
package {0} does not exist
+
+# 0: name
compiler.warn.proc.file.reopening=\
Attempt to create a file for ''{0}'' multiple times
+# 0: name
compiler.warn.proc.type.already.exists=\
A file for type ''{0}'' already exists on the sourcepath or classpath
+# 0: name
compiler.warn.proc.type.recreate=\
Attempt to create a file for type ''{0}'' multiple times
+# 0: string
compiler.warn.proc.illegal.file.name=\
Cannot create file for illegal name ''{0}''.
+# 0: string, 1: string
compiler.warn.proc.suspicious.class.name=\
Creating file for a type whose name ends in {1}: ''{0}''
+# 0: name
compiler.warn.proc.file.create.last.round=\
File for type ''{0}'' created in the last round will not be subject to annotation processing.
+# 0: string, 1: string
compiler.warn.proc.malformed.supported.string=\
Malformed string ''{0}'' for a supported annotation type returned by processor ''{1}''
+# 0: set of string
compiler.warn.proc.annotations.without.processors=\
No processor claimed any of these annotations: {0}
+# 0: source version, 1: string, 2: string
compiler.warn.proc.processor.incompatible.source.version=\
Supported source version ''{0}'' from annotation processor ''{1}'' less than -source ''{2}''
@@ -805,46 +1197,62 @@
Annotation processing without compilation requested but no processors were found.
compiler.warn.proc.use.implicit=\
-Implicitly compiled files were not subject to annotation processing.\n\
-Use -implicit to specify a policy for implicit compilation.
+ Implicitly compiled files were not subject to annotation processing.\n\
+ Use -implicit to specify a policy for implicit compilation.
compiler.warn.proc.use.proc.or.implicit=\
-Implicitly compiled files were not subject to annotation processing.\n\
-Use -proc:none to disable annotation processing or -implicit to specify a policy for implicit compilation.
+ Implicitly compiled files were not subject to annotation processing.\n\
+ Use -proc:none to disable annotation processing or -implicit to specify a policy for implicit compilation.
# Print a client-generated warning; assumed to be localized, no translation required
+# 0: string
compiler.warn.proc.messager=\
{0}
+# 0: set of name
compiler.warn.proc.unclosed.type.files=\
Unclosed files for the types ''{0}''; these types will not undergo annotation processing
+# 0: string
compiler.warn.proc.unmatched.processor.options=\
The following options were not recognized by any processor: ''{0}''
compiler.warn.try.explicit.close.call=\
explicit call to close() on an auto-closeable resource
+
+# 0: symbol
compiler.warn.try.resource.not.referenced=\
auto-closeable resource {0} is never referenced in body of corresponding try statement
+
compiler.warn.unchecked.assign=\
unchecked assignment: {0} to {1}
+
+# 0: symbol, 1: type
compiler.warn.unchecked.assign.to.var=\
unchecked assignment to variable {0} as member of raw type {1}
+
+# 0: symbol, 1: type
compiler.warn.unchecked.call.mbr.of.raw.type=\
unchecked call to {0} as a member of the raw type {1}
+
compiler.warn.unchecked.cast.to.type=\
unchecked cast to type {0}
+
+# 0: symbol kind, 1: name, 2: list of type, 3: list of type, 4: symbol kind, 5: symbol
compiler.warn.unchecked.meth.invocation.applied=\
unchecked method invocation: {0} {1} in {4} {5} is applied to given types\n\
required: {2}\n\
found: {3}
+# 0: type
compiler.warn.unchecked.generic.array.creation=\
unchecked generic array creation for varargs parameter of type {0}
+# 0: type
compiler.warn.unchecked.varargs.non.reifiable.type=\
Possible heap pollution from parameterized vararg type {0}
+# 0: symbol
compiler.warn.varargs.unsafe.use.varargs.param=\
Varargs method could cause heap pollution from non-reifiable varargs parameter {0}
@@ -869,17 +1277,22 @@
compiler.warn.annotation.method.not.found.reason=\
Cannot find annotation method ''{1}()'' in type ''{0}'': {2}
+# 0: type, 1: type
compiler.warn.raw.class.use=\
found raw type: {0}\n\
missing type arguments for generic class {1}
+# 0: unused, 1: unused
compiler.warn.diamond.redundant.args=\
redundant type arguments in new expression (use diamond operator instead).
+
+# 0: type, 1: type
compiler.warn.diamond.redundant.args.1=\
redundant type arguments in new expression (use diamond operator instead).\n\
explicit: {0}\n\
inferred: {1}
+# 0: symbol, 1: message segment
compiler.warn.varargs.redundant.trustme.anno=\
Redundant {0} annotation. {1}
@@ -889,20 +1302,28 @@
## be named as JLS3 calls them when translated to the appropriate language.
compiler.misc.token.identifier=\
<identifier>
+
compiler.misc.token.character=\
<character>
+
compiler.misc.token.string=\
<string>
+
compiler.misc.token.integer=\
<integer>
+
compiler.misc.token.long-integer=\
<long integer>
+
compiler.misc.token.float=\
<float>
+
compiler.misc.token.double=\
<double>
+
compiler.misc.token.bad-symbol=\
<bad symbol>
+
compiler.misc.token.end-of-input=\
<end of input>
@@ -915,10 +1336,15 @@
## 6. an operator (JLS3.12)
##
## This is the only place these tokens will be used.
+# 0: token
compiler.err.expected=\
{0} expected
+
+# 0: token, 1: token
compiler.err.expected2=\
{0} or {1} expected
+
+# 0: token, 1: token, 2: token
compiler.err.expected3=\
{0}, {1}, or {2} expected
@@ -930,12 +1356,15 @@
''.class'' expected
## The argument to this string will always be either 'case' or 'default'.
+# 0: token
compiler.err.orphaned=\
orphaned {0}
+# 0: name
compiler.misc.anonymous.class=\
<anonymous {0}>
+# 0: name, 1: type
compiler.misc.type.captureof=\
capture#{0} of {1}
@@ -950,54 +1379,73 @@
#####
+# 0: symbol, 1: message segment
compiler.err.cant.access=\
-cannot access {0}\n\
-{1}
+ cannot access {0}\n\
+ {1}
compiler.misc.bad.class.file.header=\
-bad class file: {0}\n\
-{1}\n\
-Please remove or make sure it appears in the correct subdirectory of the classpath.
+ bad class file: {0}\n\
+ {1}\n\
+ Please remove or make sure it appears in the correct subdirectory of the classpath.
+
+# 0: file name, 1: message segment
compiler.misc.bad.source.file.header=\
-bad source file: {0}\n\
-{1}\n\
-Please remove or make sure it appears in the correct subdirectory of the sourcepath.
+ bad source file: {0}\n\
+ {1}\n\
+ Please remove or make sure it appears in the correct subdirectory of the sourcepath.
## The following are all possible strings for the second argument ({1}) of the
## above strings.
compiler.misc.bad.class.signature=\
bad class signature: {0}
+
compiler.misc.bad.enclosing.method=\
bad enclosing method attribute: {0}
+
compiler.misc.bad.runtime.invisible.param.annotations=\
bad RuntimeInvisibleParameterAnnotations attribute: {0}
+
compiler.misc.bad.const.pool.tag=\
bad constant pool tag: {0}
+
compiler.misc.bad.const.pool.tag.at=\
bad constant pool tag: {0} at {1}
+
compiler.misc.bad.signature=\
bad signature: {0}
+
compiler.misc.class.file.wrong.class=\
class file contains wrong class: {0}
+
compiler.misc.class.file.not.found=\
class file for {0} not found
+
+# 0: name
compiler.misc.file.doesnt.contain.class=\
file does not contain class {0}
+
compiler.misc.file.does.not.contain.package=\
file does not contain package {0}
+
compiler.misc.illegal.start.of.class.file=\
illegal start of class file
+
compiler.misc.unable.to.access.file=\
unable to access file: {0}
+
compiler.misc.unicode.str.not.supported=\
unicode string in class file not supported
+
compiler.misc.undecl.type.var=\
undeclared type variable: {0}
+
compiler.misc.wrong.version=\
class file has wrong version {0}.{1}, should be {2}.{3}
#####
+# 0: type, 1: type or symbol
compiler.err.not.within.bounds=\
type argument {0} is not within bounds of type-variable {1}
@@ -1008,32 +1456,41 @@
#####
+# 0: message segment, 1: type, 2: type
compiler.err.prob.found.req=\
-{0}\n\
-required: {2}\n\
-found: {1}
+ {0}\n\
+ required: {2}\n\
+ found: {1}
+
+# 0: message segment, 1: type, 2: type
compiler.warn.prob.found.req=\
-{0}\n\
-required: {2}\n\
-found: {1}
+ {0}\n\
+ required: {2}\n\
+ found: {1}
+
compiler.err.prob.found.req.1=\
-{0} {3}\n\
-required: {2}\n\
-found: {1}
+ {0} {3}\n\
+ required: {2}\n\
+ found: {1}
## The following are all possible strings for the first argument ({0}) of the
## above strings.
compiler.misc.incompatible.types=\
incompatible types
+
+# 0: message segment
compiler.misc.incompatible.types.1=\
incompatible types; {0}
+
compiler.misc.inconvertible.types=\
inconvertible types
+
compiler.misc.possible.loss.of.precision=\
possible loss of precision
compiler.misc.unchecked.assign=\
unchecked conversion
+
# compiler.misc.storecheck=\
# assignment might cause later store checks to fail
# compiler.misc.unchecked=\
@@ -1043,8 +1500,10 @@
compiler.misc.assignment.from.super-bound=\
assignment from super-bound type {0}
+
compiler.misc.assignment.to.extends-bound=\
assignment to extends-bound type {0}
+
# compiler.err.star.expected=\
# ''*'' expected
# compiler.err.no.elem.type=\
@@ -1055,23 +1514,30 @@
#####
+# 0: message segment or type, 1: message segment
compiler.err.type.found.req=\
-unexpected type\n\
-required: {1}\n\
-found: {0}
+ unexpected type\n\
+ required: {1}\n\
+ found: {0}
## The following are all possible strings for the first argument ({0}) of the
## above string.
compiler.misc.type.req.class=\
class
+
compiler.misc.type.req.class.array=\
class or array
+
compiler.misc.type.req.array.or.iterable=\
array or java.lang.Iterable
+
compiler.misc.type.req.ref=\
reference
+
compiler.misc.type.req.exact=\
class or interface without bounds
+
+# 0: type
compiler.misc.type.parameter=\
type parameter {0}
@@ -1081,87 +1547,114 @@
## diagnostics whose key ends in ".1"
compiler.misc.undetermined.type=\
undetermined type
+
compiler.misc.type.variable.has.undetermined.type=\
type variable {0} has undetermined type
+
+# 0: type, 1: list of type
compiler.misc.no.unique.maximal.instance.exists=\
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}
+
+# 0: list of type, 1: type, 2: type
compiler.misc.infer.no.conforming.instance.exists=\
no instance(s) of type variable(s) {0} exist so that {1} conforms to {2}
+
+# 0: list of type, 1: type, 2: type
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.infer.arg.length.mismatch=\
cannot instantiate from arguments because actual and formal argument lists differ in length
+
+# 0: type, 1: list of type
compiler.misc.inferred.do.not.conform.to.bounds=\
inferred type does not conform to declared bound(s)\n\
inferred: {0}\n\
bound(s): {1}
-compiler.misc.inferred.do.not.conform.to.params=\
- actual arguments do not conform to inferred formal arguments\n\
- required: {0}\n\
- found: {1}
+
+# 0: symbol
compiler.misc.diamond=\
{0}<>
+
+# 0: list of type, 1: message segment
compiler.misc.diamond.invalid.arg=\
type argument {0} inferred for {1} is not allowed in this context
+
+# 0: list of type, 1: message segment
compiler.misc.diamond.invalid.args=\
type arguments {0} inferred for {1} are not allowed in this context
+# 0: type, 1: list of type
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
+
+# 0: type, 1: type
compiler.misc.no.conforming.assignment.exists=\
actual argument {0} cannot be converted to {1} by method invocation conversion
+
+# 0: type, 1: type
compiler.misc.varargs.argument.mismatch=\
argument type {0} does not conform to vararg element type {1}
+
#####
## The first argument ({0}) is a "kindname".
+# 0: symbol kind, 1: symbol, 2: symbol
compiler.err.abstract.cant.be.accessed.directly=\
abstract {0} {1} in {2} cannot be accessed directly
## The first argument ({0}) is a "kindname".
+# 0: symbol kind, 1: symbol
compiler.err.non-static.cant.be.ref=\
non-static {0} {1} cannot be referenced from a static context
## Both arguments ({0}, {1}) are "kindname"s. {0} is a comma-separated list
## of kindnames (the list should be identical to that provided in source.
compiler.err.unexpected.type=\
-unexpected type\n\
-required: {0}\n\
-found: {1}
+ unexpected type\n\
+ required: {0}\n\
+ found: {1}
## The first argument {0} is a "kindname" (e.g. 'constructor', 'field', etc.)
## The second argument {1} is the non-resolved symbol
## The third argument {2} is a list of type parameters (non-empty if {1} is a method)
## The fourth argument {3} is a list of argument types (non-empty if {1} is a method)
+# 0: symbol kind, 1: name, 2: unused, 3: unused
compiler.err.cant.resolve=\
cannot find symbol\n\
symbol: {0} {1}
+# 0: symbol kind, 1: name, 2: unused, 3: list of type
compiler.err.cant.resolve.args=\
cannot find symbol\n\
symbol: {0} {1}({3})
+# 0: symbol kind, 1: name, 2: list of type, 3: list of type
compiler.err.cant.resolve.args.params=\
cannot find symbol\n\
symbol: {0} <{2}>{1}({3})
## arguments from {0} to {3} have the same meaning as above
## The fifth argument {4} is a location subdiagnostic (see below)
+# 0: symbol kind, 1: name, 2: unused, 3: unused, 4: message segment
compiler.err.cant.resolve.location=\
cannot find symbol\n\
symbol: {0} {1}\n\
location: {4}
+# 0: symbol kind, 1: name, 2: unused, 3: list of type, 4: message segment
compiler.err.cant.resolve.location.args=\
cannot find symbol\n\
symbol: {0} {1}({3})\n\
location: {4}
+# 0: symbol kind, 1: name, 2: list of type, 3: list, 4: message segment
compiler.err.cant.resolve.location.args.params=\
cannot find symbol\n\
symbol: {0} <{2}>{1}({3})\n\
@@ -1172,8 +1665,11 @@
## The second argument {1} is the location name
## The third argument {2} is the location type (only when {1} is a variable name)
+# 0: symbol kind, 1: symbol, 2: unused
compiler.misc.location=\
{0} {1}
+
+# 0: symbol kind, 1: symbol, 2: type
compiler.misc.location.1=\
{0} {1} of type {2}
@@ -1184,85 +1680,124 @@
# static member
compiler.misc.kindname.annotation=\
@interface
+
compiler.misc.kindname.constructor=\
constructor
+
compiler.misc.kindname.enum=\
enum
+
compiler.misc.kindname.interface=\
interface
+
compiler.misc.kindname.static=\
static
+
compiler.misc.kindname.type.variable=\
type variable
+
compiler.misc.kindname.type.variable.bound=\
bound of type variable
+
compiler.misc.kindname.variable=\
variable
+
compiler.misc.kindname.value=\
value
+
compiler.misc.kindname.method=\
method
+
compiler.misc.kindname.class=\
class
+
compiler.misc.kindname.package=\
package
+
#####
compiler.misc.no.args=\
no arguments
+# 0: message segment
compiler.err.override.static=\
{0}\n\
overriding method is static
+
+# 0: message segment, 1: set of modifier
compiler.err.override.meth=\
{0}\n\
overridden method is {1}
+# 0: message segment, 1: type
compiler.err.override.meth.doesnt.throw=\
{0}\n\
overridden method does not throw {1}
# In the following string {1} is a space separated list of Java Keywords, as
# they would have been declared in the source code
+# 0: message segment, 1: set of modifier
compiler.err.override.weaker.access=\
{0}\n\
attempting to assign weaker access privileges; was {1}
+# 0: message segment, 1: type, 2: type
compiler.err.override.incompatible.ret=\
{0}\n\
return type {1} is not compatible with {2}
+# 0: message segment, 1: type, 2: type
compiler.warn.override.unchecked.ret=\
{0}\n\
return type requires unchecked conversion from {1} to {2}
+# 0: message segment, 1: type
compiler.warn.override.unchecked.thrown=\
{0}\n\
overridden method does not throw {1}
## The following are all possible strings for the first argument ({0}) of the
## above strings.
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
compiler.misc.cant.override=\
{0} in {1} cannot override {2} in {3}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
compiler.misc.cant.implement=\
{0} in {1} cannot implement {2} in {3}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
compiler.misc.clashes.with=\
{0} in {1} clashes with {2} in {3}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
compiler.misc.unchecked.override=\
{0} in {1} overrides {2} in {3}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
compiler.misc.unchecked.implement=\
{0} in {1} implements {2} in {3}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
compiler.misc.unchecked.clash.with=\
{0} in {1} overrides {2} in {3}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
compiler.misc.varargs.override=\
{0} in {1} overrides {2} in {3}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
compiler.misc.varargs.implement=\
{0} in {1} implements {2} in {3}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
compiler.misc.varargs.clash.with=\
{0} in {1} overrides {2} in {3}
+
compiler.misc.non.denotable.type=\
Non-denotable type {0} not allowed here
+# 0: symbol kind, 1: symbol, 2: symbol, 3: message segment
compiler.misc.inapplicable.method=\
{0} {1}.{2} is not applicable\n\
({3})
@@ -1270,77 +1805,90 @@
########################################
# Diagnostics for language feature changes
########################################
+# 0: string
compiler.err.unsupported.fp.lit=\
hexadecimal floating point literals are not supported in -source {0}\n\
-(use -source 5 or higher to enable hexadecimal floating point literals)
-
+ (use -source 5 or higher to enable hexadecimal floating point literals)
+
+# 0: string
compiler.err.unsupported.binary.lit=\
binary literals are not supported in -source {0}\n\
-(use -source 7 or higher to enable binary literals)
-
+ (use -source 7 or higher to enable binary literals)
+
+# 0: string
compiler.err.unsupported.underscore.lit=\
underscores in literals are not supported in -source {0}\n\
-(use -source 7 or higher to enable underscores in literals)
-
+ (use -source 7 or higher to enable underscores in literals)
+
+# 0: string
compiler.err.try.with.resources.not.supported.in.source=\
try-with-resources is not supported in -source {0}\n\
-(use -source 7 or higher to enable try-with-resources)
+ (use -source 7 or higher to enable try-with-resources)
compiler.warn.enum.as.identifier=\
as of release 5, ''enum'' is a keyword, and may not be used as an identifier\n\
-(use -source 5 or higher to use ''enum'' as a keyword)
+ (use -source 5 or higher to use ''enum'' as a keyword)
compiler.warn.assert.as.identifier=\
as of release 1.4, ''assert'' is a keyword, and may not be used as an identifier\n\
-(use -source 1.4 or higher to use ''assert'' as a keyword)
+ (use -source 1.4 or higher to use ''assert'' as a keyword)
compiler.err.enum.as.identifier=\
as of release 5, ''enum'' is a keyword, and may not be used as an identifier\n\
-(use -source 1.4 or lower to use ''enum'' as an identifier)
+ (use -source 1.4 or lower to use ''enum'' as an identifier)
compiler.err.assert.as.identifier=\
as of release 1.4, ''assert'' is a keyword, and may not be used as an identifier\n\
-(use -source 1.3 or lower to use ''assert'' as an identifier)
-
+ (use -source 1.3 or lower to use ''assert'' as an identifier)
+
+# 0: string
compiler.err.generics.not.supported.in.source=\
generics are not supported in -source {0}\n\
-(use -source 5 or higher to enable generics)
-
+ (use -source 5 or higher to enable generics)
+
+# 0: string
compiler.err.varargs.not.supported.in.source=\
variable-arity methods are not supported in -source {0}\n\
-(use -source 5 or higher to enable variable-arity methods)
-
+ (use -source 5 or higher to enable variable-arity methods)
+
+# 0: string
compiler.err.annotations.not.supported.in.source=\
annotations are not supported in -source {0}\n\
-(use -source 5 or higher to enable annotations)
+ (use -source 5 or higher to enable annotations)
#308 compiler.err.type.annotations.not.supported.in.source=\
#308 type annotations are not supported in -source {0}\n\
#308 (use -source 7 or higher to enable type annotations)
+# 0: string
compiler.err.foreach.not.supported.in.source=\
for-each loops are not supported in -source {0}\n\
-(use -source 5 or higher to enable for-each loops)
-
+ (use -source 5 or higher to enable for-each loops)
+
+# 0: string
compiler.err.static.import.not.supported.in.source=\
static import declarations are not supported in -source {0}\n\
-(use -source 5 or higher to enable static import declarations)
-
+ (use -source 5 or higher to enable static import declarations)
+
+# 0: string
compiler.err.enums.not.supported.in.source=\
enums are not supported in -source {0}\n\
-(use -source 5 or higher to enable enums)
-
+ (use -source 5 or higher to enable enums)
+
+# 0: string
compiler.err.diamond.not.supported.in.source=\
diamond operator is not supported in -source {0}\n\
-(use -source 7 or higher to enable diamond operator)
-
+ (use -source 7 or higher to enable diamond operator)
+
+# 0: string
compiler.err.multicatch.not.supported.in.source=\
multi-catch statement is not supported in -source {0}\n\
-(use -source 7 or higher to enable multi-catch statement)
-
+ (use -source 7 or higher to enable multi-catch statement)
+
+# 0: string
compiler.err.string.switch.not.supported.in.source=\
strings in switch are not supported in -source {0}\n\
-(use -source 7 or higher to enable strings in switch)
+ (use -source 7 or higher to enable strings in switch)
########################################
# Diagnostics for where clause implementation
@@ -1351,29 +1899,35 @@
<null>
# X#n (where n is an int id) is disambiguated tvar name
+# 0: name, 1: number
compiler.misc.type.var=\
{0}#{1}
# CAP#n (where n is an int id) is an abbreviation for 'captured type'
+# 0: number
compiler.misc.captured.type=\
CAP#{0}
# <INT#n> (where n is an int id) is an abbreviation for 'intersection type'
+# 0: number
compiler.misc.intersection.type=\
INT#{0}
# where clause for captured type: contains upper ('extends {1}') and lower
# ('super {2}') bound along with the wildcard that generated this captured type ({3})
+# 0: type, 1: type, 2: type, 3: type
compiler.misc.where.captured=\
{0} extends {1} super: {2} from capture of {3}
# compact where clause for captured type: contains upper ('extends {1}') along
# with the wildcard that generated this captured type ({3})
+# 0: type, 1: type, 2: unused, 3: type
compiler.misc.where.captured.1=\
{0} extends {1} from capture of {3}
# where clause for type variable: contains upper bound(s) ('extends {1}') along with
# the kindname ({2}) and location ({3}) in which the typevar has been declared
+# 0: type, 1: list of type, 2: symbol kind, 3: symbol
compiler.misc.where.typevar=\
{0} extends {1} declared in {2} {3}
@@ -1384,20 +1938,30 @@
# where clause for type variable: contains all the upper bound(s) ('extends {1}')
# of this intersection type
+# 0: type, 1: list of type
compiler.misc.where.intersection=\
{0} extends {1}
### Where clause headers ###
compiler.misc.where.description.captured=\
where {0} is a fresh type-variable:
+
+# 0: set of type
compiler.misc.where.description.typevar=\
where {0} is a type-variable:
+
+# 0: set of type
compiler.misc.where.description.intersection=\
where {0} is an intersection type:
+
+# 0: set of type
compiler.misc.where.description.captured.1=\
where {0} are fresh type-variables:
+
+# 0: set of type
compiler.misc.where.description.typevar.1=\
where {0} are type-variables:
+
compiler.misc.where.description.intersection.1=\
where {0} are intersection types:
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Mon Feb 14 16:31:21 2011 -0800
@@ -465,9 +465,10 @@
public List<JCImport> getImports() {
ListBuffer<JCImport> imports = new ListBuffer<JCImport>();
for (JCTree tree : defs) {
- if (tree.getTag() == IMPORT)
+ int tag = tree.getTag();
+ if (tag == IMPORT)
imports.append((JCImport)tree);
- else
+ else if (tag != SKIP)
break;
}
return imports.toList();
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Names.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Names.java Mon Feb 14 16:31:21 2011 -0800
@@ -73,7 +73,8 @@
public final Name java_io_Serializable;
public final Name serialVersionUID;
public final Name java_lang_Enum;
- public final Name java_dyn_MethodHandle;
+ public final Name transient_java_dyn_MethodHandle; // transient - 292
+ public final Name java_lang_invoke_MethodHandle;
public final Name package_info;
public final Name ConstantValue;
public final Name LineNumberTable;
@@ -183,7 +184,8 @@
java_lang_Cloneable = fromString("java.lang.Cloneable");
java_io_Serializable = fromString("java.io.Serializable");
java_lang_Enum = fromString("java.lang.Enum");
- java_dyn_MethodHandle = fromString("java.dyn.MethodHandle");
+ transient_java_dyn_MethodHandle = fromString("java.dyn.MethodHandle"); //transient - 292
+ java_lang_invoke_MethodHandle = fromString("java.lang.invoke.MethodHandle");
package_info = fromString("package-info");
serialVersionUID = fromString("serialVersionUID");
ConstantValue = fromString("ConstantValue");
--- a/langtools/src/share/classes/javax/lang/model/element/Element.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/Element.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -159,18 +159,26 @@
Set<Modifier> getModifiers();
/**
- * Returns the simple (unqualified) name of this element.
- * The name of a generic type does not include any reference
- * to its formal type parameters.
- * For example, the simple name of the type element
- * {@code java.util.Set<E>} is {@code "Set"}.
- * If this element represents an unnamed package, an empty name is
- * returned. If it represents a constructor, the name "{@code
- * <init>}" is returned. If it represents a static initializer,
- * the name "{@code <clinit>}" is returned. If it represents an
- * anonymous class or instance initializer, an empty name is
+ * Returns the simple (unqualified) name of this element. The
+ * name of a generic type does not include any reference to its
+ * formal type parameters.
+ *
+ * For example, the simple name of the type element {@code
+ * java.util.Set<E>} is {@code "Set"}.
+ *
+ * If this element represents an unnamed {@linkplain
+ * PackageElement#getSimpleName package}, an empty name is
* returned.
*
+ * If it represents a {@linkplain ExecutableElement#getSimpleName
+ * constructor}, the name "{@code <init>}" is returned. If it
+ * represents a {@linkplain ExecutableElement#getSimpleName static
+ * initializer}, the name "{@code <clinit>}" is returned.
+ *
+ * If it represents an {@linkplain TypeElement#getSimpleName
+ * anonymous class} or {@linkplain ExecutableElement#getSimpleName
+ * instance initializer}, an empty name is returned.
+ *
* @return the simple name of this element
*/
Name getSimpleName();
@@ -182,9 +190,18 @@
* <li> If this element is one whose declaration is lexically enclosed
* immediately within the declaration of another element, that other
* element is returned.
- * <li> If this is a top-level type, its package is returned.
- * <li> If this is a package, {@code null} is returned.
- * <li> If this is a type parameter, {@code null} is returned.
+ *
+ * <li> If this is a {@linkplain TypeElement#getEnclosingElement
+ * top-level type}, its package is returned.
+ *
+ * <li> If this is a {@linkplain
+ * PackageElement#getEnclosingElement package}, {@code null} is
+ * returned.
+
+ * <li> If this is a {@linkplain
+ * TypeParameterElement#getEnclosingElement type parameter},
+ * {@code null} is returned.
+
* </ul>
*
* @return the enclosing element, or {@code null} if there is none
--- a/langtools/src/share/classes/javax/lang/model/element/ExecutableElement.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/ExecutableElement.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -97,4 +97,17 @@
* @return the default value, or {@code null} if none
*/
AnnotationValue getDefaultValue();
+
+ /**
+ * Returns the simple name of a constructor, method, or
+ * initializer. For a constructor, the name {@code "<init>"} is
+ * returned, for a static initializer, the name {@code "<clinit>"}
+ * is returned, and for an anonymous class or instance
+ * initializer, an empty name is returned.
+ *
+ * @return the simple name of a constructor, method, or
+ * initializer
+ */
+ @Override
+ Name getSimpleName();
}
--- a/langtools/src/share/classes/javax/lang/model/element/PackageElement.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/PackageElement.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,16 @@
Name getQualifiedName();
/**
+ * Returns the simple name of this package. For an unnamed
+ * package, an empty name is returned
+ *
+ * @return the simple name of this package or an empty name if
+ * this is an unnamed package
+ */
+ @Override
+ Name getSimpleName();
+
+ /**
* Returns {@code true} is this is an unnamed package and {@code
* false} otherwise.
*
@@ -56,4 +66,13 @@
* @jls3 7.4.2 Unnamed Packages
*/
boolean isUnnamed();
+
+ /**
+ * Returns {@code null} since a package is not enclosed by another
+ * element.
+ *
+ * @return {@code null}
+ */
+ @Override
+ Element getEnclosingElement();
}
--- a/langtools/src/share/classes/javax/lang/model/element/TypeElement.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/TypeElement.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -105,6 +105,19 @@
*/
Name getQualifiedName();
+
+ /**
+ * Returns the simple name of this type element.
+ *
+ * For an anonymous class, an empty name is returned.
+ *
+ * @return the simple name of this class or interface,
+ * an empty name for an anonymous class
+ *
+ */
+ @Override
+ Name getSimpleName();
+
/**
* Returns the direct superclass of this type element.
* If this type element represents an interface or the class
@@ -132,4 +145,16 @@
* if there are none
*/
List<? extends TypeParameterElement> getTypeParameters();
+
+
+ /**
+ * Returns the package of a top-level type and returns the
+ * immediately lexically enclosing element for a {@linkplain
+ * NestingKind#isNested nested} type.
+ *
+ * @return the package of a top-level type, the immediately
+ * lexically enclosing element for a nested type
+ */
+ @Override
+ Element getEnclosingElement();
}
--- a/langtools/src/share/classes/javax/lang/model/element/TypeParameterElement.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/TypeParameterElement.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -62,4 +62,12 @@
* there are none
*/
List<? extends TypeMirror> getBounds();
+
+ /**
+ * Returns {@code null}.
+ *
+ * @return {@code null}
+ */
+ @Override
+ Element getEnclosingElement();
}
--- a/langtools/src/share/classes/javax/lang/model/element/VariableElement.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/VariableElement.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,17 +28,16 @@
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
-
/**
* Represents a field, {@code enum} constant, method or constructor
- * parameter, local variable, or exception parameter.
+ * parameter, local variable, resource variable, or exception
+ * parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
-
public interface VariableElement extends Element {
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/javax/lang/model/type/DisjunctiveType.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 javax.lang.model.type;
+
+import java.util.List;
+
+/**
+ * Represents a disjunctive type.
+ *
+ * As of the {@link javax.lang.model.SourceVersion#RELEASE_7
+ * RELEASE_7} source version, disjunctive types can appear as the type
+ * of a multi-catch exception parameter.
+ *
+ * @since 1.7
+ */
+public interface DisjunctiveType extends TypeMirror {
+
+ /**
+ * Return the alternatives comprising this disjunctive type.
+ *
+ * The alternatives are formally referred to as <i>disjuncts</i>.
+ *
+ * @return the alternatives comprising this disjunctive type.
+ */
+ List<? extends TypeMirror> getAlternatives();
+}
--- a/langtools/src/share/classes/javax/lang/model/type/TypeKind.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/type/TypeKind.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -137,7 +137,14 @@
* An implementation-reserved type.
* This is not the type you are looking for.
*/
- OTHER;
+ OTHER,
+
+ /**
+ * A disjunctive type.
+ *
+ * @since 1.7
+ */
+ DISJUNCTIVE;
/**
* Returns {@code true} if this kind corresponds to a primitive
--- a/langtools/src/share/classes/javax/lang/model/type/TypeVisitor.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/type/TypeVisitor.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -162,4 +162,14 @@
* a visitor implementation may optionally throw this exception
*/
R visitUnknown(TypeMirror t, P p);
+
+ /**
+ * Visits a disjunctive type.
+ *
+ * @param t the type to visit
+ * @param p a visitor-specified parameter
+ * @return a visitor-specified result
+ * @since 1.7
+ */
+ R visitDisjunctive(DisjunctiveType t, P p);
}
--- a/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,8 @@
/**
* A skeletal visitor of types with default behavior appropriate for
- * the version 6 language level.
+ * the {@link javax.lang.model.SourceVersion#RELEASE_6 RELEASE_6}
+ * source version.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
@@ -95,6 +96,20 @@
}
/**
+ * Visits a {@code DisjunctiveType} element by calling {@code
+ * visitUnknown}.
+
+ * @param t {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code visitUnknown}
+ *
+ * @since 1.7
+ */
+ public R visitDisjunctive(DisjunctiveType t, P p) {
+ return visitUnknown(t, p);
+ }
+
+ /**
* {@inheritDoc}
*
* <p> The default implementation of this method in {@code
--- a/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,8 @@
/**
* A skeletal visitor of types with default behavior appropriate for
- * the version 7 language level.
+ * the {@link javax.lang.model.SourceVersion#RELEASE_7 RELEASE_7}
+ * source version.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
@@ -64,4 +65,13 @@
protected AbstractTypeVisitor7() {
super();
}
+
+ /**
+ * Visits a {@code DisjunctiveType} in a manner defined by a subclass.
+ *
+ * @param t {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of the visit as defined by a subclass
+ */
+ public abstract R visitDisjunctive(DisjunctiveType t, P p);
}
--- a/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -199,7 +199,8 @@
* Visits a variable element, dispatching to the visit method for
* the specific {@linkplain ElementKind kind} of variable, {@code
* ENUM_CONSTANT}, {@code EXCEPTION_PARAMETER}, {@code FIELD},
- * {@code LOCAL_VARIABLE}, or {@code PARAMETER}.
+ * {@code LOCAL_VARIABLE}, {@code PARAMETER}, or {@code RESOURCE_VARIABLE}.
+ *
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
@@ -223,10 +224,12 @@
case PARAMETER:
return visitVariableAsParameter(e, p);
+ case RESOURCE_VARIABLE:
+ return visitVariableAsResourceVariable(e, p);
+
default:
throw new AssertionError("Bad kind " + k + " for VariableElement" + e);
}
-
}
/**
@@ -290,6 +293,20 @@
}
/**
+ * Visits a {@code RESOURCE_VARIABLE} variable element by calling
+ * {@code visitUnknown}.
+ *
+ * @param e the element to visit
+ * @param p a visitor-specified parameter
+ * @return the result of {@code visitUnknown}
+ *
+ * @since 1.7
+ */
+ public R visitVariableAsResourceVariable(VariableElement e, P p) {
+ return visitUnknown(e, p);
+ }
+
+ /**
* Visits an executable element, dispatching to the visit method
* for the specific {@linkplain ElementKind kind} of executable,
* {@code CONSTRUCTOR}, {@code INSTANCE_INIT}, {@code METHOD}, or
--- a/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
/**
* A visitor of program elements based on their {@linkplain
* ElementKind kind} with default behavior appropriate for the {@link
- * SourceVersion#RELEASE_6 RELEASE_6} source version. For {@linkplain
+ * SourceVersion#RELEASE_7 RELEASE_7} source version. For {@linkplain
* Element elements} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
@@ -94,4 +94,17 @@
protected ElementKindVisitor7(R defaultValue) {
super(defaultValue);
}
+
+ /**
+ * Visits a {@code RESOURCE_VARIABLE} variable element by calling
+ * {@code defaultAction}.
+ *
+ * @param e {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ */
+ @Override
+ public R visitVariableAsResourceVariable(VariableElement e, P p) {
+ return defaultAction(e, p);
+ }
}
--- a/langtools/src/share/classes/javax/lang/model/util/ElementScanner6.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/ElementScanner6.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -152,8 +152,8 @@
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
- * @param e the element to visit
- * @param p a visitor-specified parameter
+ * @param e {@inheritDoc}
+ * @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitPackage(PackageElement e, P p) {
@@ -163,8 +163,8 @@
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
- * @param e the element to visit
- * @param p a visitor-specified parameter
+ * @param e {@inheritDoc}
+ * @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitType(TypeElement e, P p) {
@@ -172,21 +172,28 @@
}
/**
- * {@inheritDoc} This implementation scans the enclosed elements.
+ * {@inheritDoc}
*
- * @param e the element to visit
- * @param p a visitor-specified parameter
+ * This implementation scans the enclosed elements, unless the
+ * element is a {@code RESOURCE_VARIABLE} in which case {@code
+ * visitUnknown} is called.
+ *
+ * @param e {@inheritDoc}
+ * @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitVariable(VariableElement e, P p) {
- return scan(e.getEnclosedElements(), p);
+ if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
+ return scan(e.getEnclosedElements(), p);
+ else
+ return visitUnknown(e, p);
}
/**
* {@inheritDoc} This implementation scans the parameters.
*
- * @param e the element to visit
- * @param p a visitor-specified parameter
+ * @param e {@inheritDoc}
+ * @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitExecutable(ExecutableElement e, P p) {
@@ -196,8 +203,8 @@
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
- * @param e the element to visit
- * @param p a visitor-specified parameter
+ * @param e {@inheritDoc}
+ * @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitTypeParameter(TypeParameterElement e, P p) {
--- a/langtools/src/share/classes/javax/lang/model/util/ElementScanner7.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/ElementScanner7.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -105,4 +105,16 @@
protected ElementScanner7(R defaultValue){
super(defaultValue);
}
+
+ /**
+ * This implementation scans the enclosed elements.
+ *
+ * @param e {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of scanning
+ */
+ @Override
+ public R visitVariable(VariableElement e, P p) {
+ return scan(e.getEnclosedElements(), p);
+ }
}
--- a/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,8 @@
/**
* A simple visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
- * source version. Visit methods call {@link
- * #defaultAction} passing their arguments to {@code defaultAction}'s
+ * source version. Visit methods call {@link #defaultAction
+ * defaultAction} passing their arguments to {@code defaultAction}'s
* corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
--- a/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,8 +38,11 @@
* source version.
*
* Visit methods corresponding to {@code RELEASE_6} language
- * constructs call {@link #defaultAction}, passing their arguments to
- * {@code defaultAction}'s corresponding parameters.
+ * constructs call {@link #defaultAction defaultAction}, passing their
+ * arguments to {@code defaultAction}'s corresponding parameters.
+ *
+ * For constructs introduced in {@code RELEASE_7} and later, {@code
+ * visitUnknown} is called instead.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
@@ -137,14 +140,21 @@
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * This implementation calls {@code defaultAction}, unless the
+ * element is a {@code RESOURCE_VARIABLE} in which case {@code
+ * visitUnknown} is called.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
- * @return the result of {@code defaultAction}
+ * @return the result of {@code defaultAction} or {@code visitUnknown}
*/
public R visitVariable(VariableElement e, P p) {
- return defaultAction(e, p);
+ if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
+ return defaultAction(e, p);
+ else
+ return visitUnknown(e, p);
}
/**
--- a/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,9 +36,10 @@
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version.
*
- * Visit methods corresponding to {@code RELEASE_7} language
- * constructs call {@link #defaultAction}, passing their arguments to
- * {@code defaultAction}'s corresponding parameters.
+ * Visit methods corresponding to {@code RELEASE_7} and earlier
+ * language constructs call {@link #defaultAction defaultAction},
+ * passing their arguments to {@code defaultAction}'s corresponding
+ * parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
@@ -89,4 +90,16 @@
protected SimpleElementVisitor7(R defaultValue){
super(defaultValue);
}
+
+ /**
+ * This implementation calls {@code defaultAction}.
+ *
+ * @param e {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ */
+ @Override
+ public R visitVariable(VariableElement e, P p) {
+ return defaultAction(e, p);
+ }
}
--- a/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,11 @@
* {@link SourceVersion#RELEASE_6 RELEASE_6} source version.
*
* Visit methods corresponding to {@code RELEASE_6} language
- * constructs call {@link #defaultAction}, passing their arguments to
- * {@code defaultAction}'s corresponding parameters.
+ * constructs call {@link #defaultAction defaultAction}, passing their
+ * arguments to {@code defaultAction}'s corresponding parameters.
+ *
+ * For constructs introduced in {@code RELEASE_7} and later, {@code
+ * visitUnknown} is called instead.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
--- a/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,9 +34,10 @@
* A simple visitor of types with default behavior appropriate for the
* {@link SourceVersion#RELEASE_7 RELEASE_7} source version.
*
- * Visit methods corresponding to {@code RELEASE_7} language
- * constructs call {@link #defaultAction}, passing their arguments to
- * {@code defaultAction}'s corresponding parameters.
+ * Visit methods corresponding to {@code RELEASE_7} and earlier
+ * language constructs call {@link #defaultAction defaultAction},
+ * passing their arguments to {@code defaultAction}'s corresponding
+ * parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
@@ -88,4 +89,17 @@
protected SimpleTypeVisitor7(R defaultValue){
super(defaultValue);
}
+
+ /**
+ * This implementation visits a {@code DisjunctiveType} by calling
+ * {@code defaultAction}.
+ *
+ * @param t {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ */
+ @Override
+ public R visitDisjunctive(DisjunctiveType t, P p) {
+ return defaultAction(t, p);
+ }
}
--- a/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -92,4 +92,17 @@
protected TypeKindVisitor7(R defaultValue) {
super(defaultValue);
}
+
+ /**
+ * This implementation visits a {@code DisjunctiveType} by calling
+ * {@code defaultAction}.
+ *
+ * @param t {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ */
+ @Override
+ public R visitDisjunctive(DisjunctiveType t, P p) {
+ return defaultAction(t, p);
+ }
}
--- a/langtools/src/share/classes/javax/lang/model/util/Types.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/src/share/classes/javax/lang/model/util/Types.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/5017953/T5017953.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 5017953
+ * @summary spurious cascaded diagnostics when name not found
+ * @compile/fail/ref=T5017953.out -XDrawDiagnostics T5017953.java
+ */
+
+class T5017953 {
+
+ int f = 0;
+ void test(int i) {}
+
+ { test(NonExistentClass.f ++);
+ test(1 + NonExistentClass.f);
+ test(NonExistentClass.f + 1);
+ test(NonExistentClass.f + NonExistentClass.f);
+ test(NonExistentClass.f += 1);
+ test(f += NonExistentClass.f);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/5017953/T5017953.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,8 @@
+T5017953.java:13:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentClass, , , (compiler.misc.location: kindname.class, T5017953, null)
+T5017953.java:14:18: compiler.err.cant.resolve.location: kindname.variable, NonExistentClass, , , (compiler.misc.location: kindname.class, T5017953, null)
+T5017953.java:15:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentClass, , , (compiler.misc.location: kindname.class, T5017953, null)
+T5017953.java:16:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentClass, , , (compiler.misc.location: kindname.class, T5017953, null)
+T5017953.java:16:35: compiler.err.cant.resolve.location: kindname.variable, NonExistentClass, , , (compiler.misc.location: kindname.class, T5017953, null)
+T5017953.java:17:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentClass, , , (compiler.misc.location: kindname.class, T5017953, null)
+T5017953.java:18:19: compiler.err.cant.resolve.location: kindname.variable, NonExistentClass, , , (compiler.misc.location: kindname.class, T5017953, null)
+7 errors
--- a/langtools/test/tools/javac/6491592/T6491592.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/6491592/T6491592.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-T6491592.java:12:11: compiler.err.operator.cant.be.applied: +, java.lang.Object,compiler.misc.type.null
+T6491592.java:12:11: compiler.err.operator.cant.be.applied.1: +, java.lang.Object, compiler.misc.type.null
1 error
--- a/langtools/test/tools/javac/AnonStaticMember_2.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/AnonStaticMember_2.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute 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
+ * @test /nodynamiccopyright/
* @bug 4279339
* @summary Verify that an anonymous class cannot contain a static method.
* @author maddox
*
- * @run compile/fail AnonStaticMember_2.java
+ * @run compile/fail/ref=AnonStaticMember_2.out -XDrawDiagnostics AnonStaticMember_2.java
*/
class AnonStaticMember_2 {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/AnonStaticMember_2.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,2 @@
+AnonStaticMember_2.java:12:21: compiler.err.icls.cant.have.static.decl: compiler.misc.anonymous.class: AnonStaticMember_2$1
+1 error
--- a/langtools/test/tools/javac/ClassPathTest/ClassPathTest.sh Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/ClassPathTest/ClassPathTest.sh Mon Feb 14 16:31:21 2011 -0800
@@ -100,7 +100,7 @@
expectedResult="$1"; shift
cleanup
echo $javac ${TESTTOOLVMOPTS} "$@"
- $javac ${TESTTOOLVMOPTS} "$@"
+ "$javac" ${TESTTOOLVMOPTS} "$@"
report $expectedResult $?
}
--- a/langtools/test/tools/javac/ExtDirs/ExtDirs.sh Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/ExtDirs/ExtDirs.sh Mon Feb 14 16:31:21 2011 -0800
@@ -85,15 +85,15 @@
done
echo "Test 1"
-$javac ${TESTTOOLVMOPTS} -d . -extdirs ext1 "${TESTSRC}${FS}ExtDirTest_1.java"
+"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1 "${TESTSRC}${FS}ExtDirTest_1.java"
if [ $? -ne 0 ] ; then fail ; fi
echo "Test 2"
-$javac ${TESTTOOLVMOPTS} -d . -extdirs ext1${PS}ext2 "${TESTSRC}${FS}ExtDirTest_2.java"
+"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1${PS}ext2 "${TESTSRC}${FS}ExtDirTest_2.java"
if [ $? -ne 0 ] ; then fail ; fi
echo "Test 3"
-$javac ${TESTTOOLVMOPTS} -d . -extdirs ext3 "${TESTSRC}${FS}ExtDirTest_3.java"
+"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext3 "${TESTSRC}${FS}ExtDirTest_3.java"
if [ $? -ne 0 ] ; then fail ; fi
echo PASS: all tests gave expected results
--- a/langtools/test/tools/javac/InterfaceInInner.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/InterfaceInInner.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute 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
+ * @test /nodynamiccopyright/
* @bug 4063740
* @summary Interfaces may only be declared in top level classes.
* @author turnidge
*
- * @compile/fail InterfaceInInner.java
+ * @compile/fail/ref=InterfaceInInner.out -XDrawDiagnostics InterfaceInInner.java
*/
class InterfaceInInner {
InterfaceInInner() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/InterfaceInInner.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,2 @@
+InterfaceInInner.java:12:13: compiler.err.intf.not.allowed.here
+1 error
--- a/langtools/test/tools/javac/Paths/Help.sh Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/Paths/Help.sh Mon Feb 14 16:31:21 2011 -0800
@@ -40,8 +40,8 @@
DiagnosticsInEnglishPlease
-HELP="`$javac ${TESTTOOLVMOPTS} -help 2>&1`"
-XHELP="`$javac ${TESTTOOLVMOPTS} -X 2>&1`"
+HELP="`\"$javac\" ${TESTTOOLVMOPTS} -help 2>&1`"
+XHELP="`\"$javac\" ${TESTTOOLVMOPTS} -X 2>&1`"
#----------------------------------------------------------------
# Standard options
--- a/langtools/test/tools/javac/QualifiedNew.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/QualifiedNew.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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
+ * @test /nodynamiccopyright/
* @bug 4406966
* @summary null qualifying inner instance creation should be error.
* @author gafter
*
- * @compile/fail QualifiedNew.java
+ * @compile/fail/ref=QualifiedNew.out -XDrawDiagnostics QualifiedNew.java
*/
class QualifiedNew {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/QualifiedNew.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,3 @@
+QualifiedNew.java:14:23: compiler.err.type.found.req: compiler.misc.type.null, (compiler.misc.type.req.ref)
+QualifiedNew.java:15:29: compiler.err.cant.resolve.location: kindname.class, Y, , , (compiler.misc.location: kindname.class, QualifiedNew.Y[], null)
+2 errors
--- a/langtools/test/tools/javac/T6247324.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/T6247324.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-T6247324.java:18:6: compiler.err.cant.resolve.location: kindname.class, Seetharam, , , (compiler.misc.location: kindname.class, Pair, null)
+T6247324.java:18:6: compiler.err.cant.resolve.location: kindname.class, Seetharam, , , (compiler.misc.location: kindname.class, Pair<X,Y>, null)
1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T6554097.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6554097
+ * @summary "final" confuses at-SuppressWarnings
+ * @compile T6554097.java
+ * @compile/fail/ref=T6554097.out -XDrawDiagnostics -Werror -Xlint:serial T6554097.java
+ */
+
+class T6554097 {
+ @SuppressWarnings("serial") final Throwable[] v1 = { new Throwable() {} };
+ @SuppressWarnings("serial") Throwable[] v2 = { new Throwable() {} };
+
+ public static void m1() throws Throwable {
+ @SuppressWarnings("serial") final Throwable[] v3 = { new Throwable() {} };
+ @SuppressWarnings("serial") Throwable[] v4 = { new Throwable() {} };
+ }
+
+ final Throwable[] v5 = { new Throwable() {} };
+ Throwable[] v6 = { new Throwable() {} };
+
+ public static void m2() throws Throwable {
+ final Throwable[] v7 = { new Throwable() {} };
+ Throwable[] v8 = { new Throwable() {} };
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T6554097.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,7 @@
+T6554097.java:18:46: compiler.warn.missing.SVUID: compiler.misc.anonymous.class: T6554097$5
+T6554097.java:19:46: compiler.warn.missing.SVUID: compiler.misc.anonymous.class: T6554097$6
+T6554097.java:22:50: compiler.warn.missing.SVUID: compiler.misc.anonymous.class: T6554097$7
+T6554097.java:23:54: compiler.warn.missing.SVUID: compiler.misc.anonymous.class: T6554097$8
+- compiler.err.warnings.and.werror
+1 error
+4 warnings
--- a/langtools/test/tools/javac/T6725036.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/T6725036.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,7 @@
import com.sun.tools.javac.file.RelativePath.RelativeFile;
import com.sun.tools.javac.file.ZipFileIndex;
import com.sun.tools.javac.file.ZipFileIndexArchive;
+import com.sun.tools.javac.file.ZipFileIndexCache;
import com.sun.tools.javac.util.Context;
public class T6725036 {
@@ -57,8 +58,8 @@
JarEntry je = j.getJarEntry(TEST_ENTRY_NAME.getPath());
long jarEntryTime = je.getTime();
- ZipFileIndex zfi =
- ZipFileIndex.getZipFileIndex(rt_jar, null, false, null, false);
+ ZipFileIndexCache zfic = ZipFileIndexCache.getSharedInstance();
+ ZipFileIndex zfi = zfic.getZipFileIndex(rt_jar, null, false, null, false);
long zfiTime = zfi.getLastModified(TEST_ENTRY_NAME);
check(je, jarEntryTime, zfi + ":" + TEST_ENTRY_NAME.getPath(), zfiTime);
--- a/langtools/test/tools/javac/TryWithResources/BadTwrSyntax.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/TryWithResources/BadTwrSyntax.java Mon Feb 14 16:31:21 2011 -0800
@@ -4,13 +4,18 @@
* @author Joseph D. Darcy
* @summary Verify bad TWRs don't compile
* @compile/fail -source 6 BadTwrSyntax.java
- * @compile/fail/ref=BadTwrSyntax.out -XDrawDiagnostics BadTwrSyntax.java
+ * @compile/fail/ref=BadTwrSyntax.out -XDrawDiagnostics BadTwrSyntax.java
*/
import java.io.IOException;
public class BadTwrSyntax implements AutoCloseable {
public static void main(String... args) throws Exception {
- // illegal semicolon ending resources
+ // illegal double semicolon ending resources
+ try(BadTwr twrflow = new BadTwr();;) {
+ System.out.println(twrflow.toString());
+ }
+
+ // but one semicolon is fine
try(BadTwr twrflow = new BadTwr();) {
System.out.println(twrflow.toString());
}
--- a/langtools/test/tools/javac/TryWithResources/BadTwrSyntax.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/TryWithResources/BadTwrSyntax.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,7 @@
-BadTwrSyntax.java:14:43: compiler.err.illegal.start.of.expr
-1 error
+BadTwrSyntax.java:14:43: compiler.err.illegal.start.of.type
+BadTwrSyntax.java:14:44: compiler.err.expected: =
+BadTwrSyntax.java:14:45: compiler.err.expected: ')'
+BadTwrSyntax.java:14:47: compiler.err.expected: '{'
+BadTwrSyntax.java:15:19: compiler.err.illegal.start.of.expr
+BadTwrSyntax.java:15:23: compiler.err.expected: ';'
+6 errors
--- a/langtools/test/tools/javac/TryWithResources/DuplicateResource.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/TryWithResources/DuplicateResource.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
/*
* @test
- * @bug 6911256 6964740 6965277
+ * @bug 6911256 6964740 6965277 7013420
* @author Maurizio Cimadamore
- * @summary Check that lowered arm block does not end up creating resource twice
+ * @summary Check that lowered try-with-resources block does not end up creating resource twice
*/
import java.util.ArrayList;
@@ -45,7 +45,7 @@
static ArrayList<TestResource> resources = new ArrayList<TestResource>();
public static void main(String[] args) {
- try(new TestResource()) {
+ try(TestResource tr = new TestResource()) {
//do something
} catch (Exception e) {
throw new AssertionError("Shouldn't reach here", e);
@@ -59,7 +59,7 @@
}
TestResource resource = resources.get(0);
if (!resource.isClosed) {
- throw new AssertionError("Resource used in ARM block has not been automatically closed");
+ throw new AssertionError("Resource used in try-with-resources block has not been automatically closed");
}
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/TryWithResources/ExplicitFinal.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 7013420
+ * @author Joseph D. Darcy
+ * @summary Test that resource variables are accepted as explicitly final.
+ */
+
+import java.io.IOException;
+
+public class ExplicitFinal implements AutoCloseable {
+ public static void main(String... args) {
+ try(final ExplicitFinal r2 = new ExplicitFinal()) {
+ r2.toString();
+ } catch (IOException ioe) {
+ throw new AssertionError("Shouldn't reach here", ioe);
+ }
+
+ try(final @SuppressWarnings("unchecked") ExplicitFinal r3 = new ExplicitFinal()) {
+ r3.toString();
+ } catch (IOException ioe) {
+ throw new AssertionError("Shouldn't reach here", ioe);
+ }
+
+ try(@SuppressWarnings("unchecked") ExplicitFinal r4 = new ExplicitFinal()) {
+ r4.toString();
+ } catch (IOException ioe) {
+ throw new AssertionError("Shouldn't reach here", ioe);
+ }
+ }
+ public void close() throws IOException {
+ System.out.println("Calling close on " + this);
+ }
+}
--- a/langtools/test/tools/javac/TryWithResources/ImplicitFinal.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/TryWithResources/ImplicitFinal.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6911256 6964740 6965277
+ * @bug 6911256 6964740 6965277 7013420
* @author Maurizio Cimadamore
* @summary Test that resource variables are implicitly final
* @compile/fail/ref=ImplicitFinal.out -XDrawDiagnostics ImplicitFinal.java
@@ -15,12 +15,25 @@
} catch (IOException ioe) { // Not reachable
throw new AssertionError("Shouldn't reach here", ioe);
}
- }
+ try(@SuppressWarnings("unchecked") ImplicitFinal r1 = new ImplicitFinal()) {
+ r1 = null; //disallowed
+ } catch (IOException ioe) { // Not reachable
+ throw new AssertionError("Shouldn't reach here", ioe);
+ }
- // A close method, but the class is <em>not</em> Closeable or
- // AutoCloseable.
+ try(final ImplicitFinal r2 = new ImplicitFinal()) {
+ r2 = null; //disallowed
+ } catch (IOException ioe) { // Not reachable
+ throw new AssertionError("Shouldn't reach here", ioe);
+ }
+ try(final @SuppressWarnings("unchecked") ImplicitFinal r3 = new ImplicitFinal()) {
+ r3 = null; //disallowed
+ } catch (IOException ioe) { // Not reachable
+ throw new AssertionError("Shouldn't reach here", ioe);
+ }
+ }
public void close() throws IOException {
throw new IOException();
}
--- a/langtools/test/tools/javac/TryWithResources/ImplicitFinal.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/TryWithResources/ImplicitFinal.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,5 @@
ImplicitFinal.java:14:13: compiler.err.try.resource.may.not.be.assigned: r
-1 error
+ImplicitFinal.java:20:13: compiler.err.try.resource.may.not.be.assigned: r1
+ImplicitFinal.java:26:13: compiler.err.try.resource.may.not.be.assigned: r2
+ImplicitFinal.java:32:13: compiler.err.try.resource.may.not.be.assigned: r3
+4 errors
--- a/langtools/test/tools/javac/TryWithResources/TwrFlow.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/TryWithResources/TwrFlow.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,26 +1,16 @@
/*
* @test /nodynamiccopyright/
- * @bug 6911256 6964740
+ * @bug 6911256 6964740 7013420
* @author Joseph D. Darcy
- * @summary Test exception analysis of ARM blocks
+ * @summary Test exception analysis of try-with-resources blocks
* @compile/fail/ref=TwrFlow.out -XDrawDiagnostics TwrFlow.java
*/
import java.io.IOException;
public class TwrFlow implements AutoCloseable {
public static void main(String... args) {
- try(TwrFlow armflow = new TwrFlow()) {
- System.out.println(armflow.toString());
- } catch (IOException ioe) { // Not reachable
- throw new AssertionError("Shouldn't reach here", ioe);
- }
- // CustomCloseException should be caught or added to throws clause
-
- // Also check behavior on a resource expression rather than a
- // declaration.
- TwrFlow armflowexpr = new TwrFlow();
- try(armflowexpr) {
- System.out.println(armflowexpr.toString());
+ try(TwrFlow twrFlow = new TwrFlow()) {
+ System.out.println(twrFlow.toString());
} catch (IOException ioe) { // Not reachable
throw new AssertionError("Shouldn't reach here", ioe);
}
--- a/langtools/test/tools/javac/TryWithResources/TwrFlow.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/TryWithResources/TwrFlow.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,3 @@
TwrFlow.java:14:11: compiler.err.except.never.thrown.in.try: java.io.IOException
-TwrFlow.java:24:11: compiler.err.except.never.thrown.in.try: java.io.IOException
TwrFlow.java:12:46: compiler.err.unreported.exception.need.to.catch.or.throw: CustomCloseException
-TwrFlow.java:22:26: compiler.err.unreported.exception.need.to.catch.or.throw: CustomCloseException
-4 errors
+2 errors
--- a/langtools/test/tools/javac/TryWithResources/TwrInference.java Thu Feb 10 16:24:51 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 6911256 6964740 6965277
- * @author Maurizio Cimadamore
- * @summary Verify that method type-inference works as expected in TWR context
- * @compile TwrInference.java
- */
-
-class TwrInference {
-
- public void test() {
- try(getX()) {
- //do something
- } catch (Exception e) { // Not reachable
- throw new AssertionError("Shouldn't reach here", e);
- }
- }
-
- <X> X getX() { return null; }
-}
--- a/langtools/test/tools/javac/TryWithResources/TwrIntersection.java Thu Feb 10 16:24:51 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 6911256 6964740 6965277
- * @author Maurizio Cimadamore
- * @summary Resource of an intersection type crashes Flow
- * @compile TwrIntersection.java
- */
-
-interface MyCloseable extends AutoCloseable {
- void close() throws java.io.IOException;
-}
-
-class ResourceTypeVar {
-
- public void test() {
- try(getX()) {
- //do something
- } catch (java.io.IOException e) { // Not reachable
- throw new AssertionError("Shouldn't reach here", e);
- }
- }
-
- <X extends Number & MyCloseable> X getX() { return null; }
-}
--- a/langtools/test/tools/javac/TryWithResources/TwrIntersection02.java Thu Feb 10 16:24:51 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6911256 6964740 6965277
- * @author Maurizio Cimadamore
- * @summary Check that resources of an intersection type forces union of exception types
- * to be caught outside twr block
- * @compile/fail/ref=TwrIntersection02.out -XDrawDiagnostics TwrIntersection02.java
- */
-
-class TwrIntersection02 {
-
- static class Exception1 extends Exception {}
- static class Exception2 extends Exception {}
-
-
- interface MyResource1 extends AutoCloseable {
- void close() throws Exception1;
- }
-
- interface MyResource2 extends AutoCloseable {
- void close() throws Exception2;
- }
-
- public void test1() throws Exception1 {
- try(getX()) {
- //do something
- }
- }
-
- public void test2() throws Exception2 {
- try(getX()) {
- //do something
- }
- }
-
- <X extends MyResource1 & MyResource2> X getX() { return null; }
-}
--- a/langtools/test/tools/javac/TryWithResources/TwrIntersection02.out Thu Feb 10 16:24:51 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-TwrIntersection02.java:25:21: compiler.err.unreported.exception.need.to.catch.or.throw: TwrIntersection02.Exception2
-TwrIntersection02.java:31:21: compiler.err.unreported.exception.need.to.catch.or.throw: TwrIntersection02.Exception1
-2 errors
--- a/langtools/test/tools/javac/TryWithResources/TwrMultiCatch.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/TryWithResources/TwrMultiCatch.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6911256 6964740
+ * @bug 6911256 6964740 7013420
* @author Joseph D. Darcy
* @summary Test that TWR and multi-catch play well together
* @compile TwrMultiCatch.java
@@ -48,9 +48,9 @@
private static void test(TwrMultiCatch twrMultiCatch,
Class<? extends Exception> expected) {
- try(twrMultiCatch) {
- System.out.println(twrMultiCatch.toString());
- } catch (final CustomCloseException1 |
+ try(TwrMultiCatch tmc = twrMultiCatch) {
+ System.out.println(tmc.toString());
+ } catch (CustomCloseException1 |
CustomCloseException2 exception) {
if (!exception.getClass().equals(expected) ) {
throw new RuntimeException("Unexpected catch!");
@@ -68,7 +68,7 @@
try {
throw t;
- } catch (final CustomCloseException1 |
+ } catch (CustomCloseException1 |
CustomCloseException2 exception) {
throw exception;
} catch (Throwable throwable) {
--- a/langtools/test/tools/javac/TryWithResources/TwrOnNonResource.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/TryWithResources/TwrOnNonResource.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6911256 6964740
+ * @bug 6911256 6964740 7013420
* @author Joseph D. Darcy
* @summary Verify invalid TWR block is not accepted.
* @compile/fail -source 6 TwrOnNonResource.java
@@ -18,18 +18,6 @@
try(TwrOnNonResource aonr = new TwrOnNonResource()) {
System.out.println(aonr.toString());
} catch (Exception e) {;}
-
- // Also check expression form
- TwrOnNonResource aonr = new TwrOnNonResource();
- try(aonr) {
- System.out.println(aonr.toString());
- }
- try(aonr) {
- System.out.println(aonr.toString());
- } finally {;}
- try(aonr) {
- System.out.println(aonr.toString());
- } catch (Exception e) {;}
}
/*
--- a/langtools/test/tools/javac/TryWithResources/TwrOnNonResource.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/TryWithResources/TwrOnNonResource.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,7 +1,4 @@
TwrOnNonResource.java:12:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
TwrOnNonResource.java:15:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
TwrOnNonResource.java:18:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:24:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:27:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:30:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-6 errors
+3 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/ArgTypeCompilerFactory.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.List;
+import javax.tools.*;
+
+import com.sun.tools.javac.api.*;
+import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.DiagnosticPart;
+import com.sun.tools.javac.api.Formattable.LocalizedString;
+import com.sun.tools.javac.code.Flags.Flag;
+import com.sun.tools.javac.code.Kinds.KindName;
+import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.file.*;
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.parser.Token;
+import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration;
+import javax.lang.model.SourceVersion;
+
+/**
+ * Compiler factory for instances of Example.Compiler that use custom
+ * DiagnosticFormatter and Messages objects to track the types of args
+ * when when localizing diagnostics.
+ * The compiler objects only support "output" mode, not "check" mode.
+ */
+class ArgTypeCompilerFactory implements Example.Compiler.Factory {
+ // Same code as Example.Compiler.DefaultFactory, but the names resolve differently
+ public Example.Compiler getCompiler(List<String> opts, boolean verbose) {
+ String first;
+ String[] rest;
+ if (opts == null || opts.isEmpty()) {
+ first = null;
+ rest = new String[0];
+ } else {
+ first = opts.get(0);
+ rest = opts.subList(1, opts.size()).toArray(new String[opts.size() - 1]);
+ }
+ if (first == null || first.equals("jsr199"))
+ return new Jsr199Compiler(verbose, rest);
+ else if (first.equals("simple"))
+ return new SimpleCompiler(verbose);
+ else if (first.equals("backdoor"))
+ return new BackdoorCompiler(verbose);
+ else
+ throw new IllegalArgumentException(first);
+ }
+
+ /**
+ * Compile using the JSR 199 API. The diagnostics generated are
+ * scanned for resource keys. Not all diagnostic keys are generated
+ * via the JSR 199 API -- for example, rich diagnostics are not directly
+ * accessible, and some diagnostics generated by the file manager may
+ * not be generated (for example, the JSR 199 file manager does not see
+ * -Xlint:path).
+ */
+ static class Jsr199Compiler extends Example.Compiler {
+ List<String> fmOpts;
+
+ Jsr199Compiler(boolean verbose, String... args) {
+ super(verbose);
+ for (int i = 0; i < args.length; i++) {
+ String arg = args[i];
+ if (arg.equals("-filemanager") && (i + 1 < args.length)) {
+ fmOpts = Arrays.asList(args[++i].split(","));
+ } else
+ throw new IllegalArgumentException(arg);
+ }
+ }
+
+ @Override
+ boolean run(PrintWriter out, Set<String> keys, boolean raw, List<String> opts, List<File> files) {
+ assert out != null && keys == null;
+
+ if (verbose)
+ System.err.println("run_jsr199: " + opts + " " + files);
+
+ JavacTool tool = JavacTool.create();
+
+ StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+ if (fmOpts != null)
+ fm = new FileManager(fm, fmOpts);
+
+ Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
+
+ JavacTaskImpl t = (JavacTaskImpl) tool.getTask(out, fm, null, opts, null, fos);
+ Context c = t.getContext();
+ ArgTypeMessages.preRegister(c);
+ Options options = Options.instance(c);
+ Log.instance(c).setDiagnosticFormatter(new ArgTypeDiagnosticFormatter(options));
+ Boolean ok = t.call();
+
+ return ok;
+ }
+ }
+
+ /**
+ * Run the test using the standard simple entry point.
+ */
+ static class SimpleCompiler extends Example.Compiler {
+ SimpleCompiler(boolean verbose) {
+ super(verbose);
+ }
+
+ @Override
+ boolean run(PrintWriter out, Set<String> keys, boolean raw, List<String> opts, List<File> files) {
+ assert out != null && keys == null;
+
+ if (verbose)
+ System.err.println("run_simple: " + opts + " " + files);
+
+ List<String> args = new ArrayList<String>();
+
+ args.addAll(opts);
+ for (File f: files)
+ args.add(f.getPath());
+
+ Main main = new Main("javac", out);
+ Context c = new Context() {
+ @Override public void clear() {
+ ((JavacFileManager) get(JavaFileManager.class)).close();
+ super.clear();
+ }
+ };
+ JavacFileManager.preRegister(c); // can't create it until Log has been set up
+ ArgTypeDiagnosticFormatter.preRegister(c);
+ ArgTypeMessages.preRegister(c);
+ int result = main.compile(args.toArray(new String[args.size()]), c);
+
+ return (result == 0);
+ }
+ }
+
+ static class BackdoorCompiler extends Example.Compiler {
+ BackdoorCompiler(boolean verbose) {
+ super(verbose);
+ }
+
+ @Override
+ boolean run(PrintWriter out, Set<String> keys, boolean raw, List<String> opts, List<File> files) {
+ assert out != null && keys == null;
+
+ if (verbose)
+ System.err.println("run_simple: " + opts + " " + files);
+
+ List<String> args = new ArrayList<String>(opts);
+ for (File f: files)
+ args.add(f.getPath());
+
+ Context c = new Context();
+ JavacFileManager.preRegister(c); // can't create it until Log has been set up
+ ArgTypeDiagnosticFormatter.preRegister(c);
+ ArgTypeMessages.preRegister(c);
+ com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", out);
+ int rc = m.compile(args.toArray(new String[args.size()]), c);
+
+ return (rc == 0);
+ }
+
+ }
+
+
+ // <editor-fold defaultstate="collapsed" desc="Custom Javac components">
+
+ /**
+ * Diagnostic formatter which reports formats a diag as a series of lines
+ * containing a key, and a possibly empty set of descriptive strings for the
+ * arg types.
+ */
+ static class ArgTypeDiagnosticFormatter extends AbstractDiagnosticFormatter {
+ static void preRegister(final Context context) {
+ context.put(Log.logKey, new Context.Factory<Log>() {
+ public Log make() {
+ Log log = new Log(context) { };
+ Options options = Options.instance(context);
+ log.setDiagnosticFormatter(new ArgTypeDiagnosticFormatter(options));
+ return log;
+ }
+ });
+
+ }
+
+ ArgTypeDiagnosticFormatter(Options options) {
+ super(null, new SimpleConfiguration(options,
+ EnumSet.of(DiagnosticPart.SUMMARY,
+ DiagnosticPart.DETAILS,
+ DiagnosticPart.SUBDIAGNOSTICS)));
+ }
+
+ @Override
+ protected String formatDiagnostic(JCDiagnostic d, Locale locale) {
+ return formatMessage(d, locale);
+ }
+
+ @Override
+ public String formatMessage(JCDiagnostic d, Locale l) {
+ StringBuilder buf = new StringBuilder();
+ formatMessage(d, buf);
+ return buf.toString();
+ }
+
+ private void formatMessage(JCDiagnostic d, StringBuilder buf) {
+ String key = d.getCode();
+ Object[] args = d.getArgs();
+ // report the primary arg types, without recursing into diag fragments
+ buf.append(getKeyArgsString(key, args));
+ // report details for any diagnostic fragments
+ for (Object arg: args) {
+ if (arg instanceof JCDiagnostic) {
+ buf.append("\n");
+ formatMessage((JCDiagnostic) arg, buf);
+ }
+ }
+ // report details for any subdiagnostics
+ for (String s: formatSubdiagnostics(d, null)) {
+ buf.append("\n");
+ buf.append(s);
+ }
+ }
+
+ @Override
+ public boolean isRaw() {
+ return true;
+ }
+ }
+
+ /**
+ * Diagnostic formatter which "localizes" a message as a line
+ * containing a key, and a possibly empty set of descriptive strings for the
+ * arg types.
+ */
+ static class ArgTypeMessages extends JavacMessages {
+ static void preRegister(final Context c) {
+ c.put(JavacMessages.messagesKey, new Context.Factory<JavacMessages>() {
+ public JavacMessages make() {
+ return new ArgTypeMessages(c) {
+ @Override
+ public String getLocalizedString(Locale l, String key, Object... args) {
+ return getKeyArgsString(key, args);
+ }
+ };
+ }
+ });
+ }
+
+ ArgTypeMessages(Context context) {
+ super(context);
+ }
+ }
+
+ /**
+ * Utility method to generate a string for key and args
+ */
+ static String getKeyArgsString(String key, Object... args) {
+ StringBuilder buf = new StringBuilder();
+ buf.append(key);
+ String sep = ": ";
+ for (Object o : args) {
+ buf.append(sep);
+ buf.append(getArgTypeOrStringValue(o));
+ sep = ", ";
+ }
+ return buf.toString();
+ }
+
+ static boolean showStringValues = false;
+
+ static String getArgTypeOrStringValue(Object o) {
+ if (showStringValues && o instanceof String)
+ return "\"" + o + "\"";
+ return getArgType(o);
+ }
+
+ static String getArgType(Object o) {
+ if (o == null)
+ return "null";
+ if (o instanceof Name)
+ return "name";
+ if (o instanceof Boolean)
+ return "boolean";
+ if (o instanceof Integer)
+ return "number";
+ if (o instanceof String)
+ return "string";
+ if (o instanceof Flag)
+ return "modifier";
+ if (o instanceof KindName)
+ return "symbol kind";
+ if (o instanceof Token)
+ return "token";
+ if (o instanceof Symbol)
+ return "symbol";
+ if (o instanceof Type)
+ return "type";
+ if (o instanceof List) {
+ List<?> l = (List<?>) o;
+ if (l.isEmpty())
+ return "list";
+ else
+ return "list of " + getArgType(l.get(0));
+ }
+ if (o instanceof ListBuffer)
+ return getArgType(((ListBuffer) o).toList());
+ if (o instanceof Set) {
+ Set<?> s = (Set<?>) o;
+ if (s.isEmpty())
+ return "set";
+ else
+ return "set of " + getArgType(s.iterator().next());
+ }
+ if (o instanceof SourceVersion)
+ return "source version";
+ if (o instanceof FileObject || o instanceof File)
+ return "file name";
+ if (o instanceof JCDiagnostic)
+ return "message segment";
+ if (o instanceof LocalizedString)
+ return "message segment"; // only instance is "no arguments"
+ String s = o.getClass().getSimpleName();
+ return (s.isEmpty() ? o.getClass().getName() : s);
+ }
+
+ // </editor-fold>
+
+}
--- a/langtools/test/tools/javac/diags/Example.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/diags/Example.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -168,7 +168,7 @@
try {
run(null, keys, true, verbose);
} catch (IOException e) {
- e.printStackTrace();
+ e.printStackTrace(System.err);
}
return keys;
}
@@ -293,10 +293,15 @@
}
abstract static class Compiler {
- static Compiler getCompiler(List<String> opts, boolean verbose) {
+ interface Factory {
+ Compiler getCompiler(List<String> opts, boolean verbose);
+ }
+
+ static class DefaultFactory implements Factory {
+ public Compiler getCompiler(List<String> opts, boolean verbose) {
String first;
String[] rest;
- if (opts == null || opts.size() == 0) {
+ if (opts == null || opts.isEmpty()) {
first = null;
rest = new String[0];
} else {
@@ -311,6 +316,16 @@
return new BackdoorCompiler(verbose);
else
throw new IllegalArgumentException(first);
+ }
+ }
+
+ static Factory factory;
+
+ static Compiler getCompiler(List<String> opts, boolean verbose) {
+ if (factory == null)
+ factory = new DefaultFactory();
+
+ return factory.getCompiler(opts, verbose);
}
protected Compiler(boolean verbose) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/MessageFile.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,463 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Class to facilitate manipulating compiler.properties.
+ */
+class MessageFile {
+ static final Pattern emptyOrCommentPattern = Pattern.compile("( *#.*)?");
+ static final Pattern infoPattern = Pattern.compile("# ([0-9]+: [-A-Za-z ]+, )*[0-9]+: [-A-Za-z ]+");
+
+ /**
+ * A line of text within the message file.
+ * The lines form a doubly linked list for simple navigation.
+ */
+ class Line {
+ String text;
+ Line prev;
+ Line next;
+
+ Line(String text) {
+ this.text = text;
+ }
+
+ boolean isEmptyOrComment() {
+ return emptyOrCommentPattern.matcher(text).matches();
+ }
+
+ boolean isInfo() {
+ return infoPattern.matcher(text).matches();
+ }
+
+ boolean hasContinuation() {
+ return (next != null) && text.endsWith("\\");
+ }
+
+ Line insertAfter(String text) {
+ Line l = new Line(text);
+ insertAfter(l);
+ return l;
+ }
+
+ void insertAfter(Line l) {
+ assert prev == null && next == null;
+ l.prev = this;
+ l.next = next;
+ if (next == null)
+ lastLine = l;
+ else
+ next.prev = l;
+ next = l;
+ }
+
+ Line insertBefore(String text) {
+ Line l = new Line(text);
+ insertBefore(l);
+ return l;
+ }
+
+ void insertBefore(Line l) {
+ assert prev == null && next == null;
+ l.prev = prev;
+ l.next = this;
+ if (prev == null)
+ firstLine = l;
+ else
+ prev.next = l;
+ prev = l;
+ }
+
+ void remove() {
+ if (prev == null)
+ firstLine = next;
+ else
+ prev.next = next;
+ if (next == null)
+ lastLine = prev;
+ else
+ next.prev = prev;
+ prev = null;
+ next = null;
+ }
+ }
+
+ /**
+ * A message within the message file.
+ * A message is a series of lines containing a "name=value" property,
+ * optionally preceded by a comment describing the use of placeholders
+ * such as {0}, {1}, etc within the property value.
+ */
+ static final class Message {
+ final Line firstLine;
+ private Info info;
+
+ Message(Line l) {
+ firstLine = l;
+ }
+
+ boolean needInfo() {
+ Line l = firstLine;
+ while (true) {
+ if (l.text.matches(".*\\{[0-9]+\\}.*"))
+ return true;
+ if (!l.hasContinuation())
+ return false;
+ l = l.next;
+ }
+ }
+
+ Set<Integer> getPlaceholders() {
+ Pattern p = Pattern.compile("\\{([0-9]+)\\}");
+ Set<Integer> results = new TreeSet<Integer>();
+ Line l = firstLine;
+ while (true) {
+ Matcher m = p.matcher(l.text);
+ while (m.find())
+ results.add(Integer.parseInt(m.group(1)));
+ if (!l.hasContinuation())
+ return results;
+ l = l.next;
+ }
+ }
+
+ /**
+ * Get the Info object for this message. It may be empty if there
+ * if no comment preceding the property specification.
+ */
+ Info getInfo() {
+ if (info == null) {
+ Line l = firstLine.prev;
+ if (l != null && l.isInfo())
+ info = new Info(l.text);
+ else
+ info = new Info();
+ }
+ return info;
+ }
+
+ /**
+ * Set the Info for this message.
+ * If there was an info comment preceding the property specification,
+ * it will be updated; otherwise, one will be inserted.
+ */
+ void setInfo(Info info) {
+ this.info = info;
+ Line l = firstLine.prev;
+ if (l != null && l.isInfo())
+ l.text = info.toComment();
+ else
+ firstLine.insertBefore(info.toComment());
+ }
+
+ /**
+ * Get all the lines pertaining to this message.
+ */
+ List<Line> getLines(boolean includeAllPrecedingComments) {
+ List<Line> lines = new ArrayList<Line>();
+ Line l = firstLine;
+ if (includeAllPrecedingComments) {
+ // scan back to find end of prev message
+ while (l.prev != null && l.prev.isEmptyOrComment())
+ l = l.prev;
+ // skip leading blank lines
+ while (l.text.isEmpty())
+ l = l.next;
+ } else {
+ if (l.prev != null && l.prev.isInfo())
+ l = l.prev;
+ }
+
+ // include any preceding lines
+ for ( ; l != firstLine; l = l.next)
+ lines.add(l);
+
+ // include message lines
+ for (l = firstLine; l != null && l.hasContinuation(); l = l.next)
+ lines.add(l);
+ lines.add(l);
+
+ // include trailing blank line if present
+ l = l.next;
+ if (l != null && l.text.isEmpty())
+ lines.add(l);
+
+ return lines;
+ }
+ }
+
+ /**
+ * An object to represent the comment that may precede the property
+ * specification in a Message.
+ * The comment is modelled as a list of fields, where the fields correspond
+ * to the placeholder values (e.g. {0}, {1}, etc) within the message value.
+ */
+ static final class Info {
+ /**
+ * An ordered set of descriptions for a placeholder value in a
+ * message.
+ */
+ static class Field {
+ boolean unused;
+ Set<String> values;
+ boolean listOfAny = false;
+ boolean setOfAny = false;
+ Field(String s) {
+ s = s.substring(s.indexOf(": ") + 2);
+ values = new LinkedHashSet<String>(Arrays.asList(s.split(" or ")));
+ for (String v: values) {
+ if (v.startsWith("list of"))
+ listOfAny = true;
+ if (v.startsWith("set of"))
+ setOfAny = true;
+ }
+ }
+
+ /**
+ * Return true if this field logically contains all the values of
+ * another field.
+ */
+ boolean contains(Field other) {
+ if (unused != other.unused)
+ return false;
+
+ for (String v: other.values) {
+ if (values.contains(v))
+ continue;
+ if (v.equals("null") || v.equals("string"))
+ continue;
+ if (v.equals("list") && listOfAny)
+ continue;
+ if (v.equals("set") && setOfAny)
+ continue;
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Merge the values of another field into this field.
+ */
+ void merge(Field other) {
+ unused |= other.unused;
+ values.addAll(other.values);
+
+ // cleanup unnecessary entries
+
+ if (values.contains("null") && values.size() > 1) {
+ // "null" is superceded by anything else
+ values.remove("null");
+ }
+
+ if (values.contains("string") && values.size() > 1) {
+ // "string" is superceded by anything else
+ values.remove("string");
+ }
+
+ if (values.contains("list")) {
+ // list is superceded by "list of ..."
+ for (String s: values) {
+ if (s.startsWith("list of ")) {
+ values.remove("list");
+ break;
+ }
+ }
+ }
+
+ if (values.contains("set")) {
+ // set is superceded by "set of ..."
+ for (String s: values) {
+ if (s.startsWith("set of ")) {
+ values.remove("set");
+ break;
+ }
+ }
+ }
+
+ if (other.values.contains("unused")) {
+ values.clear();
+ values.add("unused");
+ }
+ }
+
+ void markUnused() {
+ values = new LinkedHashSet<String>();
+ values.add("unused");
+ listOfAny = false;
+ setOfAny = false;
+ }
+
+ @Override
+ public String toString() {
+ return values.toString();
+ }
+ }
+
+ /** The fields of the Info object. */
+ List<Field> fields = new ArrayList<Field>();
+
+ Info() { }
+
+ Info(String text) throws IllegalArgumentException {
+ if (!text.startsWith("# "))
+ throw new IllegalArgumentException();
+ String[] segs = text.substring(2).split(", ");
+ fields = new ArrayList<Field>();
+ for (String seg: segs) {
+ fields.add(new Field(seg));
+ }
+ }
+
+ Info(Set<String> infos) throws IllegalArgumentException {
+ for (String s: infos)
+ merge(new Info(s));
+ }
+
+ boolean isEmpty() {
+ return fields.isEmpty();
+ }
+
+ boolean contains(Info other) {
+ if (other.isEmpty())
+ return true;
+
+ if (fields.size() != other.fields.size())
+ return false;
+
+ Iterator<Field> oIter = other.fields.iterator();
+ for (Field values: fields) {
+ if (!values.contains(oIter.next()))
+ return false;
+ }
+
+ return true;
+ }
+
+ void merge(Info other) {
+ if (fields.isEmpty()) {
+ fields.addAll(other.fields);
+ return;
+ }
+
+ if (other.fields.size() != fields.size())
+ throw new IllegalArgumentException();
+
+ Iterator<Field> oIter = other.fields.iterator();
+ for (Field d: fields) {
+ d.merge(oIter.next());
+ }
+ }
+
+ void markUnused(Set<Integer> used) {
+ for (int i = 0; i < fields.size(); i++) {
+ if (!used.contains(i))
+ fields.get(i).markUnused();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return fields.toString();
+ }
+
+ String toComment() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("# ");
+ String sep = "";
+ int i = 0;
+ for (Field f: fields) {
+ sb.append(sep);
+ sb.append(i++);
+ sb.append(": ");
+ sep = "";
+ for (String s: f.values) {
+ sb.append(sep);
+ sb.append(s);
+ sep = " or ";
+ }
+ sep = ", ";
+ }
+ return sb.toString();
+ }
+ }
+
+ Line firstLine;
+ Line lastLine;
+ Map<String, Message> messages = new TreeMap<String, Message>();
+
+ MessageFile(File file) throws IOException {
+ Reader in = new FileReader(file);
+ try {
+ read(in);
+ } finally {
+ in.close();
+ }
+ }
+
+ MessageFile(Reader in) throws IOException {
+ read(in);
+ }
+
+ final void read(Reader in) throws IOException {
+ BufferedReader br = (in instanceof BufferedReader)
+ ? (BufferedReader) in
+ : new BufferedReader(in);
+ String line;
+ while ((line = br.readLine()) != null) {
+ Line l;
+ if (firstLine == null)
+ l = firstLine = lastLine = new Line(line);
+ else
+ l = lastLine.insertAfter(line);
+ if (line.startsWith("compiler.")) {
+ int eq = line.indexOf("=");
+ if (eq > 0)
+ messages.put(line.substring(0, eq), new Message(l));
+ }
+ }
+ }
+
+ void write(File file) throws IOException {
+ Writer out = new FileWriter(file);
+ try {
+ write(out);
+ } finally {
+ out.close();
+ }
+ }
+
+ void write(Writer out) throws IOException {
+ BufferedWriter bw = (out instanceof BufferedWriter)
+ ? (BufferedWriter) out
+ : new BufferedWriter(out);
+ for (Line l = firstLine; l != null; l = l.next) {
+ bw.write(l.text);
+ bw.write("\n"); // always use Unix line endings
+ }
+ bw.flush();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/MessageInfo.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,410 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 7013272
+ * @summary Automatically generate info about how compiler resource keys are used
+ * @build Example ArgTypeCompilerFactory MessageFile MessageInfo
+ * @run main MessageInfo
+ */
+
+import java.io.*;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * Utility to manipulate compiler.properties, and suggest info comments based
+ * on information derived from running examples.
+ *
+ * Options:
+ * -examples dir location of examples directory
+ * -o file output file
+ * -check just check message file
+ * -ensureNewlines ensure newline after each entry
+ * -fixIndent fix indentation of continuation lines
+ * -sort sort messages
+ * -verbose verbose output
+ * -replace replace comments instead of merging comments
+ * file javac compiler.properties file
+ *
+ */
+public class MessageInfo {
+ public static void main(String... args) throws Exception {
+ jtreg = (System.getProperty("test.src") != null);
+ File tmpDir;
+ if (jtreg) {
+ // use standard jtreg scratch directory: the current directory
+ tmpDir = new File(System.getProperty("user.dir"));
+ } else {
+ tmpDir = new File(System.getProperty("java.io.tmpdir"),
+ MessageInfo.class.getName()
+ + (new SimpleDateFormat("yyMMddHHmmss")).format(new Date()));
+ }
+ Example.setTempDir(tmpDir);
+ Example.Compiler.factory = new ArgTypeCompilerFactory();
+
+ MessageInfo mi = new MessageInfo();
+
+ try {
+ if (mi.run(args))
+ return;
+ } finally {
+ /* VERY IMPORTANT NOTE. In jtreg mode, tmpDir is set to the
+ * jtreg scratch directory, which is the current directory.
+ * In case someone is faking jtreg mode, make sure to only
+ * clean tmpDir when it is reasonable to do so.
+ */
+ if (tmpDir.isDirectory() &&
+ tmpDir.getName().startsWith(MessageInfo.class.getName())) {
+ if (clean(tmpDir))
+ tmpDir.delete();
+ }
+ }
+
+ if (jtreg)
+ throw new Exception(mi.errors + " errors occurred");
+ else
+ System.exit(1);
+ }
+
+ void usage() {
+ System.out.println("Usage:");
+ System.out.println(" java MessageInfo [options] [file]");
+ System.out.println("where options include");
+ System.out.println(" -examples dir location of examples directory");
+ System.out.println(" -o file output file");
+ System.out.println(" -check just check message file");
+ System.out.println(" -ensureNewlines ensure newline after each entry");
+ System.out.println(" -fixIndent fix indentation of continuation lines");
+ System.out.println(" -sort sort messages");
+ System.out.println(" -verbose verbose output");
+ System.out.println(" -replace replace comments instead of merging comments");
+ System.out.println(" file javac compiler.properties file");
+ }
+
+ boolean run(String... args) {
+ File testSrc = new File(System.getProperty("test.src", "."));
+ File examplesDir = new File(testSrc, "examples");
+ File notYetFile = null;
+ File msgFile = null;
+ File outFile = null;
+ boolean verbose = false;
+ boolean ensureNewlines = false;
+ boolean fixIndent = false;
+ boolean sort = false;
+ boolean replace = false;
+ boolean check = jtreg; // default true in jtreg mode
+
+ for (int i = 0; i < args.length; i++) {
+ String arg = args[i];
+ if (arg.equals("-examples") && (i + 1) < args.length)
+ examplesDir = new File(args[++i]);
+ else if(arg.equals("-notyet") && (i + 1) < args.length)
+ notYetFile = new File(args[++i]);
+ else if (arg.equals("-ensureNewlines"))
+ ensureNewlines = true;
+ else if (arg.equals("-fixIndent"))
+ fixIndent = true;
+ else if (arg.equals("-sort"))
+ sort = true;
+ else if (arg.equals("-verbose"))
+ verbose = true;
+ else if (arg.equals("-replace"))
+ replace = true;
+ else if (arg.equals("-check"))
+ check = true;
+ else if (arg.equals("-o") && (i + 1) < args.length)
+ outFile = new File(args[++i]);
+ else if (arg.startsWith("-")) {
+ error("unknown option: " + arg);
+ return false;
+ } else if (i == args.length - 1) {
+ msgFile = new File(arg);
+ } else {
+ error("unknown arg: " + arg);
+ return false;
+ }
+ }
+
+ if (!check && outFile == null) {
+ usage();
+ return true;
+ }
+
+ if ((ensureNewlines || fixIndent || sort) && outFile == null) {
+ error("must set output file for these options");
+ return false;
+ }
+
+ if (notYetFile == null) {
+ notYetFile = new File(examplesDir.getParentFile(), "examples.not-yet.txt");
+ }
+
+ if (msgFile == null) {
+ for (File d = testSrc; d != null; d = d.getParentFile()) {
+ if (new File(d, "TEST.ROOT").exists()) {
+ d = d.getParentFile();
+ File f = new File(d, "src/share/classes/com/sun/tools/javac/resources/compiler.properties");
+ if (f.exists()) {
+ msgFile = f;
+ break;
+ }
+ }
+ }
+ if (msgFile == null) {
+ if (jtreg) {
+ System.err.println("Warning: no message file available, test skipped");
+ return true;
+ }
+ error("no message file available");
+ return false;
+ }
+ }
+
+ MessageFile mf;
+ try {
+ mf = new MessageFile(msgFile);
+ } catch (IOException e) {
+ error("problem reading message file: " + e);
+ return false;
+ }
+
+ Map<String, Set<String>> msgInfo = runExamples(examplesDir, verbose);
+
+ if (ensureNewlines)
+ ensureNewlines(mf);
+
+ if (fixIndent)
+ fixIndent(mf);
+
+ if (sort)
+ sort(mf, true);
+
+ for (Map.Entry<String, Set<String>> e: msgInfo.entrySet()) {
+ String k = e.getKey();
+ Set<String> suggestions = e.getValue();
+ MessageFile.Message m = mf.messages.get(k);
+ if (m == null) {
+ error("Can't find message for " + k + " in message file");
+ continue;
+ }
+
+ MessageFile.Info info = m.getInfo();
+ Set<Integer> placeholders = m.getPlaceholders();
+ MessageFile.Info suggestedInfo = new MessageFile.Info(suggestions);
+ suggestedInfo.markUnused(placeholders);
+
+ if (!info.isEmpty()) {
+ if (info.contains(suggestedInfo))
+ continue;
+ if (!replace) {
+ if (info.fields.size() != suggestedInfo.fields.size())
+ error("Cannot merge info for " + k);
+ else
+ suggestedInfo.merge(info);
+ }
+ }
+
+ if (outFile == null) {
+ System.err.println("suggest for " + k);
+ System.err.println(suggestedInfo.toComment());
+ } else
+ m.setInfo(suggestedInfo);
+ }
+
+ if (check)
+ check(mf, notYetFile);
+
+ try {
+ if (outFile != null)
+ mf.write(outFile);
+ } catch (IOException e) {
+ error("problem writing file: " + e);
+ return false;
+ }
+
+ return (errors == 0);
+ }
+
+ void check(MessageFile mf, File notYetFile) {
+ Set<String> notYetList = null;
+ for (Map.Entry<String, MessageFile.Message> e: mf.messages.entrySet()) {
+ String key = e.getKey();
+ MessageFile.Message m = e.getValue();
+ if (m.needInfo() && m.getInfo().isEmpty()) {
+ if (notYetList == null)
+ notYetList = getNotYetList(notYetFile);
+ if (notYetList.contains(key))
+ System.err.println("Warning: no info for " + key);
+ else
+ error("no info for " + key);
+ }
+ }
+
+ }
+
+ void ensureNewlines(MessageFile mf) {
+ for (MessageFile.Message m: mf.messages.values()) {
+ MessageFile.Line l = m.firstLine;
+ while (l.text.endsWith("\\"))
+ l = l.next;
+ if (l.next != null && !l.next.text.isEmpty())
+ l.insertAfter("");
+ }
+ }
+
+ void fixIndent(MessageFile mf) {
+ for (MessageFile.Message m: mf.messages.values()) {
+ MessageFile.Line l = m.firstLine;
+ while (l.text.endsWith("\\") && l.next != null) {
+ if (!l.next.text.matches("^ \\S.*"))
+ l.next.text = " " + l.next.text.trim();
+ l = l.next;
+ }
+ }
+ }
+
+ void sort(MessageFile mf, boolean includePrecedingNewlines) {
+ for (MessageFile.Message m: mf.messages.values()) {
+ for (MessageFile.Line l: m.getLines(includePrecedingNewlines)) {
+ l.remove();
+ mf.lastLine.insertAfter(l);
+ }
+ }
+ }
+
+ Map<String, Set<String>> runExamples(File examplesDir, boolean verbose) {
+ Map<String, Set<String>> map = new TreeMap<String, Set<String>>();
+ for (Example e: getExamples(examplesDir)) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ e.run(pw, true, verbose);
+ pw.close();
+ String[] lines = sw.toString().split("\n");
+ for (String line: lines) {
+ if (!line.startsWith("compiler."))
+ continue;
+ int colon = line.indexOf(":");
+ if (colon == -1)
+ continue;
+ String key = line.substring(0, colon);
+ StringBuilder sb = new StringBuilder();
+ sb.append("# ");
+ int i = 0;
+ String[] descs = line.substring(colon + 1).split(", *");
+ for (String desc: descs) {
+ if (i > 0) sb.append(", ");
+ sb.append(i++);
+ sb.append(": ");
+ sb.append(desc.trim());
+ }
+ Set<String> set = map.get(key);
+ if (set == null)
+ map.put(key, set = new TreeSet<String>());
+ set.add(sb.toString());
+ }
+ }
+
+ return map;
+ }
+
+ /**
+ * Get the complete set of examples to be checked.
+ */
+ Set<Example> getExamples(File examplesDir) {
+ Set<Example> results = new TreeSet<Example>();
+ for (File f: examplesDir.listFiles()) {
+ if (isValidExample(f))
+ results.add(new Example(f));
+ }
+ return results;
+ }
+
+ boolean isValidExample(File f) {
+ return (f.isDirectory() && (!jtreg || f.list().length > 0)) ||
+ (f.isFile() && f.getName().endsWith(".java"));
+ }
+
+ /**
+ * Get the contents of the "not-yet" list.
+ */
+ Set<String> getNotYetList(File file) {
+ Set<String> results = new TreeSet<String>();
+ try {
+ String[] lines = read(file).split("[\r\n]");
+ for (String line: lines) {
+ int hash = line.indexOf("#");
+ if (hash != -1)
+ line = line.substring(0, hash).trim();
+ if (line.matches("[A-Za-z0-9-_.]+"))
+ results.add(line);
+ }
+ } catch (IOException e) {
+ throw new Error(e);
+ }
+ return results;
+ }
+
+ /**
+ * Read the contents of a file.
+ */
+ String read(File f) throws IOException {
+ byte[] bytes = new byte[(int) f.length()];
+ DataInputStream in = new DataInputStream(new FileInputStream(f));
+ try {
+ in.readFully(bytes);
+ } finally {
+ in.close();
+ }
+ return new String(bytes);
+ }
+
+ /**
+ * Report an error.
+ */
+ void error(String msg) {
+ System.err.println("Error: " + msg);
+ errors++;
+ }
+
+ static boolean jtreg;
+
+ int errors;
+
+ /**
+ * Clean the contents of a directory.
+ */
+ static boolean clean(File dir) {
+ boolean ok = true;
+ for (File f: dir.listFiles()) {
+ if (f.isDirectory())
+ ok &= clean(f);
+ ok &= f.delete();
+ }
+ return ok;
+ }
+
+}
+
+
--- a/langtools/test/tools/javac/diags/RunExamples.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/diags/RunExamples.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
* @test
* @bug 6968063
* @summary provide examples of code that generate diagnostics
- * @build Example HTMLWriter RunExamples
+ * @build ArgTypeCompilerFactory Example HTMLWriter RunExamples
* @run main RunExamples
*/
@@ -97,6 +97,7 @@
boolean raw = false;
boolean showFiles = false;
boolean verbose = false;
+ boolean argTypes = false;
String title = null;
for (int i = 0; i < args.length; i++) {
@@ -115,6 +116,8 @@
outFile = new File(args[++i]);
else if (arg.equals("-title") && (i + 1) < args.length)
title = args[++i];
+ else if (arg.equals("-argtypes"))
+ argTypes = true;
else if (arg.startsWith("-")) {
error("unknown option: " + arg);
return false;
@@ -127,6 +130,11 @@
}
}
+ // special mode to show message keys and the types of the args that
+ // are used.
+ if (argTypes)
+ Example.Compiler.factory = new ArgTypeCompilerFactory();
+
if (selectedKeys.size() > 0) {
Set<Example> examples = getExamples(examplesDir);
nextKey:
@@ -138,7 +146,7 @@
error("Key " + k + ": no examples found");
}
} else {
- if (selectedExamples.size() == 0)
+ if (selectedExamples.isEmpty())
selectedExamples = getExamples(examplesDir);
}
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt Mon Feb 14 16:31:21 2011 -0800
@@ -63,7 +63,6 @@
compiler.misc.fatal.err.cant.close.loader # JavacProcessingEnvironment
compiler.misc.file.does.not.contain.package
compiler.misc.illegal.start.of.class.file
-compiler.misc.inferred.do.not.conform.to.params # UNUSED (hard to see if very complex inference scenario might require this though, so leaving it in, as per JLS3)
compiler.misc.kindname.annotation
compiler.misc.kindname.enum
compiler.misc.kindname.package
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/InaccessibleVarargsType/InaccessibleVarargsType.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.misc.inaccessible.varargs.type
+// key: compiler.err.cant.apply.symbol.1
+
+import p1.B;
+
+class InaccessibleVarargsType {
+ { new B().foo(new B(), new B()); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/InaccessibleVarargsType/p1/A.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+class A {
+ A() { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/InaccessibleVarargsType/p1/B.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+public class B extends A {
+ public B() {}
+ public void foo(A... args) { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NameClashSameErasureNoHide.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.name.clash.same.erasure.no.hide
+
+public class NameClashSameErasureNoHide<X> {
+ static class A {
+ static void m(NameClashSameErasureNoHide<String> l) {}
+ }
+
+ static class B extends A {
+ static void m(NameClashSameErasureNoHide<Integer> l) {}
+ }
+}
--- a/langtools/test/tools/javac/diags/examples/NameClashSameErasureNoOverride.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/diags/examples/NameClashSameErasureNoOverride.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,10 @@
public class NameClashSameErasureNoOverride<X> {
static class A {
- static void m(NameClashSameErasureNoOverride<String> l) {}
+ void m(NameClashSameErasureNoOverride<String> l) {}
}
static class B extends A {
- static void m(NameClashSameErasureNoOverride<Integer> l) {}
+ void m(NameClashSameErasureNoOverride<Integer> l) {}
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NameClashSameErasureNoOverride1.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.name.clash.same.erasure.no.override.1
+
+public class NameClashSameErasureNoOverride1 {
+
+ interface I<X> {
+ void m(X l);
+ }
+
+ class A {
+ void m(Object l) {}
+ }
+
+ class B extends A implements I<Integer> {
+ public void m(Integer l) {}
+ }
+}
--- a/langtools/test/tools/javac/generics/5009937/T5009937.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/5009937/T5009937.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-T5009937.java:16:21: compiler.err.name.clash.same.erasure.no.override: m(T5009937<java.lang.Integer>), T5009937.B, m(T5009937<java.lang.String>), T5009937.A
+T5009937.java:16:21: compiler.err.name.clash.same.erasure.no.hide: m(T5009937<java.lang.Integer>), T5009937.B, m(T5009937<java.lang.String>), T5009937.A
1 error
--- a/langtools/test/tools/javac/generics/6182950/T6182950b.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/6182950/T6182950b.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-T6182950b.java:15:16: compiler.err.name.clash.same.erasure.no.override: m(java.util.List<java.lang.Integer>), T6182950b.B, m(java.util.List<java.lang.String>), T6182950b.A
+T6182950b.java:15:16: compiler.err.name.clash.same.erasure.no.override: m(java.util.List<java.lang.Integer>), T6182950b.B, m(java.util.List<java.lang.String>), T6182950b.A, m(java.util.List<java.lang.Integer>), T6182950b.B
1 error
--- a/langtools/test/tools/javac/generics/6476118/T6476118a.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/6476118/T6476118a.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-T6476118a.java:14:20: compiler.err.name.clash.same.erasure.no.override: compareTo(T), java.lang.Comparable, compareTo(java.lang.Object), T6476118a.A
+T6476118a.java:14:20: compiler.err.name.clash.same.erasure.no.override.1: compareTo(T6476118a.B), T6476118a.B, compareTo(java.lang.Object), T6476118a.A, compareTo(T), java.lang.Comparable
1 error
--- a/langtools/test/tools/javac/generics/6476118/T6476118b.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/6476118/T6476118b.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-T6476118b.java:12:20: compiler.err.name.clash.same.erasure.no.override: compareTo(T), java.lang.Comparable, compareTo(java.lang.Object), T6476118b
+T6476118b.java:12:20: compiler.err.name.clash.same.erasure.no.override.1: compareTo(T6476118b.B), T6476118b.B, compareTo(java.lang.Object), T6476118b, compareTo(T), java.lang.Comparable
1 error
--- a/langtools/test/tools/javac/generics/6476118/T6476118c.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/6476118/T6476118c.java Mon Feb 14 16:31:21 2011 -0800
@@ -5,7 +5,7 @@
* @compile/fail/ref=T6476118c.out -XDrawDiagnostics T6476118c.java
*/
-class T6476118b {
+class T6476118c {
static class A<T> {
public void foo(T t) { }
}
--- a/langtools/test/tools/javac/generics/6476118/T6476118c.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/6476118/T6476118c.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,3 +1,3 @@
-T6476118c.java:18:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Object), T6476118b.C, foo(T), T6476118b.A
-T6476118c.java:19:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Number), T6476118b.C, foo(T), T6476118b.B
+T6476118c.java:18:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Object), T6476118c.C, foo(T), T6476118c.A, foo(java.lang.Object), T6476118c.C
+T6476118c.java:19:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Number), T6476118c.C, foo(T), T6476118c.B, foo(java.lang.Number), T6476118c.C
2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6910550/T6910550a.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6910550
+ *
+ * @summary javac 1.5.0_17 fails with incorrect error message
+ * @compile/fail/ref=T6910550a.out -XDrawDiagnostics T6910550a.java
+ *
+ */
+import java.util.*;
+
+class T6910550a {
+ void m(List<String> ls) {}
+ void m(List<Integer> li) {}
+
+ { m(Arrays.asList(12)); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6910550/T6910550a.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,2 @@
+T6910550a.java:13:10: compiler.err.name.clash.same.erasure: m(java.util.List<java.lang.Integer>), m(java.util.List<java.lang.String>)
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6910550/T6910550b.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6910550
+ *
+ * @summary javac 1.5.0_17 fails with incorrect error message
+ * @compile/fail/ref=T6910550b.out -XDrawDiagnostics T6910550b.java
+ *
+ */
+
+class T6910550b<X, Y, Z> {
+ void m(X x) {}
+ void m(Y y) {}
+ void m(Z y) {}
+
+ { m(null); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6910550/T6910550b.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,3 @@
+T6910550b.java:12:10: compiler.err.name.clash.same.erasure: m(Y), m(X)
+T6910550b.java:13:10: compiler.err.name.clash.same.erasure: m(Z), m(X)
+2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6910550/T6910550c.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6910550
+ *
+ * @summary javac 1.5.0_17 fails with incorrect error message
+ * @compile/fail/ref=T6910550c.out -XDrawDiagnostics T6910550c.java
+ *
+ */
+
+class T6910550c {
+ void m(Object[] x) {}
+ void m(Object... x) {}
+
+ { m(); }
+ { m(null); }
+ { m(null, null); }
+ { m(null, null, null); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6910550/T6910550c.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,2 @@
+T6910550c.java:12:10: compiler.err.array.and.varargs: m(java.lang.Object...), m(java.lang.Object[]), T6910550c
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6910550/T6910550d.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6910550
+ *
+ * @summary javac 1.5.0_17 fails with incorrect error message
+ * @compile/fail/ref=T6910550d.out -XDrawDiagnostics T6910550d.java
+ *
+ */
+
+class T6910550d {
+ <X> void m(X x) {}
+ <Y> void m(Y y) {}
+
+ { m(null); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6910550/T6910550d.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,2 @@
+T6910550d.java:12:14: compiler.err.already.defined: <X>m(X), T6910550d
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6910550/T6910550e.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6910550
+ *
+ * @summary javac 1.5.0_17 fails with incorrect error message
+ * @compile/fail/ref=T6910550e.out -XDrawDiagnostics T6910550e.java
+ *
+ */
+
+class T6910550e {
+ static class Pair<X,Y> {}
+
+ <X> void m(Pair<X,X> x) {}
+ <X,Y> void m(Pair<X,Y> y) {}
+
+ { m(new Pair<String,String>());
+ m(new Pair<String,Integer>()); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6910550/T6910550e.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,2 @@
+T6910550e.java:14:16: compiler.err.name.clash.same.erasure: <X,Y>m(T6910550e.Pair<X,Y>), <X>m(T6910550e.Pair<X,X>)
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6969184/T6969184.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6956758
+ *
+ * @summary poor error recovery after symbol not found
+ * @author Maurizio Cimadamore
+ * @compile/fail/ref=T6969184.out -XDrawDiagnostics T6969184.java
+ *
+ */
+
+class T6969184 {
+ static class C1<X> {
+ void m1(C1<? extends NonExistentClass> n) {}
+ void m2(C1<? super NonExistentClass> n) {}
+ void m3(C1<?> n) {}
+ }
+
+ static class C2<X extends NonExistentBound> {
+ void m1(C2<? extends NonExistentClass> n) {}
+ void m2(C2<? super NonExistentClass> n) {}
+ void m3(C2<?> n) {}
+ }
+
+ static class C3<X extends NonExistentBound1 & NonExistentBound2> {
+ void m1(C3<? extends NonExistentClass> n) {}
+ void m2(C3<? super NonExistentClass> n) {}
+ void m3(C3<?> n) {}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6969184/T6969184.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,10 @@
+T6969184.java:13:30: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, T6969184.C1<X>, null)
+T6969184.java:14:28: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, T6969184.C1<X>, null)
+T6969184.java:18:31: compiler.err.cant.resolve.location: kindname.class, NonExistentBound, , , (compiler.misc.location: kindname.class, T6969184, null)
+T6969184.java:19:30: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, T6969184.C2<X>, null)
+T6969184.java:20:28: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, T6969184.C2<X>, null)
+T6969184.java:24:31: compiler.err.cant.resolve.location: kindname.class, NonExistentBound1, , , (compiler.misc.location: kindname.class, T6969184, null)
+T6969184.java:24:51: compiler.err.cant.resolve.location: kindname.class, NonExistentBound2, , , (compiler.misc.location: kindname.class, T6969184, null)
+T6969184.java:25:30: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, T6969184.C3<X>, null)
+T6969184.java:26:28: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, T6969184.C3<X>, null)
+9 errors
--- a/langtools/test/tools/javac/generics/6985719/T6985719e.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/6985719/T6985719e.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-T6985719e.java:13:34: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719e.B, f(java.util.List<java.lang.String>), T6985719e.A
+T6985719e.java:13:34: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719e.B, f(java.util.List<java.lang.String>), T6985719e.A, f(java.util.List<java.lang.Integer>), T6985719e.B
1 error
--- a/langtools/test/tools/javac/generics/6985719/T6985719f.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/6985719/T6985719f.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-T6985719f.java:13:39: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719f.B, f(java.util.List<java.lang.String>), T6985719f.A
+T6985719f.java:13:39: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719f.B, f(java.util.List<java.lang.String>), T6985719f.A, f(java.util.List<java.lang.Integer>), T6985719f.B
1 error
--- a/langtools/test/tools/javac/generics/6985719/T6985719g.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/6985719/T6985719g.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-T6985719g.java:13:42: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719g.B, f(java.util.List<X>), T6985719g.A
+T6985719g.java:13:42: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719g.B, f(java.util.List<X>), T6985719g.A, f(java.util.List<java.lang.Integer>), T6985719g.B
1 error
--- a/langtools/test/tools/javac/generics/6985719/T6985719h.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/6985719/T6985719h.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-T6985719h.java:13:56: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719h.B, f(java.util.List<X>), T6985719h.A
+T6985719h.java:13:56: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719h.B, f(java.util.List<X>), T6985719h.A, f(java.util.List<java.lang.Integer>), T6985719h.B
1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7007615/T7007615.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7007615
+ * @summary java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123.
+ * @author mcimadamore
+ * @compile/fail/ref=T7007615.out -XDrawDiagnostics T7007615.java
+ */
+
+class T6985719a {
+ class AX<T extends Number> {
+ void foo(T t) { }
+ }
+
+ class BX<S extends Integer> extends AX<S> {
+ @Override
+ void foo(S t) { }
+ void bar(BX bx){}
+ }
+
+ class DX extends BX<Integer> {
+ void foo(Number t) { }
+ void bar(BX<?> bx) { }
+
+ @Override
+ void foo(Integer t) { }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7007615/T7007615.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,3 @@
+T7007615.java:21:14: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Number), T6985719a.DX, foo(T), T6985719a.AX, foo(java.lang.Number), T6985719a.DX
+T7007615.java:22:14: compiler.err.name.clash.same.erasure.no.override: bar(T6985719a.BX<?>), T6985719a.DX, bar(T6985719a.BX), T6985719a.BX, bar(T6985719a.BX<?>), T6985719a.DX
+2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7007615/acc1/AccessibilityCheck01.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7007615
+ * @summary java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123.
+ * @author dlsmith
+ * @compile AccessibilityCheck01.java
+ */
+
+public class AccessibilityCheck01 extends p2.E {
+ String m(Object o) { return "hi"; } // this is okay
+ int m(String s) { return 3; } // this overrides m(String) illegally
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7007615/acc1/p1/C.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+public class C<T> { void m(T arg) { } /* implicit: m(Object) */ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7007615/acc1/p1/D.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+public class D<T> extends C<T> { /* inherits m(T), implicit m(Object) */ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7007615/acc1/p2/E.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p2;
+public class E<T> extends p1.D<T> { /* inherits nothing */ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7007615/acc2/AccessibilityCheck02.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7007615
+ * @summary java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123.
+ * @author dlsmith
+ * @compile/fail/ref=AccessibilityCheck02.out -XDrawDiagnostics AccessibilityCheck02.java
+ */
+
+public class AccessibilityCheck02 extends p2.E {
+ String m(Object o) { return "hi"; } // this is okay
+ public int m(String s) { return 3; } // this overrides m(String) illegally
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7007615/acc2/AccessibilityCheck02.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,2 @@
+AccessibilityCheck02.java:11:14: compiler.err.override.incompatible.ret: (compiler.misc.cant.override: m(java.lang.String), AccessibilityCheck02, m(java.lang.String), p1.D), int, void
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7007615/acc2/p1/C.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+public class C<T> { void m(T arg) { } /* implicit: m(Object) */ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7007615/acc2/p1/D.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+public class D extends C<String> { public void m(String arg) {} /* implicit bridge: m(Object) */ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7007615/acc2/p2/E.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p2;
+public class E extends p1.D { /* inherits m(String) but not m(Object) */ }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg01.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.out Mon Feb 14 16:31:21 2011 -0800
@@ -17,7 +17,7 @@
Neg01.java:29:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
Neg01.java:29:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
Neg01.java:30:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:31:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01, null)
+Neg01.java:31:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01<X>, null)
Neg01.java:31:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
Neg01.java:33:15: compiler.err.not.within.bounds: java.lang.String, X
Neg01.java:33:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
--- a/langtools/test/tools/javac/generics/inference/6638712/T6638712c.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712c.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-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<?>>)
+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.no.conforming.assignment.exists: java.util.Comparator<java.lang.Enum<?>>, java.util.Comparator<? super java.lang.Enum>)
1 error
--- a/langtools/test/tools/javac/generics/inference/6638712/T6638712d.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712d.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,2 +1,2 @@
-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>>)
+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.no.conforming.assignment.exists: int, java.lang.String)
1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6838943/T6838943.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,16 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 6838943
+ * @summary inference: javac is not handling type-variable substitution properly
+ * @compile/fail/ref=T6838943.out -XDrawDiagnostics T6838943.java
+ */
+class T6838943 {
+ static class A<X> {}
+ static class B {}
+ static class C<X> {
+ <Z> void m(X x, Z z) {
+ C<A<Z>> c = new C<A<Z>>();
+ c.m(new A<B>(), new B()); //should fail
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6838943/T6838943.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,2 @@
+T6838943.java:13:14: compiler.err.cant.apply.symbol.1: kindname.method, m, T6838943.A<Z>,Z, T6838943.A<T6838943.B>,T6838943.B, kindname.class, T6838943.C<X>, (compiler.misc.infer.no.conforming.assignment.exists: Z, T6838943.A<T6838943.B>, T6838943.A<Z>)
+1 error
--- a/langtools/test/tools/javac/generics/inference/6943278/T6943278.out Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/generics/inference/6943278/T6943278.out Mon Feb 14 16:31:21 2011 -0800
@@ -1,3 +1,3 @@
T6943278.java:7:35: compiler.err.cant.resolve: kindname.class, NonExistentInterface, ,
-T6943278.java:9:25: compiler.err.cant.resolve.location: kindname.class, NonExistentInterface, , , (compiler.misc.location: kindname.class, T6943278, null)
+T6943278.java:9:25: compiler.err.cant.resolve.location: kindname.class, NonExistentInterface, , , (compiler.misc.location: kindname.class, T6943278<X>, null)
2 errors
--- a/langtools/test/tools/javac/javazip/Test.sh Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/javazip/Test.sh Mon Feb 14 16:31:21 2011 -0800
@@ -66,8 +66,8 @@
# clean old classes
rm -f ${TC}${FS}*.class
- echo "$*"
- if $* 2>&1 ; then
+ echo "$@"
+ if "$@" 2>&1 ; then
actual=ok
else
actual=err
--- a/langtools/test/tools/javac/nio/compileTest/CompileTest.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/nio/compileTest/CompileTest.java Mon Feb 14 16:31:21 2011 -0800
@@ -84,8 +84,7 @@
System.err.println("Test " + count + " " + Arrays.asList(opts) + " " + className);
Path testSrcDir = Paths.get(System.getProperty("test.src"));
Path testClassesDir = Paths.get(System.getProperty("test.classes"));
- Path classes = Paths.get("classes." + count);
- classes.createDirectory();
+ Path classes = Files.createDirectory(Paths.get("classes." + count));
Context ctx = new Context();
PathFileManager fm = new JavacPathFileManager(ctx, true, null);
--- a/langtools/test/tools/javac/processing/model/element/TestResourceVariable.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/processing/model/element/TestResourceVariable.java Mon Feb 14 16:31:21 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6911256 6964740 6967842
+ * @bug 6911256 6964740 6967842 6961571
* @summary Test that the resource variable kind is appropriately set
* @author Joseph D. Darcy
* @library ../../../lib
@@ -31,8 +31,6 @@
* @compile -processor TestResourceVariable -proc:only TestResourceVariable.java
*/
-// Bug should be filed for this misbehavior
-
import java.io.*;
import javax.annotation.processing.*;
import javax.lang.model.*;
@@ -82,6 +80,33 @@
try(TestResourceVariable trv1 = this; TestResourceVariable trv2 = trv1) {}
}
+ /**
+ * Verify that a resource variable modeled as an element behaves
+ * as expected under 6 and 7 specific visitors.
+ */
+ private static void testResourceVariable(Element element) {
+ ElementVisitor visitor6 = new ElementKindVisitor6<Void, Void>() {};
+
+ try {
+ visitor6.visit(element);
+ throw new RuntimeException("Expected UnknownElementException not thrown.");
+ } catch (UnknownElementException uee) {
+ ; // Expected.
+ }
+
+ ElementKindVisitor7 visitor7 = new ElementKindVisitor7<Object, Void>() {
+ @Override
+ public Object visitVariableAsResourceVariable(VariableElement e,
+ Void p) {
+ return e; // a non-null value
+ }
+ };
+
+ if (visitor7.visit(element) == null) {
+ throw new RuntimeException("Null result of resource variable visitation.");
+ }
+ }
+
class ResourceVariableScanner extends TreeScanner<Void, CompilationUnitTree> {
private Trees trees;
@@ -92,17 +117,14 @@
@Override
public Void visitVariable(VariableTree node, CompilationUnitTree cu) {
Element element = trees.getElement(trees.getPath(cu, node));
- if (element == null) {
- System.out.println("Null variable element: " + node);
- } else {
- System.out.println("Name: " + element.getSimpleName() +
- "\tKind: " + element.getKind());
- }
- if (element != null &&
- element.getKind() == ElementKind.RESOURCE_VARIABLE) {
+
+ System.out.println("Name: " + element.getSimpleName() +
+ "\tKind: " + element.getKind());
+ if (element.getKind() == ElementKind.RESOURCE_VARIABLE) {
+ testResourceVariable(element);
resourceVariableCount++;
}
return super.visitVariable(node, cu);
}
- }
+ }
}
--- a/langtools/test/tools/javac/scope/HashCollisionTest.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/scope/HashCollisionTest.java Mon Feb 14 16:31:21 2011 -0800
@@ -47,7 +47,6 @@
JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab
names = Names.instance(context); // Name.Table impls tied to an instance of Names
symtab = Symtab.instance(context);
- scopeCounter = ScopeCounter.instance(context);
// determine hashMask for an empty scope
Scope emptyScope = new Scope(symtab.unnamedPackage); // any owner will do
@@ -171,7 +170,7 @@
*/
ClassSymbol createClass(Name name, Symbol owner) {
ClassSymbol sym = new ClassSymbol(0, name, owner);
- sym.members_field = new ClassScope(sym, scopeCounter);
+ sym.members_field = new Scope(sym);
if (owner != symtab.unnamedPackage)
owner.members().enter(sym);
return sym;
@@ -247,5 +246,4 @@
Names names;
Symtab symtab;
- ScopeCounter scopeCounter;
}
--- a/langtools/test/tools/javac/scope/StarImportTest.java Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/scope/StarImportTest.java Mon Feb 14 16:31:21 2011 -0800
@@ -136,7 +136,6 @@
JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab
names = Names.instance(context); // Name.Table impls tied to an instance of Names
symtab = Symtab.instance(context);
- scopeCounter = ScopeCounter.instance(context);
int setupCount = rgen.nextInt(MAX_SETUP_COUNT);
for (int i = 0; i < setupCount; i++) {
switch (random(SetupKind.values())) {
@@ -303,7 +302,7 @@
ClassSymbol createClass(Name name, Symbol owner) {
ClassSymbol sym = new ClassSymbol(0, name, owner);
- sym.members_field = new ClassScope(sym, scopeCounter);
+ sym.members_field = new Scope(sym);
if (owner != symtab.unnamedPackage)
owner.members().enter(sym);
return sym;
@@ -311,7 +310,6 @@
Context context;
Symtab symtab;
- ScopeCounter scopeCounter;
Names names;
int nextNameSerial;
List<PackageSymbol> packages = new ArrayList<PackageSymbol>();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/tree/T6963934.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6963934
+ * @summary JCCompilationUnit.getImports does not report all imports
+ */
+
+import java.io.File;
+import javax.tools.JavaCompiler;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;; // NOTE: extra semicolon for test
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.ImportTree;
+import com.sun.source.util.JavacTask;
+; // NOTE: extra semicolon for test
+
+public class T6963934 {
+ public static void main(String[] args) throws Exception {
+ File testSrc = new File(System.getProperty("test.src"));
+ File thisSrc = new File(testSrc, T6963934.class.getSimpleName() + ".java");
+ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
+ JavacTask task = (JavacTask) compiler.getTask(null, fileManager, null, null, null,
+ fileManager.getJavaFileObjects(thisSrc));
+ CompilationUnitTree tree = task.parse().iterator().next();
+ int count = 0;
+ for (ImportTree importTree : tree.getImports()) {
+ System.out.println(importTree);
+ count++;
+ }
+ int expected = 7;
+ if (count != expected)
+ throw new Exception("unexpected number of imports found: " + count + ", expected: " + expected);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/varargs/6313164/T6313164.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6313164
+ * @author mcimadamore
+ * @summary javac generates code that fails byte code verification for the varargs feature
+ * @compile/fail/ref=T6313164.out -XDrawDiagnostics T6313164.java
+ */
+import p1.*;
+
+class T6313164 {
+ { B b = new B();
+ b.foo1(new B(), new B()); //error - A not accesible
+ b.foo2(new B(), new B()); //ok - A not accessible, but foo2(Object...) applicable
+ b.foo3(null, null); //error - A (inferred) not accesible
+ b.foo4(null, null); //error - A (inferred in 15.12.2.8 - no resolution backtrack) not accesible
+ b.foo4(new B(), new C()); //ok - A (inferred in 15.12.2.7) not accessible, but foo4(Object...) applicable
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/varargs/6313164/T6313164.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,6 @@
+T6313164.java:12:8: compiler.err.cant.apply.symbol.1: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
+T6313164.java:14:13: compiler.err.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
+T6313164.java:15:13: compiler.err.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
+- compiler.note.unchecked.filename: B.java
+- compiler.note.unchecked.recompile
+3 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/varargs/6313164/p1/A.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+class A {
+ A() { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/varargs/6313164/p1/B.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+public class B extends A {
+ public B() {}
+ public void foo1(A... args) { }
+ public void foo2(A... args) { }
+ public void foo2(Object... args) { }
+ public <X extends A> void foo3(X... args) { }
+ public <X extends A> void foo4(X... args) { }
+ public void foo4(Object... args) { }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/varargs/6313164/p1/C.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+public class C extends A { }
--- a/langtools/test/tools/javac/versions/check.sh Thu Feb 10 16:24:51 2011 -0800
+++ b/langtools/test/tools/javac/versions/check.sh Mon Feb 14 16:31:21 2011 -0800
@@ -32,7 +32,7 @@
J="$TESTJAVA/bin/java"
JC="$TESTJAVA/bin/javac"
-CFV="$J ${TESTVMOPTS} -cp $TC CheckClassFileVersion"
+CFV="${TESTVMOPTS} -cp $TC CheckClassFileVersion"
rm -f $TC/X.java $TC/X.java
echo 'public class X { }' > $TC/X.java
@@ -44,7 +44,7 @@
check() {
V=$1; shift
echo "+ javac $* [$V]"
- $JC ${TESTTOOLVMOPTS} -d $TC $* $TC/X.java && $CFV $TC/X.class $V || exit 2
+ "$JC" ${TESTTOOLVMOPTS} -d $TC $* $TC/X.java && "$J" $CFV $TC/X.class $V || exit 2
}
check 48.0 -source 1.4
@@ -73,7 +73,7 @@
fail() {
echo "+ javac $*"
- if $JC ${TESTTOOLVMOPTS} -d $TC $*; then
+ if "$JC" ${TESTTOOLVMOPTS} -d $TC $*; then
echo "-- did not fail as expected"
exit 3
else
@@ -83,7 +83,7 @@
pass() {
echo "+ javac $*"
- if $JC ${TESTTOOLVMOPTS} -d $TC $*; then
+ if "$JC" ${TESTTOOLVMOPTS} -d $TC $*; then
echo "-- passed"
else
echo "-- failed"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/warnings/6594914/DeprecatedClass.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+@Deprecated
+class DeprecatedClass extends Exception {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/warnings/6594914/T6594914a.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,29 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 6594914
+ * @summary \\@SuppressWarnings("deprecation") does not not work for the type of a variable
+ * @compile/ref=T6594914a.out -XDrawDiagnostics -Xlint:deprecation T6594914a.java
+ */
+
+
+class T6747671a {
+
+ DeprecatedClass a1; //warn
+
+ @SuppressWarnings("deprecation")
+ DeprecatedClass a2;
+
+ <X extends DeprecatedClass> DeprecatedClass m1(DeprecatedClass a)
+ throws DeprecatedClass { return null; } //warn
+
+ @SuppressWarnings("deprecation")
+ <X extends DeprecatedClass> DeprecatedClass m2(DeprecatedClass a)
+ throws DeprecatedClass { return null; }
+
+ void test() {
+ DeprecatedClass a1; //warn
+
+ @SuppressWarnings("deprecation")
+ DeprecatedClass a2;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/warnings/6594914/T6594914a.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,7 @@
+T6594914a.java:11:5: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
+T6594914a.java:16:16: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
+T6594914a.java:16:52: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
+T6594914a.java:16:33: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
+T6594914a.java:17:20: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
+T6594914a.java:24:9: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
+6 warnings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/warnings/6594914/T6594914b.java Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,29 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 6594914
+ * @summary \\@SuppressWarnings("deprecation") does not not work for the type of a variable
+ * @compile/ref=T6594914b.out -XDenableSunApiLintControl -XDrawDiagnostics -Xlint:sunapi T6594914b.java
+ */
+
+
+class T6747671b {
+
+ sun.misc.Lock a1; //warn
+
+ @SuppressWarnings("sunapi")
+ sun.misc.Lock a2;
+
+ <X extends sun.misc.Lock> sun.misc.Lock m1(sun.misc.Lock a)
+ throws sun.misc.CEFormatException { return null; } //warn
+
+ @SuppressWarnings("sunapi")
+ <X extends sun.misc.Lock> sun.misc.Lock m2(sun.misc.Lock a)
+ throws sun.misc.CEFormatException { return null; }
+
+ void test() {
+ sun.misc.Lock a1; //warn
+
+ @SuppressWarnings("sunapi")
+ sun.misc.Lock a2;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/warnings/6594914/T6594914b.out Mon Feb 14 16:31:21 2011 -0800
@@ -0,0 +1,7 @@
+T6594914b.java:11:13: compiler.warn.sun.proprietary: sun.misc.Lock
+T6594914b.java:16:24: compiler.warn.sun.proprietary: sun.misc.Lock
+T6594914b.java:16:56: compiler.warn.sun.proprietary: sun.misc.Lock
+T6594914b.java:16:39: compiler.warn.sun.proprietary: sun.misc.Lock
+T6594914b.java:17:28: compiler.warn.sun.proprietary: sun.misc.CEFormatException
+T6594914b.java:24:17: compiler.warn.sun.proprietary: sun.misc.Lock
+6 warnings