mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
Merge
This commit is contained in:
commit
59ccd77845
164 changed files with 4394 additions and 1107 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -280,7 +280,7 @@ public class AptJavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
|
|||
}
|
||||
|
||||
if (verbose)
|
||||
printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
|
||||
log.printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
|
||||
|
||||
chk.reportDeferredDiagnostics();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -48,15 +48,15 @@ public class Bark extends Log {
|
|||
* Preregisters factories to create and use a Bark object for use as
|
||||
* both a Log and a Bark.
|
||||
*/
|
||||
public static void preRegister(final Context context) {
|
||||
public static void preRegister(Context context) {
|
||||
context.put(barkKey, new Context.Factory<Bark>() {
|
||||
public Bark make() {
|
||||
return new Bark(context);
|
||||
public Bark make(Context c) {
|
||||
return new Bark(c);
|
||||
}
|
||||
});
|
||||
context.put(Log.logKey, new Context.Factory<Log>() {
|
||||
public Log make() {
|
||||
return Bark.instance(context);
|
||||
public Log make(Context c) {
|
||||
return Bark.instance(c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
|
@ -156,7 +156,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
|||
if (index < 0) {
|
||||
return htmlstr;
|
||||
}
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
int previndex = 0;
|
||||
while (true) {
|
||||
// Search for lowercase version of {@docRoot}
|
||||
|
@ -2279,7 +2279,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
|||
*/
|
||||
public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags,
|
||||
boolean isFirstSentence) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
// Array of all possible inline tags for this javadoc run
|
||||
configuration.tagletManager.checkTags(doc, tags, true);
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
|
@ -2315,7 +2315,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
|||
StringTokenizer lines = new StringTokenizer(text, "\r\n", true);
|
||||
StringBuffer textBuff = new StringBuffer();
|
||||
while (lines.hasMoreTokens()) {
|
||||
StringBuffer line = new StringBuffer(lines.nextToken());
|
||||
StringBuilder line = new StringBuilder(lines.nextToken());
|
||||
Util.replaceTabs(configuration.sourcetab, line);
|
||||
textBuff.append(line.toString());
|
||||
}
|
||||
|
@ -2473,7 +2473,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
|||
return text;
|
||||
}
|
||||
int endindex = startindex + tobe.length();
|
||||
StringBuffer replaced = new StringBuffer();
|
||||
StringBuilder replaced = new StringBuilder();
|
||||
if (startindex > 0) {
|
||||
replaced.append(text.substring(0, startindex));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
|
@ -30,7 +30,6 @@ import java.util.*;
|
|||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.taglets.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
import com.sun.tools.doclets.formats.html.markup.*;
|
||||
|
||||
/**
|
||||
|
@ -53,7 +52,7 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
|
|||
}
|
||||
|
||||
public List<FieldDoc> members(ClassDoc cd) {
|
||||
return Util.asList(cd.serializableFields());
|
||||
return Arrays.asList(cd.serializableFields());
|
||||
}
|
||||
|
||||
protected void printTypeLinkNoDimension(Type type) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 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
|
||||
|
@ -266,7 +266,7 @@ public class SourceToHTMLConverter {
|
|||
private static void addLine(Content pre, String line, int tabLength,
|
||||
int currentLineNo) {
|
||||
if (line != null) {
|
||||
StringBuffer lineBuffer = new StringBuffer(Util.escapeHtmlChars(line));
|
||||
StringBuilder lineBuffer = new StringBuilder(Util.escapeHtmlChars(line));
|
||||
Util.replaceTabs(tabLength, lineBuffer);
|
||||
pre.addContent(new RawHtml(lineBuffer.toString()));
|
||||
Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
|
@ -375,8 +375,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
|
|||
*/
|
||||
public void buildFieldSerializationOverview(ClassDoc classDoc, Content classContentTree) {
|
||||
if (classDoc.definesSerializableFields()) {
|
||||
FieldDoc serialPersistentField =
|
||||
Util.asList(classDoc.serializableFields()).get(0);
|
||||
FieldDoc serialPersistentField = classDoc.serializableFields()[0];
|
||||
// Check to see if there are inline comments, tags or deprecation
|
||||
// information to be printed.
|
||||
if (fieldWriter.shouldPrintOverview(serialPersistentField)) {
|
||||
|
|
|
@ -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
|
||||
|
@ -382,7 +382,7 @@ public class Util {
|
|||
out.close();
|
||||
}
|
||||
} catch (IOException ie) {
|
||||
ie.printStackTrace();
|
||||
ie.printStackTrace(System.err);
|
||||
throw new DocletAbortException();
|
||||
}
|
||||
}
|
||||
|
@ -399,12 +399,12 @@ public class Util {
|
|||
String pkgPath = DirectoryManager.getDirectoryPath(pkgDoc);
|
||||
String completePath = new SourcePath(configuration.sourcepath).
|
||||
getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPARATOR;
|
||||
//Make sure that both paths are using the same seperators.
|
||||
//Make sure that both paths are using the same separators.
|
||||
completePath = Util.replaceText(completePath, File.separator,
|
||||
DirectoryManager.URL_FILE_SEPARATOR);
|
||||
pkgPath = Util.replaceText(pkgPath, File.separator,
|
||||
DirectoryManager.URL_FILE_SEPARATOR);
|
||||
return completePath.substring(0, completePath.indexOf(pkgPath));
|
||||
return completePath.substring(0, completePath.lastIndexOf(pkgPath));
|
||||
} catch (Exception e){
|
||||
return "";
|
||||
}
|
||||
|
@ -536,15 +536,6 @@ public class Util {
|
|||
findAllInterfaceTypes(results, (ClassDoc) type, true, configuration);
|
||||
}
|
||||
|
||||
|
||||
public static <T extends ProgramElementDoc> List<T> asList(T[] members) {
|
||||
List<T> list = new ArrayList<T>();
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
list.add(members[i]);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enclose in quotes, used for paths and filenames that contains spaces
|
||||
*/
|
||||
|
@ -583,14 +574,7 @@ public class Util {
|
|||
if (oldStr == null || newStr == null || oldStr.equals(newStr)) {
|
||||
return originalStr;
|
||||
}
|
||||
StringBuffer result = new StringBuffer(originalStr);
|
||||
int startIndex = 0;
|
||||
while ((startIndex = result.indexOf(oldStr, startIndex)) != -1) {
|
||||
result = result.replace(startIndex, startIndex + oldStr.length(),
|
||||
newStr);
|
||||
startIndex += newStr.length();
|
||||
}
|
||||
return result.toString();
|
||||
return originalStr.replace(oldStr, newStr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -833,19 +817,17 @@ public class Util {
|
|||
* @param tabLength the length of each tab.
|
||||
* @param s the String to scan.
|
||||
*/
|
||||
public static void replaceTabs(int tabLength, StringBuffer s) {
|
||||
int index, col;
|
||||
StringBuffer whitespace;
|
||||
while ((index = s.indexOf("\t")) != -1) {
|
||||
whitespace = new StringBuffer();
|
||||
col = index;
|
||||
do {
|
||||
whitespace.append(" ");
|
||||
col++;
|
||||
} while ((col%tabLength) != 0);
|
||||
s.replace(index, index+1, whitespace.toString());
|
||||
public static void replaceTabs(int tabLength, StringBuilder s) {
|
||||
if (whitespace == null || whitespace.length() < tabLength)
|
||||
whitespace = String.format("%" + tabLength + "s", " ");
|
||||
int index = 0;
|
||||
while ((index = s.indexOf("\t", index)) != -1) {
|
||||
int spaceCount = tabLength - index % tabLength;
|
||||
s.replace(index, index+1, whitespace.substring(0, spaceCount));
|
||||
index += spaceCount;
|
||||
}
|
||||
}
|
||||
private static String whitespace;
|
||||
|
||||
/**
|
||||
* The documentation for values() and valueOf() in Enums are set by the
|
||||
|
|
|
@ -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
|
||||
|
@ -157,19 +157,19 @@ public final class JavacTool implements JavaCompiler {
|
|||
/**
|
||||
* Register that a compilation is about to start.
|
||||
*/
|
||||
void beginContext(final Context context) {
|
||||
void beginContext(Context context) {
|
||||
if (compilationInProgress)
|
||||
throw new IllegalStateException("Compilation in progress");
|
||||
compilationInProgress = true;
|
||||
final JavaFileManager givenFileManager = context.get(JavaFileManager.class);
|
||||
context.put(JavaFileManager.class, (JavaFileManager)null);
|
||||
context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
|
||||
public JavaFileManager make() {
|
||||
public JavaFileManager make(Context c) {
|
||||
if (givenFileManager != null) {
|
||||
context.put(JavaFileManager.class, givenFileManager);
|
||||
c.put(JavaFileManager.class, givenFileManager);
|
||||
return givenFileManager;
|
||||
} else {
|
||||
return new JavacFileManager(context, true, null);
|
||||
return new JavacFileManager(c, true, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -43,7 +43,7 @@ public class Flags {
|
|||
private Flags() {} // uninstantiable
|
||||
|
||||
public static String toString(long flags) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
String sep = "";
|
||||
for (Flag s : asFlagSet(flags)) {
|
||||
buf.append(sep);
|
||||
|
|
|
@ -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
|
||||
|
@ -163,6 +163,7 @@ public class Kinds {
|
|||
case PARAMETER:
|
||||
case LOCAL_VARIABLE:
|
||||
case EXCEPTION_PARAMETER:
|
||||
case RESOURCE_VARIABLE:
|
||||
return KindName.VAR;
|
||||
|
||||
case CONSTRUCTOR:
|
||||
|
|
|
@ -831,6 +831,8 @@ public abstract class Symbol implements Element {
|
|||
ClassType t = (ClassType)type;
|
||||
if (t.interfaces_field == null) // FIXME: shouldn't be null
|
||||
t.interfaces_field = List.nil();
|
||||
if (t.all_interfaces_field != null)
|
||||
return Type.getModelTypes(t.all_interfaces_field);
|
||||
return t.interfaces_field;
|
||||
} else {
|
||||
return List.nil();
|
||||
|
@ -846,7 +848,7 @@ public abstract class Symbol implements Element {
|
|||
// An interface has no superclass; its supertype is Object.
|
||||
return t.isInterface()
|
||||
? Type.noType
|
||||
: t.supertype_field;
|
||||
: t.supertype_field.getModelType();
|
||||
} else {
|
||||
return Type.noType;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -26,6 +26,8 @@
|
|||
package com.sun.tools.javac.code;
|
||||
|
||||
import java.util.*;
|
||||
import javax.lang.model.type.TypeVisitor;
|
||||
import javax.lang.model.element.ElementVisitor;
|
||||
|
||||
import com.sun.tools.javac.util.*;
|
||||
import com.sun.tools.javac.util.List;
|
||||
|
@ -345,7 +347,12 @@ public class Symtab {
|
|||
target = Target.instance(context);
|
||||
|
||||
// Create the unknown type
|
||||
unknownType = new Type(TypeTags.UNKNOWN, null);
|
||||
unknownType = new Type(TypeTags.UNKNOWN, null) {
|
||||
@Override
|
||||
public <R, P> R accept(TypeVisitor<R, P> v, P p) {
|
||||
return v.visitUnknown(this, p);
|
||||
}
|
||||
};
|
||||
|
||||
// create the basic builtin symbols
|
||||
rootPackage = new PackageSymbol(names.empty, null);
|
||||
|
@ -355,14 +362,21 @@ public class Symtab {
|
|||
return messages.getLocalizedString("compiler.misc.unnamed.package");
|
||||
}
|
||||
};
|
||||
noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage);
|
||||
noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage) {
|
||||
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
|
||||
return v.visitUnknown(this, p);
|
||||
}
|
||||
};
|
||||
noSymbol.kind = Kinds.NIL;
|
||||
|
||||
// create the error symbols
|
||||
errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage);
|
||||
unknownSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.fromString("<any?>"), null, rootPackage);
|
||||
errType = new ErrorType(errSymbol, Type.noType);
|
||||
|
||||
unknownSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.fromString("<any?>"), null, rootPackage);
|
||||
unknownSymbol.members_field = new Scope.ErrorScope(unknownSymbol);
|
||||
unknownSymbol.type = unknownType;
|
||||
|
||||
// initialize builtin types
|
||||
initType(byteType, "byte", "Byte");
|
||||
initType(shortType, "short", "Short");
|
||||
|
@ -382,9 +396,11 @@ public class Symtab {
|
|||
|
||||
// VGJ
|
||||
boundClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Bound, noSymbol);
|
||||
boundClass.members_field = new Scope.ErrorScope(boundClass);
|
||||
|
||||
// the builtin class of all methods
|
||||
methodClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Method, noSymbol);
|
||||
methodClass.members_field = new Scope.ErrorScope(boundClass);
|
||||
|
||||
// Create class to hold all predefined constants and operations.
|
||||
predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
|
||||
|
|
|
@ -93,6 +93,22 @@ public class Type implements PrimitiveType {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the representation of this type used for modelling purposes.
|
||||
* By default, this is itself. For ErrorType, a different value
|
||||
* may be provided,
|
||||
*/
|
||||
public Type getModelType() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static List<Type> getModelTypes(List<Type> ts) {
|
||||
ListBuffer<Type> lb = new ListBuffer<Type>();
|
||||
for (Type t: ts)
|
||||
lb.append(t.getModelType());
|
||||
return lb.toList();
|
||||
}
|
||||
|
||||
public <R,S> R accept(Type.Visitor<R,S> v, S s) { return v.visitType(this, s); }
|
||||
|
||||
/** Define a type given its tag and type symbol
|
||||
|
@ -190,7 +206,7 @@ public class Type implements PrimitiveType {
|
|||
if (ts.isEmpty()) {
|
||||
return "";
|
||||
} else {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(ts.head.toString());
|
||||
for (List<Type> l = ts.tail; l.nonEmpty(); l = l.tail)
|
||||
buf.append(",").append(l.head.toString());
|
||||
|
@ -464,7 +480,7 @@ public class Type implements PrimitiveType {
|
|||
|
||||
boolean isPrintingBound = false;
|
||||
public String toString() {
|
||||
StringBuffer s = new StringBuffer();
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(kind.toString());
|
||||
if (kind != UNBOUND)
|
||||
s.append(type);
|
||||
|
@ -538,6 +554,10 @@ public class Type implements PrimitiveType {
|
|||
*/
|
||||
public List<Type> interfaces_field;
|
||||
|
||||
/** All the interfaces of this class, including missing ones.
|
||||
*/
|
||||
public List<Type> all_interfaces_field;
|
||||
|
||||
public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym) {
|
||||
super(CLASS, tsym);
|
||||
this.outer_field = outer;
|
||||
|
@ -578,7 +598,7 @@ public class Type implements PrimitiveType {
|
|||
/** The Java source which this type represents.
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (getEnclosingType().tag == CLASS && tsym.owner.kind == TYP) {
|
||||
buf.append(getEnclosingType().toString());
|
||||
buf.append(".");
|
||||
|
@ -596,7 +616,7 @@ public class Type implements PrimitiveType {
|
|||
//where
|
||||
private String className(Symbol sym, boolean longform) {
|
||||
if (sym.name.isEmpty() && (sym.flags() & COMPOUND) != 0) {
|
||||
StringBuffer s = new StringBuffer(supertype_field.toString());
|
||||
StringBuilder s = new StringBuilder(supertype_field.toString());
|
||||
for (List<Type> is=interfaces_field; is.nonEmpty(); is = is.tail) {
|
||||
s.append("&");
|
||||
s.append(is.head.toString());
|
||||
|
|
|
@ -1992,7 +1992,11 @@ public class Types {
|
|||
* @return true if t is a sub signature of s.
|
||||
*/
|
||||
public boolean isSubSignature(Type t, Type s) {
|
||||
return hasSameArgs(t, s) || hasSameArgs(t, erasure(s));
|
||||
return isSubSignature(t, s, true);
|
||||
}
|
||||
|
||||
public boolean isSubSignature(Type t, Type s, boolean strict) {
|
||||
return hasSameArgs(t, s, strict) || hasSameArgs(t, erasure(s), strict);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2129,10 +2133,24 @@ public class Types {
|
|||
* where correspondence is by position in the type parameter list.
|
||||
*/
|
||||
public boolean hasSameArgs(Type t, Type s) {
|
||||
return hasSameArgs(t, s, true);
|
||||
}
|
||||
|
||||
public boolean hasSameArgs(Type t, Type s, boolean strict) {
|
||||
return hasSameArgs(t, s, strict ? hasSameArgs_strict : hasSameArgs_nonstrict);
|
||||
}
|
||||
|
||||
private boolean hasSameArgs(Type t, Type s, TypeRelation hasSameArgs) {
|
||||
return hasSameArgs.visit(t, s);
|
||||
}
|
||||
// where
|
||||
private TypeRelation hasSameArgs = new TypeRelation() {
|
||||
private class HasSameArgs extends TypeRelation {
|
||||
|
||||
boolean strict;
|
||||
|
||||
public HasSameArgs(boolean strict) {
|
||||
this.strict = strict;
|
||||
}
|
||||
|
||||
public Boolean visitType(Type t, Type s) {
|
||||
throw new AssertionError();
|
||||
|
@ -2147,7 +2165,7 @@ public class Types {
|
|||
@Override
|
||||
public Boolean visitForAll(ForAll t, Type s) {
|
||||
if (s.tag != FORALL)
|
||||
return false;
|
||||
return strict ? false : visitMethodType(t.asMethodType(), s);
|
||||
|
||||
ForAll forAll = (ForAll)s;
|
||||
return hasSameBounds(t, forAll)
|
||||
|
@ -2159,6 +2177,10 @@ public class Types {
|
|||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
TypeRelation hasSameArgs_strict = new HasSameArgs(true);
|
||||
TypeRelation hasSameArgs_nonstrict = new HasSameArgs(false);
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="subst">
|
||||
|
@ -2534,7 +2556,7 @@ public class Types {
|
|||
}
|
||||
// where
|
||||
private String typaramsString(List<Type> tvars) {
|
||||
StringBuffer s = new StringBuffer();
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append('<');
|
||||
boolean first = true;
|
||||
for (Type t : tvars) {
|
||||
|
@ -2545,7 +2567,7 @@ public class Types {
|
|||
s.append('>');
|
||||
return s.toString();
|
||||
}
|
||||
private void appendTyparamString(TypeVar t, StringBuffer buf) {
|
||||
private void appendTyparamString(TypeVar t, StringBuilder buf) {
|
||||
buf.append(t);
|
||||
if (t.bound == null ||
|
||||
t.bound.tsym.getQualifiedName() == names.java_lang_Object)
|
||||
|
@ -2832,12 +2854,26 @@ public class Types {
|
|||
while (ts.head.tag != CLASS && ts.head.tag != TYPEVAR)
|
||||
ts = ts.tail;
|
||||
Assert.check(!ts.isEmpty());
|
||||
List<Type> cl = closure(ts.head);
|
||||
//step 1 - compute erased candidate set (EC)
|
||||
List<Type> cl = erasedSupertypes(ts.head);
|
||||
for (Type t : ts.tail) {
|
||||
if (t.tag == CLASS || t.tag == TYPEVAR)
|
||||
cl = intersect(cl, closure(t));
|
||||
cl = intersect(cl, erasedSupertypes(t));
|
||||
}
|
||||
return compoundMin(cl);
|
||||
//step 2 - compute minimal erased candidate set (MEC)
|
||||
List<Type> mec = closureMin(cl);
|
||||
//step 3 - for each element G in MEC, compute lci(Inv(G))
|
||||
List<Type> candidates = List.nil();
|
||||
for (Type erasedSupertype : mec) {
|
||||
List<Type> lci = List.of(asSuper(ts.head, erasedSupertype.tsym));
|
||||
for (Type t : ts) {
|
||||
lci = intersect(lci, List.of(asSuper(t, erasedSupertype.tsym)));
|
||||
}
|
||||
candidates = candidates.appendList(lci);
|
||||
}
|
||||
//step 4 - let MEC be { G1, G2 ... Gn }, then we have that
|
||||
//lub = lci(Inv(G1)) & lci(Inv(G2)) & ... & lci(Inv(Gn))
|
||||
return compoundMin(candidates);
|
||||
|
||||
default:
|
||||
// calculate lub(A, B[])
|
||||
|
@ -2851,6 +2887,18 @@ public class Types {
|
|||
}
|
||||
}
|
||||
// where
|
||||
List<Type> erasedSupertypes(Type t) {
|
||||
ListBuffer<Type> buf = lb();
|
||||
for (Type sup : closure(t)) {
|
||||
if (sup.tag == TYPEVAR) {
|
||||
buf.append(sup);
|
||||
} else {
|
||||
buf.append(erasure(sup));
|
||||
}
|
||||
}
|
||||
return buf.toList();
|
||||
}
|
||||
|
||||
private Type arraySuperType = null;
|
||||
private Type arraySuperType() {
|
||||
// initialized lazily to avoid problems during compiler startup
|
||||
|
|
|
@ -1425,7 +1425,7 @@ public class Attr extends JCTree.Visitor {
|
|||
// qualifier omitted; check for existence
|
||||
// of an appropriate implicit qualifier.
|
||||
rs.resolveImplicitThis(tree.meth.pos(),
|
||||
localEnv, site);
|
||||
localEnv, site, true);
|
||||
}
|
||||
} else if (tree.meth.getTag() == JCTree.SELECT) {
|
||||
log.error(tree.meth.pos(), "illegal.qual.not.icls",
|
||||
|
@ -1581,15 +1581,7 @@ public class Attr extends JCTree.Visitor {
|
|||
// symbol + type back into the attributed tree.
|
||||
Type clazztype = attribType(clazz, env);
|
||||
Pair<Scope,Scope> mapping = getSyntheticScopeMapping(clazztype, cdef != null);
|
||||
if (!TreeInfo.isDiamond(tree)) {
|
||||
clazztype = chk.checkClassType(
|
||||
tree.clazz.pos(), clazztype, true);
|
||||
} else if (!clazztype.isErroneous() &&
|
||||
!clazztype.tsym.type.isParameterized()) {
|
||||
log.error(tree.clazz.pos(),
|
||||
"cant.apply.diamond.1",
|
||||
clazztype, diags.fragment("diamond.non.generic", clazztype));
|
||||
}
|
||||
clazztype = chk.checkDiamond(tree, clazztype);
|
||||
chk.validate(clazz, localEnv);
|
||||
if (tree.encl != null) {
|
||||
// We have to work in this case to store
|
||||
|
@ -1614,10 +1606,12 @@ public class Attr extends JCTree.Visitor {
|
|||
List<Type> argtypes = attribArgs(tree.args, localEnv);
|
||||
List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
|
||||
|
||||
if (TreeInfo.isDiamond(tree) && clazztype.tsym.type.isParameterized()) {
|
||||
if (TreeInfo.isDiamond(tree) && !clazztype.isErroneous()) {
|
||||
clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes);
|
||||
clazz.type = clazztype;
|
||||
} else if (allowDiamondFinder &&
|
||||
tree.def == null &&
|
||||
!clazztype.isErroneous() &&
|
||||
clazztype.getTypeArguments().nonEmpty() &&
|
||||
findDiamonds) {
|
||||
boolean prevDeferDiags = log.deferDiagnostics;
|
||||
|
@ -1641,8 +1635,7 @@ public class Attr extends JCTree.Visitor {
|
|||
if (inferred != null &&
|
||||
!inferred.isErroneous() &&
|
||||
inferred.tag == CLASS &&
|
||||
types.isAssignable(inferred, pt.tag == NONE ? clazztype : pt, Warner.noWarnings) &&
|
||||
chk.checkDiamond((ClassType)inferred).isEmpty()) {
|
||||
types.isAssignable(inferred, pt.tag == NONE ? clazztype : pt, Warner.noWarnings)) {
|
||||
String key = types.isSameType(clazztype, inferred) ?
|
||||
"diamond.redundant.args" :
|
||||
"diamond.redundant.args.1";
|
||||
|
@ -1857,34 +1850,9 @@ public class Attr extends JCTree.Visitor {
|
|||
ex.diagnostic);
|
||||
}
|
||||
}
|
||||
clazztype = chk.checkClassType(tree.clazz.pos(),
|
||||
return chk.checkClassType(tree.clazz.pos(),
|
||||
clazztype,
|
||||
true);
|
||||
if (clazztype.tag == CLASS) {
|
||||
List<Type> invalidDiamondArgs = chk.checkDiamond((ClassType)clazztype);
|
||||
if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) {
|
||||
//one or more types inferred in the previous steps is either a
|
||||
//captured type or an intersection type --- we need to report an error.
|
||||
String subkey = invalidDiamondArgs.size() > 1 ?
|
||||
"diamond.invalid.args" :
|
||||
"diamond.invalid.arg";
|
||||
//The error message is of the kind:
|
||||
//
|
||||
//cannot infer type arguments for {clazztype}<>;
|
||||
//reason: {subkey}
|
||||
//
|
||||
//where subkey is a fragment of the kind:
|
||||
//
|
||||
//type argument(s) {invalidDiamondArgs} inferred for {clazztype}<> is not allowed in this context
|
||||
log.error(tree.clazz.pos(),
|
||||
"cant.apply.diamond.1",
|
||||
diags.fragment("diamond", clazztype.tsym),
|
||||
diags.fragment(subkey,
|
||||
invalidDiamondArgs,
|
||||
diags.fragment("diamond", clazztype.tsym)));
|
||||
}
|
||||
}
|
||||
return clazztype;
|
||||
}
|
||||
|
||||
/** Creates a synthetic scope containing fake generic constructors.
|
||||
|
@ -2806,7 +2774,7 @@ public class Attr extends JCTree.Visitor {
|
|||
sym.location());
|
||||
owntype = new MethodType(owntype.getParameterTypes(),
|
||||
types.erasure(owntype.getReturnType()),
|
||||
owntype.getThrownTypes(),
|
||||
types.erasure(owntype.getThrownTypes()),
|
||||
syms.methodClass);
|
||||
}
|
||||
if (useVarargs) {
|
||||
|
@ -2980,7 +2948,7 @@ public class Attr extends JCTree.Visitor {
|
|||
// (see comment for TypeVar.bound).
|
||||
// In this case, generate a class tree that represents the
|
||||
// bound class, ...
|
||||
JCTree extending;
|
||||
JCExpression extending;
|
||||
List<JCExpression> implementing;
|
||||
if ((bs.head.tsym.flags() & INTERFACE) == 0) {
|
||||
extending = tree.bounds.head;
|
||||
|
|
|
@ -664,40 +664,25 @@ public class Check {
|
|||
return true;
|
||||
}
|
||||
|
||||
/** Check that the type inferred using the diamond operator does not contain
|
||||
* non-denotable types such as captured types or intersection types.
|
||||
* @param t the type inferred using the diamond operator
|
||||
/** Check that usage of diamond operator is correct (i.e. diamond should not
|
||||
* be used with non-generic classes or in anonymous class creation expressions)
|
||||
*/
|
||||
List<Type> checkDiamond(ClassType t) {
|
||||
DiamondTypeChecker dtc = new DiamondTypeChecker();
|
||||
ListBuffer<Type> buf = ListBuffer.lb();
|
||||
for (Type arg : t.getTypeArguments()) {
|
||||
if (!dtc.visit(arg, null)) {
|
||||
buf.append(arg);
|
||||
}
|
||||
}
|
||||
return buf.toList();
|
||||
}
|
||||
|
||||
static class DiamondTypeChecker extends Types.SimpleVisitor<Boolean, Void> {
|
||||
public Boolean visitType(Type t, Void s) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public Boolean visitClassType(ClassType t, Void s) {
|
||||
if (t.isCompound()) {
|
||||
return false;
|
||||
}
|
||||
for (Type targ : t.getTypeArguments()) {
|
||||
if (!visit(targ, s)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public Boolean visitCapturedType(CapturedType t, Void s) {
|
||||
return false;
|
||||
Type checkDiamond(JCNewClass tree, Type t) {
|
||||
if (!TreeInfo.isDiamond(tree) ||
|
||||
t.isErroneous()) {
|
||||
return checkClassType(tree.clazz.pos(), t, true);
|
||||
} else if (tree.def != null) {
|
||||
log.error(tree.clazz.pos(),
|
||||
"cant.apply.diamond.1",
|
||||
t, diags.fragment("diamond.and.anon.class", t));
|
||||
return types.createErrorType(t);
|
||||
} else if (!t.tsym.type.isParameterized()) {
|
||||
log.error(tree.clazz.pos(),
|
||||
"cant.apply.diamond.1",
|
||||
t, diags.fragment("diamond.non.generic", t));
|
||||
return types.createErrorType(t);
|
||||
} else {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1679,7 +1664,8 @@ public class Check {
|
|||
"(" + types.memberType(t2, s2).getParameterTypes() + ")");
|
||||
return s2;
|
||||
}
|
||||
} else if (checkNameClash((ClassSymbol)site.tsym, s1, s2)) {
|
||||
} else if (checkNameClash((ClassSymbol)site.tsym, s1, s2) &&
|
||||
!checkCommonOverriderIn(s1, s2, site)) {
|
||||
log.error(pos,
|
||||
"name.clash.same.erasure.no.override",
|
||||
s1, s1.location(),
|
||||
|
@ -2113,7 +2099,7 @@ public class Check {
|
|||
if (s1 == s2 || !sym.overrides(s2, 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, s1)) &&
|
||||
if (!types.isSubSignature(sym.type, types.memberType(site, s1), false) &&
|
||||
types.hasSameArgs(s1.erasure(types), s2.erasure(types))) {
|
||||
sym.flags_field |= CLASH;
|
||||
String key = s2 == sym ?
|
||||
|
@ -2145,7 +2131,7 @@ public class Check {
|
|||
for (Symbol s : types.membersClosure(site).getElementsByName(sym.name, 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, s)) &&
|
||||
if (!types.isSubSignature(sym.type, types.memberType(site, s), false) &&
|
||||
types.hasSameArgs(s.erasure(types), sym.erasure(types))) {
|
||||
log.error(pos,
|
||||
"name.clash.same.erasure.no.hide",
|
||||
|
@ -2666,7 +2652,7 @@ public class Check {
|
|||
if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) {
|
||||
varargsDuplicateError(pos, sym, e.sym);
|
||||
return true;
|
||||
} else if (sym.kind == MTH && !hasSameSignature(sym.type, e.sym.type)) {
|
||||
} else if (sym.kind == MTH && !types.hasSameArgs(sym.type, e.sym.type, false)) {
|
||||
duplicateErasureError(pos, sym, e.sym);
|
||||
sym.flags_field |= CLASH;
|
||||
return true;
|
||||
|
@ -2678,15 +2664,6 @@ public class Check {
|
|||
}
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -272,7 +272,7 @@ public class Flow extends TreeScanner {
|
|||
|
||||
/** The list of unreferenced automatic resources.
|
||||
*/
|
||||
Map<VarSymbol, JCVariableDecl> unrefdResources;
|
||||
Scope unrefdResources;
|
||||
|
||||
/** Set when processing a loop body the second time for DU analysis. */
|
||||
boolean loopPassTwo = false;
|
||||
|
@ -804,14 +804,16 @@ public class Flow extends TreeScanner {
|
|||
ListBuffer<PendingExit> prevPendingExits = pendingExits;
|
||||
boolean prevLoopPassTwo = loopPassTwo;
|
||||
pendingExits = new ListBuffer<PendingExit>();
|
||||
int prevErrors = log.nerrors;
|
||||
do {
|
||||
Bits uninitsEntry = uninits.dup();
|
||||
uninitsEntry.excludeFrom(nextadr);
|
||||
scanStat(tree.body);
|
||||
alive |= resolveContinues(tree);
|
||||
scanCond(tree.cond);
|
||||
if (log.nerrors != 0 ||
|
||||
if (log.nerrors != prevErrors ||
|
||||
loopPassTwo ||
|
||||
uninitsEntry.diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
|
||||
uninitsEntry.dup().diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
|
||||
break;
|
||||
inits = initsWhenTrue;
|
||||
uninits = uninitsEntry.andSet(uninitsWhenTrue);
|
||||
|
@ -831,8 +833,10 @@ public class Flow extends TreeScanner {
|
|||
Bits initsCond;
|
||||
Bits uninitsCond;
|
||||
pendingExits = new ListBuffer<PendingExit>();
|
||||
int prevErrors = log.nerrors;
|
||||
do {
|
||||
Bits uninitsEntry = uninits.dup();
|
||||
uninitsEntry.excludeFrom(nextadr);
|
||||
scanCond(tree.cond);
|
||||
initsCond = initsWhenFalse;
|
||||
uninitsCond = uninitsWhenFalse;
|
||||
|
@ -841,9 +845,9 @@ public class Flow extends TreeScanner {
|
|||
alive = !tree.cond.type.isFalse();
|
||||
scanStat(tree.body);
|
||||
alive |= resolveContinues(tree);
|
||||
if (log.nerrors != 0 ||
|
||||
if (log.nerrors != prevErrors ||
|
||||
loopPassTwo ||
|
||||
uninitsEntry.diffSet(uninits).nextBit(firstadr) == -1)
|
||||
uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
|
||||
break;
|
||||
uninits = uninitsEntry.andSet(uninits);
|
||||
loopPassTwo = true;
|
||||
|
@ -864,8 +868,10 @@ public class Flow extends TreeScanner {
|
|||
Bits initsCond;
|
||||
Bits uninitsCond;
|
||||
pendingExits = new ListBuffer<PendingExit>();
|
||||
int prevErrors = log.nerrors;
|
||||
do {
|
||||
Bits uninitsEntry = uninits.dup();
|
||||
uninitsEntry.excludeFrom(nextadr);
|
||||
if (tree.cond != null) {
|
||||
scanCond(tree.cond);
|
||||
initsCond = initsWhenFalse;
|
||||
|
@ -883,7 +889,7 @@ public class Flow extends TreeScanner {
|
|||
scanStat(tree.body);
|
||||
alive |= resolveContinues(tree);
|
||||
scan(tree.step);
|
||||
if (log.nerrors != 0 ||
|
||||
if (log.nerrors != prevErrors ||
|
||||
loopPassTwo ||
|
||||
uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
|
||||
break;
|
||||
|
@ -897,8 +903,6 @@ public class Flow extends TreeScanner {
|
|||
alive = resolveBreaks(tree, prevPendingExits) ||
|
||||
tree.cond != null && !tree.cond.type.isTrue();
|
||||
nextadr = nextadrPrev;
|
||||
inits.excludeFrom(nextadr);
|
||||
uninits.excludeFrom(nextadr);
|
||||
}
|
||||
|
||||
public void visitForeachLoop(JCEnhancedForLoop tree) {
|
||||
|
@ -913,13 +917,15 @@ public class Flow extends TreeScanner {
|
|||
|
||||
letInit(tree.pos(), tree.var.sym);
|
||||
pendingExits = new ListBuffer<PendingExit>();
|
||||
int prevErrors = log.nerrors;
|
||||
do {
|
||||
Bits uninitsEntry = uninits.dup();
|
||||
uninitsEntry.excludeFrom(nextadr);
|
||||
scanStat(tree.body);
|
||||
alive |= resolveContinues(tree);
|
||||
if (log.nerrors != 0 ||
|
||||
if (log.nerrors != prevErrors ||
|
||||
loopPassTwo ||
|
||||
uninitsEntry.diffSet(uninits).nextBit(firstadr) == -1)
|
||||
uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
|
||||
break;
|
||||
uninits = uninitsEntry.andSet(uninits);
|
||||
loopPassTwo = true;
|
||||
|
@ -992,7 +998,6 @@ public class Flow extends TreeScanner {
|
|||
public void visitTry(JCTry tree) {
|
||||
List<Type> caughtPrev = caught;
|
||||
List<Type> thrownPrev = thrown;
|
||||
Map<VarSymbol, JCVariableDecl> unrefdResourcesPrev = unrefdResources;
|
||||
thrown = List.nil();
|
||||
for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
|
||||
List<JCExpression> subClauses = TreeInfo.isMultiCatch(l.head) ?
|
||||
|
@ -1002,17 +1007,18 @@ public class Flow extends TreeScanner {
|
|||
caught = chk.incl(ct.type, caught);
|
||||
}
|
||||
}
|
||||
ListBuffer<JCVariableDecl> resourceVarDecls = ListBuffer.lb();
|
||||
Bits uninitsTryPrev = uninitsTry;
|
||||
ListBuffer<PendingExit> prevPendingExits = pendingExits;
|
||||
pendingExits = new ListBuffer<PendingExit>();
|
||||
Bits initsTry = inits.dup();
|
||||
uninitsTry = uninits.dup();
|
||||
unrefdResources = new LinkedHashMap<VarSymbol, JCVariableDecl>();
|
||||
for (JCTree resource : tree.resources) {
|
||||
if (resource instanceof JCVariableDecl) {
|
||||
JCVariableDecl vdecl = (JCVariableDecl) resource;
|
||||
visitVarDef(vdecl);
|
||||
unrefdResources.put(vdecl.sym, vdecl);
|
||||
unrefdResources.enter(vdecl.sym);
|
||||
resourceVarDecls.append(vdecl);
|
||||
} else if (resource instanceof JCExpression) {
|
||||
scanExpr((JCExpression) resource);
|
||||
} else {
|
||||
|
@ -1049,11 +1055,14 @@ public class Flow extends TreeScanner {
|
|||
Bits uninitsEnd = uninits;
|
||||
int nextadrCatch = nextadr;
|
||||
|
||||
if (!unrefdResources.isEmpty() &&
|
||||
if (!resourceVarDecls.isEmpty() &&
|
||||
lint.isEnabled(Lint.LintCategory.TRY)) {
|
||||
for (Map.Entry<VarSymbol, JCVariableDecl> e : unrefdResources.entrySet()) {
|
||||
log.warning(Lint.LintCategory.TRY, e.getValue().pos(),
|
||||
"try.resource.not.referenced", e.getKey());
|
||||
for (JCVariableDecl resVar : resourceVarDecls) {
|
||||
if (unrefdResources.includes(resVar.sym)) {
|
||||
log.warning(Lint.LintCategory.TRY, resVar.pos(),
|
||||
"try.resource.not.referenced", resVar.sym);
|
||||
unrefdResources.remove(resVar.sym);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1143,7 +1152,6 @@ public class Flow extends TreeScanner {
|
|||
while (exits.nonEmpty()) pendingExits.append(exits.next());
|
||||
}
|
||||
uninitsTry.andSet(uninitsTryPrev).andSet(uninits);
|
||||
unrefdResources = unrefdResourcesPrev;
|
||||
}
|
||||
|
||||
public void visitConditional(JCConditional tree) {
|
||||
|
@ -1369,9 +1377,7 @@ public class Flow extends TreeScanner {
|
|||
}
|
||||
|
||||
void referenced(Symbol sym) {
|
||||
if (unrefdResources != null && unrefdResources.containsKey(sym)) {
|
||||
unrefdResources.remove(sym);
|
||||
}
|
||||
unrefdResources.remove(sym);
|
||||
}
|
||||
|
||||
public void visitTypeCast(JCTypeCast tree) {
|
||||
|
@ -1430,6 +1436,7 @@ public class Flow extends TreeScanner {
|
|||
alive = true;
|
||||
this.thrown = this.caught = null;
|
||||
this.classDef = null;
|
||||
unrefdResources = new Scope(env.enclClass.sym);
|
||||
scan(tree);
|
||||
} finally {
|
||||
// note that recursive invocations of this method fail hard
|
||||
|
@ -1444,6 +1451,7 @@ public class Flow extends TreeScanner {
|
|||
this.make = null;
|
||||
this.thrown = this.caught = null;
|
||||
this.classDef = null;
|
||||
unrefdResources = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,10 +465,9 @@ public class Infer {
|
|||
// quantify result type with them
|
||||
final List<Type> inferredTypes = insttypes.toList();
|
||||
final List<Type> all_tvars = tvars; //this is the wrong tvars
|
||||
final MethodType mt2 = new MethodType(mt.argtypes, null, mt.thrown, syms.methodClass);
|
||||
mt2.restype = new ForAll(restvars.toList(), mt.restype) {
|
||||
return new UninferredMethodType(mt, restvars.toList()) {
|
||||
@Override
|
||||
public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
|
||||
List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
|
||||
for (Type t : restundet.toList()) {
|
||||
UndetVar uv = (UndetVar)t;
|
||||
if (uv.qtype == tv) {
|
||||
|
@ -481,21 +480,17 @@ public class Infer {
|
|||
}
|
||||
return List.nil();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type inst(List<Type> inferred, Types types) throws NoInstanceException {
|
||||
List<Type> formals = types.subst(mt2.argtypes, tvars, inferred);
|
||||
void check(List<Type> inferred, Types types) throws NoInstanceException {
|
||||
// check that actuals conform to inferred formals
|
||||
checkArgumentsAcceptable(env, capturedArgs, formals, allowBoxing, useVarargs, warn);
|
||||
checkArgumentsAcceptable(env, capturedArgs, getParameterTypes(), allowBoxing, useVarargs, warn);
|
||||
// check that inferred bounds conform to their bounds
|
||||
checkWithinBounds(all_tvars,
|
||||
types.subst(inferredTypes, tvars, inferred), warn);
|
||||
if (useVarargs) {
|
||||
chk.checkVararg(env.tree.pos(), formals, msym);
|
||||
chk.checkVararg(env.tree.pos(), getParameterTypes(), msym);
|
||||
}
|
||||
return super.inst(inferred, types);
|
||||
}};
|
||||
return mt2;
|
||||
}
|
||||
else {
|
||||
// check that actuals conform to inferred formals
|
||||
|
@ -506,6 +501,62 @@ public class Infer {
|
|||
}
|
||||
//where
|
||||
|
||||
/**
|
||||
* A delegated type representing a partially uninferred method type.
|
||||
* The return type of a partially uninferred method type is a ForAll
|
||||
* type - when the return type is instantiated (see Infer.instantiateExpr)
|
||||
* the underlying method type is also updated.
|
||||
*/
|
||||
static abstract class UninferredMethodType extends DelegatedType {
|
||||
|
||||
final List<Type> tvars;
|
||||
|
||||
public UninferredMethodType(MethodType mtype, List<Type> tvars) {
|
||||
super(METHOD, new MethodType(mtype.argtypes, null, mtype.thrown, mtype.tsym));
|
||||
this.tvars = tvars;
|
||||
asMethodType().restype = new UninferredReturnType(tvars, mtype.restype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodType asMethodType() {
|
||||
return qtype.asMethodType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type map(Mapping f) {
|
||||
return qtype.map(f);
|
||||
}
|
||||
|
||||
void instantiateReturnType(Type restype, List<Type> inferred, Types types) throws NoInstanceException {
|
||||
//update method type with newly inferred type-arguments
|
||||
qtype = new MethodType(types.subst(getParameterTypes(), tvars, inferred),
|
||||
restype,
|
||||
types.subst(UninferredMethodType.this.getThrownTypes(), tvars, inferred),
|
||||
UninferredMethodType.this.qtype.tsym);
|
||||
check(inferred, types);
|
||||
}
|
||||
|
||||
abstract void check(List<Type> inferred, Types types) throws NoInstanceException;
|
||||
|
||||
abstract List<Type> getConstraints(TypeVar tv, ConstraintKind ck);
|
||||
|
||||
class UninferredReturnType extends ForAll {
|
||||
public UninferredReturnType(List<Type> tvars, Type restype) {
|
||||
super(tvars, restype);
|
||||
}
|
||||
@Override
|
||||
public Type inst(List<Type> actuals, Types types) {
|
||||
Type newRestype = super.inst(actuals, types);
|
||||
instantiateReturnType(newRestype, actuals, types);
|
||||
return newRestype;
|
||||
}
|
||||
@Override
|
||||
public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
|
||||
return UninferredMethodType.this.getConstraints(tv, ck);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkArgumentsAcceptable(Env<AttrContext> env, List<Type> actuals, List<Type> formals,
|
||||
boolean allowBoxing, boolean useVarargs, Warner warn) {
|
||||
try {
|
||||
|
@ -518,25 +569,25 @@ public class Infer {
|
|||
}
|
||||
}
|
||||
|
||||
/** 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
|
||||
* by an unknown type.
|
||||
*/
|
||||
private Type instantiateArg(ForAll that,
|
||||
Type to,
|
||||
List<Type> tvars,
|
||||
Warner warn) throws InferenceException {
|
||||
List<Type> targs;
|
||||
try {
|
||||
return instantiateExpr(that, to, warn);
|
||||
} catch (NoInstanceException ex) {
|
||||
Type to1 = to;
|
||||
for (List<Type> l = tvars; l.nonEmpty(); l = l.tail)
|
||||
to1 = types.subst(to1, List.of(l.head), List.of(syms.unknownType));
|
||||
return instantiateExpr(that, to1, warn);
|
||||
}
|
||||
/** 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
|
||||
* by an unknown type.
|
||||
*/
|
||||
private Type instantiateArg(ForAll that,
|
||||
Type to,
|
||||
List<Type> tvars,
|
||||
Warner warn) throws InferenceException {
|
||||
List<Type> targs;
|
||||
try {
|
||||
return instantiateExpr(that, to, warn);
|
||||
} catch (NoInstanceException ex) {
|
||||
Type to1 = to;
|
||||
for (List<Type> l = tvars; l.nonEmpty(); l = l.tail)
|
||||
to1 = types.subst(to1, List.of(l.head), List.of(syms.unknownType));
|
||||
return instantiateExpr(that, to1, warn);
|
||||
}
|
||||
}
|
||||
|
||||
/** check that type parameters are within their bounds.
|
||||
*/
|
||||
|
@ -616,4 +667,4 @@ public class Infer {
|
|||
return t;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2817,8 +2817,8 @@ public class Lower extends TreeTranslator {
|
|||
// local class or this() call
|
||||
thisArg = makeThis(tree.meth.pos(), c.type.getEnclosingType().tsym);
|
||||
} else {
|
||||
// super() call of nested class
|
||||
thisArg = makeOwnerThis(tree.meth.pos(), c, false);
|
||||
// super() call of nested class - never pick 'this'
|
||||
thisArg = makeOwnerThisN(tree.meth.pos(), c, false);
|
||||
}
|
||||
tree.args = tree.args.prepend(thisArg);
|
||||
}
|
||||
|
|
|
@ -889,10 +889,11 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
|||
: (c.fullname == names.java_lang_Object)
|
||||
? Type.noType
|
||||
: syms.objectType;
|
||||
ct.supertype_field = supertype;
|
||||
ct.supertype_field = modelMissingTypes(supertype, tree.extending, false);
|
||||
|
||||
// Determine interfaces.
|
||||
ListBuffer<Type> interfaces = new ListBuffer<Type>();
|
||||
ListBuffer<Type> all_interfaces = null; // lazy init
|
||||
Set<Type> interfaceSet = new HashSet<Type>();
|
||||
List<JCExpression> interfaceTrees = tree.implementing;
|
||||
if ((tree.mods.flags & Flags.ENUM) != 0 && target.compilerBootstrap(c)) {
|
||||
|
@ -909,13 +910,22 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
|||
Type i = attr.attribBase(iface, baseEnv, false, true, true);
|
||||
if (i.tag == CLASS) {
|
||||
interfaces.append(i);
|
||||
if (all_interfaces != null) all_interfaces.append(i);
|
||||
chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet);
|
||||
} else {
|
||||
if (all_interfaces == null)
|
||||
all_interfaces = new ListBuffer<Type>().appendList(interfaces);
|
||||
all_interfaces.append(modelMissingTypes(i, iface, true));
|
||||
}
|
||||
}
|
||||
if ((c.flags_field & ANNOTATION) != 0)
|
||||
if ((c.flags_field & ANNOTATION) != 0) {
|
||||
ct.interfaces_field = List.of(syms.annotationType);
|
||||
else
|
||||
ct.all_interfaces_field = ct.interfaces_field;
|
||||
} else {
|
||||
ct.interfaces_field = interfaces.toList();
|
||||
ct.all_interfaces_field = (all_interfaces == null)
|
||||
? ct.interfaces_field : all_interfaces.toList();
|
||||
}
|
||||
|
||||
if (c.fullname == names.java_lang_Object) {
|
||||
if (tree.extending != null) {
|
||||
|
@ -1066,6 +1076,125 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
|||
return result;
|
||||
}
|
||||
|
||||
Type modelMissingTypes(Type t, final JCExpression tree, final boolean interfaceExpected) {
|
||||
if (t.tag != ERROR)
|
||||
return t;
|
||||
|
||||
return new ErrorType(((ErrorType) t).getOriginalType(), t.tsym) {
|
||||
private Type modelType;
|
||||
|
||||
@Override
|
||||
public Type getModelType() {
|
||||
if (modelType == null)
|
||||
modelType = new Synthesizer(getOriginalType(), interfaceExpected).visit(tree);
|
||||
return modelType;
|
||||
}
|
||||
};
|
||||
}
|
||||
// where
|
||||
private class Synthesizer extends JCTree.Visitor {
|
||||
Type originalType;
|
||||
boolean interfaceExpected;
|
||||
List<ClassSymbol> synthesizedSymbols = List.nil();
|
||||
Type result;
|
||||
|
||||
Synthesizer(Type originalType, boolean interfaceExpected) {
|
||||
this.originalType = originalType;
|
||||
this.interfaceExpected = interfaceExpected;
|
||||
}
|
||||
|
||||
Type visit(JCTree tree) {
|
||||
tree.accept(this);
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Type> visit(List<? extends JCTree> trees) {
|
||||
ListBuffer<Type> lb = new ListBuffer<Type>();
|
||||
for (JCTree t: trees)
|
||||
lb.append(visit(t));
|
||||
return lb.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTree(JCTree tree) {
|
||||
result = syms.errType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIdent(JCIdent tree) {
|
||||
if (tree.type.tag != ERROR) {
|
||||
result = tree.type;
|
||||
} else {
|
||||
result = synthesizeClass(tree.name, syms.unnamedPackage).type;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSelect(JCFieldAccess tree) {
|
||||
if (tree.type.tag != ERROR) {
|
||||
result = tree.type;
|
||||
} else {
|
||||
Type selectedType;
|
||||
boolean prev = interfaceExpected;
|
||||
try {
|
||||
interfaceExpected = false;
|
||||
selectedType = visit(tree.selected);
|
||||
} finally {
|
||||
interfaceExpected = prev;
|
||||
}
|
||||
ClassSymbol c = synthesizeClass(tree.name, selectedType.tsym);
|
||||
result = c.type;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeApply(JCTypeApply tree) {
|
||||
if (tree.type.tag != ERROR) {
|
||||
result = tree.type;
|
||||
} else {
|
||||
ClassType clazzType = (ClassType) visit(tree.clazz);
|
||||
if (synthesizedSymbols.contains(clazzType.tsym))
|
||||
synthesizeTyparams((ClassSymbol) clazzType.tsym, tree.arguments.size());
|
||||
final List<Type> actuals = visit(tree.arguments);
|
||||
result = new ErrorType(tree.type, clazzType.tsym) {
|
||||
@Override
|
||||
public List<Type> getTypeArguments() {
|
||||
return actuals;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ClassSymbol synthesizeClass(Name name, Symbol owner) {
|
||||
int flags = interfaceExpected ? INTERFACE : 0;
|
||||
ClassSymbol c = new ClassSymbol(flags, name, owner);
|
||||
c.members_field = new Scope.ErrorScope(c);
|
||||
c.type = new ErrorType(originalType, c) {
|
||||
@Override
|
||||
public List<Type> getTypeArguments() {
|
||||
return typarams_field;
|
||||
}
|
||||
};
|
||||
synthesizedSymbols = synthesizedSymbols.prepend(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
void synthesizeTyparams(ClassSymbol sym, int n) {
|
||||
ClassType ct = (ClassType) sym.type;
|
||||
Assert.check(ct.typarams_field.isEmpty());
|
||||
if (n == 1) {
|
||||
TypeVar v = new TypeVar(names.fromString("T"), sym, syms.botType);
|
||||
ct.typarams_field = ct.typarams_field.prepend(v);
|
||||
} else {
|
||||
for (int i = n; i > 0; i--) {
|
||||
TypeVar v = new TypeVar(names.fromString("T" + i), sym, syms.botType);
|
||||
ct.typarams_field = ct.typarams_field.prepend(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ***************************************************************************
|
||||
* tree building
|
||||
****************************************************************************/
|
||||
|
|
|
@ -45,7 +45,9 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
|
|||
import javax.lang.model.element.ElementVisitor;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
/** Helper class for name resolution, used mostly by the attribution phase.
|
||||
*
|
||||
|
@ -896,7 +898,8 @@ public class Resolve {
|
|||
bestSoFar,
|
||||
allowBoxing,
|
||||
useVarargs,
|
||||
operator);
|
||||
operator,
|
||||
new HashSet<TypeSymbol>());
|
||||
}
|
||||
// where
|
||||
private Symbol findMethod(Env<AttrContext> env,
|
||||
|
@ -909,11 +912,13 @@ public class Resolve {
|
|||
Symbol bestSoFar,
|
||||
boolean allowBoxing,
|
||||
boolean useVarargs,
|
||||
boolean operator) {
|
||||
boolean operator,
|
||||
Set<TypeSymbol> seen) {
|
||||
for (Type ct = intype; ct.tag == CLASS || ct.tag == TYPEVAR; ct = types.supertype(ct)) {
|
||||
while (ct.tag == TYPEVAR)
|
||||
ct = ct.getUpperBound();
|
||||
ClassSymbol c = (ClassSymbol)ct.tsym;
|
||||
if (!seen.add(c)) return bestSoFar;
|
||||
if ((c.flags() & (ABSTRACT | INTERFACE | ENUM)) == 0)
|
||||
abstractok = false;
|
||||
for (Scope.Entry e = c.members().lookup(name);
|
||||
|
@ -942,7 +947,7 @@ public class Resolve {
|
|||
bestSoFar = findMethod(env, site, name, argtypes,
|
||||
typeargtypes,
|
||||
l.head, abstractok, bestSoFar,
|
||||
allowBoxing, useVarargs, operator);
|
||||
allowBoxing, useVarargs, operator, seen);
|
||||
}
|
||||
if (concrete != bestSoFar &&
|
||||
concrete.kind < ERR && bestSoFar.kind < ERR &&
|
||||
|
@ -1736,24 +1741,26 @@ public class Resolve {
|
|||
*/
|
||||
Symbol resolveSelfContaining(DiagnosticPosition pos,
|
||||
Env<AttrContext> env,
|
||||
Symbol member) {
|
||||
Symbol member,
|
||||
boolean isSuperCall) {
|
||||
Name name = names._this;
|
||||
Env<AttrContext> env1 = env;
|
||||
Env<AttrContext> env1 = isSuperCall ? env.outer : env;
|
||||
boolean staticOnly = false;
|
||||
while (env1.outer != null) {
|
||||
if (isStatic(env1)) staticOnly = true;
|
||||
if (env1.enclClass.sym.isSubClass(member.owner, types) &&
|
||||
isAccessible(env, env1.enclClass.sym.type, member)) {
|
||||
Symbol sym = env1.info.scope.lookup(name).sym;
|
||||
if (sym != null) {
|
||||
if (staticOnly) sym = new StaticError(sym);
|
||||
return access(sym, pos, env.enclClass.sym.type,
|
||||
name, true);
|
||||
if (env1 != null) {
|
||||
while (env1 != null && env1.outer != null) {
|
||||
if (isStatic(env1)) staticOnly = true;
|
||||
if (env1.enclClass.sym.isSubClass(member.owner, types)) {
|
||||
Symbol sym = env1.info.scope.lookup(name).sym;
|
||||
if (sym != null) {
|
||||
if (staticOnly) sym = new StaticError(sym);
|
||||
return access(sym, pos, env.enclClass.sym.type,
|
||||
name, true);
|
||||
}
|
||||
}
|
||||
if ((env1.enclClass.sym.flags() & STATIC) != 0)
|
||||
staticOnly = true;
|
||||
env1 = env1.outer;
|
||||
}
|
||||
if ((env1.enclClass.sym.flags() & STATIC) != 0)
|
||||
staticOnly = true;
|
||||
env1 = env1.outer;
|
||||
}
|
||||
log.error(pos, "encl.class.required", member);
|
||||
return syms.errSymbol;
|
||||
|
@ -1764,9 +1771,13 @@ public class Resolve {
|
|||
* JLS2 8.8.5.1 and 15.9.2
|
||||
*/
|
||||
Type resolveImplicitThis(DiagnosticPosition pos, Env<AttrContext> env, Type t) {
|
||||
return resolveImplicitThis(pos, env, t, false);
|
||||
}
|
||||
|
||||
Type resolveImplicitThis(DiagnosticPosition pos, Env<AttrContext> env, Type t, boolean isSuperCall) {
|
||||
Type thisType = (((t.tsym.owner.kind & (MTH|VAR)) != 0)
|
||||
? resolveSelf(pos, env, t.getEnclosingType().tsym, names._this)
|
||||
: resolveSelfContaining(pos, env, t.tsym)).type;
|
||||
: resolveSelfContaining(pos, env, t.tsym, isSuperCall)).type;
|
||||
if (env.info.isSelfCall && thisType.tsym == env.enclClass.sym)
|
||||
log.error(pos, "cant.ref.before.ctor.called", "this");
|
||||
return thisType;
|
||||
|
|
|
@ -44,13 +44,13 @@ import com.sun.tools.javac.util.Context;
|
|||
public class CacheFSInfo extends FSInfo {
|
||||
|
||||
/**
|
||||
* Register a Context.Factory to create a singleton CacheFSInfo.
|
||||
* Register a Context.Factory to create a CacheFSInfo.
|
||||
*/
|
||||
public static void preRegister(final Context context) {
|
||||
public static void preRegister(Context context) {
|
||||
context.put(FSInfo.class, new Context.Factory<FSInfo>() {
|
||||
public FSInfo make() {
|
||||
public FSInfo make(Context c) {
|
||||
FSInfo instance = new CacheFSInfo();
|
||||
context.put(FSInfo.class, instance);
|
||||
c.put(FSInfo.class, instance);
|
||||
return instance;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -129,10 +129,10 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
|||
/**
|
||||
* Register a Context.Factory to create a JavacFileManager.
|
||||
*/
|
||||
public static void preRegister(final Context context) {
|
||||
public static void preRegister(Context context) {
|
||||
context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
|
||||
public JavaFileManager make() {
|
||||
return new JavacFileManager(context, true, null);
|
||||
public JavaFileManager make(Context c) {
|
||||
return new JavacFileManager(c, true, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2183,7 +2183,7 @@ public class ClassReader implements Completer {
|
|||
}
|
||||
currentClassFile = classfile;
|
||||
if (verbose) {
|
||||
printVerbose("loading", currentClassFile.toString());
|
||||
log.printVerbose("loading", currentClassFile.toString());
|
||||
}
|
||||
if (classfile.getKind() == JavaFileObject.Kind.CLASS) {
|
||||
filling = true;
|
||||
|
@ -2452,13 +2452,13 @@ public class ClassReader implements Completer {
|
|||
for (File file : fm.getLocation(SOURCE_PATH)) {
|
||||
path = path.prepend(file);
|
||||
}
|
||||
printVerbose("sourcepath", path.reverse().toString());
|
||||
log.printVerbose("sourcepath", path.reverse().toString());
|
||||
} else if (wantSourceFiles) {
|
||||
List<File> path = List.nil();
|
||||
for (File file : fm.getLocation(CLASS_PATH)) {
|
||||
path = path.prepend(file);
|
||||
}
|
||||
printVerbose("sourcepath", path.reverse().toString());
|
||||
log.printVerbose("sourcepath", path.reverse().toString());
|
||||
}
|
||||
if (wantClassFiles) {
|
||||
List<File> path = List.nil();
|
||||
|
@ -2468,7 +2468,7 @@ public class ClassReader implements Completer {
|
|||
for (File file : fm.getLocation(CLASS_PATH)) {
|
||||
path = path.prepend(file);
|
||||
}
|
||||
printVerbose("classpath", path.reverse().toString());
|
||||
log.printVerbose("classpath", path.reverse().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2519,14 +2519,6 @@ public class ClassReader implements Completer {
|
|||
}
|
||||
}
|
||||
|
||||
/** Output for "-verbose" option.
|
||||
* @param key The key to look up the correct internationalized string.
|
||||
* @param arg An argument for substitution into the output string.
|
||||
*/
|
||||
private void printVerbose(String key, CharSequence arg) {
|
||||
log.printNoteLines("verbose." + key, arg);
|
||||
}
|
||||
|
||||
/** Output for "-checkclassfile" option.
|
||||
* @param key The key to look up the correct internationalized string.
|
||||
* @param arg An argument for substitution into the output string.
|
||||
|
|
|
@ -1447,7 +1447,7 @@ public class ClassWriter extends ClassFile {
|
|||
try {
|
||||
writeClassFile(out, c);
|
||||
if (verbose)
|
||||
log.printErrLines("verbose.wrote.file", outFile);
|
||||
log.printVerbose("wrote.file", outFile);
|
||||
out.close();
|
||||
out = null;
|
||||
} finally {
|
||||
|
|
|
@ -298,6 +298,13 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
*/
|
||||
protected JavaCompiler delegateCompiler;
|
||||
|
||||
/**
|
||||
* Command line options.
|
||||
*/
|
||||
protected Options options;
|
||||
|
||||
protected Context context;
|
||||
|
||||
/**
|
||||
* Flag set if any annotation processing occurred.
|
||||
**/
|
||||
|
@ -308,11 +315,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
**/
|
||||
protected boolean implicitSourceFilesRead;
|
||||
|
||||
protected Context context;
|
||||
|
||||
/** Construct a new compiler using a shared context.
|
||||
*/
|
||||
public JavaCompiler(final Context context) {
|
||||
public JavaCompiler(Context context) {
|
||||
this.context = context;
|
||||
context.put(compilerKey, this);
|
||||
|
||||
|
@ -354,7 +359,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
|
||||
reader.sourceCompleter = this;
|
||||
|
||||
Options options = Options.instance(context);
|
||||
options = Options.instance(context);
|
||||
|
||||
verbose = options.isSet(VERBOSE);
|
||||
sourceOutput = options.isSet(PRINTSOURCE); // used to be -s
|
||||
|
@ -580,7 +585,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
null, List.<JCTree>nil());
|
||||
if (content != null) {
|
||||
if (verbose) {
|
||||
printVerbose("parsing.started", filename);
|
||||
log.printVerbose("parsing.started", filename);
|
||||
}
|
||||
if (taskListener != null) {
|
||||
TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE, filename);
|
||||
|
@ -589,7 +594,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
Parser parser = parserFactory.newParser(content, keepComments(), genEndPos, lineDebugInfo);
|
||||
tree = parser.parseCompilationUnit();
|
||||
if (verbose) {
|
||||
printVerbose("parsing.done", Long.toString(elapsed(msec)));
|
||||
log.printVerbose("parsing.done", Long.toString(elapsed(msec)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -676,7 +681,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
try {
|
||||
new Pretty(out, true).printUnit(env.toplevel, cdef);
|
||||
if (verbose)
|
||||
printVerbose("wrote.file", outFile);
|
||||
log.printVerbose("wrote.file", outFile);
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
|
@ -792,6 +797,11 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
throw new AssertionError("attempt to reuse JavaCompiler");
|
||||
hasBeenUsed = true;
|
||||
|
||||
// forcibly set the equivalent of -Xlint:-options, so that no further
|
||||
// warnings about command line options are generated from this point on
|
||||
options.put(XLINT_CUSTOM + "-" + LintCategory.OPTIONS.option, "true");
|
||||
options.remove(XLINT_CUSTOM + LintCategory.OPTIONS.option);
|
||||
|
||||
start_msec = now();
|
||||
|
||||
try {
|
||||
|
@ -857,7 +867,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
|
||||
if (verbose) {
|
||||
elapsed_msec = elapsed(start_msec);
|
||||
printVerbose("total", Long.toString(elapsed_msec));
|
||||
log.printVerbose("total", Long.toString(elapsed_msec));
|
||||
}
|
||||
|
||||
reportDeferredDiagnostics();
|
||||
|
@ -963,7 +973,6 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
public void initProcessAnnotations(Iterable<? extends Processor> processors) {
|
||||
// Process annotations if processing is not disabled and there
|
||||
// is at least one Processor available.
|
||||
Options options = Options.instance(context);
|
||||
if (options.isSet(PROC, "none")) {
|
||||
processAnnotations = false;
|
||||
} else if (procEnvImpl == null) {
|
||||
|
@ -1022,7 +1031,6 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
// If there are no annotation processors present, and
|
||||
// annotation processing is to occur with compilation,
|
||||
// emit a warning.
|
||||
Options options = Options.instance(context);
|
||||
if (options.isSet(PROC, "only")) {
|
||||
log.warning("proc.proc-only.requested.no.procs");
|
||||
todo.clear();
|
||||
|
@ -1108,9 +1116,13 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
}
|
||||
|
||||
boolean explicitAnnotationProcessingRequested() {
|
||||
Options options = Options.instance(context);
|
||||
return
|
||||
explicitAnnotationProcessingRequested ||
|
||||
explicitAnnotationProcessingRequested(options);
|
||||
}
|
||||
|
||||
static boolean explicitAnnotationProcessingRequested(Options options) {
|
||||
return
|
||||
options.isSet(PROCESSOR) ||
|
||||
options.isSet(PROCESSORPATH) ||
|
||||
options.isSet(PROC, "only") ||
|
||||
|
@ -1142,7 +1154,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
if (verboseCompilePolicy)
|
||||
printNote("[attribute " + env.enclClass.sym + "]");
|
||||
if (verbose)
|
||||
printVerbose("checking.attribution", env.enclClass.sym);
|
||||
log.printVerbose("checking.attribution", env.enclClass.sym);
|
||||
|
||||
if (taskListener != null) {
|
||||
TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
|
||||
|
@ -1508,7 +1520,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
}
|
||||
|
||||
public void reportDeferredDiagnostics() {
|
||||
if (annotationProcessingOccurred
|
||||
if (errorCount() == 0
|
||||
&& annotationProcessingOccurred
|
||||
&& implicitSourceFilesRead
|
||||
&& implicitSourcePolicy == ImplicitSourcePolicy.UNSET) {
|
||||
if (explicitAnnotationProcessingRequested())
|
||||
|
@ -1562,14 +1575,6 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||
Log.printLines(log.noticeWriter, lines);
|
||||
}
|
||||
|
||||
/** Output for "-verbose" option.
|
||||
* @param key The key to look up the correct internationalized string.
|
||||
* @param arg An argument for substitution into the output string.
|
||||
*/
|
||||
protected void printVerbose(String key, Object arg) {
|
||||
log.printNoteLines("verbose." + key, arg);
|
||||
}
|
||||
|
||||
/** Print numbers of errors and warnings.
|
||||
*/
|
||||
protected void printCount(String kind, int count) {
|
||||
|
|
|
@ -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
|
||||
|
@ -367,7 +367,11 @@ public class Main {
|
|||
|| options.isSet(VERSION)
|
||||
|| options.isSet(FULLVERSION))
|
||||
return EXIT_OK;
|
||||
error("err.no.source.files");
|
||||
if (JavaCompiler.explicitAnnotationProcessingRequested(options)) {
|
||||
error("err.no.source.files.classes");
|
||||
} else {
|
||||
error("err.no.source.files");
|
||||
}
|
||||
return EXIT_CMDERR;
|
||||
}
|
||||
} catch (java.io.FileNotFoundException e) {
|
||||
|
|
|
@ -88,6 +88,7 @@ public enum OptionName {
|
|||
O("-O"),
|
||||
XJCOV("-Xjcov"),
|
||||
XD("-XD"),
|
||||
AT("@"),
|
||||
SOURCEFILE("sourcefile");
|
||||
|
||||
public final String optionName;
|
||||
|
|
|
@ -168,6 +168,7 @@ public class RecognizedOptions {
|
|||
O,
|
||||
XJCOV,
|
||||
XD,
|
||||
AT,
|
||||
SOURCEFILE);
|
||||
|
||||
static Set<OptionName> javacFileManagerOptions = EnumSet.of(
|
||||
|
@ -565,12 +566,27 @@ public class RecognizedOptions {
|
|||
}
|
||||
},
|
||||
|
||||
// This option exists only for the purpose of documenting itself.
|
||||
// It's actually implemented by the CommandLine class.
|
||||
new Option(AT, "opt.arg.file", "opt.AT") {
|
||||
@Override
|
||||
String helpSynopsis() {
|
||||
hasSuffix = true;
|
||||
return super.helpSynopsis();
|
||||
}
|
||||
@Override
|
||||
public boolean process(Options options, String option) {
|
||||
throw new AssertionError
|
||||
("the @ flag should be caught by CommandLine.");
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* TODO: With apt, the matches method accepts anything if
|
||||
* -XclassAsDecls is used; code elsewhere does the lookup to
|
||||
* see if the class name is both legal and found.
|
||||
*
|
||||
* In apt, the process method adds the candiate class file
|
||||
* In apt, the process method adds the candidate class file
|
||||
* name to a separate list.
|
||||
*/
|
||||
new HiddenOption(SOURCEFILE) {
|
||||
|
|
|
@ -2357,7 +2357,7 @@ public class JavacParser implements Parser {
|
|||
|
||||
List<JCTypeParameter> typarams = typeParametersOpt();
|
||||
|
||||
JCTree extending = null;
|
||||
JCExpression extending = null;
|
||||
if (S.token() == EXTENDS) {
|
||||
S.nextToken();
|
||||
extending = parseType();
|
||||
|
|
|
@ -807,8 +807,6 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
|||
final JavaCompiler compiler;
|
||||
/** The log for the round. */
|
||||
final Log log;
|
||||
/** The number of warnings in the previous round. */
|
||||
final int priorWarnings;
|
||||
|
||||
/** The ASTs to be compiled. */
|
||||
List<JCCompilationUnit> roots;
|
||||
|
@ -826,10 +824,10 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
|||
private Round(Context context, int number, int priorWarnings) {
|
||||
this.context = context;
|
||||
this.number = number;
|
||||
this.priorWarnings = priorWarnings;
|
||||
|
||||
compiler = JavaCompiler.instance(context);
|
||||
log = Log.instance(context);
|
||||
log.nwarnings += priorWarnings;
|
||||
log.deferDiagnostics = true;
|
||||
|
||||
// the following is for the benefit of JavacProcessingEnvironment.getContext()
|
||||
|
@ -904,8 +902,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
|||
JavaCompiler finalCompiler(boolean errorStatus) {
|
||||
try {
|
||||
JavaCompiler c = JavaCompiler.instance(nextContext());
|
||||
c.log.nwarnings += compiler.log.nwarnings;
|
||||
if (errorStatus) {
|
||||
c.log.nwarnings += priorWarnings + compiler.log.nwarnings;
|
||||
c.log.nerrors += compiler.log.nerrors;
|
||||
}
|
||||
return c;
|
||||
|
@ -1045,7 +1043,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
|||
* other values are implicitly reset.
|
||||
*/
|
||||
private Context nextContext() {
|
||||
Context next = new Context();
|
||||
Context next = new Context(context);
|
||||
|
||||
Options options = Options.instance(context);
|
||||
Assert.checkNonNull(options);
|
||||
|
|
|
@ -1588,14 +1588,6 @@ compiler.misc.diamond=\
|
|||
compiler.misc.diamond.non.generic=\
|
||||
cannot use ''<>'' with non-generic class {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}
|
||||
|
@ -1803,8 +1795,8 @@ compiler.misc.varargs.implement=\
|
|||
compiler.misc.varargs.clash.with=\
|
||||
{0} in {1} overrides {2} in {3}
|
||||
|
||||
compiler.misc.non.denotable.type=\
|
||||
Non-denotable type {0} not allowed here
|
||||
compiler.misc.diamond.and.anon.class=\
|
||||
cannot use ''<>'' with anonymous inner classes
|
||||
|
||||
# 0: symbol kind, 1: symbol, 2: symbol, 3: message segment
|
||||
compiler.misc.inapplicable.method=\
|
||||
|
|
|
@ -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
|
||||
|
@ -146,6 +146,8 @@ javac.opt.printProcessorInfo=\
|
|||
Print information about which annotations a processor is asked to process
|
||||
javac.opt.prefer=\
|
||||
Specify which file to read when both a source file and class file are found for an implicitly compiled class
|
||||
javac.opt.AT=\
|
||||
Read options and filenames from file
|
||||
|
||||
## errors
|
||||
|
||||
|
@ -161,6 +163,8 @@ javac.err.invalid.target=\
|
|||
invalid target release: {0}
|
||||
javac.err.no.source.files=\
|
||||
no source files
|
||||
javac.err.no.source.files.classes=\
|
||||
no source files or class names
|
||||
javac.err.req.arg=\
|
||||
{0} requires an argument
|
||||
javac.err.invalid.source=\
|
||||
|
|
|
@ -567,14 +567,14 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
|||
public JCModifiers mods;
|
||||
public Name name;
|
||||
public List<JCTypeParameter> typarams;
|
||||
public JCTree extending;
|
||||
public JCExpression extending;
|
||||
public List<JCExpression> implementing;
|
||||
public List<JCTree> defs;
|
||||
public ClassSymbol sym;
|
||||
protected JCClassDecl(JCModifiers mods,
|
||||
Name name,
|
||||
List<JCTypeParameter> typarams,
|
||||
JCTree extending,
|
||||
JCExpression extending,
|
||||
List<JCExpression> implementing,
|
||||
List<JCTree> defs,
|
||||
ClassSymbol sym)
|
||||
|
@ -2104,7 +2104,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
|||
JCClassDecl ClassDef(JCModifiers mods,
|
||||
Name name,
|
||||
List<JCTypeParameter> typarams,
|
||||
JCTree extending,
|
||||
JCExpression extending,
|
||||
List<JCExpression> implementing,
|
||||
List<JCTree> defs);
|
||||
JCMethodDecl MethodDef(JCModifiers mods,
|
||||
|
|
|
@ -135,7 +135,7 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
|
|||
JCClassDecl t = (JCClassDecl) node;
|
||||
JCModifiers mods = copy(t.mods, p);
|
||||
List<JCTypeParameter> typarams = copy(t.typarams, p);
|
||||
JCTree extending = copy(t.extending, p);
|
||||
JCExpression extending = copy(t.extending, p);
|
||||
List<JCExpression> implementing = copy(t.implementing, p);
|
||||
List<JCTree> defs = copy(t.defs, p);
|
||||
return M.at(t.pos).ClassDef(mods, t.name, typarams, extending, implementing, defs);
|
||||
|
|
|
@ -146,7 +146,7 @@ public class TreeMaker implements JCTree.Factory {
|
|||
public JCClassDecl ClassDef(JCModifiers mods,
|
||||
Name name,
|
||||
List<JCTypeParameter> typarams,
|
||||
JCTree extending,
|
||||
JCExpression extending,
|
||||
List<JCExpression> implementing,
|
||||
List<JCTree> defs)
|
||||
{
|
||||
|
|
|
@ -108,7 +108,7 @@ public class Context {
|
|||
* instance.
|
||||
*/
|
||||
public static interface Factory<T> {
|
||||
T make();
|
||||
T make(Context c);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -124,6 +124,8 @@ public class Context {
|
|||
Object old = ht.put(key, fac);
|
||||
if (old != null)
|
||||
throw new AssertionError("duplicate context value");
|
||||
checkState(ft);
|
||||
ft.put(key, fac); // cannot be duplicate if unique in ht
|
||||
}
|
||||
|
||||
/** Set the value for the key in this context. */
|
||||
|
@ -142,7 +144,7 @@ public class Context {
|
|||
Object o = ht.get(key);
|
||||
if (o instanceof Factory<?>) {
|
||||
Factory<?> fac = (Factory<?>)o;
|
||||
o = fac.make();
|
||||
o = fac.make(this);
|
||||
if (o instanceof Factory<?>)
|
||||
throw new AssertionError("T extends Context.Factory");
|
||||
Assert.check(ht.get(key) == o);
|
||||
|
@ -158,6 +160,20 @@ public class Context {
|
|||
|
||||
public Context() {}
|
||||
|
||||
/**
|
||||
* The table of preregistered factories.
|
||||
*/
|
||||
private Map<Key<?>,Factory<?>> ft = new HashMap<Key<?>,Factory<?>>();
|
||||
|
||||
public Context(Context prev) {
|
||||
kt.putAll(prev.kt); // retain all implicit keys
|
||||
ft.putAll(prev.ft); // retain all factory objects
|
||||
ht.putAll(prev.ft); // init main table with factories
|
||||
}
|
||||
|
||||
/*
|
||||
* The key table, providing a unique Key<T> for each Class<T>.
|
||||
*/
|
||||
private Map<Class<?>, Key<?>> kt = new HashMap<Class<?>, Key<?>>();
|
||||
|
||||
private <T> Key<T> key(Class<T> clss) {
|
||||
|
@ -198,6 +214,7 @@ public class Context {
|
|||
public void clear() {
|
||||
ht = null;
|
||||
kt = null;
|
||||
ft = null;
|
||||
}
|
||||
|
||||
private static void checkState(Map<?,?> t) {
|
||||
|
|
|
@ -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
|
||||
|
@ -329,7 +329,6 @@ public class Log extends AbstractLog {
|
|||
printLines(errWriter, localize(key, args));
|
||||
}
|
||||
|
||||
|
||||
/** Print the text of a message to the noticeWriter stream,
|
||||
* translating newlines appropriately for the platform.
|
||||
*/
|
||||
|
@ -337,6 +336,14 @@ public class Log extends AbstractLog {
|
|||
printLines(noticeWriter, localize(key, args));
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the localized text of a "verbose" message to the
|
||||
* noticeWriter stream.
|
||||
*/
|
||||
public void printVerbose(String key, Object... args) {
|
||||
printLines(noticeWriter, localize("verbose." + key, args));
|
||||
}
|
||||
|
||||
protected void directError(String key, Object... args) {
|
||||
printErrLines(key, args);
|
||||
errWriter.flush();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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,8 +92,9 @@ public class AnnotationDescImpl implements AnnotationDesc {
|
|||
* @com.example.foo
|
||||
* Omit parens for marker annotations, and omit "value=" when allowed.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer("@");
|
||||
StringBuilder sb = new StringBuilder("@");
|
||||
sb.append(annotation.type.tsym);
|
||||
|
||||
ElementValuePair vals[] = elementValues();
|
||||
|
@ -153,6 +154,7 @@ public class AnnotationDescImpl implements AnnotationDesc {
|
|||
* Returns a string representation of this pair
|
||||
* of the form "name=value".
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return meth.name + "=" + value();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
|
@ -30,7 +30,6 @@ import com.sun.javadoc.*;
|
|||
|
||||
import com.sun.tools.javac.code.Attribute;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.code.Type;
|
||||
import com.sun.tools.javac.code.TypeTags;
|
||||
|
||||
|
||||
|
@ -114,6 +113,7 @@ public class AnnotationValueImpl implements AnnotationValue {
|
|||
* @return the text of a Java language annotation value expression
|
||||
* whose value is the value of this annotation type element.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringVisitor tv = new ToStringVisitor();
|
||||
attr.accept(tv);
|
||||
|
@ -121,8 +121,9 @@ public class AnnotationValueImpl implements AnnotationValue {
|
|||
}
|
||||
|
||||
private class ToStringVisitor implements Attribute.Visitor {
|
||||
private final StringBuffer sb = new StringBuffer();
|
||||
private final StringBuilder sb = new StringBuilder();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
|
@ -64,7 +64,6 @@ import com.sun.tools.javac.util.Name;
|
|||
import com.sun.tools.javac.util.Names;
|
||||
import com.sun.tools.javac.util.Position;
|
||||
|
||||
import static com.sun.tools.javac.code.Flags.*;
|
||||
import static com.sun.tools.javac.code.Kinds.*;
|
||||
|
||||
/**
|
||||
|
@ -147,6 +146,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
|||
/**
|
||||
* Return true if this is a class, not an interface.
|
||||
*/
|
||||
@Override
|
||||
public boolean isClass() {
|
||||
return !Modifier.isInterface(getModifiers());
|
||||
}
|
||||
|
@ -155,6 +155,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
|||
* Return true if this is a ordinary class,
|
||||
* not an enumeration, exception, an error, or an interface.
|
||||
*/
|
||||
@Override
|
||||
public boolean isOrdinaryClass() {
|
||||
if (isEnum() || isInterface() || isAnnotationType()) {
|
||||
return false;
|
||||
|
@ -172,6 +173,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
|||
* Return true if this is an enumeration.
|
||||
* (For legacy doclets, return false.)
|
||||
*/
|
||||
@Override
|
||||
public boolean isEnum() {
|
||||
return (getFlags() & Flags.ENUM) != 0
|
||||
&&
|
||||
|
@ -182,6 +184,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
|||
* Return true if this is an interface, but not an annotation type.
|
||||
* Overridden by AnnotationTypeDocImpl.
|
||||
*/
|
||||
@Override
|
||||
public boolean isInterface() {
|
||||
return Modifier.isInterface(getModifiers());
|
||||
}
|
||||
|
@ -189,6 +192,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
|||
/**
|
||||
* Return true if this is an exception class
|
||||
*/
|
||||
@Override
|
||||
public boolean isException() {
|
||||
if (isEnum() || isInterface() || isAnnotationType()) {
|
||||
return false;
|
||||
|
@ -204,6 +208,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
|||
/**
|
||||
* Return true if this is an error class
|
||||
*/
|
||||
@Override
|
||||
public boolean isError() {
|
||||
if (isEnum() || isInterface() || isAnnotationType()) {
|
||||
return false;
|
||||
|
@ -275,6 +280,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
|||
/**
|
||||
* Return the package that this class is contained in.
|
||||
*/
|
||||
@Override
|
||||
public PackageDoc containingPackage() {
|
||||
PackageDocImpl p = env.getPackageDoc(tsym.packge());
|
||||
if (p.setDocPath == false) {
|
||||
|
@ -374,6 +380,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
|||
* Return the qualified name and any type parameters.
|
||||
* Each parameter is a type variable with optional bounds.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return classToString(env, tsym, true);
|
||||
}
|
||||
|
@ -401,7 +408,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
|||
* qualified by their enclosing class(es) only.
|
||||
*/
|
||||
static String classToString(DocEnv env, ClassSymbol c, boolean full) {
|
||||
StringBuffer s = new StringBuffer();
|
||||
StringBuilder s = new StringBuilder();
|
||||
if (!c.isInner()) { // if c is not an inner class
|
||||
s.append(getClassName(c, full));
|
||||
} else {
|
||||
|
@ -449,10 +456,12 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
|||
* Return the modifier string for this class. If it's an interface
|
||||
* exclude 'abstract' keyword from the modifier string
|
||||
*/
|
||||
@Override
|
||||
public String modifiers() {
|
||||
return Modifier.toString(modifierSpecifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int modifierSpecifier() {
|
||||
int modifiers = getModifiers();
|
||||
return (isInterface() || isAnnotationType())
|
||||
|
@ -1285,6 +1294,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
|||
* Return the source position of the entity, or null if
|
||||
* no position is available.
|
||||
*/
|
||||
@Override
|
||||
public SourcePosition position() {
|
||||
if (tsym.sourcefile == null) return null;
|
||||
return SourcePositionImpl.make(tsym.sourcefile,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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,6 +25,7 @@
|
|||
|
||||
package com.sun.tools.javadoc;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.CollationKey;
|
||||
|
@ -33,6 +34,8 @@ import javax.tools.FileObject;
|
|||
import com.sun.javadoc.*;
|
||||
|
||||
import com.sun.tools.javac.util.Position;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* abstract base class of all Doc classes. Doc item's are representations
|
||||
|
@ -166,51 +169,28 @@ public abstract class DocImpl implements Doc, Comparable<Object> {
|
|||
* Utility for subclasses which read HTML documentation files.
|
||||
*/
|
||||
String readHTMLDocumentation(InputStream input, FileObject filename) throws IOException {
|
||||
int filesize = input.available();
|
||||
byte[] filecontents = new byte[filesize];
|
||||
input.read(filecontents, 0, filesize);
|
||||
input.close();
|
||||
byte[] filecontents = new byte[input.available()];
|
||||
try {
|
||||
DataInputStream dataIn = new DataInputStream(input);
|
||||
dataIn.readFully(filecontents);
|
||||
} finally {
|
||||
input.close();
|
||||
}
|
||||
String encoding = env.getEncoding();
|
||||
String rawDoc = (encoding!=null)
|
||||
? new String(filecontents, encoding)
|
||||
: new String(filecontents);
|
||||
String upper = null;
|
||||
int bodyIdx = rawDoc.indexOf("<body");
|
||||
if (bodyIdx == -1) {
|
||||
bodyIdx = rawDoc.indexOf("<BODY");
|
||||
if (bodyIdx == -1) {
|
||||
upper = rawDoc.toUpperCase();
|
||||
bodyIdx = upper.indexOf("<BODY");
|
||||
if (bodyIdx == -1) {
|
||||
env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
|
||||
"javadoc.Body_missing_from_html_file");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
bodyIdx = rawDoc.indexOf('>', bodyIdx);
|
||||
if (bodyIdx == -1) {
|
||||
env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
|
||||
"javadoc.Body_missing_from_html_file");
|
||||
Pattern bodyPat = Pattern.compile("(?is).*<body\\b[^>]*>(.*)</body\\b.*");
|
||||
Matcher m = bodyPat.matcher(rawDoc);
|
||||
if (m.matches()) {
|
||||
return m.group(1);
|
||||
} else {
|
||||
String key = rawDoc.matches("(?is).*<body\\b.*")
|
||||
? "javadoc.End_body_missing_from_html_file"
|
||||
: "javadoc.Body_missing_from_html_file";
|
||||
env.error(SourcePositionImpl.make(filename, Position.NOPOS, null), key);
|
||||
return "";
|
||||
}
|
||||
++bodyIdx;
|
||||
int endIdx = rawDoc.indexOf("</body", bodyIdx);
|
||||
if (endIdx == -1) {
|
||||
endIdx = rawDoc.indexOf("</BODY", bodyIdx);
|
||||
if (endIdx == -1) {
|
||||
if (upper == null) {
|
||||
upper = rawDoc.toUpperCase();
|
||||
}
|
||||
endIdx = upper.indexOf("</BODY", bodyIdx);
|
||||
if (endIdx == -1) {
|
||||
env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
|
||||
"javadoc.End_body_missing_from_html_file");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return rawDoc.substring(bodyIdx, endIdx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -256,6 +236,7 @@ public abstract class DocImpl implements Doc, Comparable<Object> {
|
|||
/**
|
||||
* Returns a string representation of this Doc item.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return qualifiedName();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
|
@ -31,14 +31,13 @@ import static com.sun.javadoc.LanguageVersion.*;
|
|||
|
||||
import com.sun.tools.javac.util.List;
|
||||
|
||||
import java.net.*;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* Class creates, controls and invokes doclets.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
|
@ -226,7 +226,7 @@ public abstract class ExecutableMemberDocImpl
|
|||
}
|
||||
|
||||
private String makeSignature(boolean full) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("(");
|
||||
for (List<Type> types = sym.type.getParameterTypes(); types.nonEmpty(); ) {
|
||||
Type t = types.head;
|
||||
|
@ -251,6 +251,7 @@ public abstract class ExecutableMemberDocImpl
|
|||
/**
|
||||
* Generate a key for sorting.
|
||||
*/
|
||||
@Override
|
||||
CollationKey generateKey() {
|
||||
String k = name() + flatSignature() + typeParametersString();
|
||||
// ',' and '&' are between '$' and 'a': normalize to spaces.
|
||||
|
@ -263,6 +264,7 @@ public abstract class ExecutableMemberDocImpl
|
|||
* Return the source position of the entity, or null if
|
||||
* no position is available.
|
||||
*/
|
||||
@Override
|
||||
public SourcePosition position() {
|
||||
if (sym.enclClass().sourcefile == null) return null;
|
||||
return SourcePositionImpl.make(sym.enclClass().sourcefile,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
|
@ -142,7 +142,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
|
|||
return v + (suffix == 'f' || suffix == 'F' ? "" + suffix : "");
|
||||
}
|
||||
private static String sourceForm(char c) {
|
||||
StringBuffer buf = new StringBuffer(8);
|
||||
StringBuilder buf = new StringBuilder(8);
|
||||
buf.append('\'');
|
||||
sourceChar(c, buf);
|
||||
buf.append('\'');
|
||||
|
@ -152,7 +152,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
|
|||
return "0x" + Integer.toString(c & 0xff, 16);
|
||||
}
|
||||
private static String sourceForm(String s) {
|
||||
StringBuffer buf = new StringBuffer(s.length() + 5);
|
||||
StringBuilder buf = new StringBuilder(s.length() + 5);
|
||||
buf.append('\"');
|
||||
for (int i=0; i<s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
|
@ -161,7 +161,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
|
|||
buf.append('\"');
|
||||
return buf.toString();
|
||||
}
|
||||
private static void sourceChar(char c, StringBuffer buf) {
|
||||
private static void sourceChar(char c, StringBuilder buf) {
|
||||
switch (c) {
|
||||
case '\b': buf.append("\\b"); return;
|
||||
case '\t': buf.append("\\t"); return;
|
||||
|
@ -179,7 +179,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
|
|||
return;
|
||||
}
|
||||
}
|
||||
private static void unicodeEscape(char c, StringBuffer buf) {
|
||||
private static void unicodeEscape(char c, StringBuilder buf) {
|
||||
final String chars = "0123456789abcdef";
|
||||
buf.append("\\u");
|
||||
buf.append(chars.charAt(15 & (c>>12)));
|
||||
|
@ -201,6 +201,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
|
|||
/**
|
||||
* Is this Doc item a field (but not an enum constant?
|
||||
*/
|
||||
@Override
|
||||
public boolean isField() {
|
||||
return !isEnumConstant();
|
||||
}
|
||||
|
@ -209,6 +210,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
|
|||
* Is this Doc item an enum constant?
|
||||
* (For legacy doclets, return false.)
|
||||
*/
|
||||
@Override
|
||||
public boolean isEnumConstant() {
|
||||
return (getFlags() & Flags.ENUM) != 0 &&
|
||||
!env.legacyDoclet;
|
||||
|
@ -257,6 +259,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
|
|||
* Return the source position of the entity, or null if
|
||||
* no position is available.
|
||||
*/
|
||||
@Override
|
||||
public SourcePosition position() {
|
||||
if (sym.enclClass().sourcefile == null) return null;
|
||||
return SourcePositionImpl.make(sym.enclClass().sourcefile,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -44,10 +44,10 @@ class JavadocClassReader extends ClassReader {
|
|||
return (JavadocClassReader)instance;
|
||||
}
|
||||
|
||||
public static void preRegister(final Context context) {
|
||||
public static void preRegister(Context context) {
|
||||
context.put(classReaderKey, new Context.Factory<ClassReader>() {
|
||||
public ClassReader make() {
|
||||
return new JavadocClassReader(context);
|
||||
public ClassReader make(Context c) {
|
||||
return new JavadocClassReader(c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 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,10 +48,10 @@ public class JavadocEnter extends Enter {
|
|||
return (JavadocEnter)instance;
|
||||
}
|
||||
|
||||
public static void preRegister(final Context context) {
|
||||
public static void preRegister(Context context) {
|
||||
context.put(enterKey, new Context.Factory<Enter>() {
|
||||
public Enter make() {
|
||||
return new JavadocEnter(context);
|
||||
public Enter make(Context c) {
|
||||
return new JavadocEnter(c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
|
@ -46,10 +46,10 @@ class JavadocMemberEnter extends MemberEnter {
|
|||
return (JavadocMemberEnter)instance;
|
||||
}
|
||||
|
||||
public static void preRegister(final Context context) {
|
||||
public static void preRegister(Context context) {
|
||||
context.put(memberEnterKey, new Context.Factory<MemberEnter>() {
|
||||
public MemberEnter make() {
|
||||
return new JavadocMemberEnter(context);
|
||||
public MemberEnter make(Context c) {
|
||||
return new JavadocMemberEnter(c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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,10 +34,10 @@ import com.sun.tools.javac.util.*;
|
|||
* @author Neal Gafter
|
||||
*/
|
||||
public class JavadocTodo extends Todo {
|
||||
public static void preRegister(final Context context) {
|
||||
public static void preRegister(Context context) {
|
||||
context.put(todoKey, new Context.Factory<Todo>() {
|
||||
public Todo make() {
|
||||
return new JavadocTodo(context);
|
||||
public Todo make(Context c) {
|
||||
return new JavadocTodo(c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
|
@ -57,23 +57,23 @@ public class Messager extends Log implements DocErrorReporter {
|
|||
return (Messager)instance;
|
||||
}
|
||||
|
||||
public static void preRegister(final Context context,
|
||||
public static void preRegister(Context context,
|
||||
final String programName) {
|
||||
context.put(logKey, new Context.Factory<Log>() {
|
||||
public Log make() {
|
||||
return new Messager(context,
|
||||
public Log make(Context c) {
|
||||
return new Messager(c,
|
||||
programName);
|
||||
}
|
||||
});
|
||||
}
|
||||
public static void preRegister(final Context context,
|
||||
public static void preRegister(Context context,
|
||||
final String programName,
|
||||
final PrintWriter errWriter,
|
||||
final PrintWriter warnWriter,
|
||||
final PrintWriter noticeWriter) {
|
||||
context.put(logKey, new Context.Factory<Log>() {
|
||||
public Log make() {
|
||||
return new Messager(context,
|
||||
public Log make(Context c) {
|
||||
return new Messager(c,
|
||||
programName,
|
||||
errWriter,
|
||||
warnWriter,
|
||||
|
@ -143,11 +143,9 @@ public class Messager extends Log implements DocErrorReporter {
|
|||
* if needed.
|
||||
*/
|
||||
private String getString(String key) {
|
||||
ResourceBundle messageRB = this.messageRB;
|
||||
if (messageRB == null) {
|
||||
try {
|
||||
this.messageRB = messageRB =
|
||||
ResourceBundle.getBundle(
|
||||
messageRB = ResourceBundle.getBundle(
|
||||
"com.sun.tools.javadoc.resources.javadoc");
|
||||
} catch (MissingResourceException e) {
|
||||
throw new Error("Fatal: Resource for javadoc is missing");
|
||||
|
@ -456,8 +454,6 @@ public class Messager extends Log implements DocErrorReporter {
|
|||
* Print exit message.
|
||||
*/
|
||||
public void exitNotice() {
|
||||
int nerrors = nerrors();
|
||||
int nwarnings = nwarnings();
|
||||
if (nerrors > 0) {
|
||||
notice((nerrors > 1) ? "main.errors" : "main.error",
|
||||
"" + nerrors);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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,15 +25,11 @@
|
|||
|
||||
package com.sun.tools.javadoc;
|
||||
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
|
||||
import static com.sun.javadoc.LanguageVersion.*;
|
||||
|
||||
import com.sun.tools.javac.code.Symbol.ClassSymbol;
|
||||
import com.sun.tools.javac.code.Type;
|
||||
import com.sun.tools.javac.code.Type.ClassType;
|
||||
import com.sun.tools.javac.util.List;
|
||||
|
||||
import static com.sun.tools.javac.code.TypeTags.*;
|
||||
|
||||
|
@ -55,6 +51,7 @@ public class ParameterizedTypeImpl
|
|||
/**
|
||||
* Return the generic class or interface that declared this type.
|
||||
*/
|
||||
@Override
|
||||
public ClassDoc asClassDoc() {
|
||||
return env.getClassDoc((ClassSymbol)type.tsym);
|
||||
}
|
||||
|
@ -111,14 +108,17 @@ public class ParameterizedTypeImpl
|
|||
// Asking for the "name" of a parameterized type doesn't exactly make
|
||||
// sense. It's a type expression. Return the name of its generic
|
||||
// type.
|
||||
@Override
|
||||
public String typeName() {
|
||||
return TypeMaker.getTypeName(type, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParameterizedType asParameterizedType() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return parameterizedTypeToString(env, (ClassType)type, true);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class ParameterizedTypeImpl
|
|||
if (env.legacyDoclet) {
|
||||
return TypeMaker.getTypeName(cl, full);
|
||||
}
|
||||
StringBuffer s = new StringBuffer();
|
||||
StringBuilder s = new StringBuilder();
|
||||
if (cl.getEnclosingType().tag != CLASS) { // if not an inner class...
|
||||
s.append(TypeMaker.getTypeName(cl, full));
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
|
@ -322,6 +322,7 @@ public class RootDocImpl extends DocImpl implements RootDoc {
|
|||
/**
|
||||
* Do lazy initialization of "documentation" string.
|
||||
*/
|
||||
@Override
|
||||
protected String documentation() {
|
||||
if (documentation == null) {
|
||||
int cnt = options.length();
|
||||
|
@ -348,6 +349,7 @@ public class RootDocImpl extends DocImpl implements RootDoc {
|
|||
* Return the source position of the entity, or null if
|
||||
* no position is available.
|
||||
*/
|
||||
@Override
|
||||
public SourcePosition position() {
|
||||
JavaFileObject path;
|
||||
return ((path = getOverviewPath()) == null) ?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
|
@ -358,14 +358,14 @@ class SeeTagImpl extends TagImpl implements SeeTag, LayoutCharacters {
|
|||
|
||||
String parameters;
|
||||
|
||||
StringBuffer typeId;
|
||||
StringBuilder typeId;
|
||||
|
||||
ListBuffer<String> paramList;
|
||||
|
||||
ParameterParseMachine(String parameters) {
|
||||
this.parameters = parameters;
|
||||
this.paramList = new ListBuffer<String>();
|
||||
typeId = new StringBuffer();
|
||||
typeId = new StringBuilder();
|
||||
}
|
||||
|
||||
public String[] parseParameters() {
|
||||
|
@ -464,6 +464,7 @@ class SeeTagImpl extends TagImpl implements SeeTag, LayoutCharacters {
|
|||
/**
|
||||
* Return the kind of this tag.
|
||||
*/
|
||||
@Override
|
||||
public String kind() {
|
||||
return "@see";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
|
@ -396,6 +396,10 @@ class Start {
|
|||
boolean ok = root != null;
|
||||
if (ok) ok = docletInvoker.start(root);
|
||||
|
||||
Messager docletMessager = Messager.instance0(context);
|
||||
messager.nwarnings += docletMessager.nwarnings;
|
||||
messager.nerrors += docletMessager.nerrors;
|
||||
|
||||
// We're done.
|
||||
if (compOpts.get("-verbose") != null) {
|
||||
tm = System.currentTimeMillis() - tm;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,15 +27,12 @@ package com.sun.tools.javadoc;
|
|||
|
||||
import com.sun.javadoc.*;
|
||||
|
||||
import static com.sun.javadoc.LanguageVersion.*;
|
||||
|
||||
import com.sun.tools.javac.code.Symbol;
|
||||
import com.sun.tools.javac.code.Symbol.ClassSymbol;
|
||||
import com.sun.tools.javac.code.Type;
|
||||
import com.sun.tools.javac.code.Type.ClassType;
|
||||
import com.sun.tools.javac.code.Type.TypeVar;
|
||||
import com.sun.tools.javac.code.Type.ArrayType;
|
||||
import com.sun.tools.javac.code.Types;
|
||||
import com.sun.tools.javac.util.List;
|
||||
|
||||
import static com.sun.tools.javac.code.TypeTags.*;
|
||||
|
@ -109,12 +106,13 @@ public class TypeMaker {
|
|||
public static String getTypeName(Type t, boolean full) {
|
||||
switch (t.tag) {
|
||||
case ARRAY:
|
||||
StringBuffer dimension = new StringBuffer();
|
||||
StringBuilder s = new StringBuilder();
|
||||
while (t.tag == ARRAY) {
|
||||
dimension = dimension.append("[]");
|
||||
s.append("[]");
|
||||
t = ((ArrayType)t).elemtype;
|
||||
}
|
||||
return getTypeName(t, full) + dimension;
|
||||
s.insert(0, getTypeName(t, full));
|
||||
return s.toString();
|
||||
case CLASS:
|
||||
return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
|
||||
default:
|
||||
|
@ -130,12 +128,13 @@ public class TypeMaker {
|
|||
static String getTypeString(DocEnv env, Type t, boolean full) {
|
||||
switch (t.tag) {
|
||||
case ARRAY:
|
||||
StringBuffer dimension = new StringBuffer();
|
||||
StringBuilder s = new StringBuilder();
|
||||
while (t.tag == ARRAY) {
|
||||
dimension = dimension.append("[]");
|
||||
s.append("[]");
|
||||
t = env.types.elemtype(t);
|
||||
}
|
||||
return getTypeString(env, t, full) + dimension;
|
||||
s.insert(0, getTypeString(env, t, full));
|
||||
return s.toString();
|
||||
case CLASS:
|
||||
return ParameterizedTypeImpl.
|
||||
parameterizedTypeToString(env, (ClassType)t, full);
|
||||
|
@ -157,7 +156,7 @@ public class TypeMaker {
|
|||
if (env.legacyDoclet || sym.type.getTypeArguments().isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
StringBuffer s = new StringBuffer();
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (Type t : sym.type.getTypeArguments()) {
|
||||
s.append(s.length() == 0 ? "<" : ", ");
|
||||
s.append(TypeVariableImpl.typeVarToString(env, (TypeVar)t, full));
|
||||
|
@ -175,7 +174,7 @@ public class TypeMaker {
|
|||
if (env.legacyDoclet || cl.getTypeArguments().isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
StringBuffer s = new StringBuffer();
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (Type t : cl.getTypeArguments()) {
|
||||
s.append(s.length() == 0 ? "<" : ", ");
|
||||
s.append(getTypeString(env, t, full));
|
||||
|
@ -213,9 +212,9 @@ public class TypeMaker {
|
|||
* For example, a two dimensional array of String returns '[][]'.
|
||||
*/
|
||||
public String dimension() {
|
||||
StringBuffer dimension = new StringBuffer();
|
||||
StringBuilder dimension = new StringBuilder();
|
||||
for (Type t = arrayType; t.tag == ARRAY; t = env.types.elemtype(t)) {
|
||||
dimension = dimension.append("[]");
|
||||
dimension.append("[]");
|
||||
}
|
||||
return dimension.toString();
|
||||
}
|
||||
|
@ -304,6 +303,7 @@ public class TypeMaker {
|
|||
*
|
||||
* @return name of type including any dimension information.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return qualifiedTypeName() + dimension();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
|
@ -78,14 +78,17 @@ public class TypeVariableImpl extends AbstractTypeImpl implements TypeVariable {
|
|||
/**
|
||||
* Return the ClassDoc of the erasure of this type variable.
|
||||
*/
|
||||
@Override
|
||||
public ClassDoc asClassDoc() {
|
||||
return env.getClassDoc((ClassSymbol)env.types.erasure(type).tsym);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeVariable asTypeVariable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return typeVarToString(env, (TypeVar)type, true);
|
||||
}
|
||||
|
@ -96,7 +99,7 @@ public class TypeVariableImpl extends AbstractTypeImpl implements TypeVariable {
|
|||
* "extends" clause. Class names are qualified if "full" is true.
|
||||
*/
|
||||
static String typeVarToString(DocEnv env, TypeVar v, boolean full) {
|
||||
StringBuffer s = new StringBuffer(v.toString());
|
||||
StringBuilder s = new StringBuilder(v.toString());
|
||||
List<Type> bounds = getBounds(v, env);
|
||||
if (bounds.nonEmpty()) {
|
||||
boolean first = true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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,8 +28,6 @@ package com.sun.tools.javadoc;
|
|||
|
||||
import com.sun.javadoc.*;
|
||||
|
||||
import static com.sun.javadoc.LanguageVersion.*;
|
||||
|
||||
import com.sun.tools.javac.code.Symbol.ClassSymbol;
|
||||
import com.sun.tools.javac.code.Type;
|
||||
import com.sun.tools.javac.util.List;
|
||||
|
@ -69,18 +67,24 @@ public class WildcardTypeImpl extends AbstractTypeImpl implements WildcardType {
|
|||
/**
|
||||
* Return the ClassDoc of the erasure of this wildcard type.
|
||||
*/
|
||||
@Override
|
||||
public ClassDoc asClassDoc() {
|
||||
return env.getClassDoc((ClassSymbol)env.types.erasure(type).tsym);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WildcardType asWildcardType() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String typeName() { return "?"; }
|
||||
@Override
|
||||
public String qualifiedTypeName() { return "?"; }
|
||||
@Override
|
||||
public String simpleTypeName() { return "?"; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return wildcardTypeToString(env, (Type.WildcardType)type, true);
|
||||
}
|
||||
|
@ -96,7 +100,7 @@ public class WildcardTypeImpl extends AbstractTypeImpl implements WildcardType {
|
|||
if (env.legacyDoclet) {
|
||||
return TypeMaker.getTypeName(env.types.erasure(wildThing), full);
|
||||
}
|
||||
StringBuffer s = new StringBuffer("?");
|
||||
StringBuilder s = new StringBuilder("?");
|
||||
List<Type> bounds = getExtendsBounds(wildThing);
|
||||
if (bounds.nonEmpty()) {
|
||||
s.append(" extends ");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 1997, 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
|
||||
|
@ -104,7 +104,7 @@ tag.throws.exception_not_found={0} tag, class {1} not found.
|
|||
tag.End_delimiter_missing_for_possible_SeeTag=End Delimiter } missing for possible See Tag in comment string: "{0}"
|
||||
tag.Improper_Use_Of_Link_Tag=Missing closing ''}'' character for inline tag: "{0}"
|
||||
javadoc.File_Read_Error=Error while reading file {0}
|
||||
javadoc.Body_missing_from_html_file=Body tag missing from HTML
|
||||
javadoc.Body_missing_from_html_file=Body tag missing from HTML file
|
||||
javadoc.End_body_missing_from_html_file=Close body tag missing from HTML file
|
||||
javadoc.Multiple_package_comments=Multiple sources of package comments found for package "{0}"
|
||||
javadoc.class_not_found=Class {0} not found.
|
||||
|
|
71
langtools/test/tools/javac/7023703/T7023703neg.java
Normal file
71
langtools/test/tools/javac/7023703/T7023703neg.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* 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 7023703
|
||||
* @summary Valid code doesn't compile
|
||||
* @compile/fail/ref=T7023703neg.out -XDrawDiagnostics T7023703neg.java
|
||||
*/
|
||||
|
||||
class T7023703neg {
|
||||
|
||||
void testForLoop(boolean cond) {
|
||||
final int bug;
|
||||
final int bug2;
|
||||
for (;cond;) {
|
||||
final int item = 0;
|
||||
bug2 = 1; //error
|
||||
}
|
||||
bug = 0; //ok
|
||||
}
|
||||
|
||||
void testForEachLoop(java.util.Collection<Integer> c) {
|
||||
final int bug;
|
||||
final int bug2;
|
||||
for (Integer i : c) {
|
||||
final int item = 0;
|
||||
bug2 = 1; //error
|
||||
}
|
||||
bug = 0; //ok
|
||||
}
|
||||
|
||||
void testWhileLoop(boolean cond) {
|
||||
final int bug;
|
||||
final int bug2;
|
||||
while (cond) {
|
||||
final int item = 0;
|
||||
bug2 = 1; //error
|
||||
}
|
||||
bug = 0; //ok
|
||||
}
|
||||
|
||||
void testDoWhileLoop(boolean cond) {
|
||||
final int bug;
|
||||
final int bug2;
|
||||
do {
|
||||
final int item = 0;
|
||||
bug2 = 1; //error
|
||||
} while (cond);
|
||||
bug = 0; //ok
|
||||
}
|
||||
}
|
5
langtools/test/tools/javac/7023703/T7023703neg.out
Normal file
5
langtools/test/tools/javac/7023703/T7023703neg.out
Normal file
|
@ -0,0 +1,5 @@
|
|||
T7023703neg.java:37:13: compiler.err.var.might.be.assigned.in.loop: bug2
|
||||
T7023703neg.java:47:13: compiler.err.var.might.be.assigned.in.loop: bug2
|
||||
T7023703neg.java:57:13: compiler.err.var.might.be.assigned.in.loop: bug2
|
||||
T7023703neg.java:67:13: compiler.err.var.might.be.assigned.in.loop: bug2
|
||||
4 errors
|
73
langtools/test/tools/javac/7023703/T7023703pos.java
Normal file
73
langtools/test/tools/javac/7023703/T7023703pos.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* 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 7023703
|
||||
* @summary Valid code doesn't compile
|
||||
* @compile T7023703pos.java
|
||||
*/
|
||||
|
||||
class T7023703pos {
|
||||
|
||||
void testForLoop() {
|
||||
final int bug;
|
||||
for (;"a".equals("b");) {
|
||||
final int item = 0;
|
||||
}
|
||||
bug = 0; //ok
|
||||
}
|
||||
|
||||
void testForEachLoop(boolean cond, java.util.Collection<Integer> c) {
|
||||
final int bug;
|
||||
for (Integer i : c) {
|
||||
if (cond) {
|
||||
final int item = 0;
|
||||
}
|
||||
}
|
||||
bug = 0; //ok
|
||||
}
|
||||
|
||||
void testWhileLoop() {
|
||||
final int bug;
|
||||
while ("a".equals("b")) {
|
||||
final int item = 0;
|
||||
}
|
||||
bug = 0; //ok
|
||||
}
|
||||
|
||||
void testDoWhileLoop() {
|
||||
final int bug;
|
||||
do {
|
||||
final int item = 0;
|
||||
} while ("a".equals("b"));
|
||||
bug = 0; //ok
|
||||
}
|
||||
|
||||
private static class Inner {
|
||||
private final int a, b, c, d, e;
|
||||
|
||||
public Inner() {
|
||||
a = b = c = d = e = 0;
|
||||
}
|
||||
}
|
||||
}
|
46
langtools/test/tools/javac/7024568/T7024568.java
Normal file
46
langtools/test/tools/javac/7024568/T7024568.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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 7024568
|
||||
* @summary Very long method resolution causing OOM error
|
||||
* @compile/fail/ref=T7024568.out -XDrawDiagnostics T7024568.java
|
||||
*/
|
||||
|
||||
class Main {
|
||||
void test(Obj o) {
|
||||
o.test(0, 0, 0, 0, 0, 0, 0, 0, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
interface Test {
|
||||
public void test(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, String str);
|
||||
public void test(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, long l);
|
||||
}
|
||||
|
||||
interface Obj extends Test, A, B, C, D, E {}
|
||||
interface A extends Test {}
|
||||
interface B extends A, Test {}
|
||||
interface C extends A, B, Test {}
|
||||
interface D extends A, B, C, Test {}
|
||||
interface E extends A, B, C, D, Test {}
|
2
langtools/test/tools/javac/7024568/T7024568.out
Normal file
2
langtools/test/tools/javac/7024568/T7024568.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
T7024568.java:32:40: compiler.err.cant.resolve.location: kindname.variable, undefined, , , (compiler.misc.location: kindname.class, Main, null)
|
||||
1 error
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 4279339
|
||||
* @bug 4279339 6969184
|
||||
* @summary Verify that an anonymous class cannot contain a static method.
|
||||
* @author maddox
|
||||
*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 4063740
|
||||
* @bug 4063740 6969184
|
||||
* @summary Interfaces may only be declared in top level classes.
|
||||
* @author turnidge
|
||||
*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 4406966
|
||||
* @bug 4406966 6969184
|
||||
* @summary null qualifying inner instance creation should be error.
|
||||
* @author gafter
|
||||
*
|
||||
|
|
20
langtools/test/tools/javac/TryWithResources/T7022711.java
Normal file
20
langtools/test/tools/javac/TryWithResources/T7022711.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 7022711
|
||||
* @summary compiler crash in try-with-resources
|
||||
* @compile/fail/ref=T7022711.out -XDrawDiagnostics T7022711.java
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
|
||||
class T7022711 {
|
||||
public static void main (String args[]) throws Exception {
|
||||
try (DataInputStream is = new DataInputStream(new FileInputStream("x"))) {
|
||||
while (true) {
|
||||
is.getChar(); // method not found
|
||||
}
|
||||
} catch (EOFException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
langtools/test/tools/javac/TryWithResources/T7022711.out
Normal file
2
langtools/test/tools/javac/TryWithResources/T7022711.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
T7022711.java:14:19: compiler.err.cant.resolve.location.args: kindname.method, getChar, , , (compiler.misc.location.1: kindname.variable, is, java.io.DataInputStream)
|
||||
1 error
|
|
@ -0,0 +1,250 @@
|
|||
/*
|
||||
* 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 7023233
|
||||
* @summary False positive for -Xlint:try with nested try with resources blocks
|
||||
*/
|
||||
|
||||
import com.sun.source.util.JavacTask;
|
||||
import com.sun.tools.javac.api.JavacTool;
|
||||
import com.sun.tools.javac.util.JCDiagnostic;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.SimpleJavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
public class UnusedResourcesTest {
|
||||
|
||||
enum XlintOption {
|
||||
NONE("none"),
|
||||
TRY("try");
|
||||
|
||||
String opt;
|
||||
|
||||
XlintOption(String opt) {
|
||||
this.opt = opt;
|
||||
}
|
||||
|
||||
String getXlintOption() {
|
||||
return "-Xlint:" + opt;
|
||||
}
|
||||
}
|
||||
|
||||
enum TwrStmt {
|
||||
TWR1("res1"),
|
||||
TWR2("res2"),
|
||||
TWR3("res3");
|
||||
|
||||
final String resourceName;
|
||||
|
||||
private TwrStmt(String resourceName) {
|
||||
this.resourceName = resourceName;
|
||||
}
|
||||
}
|
||||
|
||||
enum SuppressLevel {
|
||||
NONE,
|
||||
SUPPRESS;
|
||||
|
||||
String getSuppressAnno() {
|
||||
return this == SUPPRESS ?
|
||||
"@SuppressWarnings(\"try\")" :
|
||||
"";
|
||||
}
|
||||
}
|
||||
|
||||
enum ResourceUsage {
|
||||
NONE(null),
|
||||
USE_R1(TwrStmt.TWR1),
|
||||
USE_R2(TwrStmt.TWR2),
|
||||
USE_R3(TwrStmt.TWR3);
|
||||
|
||||
TwrStmt stmt;
|
||||
|
||||
private ResourceUsage(TwrStmt stmt) {
|
||||
this.stmt = stmt;
|
||||
}
|
||||
|
||||
String usedResourceName() {
|
||||
return stmt != null ? stmt.resourceName : null;
|
||||
}
|
||||
|
||||
boolean isUsedIn(TwrStmt res, TwrStmt stmt) {
|
||||
return this.stmt == res &&
|
||||
stmt.ordinal() >= this.stmt.ordinal();
|
||||
}
|
||||
|
||||
String getUsage(TwrStmt stmt) {
|
||||
return this != NONE && stmt.ordinal() >= this.stmt.ordinal() ?
|
||||
"use(" + usedResourceName() + ");" :
|
||||
"";
|
||||
}
|
||||
}
|
||||
|
||||
static class JavaSource extends SimpleJavaFileObject {
|
||||
|
||||
String template = "class Resource implements AutoCloseable {\n" +
|
||||
"public void close() {}\n" +
|
||||
"}\n" +
|
||||
"class Test {\n" +
|
||||
"void use(Resource r) {}\n" +
|
||||
"#S void test() {\n" +
|
||||
"try (Resource #R1 = new Resource()) {\n" +
|
||||
"#U1_R1\n" +
|
||||
"#U1_R2\n" +
|
||||
"#U1_R3\n" +
|
||||
"try (Resource #R2 = new Resource()) {\n" +
|
||||
"#U2_R1\n" +
|
||||
"#U2_R2\n" +
|
||||
"#U2_R3\n" +
|
||||
"try (Resource #R3 = new Resource()) {\n" +
|
||||
"#U3_R1\n" +
|
||||
"#U3_R2\n" +
|
||||
"#U3_R3\n" +
|
||||
"}\n" +
|
||||
"}\n" +
|
||||
"}\n" +
|
||||
"}\n" +
|
||||
"}\n";
|
||||
|
||||
String source;
|
||||
|
||||
public JavaSource(SuppressLevel suppressLevel, ResourceUsage usage1,
|
||||
ResourceUsage usage2, ResourceUsage usage3) {
|
||||
super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
|
||||
source = template.replace("#S", suppressLevel.getSuppressAnno()).
|
||||
replace("#R1", TwrStmt.TWR1.resourceName).
|
||||
replace("#R2", TwrStmt.TWR2.resourceName).
|
||||
replace("#R3", TwrStmt.TWR3.resourceName).
|
||||
replace("#U1_R1", usage1.getUsage(TwrStmt.TWR1)).
|
||||
replace("#U1_R2", usage2.getUsage(TwrStmt.TWR1)).
|
||||
replace("#U1_R3", usage3.getUsage(TwrStmt.TWR1)).
|
||||
replace("#U2_R1", usage1.getUsage(TwrStmt.TWR2)).
|
||||
replace("#U2_R2", usage2.getUsage(TwrStmt.TWR2)).
|
||||
replace("#U2_R3", usage3.getUsage(TwrStmt.TWR2)).
|
||||
replace("#U3_R1", usage1.getUsage(TwrStmt.TWR3)).
|
||||
replace("#U3_R2", usage2.getUsage(TwrStmt.TWR3)).
|
||||
replace("#U3_R3", usage3.getUsage(TwrStmt.TWR3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
for (XlintOption xlint : XlintOption.values()) {
|
||||
for (SuppressLevel suppressLevel : SuppressLevel.values()) {
|
||||
for (ResourceUsage usage1 : ResourceUsage.values()) {
|
||||
for (ResourceUsage usage2 : ResourceUsage.values()) {
|
||||
for (ResourceUsage usage3 : ResourceUsage.values()) {
|
||||
test(xlint,
|
||||
suppressLevel,
|
||||
usage1,
|
||||
usage2,
|
||||
usage3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create a single file manager and reuse it for each compile to save time.
|
||||
static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
|
||||
|
||||
static void test(XlintOption xlint, SuppressLevel suppressLevel, ResourceUsage usage1,
|
||||
ResourceUsage usage2, ResourceUsage usage3) throws Exception {
|
||||
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||
JavaSource source = new JavaSource(suppressLevel, usage1, usage2, usage3);
|
||||
DiagnosticChecker dc = new DiagnosticChecker();
|
||||
JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
|
||||
Arrays.asList(xlint.getXlintOption()), null, Arrays.asList(source));
|
||||
ct.analyze();
|
||||
check(source, xlint, suppressLevel, usage1, usage2, usage3, dc);
|
||||
}
|
||||
|
||||
static void check(JavaSource source, XlintOption xlint, SuppressLevel suppressLevel,
|
||||
ResourceUsage usage1, ResourceUsage usage2, ResourceUsage usage3, DiagnosticChecker dc) {
|
||||
|
||||
ResourceUsage[] usages = { usage1, usage2, usage3 };
|
||||
boolean[] unusedFound = { dc.unused_r1, dc.unused_r2, dc.unused_r3 };
|
||||
boolean[] usedResources = { false, false, false };
|
||||
|
||||
for (TwrStmt res : TwrStmt.values()) {
|
||||
outer: for (TwrStmt stmt : TwrStmt.values()) {
|
||||
for (ResourceUsage usage : usages) {
|
||||
if (usage.isUsedIn(res, stmt)) {
|
||||
usedResources[res.ordinal()] = true;
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TwrStmt stmt : TwrStmt.values()) {
|
||||
boolean unused = !usedResources[stmt.ordinal()] &&
|
||||
xlint == XlintOption.TRY &&
|
||||
suppressLevel != SuppressLevel.SUPPRESS;
|
||||
if (unused != unusedFound[stmt.ordinal()]) {
|
||||
throw new Error("invalid diagnostics for source:\n" +
|
||||
source.getCharContent(true) +
|
||||
"\nOptions: " + xlint.getXlintOption() +
|
||||
"\nFound unused res1: " + unusedFound[0] +
|
||||
"\nFound unused res2: " + unusedFound[1] +
|
||||
"\nFound unused res3: " + unusedFound[2] +
|
||||
"\nExpected unused res1: " + !usedResources[0] +
|
||||
"\nExpected unused res2: " + !usedResources[1] +
|
||||
"\nExpected unused res3: " + !usedResources[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
|
||||
|
||||
boolean unused_r1 = false;
|
||||
boolean unused_r2 = false;
|
||||
boolean unused_r3 = false;
|
||||
|
||||
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
|
||||
if (diagnostic.getKind() == Diagnostic.Kind.WARNING &&
|
||||
diagnostic.getCode().contains("try.resource.not.referenced")) {
|
||||
String varName = ((JCDiagnostic)diagnostic).getArgs()[0].toString();
|
||||
if (varName.equals(TwrStmt.TWR1.resourceName)) {
|
||||
unused_r1 = true;
|
||||
} else if (varName.equals(TwrStmt.TWR2.resourceName)) {
|
||||
unused_r2 = true;
|
||||
} else if (varName.equals(TwrStmt.TWR3.resourceName)) {
|
||||
unused_r3 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -119,7 +119,7 @@ public class T6557752 {
|
|||
Types types = task.getTypes();
|
||||
|
||||
if (types.asElement(trees.getOriginalType((ErrorType)typeMirror)) != null) {
|
||||
throw new AssertionError("Ttypes.asElement() error!");
|
||||
throw new AssertionError("Types.asElement() error!");
|
||||
}
|
||||
foundError = true;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ 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.main.JavaCompiler;
|
||||
import com.sun.tools.javac.parser.Token;
|
||||
import com.sun.tools.javac.util.*;
|
||||
import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration;
|
||||
|
@ -107,8 +108,7 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
|
|||
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));
|
||||
ArgTypeJavaCompiler.preRegister(c);
|
||||
Boolean ok = t.call();
|
||||
|
||||
return ok;
|
||||
|
@ -144,7 +144,7 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
|
|||
}
|
||||
};
|
||||
JavacFileManager.preRegister(c); // can't create it until Log has been set up
|
||||
ArgTypeDiagnosticFormatter.preRegister(c);
|
||||
ArgTypeJavaCompiler.preRegister(c);
|
||||
ArgTypeMessages.preRegister(c);
|
||||
int result = main.compile(args.toArray(new String[args.size()]), c);
|
||||
|
||||
|
@ -170,7 +170,7 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
|
|||
|
||||
Context c = new Context();
|
||||
JavacFileManager.preRegister(c); // can't create it until Log has been set up
|
||||
ArgTypeDiagnosticFormatter.preRegister(c);
|
||||
ArgTypeJavaCompiler.preRegister(c);
|
||||
ArgTypeMessages.preRegister(c);
|
||||
com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", out);
|
||||
int rc = m.compile(args.toArray(new String[args.size()]), c);
|
||||
|
@ -189,17 +189,6 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
|
|||
* 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,
|
||||
|
@ -245,15 +234,38 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trivial subtype of JavaCompiler to get access to the protected compilerKey field.
|
||||
* The factory is used to ensure that the log is initialized with an instance of
|
||||
* ArgTypeDiagnosticFormatter before we create the required JavaCompiler.
|
||||
*/
|
||||
static class ArgTypeJavaCompiler extends JavaCompiler {
|
||||
static void preRegister(Context context) {
|
||||
context.put(compilerKey, new Context.Factory<JavaCompiler>() {
|
||||
public JavaCompiler make(Context c) {
|
||||
Log log = Log.instance(c);
|
||||
Options options = Options.instance(c);
|
||||
log.setDiagnosticFormatter(new ArgTypeDiagnosticFormatter(options));
|
||||
return new JavaCompiler(c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// not used
|
||||
private ArgTypeJavaCompiler() {
|
||||
super(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
static void preRegister(Context context) {
|
||||
context.put(JavacMessages.messagesKey, new Context.Factory<JavacMessages>() {
|
||||
public JavacMessages make(Context c) {
|
||||
return new ArgTypeMessages(c) {
|
||||
@Override
|
||||
public String getLocalizedString(Locale l, String key, Object... args) {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6964768 6964461 6964469 6964487 6964460 6964481
|
||||
* @bug 6964768 6964461 6964469 6964487 6964460 6964481 6980021
|
||||
* @summary need test program to validate javac resource bundles
|
||||
*/
|
||||
|
||||
|
|
|
@ -486,7 +486,7 @@ class Example implements Comparable<Example> {
|
|||
if (verbose)
|
||||
System.err.println("run_simple: " + opts + " " + files);
|
||||
|
||||
List<String> args = new ArrayList<String>(opts);
|
||||
List<String> args = new ArrayList<String>();
|
||||
|
||||
if (out != null && raw)
|
||||
args.add("-XDrawDiagnostics");
|
||||
|
@ -522,10 +522,10 @@ class Example implements Comparable<Example> {
|
|||
super(context);
|
||||
}
|
||||
|
||||
static void preRegister(final Context c, final Set<String> keys) {
|
||||
static void preRegister(Context c, final Set<String> keys) {
|
||||
if (keys != null) {
|
||||
c.put(JavacMessages.messagesKey, new Context.Factory<JavacMessages>() {
|
||||
public JavacMessages make() {
|
||||
public JavacMessages make(Context c) {
|
||||
return new MessageTracker(c) {
|
||||
@Override
|
||||
public String getLocalizedString(Locale l, String key, Object... args) {
|
||||
|
|
|
@ -70,7 +70,6 @@ compiler.misc.kindname.static
|
|||
compiler.misc.kindname.type.variable
|
||||
compiler.misc.kindname.type.variable.bound
|
||||
compiler.misc.kindname.value
|
||||
compiler.misc.non.denotable.type
|
||||
compiler.misc.no.unique.minimal.instance.exists
|
||||
compiler.misc.resume.abort # prompt for a response
|
||||
compiler.misc.source.unavailable # DiagnosticSource
|
||||
|
|
|
@ -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
|
||||
|
@ -21,11 +21,13 @@
|
|||
* questions.
|
||||
*/
|
||||
|
||||
// key: compiler.misc.diamond.invalid.arg
|
||||
// key: compiler.misc.diamond
|
||||
// key: compiler.misc.diamond.and.anon.class
|
||||
// key: compiler.err.cant.apply.diamond.1
|
||||
|
||||
class DiamondInvalidArg {
|
||||
static class Foo<X extends Number & Comparable<Number>> { }
|
||||
Foo<?> foo = new Foo<>();
|
||||
import java.util.*;
|
||||
|
||||
class DiamondAndAnonClass {
|
||||
void m() {
|
||||
List<String> list = new ArrayList<>() {};
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 6956758
|
||||
* @bug 6969184
|
||||
*
|
||||
* @summary poor error recovery after symbol not found
|
||||
* @author Maurizio Cimadamore
|
||||
|
|
131
langtools/test/tools/javac/generics/7015430/T7015430.java
Normal file
131
langtools/test/tools/javac/generics/7015430/T7015430.java
Normal file
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 7015430
|
||||
*
|
||||
* @summary Incorrect thrown type determined for unchecked invocations
|
||||
* @author Daniel Smith
|
||||
* @compile/fail/ref=T7015430.out -Xlint:unchecked -XDrawDiagnostics T7015430.java
|
||||
*
|
||||
*/
|
||||
|
||||
class T7015430 {
|
||||
static <E extends Exception> Iterable<E> empty(Iterable<E> arg) throws E {
|
||||
return null;
|
||||
}
|
||||
|
||||
<E extends Exception> T7015430(Iterable<E> arg) throws E { }
|
||||
|
||||
static <E extends Exception> Iterable<E> empty2(Iterable x) throws E {
|
||||
return null;
|
||||
}
|
||||
|
||||
static class Foo<X extends Exception> {
|
||||
Foo() throws X {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method invocation, no unchecked
|
||||
* inferred: RuntimeException - should pass
|
||||
*/
|
||||
void m1() {
|
||||
Iterable<RuntimeException> i = java.util.Collections.emptyList();
|
||||
empty(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method invocation, unchecked, inferred arguments
|
||||
* inferred: Exception - should fail
|
||||
*/
|
||||
void m2() {
|
||||
Iterable i = java.util.Collections.EMPTY_LIST;
|
||||
empty(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method invocation, unchecked, explicit arguments
|
||||
* inferred: RuntimeException - should pass
|
||||
*/
|
||||
void m3() {
|
||||
Iterable i = java.util.Collections.EMPTY_LIST;
|
||||
T7015430.<RuntimeException>empty(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor invocation, no unchecked
|
||||
* inferred: RuntimeException - should pass
|
||||
*/
|
||||
void m4() {
|
||||
Iterable<RuntimeException> i = java.util.Collections.emptyList();
|
||||
new T7015430(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor invocation, unchecked, inferred arguments
|
||||
* inferred: Exception - should fail
|
||||
*/
|
||||
void m5() {
|
||||
Iterable i = java.util.Collections.EMPTY_LIST;
|
||||
new T7015430(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor invocation, unchecked, explicit arguments
|
||||
* inferred: RuntimeException - should pass
|
||||
*/
|
||||
void m6() {
|
||||
Iterable i = java.util.Collections.EMPTY_LIST;
|
||||
new <RuntimeException>T7015430(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method invocation, no unchecked, inferred arguments
|
||||
* inferred: RuntimeException - should pass
|
||||
*/
|
||||
void m7() {
|
||||
Iterable i = java.util.Collections.EMPTY_LIST;
|
||||
Iterable<RuntimeException> e = empty2(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method invocation, no unchecked, inferred arguments
|
||||
* inferred: Exception - should fail
|
||||
*/
|
||||
void m8() {
|
||||
Iterable i = java.util.Collections.EMPTY_LIST;
|
||||
empty2(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor invocation, unchecked, explicit arguments
|
||||
* inferred: RuntimeException - should pass
|
||||
*/
|
||||
void m9() {
|
||||
Iterable i = java.util.Collections.EMPTY_LIST;
|
||||
new <RuntimeException> T7015430(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor invocation, unchecked, inferred arguments
|
||||
* inferred: Exception - should fail
|
||||
*/
|
||||
void m10() {
|
||||
Iterable i = java.util.Collections.EMPTY_LIST;
|
||||
new T7015430(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor invocation, no unchecked, inferred arguments (diamond)
|
||||
* inferred: RuntimeException - should pass
|
||||
*/
|
||||
void m11() {
|
||||
Foo<RuntimeException> o = new Foo<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor invocation, no unchecked, inferred arguments (diamond)
|
||||
* inferred: Exception - should fail
|
||||
*/
|
||||
void m12() {
|
||||
new Foo<>();
|
||||
}
|
||||
}
|
19
langtools/test/tools/javac/generics/7015430/T7015430.out
Normal file
19
langtools/test/tools/javac/generics/7015430/T7015430.out
Normal file
|
@ -0,0 +1,19 @@
|
|||
T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
|
||||
T7015430.java:41:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
|
||||
T7015430.java:50:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
|
||||
T7015430.java:50:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
|
||||
T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
|
||||
T7015430.java:68:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
|
||||
T7015430.java:77:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
|
||||
T7015430.java:77:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
|
||||
T7015430.java:104:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
|
||||
T7015430.java:104:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
|
||||
T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
|
||||
T7015430.java:113:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
|
||||
T7015430.java:41:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
|
||||
T7015430.java:68:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
|
||||
T7015430.java:95:15: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
|
||||
T7015430.java:113:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
|
||||
T7015430.java:129:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
|
||||
5 errors
|
||||
12 warnings
|
23
langtools/test/tools/javac/generics/7020657/T7020657neg.java
Normal file
23
langtools/test/tools/javac/generics/7020657/T7020657neg.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 7020657 6985719
|
||||
*
|
||||
* @summary Javac rejects a fairly common idiom with raw override and interfaces
|
||||
* @author Maurizio Cimadamore
|
||||
* @compile/fail/ref=T7020657neg.out -XDrawDiagnostics T7020657neg.java
|
||||
*
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class T7020657neg {
|
||||
interface A {
|
||||
int get(List<String> l);
|
||||
}
|
||||
|
||||
interface B {
|
||||
int get(List<Integer> l);
|
||||
}
|
||||
|
||||
interface C extends A, B { }
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
T7020657neg.java:22:5: compiler.err.name.clash.same.erasure.no.override: get(java.util.List<java.lang.Integer>), T7020657neg.B, get(java.util.List<java.lang.String>), T7020657neg.A
|
||||
1 error
|
48
langtools/test/tools/javac/generics/7020657/T7020657pos.java
Normal file
48
langtools/test/tools/javac/generics/7020657/T7020657pos.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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 7020657 6985719
|
||||
*
|
||||
* @summary Javac rejects a fairly common idiom with raw override and interfaces
|
||||
* @author Robert Field
|
||||
* @compile T7020657pos.java
|
||||
*
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class T7020657pos {
|
||||
interface A {
|
||||
int get(List<String> l);
|
||||
}
|
||||
|
||||
interface B {
|
||||
int get(List<Integer> l);
|
||||
}
|
||||
|
||||
interface C extends A, B {
|
||||
int get(List l);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 7022054
|
||||
*
|
||||
* @summary Invalid compiler error on covariant overriding methods with the same erasure
|
||||
* @compile/fail/ref=T7022054neg1.out -XDrawDiagnostics T7022054neg1.java
|
||||
*
|
||||
*/
|
||||
|
||||
class T7022054neg1 {
|
||||
static class A {
|
||||
A m(String s) { return null; }
|
||||
}
|
||||
static class B extends A {
|
||||
<X extends String> A m(X s) { return null; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
T7022054neg1.java:15:30: compiler.err.name.clash.same.erasure.no.override: <X>m(X), T7022054neg1.B, m(java.lang.String), T7022054neg1.A, <X>m(X), T7022054neg1.B
|
||||
1 error
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 7022054
|
||||
*
|
||||
* @summary Invalid compiler error on covariant overriding methods with the same erasure
|
||||
* @compile/fail/ref=T7022054neg2.out -XDrawDiagnostics T7022054neg2.java
|
||||
*
|
||||
*/
|
||||
|
||||
class T7022054neg2 {
|
||||
static class A {
|
||||
static A m(String s) { return null; }
|
||||
}
|
||||
static class B extends A {
|
||||
static <X extends String> A m(X s) { return null; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
T7022054neg2.java:15:37: compiler.err.name.clash.same.erasure.no.hide: <X>m(X), T7022054neg2.B, m(java.lang.String), T7022054neg2.A
|
||||
1 error
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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 7022054
|
||||
*
|
||||
* @summary Invalid compiler error on covariant overriding methods with the same erasure
|
||||
* @compile T7022054pos1.java
|
||||
*
|
||||
*/
|
||||
|
||||
class T7022054pos1 {
|
||||
static class A {
|
||||
A m(String s) { return null; }
|
||||
}
|
||||
static class B extends A {
|
||||
<X extends B> X m(String s) { return null; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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 7022054
|
||||
*
|
||||
* @summary Invalid compiler error on covariant overriding methods with the same erasure
|
||||
* @compile T7022054pos2.java
|
||||
*
|
||||
*/
|
||||
|
||||
class T7022054pos2 {
|
||||
static class A {
|
||||
static A m(String s) { return null; }
|
||||
}
|
||||
static class B extends A {
|
||||
static <X extends B> X m(String s) { return null; }
|
||||
}
|
||||
}
|
|
@ -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 6996914
|
||||
* @bug 6996914 7020044
|
||||
* @summary Diamond inference: problem when accessing protected constructor
|
||||
* @run main T6996914a
|
||||
*/
|
||||
|
@ -53,17 +53,6 @@ public class T6996914a {
|
|||
}
|
||||
}
|
||||
|
||||
enum DiamondKind {
|
||||
STANDARD("new Foo<>();"),
|
||||
ANON("new Foo<>() {};");
|
||||
|
||||
String expr;
|
||||
|
||||
DiamondKind(String expr) {
|
||||
this.expr = expr;
|
||||
}
|
||||
}
|
||||
|
||||
enum ConstructorKind {
|
||||
PACKAGE(""),
|
||||
PROTECTED("protected"),
|
||||
|
@ -104,14 +93,14 @@ public class T6996914a {
|
|||
final static String sourceStub =
|
||||
"#I\n" +
|
||||
"class Test {\n" +
|
||||
" Foo<String> fs = #D\n" +
|
||||
" Foo<String> fs = new Foo<>();\n" +
|
||||
"}\n";
|
||||
|
||||
String source;
|
||||
|
||||
public ClientClass(PackageKind pk, DiamondKind dk) {
|
||||
public ClientClass(PackageKind pk) {
|
||||
super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
|
||||
source = sourceStub.replace("#I", pk.importDecl).replace("#D", dk.expr);
|
||||
source = sourceStub.replace("#I", pk.importDecl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,22 +112,20 @@ public class T6996914a {
|
|||
public static void main(String... args) throws Exception {
|
||||
for (PackageKind pk : PackageKind.values()) {
|
||||
for (ConstructorKind ck : ConstructorKind.values()) {
|
||||
for (DiamondKind dk : DiamondKind.values()) {
|
||||
compileAndCheck(pk, ck, dk);
|
||||
}
|
||||
compileAndCheck(pk, ck);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void compileAndCheck(PackageKind pk, ConstructorKind ck, DiamondKind dk) throws Exception {
|
||||
static void compileAndCheck(PackageKind pk, ConstructorKind ck) throws Exception {
|
||||
FooClass foo = new FooClass(pk, ck);
|
||||
ClientClass client = new ClientClass(pk, dk);
|
||||
ClientClass client = new ClientClass(pk);
|
||||
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||
ErrorListener el = new ErrorListener();
|
||||
JavacTask ct = (JavacTask)tool.getTask(null, null, el,
|
||||
null, null, Arrays.asList(foo, client));
|
||||
ct.analyze();
|
||||
if (el.errors > 0 == check(pk, ck, dk)) {
|
||||
if (el.errors > 0 == check(pk, ck)) {
|
||||
String msg = el.errors > 0 ?
|
||||
"Error compiling files" :
|
||||
"No error when compiling files";
|
||||
|
@ -146,10 +133,9 @@ public class T6996914a {
|
|||
}
|
||||
}
|
||||
|
||||
static boolean check(PackageKind pk, ConstructorKind ck, DiamondKind dk) {
|
||||
static boolean check(PackageKind pk, ConstructorKind ck) {
|
||||
switch (pk) {
|
||||
case A: return ck == ConstructorKind.PUBLIC ||
|
||||
(ck == ConstructorKind.PROTECTED && dk == DiamondKind.ANON);
|
||||
case A: return ck == ConstructorKind.PUBLIC;
|
||||
case DEFAULT: return ck != ConstructorKind.PRIVATE;
|
||||
default: throw new AssertionError("Unknown package kind");
|
||||
}
|
||||
|
|
|
@ -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 6996914
|
||||
* @bug 6996914 7020044
|
||||
* @summary Diamond inference: problem when accessing protected constructor
|
||||
* @compile T6996914b.java
|
||||
*/
|
||||
|
@ -35,5 +35,4 @@ class Super<X,Y> {
|
|||
|
||||
class Test {
|
||||
Super<String,Integer> ssi1 = new Super<>(1, "", 2);
|
||||
Super<String,Integer> ssi2 = new Super<>(1, "", 2) {};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 6939780
|
||||
* @bug 6939780 7020044
|
||||
*
|
||||
* @summary add a warning to detect diamond sites
|
||||
* @author mcimadamore
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
T6939780.java:19:28: compiler.warn.diamond.redundant.args: Foo<java.lang.Number>, Foo<java.lang.Number>
|
||||
T6939780.java:20:28: compiler.warn.diamond.redundant.args.1: Foo<java.lang.Integer>, Foo<java.lang.Number>
|
||||
T6939780.java:22:28: compiler.warn.diamond.redundant.args: Foo<java.lang.Number>, Foo<java.lang.Number>
|
||||
T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: Foo<java.lang.Integer>, Foo<java.lang.Number>
|
||||
4 warnings
|
||||
2 warnings
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 6939620
|
||||
* @bug 6939620 7020044
|
||||
*
|
||||
* @summary Switch to 'complex' diamond inference scheme
|
||||
* @summary Check that diamond fails when inference violates declared bounds
|
||||
* (basic test with nested class, generic/non-generic constructors)
|
||||
* @author mcimadamore
|
||||
* @compile/fail/ref=Neg01.out Neg01.java -XDrawDiagnostics
|
||||
*
|
||||
|
@ -20,19 +21,9 @@ class Neg01<X extends Number> {
|
|||
Neg01<?> n3 = new Neg01<>("");
|
||||
Neg01<? super String> n4 = new Neg01<>("");
|
||||
|
||||
Neg01<String> n5 = new Neg01<>(""){};
|
||||
Neg01<? extends String> n6 = new Neg01<>(""){};
|
||||
Neg01<?> n7 = new Neg01<>(""){};
|
||||
Neg01<? super String> n8 = new Neg01<>(""){};
|
||||
|
||||
Neg01<String> n9 = new Neg01<>("", "");
|
||||
Neg01<? extends String> n10 = new Neg01<>("", "");
|
||||
Neg01<?> n11 = new Neg01<>("", "");
|
||||
Foo<? super String> n12 = new Neg01<>("", "");
|
||||
|
||||
Neg01<String> n13 = new Neg01<>("", ""){};
|
||||
Neg01<? extends String> n14 = new Neg01<>("", ""){};
|
||||
Neg01<?> n15 = new Neg01<>("", ""){};
|
||||
Neg01<? super String> n16 = new Neg01<>("", ""){};
|
||||
Neg01<String> n5 = new Neg01<>("", "");
|
||||
Neg01<? extends String> n6 = new Neg01<>("", "");
|
||||
Neg01<?> n7 = new Neg01<>("", "");
|
||||
Foo<? super String> n8 = new Neg01<>("", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,15 @@
|
|||
Neg01.java:18:15: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg01.java:18:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:19:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg01.java:19:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:20:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:21:15: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg01.java:21:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:23:15: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg01.java:23:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:24:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg01.java:24:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:25:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:26:15: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg01.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:28:15: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg01.java:28:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
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<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
|
||||
Neg01.java:34:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg01.java:34:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:35:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:36:15: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg01.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
28 errors
|
||||
Neg01.java:19:15: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg01.java:19:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:20:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg01.java:20:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:21:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:22:15: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg01.java:22:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:24:15: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg01.java:24:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:25:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg01.java:25:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:26:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
Neg01.java:27:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01<X>, null)
|
||||
Neg01.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
|
||||
14 errors
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 6939620
|
||||
* @bug 6939620 7020044
|
||||
*
|
||||
* @summary Switch to 'complex' diamond inference scheme
|
||||
* @summary Check that diamond fails when inference violates declared bounds
|
||||
* (test with nested class, qualified/simple type expressions)
|
||||
* @author mcimadamore
|
||||
* @compile/fail/ref=Neg02.out Neg02.java -XDrawDiagnostics
|
||||
*
|
||||
|
@ -21,20 +22,10 @@ class Neg02 {
|
|||
Foo<?> f3 = new Foo<>("");
|
||||
Foo<? super String> f4 = new Foo<>("");
|
||||
|
||||
Foo<String> f5 = new Foo<>(""){};
|
||||
Foo<? extends String> f6 = new Foo<>(""){};
|
||||
Foo<?> f7 = new Foo<>(""){};
|
||||
Foo<? super String> f8 = new Foo<>(""){};
|
||||
|
||||
Foo<String> f9 = new Foo<>("", "");
|
||||
Foo<? extends String> f10 = new Foo<>("", "");
|
||||
Foo<?> f11 = new Foo<>("", "");
|
||||
Foo<? super String> f12 = new Foo<>("", "");
|
||||
|
||||
Foo<String> f13 = new Foo<>("", ""){};
|
||||
Foo<? extends String> f14 = new Foo<>("", ""){};
|
||||
Foo<?> f15 = new Foo<>("", ""){};
|
||||
Foo<? super String> f16 = new Foo<>("", ""){};
|
||||
Foo<String> f5 = new Foo<>("", "");
|
||||
Foo<? extends String> f6 = new Foo<>("", "");
|
||||
Foo<?> f7 = new Foo<>("", "");
|
||||
Foo<? super String> f8 = new Foo<>("", "");
|
||||
}
|
||||
|
||||
void testQualified() {
|
||||
|
@ -43,19 +34,9 @@ class Neg02 {
|
|||
Foo<?> f3 = new Neg02.Foo<>("");
|
||||
Foo<? super String> f4 = new Neg02.Foo<>("");
|
||||
|
||||
Foo<String> f5 = new Neg02.Foo<>(""){};
|
||||
Foo<? extends String> f6 = new Neg02.Foo<>(""){};
|
||||
Foo<?> f7 = new Neg02.Foo<>(""){};
|
||||
Foo<? super String> f8 = new Neg02.Foo<>(""){};
|
||||
|
||||
Foo<String> f9 = new Neg02.Foo<>("", "");
|
||||
Foo<? extends String> f10 = new Neg02.Foo<>("", "");
|
||||
Foo<?> f11 = new Neg02.Foo<>("", "");
|
||||
Foo<? super String> f12 = new Neg02.Foo<>("", "");
|
||||
|
||||
Foo<String> f13 = new Neg02.Foo<>("", ""){};
|
||||
Foo<? extends String> f14 = new Neg02.Foo<>("", ""){};
|
||||
Foo<?> f15 = new Neg02.Foo<>("", ""){};
|
||||
Foo<? super String> f16 = new Neg02.Foo<>("", ""){};
|
||||
Foo<String> f5 = new Neg02.Foo<>("", "");
|
||||
Foo<? extends String> f6 = new Neg02.Foo<>("", "");
|
||||
Foo<?> f7 = new Neg02.Foo<>("", "");
|
||||
Foo<? super String> f8 = new Neg02.Foo<>("", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,57 +1,29 @@
|
|||
Neg02.java:19:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:24:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:29:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:34:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:41:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:41:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:42:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:42:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:43:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:44:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:44:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:46:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:46:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:47:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:48:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:49:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:49:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:51:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:51:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:52:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:52:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:53:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:54:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:54:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:56:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:56:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:57:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:57:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:58:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:59:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:59:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
56 errors
|
||||
Neg02.java:20:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:20:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:21:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:21:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:22:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:23:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:23:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:25:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:25:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:26:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:32:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:37:13: compiler.err.not.within.bounds: java.lang.String, X
|
||||
Neg02.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
|
||||
Neg02.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
Neg02.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, X
|
||||
Neg02.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
|
||||
28 errors
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 6939620
|
||||
* @bug 6939620 7020044
|
||||
*
|
||||
* @summary Switch to 'complex' diamond inference scheme
|
||||
* @summary Check that diamond fails when inference violates declared bounds
|
||||
* (test with inner class, qualified/simple type expressions)
|
||||
* @author mcimadamore
|
||||
* @compile/fail/ref=Neg03.out Neg03.java -XDrawDiagnostics
|
||||
*
|
||||
|
@ -21,20 +22,10 @@ class Neg03<U> {
|
|||
Foo<?> f3 = new Foo<>("");
|
||||
Foo<? super String> f4 = new Foo<>("");
|
||||
|
||||
Foo<String> f5 = new Foo<>(""){};
|
||||
Foo<? extends String> f6 = new Foo<>(""){};
|
||||
Foo<?> f7 = new Foo<>(""){};
|
||||
Foo<? super String> f8 = new Foo<>(""){};
|
||||
|
||||
Foo<String> f9 = new Foo<>("", "");
|
||||
Foo<? extends String> f10 = new Foo<>("", "");
|
||||
Foo<?> f11 = new Foo<>("", "");
|
||||
Foo<? super String> f12 = new Foo<>("", "");
|
||||
|
||||
Foo<String> f13 = new Foo<>("", ""){};
|
||||
Foo<? extends String> f14 = new Foo<>("", ""){};
|
||||
Foo<?> f15 = new Foo<>("", ""){};
|
||||
Foo<? super String> f16 = new Foo<>("", ""){};
|
||||
Foo<String> f5 = new Foo<>("", "");
|
||||
Foo<? extends String> f6 = new Foo<>("", "");
|
||||
Foo<?> f7 = new Foo<>("", "");
|
||||
Foo<? super String> f8 = new Foo<>("", "");
|
||||
}
|
||||
|
||||
void testQualified_1() {
|
||||
|
@ -43,20 +34,10 @@ class Neg03<U> {
|
|||
Foo<?> f3 = new Neg03<U>.Foo<>("");
|
||||
Foo<? super String> f4 = new Neg03<U>.Foo<>("");
|
||||
|
||||
Foo<String> f5 = new Neg03<U>.Foo<>(""){};
|
||||
Foo<? extends String> f6 = new Neg03<U>.Foo<>(""){};
|
||||
Foo<?> f7 = new Neg03<U>.Foo<>(""){};
|
||||
Foo<? super String> f8 = new Neg03<U>.Foo<>(""){};
|
||||
|
||||
Foo<String> f9 = new Neg03<U>.Foo<>("", "");
|
||||
Foo<? extends String> f10 = new Neg03<U>.Foo<>("", "");
|
||||
Foo<?> f11 = new Neg03<U>.Foo<>("", "");
|
||||
Foo<? super String> f12 = new Neg03<U>.Foo<>("", "");
|
||||
|
||||
Foo<String> f13 = new Neg03<U>.Foo<>("", ""){};
|
||||
Foo<? extends String> f14 = new Neg03<U>.Foo<>("", ""){};
|
||||
Foo<?> f15 = new Neg03<U>.Foo<>("", ""){};
|
||||
Foo<? super String> f16 = new Neg03<U>.Foo<>("", ""){};
|
||||
Foo<String> f5 = new Neg03<U>.Foo<>("", "");
|
||||
Foo<? extends String> f6 = new Neg03<U>.Foo<>("", "");
|
||||
Foo<?> f7 = new Neg03<U>.Foo<>("", "");
|
||||
Foo<? super String> f8 = new Neg03<U>.Foo<>("", "");
|
||||
}
|
||||
|
||||
void testQualified_2(Neg03<U> n) {
|
||||
|
@ -65,19 +46,9 @@ class Neg03<U> {
|
|||
Foo<?> f3 = n.new Foo<>("");
|
||||
Foo<? super String> f4 = n.new Foo<>("");
|
||||
|
||||
Foo<String> f5 = n.new Foo<>(""){};
|
||||
Foo<? extends String> f6 = n.new Foo<>(""){};
|
||||
Foo<?> f7 = n.new Foo<>(""){};
|
||||
Foo<? super String> f8 = n.new Foo<>(""){};
|
||||
|
||||
Foo<String> f9 = n.new Foo<>("", "");
|
||||
Foo<? extends String> f10 = n.new Foo<>("", "");
|
||||
Foo<?> f11 = n.new Foo<>("", "");
|
||||
Foo<? super String> f12 = n.new Foo<>("", "");
|
||||
|
||||
Foo<String> f13 = n.new Foo<>("", ""){};
|
||||
Foo<? extends String> f14 = n.new Foo<>("", ""){};
|
||||
Foo<?> f15 = n.new Foo<>("", ""){};
|
||||
Foo<? super String> f16 = n.new Foo<>("", ""){};
|
||||
Foo<String> f5 = n.new Foo<>("", "");
|
||||
Foo<? extends String> f6 = n.new Foo<>("", "");
|
||||
Foo<?> f7 = n.new Foo<>("", "");
|
||||
Foo<? super String> f8 = n.new Foo<>("", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,85 +1,43 @@
|
|||
Neg03.java:19:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:24:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:29:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:34:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:41:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:41:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:42:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:42:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:43:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:44:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:44:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:46:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:46:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:47:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:20:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:20:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:21:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:21:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:22:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:23:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:23:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:25:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:25:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:26:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:32:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:37:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:44:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:44:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:45:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:45:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:46:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:47:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:48:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:49:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:49:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:51:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:51:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:52:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:52:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:53:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:54:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:54:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:56:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:56:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:57:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:57:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:58:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:59:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:59:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:63:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:63:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:64:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:64:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:65:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:66:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:66:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:68:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:68:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:69:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:69:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:70:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:71:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:71:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:73:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:73:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:74:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:74:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:75:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:76:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:76:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:78:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:78:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:79:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:79:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:80:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:81:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:81:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
84 errors
|
||||
Neg03.java:49:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg03.java:49:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:50:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg03.java:50:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:51:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
Neg03.java:52:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg03.java:52:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
|
||||
42 errors
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 6939620
|
||||
* @bug 6939620 7020044
|
||||
*
|
||||
* @summary Switch to 'complex' diamond inference scheme
|
||||
* @summary Check that diamond fails when inference violates declared bounds
|
||||
* (test with local class, qualified/simple type expressions)
|
||||
* @author mcimadamore
|
||||
* @compile/fail/ref=Neg04.out Neg04.java -XDrawDiagnostics
|
||||
*
|
||||
|
@ -20,19 +21,9 @@ class Neg04 {
|
|||
Foo<?> n3 = new Foo<>("");
|
||||
Foo<? super String> n4 = new Foo<>("");
|
||||
|
||||
Foo<String> n5 = new Foo<>(""){};
|
||||
Foo<? extends String> n6 = new Foo<>(""){};
|
||||
Foo<?> n7 = new Foo<>(""){};
|
||||
Foo<? super String> n8 = new Foo<>(""){};
|
||||
|
||||
Foo<String> n9 = new Foo<>("", "");
|
||||
Foo<? extends String> n10 = new Foo<>("", "");
|
||||
Foo<?> n11 = new Foo<>("", "");
|
||||
Foo<? super String> n12 = new Foo<>("", "");
|
||||
|
||||
Foo<String> n13 = new Foo<>("", ""){};
|
||||
Foo<? extends String> n14 = new Foo<>("", ""){};
|
||||
Foo<?> n15 = new Foo<>("", ""){};
|
||||
Foo<? super String> n16 = new Foo<>("", ""){};
|
||||
Foo<String> n5 = new Foo<>("", "");
|
||||
Foo<? extends String> n6 = new Foo<>("", "");
|
||||
Foo<?> n7 = new Foo<>("", "");
|
||||
Foo<? super String> n8 = new Foo<>("", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,15 @@
|
|||
Neg04.java:18:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg04.java:18:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:19:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg04.java:19:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:20:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:21:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg04.java:21:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:23:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg04.java:23:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:24:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg04.java:24:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:25:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:26:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg04.java:26:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:28:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg04.java:28:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:29:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg04.java:29:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:30:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:31:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg04.java:31:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:33:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg04.java:33:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:34:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg04.java:34:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:35:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:36:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg04.java:36:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
28 errors
|
||||
Neg04.java:19:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg04.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg04.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg04.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:24:13: compiler.err.not.within.bounds: java.lang.String, V
|
||||
Neg04.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
|
||||
Neg04.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
Neg04.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, V
|
||||
Neg04.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
|
||||
14 errors
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 6939620
|
||||
* @bug 6939620 7020044
|
||||
*
|
||||
* @summary Switch to 'complex' diamond inference scheme
|
||||
* @summary Check that usage of rare types doesn't cause spurious diamond diagnostics
|
||||
* @author mcimadamore
|
||||
* @compile/fail/ref=Neg05.out Neg05.java -XDrawDiagnostics
|
||||
*
|
||||
|
@ -21,20 +21,10 @@ class Neg05<U> {
|
|||
Neg05<?>.Foo<?> f3 = new Neg05.Foo<>("");
|
||||
Neg05<?>.Foo<? super String> f4 = new Neg05.Foo<>("");
|
||||
|
||||
Neg05<?>.Foo<String> f5 = new Neg05.Foo<>(""){};
|
||||
Neg05<?>.Foo<? extends String> f6 = new Neg05.Foo<>(""){};
|
||||
Neg05<?>.Foo<?> f7 = new Neg05.Foo<>(""){};
|
||||
Neg05<?>.Foo<? super String> f8 = new Neg05.Foo<>(""){};
|
||||
|
||||
Neg05<?>.Foo<String> f9 = new Neg05.Foo<>("", "");
|
||||
Neg05<?>.Foo<? extends String> f10 = new Neg05.Foo<>("", "");
|
||||
Neg05<?>.Foo<?> f11 = new Neg05.Foo<>("", "");
|
||||
Neg05<?>.Foo<? super String> f12 = new Neg05.Foo<>("", "");
|
||||
|
||||
Neg05<?>.Foo<String> f13 = new Neg05.Foo<>("", ""){};
|
||||
Neg05<?>.Foo<? extends String> f14 = new Neg05.Foo<>("", ""){};
|
||||
Neg05<?>.Foo<?> f15 = new Neg05.Foo<>("", ""){};
|
||||
Neg05<?>.Foo<? super String> f16 = new Neg05.Foo<>("", ""){};
|
||||
Neg05<?>.Foo<String> f5 = new Neg05.Foo<>("", "");
|
||||
Neg05<?>.Foo<? extends String> f6 = new Neg05.Foo<>("", "");
|
||||
Neg05<?>.Foo<?> f7 = new Neg05.Foo<>("", "");
|
||||
Neg05<?>.Foo<? super String> f8 = new Neg05.Foo<>("", "");
|
||||
}
|
||||
|
||||
void testRare_2(Neg05 n) {
|
||||
|
@ -43,19 +33,9 @@ class Neg05<U> {
|
|||
Neg05<?>.Foo<?> f3 = n.new Foo<>("");
|
||||
Neg05<?>.Foo<? super String> f4 = n.new Foo<>("");
|
||||
|
||||
Neg05<?>.Foo<String> f5 = n.new Foo<>(""){};
|
||||
Neg05<?>.Foo<? extends String> f6 = n.new Foo<>(""){};
|
||||
Neg05<?>.Foo<?> f7 = n.new Foo<>(""){};
|
||||
Neg05<?>.Foo<? super String> f8 = n.new Foo<>(""){};
|
||||
|
||||
Neg05<?>.Foo<String> f9 = n.new Foo<>("", "");
|
||||
Neg05<?>.Foo<? extends String> f10 = n.new Foo<>("", "");
|
||||
Neg05<?>.Foo<?> f11 = n.new Foo<>("", "");
|
||||
Neg05<?>.Foo<? super String> f12 = n.new Foo<>("", "");
|
||||
|
||||
Neg05<?>.Foo<String> f13 = n.new Foo<>("", ""){};
|
||||
Neg05<?>.Foo<? extends String> f14 = n.new Foo<>("", ""){};
|
||||
Neg05<?>.Foo<?> f15 = n.new Foo<>("", ""){};
|
||||
Neg05<?>.Foo<? super String> f16 = n.new Foo<>("", ""){};
|
||||
Neg05<?>.Foo<String> f5 = n.new Foo<>("", "");
|
||||
Neg05<?>.Foo<? extends String> f6 = n.new Foo<>("", "");
|
||||
Neg05<?>.Foo<?> f7 = n.new Foo<>("", "");
|
||||
Neg05<?>.Foo<? super String> f8 = n.new Foo<>("", "");
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue