8030244: Update langtools to use Diamond

Reviewed-by: darcy
This commit is contained in:
Brian Goetz 2013-12-18 16:05:18 -05:00
parent 6255412f38
commit 6b6b488756
216 changed files with 1006 additions and 1096 deletions

View File

@ -36,7 +36,7 @@ import javax.lang.model.element.Name;
@jdk.Exported
public interface AttributeTree extends DocTree {
@jdk.Exported
enum ValueKind { EMPTY, UNQUOTED, SINGLE, DOUBLE };
enum ValueKind { EMPTY, UNQUOTED, SINGLE, DOUBLE }
Name getName();
ValueKind getValueKind();

View File

@ -236,7 +236,7 @@ public interface DocTree {
Kind(String tagName) {
this.tagName = tagName;
}
};
}
/**
* Gets the kind of this tree.

View File

@ -49,7 +49,7 @@ public interface LambdaExpressionTree extends ExpressionTree {
/** enum constant for expression lambdas */
EXPRESSION,
/** enum constant for statement lambdas */
STATEMENT;
STATEMENT
}
List<? extends VariableTree> getParameters();

View File

@ -69,7 +69,7 @@ public final class TaskEvent
* For events relating to an individual annotation processing round.
**/
ANNOTATION_PROCESSING_ROUND
};
}
public TaskEvent(Kind kind) {
this(kind, null, null, null);

View File

@ -82,8 +82,8 @@ public abstract class Trees {
ClassLoader cl = arg.getClass().getClassLoader();
Class<?> c = Class.forName("com.sun.tools.javac.api.JavacTrees", false, cl);
argType = Class.forName(argType.getName(), false, cl);
Method m = c.getMethod("instance", new Class<?>[] { argType });
return (Trees) m.invoke(null, new Object[] { arg });
Method m = c.getMethod("instance", argType);
return (Trees) m.invoke(null, arg);
} catch (Throwable e) {
throw new AssertionError(e);
}

View File

@ -58,7 +58,7 @@ public class AccessFlags {
public static final int ACC_ENUM = 0x4000; // class, inner, field
public static final int ACC_MANDATED = 0x8000; // class, inner, field, method
public static enum Kind { Class, InnerClass, Field, Method};
public static enum Kind { Class, InnerClass, Field, Method}
AccessFlags(ClassReader cr) throws IOException {
this(cr.readUnsignedShort());
@ -159,7 +159,7 @@ public class AccessFlags {
}
private static Set<String> getModifiers(int flags, int[] modifierFlags, Kind t) {
Set<String> s = new LinkedHashSet<String>();
Set<String> s = new LinkedHashSet<>();
for (int m: modifierFlags) {
if ((flags & m) != 0)
s.add(flagToModifier(m, t));
@ -168,7 +168,7 @@ public class AccessFlags {
}
private Set<String> getFlags(int[] expectedFlags, Kind t) {
Set<String> s = new LinkedHashSet<String>();
Set<String> s = new LinkedHashSet<>();
int f = flags;
for (int e: expectedFlags) {
if ((f & e) != 0) {

View File

@ -90,7 +90,7 @@ public abstract class Attribute {
try {
Class<?>[] constrArgTypes = {ClassReader.class, int.class, int.class};
Constructor<? extends Attribute> constr = attrClass.getDeclaredConstructor(constrArgTypes);
return constr.newInstance(new Object[] { cr, name_index, data.length });
return constr.newInstance(cr, name_index, data.length);
} catch (Throwable t) {
reasonForDefaultAttr = t.toString();
// fall through and use DefaultAttribute
@ -107,7 +107,7 @@ public abstract class Attribute {
}
protected void init() {
standardAttributes = new HashMap<String,Class<? extends Attribute>>();
standardAttributes = new HashMap<>();
standardAttributes.put(AnnotationDefault, AnnotationDefault_attribute.class);
standardAttributes.put(BootstrapMethods, BootstrapMethods_attribute.class);
standardAttributes.put(CharacterRangeTable, CharacterRangeTable_attribute.class);

View File

@ -38,8 +38,12 @@ import java.util.Map;
* deletion without notice.</b>
*/
public class Attributes implements Iterable<Attribute> {
public final Attribute[] attrs;
public final Map<String, Attribute> map;
Attributes(ClassReader cr) throws IOException {
map = new HashMap<String,Attribute>();
map = new HashMap<>();
int attrs_count = cr.readUnsignedShort();
attrs = new Attribute[attrs_count];
for (int i = 0; i < attrs_count; i++) {
@ -55,7 +59,7 @@ public class Attributes implements Iterable<Attribute> {
public Attributes(ConstantPool constant_pool, Attribute[] attrs) {
this.attrs = attrs;
map = new HashMap<String,Attribute>();
map = new HashMap<>();
for (Attribute attr : attrs) {
try {
map.put(attr.getName(constant_pool), attr);
@ -100,7 +104,4 @@ public class Attributes implements Iterable<Attribute> {
length += a.byteLength();
return length;
}
public final Attribute[] attrs;
public final Map<String, Attribute> map;
}

View File

@ -86,5 +86,5 @@ public class CharacterRangeTable_attribute extends Attribute {
public final int character_range_start;
public final int character_range_end;
public final int flags;
};
}
}

View File

@ -245,7 +245,7 @@ public class Dependencies {
ClassFileReader classFinder, Set<String> rootClassNames,
boolean transitiveClosure)
throws ClassFileNotFoundException {
final Set<Dependency> results = new HashSet<Dependency>();
final Set<Dependency> results = new HashSet<>();
Recorder r = new Recorder() {
public void addDependency(Dependency d) {
results.add(d);
@ -276,7 +276,7 @@ public class Dependencies {
ClassFileReader classFinder, Set<String> rootClassNames,
boolean transitiveClosure, Recorder recorder)
throws ClassFileNotFoundException {
Set<String> doneClasses = new HashSet<String>();
Set<String> doneClasses = new HashSet<>();
getFinder(); // ensure initialized
getFilter(); // ensure initialized
@ -284,7 +284,7 @@ public class Dependencies {
// Work queue of names of classfiles to be searched.
// Entries will be unique, and for classes that do not yet have
// dependencies in the results map.
Deque<String> deque = new LinkedList<String>(rootClassNames);
Deque<String> deque = new LinkedList<>(rootClassNames);
String className;
while ((className = deque.poll()) != null) {
@ -560,7 +560,7 @@ public class Dependencies {
}
static abstract class BasicDependencyFinder implements Finder {
private Map<String,Location> locations = new HashMap<String,Location>();
private Map<String,Location> locations = new HashMap<>();
Location getLocation(String className) {
Location l = locations.get(className);
@ -578,7 +578,7 @@ public class Dependencies {
try {
constant_pool = classFile.constant_pool;
origin = getLocation(classFile.getName());
deps = new HashSet<Dependency>();
deps = new HashSet<>();
} catch (ConstantPoolException e) {
throw new ClassFileError(e);
}

View File

@ -93,7 +93,7 @@ public class Instruction {
/** The length, in bytes, of this kind of instruction, or -1 is the
* length depends on the specific instruction. */
public final int length;
};
}
/** A utility visitor to help decode the operands of an instruction.
* @see Instruction#accept */

View File

@ -468,5 +468,5 @@ public enum Opcode {
/** Standard opcodes. */
STANDARD,
/** Legacy support for PicoJava opcodes. */
PICOJAVA };
PICOJAVA }
}

View File

@ -94,7 +94,7 @@ public final class ReferenceFinder {
* @throws ConstantPoolException if an error of the constant pool
*/
public boolean parse(ClassFile cf) throws ConstantPoolException {
List<Integer> cprefs = new ArrayList<Integer>();
List<Integer> cprefs = new ArrayList<>();
int index = 1;
for (ConstantPool.CPInfo cpInfo : cf.constant_pool.entries()) {
if (cpInfo.accept(cpVisitor, cf.constant_pool)) {
@ -108,7 +108,7 @@ public final class ReferenceFinder {
}
for (Method m : cf.methods) {
Set<Integer> ids = new HashSet<Integer>();
Set<Integer> ids = new HashSet<>();
Code_attribute c_attr = (Code_attribute) m.attributes.get(Attribute.Code);
if (c_attr != null) {
for (Instruction instr : c_attr.getInstructions()) {
@ -119,7 +119,7 @@ public final class ReferenceFinder {
}
}
if (ids.size() > 0) {
List<CPRefInfo> refInfos = new ArrayList<CPRefInfo>(ids.size());
List<CPRefInfo> refInfos = new ArrayList<>(ids.size());
for (int id : ids) {
refInfos.add(CPRefInfo.class.cast(cf.constant_pool.get(id)));
}

View File

@ -96,7 +96,7 @@ public class Signature extends Descriptor {
while (sigp < sig.length() && sig.charAt(sigp) == '^') {
sigp++;
if (throwsTypes == null)
throwsTypes = new ArrayList<Type>();
throwsTypes = new ArrayList<>();
throwsTypes.add(parseTypeSignature());
}
return new MethodType(typeParamTypes, paramTypes, returnType, throwsTypes);
@ -108,7 +108,7 @@ public class Signature extends Descriptor {
List<Type> superinterfaces = null;
while (sigp < sig.length()) {
if (superinterfaces == null)
superinterfaces = new ArrayList<Type>();
superinterfaces = new ArrayList<>();
superinterfaces.add(parseTypeSignature());
}
return new ClassSigType(typeParamTypes, superclass, superinterfaces);
@ -183,7 +183,7 @@ public class Signature extends Descriptor {
private List<Type> parseTypeSignatures(char term) {
sigp++;
List<Type> types = new ArrayList<Type>();
List<Type> types = new ArrayList<>();
while (sig.charAt(sigp) != term)
types.add(parseTypeSignature());
sigp++;
@ -229,7 +229,7 @@ public class Signature extends Descriptor {
private List<TypeParamType> parseTypeParamTypes() {
assert sig.charAt(sigp) == '<';
sigp++;
List<TypeParamType> types = new ArrayList<TypeParamType>();
List<TypeParamType> types = new ArrayList<>();
while (sig.charAt(sigp) != '>')
types.add(parseTypeParamType());
sigp++;
@ -247,7 +247,7 @@ public class Signature extends Descriptor {
while (sig.charAt(sigp) == ':') {
sigp++;
if (interfaceBounds == null)
interfaceBounds = new ArrayList<Type>();
interfaceBounds = new ArrayList<>();
interfaceBounds.add(parseTypeSignature());
}
return new TypeParamType(name, classBound, interfaceBounds);

View File

@ -103,7 +103,7 @@ public abstract class Type {
return primitiveTypes.contains(name);
}
// where
private static final Set<String> primitiveTypes = new HashSet<String>(Arrays.asList(
private static final Set<String> primitiveTypes = new HashSet<>(Arrays.asList(
"boolean", "byte", "char", "double", "float", "int", "long", "short", "void"));
@Override
@ -344,7 +344,8 @@ public abstract class Type {
* {@code -}
*/
public static class WildcardType extends Type {
public enum Kind { UNBOUNDED, EXTENDS, SUPER };
public enum Kind { UNBOUNDED, EXTENDS, SUPER }
public WildcardType() {
this(Kind.UNBOUNDED, null);
}

View File

@ -165,7 +165,7 @@ public class TypeAnnotation {
{ // Write type path
int len = cr.readUnsignedByte();
List<Integer> loc = new ArrayList<Integer>(len);
List<Integer> loc = new ArrayList<>(len);
for (int i = 0; i < len * TypePathEntry.bytesPerEntry; ++i)
loc.add(cr.readUnsignedByte());
position.location = Position.getTypePathFromBinary(loc);
@ -342,7 +342,7 @@ public class TypeAnnotation {
// For generic/array types.
// TODO: or should we use null? Noone will use this object.
public List<TypePathEntry> location = new ArrayList<TypePathEntry>(0);
public List<TypePathEntry> location = new ArrayList<>(0);
// Tree position.
public int pos = -1;
@ -498,7 +498,7 @@ public class TypeAnnotation {
* @param list The bytecode representation of the type path.
*/
public static List<TypePathEntry> getTypePathFromBinary(List<Integer> list) {
List<TypePathEntry> loc = new ArrayList<TypePathEntry>(list.size() / TypePathEntry.bytesPerEntry);
List<TypePathEntry> loc = new ArrayList<>(list.size() / TypePathEntry.bytesPerEntry);
int idx = 0;
while (idx < list.size()) {
if (idx + 1 == list.size()) {
@ -511,7 +511,7 @@ public class TypeAnnotation {
}
public static List<Integer> getBinaryFromTypePath(List<TypePathEntry> locs) {
List<Integer> loc = new ArrayList<Integer>(locs.size() * TypePathEntry.bytesPerEntry);
List<Integer> loc = new ArrayList<>(locs.size() * TypePathEntry.bytesPerEntry);
for (TypePathEntry tpe : locs) {
loc.add(tpe.tag.tag);
loc.add(tpe.arg);

View File

@ -52,7 +52,7 @@ public abstract class AbstractMemberWriter {
protected final ConfigurationImpl configuration;
protected final SubWriterHolderWriter writer;
protected final ClassDoc classdoc;
protected Map<String,Integer> typeMap = new LinkedHashMap<String,Integer>();
protected Map<String,Integer> typeMap = new LinkedHashMap<>();
protected Set<MethodTypes> methodTypes = EnumSet.noneOf(MethodTypes.class);
private int methodTypesOr = 0;
public final boolean nodepr;

View File

@ -103,9 +103,9 @@ public class ClassUseWriter extends SubWriterHolderWriter {
super(configuration, filename);
this.classdoc = classdoc;
if (mapper.classToPackageAnnotations.containsKey(classdoc.qualifiedName()))
pkgToPackageAnnotations = new TreeSet<PackageDoc>(mapper.classToPackageAnnotations.get(classdoc.qualifiedName()));
pkgToPackageAnnotations = new TreeSet<>(mapper.classToPackageAnnotations.get(classdoc.qualifiedName()));
configuration.currentcd = classdoc;
this.pkgSet = new TreeSet<PackageDoc>();
this.pkgSet = new TreeSet<>();
this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam);
this.pkgToClassAnnotations = pkgDivide(mapper.classToClassAnnotations);
this.pkgToMethodTypeParameter = pkgDivide(mapper.classToExecMemberDocTypeParam);
@ -177,7 +177,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
}
private Map<String,List<ProgramElementDoc>> pkgDivide(Map<String,? extends List<? extends ProgramElementDoc>> classMap) {
Map<String,List<ProgramElementDoc>> map = new HashMap<String,List<ProgramElementDoc>>();
Map<String,List<ProgramElementDoc>> map = new HashMap<>();
List<? extends ProgramElementDoc> list= classMap.get(classdoc.qualifiedName());
if (list != null) {
Collections.sort(list);
@ -186,7 +186,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
pkgSet.add(pkg);
List<ProgramElementDoc> inPkg = map.get(pkg.name());
if (inPkg == null) {
inPkg = new ArrayList<ProgramElementDoc>();
inPkg = new ArrayList<>();
map.put(pkg.name(), inPkg);
}
inPkg.add(doc);

View File

@ -178,7 +178,7 @@ public class ConfigurationImpl extends Configuration {
/**
* Collected set of doclint options
*/
public Set<String> doclintOpts = new LinkedHashSet<String>();
public Set<String> doclintOpts = new LinkedHashSet<>();
/**
* Unique Resource Handler for this package.
@ -286,7 +286,7 @@ public class ConfigurationImpl extends Configuration {
}
}
if (root.specifiedClasses().length > 0) {
Map<String,PackageDoc> map = new HashMap<String,PackageDoc>();
Map<String,PackageDoc> map = new HashMap<>();
PackageDoc pd;
ClassDoc[] classes = root.classes();
for (ClassDoc aClass : classes) {

View File

@ -61,7 +61,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
super(writer, classDoc);
VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc,
VisibleMemberMap.CONSTRUCTORS, configuration);
List<ProgramElementDoc> constructors = new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
List<ProgramElementDoc> constructors = new ArrayList<>(visibleMemberMap.getMembersFor(classDoc));
for (ProgramElementDoc constructor : constructors) {
if (constructor.isProtected() || constructor.isPrivate()) {
setFoundNonPubConstructor(true);

View File

@ -1738,7 +1738,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
return text;
}
static final Set<String> blockTags = new HashSet<String>();
static final Set<String> blockTags = new HashSet<>();
static {
for (HtmlTag t: HtmlTag.values()) {
if (t.blockType == HtmlTag.BlockType.BLOCK)
@ -1944,7 +1944,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
*/
public List<Content> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak,
boolean isJava5DeclarationLocation) {
List<Content> results = new ArrayList<Content>();
List<Content> results = new ArrayList<>();
ContentBuilder annotation;
for (AnnotationDesc aDesc : descList) {
AnnotationTypeDoc annotationDoc = aDesc.annotationType();
@ -1971,7 +1971,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
if (aDesc.isSynthesized()) {
for (AnnotationDesc.ElementValuePair pair : pairs) {
AnnotationValue annotationValue = pair.value();
List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
List<AnnotationValue> annotationTypeValues = new ArrayList<>();
if (annotationValue.value() instanceof AnnotationValue[]) {
AnnotationValue[] annotationArray =
(AnnotationValue[]) annotationValue.value();
@ -1994,7 +1994,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
if (pairs.length == 1 && isAnnotationDocumented) {
AnnotationValue[] annotationArray =
(AnnotationValue[]) (pairs[0].value()).value();
List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
List<AnnotationValue> annotationTypeValues = new ArrayList<>();
annotationTypeValues.addAll(Arrays.asList(annotationArray));
String sep = "";
for (AnnotationValue av : annotationTypeValues) {
@ -2052,7 +2052,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
pairs[j].element(), pairs[j].element().name(), false));
annotation.addContent("=");
AnnotationValue annotationValue = pairs[j].value();
List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
List<AnnotationValue> annotationTypeValues = new ArrayList<>();
if (annotationValue.value() instanceof AnnotationValue[]) {
AnnotationValue[] annotationArray =
(AnnotationValue[]) annotationValue.value();

View File

@ -76,7 +76,7 @@ public class PackageFrameWriter extends HtmlDocletWriter {
super(configuration, DocPath.forPackage(packageDoc).resolve(DocPaths.PACKAGE_FRAME));
this.packageDoc = packageDoc;
if (configuration.root.specifiedPackages().length == 0) {
documentedClasses = new HashSet<ClassDoc>(Arrays.asList(configuration.root.classes()));
documentedClasses = new HashSet<>(Arrays.asList(configuration.root.classes()));
}
}

View File

@ -47,7 +47,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
public class PackageUseWriter extends SubWriterHolderWriter {
final PackageDoc pkgdoc;
final SortedMap<String,Set<ClassDoc>> usingPackageToUsedClasses = new TreeMap<String,Set<ClassDoc>>();
final SortedMap<String,Set<ClassDoc>> usingPackageToUsedClasses = new TreeMap<>();
/**
* Constructor.
@ -73,7 +73,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
Set<ClassDoc> usedClasses = usingPackageToUsedClasses
.get(usingPackage.name());
if (usedClasses == null) {
usedClasses = new TreeSet<ClassDoc>();
usedClasses = new TreeSet<>();
usingPackageToUsedClasses.put(Util.getPackageName(usingPackage),
usedClasses);
}

View File

@ -90,6 +90,6 @@ public class ContentBuilder extends Content {
private void ensureMutableContents() {
if (contents.isEmpty())
contents = new ArrayList<Content>();
contents = new ArrayList<>();
}
}

View File

@ -54,7 +54,7 @@ public class HtmlDocument extends Content {
* @param htmlTree HTML tree of the document
*/
public HtmlDocument(Content docType, Content docComment, Content htmlTree) {
docContent = new ArrayList<Content>();
docContent = new ArrayList<>();
addContent(nullCheck(docType));
addContent(nullCheck(docComment));
addContent(nullCheck(htmlTree));
@ -67,7 +67,7 @@ public class HtmlDocument extends Content {
* @param htmlTree HTML tree of the document
*/
public HtmlDocument(Content docType, Content htmlTree) {
docContent = new ArrayList<Content>();
docContent = new ArrayList<>();
addContent(nullCheck(docType));
addContent(nullCheck(htmlTree));
}

View File

@ -98,5 +98,5 @@ public enum HtmlStyle {
typeNameLabel,
typeNameLink,
typeSummary,
useSummary;
useSummary
}

View File

@ -99,7 +99,7 @@ public enum HtmlTag {
public static enum BlockType {
BLOCK,
INLINE,
OTHER;
OTHER
}
/**
@ -107,7 +107,7 @@ public enum HtmlTag {
*/
public static enum EndTag {
END,
NOEND;
NOEND
}
HtmlTag() {

View File

@ -79,7 +79,7 @@ public class HtmlTree extends Content {
*/
public void addAttr(HtmlAttr attrName, String attrValue) {
if (attrs.isEmpty())
attrs = new LinkedHashMap<HtmlAttr,String>(3);
attrs = new LinkedHashMap<>(3);
attrs.put(nullCheck(attrName), escapeHtmlChars(attrValue));
}
@ -109,7 +109,7 @@ public class HtmlTree extends Content {
}
else if (tagContent == HtmlTree.EMPTY || tagContent.isValid()) {
if (content.isEmpty())
content = new ArrayList<Content>();
content = new ArrayList<>();
content.add(tagContent);
}
}

View File

@ -95,7 +95,7 @@ public class RawHtml extends Content {
return rawHtmlContent;
}
private enum State { TEXT, ENTITY, TAG, STRING };
private enum State { TEXT, ENTITY, TAG, STRING }
@Override
public int charCount() {

View File

@ -307,8 +307,8 @@ public abstract class Configuration {
message =
new MessageRetriever(this,
"com.sun.tools.doclets.internal.toolkit.resources.doclets");
excludedDocFileDirs = new HashSet<String>();
excludedQualifiers = new HashSet<String>();
excludedDocFileDirs = new HashSet<>();
excludedQualifiers = new HashSet<>();
setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
}
@ -392,10 +392,9 @@ public abstract class Configuration {
// Group the packages to be documented by the lowest profile (if any)
// in which each appears
Map<Profile, List<PackageDoc>> interimResults =
new EnumMap<Profile, List<PackageDoc>>(Profile.class);
Map<Profile, List<PackageDoc>> interimResults = new EnumMap<>(Profile.class);
for (Profile p: Profile.values())
interimResults.put(p, new ArrayList<PackageDoc>());
interimResults.put(p, new ArrayList<>());
for (PackageDoc pkg: packages) {
if (nodeprecated && Util.isDeprecated(pkg)) {
@ -412,7 +411,7 @@ public abstract class Configuration {
}
// Build the profilePackages structure used by the doclet
profilePackages = new HashMap<String,PackageDoc[]>();
profilePackages = new HashMap<>();
List<PackageDoc> prev = Collections.<PackageDoc>emptyList();
int size;
for (Map.Entry<Profile,List<PackageDoc>> e: interimResults.entrySet()) {
@ -434,11 +433,11 @@ public abstract class Configuration {
}
private void initPackageArray() {
Set<PackageDoc> set = new HashSet<PackageDoc>(Arrays.asList(root.specifiedPackages()));
Set<PackageDoc> set = new HashSet<>(Arrays.asList(root.specifiedPackages()));
for (ClassDoc aClass : root.specifiedClasses()) {
set.add(aClass.containingPackage());
}
ArrayList<PackageDoc> results = new ArrayList<PackageDoc>(set);
ArrayList<PackageDoc> results = new ArrayList<>(set);
Collections.sort(results);
packages = results.toArray(new PackageDoc[] {});
}
@ -449,7 +448,7 @@ public abstract class Configuration {
* @param options the two dimensional array of options.
*/
public void setOptions(String[][] options) throws Fault {
LinkedHashSet<String[]> customTagStrs = new LinkedHashSet<String[]>();
LinkedHashSet<String[]> customTagStrs = new LinkedHashSet<>();
// Some options, specifically -link and -linkoffline, require that
// the output directory has already been created: so do that first.
@ -629,7 +628,7 @@ public abstract class Configuration {
* @return an array of tokens.
*/
private String[] tokenize(String s, char separator, int maxTokens) {
List<String> tokens = new ArrayList<String>();
List<String> tokens = new ArrayList<>();
StringBuilder token = new StringBuilder ();
boolean prevIsEscapeChar = false;
for (int i = 0; i < s.length(); i += Character.charCount(i)) {

View File

@ -87,8 +87,7 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder {
this.writer = writer;
this.visibleMemberMap = new VisibleMemberMap(classDoc, memberType,
configuration);
this.members = new ArrayList<ProgramElementDoc>(
this.visibleMemberMap.getMembersFor(classDoc));
this.members = new ArrayList<>(this.visibleMemberMap.getMembersFor(classDoc));
if (configuration.getMemberComparator() != null) {
Collections.sort(this.members, configuration.getMemberComparator());
}

View File

@ -87,8 +87,7 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
this.writer = writer;
this.visibleMemberMap = new VisibleMemberMap(classDoc, memberType,
configuration);
this.members = new ArrayList<ProgramElementDoc>(
this.visibleMemberMap.getMembersFor(classDoc));
this.members = new ArrayList<>(this.visibleMemberMap.getMembersFor(classDoc));
if (configuration.getMemberComparator() != null) {
Collections.sort(this.members, configuration.getMemberComparator());
}

View File

@ -68,7 +68,7 @@ public class BuilderFactory {
this.configuration = configuration;
this.writerFactory = configuration.getWriterFactory();
Set<String> containingPackagesSeen = new HashSet<String>();
Set<String> containingPackagesSeen = new HashSet<>();
context = new AbstractBuilder.Context(configuration, containingPackagesSeen,
LayoutParser.getInstance(configuration));
}

View File

@ -97,7 +97,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
ConstantsSummaryWriter writer) {
super(context);
this.writer = writer;
this.classDocsWithConstFields = new HashSet<ClassDoc>();
this.classDocsWithConstFields = new HashSet<>();
}
/**
@ -151,7 +151,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
*/
public void buildContents(XMLNode node, Content contentTree) {
Content contentListTree = writer.getContentsHeader();
printedPackageHeaders = new HashSet<String>();
printedPackageHeaders = new HashSet<>();
for (PackageDoc pkg : configuration.packages) {
if (hasConstantField(pkg) && !hasPrintedPackageIndex(pkg.name())) {
writer.addLinkToPackageContent(pkg,
@ -169,7 +169,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
* @param contentTree the tree to which the summaries will be added
*/
public void buildConstantSummaries(XMLNode node, Content contentTree) {
printedPackageHeaders = new HashSet<String>();
printedPackageHeaders = new HashSet<>();
Content summariesTree = writer.getConstantSummaries();
for (PackageDoc aPackage : configuration.packages) {
if (hasConstantField(aPackage)) {
@ -331,7 +331,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
* will be added
*/
protected void buildMembersSummary(XMLNode node, Content classConstantTree) {
List<FieldDoc> members = new ArrayList<FieldDoc>(members());
List<FieldDoc> members = new ArrayList<>(members());
if (members.size() > 0) {
Collections.sort(members);
writer.addConstantMembers(classdoc, members, classConstantTree);
@ -352,7 +352,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
} else {
return null;
}
List<FieldDoc> inclList = new LinkedList<FieldDoc>();
List<FieldDoc> inclList = new LinkedList<>();
FieldDoc member;
while(iter.hasNext()){
member = (FieldDoc)iter.next();

View File

@ -94,8 +94,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
classDoc,
VisibleMemberMap.CONSTRUCTORS,
configuration);
constructors =
new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
constructors = new ArrayList<>(visibleMemberMap.getMembersFor(classDoc));
for (ProgramElementDoc constructor : constructors) {
if (constructor.isProtected() || constructor.isPrivate()) {
writer.setFoundNonPubConstructor(true);

View File

@ -88,8 +88,7 @@ public class EnumConstantBuilder extends AbstractMemberBuilder {
classDoc,
VisibleMemberMap.ENUM_CONSTANTS,
configuration);
enumConstants =
new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
enumConstants = new ArrayList<>(visibleMemberMap.getMembersFor(classDoc));
if (configuration.getMemberComparator() != null) {
Collections.sort(enumConstants, configuration.getMemberComparator());
}

View File

@ -89,9 +89,7 @@ public class FieldBuilder extends AbstractMemberBuilder {
classDoc,
VisibleMemberMap.FIELDS,
configuration);
fields =
new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
configuration));
fields = new ArrayList<>(visibleMemberMap.getLeafClassMembers(configuration));
if (configuration.getMemberComparator() != null) {
Collections.sort(fields, configuration.getMemberComparator());
}

View File

@ -60,7 +60,7 @@ public class LayoutParser extends DefaultHandler {
private boolean isParsing;
private LayoutParser(Configuration configuration) {
xmlElementsMap = new HashMap<String,XMLNode>();
xmlElementsMap = new HashMap<>();
this.configuration = configuration;
}

View File

@ -330,11 +330,11 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
*/
private void buildSummary(MemberSummaryWriter writer,
VisibleMemberMap visibleMemberMap, LinkedList<Content> summaryTreeList) {
List<ProgramElementDoc> members = new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
List<ProgramElementDoc> members = new ArrayList<>(visibleMemberMap.getLeafClassMembers(
configuration));
if (members.size() > 0) {
Collections.sort(members);
List<Content> tableContents = new LinkedList<Content>();
List<Content> tableContents = new LinkedList<>();
for (int i = 0; i < members.size(); i++) {
ProgramElementDoc member = members.get(i);
final ProgramElementDoc propertyDoc =
@ -400,7 +400,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
commentTextBuilder.append(propertyDoc.commentText());
// copy certain tags
List<Tag> allTags = new LinkedList<Tag>();
List<Tag> allTags = new LinkedList<>();
String[] tagNames = {"@defaultValue", "@since"};
for (String tagName: tagNames) {
Tag[] tags = propertyDoc.tags(tagName);
@ -514,7 +514,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
private void addSummary(MemberSummaryWriter writer,
VisibleMemberMap visibleMemberMap, boolean showInheritedSummary,
Content memberSummaryTree) {
LinkedList<Content> summaryTreeList = new LinkedList<Content>();
LinkedList<Content> summaryTreeList = new LinkedList<>();
buildSummary(writer, visibleMemberMap, summaryTreeList);
if (showInheritedSummary)
buildInheritedSummary(writer, visibleMemberMap, summaryTreeList);

View File

@ -90,8 +90,7 @@ public class MethodBuilder extends AbstractMemberBuilder {
VisibleMemberMap.METHODS,
configuration);
methods =
new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
configuration));
new ArrayList<>(visibleMemberMap.getLeafClassMembers(configuration));
if (configuration.getMemberComparator() != null) {
Collections.sort(methods, configuration.getMemberComparator());
}

View File

@ -90,7 +90,7 @@ public class PropertyBuilder extends AbstractMemberBuilder {
VisibleMemberMap.PROPERTIES,
configuration);
properties =
new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
new ArrayList<>(visibleMemberMap.getMembersFor(classDoc));
if (configuration.getMemberComparator() != null) {
Collections.sort(properties, configuration.getMemberComparator());
}

View File

@ -42,8 +42,8 @@ public class XMLNode {
XMLNode(XMLNode parent, String qname) {
this.parent = parent;
name = qname;
attrs = new HashMap<String,String>();
children = new ArrayList<XMLNode>();
attrs = new HashMap<>();
children = new ArrayList<>();
if (parent != null)
parent.children.add(this);

View File

@ -63,7 +63,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
if (params == null) {
return null;
}
HashMap<String,String> result = new HashMap<String,String>();
HashMap<String,String> result = new HashMap<>();
for (int i = 0; i < params.length; i++) {
String name = params[i] instanceof Parameter ?
((Parameter) params[i]).name() :
@ -195,7 +195,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
private Content getTagletOutput(boolean isNonTypeParams, Doc holder,
TagletWriter writer, Object[] formalParameters, ParamTag[] paramTags) {
Content result = writer.getOutputInstance();
Set<String> alreadyDocumented = new HashSet<String>();
Set<String> alreadyDocumented = new HashSet<>();
if (paramTags.length > 0) {
result.addContent(
processParamTags(isNonTypeParams, paramTags,

View File

@ -173,12 +173,12 @@ public class TagletManager {
public TagletManager(boolean nosince, boolean showversion,
boolean showauthor, boolean javafx,
MessageRetriever message) {
overridenStandardTags = new HashSet<String>();
potentiallyConflictingTags = new HashSet<String>();
standardTags = new HashSet<String>();
standardTagsLowercase = new HashSet<String>();
unseenCustomTags = new HashSet<String>();
customTags = new LinkedHashMap<String,Taglet>();
overridenStandardTags = new HashSet<>();
potentiallyConflictingTags = new HashSet<>();
standardTags = new HashSet<>();
standardTagsLowercase = new HashSet<>();
unseenCustomTags = new HashSet<>();
customTags = new LinkedHashMap<>();
this.nosince = nosince;
this.showversion = showversion;
this.showauthor = showauthor;
@ -235,11 +235,11 @@ public class TagletManager {
customTagClass = tagClassLoader.loadClass(classname);
Method meth = customTagClass.getMethod("register",
new Class<?>[] {java.util.Map.class});
Map.class);
Object[] list = customTags.values().toArray();
Taglet lastTag = (list != null && list.length > 0)
? (Taglet) list[list.length-1] : null;
meth.invoke(null, new Object[] {customTags});
meth.invoke(null, customTags);
list = customTags.values().toArray();
Object newLastTag = (list != null&& list.length > 0)
? list[list.length-1] : null;
@ -276,7 +276,7 @@ public class TagletManager {
* @return the resulting array of directory and JAR file URLs
*/
private URL[] pathToURLs(String path) {
Set<URL> urls = new LinkedHashSet<URL>();
Set<URL> urls = new LinkedHashSet<>();
for (String s: path.split(File.pathSeparator)) {
if (s.isEmpty()) continue;
try {
@ -414,7 +414,7 @@ public class TagletManager {
* @param holderType the type of documentation that the misused tag was found in.
*/
private void printTagMisuseWarn(Taglet taglet, Tag tag, String holderType) {
Set<String> locationsSet = new LinkedHashSet<String>();
Set<String> locationsSet = new LinkedHashSet<>();
if (taglet.inOverview()) {
locationsSet.add("overview");
}
@ -582,14 +582,14 @@ public class TagletManager {
*/
private void initCustomTagletArrays() {
Iterator<Taglet> it = customTags.values().iterator();
ArrayList<Taglet> pTags = new ArrayList<Taglet>(customTags.size());
ArrayList<Taglet> tTags = new ArrayList<Taglet>(customTags.size());
ArrayList<Taglet> fTags = new ArrayList<Taglet>(customTags.size());
ArrayList<Taglet> cTags = new ArrayList<Taglet>(customTags.size());
ArrayList<Taglet> mTags = new ArrayList<Taglet>(customTags.size());
ArrayList<Taglet> iTags = new ArrayList<Taglet>(customTags.size());
ArrayList<Taglet> oTags = new ArrayList<Taglet>(customTags.size());
ArrayList<Taglet> sTags = new ArrayList<Taglet>();
ArrayList<Taglet> pTags = new ArrayList<>(customTags.size());
ArrayList<Taglet> tTags = new ArrayList<>(customTags.size());
ArrayList<Taglet> fTags = new ArrayList<>(customTags.size());
ArrayList<Taglet> cTags = new ArrayList<>(customTags.size());
ArrayList<Taglet> mTags = new ArrayList<>(customTags.size());
ArrayList<Taglet> iTags = new ArrayList<>(customTags.size());
ArrayList<Taglet> oTags = new ArrayList<>(customTags.size());
ArrayList<Taglet> sTags = new ArrayList<>();
Taglet current;
while (it.hasNext()) {
current = it.next();

View File

@ -113,7 +113,7 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet
TagletWriter writer) {
Content result = writer.getOutputInstance();
if (holder instanceof MethodDoc) {
Set<Tag> declaredExceptionTags = new LinkedHashSet<Tag>();
Set<Tag> declaredExceptionTags = new LinkedHashSet<>();
for (Type declaredExceptionType : declaredExceptionTypes) {
DocFinder.Output inheritedDoc =
DocFinder.search(new DocFinder.Input((MethodDoc) holder, this,
@ -139,7 +139,7 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet
ExecutableMemberDoc execHolder = (ExecutableMemberDoc) holder;
ThrowsTag[] tags = execHolder.throwsTags();
Content result = writer.getOutputInstance();
HashSet<String> alreadyDocumented = new HashSet<String>();
HashSet<String> alreadyDocumented = new HashSet<>();
if (tags.length > 0) {
result.addContent(throwsTagsOutput(
execHolder.throwsTags(), writer, alreadyDocumented, true));

View File

@ -114,14 +114,14 @@ import com.sun.tools.doclets.internal.toolkit.Configuration;
}
private void init() {
allClasses = new HashMap<String,Set<ClassDoc>>();
ordinaryClasses = new HashMap<String,Set<ClassDoc>>();
exceptions = new HashMap<String,Set<ClassDoc>>();
enums = new HashMap<String,Set<ClassDoc>>();
annotationTypes = new HashMap<String,Set<ClassDoc>>();
errors = new HashMap<String,Set<ClassDoc>>();
interfaces = new HashMap<String,Set<ClassDoc>>();
packageSet = new HashSet<String>();
allClasses = new HashMap<>();
ordinaryClasses = new HashMap<>();
exceptions = new HashMap<>();
enums = new HashMap<>();
annotationTypes = new HashMap<>();
errors = new HashMap<>();
interfaces = new HashMap<>();
packageSet = new HashSet<>();
}
/**
@ -166,7 +166,7 @@ import com.sun.tools.doclets.internal.toolkit.Configuration;
Set<ClassDoc> s = map.get(key);
if (s == null) {
packageSet.add(key);
s = new HashSet<ClassDoc>();
s = new HashSet<>();
}
s.add(classdoc);
map.put(key, s);

View File

@ -51,35 +51,35 @@ public class ClassTree {
* List of baseclasses. Contains only java.lang.Object. Can be used to get
* the mapped listing of sub-classes.
*/
private List<ClassDoc> baseclasses = new ArrayList<ClassDoc>();
private List<ClassDoc> baseclasses = new ArrayList<>();
/**
* Mapping for each Class with their SubClasses
*/
private Map<ClassDoc,List<ClassDoc>> subclasses = new HashMap<ClassDoc,List<ClassDoc>>();
private Map<ClassDoc,List<ClassDoc>> subclasses = new HashMap<>();
/**
* List of base-interfaces. Contains list of all the interfaces who do not
* have super-interfaces. Can be used to get the mapped listing of
* sub-interfaces.
*/
private List<ClassDoc> baseinterfaces = new ArrayList<ClassDoc>();
private List<ClassDoc> baseinterfaces = new ArrayList<>();
/**
* Mapping for each Interface with their SubInterfaces
*/
private Map<ClassDoc,List<ClassDoc>> subinterfaces = new HashMap<ClassDoc,List<ClassDoc>>();
private Map<ClassDoc,List<ClassDoc>> subinterfaces = new HashMap<>();
private List<ClassDoc> baseEnums = new ArrayList<ClassDoc>();
private Map<ClassDoc,List<ClassDoc>> subEnums = new HashMap<ClassDoc,List<ClassDoc>>();
private List<ClassDoc> baseEnums = new ArrayList<>();
private Map<ClassDoc,List<ClassDoc>> subEnums = new HashMap<>();
private List<ClassDoc> baseAnnotationTypes = new ArrayList<ClassDoc>();
private Map<ClassDoc,List<ClassDoc>> subAnnotationTypes = new HashMap<ClassDoc,List<ClassDoc>>();
private List<ClassDoc> baseAnnotationTypes = new ArrayList<>();
private Map<ClassDoc,List<ClassDoc>> subAnnotationTypes = new HashMap<>();
/**
* Mapping for each Interface with classes who implement it.
*/
private Map<ClassDoc,List<ClassDoc>> implementingclasses = new HashMap<ClassDoc,List<ClassDoc>>();
private Map<ClassDoc,List<ClassDoc>> implementingclasses = new HashMap<>();
/**
* Constructor. Build the Tree using the Root of this Javadoc run.
@ -234,7 +234,7 @@ public class ClassTree {
private boolean add(Map<ClassDoc,List<ClassDoc>> map, ClassDoc superclass, ClassDoc cd) {
List<ClassDoc> list = map.get(superclass);
if (list == null) {
list = new ArrayList<ClassDoc>();
list = new ArrayList<>();
map.put(superclass, list);
}
if (list.contains(cd)) {
@ -256,7 +256,7 @@ public class ClassTree {
private List<ClassDoc> get(Map<ClassDoc,List<ClassDoc>> map, ClassDoc cd) {
List<ClassDoc> list = map.get(cd);
if (list == null) {
return new ArrayList<ClassDoc>();
return new ArrayList<>();
}
return list;
}

View File

@ -48,138 +48,138 @@ public class ClassUseMapper {
* Mapping of ClassDocs to set of PackageDoc used by that class.
* Entries may be null.
*/
public Map<String,Set<PackageDoc>> classToPackage = new HashMap<String,Set<PackageDoc>>();
public Map<String,Set<PackageDoc>> classToPackage = new HashMap<>();
/**
* Mapping of Annotations to set of PackageDoc that use the annotation.
*/
public Map<String,List<PackageDoc>> classToPackageAnnotations = new HashMap<String,List<PackageDoc>>();
public Map<String,List<PackageDoc>> classToPackageAnnotations = new HashMap<>();
/**
* Mapping of ClassDocs to set of ClassDoc used by that class.
* Entries may be null.
*/
public Map<String,Set<ClassDoc>> classToClass = new HashMap<String,Set<ClassDoc>>();
public Map<String,Set<ClassDoc>> classToClass = new HashMap<>();
/**
* Mapping of ClassDocs to list of ClassDoc which are direct or
* indirect subclasses of that class.
* Entries may be null.
*/
public Map<String,List<ClassDoc>> classToSubclass = new HashMap<String,List<ClassDoc>>();
public Map<String,List<ClassDoc>> classToSubclass = new HashMap<>();
/**
* Mapping of ClassDocs to list of ClassDoc which are direct or
* indirect subinterfaces of that interface.
* Entries may be null.
*/
public Map<String,List<ClassDoc>> classToSubinterface = new HashMap<String,List<ClassDoc>>();
public Map<String,List<ClassDoc>> classToSubinterface = new HashMap<>();
/**
* Mapping of ClassDocs to list of ClassDoc which implement
* this interface.
* Entries may be null.
*/
public Map<String,List<ClassDoc>> classToImplementingClass = new HashMap<String,List<ClassDoc>>();
public Map<String,List<ClassDoc>> classToImplementingClass = new HashMap<>();
/**
* Mapping of ClassDocs to list of FieldDoc declared as that class.
* Entries may be null.
*/
public Map<String,List<FieldDoc>> classToField = new HashMap<String,List<FieldDoc>>();
public Map<String,List<FieldDoc>> classToField = new HashMap<>();
/**
* Mapping of ClassDocs to list of MethodDoc returning that class.
* Entries may be null.
*/
public Map<String,List<MethodDoc>> classToMethodReturn = new HashMap<String,List<MethodDoc>>();
public Map<String,List<MethodDoc>> classToMethodReturn = new HashMap<>();
/**
* Mapping of ClassDocs to list of MethodDoc having that class
* as an arg.
* Entries may be null.
*/
public Map<String,List<ExecutableMemberDoc>> classToMethodArgs = new HashMap<String,List<ExecutableMemberDoc>>();
public Map<String,List<ExecutableMemberDoc>> classToMethodArgs = new HashMap<>();
/**
* Mapping of ClassDocs to list of MethodDoc which throws that class.
* Entries may be null.
*/
public Map<String,List<ExecutableMemberDoc>> classToMethodThrows = new HashMap<String,List<ExecutableMemberDoc>>();
public Map<String,List<ExecutableMemberDoc>> classToMethodThrows = new HashMap<>();
/**
* Mapping of ClassDocs to list of ConstructorDoc having that class
* as an arg.
* Entries may be null.
*/
public Map<String,List<ExecutableMemberDoc>> classToConstructorArgs = new HashMap<String,List<ExecutableMemberDoc>>();
public Map<String,List<ExecutableMemberDoc>> classToConstructorArgs = new HashMap<>();
/**
* Mapping of ClassDocs to list of ConstructorDoc which throws that class.
* Entries may be null.
*/
public Map<String,List<ExecutableMemberDoc>> classToConstructorThrows = new HashMap<String,List<ExecutableMemberDoc>>();
public Map<String,List<ExecutableMemberDoc>> classToConstructorThrows = new HashMap<>();
/**
* The mapping of AnnotationTypeDocs to constructors that use them.
*/
public Map<String,List<ConstructorDoc>> classToConstructorAnnotations = new HashMap<String,List<ConstructorDoc>>();
public Map<String,List<ConstructorDoc>> classToConstructorAnnotations = new HashMap<>();
/**
* The mapping of AnnotationTypeDocs to Constructor parameters that use them.
*/
public Map<String,List<ExecutableMemberDoc>> classToConstructorParamAnnotation = new HashMap<String,List<ExecutableMemberDoc>>();
public Map<String,List<ExecutableMemberDoc>> classToConstructorParamAnnotation = new HashMap<>();
/**
* The mapping of ClassDocs to Constructor arguments that use them as type parameters.
*/
public Map<String,List<ExecutableMemberDoc>> classToConstructorDocArgTypeParam = new HashMap<String,List<ExecutableMemberDoc>>();
public Map<String,List<ExecutableMemberDoc>> classToConstructorDocArgTypeParam = new HashMap<>();
/**
* The mapping of ClassDocs to ClassDocs that use them as type parameters.
*/
public Map<String,List<ClassDoc>> classToClassTypeParam = new HashMap<String,List<ClassDoc>>();
public Map<String,List<ClassDoc>> classToClassTypeParam = new HashMap<>();
/**
* The mapping of AnnotationTypeDocs to ClassDocs that use them.
*/
public Map<String,List<ClassDoc>> classToClassAnnotations = new HashMap<String,List<ClassDoc>>();
public Map<String,List<ClassDoc>> classToClassAnnotations = new HashMap<>();
/**
* The mapping of ClassDocs to ExecutableMemberDocs that use them as type parameters.
*/
public Map<String,List<MethodDoc>> classToExecMemberDocTypeParam = new HashMap<String,List<MethodDoc>>();
public Map<String,List<MethodDoc>> classToExecMemberDocTypeParam = new HashMap<>();
/**
* The mapping of ClassDocs to ExecutableMemberDocs arguments that use them as type parameters.
*/
public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocArgTypeParam = new HashMap<String,List<ExecutableMemberDoc>>();
public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocArgTypeParam = new HashMap<>();
/**
* The mapping of AnnotationTypeDocs to ExecutableMemberDocs that use them.
*/
public Map<String,List<MethodDoc>> classToExecMemberDocAnnotations = new HashMap<String,List<MethodDoc>>();
public Map<String,List<MethodDoc>> classToExecMemberDocAnnotations = new HashMap<>();
/**
* The mapping of ClassDocs to ExecutableMemberDocs that have return type
* with type parameters of that class.
*/
public Map<String,List<MethodDoc>> classToExecMemberDocReturnTypeParam = new HashMap<String,List<MethodDoc>>();
public Map<String,List<MethodDoc>> classToExecMemberDocReturnTypeParam = new HashMap<>();
/**
* The mapping of AnnotationTypeDocs to MethodDoc parameters that use them.
*/
public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocParamAnnotation = new HashMap<String,List<ExecutableMemberDoc>>();
public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocParamAnnotation = new HashMap<>();
/**
* The mapping of ClassDocs to FieldDocs that use them as type parameters.
*/
public Map<String,List<FieldDoc>> classToFieldDocTypeParam = new HashMap<String,List<FieldDoc>>();
public Map<String,List<FieldDoc>> classToFieldDocTypeParam = new HashMap<>();
/**
* The mapping of AnnotationTypeDocs to FieldDocs that use them.
*/
public Map<String,List<FieldDoc>> annotationToFieldDoc = new HashMap<String,List<FieldDoc>>();
public Map<String,List<FieldDoc>> annotationToFieldDoc = new HashMap<>();
public ClassUseMapper(RootDoc root, ClassTree classtree) {
@ -234,7 +234,7 @@ public class ClassUseMapper {
private Collection<ClassDoc> subclasses(ClassDoc cd) {
Collection<ClassDoc> ret = classToSubclass.get(cd.qualifiedName());
if (ret == null) {
ret = new TreeSet<ClassDoc>();
ret = new TreeSet<>();
List<ClassDoc> subs = classtree.subclasses(cd);
if (subs != null) {
ret.addAll(subs);
@ -253,7 +253,7 @@ public class ClassUseMapper {
private Collection<ClassDoc> subinterfaces(ClassDoc cd) {
Collection<ClassDoc> ret = classToSubinterface.get(cd.qualifiedName());
if (ret == null) {
ret = new TreeSet<ClassDoc>();
ret = new TreeSet<>();
List<ClassDoc> subs = classtree.subinterfaces(cd);
if (subs != null) {
ret.addAll(subs);
@ -275,7 +275,7 @@ public class ClassUseMapper {
private Collection<ClassDoc> implementingClasses(ClassDoc cd) {
Collection<ClassDoc> ret = classToImplementingClass.get(cd.qualifiedName());
if (ret == null) {
ret = new TreeSet<ClassDoc>();
ret = new TreeSet<>();
List<ClassDoc> impl = classtree.implementingclasses(cd);
if (impl != null) {
ret.addAll(impl);
@ -297,7 +297,7 @@ public class ClassUseMapper {
*/
private void mapExecutable(ExecutableMemberDoc em) {
boolean isConstructor = em.isConstructor();
List<Type> classArgs = new ArrayList<Type>();
List<Type> classArgs = new ArrayList<>();
for (Parameter param : em.parameters()) {
Type pcd = param.type();
// primitives don't get mapped, also avoid dups
@ -326,8 +326,7 @@ public class ClassUseMapper {
private <T> List<T> refList(Map<String,List<T>> map, ClassDoc cd) {
List<T> list = map.get(cd.qualifiedName());
if (list == null) {
List<T> l = new ArrayList<T>();
list = l;
list = new ArrayList<>();
map.put(cd.qualifiedName(), list);
}
return list;
@ -336,7 +335,7 @@ public class ClassUseMapper {
private Set<PackageDoc> packageSet(ClassDoc cd) {
Set<PackageDoc> pkgSet = classToPackage.get(cd.qualifiedName());
if (pkgSet == null) {
pkgSet = new TreeSet<PackageDoc>();
pkgSet = new TreeSet<>();
classToPackage.put(cd.qualifiedName(), pkgSet);
}
return pkgSet;
@ -345,8 +344,7 @@ public class ClassUseMapper {
private Set<ClassDoc> classSet(ClassDoc cd) {
Set<ClassDoc> clsSet = classToClass.get(cd.qualifiedName());
if (clsSet == null) {
Set<ClassDoc> s = new TreeSet<ClassDoc>();
clsSet = s;
clsSet = new TreeSet<>();
classToClass.put(cd.qualifiedName(), clsSet);
}
return clsSet;

View File

@ -69,9 +69,9 @@ public class DeprecatedAPIListBuilder {
* @param configuration the current configuration of the doclet
*/
public DeprecatedAPIListBuilder(Configuration configuration) {
deprecatedLists = new ArrayList<List<Doc>>();
deprecatedLists = new ArrayList<>();
for (int i = 0; i < NUM_TYPES; i++) {
deprecatedLists.add(i, new ArrayList<Doc>());
deprecatedLists.add(i, new ArrayList<>());
}
buildDeprecatedAPIInfo(configuration);
}

View File

@ -46,8 +46,7 @@ import com.sun.tools.doclets.internal.toolkit.Configuration;
* @since 1.8
*/
abstract class DocFileFactory {
private static final Map<Configuration, DocFileFactory> factories =
new WeakHashMap<Configuration, DocFileFactory>();
private static final Map<Configuration, DocFileFactory> factories = new WeakHashMap<>();
/**
* Get the appropriate factory, based on the file manager given in the

View File

@ -171,7 +171,7 @@ public class DocFinder {
* subclass of IOException. This subclass of DocFinder.Output allows
* multiple tag inheritence.
*/
public List<Tag> tagList = new ArrayList<Tag>();
public List<Tag> tagList = new ArrayList<>();
}
/**

View File

@ -68,7 +68,7 @@ public class DocPaths {
public static final DocPath INDEX_FILES = DocPath.create("index-files");
/** Generate the name of one of the files in the split index. */
public static final DocPath indexN(int n) {
public static DocPath indexN(int n) {
return DocPath.create("index-" + n + ".html");
}
@ -88,22 +88,22 @@ public class DocPaths {
public static final DocPath PACKAGE_FRAME = DocPath.create("package-frame.html");
/** The name of the file for the profile frame. */
public static final DocPath profileFrame(String profileName) {
public static DocPath profileFrame(String profileName) {
return DocPath.create(profileName + "-frame.html");
}
/** The name of the file for the profile package frame. */
public static final DocPath profilePackageFrame(String profileName) {
public static DocPath profilePackageFrame(String profileName) {
return DocPath.create(profileName + "-package-frame.html");
}
/** The name of the file for the profile package summary. */
public static final DocPath profilePackageSummary(String profileName) {
public static DocPath profilePackageSummary(String profileName) {
return DocPath.create(profileName + "-package-summary.html");
}
/** The name of the file for the profile summary. */
public static final DocPath profileSummary(String profileName) {
public static DocPath profileSummary(String profileName) {
return DocPath.create(profileName + "-summary.html");
}

View File

@ -104,7 +104,7 @@ public class Extern {
this.path = path;
this.relative = relative;
if (packageToItemMap == null) {
packageToItemMap = new HashMap<String,Item>();
packageToItemMap = new HashMap<>();
}
if (!packageToItemMap.containsKey(packageName)) { // save the previous
packageToItemMap.put(packageName, this); // mapped location

View File

@ -61,24 +61,24 @@ public class Group {
/**
* Map of regular expressions with the corresponding group name.
*/
private Map<String,String> regExpGroupMap = new HashMap<String,String>();
private Map<String,String> regExpGroupMap = new HashMap<>();
/**
* List of regular expressions sorted according to the length. Regular
* expression with longest length will be first in the sorted order.
*/
private List<String> sortedRegExpList = new ArrayList<String>();
private List<String> sortedRegExpList = new ArrayList<>();
/**
* List of group names in the same order as given on the command line.
*/
private List<String> groupList = new ArrayList<String>();
private List<String> groupList = new ArrayList<>();
/**
* Map of non-regular expressions(possible package names) with the
* corresponding group name.
*/
private Map<String,String> pkgNameGroupMap = new HashMap<String,String>();
private Map<String,String> pkgNameGroupMap = new HashMap<>();
/**
* The global configuration information for this run.
@ -176,7 +176,7 @@ public class Group {
* @param packages Packages specified on the command line.
*/
public Map<String,List<PackageDoc>> groupPackages(PackageDoc[] packages) {
Map<String,List<PackageDoc>> groupPackageMap = new HashMap<String,List<PackageDoc>>();
Map<String,List<PackageDoc>> groupPackageMap = new HashMap<>();
String defaultGroupName =
(pkgNameGroupMap.isEmpty() && regExpGroupMap.isEmpty())?
configuration.message.getText("doclet.Packages") :
@ -229,7 +229,7 @@ public class Group {
List<PackageDoc> getPkgList(Map<String,List<PackageDoc>> map, String groupname) {
List<PackageDoc> list = map.get(groupname);
if (list == null) {
list = new ArrayList<PackageDoc>();
list = new ArrayList<>();
map.put(groupname, list);
}
return list;

View File

@ -43,8 +43,8 @@ import com.sun.tools.doclets.internal.toolkit.Configuration;
*/
public class ImplementedMethods {
private Map<MethodDoc,Type> interfaces = new HashMap<MethodDoc,Type>();
private List<MethodDoc> methlist = new ArrayList<MethodDoc>();
private Map<MethodDoc,Type> interfaces = new HashMap<>();
private List<MethodDoc> methlist = new ArrayList<>();
private Configuration configuration;
private final ClassDoc classdoc;
private final MethodDoc method;

View File

@ -51,7 +51,7 @@ public class IndexBuilder {
* Mapping of each Unicode Character with the member list containing
* members with names starting with it.
*/
private Map<Character,List<Doc>> indexmap = new HashMap<Character,List<Doc>>();
private Map<Character,List<Doc>> indexmap = new HashMap<>();
/**
* Don't generate deprecated information if true.
@ -149,7 +149,7 @@ public class IndexBuilder {
ClassDoc[] classes = root.classes();
if (!classesOnly) {
if (packages.length == 0) {
Set<PackageDoc> set = new HashSet<PackageDoc>();
Set<PackageDoc> set = new HashSet<>();
for (ClassDoc aClass : classes) {
PackageDoc pd = aClass.containingPackage();
if (pd != null && pd.name().length() > 0) {
@ -202,7 +202,7 @@ public class IndexBuilder {
Character unicode = ch;
List<Doc> list = indexmap.get(unicode);
if (list == null) {
list = new ArrayList<Doc>();
list = new ArrayList<>();
indexmap.put(unicode, list);
}
list.add(element);

View File

@ -71,7 +71,7 @@ public class MetaKeywords {
* definitions are on separate pages.
*/
public String[] getMetaKeywords(ClassDoc classdoc) {
ArrayList<String> results = new ArrayList<String>();
ArrayList<String> results = new ArrayList<>();
// Add field and method keywords only if -keywords option is used
if( configuration.keywords ) {
@ -88,7 +88,7 @@ public class MetaKeywords {
*/
protected ArrayList<String> getClassKeyword(ClassDoc classdoc) {
String cltypelower = classdoc.isInterface() ? "interface" : "class";
ArrayList<String> metakeywords = new ArrayList<String>(1);
ArrayList<String> metakeywords = new ArrayList<>(1);
metakeywords.add(classdoc.qualifiedName() + " " + cltypelower);
return metakeywords;
}
@ -145,7 +145,7 @@ public class MetaKeywords {
* @param memberdocs array of MemberDoc objects to be added to keywords
*/
protected ArrayList<String> getMemberKeywords(MemberDoc[] memberdocs) {
ArrayList<String> results = new ArrayList<String>();
ArrayList<String> results = new ArrayList<>();
String membername;
for (MemberDoc memberdoc : memberdocs) {
membername = memberdoc.name() + (memberdoc.isMethod() ? "()" : "");

View File

@ -76,7 +76,7 @@ public class PackageListWriter extends PrintWriter {
}
protected void generatePackageListFile(RootDoc root) {
ArrayList<String> names = new ArrayList<String>();
ArrayList<String> names = new ArrayList<>();
for (PackageDoc pkg : configuration.packages) {
// if the -nodeprecated option is set and the package is marked as
// deprecated, do not include it in the packages list.

View File

@ -102,7 +102,7 @@ class PathDocFileFactory extends DocFileFactory {
if (location != StandardLocation.SOURCE_PATH)
throw new IllegalArgumentException();
Set<DocFile> files = new LinkedHashSet<DocFile>();
Set<DocFile> files = new LinkedHashSet<>();
if (fileManager.hasLocation(location)) {
for (Path f: fileManager.getLocation(location)) {
if (Files.isDirectory(f)) {
@ -221,7 +221,7 @@ class PathDocFileFactory extends DocFileFactory {
/** If the file is a directory, list its contents. */
public Iterable<DocFile> list() throws IOException {
List<DocFile> files = new ArrayList<DocFile>();
List<DocFile> files = new ArrayList<>();
try (DirectoryStream<Path> ds = Files.newDirectoryStream(file)) {
for (Path f: ds) {
files.add(new StandardDocFile(f));

View File

@ -83,7 +83,7 @@ class SimpleDocFileFactory extends DocFileFactory {
if (location != StandardLocation.SOURCE_PATH)
throw new IllegalArgumentException();
Set<DocFile> files = new LinkedHashSet<DocFile>();
Set<DocFile> files = new LinkedHashSet<>();
for (String s : configuration.sourcepath.split(File.pathSeparator)) {
if (s.isEmpty())
continue;
@ -206,7 +206,7 @@ class SimpleDocFileFactory extends DocFileFactory {
/** If the file is a directory, list its contents. */
public Iterable<DocFile> list() {
List<DocFile> files = new ArrayList<DocFile>();
List<DocFile> files = new ArrayList<>();
for (File f: file.listFiles()) {
files.add(new SimpleDocFile(f));
}

View File

@ -105,7 +105,7 @@ class StandardDocFileFactory extends DocFileFactory {
if (location != StandardLocation.SOURCE_PATH)
throw new IllegalArgumentException();
Set<DocFile> files = new LinkedHashSet<DocFile>();
Set<DocFile> files = new LinkedHashSet<>();
Location l = fileManager.hasLocation(StandardLocation.SOURCE_PATH)
? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;
for (File f: fileManager.getLocation(l)) {
@ -231,7 +231,7 @@ class StandardDocFileFactory extends DocFileFactory {
/** If the file is a directory, list its contents. */
public Iterable<DocFile> list() {
List<DocFile> files = new ArrayList<DocFile>();
List<DocFile> files = new ArrayList<>();
for (File f: file.listFiles()) {
files.add(new StandardDocFile(f));
}

View File

@ -76,7 +76,7 @@ public class Util {
*/
public static List<ProgramElementDoc> excludeDeprecatedMembersAsList(
ProgramElementDoc[] members) {
List<ProgramElementDoc> list = new ArrayList<ProgramElementDoc>();
List<ProgramElementDoc> list = new ArrayList<>();
for (ProgramElementDoc member : members) {
if (member.tags("deprecated").length == 0) {
list.add(member);
@ -273,7 +273,7 @@ public class Util {
*/
public static List<Type> getAllInterfaces(Type type,
Configuration configuration, boolean sort) {
Map<ClassDoc,Type> results = sort ? new TreeMap<ClassDoc,Type>() : new LinkedHashMap<ClassDoc,Type>();
Map<ClassDoc,Type> results = sort ? new TreeMap<>() : new LinkedHashMap<>();
Type[] interfaceTypes = null;
Type superType = null;
if (type instanceof ParameterizedType) {
@ -300,13 +300,13 @@ public class Util {
}
}
if (superType == null)
return new ArrayList<Type>(results.values());
return new ArrayList<>(results.values());
//Try walking the tree.
addAllInterfaceTypes(results,
superType,
interfaceTypesOf(superType),
false, configuration);
List<Type> resultsList = new ArrayList<Type>(results.values());
List<Type> resultsList = new ArrayList<>(results.values());
if (sort) {
Collections.sort(resultsList, new TypeComparator());
}
@ -744,8 +744,7 @@ public class Util {
if (!javafx) {
return classes;
}
final List<ClassDoc> filteredOutClasses =
new ArrayList<ClassDoc>(classes.length);
final List<ClassDoc> filteredOutClasses = new ArrayList<>(classes.length);
for (ClassDoc classDoc : classes) {
if (classDoc.isPrivate() || classDoc.isPackagePrivate()) {
continue;

View File

@ -70,19 +70,19 @@ public class VisibleMemberMap {
/**
* List of ClassDoc objects for which ClassMembers objects are built.
*/
private final List<ClassDoc> visibleClasses = new ArrayList<ClassDoc>();
private final List<ClassDoc> visibleClasses = new ArrayList<>();
/**
* Map for each member name on to a map which contains members with same
* name-signature. The mapped map will contain mapping for each MemberDoc
* onto it's respecive level string.
*/
private final Map<Object,Map<ProgramElementDoc,String>> memberNameMap = new HashMap<Object,Map<ProgramElementDoc,String>>();
private final Map<Object,Map<ProgramElementDoc,String>> memberNameMap = new HashMap<>();
/**
* Map of class and it's ClassMembers object.
*/
private final Map<ClassDoc,ClassMembers> classMap = new HashMap<ClassDoc,ClassMembers>();
private final Map<ClassDoc,ClassMembers> classMap = new HashMap<>();
/**
* Type whose visible members are requested. This is the leaf of
@ -100,12 +100,9 @@ public class VisibleMemberMap {
*/
private final Configuration configuration;
private static final Map<ClassDoc, ProgramElementDoc[]> propertiesCache =
new HashMap<ClassDoc, ProgramElementDoc[]>();
private static final Map<ProgramElementDoc, ProgramElementDoc> classPropertiesMap =
new HashMap<ProgramElementDoc, ProgramElementDoc>();
private static final Map<ProgramElementDoc, GetterSetter> getterSetterMap =
new HashMap<ProgramElementDoc, GetterSetter>();
private static final Map<ClassDoc, ProgramElementDoc[]> propertiesCache = new HashMap<>();
private static final Map<ProgramElementDoc, ProgramElementDoc> classPropertiesMap = new HashMap<>();
private static final Map<ProgramElementDoc, GetterSetter> getterSetterMap = new HashMap<>();
/**
* Construct a VisibleMemberMap of the given type for the given
@ -172,7 +169,7 @@ public class VisibleMemberMap {
* @return the package private members inherited by the class.
*/
private List<ProgramElementDoc> getInheritedPackagePrivateMethods(Configuration configuration) {
List<ProgramElementDoc> results = new ArrayList<ProgramElementDoc>();
List<ProgramElementDoc> results = new ArrayList<>();
for (ClassDoc currentClass : visibleClasses) {
if (currentClass != classdoc &&
currentClass.isPackagePrivate() &&
@ -208,7 +205,7 @@ public class VisibleMemberMap {
public List<ProgramElementDoc> getMembersFor(ClassDoc cd) {
ClassMembers clmembers = classMap.get(cd);
if (clmembers == null) {
return new ArrayList<ProgramElementDoc>();
return new ArrayList<>();
}
return clmembers.getMembers();
}
@ -218,8 +215,8 @@ public class VisibleMemberMap {
* classes followed by interfaces traversed. Don't sort alphabetically.
*/
private void sort(List<ClassDoc> list) {
List<ClassDoc> classes = new ArrayList<ClassDoc>();
List<ClassDoc> interfaces = new ArrayList<ClassDoc>();
List<ClassDoc> classes = new ArrayList<>();
List<ClassDoc> interfaces = new ArrayList<>();
for (ClassDoc cd : list) {
if (cd.isClass()) {
classes.add(cd);
@ -238,7 +235,7 @@ public class VisibleMemberMap {
Object key = getMemberKey(element);
Map<ProgramElementDoc, String> memberLevelMap = memberNameMap.get(key);
if (memberLevelMap == null) {
memberLevelMap = new HashMap<ProgramElementDoc, String>();
memberLevelMap = new HashMap<>();
memberNameMap.put(key, memberLevelMap);
}
memberLevelMap.put(element, level);
@ -263,7 +260,7 @@ public class VisibleMemberMap {
private Set<ProgramElementDoc> members;
public ClassMember(ProgramElementDoc programElementDoc) {
members = new HashSet<ProgramElementDoc>();
members = new HashSet<>();
members.add(programElementDoc);
}
@ -297,7 +294,7 @@ public class VisibleMemberMap {
/**
* List of inherited members from the mapping class.
*/
private List<ProgramElementDoc> members = new ArrayList<ProgramElementDoc>();
private List<ProgramElementDoc> members = new ArrayList<>();
/**
* Level/Depth of inheritance.
@ -368,7 +365,7 @@ public class VisibleMemberMap {
*/
private void addMembers(ClassDoc fromClass) {
List<ProgramElementDoc> cdmembers = getClassMembers(fromClass, true);
List<ProgramElementDoc> incllist = new ArrayList<ProgramElementDoc>();
List<ProgramElementDoc> incllist = new ArrayList<>();
for (ProgramElementDoc pgmelem : cdmembers) {
if (!found(members, pgmelem) &&
memberIsVisible(pgmelem) &&
@ -487,7 +484,7 @@ public class VisibleMemberMap {
private AnnotationTypeElementDoc[] filter(AnnotationTypeDoc doc,
boolean required) {
AnnotationTypeElementDoc[] members = doc.elements();
List<AnnotationTypeElementDoc> targetMembers = new ArrayList<AnnotationTypeElementDoc>();
List<AnnotationTypeElementDoc> targetMembers = new ArrayList<>();
for (AnnotationTypeElementDoc member : members) {
if ((required && member.defaultValue() == null) ||
((!required) && member.defaultValue() != null)) {
@ -534,7 +531,7 @@ public class VisibleMemberMap {
return propertiesCache.get(cd);
}
final List<MethodDoc> result = new ArrayList<MethodDoc>();
final List<MethodDoc> result = new ArrayList<>();
for (final MethodDoc propertyMethod : allMethods) {

View File

@ -306,7 +306,7 @@ public class DocLint implements Plugin {
}
}
Queue<CompilationUnitTree> todo = new LinkedList<CompilationUnitTree>();
Queue<CompilationUnitTree> todo = new LinkedList<>();
};
task.addTaskListener(tl);

View File

@ -312,8 +312,8 @@ public enum Entity {
return codes.containsKey(code) || ( 32 <= code && code < 2127);
}
private static final Map<String,Entity> names = new HashMap<String,Entity>();
private static final Map<Integer,Entity> codes = new HashMap<Integer,Entity>();
private static final Map<String,Entity> names = new HashMap<>();
private static final Map<Integer,Entity> codes = new HashMap<>();
static {
for (Entity e: values()) {
String name = e.name();

View File

@ -81,7 +81,7 @@ public class Env {
else
return AccessKind.PACKAGE;
}
};
}
/** Message handler. */
final Messages messages;
@ -140,7 +140,7 @@ public class Env {
}
void setCustomTags(String cTags) {
customTags = new LinkedHashSet<String>();
customTags = new LinkedHashSet<>();
for (String s : cTags.split(DocLint.TAGS_SEPARATOR)) {
if (!s.isEmpty())
customTags.add(s);

View File

@ -291,7 +291,7 @@ public enum HtmlTag {
INLINE,
LIST_ITEM,
TABLE_ITEM,
OTHER;
OTHER
}
/**
@ -300,7 +300,7 @@ public enum HtmlTag {
public static enum EndKind {
NONE,
OPTIONAL,
REQUIRED;
REQUIRED
}
public static enum Flag {
@ -356,7 +356,7 @@ public enum HtmlTag {
return StringUtils.toLowerCase(name());
}
static final Map<String,Attr> index = new HashMap<String,Attr>();
static final Map<String,Attr> index = new HashMap<>();
static {
for (Attr t: values()) {
index.put(t.getText(), t);
@ -394,7 +394,7 @@ public enum HtmlTag {
this.blockType = blockType;
this.endKind = endKind;
this.flags = flags;
this.attrs = new EnumMap<Attr,AttrKind>(Attr.class);
this.attrs = new EnumMap<>(Attr.class);
for (Map<Attr,AttrKind> m: attrMaps)
this.attrs.putAll(m);
attrs.put(Attr.CLASS, AttrKind.OK);
@ -450,7 +450,7 @@ public enum HtmlTag {
return map;
}
private static final Map<String,HtmlTag> index = new HashMap<String,HtmlTag>();
private static final Map<String,HtmlTag> index = new HashMap<>();
static {
for (HtmlTag t: values()) {
index.put(t.getText(), t);

View File

@ -76,7 +76,7 @@ public class Messages {
if (opt.equals(g.optName())) return true;
return false;
}
};
}
private final Options options;
private final Stats stats;
@ -154,7 +154,7 @@ public class Messages {
* Handler for (sub)options specific to message handling.
*/
static class Options {
Map<String, Env.AccessKind> map = new HashMap<String, Env.AccessKind>();
Map<String, Env.AccessKind> map = new HashMap<>();
private final Stats stats;
static boolean isValidOptions(String opts) {
@ -256,7 +256,7 @@ public class Messages {
if (b) {
groupCounts = new int[Messages.Group.values().length];
dkindCounts = new int[Diagnostic.Kind.values().length];
codeCounts = new HashMap<String, Integer>();
codeCounts = new HashMap<>();
} else {
groupCounts = null;
dkindCounts = null;
@ -321,7 +321,7 @@ public class Messages {
return o2.compareTo(o1);
}
};
private final TreeMap<Integer, Set<String>> map = new TreeMap<Integer, Set<String>>(DECREASING);
private final TreeMap<Integer, Set<String>> map = new TreeMap<>(DECREASING);
void put(String label, int n) {
if (n == 0) {
@ -329,7 +329,7 @@ public class Messages {
}
Set<String> labels = map.get(n);
if (labels == null) {
map.put(n, labels = new TreeSet<String>());
map.put(n, labels = new TreeSet<>());
}
labels.add(label);
}

View File

@ -107,7 +107,7 @@ public class ClientCodeWrapper {
Map<Class<?>, Boolean> trustedClasses;
protected ClientCodeWrapper(Context context) {
trustedClasses = new HashMap<Class<?>, Boolean>();
trustedClasses = new HashMap<>();
}
public JavaFileManager wrap(JavaFileManager fm) {
@ -136,7 +136,7 @@ public class ClientCodeWrapper {
}
public Iterable<JavaFileObject> wrapJavaFileObjects(Iterable<? extends JavaFileObject> list) {
List<JavaFileObject> wrapped = new ArrayList<JavaFileObject>();
List<JavaFileObject> wrapped = new ArrayList<>();
for (JavaFileObject fo : list)
wrapped.add(wrap(fo));
return Collections.unmodifiableList(wrapped);
@ -152,7 +152,7 @@ public class ClientCodeWrapper {
public <T /*super JavaFileOject*/> DiagnosticListener<T> wrap(DiagnosticListener<T> dl) {
if (isTrusted(dl))
return dl;
return new WrappedDiagnosticListener<T>(dl);
return new WrappedDiagnosticListener<>(dl);
}
TaskListener wrap(TaskListener tl) {
@ -169,7 +169,7 @@ public class ClientCodeWrapper {
}
Collection<TaskListener> unwrap(Collection<? extends TaskListener> listeners) {
Collection<TaskListener> c = new ArrayList<TaskListener>(listeners.size());
Collection<TaskListener> c = new ArrayList<>(listeners.size());
for (TaskListener l: listeners)
c.add(unwrap(l));
return c;

View File

@ -176,7 +176,7 @@ public interface DiagnosticFormatter<D extends Diagnostic<?>> {
/**
* JLS paragraph this diagnostic might refer to (if applicable).
*/
JLS;
JLS
}
/**
@ -212,7 +212,7 @@ public interface DiagnosticFormatter<D extends Diagnostic<?>> {
* Controls the maximum amount of subdiagnostics that are part of a
* given multiline diagnostic.
*/
LENGTH;
LENGTH
}
}
}

View File

@ -105,7 +105,7 @@ public class JavacTaskImpl extends BasicJavacTask {
}
static private String[] toArray(Iterable<String> iter) {
ListBuffer<String> result = new ListBuffer<String>();
ListBuffer<String> result = new ListBuffer<>();
if (iter != null)
for (String s : iter)
result.append(s);
@ -115,7 +115,7 @@ public class JavacTaskImpl extends BasicJavacTask {
static private List<JavaFileObject> toList(Iterable<? extends JavaFileObject> fileObjects) {
if (fileObjects == null)
return List.nil();
ListBuffer<JavaFileObject> result = new ListBuffer<JavaFileObject>();
ListBuffer<JavaFileObject> result = new ListBuffer<>();
for (JavaFileObject fo : fileObjects)
result.append(fo);
return result.toList();
@ -124,7 +124,7 @@ public class JavacTaskImpl extends BasicJavacTask {
public Main.Result doCall() {
if (!used.getAndSet(true)) {
initContext();
notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
notYetEntered = new HashMap<>();
compilerMain.setAPIMode(true);
result = compilerMain.compile(args, classNames, context, fileObjects, processors);
cleanup();
@ -160,7 +160,7 @@ public class JavacTaskImpl extends BasicJavacTask {
initContext();
compilerMain.log = Log.instance(context);
compilerMain.setOptions(Options.instance(context));
compilerMain.filenames = new LinkedHashSet<File>();
compilerMain.filenames = new LinkedHashSet<>();
Collection<File> filenames = compilerMain.processArgs(CommandLine.parse(args), classNames);
if (filenames != null && !filenames.isEmpty())
throw new IllegalArgumentException("Malformed arguments " + toString(filenames, " "));
@ -169,10 +169,10 @@ public class JavacTaskImpl extends BasicJavacTask {
compiler.genEndPos = true;
// NOTE: this value will be updated after annotation processing
compiler.initProcessAnnotations(processors);
notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
notYetEntered = new HashMap<>();
for (JavaFileObject file: fileObjects)
notYetEntered.put(file, null);
genList = new ListBuffer<Env<AttrContext>>();
genList = new ListBuffer<>();
// endContext will be called when all classes have been generated
// TODO: should handle the case after each phase if errors have occurred
args = null;
@ -289,7 +289,7 @@ public class JavacTaskImpl extends BasicJavacTask {
JCCompilationUnit unit = notYetEntered.remove(file);
if (unit != null) {
if (roots == null)
roots = new ListBuffer<JCCompilationUnit>();
roots = new ListBuffer<>();
roots.append(unit);
}
}
@ -300,7 +300,7 @@ public class JavacTaskImpl extends BasicJavacTask {
for (CompilationUnitTree cu : trees) {
if (cu instanceof JCCompilationUnit) {
if (roots == null)
roots = new ListBuffer<JCCompilationUnit>();
roots = new ListBuffer<>();
roots.append((JCCompilationUnit)cu);
notYetEntered.remove(cu.getSourceFile());
}
@ -318,7 +318,7 @@ public class JavacTaskImpl extends BasicJavacTask {
if (notYetEntered.isEmpty())
compiler = compiler.processAnnotations(units);
ListBuffer<TypeElement> elements = new ListBuffer<TypeElement>();
ListBuffer<TypeElement> elements = new ListBuffer<>();
for (JCCompilationUnit unit : units) {
for (JCTree node : unit.defs) {
if (node.hasTag(JCTree.Tag.CLASSDEF)) {
@ -358,7 +358,7 @@ public class JavacTaskImpl extends BasicJavacTask {
public Iterable<? extends Element> analyze(Iterable<? extends TypeElement> classes) throws IOException {
enter(null); // ensure all classes have been entered
final ListBuffer<Element> results = new ListBuffer<Element>();
final ListBuffer<Element> results = new ListBuffer<>();
try {
if (classes == null) {
handleFlowResults(compiler.flow(compiler.attribute(compiler.todo)), results);
@ -414,7 +414,7 @@ public class JavacTaskImpl extends BasicJavacTask {
* @param classes a list of class elements
*/
public Iterable<? extends JavaFileObject> generate(Iterable<? extends TypeElement> classes) throws IOException {
final ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>();
final ListBuffer<JavaFileObject> results = new ListBuffer<>();
try {
analyze(null); // ensure all classes have been parsed, entered, and analyzed
@ -468,7 +468,7 @@ public class JavacTaskImpl extends BasicJavacTask {
abstract class Filter {
void run(Queue<Env<AttrContext>> list, Iterable<? extends TypeElement> classes) {
Set<TypeElement> set = new HashSet<TypeElement>();
Set<TypeElement> set = new HashSet<>();
for (TypeElement item: classes)
set.add(item);

View File

@ -398,7 +398,7 @@ public class JavacTrees extends DocTrees {
if (ref.paramTypes == null)
paramTypes = null;
else {
ListBuffer<Type> lb = new ListBuffer<Type>();
ListBuffer<Type> lb = new ListBuffer<>();
for (List<JCTree> l = ref.paramTypes; l.nonEmpty(); l = l.tail) {
JCTree tree = l.head;
Type t = attr.attribType(tree, env);
@ -459,7 +459,7 @@ public class JavacTrees extends DocTrees {
/** @see com.sun.tools.javadoc.ClassDocImpl#findField */
private VarSymbol findField(ClassSymbol tsym, Name fieldName) {
return searchField(tsym, fieldName, new HashSet<ClassSymbol>());
return searchField(tsym, fieldName, new HashSet<>());
}
/** @see com.sun.tools.javadoc.ClassDocImpl#searchField */
@ -525,7 +525,7 @@ public class JavacTrees extends DocTrees {
/** @see com.sun.tools.javadoc.ClassDocImpl#findMethod */
private MethodSymbol findMethod(ClassSymbol tsym, Name methodName, List<Type> paramTypes) {
return searchMethod(tsym, methodName, paramTypes, new HashSet<ClassSymbol>());
return searchMethod(tsym, methodName, paramTypes, new HashSet<>());
}
/** @see com.sun.tools.javadoc.ClassDocImpl#searchMethod */

View File

@ -42,8 +42,7 @@ import com.sun.tools.javac.util.Context;
*/
public class MultiTaskListener implements TaskListener {
/** The context key for the MultiTaskListener. */
public static final Context.Key<MultiTaskListener> taskListenerKey =
new Context.Key<MultiTaskListener>();
public static final Context.Key<MultiTaskListener> taskListenerKey = new Context.Key<>();
/** Get the MultiTaskListener instance for this context. */
public static MultiTaskListener instance(Context context) {

View File

@ -115,7 +115,7 @@ public class WrappingJavaFileManager<M extends JavaFileManager> extends Forwardi
* @return the mapping
*/
protected Iterable<JavaFileObject> wrap(Iterable<JavaFileObject> fileObjects) {
List<JavaFileObject> mapped = new ArrayList<JavaFileObject>();
List<JavaFileObject> mapped = new ArrayList<>();
for (JavaFileObject fileObject : fileObjects)
mapped.add(wrap(fileObject));
return Collections.unmodifiableList(mapped);

View File

@ -64,7 +64,7 @@ public abstract class Attribute implements AnnotationValue {
return false;
}
public TypeAnnotationPosition getPosition() { return null; };
public TypeAnnotationPosition getPosition() { return null; }
/** The value for an annotation element of primitive type or String. */
public static class Constant extends Attribute {
@ -226,8 +226,7 @@ public abstract class Attribute implements AnnotationValue {
}
public Map<MethodSymbol, Attribute> getElementValues() {
Map<MethodSymbol, Attribute> valmap =
new LinkedHashMap<MethodSymbol, Attribute>();
Map<MethodSymbol, Attribute> valmap = new LinkedHashMap<>();
for (Pair<MethodSymbol, Attribute> value : values)
valmap.put(value.fst, value.snd);
return valmap;

View File

@ -43,8 +43,7 @@ import com.sun.tools.javac.util.ListBuffer;
* deletion without notice.</b>
*/
public class DeferredLintHandler {
protected static final Context.Key<DeferredLintHandler> deferredLintHandlerKey =
new Context.Key<DeferredLintHandler>();
protected static final Context.Key<DeferredLintHandler> deferredLintHandlerKey = new Context.Key<>();
public static DeferredLintHandler instance(Context context) {
DeferredLintHandler instance = context.get(deferredLintHandlerKey);
@ -67,7 +66,7 @@ public class DeferredLintHandler {
}
private DiagnosticPosition currentPos;
private Map<DiagnosticPosition, ListBuffer<LintLogger>> loggersQueue = new HashMap<DiagnosticPosition, ListBuffer<LintLogger>>();
private Map<DiagnosticPosition, ListBuffer<LintLogger>> loggersQueue = new HashMap<>();
/**Associate the given logger with the current position as set by {@link #setPos(DiagnosticPosition) }.
* Will be invoked when {@link #flush(DiagnosticPosition) } will be invoked with the same position.

View File

@ -29,6 +29,7 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.lang.model.element.Modifier;
@ -322,8 +323,7 @@ public class Flags {
}
// Cache of modifier sets.
private static final Map<Long, Set<Modifier>> modifierSets =
new java.util.concurrent.ConcurrentHashMap<Long, Set<Modifier>>(64);
private static final Map<Long, Set<Modifier>> modifierSets = new ConcurrentHashMap<>(64);
public static boolean isStatic(Symbol symbol) {
return (symbol.flags() & STATIC) != 0;

View File

@ -27,6 +27,8 @@ package com.sun.tools.javac.code;
import java.util.EnumSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
@ -44,7 +46,7 @@ import com.sun.tools.javac.util.Pair;
public class Lint
{
/** The context key for the root Lint object. */
protected static final Context.Key<Lint> lintKey = new Context.Key<Lint>();
protected static final Context.Key<Lint> lintKey = new Context.Key<>();
/** Get the root Lint instance. */
public static Lint instance(Context context) {
@ -83,8 +85,7 @@ public class Lint
private final EnumSet<LintCategory> values;
private final EnumSet<LintCategory> suppressedValues;
private static final Map<String, LintCategory> map =
new java.util.concurrent.ConcurrentHashMap<String, LintCategory>(20);
private static final Map<String, LintCategory> map = new ConcurrentHashMap<>(20);
protected Lint(Context context) {
// initialize values according to the lint options
@ -242,7 +243,7 @@ public class Lint
public final String option;
public final boolean hidden;
};
}
/**
* Checks if a warning category is enabled. A warning category may be enabled
@ -341,5 +342,5 @@ public class Lint
public void visitError(Attribute.Error e) {
}
};
}
}

View File

@ -73,8 +73,7 @@ public enum Source {
/** 1.9 covers the to be determined language features that will be added in JDK 9. */
JDK1_9("1.9");
private static final Context.Key<Source> sourceKey
= new Context.Key<Source>();
private static final Context.Key<Source> sourceKey = new Context.Key<>();
public static Source instance(Context context) {
Source instance = context.get(sourceKey);

View File

@ -1541,7 +1541,7 @@ public abstract class Symbol extends AnnoConstruct implements Element {
if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
paramNames = List.nil();
}
ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
ListBuffer<VarSymbol> buf = new ListBuffer<>();
List<Name> remaining = paramNames;
// assert: remaining and paramNames are both empty or both
// have same cardinality as type.getParameterTypes()

View File

@ -180,7 +180,7 @@ public class SymbolMetadata {
// are introduced, because PlaceHolder is a subtype of TypeCompound.
T res;
@SuppressWarnings("unchecked")
T ph = (T) new Placeholder<T>(ctx, lb.toList(), sym);
T ph = (T) new Placeholder<>(ctx, lb.toList(), sym);
res = ph;
buf = buf.prepend(res);
atLeastOneRepeated = true;
@ -244,7 +244,7 @@ public class SymbolMetadata {
attributes = filterDeclSentinels(attributes);
if (l.isEmpty()) {
; // no-op
// no-op
} else if (attributes.isEmpty()) {
attributes = l;
} else {
@ -255,7 +255,7 @@ public class SymbolMetadata {
public SymbolMetadata appendUniqueTypes(List<Attribute.TypeCompound> l) {
if (l.isEmpty()) {
; // no-op
// no-op
} else if (type_attributes.isEmpty()) {
type_attributes = l;
} else {
@ -271,7 +271,7 @@ public class SymbolMetadata {
public SymbolMetadata appendInitTypeAttributes(List<Attribute.TypeCompound> l) {
if (l.isEmpty()) {
; // no-op
// no-op
} else if (init_type_attributes.isEmpty()) {
init_type_attributes = l;
} else {
@ -282,7 +282,7 @@ public class SymbolMetadata {
public SymbolMetadata appendClassInitTypeAttributes(List<Attribute.TypeCompound> l) {
if (l.isEmpty()) {
; // no-op
// no-op
} else if (clinit_type_attributes.isEmpty()) {
clinit_type_attributes = l;
} else {
@ -295,7 +295,7 @@ public class SymbolMetadata {
attributes = filterDeclSentinels(attributes);
if (l.isEmpty()) {
; // no-op
// no-op
} else if (attributes.isEmpty()) {
attributes = l;
} else {

View File

@ -51,8 +51,7 @@ import static com.sun.tools.javac.code.TypeTag.*;
*/
public class Symtab {
/** The context key for the symbol table. */
protected static final Context.Key<Symtab> symtabKey =
new Context.Key<Symtab>();
protected static final Context.Key<Symtab> symtabKey = new Context.Key<>();
/** Get the symbol table instance. */
public static Symtab instance(Context context) {
@ -190,20 +189,20 @@ public class Symtab {
/** A set containing all operator names.
*/
public final Set<Name> operatorNames = new HashSet<Name>();
public final Set<Name> operatorNames = new HashSet<>();
/** A hashtable containing the encountered top-level and member classes,
* indexed by flat names. The table does not contain local classes.
* It should be updated from the outside to reflect classes defined
* by compiled source files.
*/
public final Map<Name, ClassSymbol> classes = new HashMap<Name, ClassSymbol>();
public final Map<Name, ClassSymbol> classes = new HashMap<>();
/** A hashtable containing the encountered packages.
* the table should be updated from outside to reflect packages defined
* by compiled source files.
*/
public final Map<Name, PackageSymbol> packages = new HashMap<Name, PackageSymbol>();
public final Map<Name, PackageSymbol> packages = new HashMap<>();
public void initType(Type type, ClassSymbol c) {
type.tsym = c;

View File

@ -1450,7 +1450,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
/** lower bounds */
LOWER,
/** equality constraints */
EQ;
EQ
}
/** inference variable bounds */
@ -1472,7 +1472,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public UndetVar(TypeVar origin, Types types) {
super(UNDETVAR, origin);
bounds = new EnumMap<InferenceBound, List<Type>>(InferenceBound.class);
bounds = new EnumMap<>(InferenceBound.class);
List<Type> declaredBounds = types.getBounds(origin);
declaredCount = declaredBounds.length();
bounds.put(InferenceBound.UPPER, declaredBounds);

View File

@ -82,8 +82,7 @@ import com.sun.tools.javac.util.Options;
* and determine the TypeAnnotationPositions for all type annotations.
*/
public class TypeAnnotations {
protected static final Context.Key<TypeAnnotations> typeAnnosKey =
new Context.Key<TypeAnnotations>();
protected static final Context.Key<TypeAnnotations> typeAnnosKey = new Context.Key<>();
public static TypeAnnotations instance(Context context) {
TypeAnnotations instance = context.get(typeAnnosKey);
@ -155,7 +154,7 @@ public class TypeAnnotations {
new TypeAnnotationPositions(false).scan(tree);
}
public enum AnnotationType { DECLARATION, TYPE, BOTH };
public enum AnnotationType { DECLARATION, TYPE, BOTH }
/**
* Determine whether an annotation is a declaration annotation,
@ -286,9 +285,9 @@ public class TypeAnnotations {
private void separateAnnotationsKinds(JCTree typetree, Type type, Symbol sym,
TypeAnnotationPosition pos) {
List<Attribute.Compound> annotations = sym.getRawAttributes();
ListBuffer<Attribute.Compound> declAnnos = new ListBuffer<Attribute.Compound>();
ListBuffer<Attribute.TypeCompound> typeAnnos = new ListBuffer<Attribute.TypeCompound>();
ListBuffer<Attribute.TypeCompound> onlyTypeAnnos = new ListBuffer<Attribute.TypeCompound>();
ListBuffer<Attribute.Compound> declAnnos = new ListBuffer<>();
ListBuffer<Attribute.TypeCompound> typeAnnos = new ListBuffer<>();
ListBuffer<Attribute.TypeCompound> onlyTypeAnnos = new ListBuffer<>();
for (Attribute.Compound a : annotations) {
switch (annotationType(a, sym)) {
@ -351,7 +350,7 @@ public class TypeAnnotations {
MethodType methType = sym.owner.type.asMethodType();
List<VarSymbol> params = ((MethodSymbol)sym.owner).params;
List<Type> oldArgs = methType.argtypes;
ListBuffer<Type> newArgs = new ListBuffer<Type>();
ListBuffer<Type> newArgs = new ListBuffer<>();
while (params.nonEmpty()) {
if (params.head == sym) {
newArgs.add(type);
@ -1224,8 +1223,7 @@ public class TypeAnnotations {
private void copyNewClassAnnotationsToOwner(JCNewClass tree) {
Symbol sym = tree.def.sym;
TypeAnnotationPosition pos = new TypeAnnotationPosition();
ListBuffer<Attribute.TypeCompound> newattrs =
new ListBuffer<Attribute.TypeCompound>();
ListBuffer<Attribute.TypeCompound> newattrs = new ListBuffer<>();
for (Attribute.TypeCompound old : sym.getRawTypeAttributes()) {
newattrs.append(new Attribute.TypeCompound(old.type, old.values,

View File

@ -75,8 +75,7 @@ import static com.sun.tools.javac.jvm.ClassFile.externalize;
* deletion without notice.</b>
*/
public class Types {
protected static final Context.Key<Types> typesKey =
new Context.Key<Types>();
protected static final Context.Key<Types> typesKey = new Context.Key<>();
final Symtab syms;
final JavacMessages messages;
@ -247,8 +246,8 @@ public class Types {
Type base = asSuper(sym.type, t.tsym);
if (base == null)
return null;
ListBuffer<Type> from = new ListBuffer<Type>();
ListBuffer<Type> to = new ListBuffer<Type>();
ListBuffer<Type> from = new ListBuffer<>();
ListBuffer<Type> to = new ListBuffer<>();
try {
adapt(base, t, from, to);
} catch (AdaptFailure ex) {
@ -257,7 +256,7 @@ public class Types {
Type res = subst(sym.type, from.toList(), to.toList());
if (!isSubtype(res, t))
return null;
ListBuffer<Type> openVars = new ListBuffer<Type>();
ListBuffer<Type> openVars = new ListBuffer<>();
for (List<Type> l = sym.type.allparams();
l.nonEmpty(); l = l.tail)
if (res.contains(l.head) && !t.contains(l.head))
@ -269,7 +268,7 @@ public class Types {
} else {
// Unbound type arguments default to ?
List<Type> opens = openVars.toList();
ListBuffer<Type> qs = new ListBuffer<Type>();
ListBuffer<Type> qs = new ListBuffer<>();
for (List<Type> iter = opens; iter.nonEmpty(); iter = iter.tail) {
qs.append(new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass, (TypeVar) iter.head.unannotatedType()));
}
@ -347,7 +346,7 @@ public class Types {
*/
class DescriptorCache {
private WeakHashMap<TypeSymbol, Entry> _map = new WeakHashMap<TypeSymbol, Entry>();
private WeakHashMap<TypeSymbol, Entry> _map = new WeakHashMap<>();
class FunctionDescriptor {
Symbol descSym;
@ -727,7 +726,7 @@ public class Types {
!overridesObjectMethod(origin, sym) &&
(interfaceCandidates(origin.type, (MethodSymbol)sym).head.flags() & DEFAULT) == 0;
}
};
}
// <editor-fold defaultstate="collapsed" desc="isSubtype">
/**
@ -864,7 +863,7 @@ public class Types {
}
}
private Set<TypePair> cache = new HashSet<TypePair>();
private Set<TypePair> cache = new HashSet<>();
private boolean containsTypeRecursive(Type t, Type s) {
TypePair pair = new TypePair(t, s);
@ -1144,7 +1143,7 @@ public class Types {
if (!visit(supertype(t), supertype(s)))
return false;
HashSet<UniqueType> set = new HashSet<UniqueType>();
HashSet<UniqueType> set = new HashSet<>();
for (Type x : interfaces(t))
set.add(new UniqueType(x.unannotatedType(), Types.this));
for (Type x : interfaces(s)) {
@ -1232,9 +1231,9 @@ public class Types {
protected boolean containsTypes(List<Type> ts1, List<Type> ts2) {
return containsTypeEquivalent(ts1, ts2);
}
};
}
/**
/**
* Strict type-equality relation - type variables are considered
* equals if they share the same object identity.
*/
@ -1707,7 +1706,7 @@ public class Types {
// where
private TypeRelation disjointType = new TypeRelation() {
private Set<TypePair> cache = new HashSet<TypePair>();
private Set<TypePair> cache = new HashSet<>();
@Override
public Boolean visitType(Type t, Type s) {
@ -2446,7 +2445,7 @@ public class Types {
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="isDerivedRaw">
Map<Type,Boolean> isDerivedRawCache = new HashMap<Type,Boolean>();
Map<Type,Boolean> isDerivedRawCache = new HashMap<>();
public boolean isDerivedRaw(Type t) {
Boolean result = isDerivedRawCache.get(t);
@ -2608,8 +2607,7 @@ public class Types {
// <editor-fold defaultstate="collapsed" desc="Determining method implementation in given site">
class ImplementationCache {
private WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, Entry>>> _map =
new WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, Entry>>>();
private WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, Entry>>> _map = new WeakHashMap<>();
class Entry {
final MethodSymbol cachedImpl;
@ -2638,8 +2636,8 @@ public class Types {
SoftReference<Map<TypeSymbol, Entry>> ref_cache = _map.get(ms);
Map<TypeSymbol, Entry> cache = ref_cache != null ? ref_cache.get() : null;
if (cache == null) {
cache = new HashMap<TypeSymbol, Entry>();
_map.put(ms, new SoftReference<Map<TypeSymbol, Entry>>(cache));
cache = new HashMap<>();
_map.put(ms, new SoftReference<>(cache));
}
Entry e = cache.get(origin);
CompoundScope members = membersClosure(origin.type, true);
@ -2681,8 +2679,7 @@ public class Types {
// <editor-fold defaultstate="collapsed" desc="compute transitive closure of all members in given site">
class MembersClosureCache extends SimpleVisitor<CompoundScope, Boolean> {
private WeakHashMap<TypeSymbol, Entry> _map =
new WeakHashMap<TypeSymbol, Entry>();
private WeakHashMap<TypeSymbol, Entry> _map = new WeakHashMap<>();
class Entry {
final boolean skipInterfaces;
@ -2800,7 +2797,7 @@ public class Types {
s.isInheritedIn(site.tsym, Types.this) &&
overrideEquivalent(memberType(site, s), memberType(site, msym));
}
};
}
// </editor-fold>
/**
@ -2856,9 +2853,9 @@ public class Types {
public Boolean visitErrorType(ErrorType t, Type s) {
return false;
}
};
}
TypeRelation hasSameArgs_strict = new HasSameArgs(true);
TypeRelation hasSameArgs_strict = new HasSameArgs(true);
TypeRelation hasSameArgs_nonstrict = new HasSameArgs(false);
// </editor-fold>
@ -3301,7 +3298,7 @@ public class Types {
* (that is, subclasses come first, arbitrary but fixed
* otherwise).
*/
private Map<Type,List<Type>> closureCache = new HashMap<Type,List<Type>>();
private Map<Type,List<Type>> closureCache = new HashMap<>();
/**
* Returns the closure of a class or interface type.
@ -3404,13 +3401,13 @@ public class Types {
&& isSameType(t2, typePair.t2);
}
}
Set<TypePair> mergeCache = new HashSet<TypePair>();
Set<TypePair> mergeCache = new HashSet<>();
private Type merge(Type c1, Type c2) {
ClassType class1 = (ClassType) c1;
List<Type> act1 = class1.getTypeArguments();
ClassType class2 = (ClassType) c2;
List<Type> act2 = class2.getTypeArguments();
ListBuffer<Type> merged = new ListBuffer<Type>();
ListBuffer<Type> merged = new ListBuffer<>();
List<Type> typarams = class1.tsym.type.getTypeArguments();
while (act1.nonEmpty() && act2.nonEmpty() && typarams.nonEmpty()) {
@ -4090,7 +4087,7 @@ public class Types {
Adapter(ListBuffer<Type> from, ListBuffer<Type> to) {
this.from = from;
this.to = to;
mapping = new HashMap<Symbol,Type>();
mapping = new HashMap<>();
}
public void adapt(Type source, Type target) throws AdaptFailure {
@ -4159,7 +4156,7 @@ public class Types {
return null;
}
private Set<TypePair> cache = new HashSet<TypePair>();
private Set<TypePair> cache = new HashSet<>();
private void adaptRecursive(Type source, Type target) {
TypePair pair = new TypePair(source, target);
@ -4233,7 +4230,7 @@ public class Types {
@Override
public Type visitClassType(ClassType t, Void s) {
ListBuffer<Type> rewritten = new ListBuffer<Type>();
ListBuffer<Type> rewritten = new ListBuffer<>();
boolean changed = false;
for (Type arg : t.allparams()) {
Type bound = visit(arg);

View File

@ -49,8 +49,7 @@ import javax.lang.model.type.ErrorType;
* deletion without notice.</b>
*/
public class Annotate {
protected static final Context.Key<Annotate> annotateKey =
new Context.Key<Annotate>();
protected static final Context.Key<Annotate> annotateKey = new Context.Key<>();
public static Annotate instance(Context context) {
Annotate instance = context.get(annotateKey);
@ -88,11 +87,11 @@ public class Annotate {
private int enterCount = 0;
ListBuffer<Worker> q = new ListBuffer<Worker>();
ListBuffer<Worker> typesQ = new ListBuffer<Worker>();
ListBuffer<Worker> repeatedQ = new ListBuffer<Worker>();
ListBuffer<Worker> afterRepeatedQ = new ListBuffer<Worker>();
ListBuffer<Worker> validateQ = new ListBuffer<Worker>();
ListBuffer<Worker> q = new ListBuffer<>();
ListBuffer<Worker> typesQ = new ListBuffer<>();
ListBuffer<Worker> repeatedQ = new ListBuffer<>();
ListBuffer<Worker> afterRepeatedQ = new ListBuffer<>();
ListBuffer<Worker> validateQ = new ListBuffer<>();
public void earlier(Worker a) {
q.prepend(a);
@ -352,7 +351,7 @@ public class Annotate {
if (na.elemtype != null) {
log.error(na.elemtype.pos(), "new.not.allowed.in.annotation");
}
ListBuffer<Attribute> buf = new ListBuffer<Attribute>();
ListBuffer<Attribute> buf = new ListBuffer<>();
for (List<JCExpression> l = na.elems; l.nonEmpty(); l=l.tail) {
buf.append(enterAttributeValue(types.elemtype(expected),
l.head,
@ -509,8 +508,8 @@ public class Annotate {
repeated = repeated.reverse();
TreeMaker m = make.at(ctx.pos.get(firstOccurrence));
Pair<MethodSymbol, Attribute> p =
new Pair<MethodSymbol, Attribute>(containerValueSymbol,
new Attribute.Array(arrayOfOrigAnnoType, repeated));
new Pair<>(containerValueSymbol,
new Attribute.Array(arrayOfOrigAnnoType, repeated));
if (ctx.isTypeCompound) {
/* TODO: the following code would be cleaner:
Attribute.TypeCompound at = new Attribute.TypeCompound(targetContainerType, List.of(p),

View File

@ -73,8 +73,7 @@ import static com.sun.tools.javac.tree.JCTree.Tag.*;
* deletion without notice.</b>
*/
public class Attr extends JCTree.Visitor {
protected static final Context.Key<Attr> attrKey =
new Context.Key<Attr>();
protected static final Context.Key<Attr> attrKey = new Context.Key<>();
final Names names;
final Log log;
@ -668,7 +667,7 @@ public class Attr extends JCTree.Visitor {
/** Attribute a list of expressions, returning a list of types.
*/
List<Type> attribExprs(List<JCExpression> trees, Env<AttrContext> env, Type pt) {
ListBuffer<Type> ts = new ListBuffer<Type>();
ListBuffer<Type> ts = new ListBuffer<>();
for (List<JCExpression> l = trees; l.nonEmpty(); l = l.tail)
ts.append(attribExpr(l.head, env, pt));
return ts.toList();
@ -702,7 +701,7 @@ public class Attr extends JCTree.Visitor {
* Caller is responsible for calling checkRefTypes.
*/
List<Type> attribAnyTypes(List<JCExpression> trees, Env<AttrContext> env) {
ListBuffer<Type> argtypes = new ListBuffer<Type>();
ListBuffer<Type> argtypes = new ListBuffer<>();
for (List<JCExpression> l = trees; l.nonEmpty(); l = l.tail)
argtypes.append(attribType(l.head, env));
return argtypes.toList();
@ -1238,7 +1237,7 @@ public class Attr extends JCTree.Visitor {
// Attribute all cases and
// check that there are no duplicate case labels or default clauses.
Set<Object> labels = new HashSet<Object>(); // The set of case labels.
Set<Object> labels = new HashSet<>(); // The set of case labels.
boolean hasDefault = false; // Is there a default label?
for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
JCCase c = l.head;
@ -3815,7 +3814,7 @@ public class Attr extends JCTree.Visitor {
Resolve.InapplicableSymbolError errSym = rs.new InapplicableSymbolError(null) {
@Override
protected Pair<Symbol, JCDiagnostic> errCandidate() {
return new Pair<Symbol, JCDiagnostic>(sym, diag);
return new Pair<>(sym, diag);
}
};
List<Type> argtypes2 = Type.map(argtypes,
@ -3968,7 +3967,7 @@ public class Attr extends JCTree.Visitor {
}
Type checkIntersection(JCTree tree, List<JCExpression> bounds) {
Set<Type> boundSet = new HashSet<Type>();
Set<Type> boundSet = new HashSet<>();
if (bounds.nonEmpty()) {
// accept class or interface or typevar as first bound.
bounds.head.type = checkBase(bounds.head.type, bounds.head, env, false, false, false);
@ -4573,7 +4572,7 @@ public class Attr extends JCTree.Visitor {
if (at.getAnnotations().size() == 1) {
log.error(at.underlyingType.pos(), "cant.type.annotate.scoping.1", at.getAnnotations().head.attribute);
} else {
ListBuffer<Attribute.Compound> comps = new ListBuffer<Attribute.Compound>();
ListBuffer<Attribute.Compound> comps = new ListBuffer<>();
for (JCAnnotation an : at.getAnnotations()) {
comps.add(an.attribute);
}
@ -4634,7 +4633,7 @@ public class Attr extends JCTree.Visitor {
}
}
}
};
}
// <editor-fold desc="post-attribution visitor">

View File

@ -64,8 +64,7 @@ import static com.sun.tools.javac.tree.JCTree.Tag.*;
* deletion without notice.</b>
*/
public class Check {
protected static final Context.Key<Check> checkKey =
new Context.Key<Check>();
protected static final Context.Key<Check> checkKey = new Context.Key<>();
private final Names names;
private final Log log;
@ -191,7 +190,7 @@ public class Check {
/** A table mapping flat names of all compiled classes in this run to their
* symbols; maintained from outside.
*/
public Map<Name,ClassSymbol> compiled = new HashMap<Name, ClassSymbol>();
public Map<Name,ClassSymbol> compiled = new HashMap<>();
/** A handler for messages about deprecated usage.
*/
@ -937,7 +936,7 @@ public class Check {
List<Type> actuals = type.allparams();
List<Type> args = type.getTypeArguments();
List<Type> forms = type.tsym.type.getTypeArguments();
ListBuffer<Type> bounds_buf = new ListBuffer<Type>();
ListBuffer<Type> bounds_buf = new ListBuffer<>();
// For matching pairs of actual argument types `a' and
// formal type parameters with declared bound `b' ...
@ -1169,7 +1168,7 @@ public class Check {
boolean specialized;
SpecialTreeVisitor() {
this.specialized = false;
};
}
@Override
public void visitTree(JCTree tree) { /* no-op */ }
@ -1818,13 +1817,13 @@ public class Check {
* @returns symbol from t2 that conflicts with one in t1.
*/
private Symbol firstIncompatibility(DiagnosticPosition pos, Type t1, Type t2, Type site) {
Map<TypeSymbol,Type> interfaces1 = new HashMap<TypeSymbol,Type>();
Map<TypeSymbol,Type> interfaces1 = new HashMap<>();
closure(t1, interfaces1);
Map<TypeSymbol,Type> interfaces2;
if (t1 == t2)
interfaces2 = interfaces1;
else
closure(t2, interfaces1, interfaces2 = new HashMap<TypeSymbol,Type>());
closure(t2, interfaces1, interfaces2 = new HashMap<>());
for (Type t3 : interfaces1.values()) {
for (Type t4 : interfaces2.values()) {
@ -1904,7 +1903,7 @@ public class Check {
}
//WHERE
boolean checkCommonOverriderIn(Symbol s1, Symbol s2, Type site) {
Map<TypeSymbol,Type> supertypes = new HashMap<TypeSymbol,Type>();
Map<TypeSymbol,Type> supertypes = new HashMap<>();
Type st1 = types.memberType(site, s1);
Type st2 = types.memberType(site, s2);
closure(site, supertypes);
@ -2602,7 +2601,7 @@ public class Check {
* @param type The type whose interfaces are checked.
*/
void checkClassBounds(DiagnosticPosition pos, Type type) {
checkClassBounds(pos, new HashMap<TypeSymbol,Type>(), type);
checkClassBounds(pos, new HashMap<>(), type);
}
//where
/** Enter all interfaces of type `type' into the hash table `seensofar'
@ -2846,14 +2845,14 @@ public class Check {
if (containerTarget == null) {
containerTargets = getDefaultTargetSet();
} else {
containerTargets = new HashSet<Name>();
for (Attribute app : containerTarget.values) {
if (!(app instanceof Attribute.Enum)) {
continue; // recovery
containerTargets = new HashSet<>();
for (Attribute app : containerTarget.values) {
if (!(app instanceof Attribute.Enum)) {
continue; // recovery
}
Attribute.Enum e = (Attribute.Enum)app;
containerTargets.add(e.value.name);
}
Attribute.Enum e = (Attribute.Enum)app;
containerTargets.add(e.value.name);
}
}
Set<Name> containedTargets;
@ -2861,14 +2860,14 @@ public class Check {
if (containedTarget == null) {
containedTargets = getDefaultTargetSet();
} else {
containedTargets = new HashSet<Name>();
for (Attribute app : containedTarget.values) {
if (!(app instanceof Attribute.Enum)) {
continue; // recovery
containedTargets = new HashSet<>();
for (Attribute app : containedTarget.values) {
if (!(app instanceof Attribute.Enum)) {
continue; // recovery
}
Attribute.Enum e = (Attribute.Enum)app;
containedTargets.add(e.value.name);
}
Attribute.Enum e = (Attribute.Enum)app;
containedTargets.add(e.value.name);
}
}
if (!isTargetSubsetOf(containerTargets, containedTargets)) {
@ -2879,7 +2878,7 @@ public class Check {
/* get a set of names for the default target */
private Set<Name> getDefaultTargetSet() {
if (defaultTargets == null) {
Set<Name> targets = new HashSet<Name>();
Set<Name> targets = new HashSet<>();
targets.add(names.ANNOTATION_TYPE);
targets.add(names.CONSTRUCTOR);
targets.add(names.FIELD);
@ -3078,7 +3077,7 @@ public class Check {
private boolean validateAnnotation(JCAnnotation a) {
boolean isValid = true;
// collect an inventory of the annotation elements
Set<MethodSymbol> members = new LinkedHashSet<MethodSymbol>();
Set<MethodSymbol> members = new LinkedHashSet<>();
for (Scope.Entry e = a.annotationType.type.tsym.members().elems;
e != null;
e = e.sibling)
@ -3128,7 +3127,7 @@ public class Check {
JCTree rhs = assign.rhs;
if (!rhs.hasTag(NEWARRAY)) return false;
JCNewArray na = (JCNewArray) rhs;
Set<Symbol> targets = new HashSet<Symbol>();
Set<Symbol> targets = new HashSet<>();
for (JCTree elem : na.elems) {
if (!targets.add(TreeInfo.symbol(elem))) {
isValid = false;
@ -3246,7 +3245,7 @@ public class Check {
* constructors.
*/
void checkCyclicConstructors(JCClassDecl tree) {
Map<Symbol,Symbol> callMap = new HashMap<Symbol, Symbol>();
Map<Symbol,Symbol> callMap = new HashMap<>();
// enter each constructor this-call into the map
for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {

View File

@ -39,8 +39,7 @@ import com.sun.tools.javac.util.Context;
*/
public class CompileStates extends HashMap<Env<AttrContext>, CompileStates.CompileState> {
/** The context key for the compile states. */
protected static final Context.Key<CompileStates> compileStatesKey =
new Context.Key<CompileStates>();
protected static final Context.Key<CompileStates> compileStatesKey = new Context.Key<>();
/** Get the CompileStates instance for this context. */
public static CompileStates instance(Context context) {
@ -74,7 +73,7 @@ public class CompileStates extends HashMap<Env<AttrContext>, CompileStates.Compi
return a.value > b.value ? a : b;
}
private final int value;
};
}
private static final long serialVersionUID = 1812267524140424433L;

View File

@ -42,8 +42,7 @@ import static com.sun.tools.javac.jvm.ByteCodes.*;
* deletion without notice.</b>
*/
strictfp class ConstFold {
protected static final Context.Key<ConstFold> constFoldKey =
new Context.Key<ConstFold>();
protected static final Context.Key<ConstFold> constFoldKey = new Context.Key<>();
private Symtab syms;

View File

@ -63,8 +63,7 @@ import static com.sun.tools.javac.tree.JCTree.Tag.*;
* deletion without notice.</b>
*/
public class DeferredAttr extends JCTree.Visitor {
protected static final Context.Key<DeferredAttr> deferredAttrKey =
new Context.Key<DeferredAttr>();
protected static final Context.Key<DeferredAttr> deferredAttrKey = new Context.Key<>();
final Attr attr;
final Check chk;
@ -147,8 +146,7 @@ public class DeferredAttr extends JCTree.Visitor {
*/
class SpeculativeCache {
private Map<Symbol, List<Entry>> cache =
new WeakHashMap<Symbol, List<Entry>>();
private Map<Symbol, List<Entry>> cache = new WeakHashMap<>();
class Entry {
JCTree speculativeTree;
@ -335,7 +333,7 @@ public class DeferredAttr extends JCTree.Visitor {
/**
* This is the plain type-checking mode. Produces side-effects on the underlying AST node
*/
CHECK;
CHECK
}
/**
@ -345,7 +343,7 @@ public class DeferredAttr extends JCTree.Visitor {
* disabled during speculative type-checking.
*/
JCTree attribSpeculative(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
final JCTree newTree = new TreeCopier<Object>(make).copy(tree);
final JCTree newTree = new TreeCopier<>(make).copy(tree);
Env<AttrContext> speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared()));
speculativeEnv.info.scope.owner = env.info.scope.owner;
Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
@ -362,7 +360,7 @@ public class DeferredAttr extends JCTree.Visitor {
}
super.scan(tree);
}
};
}
PosScanner posScanner = new PosScanner();
posScanner.scan(newTree);
return posScanner.found;
@ -425,7 +423,7 @@ public class DeferredAttr extends JCTree.Visitor {
final Warner warn;
/** list of deferred attribution nodes to be processed */
ArrayList<DeferredAttrNode> deferredAttrNodes = new ArrayList<DeferredAttrNode>();
ArrayList<DeferredAttrNode> deferredAttrNodes = new ArrayList<>();
DeferredAttrContext(AttrMode mode, Symbol msym, MethodResolutionPhase phase,
InferenceContext inferenceContext, DeferredAttrContext parent, Warner warn) {
@ -454,7 +452,7 @@ public class DeferredAttr extends JCTree.Visitor {
*/
void complete() {
while (!deferredAttrNodes.isEmpty()) {
Map<Type, Set<Type>> depVarsMap = new LinkedHashMap<Type, Set<Type>>();
Map<Type, Set<Type>> depVarsMap = new LinkedHashMap<>();
List<Type> stuckVars = List.nil();
boolean progress = false;
//scan a defensive copy of the node list - this is because a deferred
@ -470,7 +468,7 @@ public class DeferredAttr extends JCTree.Visitor {
.intersect(inferenceContext.restvars())) {
Set<Type> prevDeps = depVarsMap.get(t);
if (prevDeps == null) {
prevDeps = new LinkedHashSet<Type>();
prevDeps = new LinkedHashSet<>();
depVarsMap.put(t, prevDeps);
}
prevDeps.addAll(restStuckVars);
@ -815,8 +813,8 @@ public class DeferredAttr extends JCTree.Visitor {
Type pt;
Infer.InferenceContext inferenceContext;
Set<Type> stuckVars = new LinkedHashSet<Type>();
Set<Type> depVars = new LinkedHashSet<Type>();
Set<Type> stuckVars = new LinkedHashSet<>();
Set<Type> depVars = new LinkedHashSet<>();
@Override
public boolean isStuck() {

View File

@ -90,8 +90,7 @@ import static com.sun.tools.javac.code.Kinds.*;
* deletion without notice.</b>
*/
public class Enter extends JCTree.Visitor {
protected static final Context.Key<Enter> enterKey =
new Context.Key<Enter>();
protected static final Context.Key<Enter> enterKey = new Context.Key<>();
Log log;
Symtab syms;
@ -147,8 +146,7 @@ public class Enter extends JCTree.Visitor {
/** A hashtable mapping classes and packages to the environments current
* at the points of their definitions.
*/
Map<TypeSymbol,Env<AttrContext>> typeEnvs =
new HashMap<TypeSymbol,Env<AttrContext>>();
Map<TypeSymbol,Env<AttrContext>> typeEnvs = new HashMap<>();
/** Accessor for typeEnvs
*/
@ -207,7 +205,7 @@ public class Enter extends JCTree.Visitor {
* @param tree The toplevel tree.
*/
Env<AttrContext> topLevelEnv(JCCompilationUnit tree) {
Env<AttrContext> localEnv = new Env<AttrContext>(tree, new AttrContext());
Env<AttrContext> localEnv = new Env<>(tree, new AttrContext());
localEnv.toplevel = tree;
localEnv.enclClass = predefClassDef;
tree.namedImportScope = new ImportScope(tree.packge);
@ -218,7 +216,7 @@ public class Enter extends JCTree.Visitor {
}
public Env<AttrContext> getTopLevelEnv(JCCompilationUnit tree) {
Env<AttrContext> localEnv = new Env<AttrContext>(tree, new AttrContext());
Env<AttrContext> localEnv = new Env<>(tree, new AttrContext());
localEnv.toplevel = tree;
localEnv.enclClass = predefClassDef;
localEnv.info.scope = tree.namedImportScope;
@ -271,7 +269,7 @@ public class Enter extends JCTree.Visitor {
/** Visitor method: enter classes of a list of trees, returning a list of types.
*/
<T extends JCTree> List<Type> classEnter(List<T> trees, Env<AttrContext> env) {
ListBuffer<Type> ts = new ListBuffer<Type>();
ListBuffer<Type> ts = new ListBuffer<>();
for (List<T> l = trees; l.nonEmpty(); l = l.tail) {
Type t = classEnter(l.head, env);
if (t != null)
@ -483,7 +481,7 @@ public class Enter extends JCTree.Visitor {
public void complete(List<JCCompilationUnit> trees, ClassSymbol c) {
annotate.enterStart();
ListBuffer<ClassSymbol> prevUncompleted = uncompleted;
if (memberEnter.completionEnabled) uncompleted = new ListBuffer<ClassSymbol>();
if (memberEnter.completionEnabled) uncompleted = new ListBuffer<>();
try {
// enter all classes, and construct uncompleted list

View File

@ -92,7 +92,7 @@ public class Env<A> implements Iterable<Env<A>> {
* and copying all other fields.
*/
public Env<A> dup(JCTree tree, A info) {
return dupto(new Env<A>(tree, info));
return dupto(new Env<>(tree, info));
}
/** Duplicate this environment into a given Environment,

View File

@ -181,8 +181,7 @@ import static com.sun.tools.javac.tree.JCTree.Tag.*;
* deletion without notice.</b>
*/
public class Flow {
protected static final Context.Key<Flow> flowKey =
new Context.Key<Flow>();
protected static final Context.Key<Flow> flowKey = new Context.Key<>();
private final Names names;
private final Log log;
@ -373,7 +372,7 @@ public class Flow {
/** Resolve all continues of this statement. */
boolean resolveContinues(JCTree tree) {
return resolveJump(tree, new ListBuffer<P>(), JumpKind.CONTINUE);
return resolveJump(tree, new ListBuffer<>(), JumpKind.CONTINUE);
}
/** Resolve all breaks of this statement. */
@ -449,7 +448,7 @@ public class Flow {
ListBuffer<PendingExit> pendingExitsPrev = pendingExits;
Lint lintPrev = lint;
pendingExits = new ListBuffer<PendingExit>();
pendingExits = new ListBuffer<>();
lint = lint.augment(tree.sym);
try {
@ -498,7 +497,7 @@ public class Flow {
log.error(TreeInfo.diagEndPos(tree.body), "missing.ret.stmt");
List<PendingExit> exits = pendingExits.toList();
pendingExits = new ListBuffer<PendingExit>();
pendingExits = new ListBuffer<>();
while (exits.nonEmpty()) {
PendingExit exit = exits.head;
exits = exits.tail;
@ -527,7 +526,7 @@ public class Flow {
public void visitDoLoop(JCDoWhileLoop tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<PendingExit>();
pendingExits = new ListBuffer<>();
scanStat(tree.body);
alive |= resolveContinues(tree);
scan(tree.cond);
@ -537,7 +536,7 @@ public class Flow {
public void visitWhileLoop(JCWhileLoop tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<PendingExit>();
pendingExits = new ListBuffer<>();
scan(tree.cond);
alive = !tree.cond.type.isFalse();
scanStat(tree.body);
@ -549,7 +548,7 @@ public class Flow {
public void visitForLoop(JCForLoop tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
scanStats(tree.init);
pendingExits = new ListBuffer<PendingExit>();
pendingExits = new ListBuffer<>();
if (tree.cond != null) {
scan(tree.cond);
alive = !tree.cond.type.isFalse();
@ -567,7 +566,7 @@ public class Flow {
visitVarDef(tree.var);
ListBuffer<PendingExit> prevPendingExits = pendingExits;
scan(tree.expr);
pendingExits = new ListBuffer<PendingExit>();
pendingExits = new ListBuffer<>();
scanStat(tree.body);
alive |= resolveContinues(tree);
resolveBreaks(tree, prevPendingExits);
@ -576,14 +575,14 @@ public class Flow {
public void visitLabelled(JCLabeledStatement tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<PendingExit>();
pendingExits = new ListBuffer<>();
scanStat(tree.body);
alive |= resolveBreaks(tree, prevPendingExits);
}
public void visitSwitch(JCSwitch tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<PendingExit>();
pendingExits = new ListBuffer<>();
scan(tree.selector);
boolean hasDefault = false;
for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
@ -610,7 +609,7 @@ public class Flow {
public void visitTry(JCTry tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<PendingExit>();
pendingExits = new ListBuffer<>();
for (JCTree resource : tree.resources) {
if (resource instanceof JCVariableDecl) {
JCVariableDecl vdecl = (JCVariableDecl) resource;
@ -741,7 +740,7 @@ public class Flow {
try {
attrEnv = env;
Flow.this.make = make;
pendingExits = new ListBuffer<PendingExit>();
pendingExits = new ListBuffer<>();
alive = true;
scan(tree);
} finally {
@ -846,7 +845,7 @@ public class Flow {
ListBuffer<FlowPendingExit> pendingExitsPrev = pendingExits;
Lint lintPrev = lint;
pendingExits = new ListBuffer<FlowPendingExit>();
pendingExits = new ListBuffer<>();
if (tree.name != names.empty) {
caught = List.nil();
}
@ -951,7 +950,7 @@ public class Flow {
scan(tree.body);
List<FlowPendingExit> exits = pendingExits.toList();
pendingExits = new ListBuffer<FlowPendingExit>();
pendingExits = new ListBuffer<>();
while (exits.nonEmpty()) {
FlowPendingExit exit = exits.head;
exits = exits.tail;
@ -986,7 +985,7 @@ public class Flow {
public void visitDoLoop(JCDoWhileLoop tree) {
ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<FlowPendingExit>();
pendingExits = new ListBuffer<>();
scan(tree.body);
resolveContinues(tree);
scan(tree.cond);
@ -995,7 +994,7 @@ public class Flow {
public void visitWhileLoop(JCWhileLoop tree) {
ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<FlowPendingExit>();
pendingExits = new ListBuffer<>();
scan(tree.cond);
scan(tree.body);
resolveContinues(tree);
@ -1005,7 +1004,7 @@ public class Flow {
public void visitForLoop(JCForLoop tree) {
ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
scan(tree.init);
pendingExits = new ListBuffer<FlowPendingExit>();
pendingExits = new ListBuffer<>();
if (tree.cond != null) {
scan(tree.cond);
}
@ -1019,7 +1018,7 @@ public class Flow {
visitVarDef(tree.var);
ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
scan(tree.expr);
pendingExits = new ListBuffer<FlowPendingExit>();
pendingExits = new ListBuffer<>();
scan(tree.body);
resolveContinues(tree);
resolveBreaks(tree, prevPendingExits);
@ -1027,14 +1026,14 @@ public class Flow {
public void visitLabelled(JCLabeledStatement tree) {
ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<FlowPendingExit>();
pendingExits = new ListBuffer<>();
scan(tree.body);
resolveBreaks(tree, prevPendingExits);
}
public void visitSwitch(JCSwitch tree) {
ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<FlowPendingExit>();
pendingExits = new ListBuffer<>();
scan(tree.selector);
for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
JCCase c = l.head;
@ -1060,7 +1059,7 @@ public class Flow {
}
ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<FlowPendingExit>();
pendingExits = new ListBuffer<>();
for (JCTree resource : tree.resources) {
if (resource instanceof JCVariableDecl) {
JCVariableDecl vdecl = (JCVariableDecl) resource;
@ -1270,7 +1269,7 @@ public class Flow {
thrown = List.nil();
scan(tree.body);
List<FlowPendingExit> exits = pendingExits.toList();
pendingExits = new ListBuffer<FlowPendingExit>();
pendingExits = new ListBuffer<>();
while (exits.nonEmpty()) {
FlowPendingExit exit = exits.head;
exits = exits.tail;
@ -1307,8 +1306,8 @@ public class Flow {
try {
attrEnv = env;
Flow.this.make = make;
pendingExits = new ListBuffer<FlowPendingExit>();
preciseRethrowTypes = new HashMap<Symbol, List<Type>>();
pendingExits = new ListBuffer<>();
preciseRethrowTypes = new HashMap<>();
this.thrown = this.caught = null;
this.classDef = null;
scan(tree);
@ -1651,7 +1650,7 @@ public class Flow {
int nextadrPrev = nextadr;
ListBuffer<P> pendingExitsPrev = pendingExits;
pendingExits = new ListBuffer<P>();
pendingExits = new ListBuffer<>();
if (tree.name != names.empty) {
firstadr = nextadr;
}
@ -1826,7 +1825,7 @@ public class Flow {
flowKind = FlowKind.NORMAL;
final Bits initsSkip = new Bits(true);
final Bits uninitsSkip = new Bits(true);
pendingExits = new ListBuffer<P>();
pendingExits = new ListBuffer<>();
int prevErrors = getLogNumberOfErrors();
do {
final Bits uninitsEntry = new Bits(uninits);
@ -1896,7 +1895,7 @@ public class Flow {
scan(tree.init);
final Bits initsSkip = new Bits(true);
final Bits uninitsSkip = new Bits(true);
pendingExits = new ListBuffer<P>();
pendingExits = new ListBuffer<>();
int prevErrors = getLogNumberOfErrors();
do {
final Bits uninitsEntry = new Bits(uninits);
@ -1946,7 +1945,7 @@ public class Flow {
final Bits uninitsStart = new Bits(uninits);
letInit(tree.pos(), tree.var.sym);
pendingExits = new ListBuffer<P>();
pendingExits = new ListBuffer<>();
int prevErrors = getLogNumberOfErrors();
do {
final Bits uninitsEntry = new Bits(uninits);
@ -1969,7 +1968,7 @@ public class Flow {
public void visitLabelled(JCLabeledStatement tree) {
ListBuffer<P> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<P>();
pendingExits = new ListBuffer<>();
scan(tree.body);
resolveBreaks(tree, prevPendingExits);
}
@ -2219,7 +2218,7 @@ public class Flow {
ListBuffer<P> prevPending = pendingExits;
try {
returnadr = nextadr;
pendingExits = new ListBuffer<P>();
pendingExits = new ListBuffer<>();
for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
JCVariableDecl def = l.head;
scan(def);
@ -2676,7 +2675,7 @@ public class Flow {
try {
attrEnv = env;
Flow.this.make = make;
pendingExits = new ListBuffer<PendingExit>();
pendingExits = new ListBuffer<>();
scan(tree);
} finally {
pendingExits = null;

View File

@ -62,8 +62,7 @@ import static com.sun.tools.javac.code.TypeTag.*;
* deletion without notice.</b>
*/
public class Infer {
protected static final Context.Key<Infer> inferKey =
new Context.Key<Infer>();
protected static final Context.Key<Infer> inferKey = new Context.Key<>();
Resolve rs;
Check chk;
@ -510,9 +509,9 @@ public class Infer {
uv.listener = null;
}
}
};
}
/** max number of incorporation rounds */
/** max number of incorporation rounds */
static final int MAX_INCORPORATION_STEPS = 100;
/**
@ -893,8 +892,7 @@ public class Infer {
}
/** an incorporation cache keeps track of all executed incorporation-related operations */
Map<IncorporationBinaryOp, Boolean> incorporationCache =
new HashMap<IncorporationBinaryOp, Boolean>();
Map<IncorporationBinaryOp, Boolean> incorporationCache = new HashMap<>();
/**
* Make sure that the upper bounds we got so far lead to a solvable inference
@ -927,7 +925,7 @@ public class Infer {
return !t.isErroneous() && !inferenceContext.free(t) &&
!t.hasTag(BOT);
}
};
}
/**
* This enumeration defines all possible bound-checking related errors.
@ -1045,7 +1043,7 @@ public class Infer {
if (g.nodes.isEmpty()) {
//should not happen
throw new NodeNotFoundException(g);
};
}
return g.nodes.get(0);
}
@ -1111,16 +1109,15 @@ public class Infer {
//cache miss
if (n.isLeaf()) {
//if leaf, stop
cachedPath = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
cachedPath = new Pair<>(List.of(n), n.data.length());
} else {
//if non-leaf, proceed recursively
Pair<List<Node>, Integer> path = new Pair<List<Node>, Integer>(List.of(n), n.data.length());
Pair<List<Node>, Integer> path = new Pair<>(List.of(n), n.data.length());
for (Node n2 : n.getAllDependencies()) {
if (n2 == n) continue;
Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2);
path = new Pair<List<Node>, Integer>(
path.fst.prependList(subpath.fst),
path.snd + subpath.snd);
path = new Pair<>(path.fst.prependList(subpath.fst),
path.snd + subpath.snd);
}
cachedPath = path;
}
@ -1131,12 +1128,10 @@ public class Infer {
}
/** cache used to avoid redundant computation of tree costs */
final Map<Node, Pair<List<Node>, Integer>> treeCache =
new HashMap<Node, Pair<List<Node>, Integer>>();
final Map<Node, Pair<List<Node>, Integer>> treeCache = new HashMap<>();
/** constant value used to mark non-existent paths */
final Pair<List<Node>, Integer> noPath =
new Pair<List<Node>, Integer>(null, Integer.MAX_VALUE);
final Pair<List<Node>, Integer> noPath = new Pair<>(null, Integer.MAX_VALUE);
/**
* Pick the leaf that minimize cost
@ -1460,7 +1455,7 @@ public class Infer {
Node(Type ivar) {
super(ListBuffer.of(ivar));
this.deps = new EnumMap<DependencyKind, Set<Node>>(DependencyKind.class);
this.deps = new EnumMap<>(DependencyKind.class);
}
@Override
@ -1502,7 +1497,7 @@ public class Infer {
* Retrieves all dependencies with given kind(s).
*/
protected Set<Node> getDependencies(DependencyKind... depKinds) {
Set<Node> buf = new LinkedHashSet<Node>();
Set<Node> buf = new LinkedHashSet<>();
for (DependencyKind dk : depKinds) {
Set<Node> depsByKind = deps.get(dk);
if (depsByKind != null) {
@ -1518,7 +1513,7 @@ public class Infer {
protected void addDependency(DependencyKind dk, Node depToAdd) {
Set<Node> depsByKind = deps.get(dk);
if (depsByKind == null) {
depsByKind = new LinkedHashSet<Node>();
depsByKind = new LinkedHashSet<>();
deps.put(dk, depsByKind);
}
depsByKind.add(depToAdd);
@ -1554,11 +1549,11 @@ public class Infer {
*/
protected Set<Node> closure(DependencyKind... depKinds) {
boolean progress = true;
Set<Node> closure = new HashSet<Node>();
Set<Node> closure = new HashSet<>();
closure.add(this);
while (progress) {
progress = false;
for (Node n1 : new HashSet<Node>(closure)) {
for (Node n1 : new HashSet<>(closure)) {
progress = closure.addAll(n1.getDependencies(depKinds));
}
}
@ -1595,12 +1590,12 @@ public class Infer {
}
}
//update deps
EnumMap<DependencyKind, Set<Node>> deps2 = new EnumMap<DependencyKind, Set<Node>>(DependencyKind.class);
EnumMap<DependencyKind, Set<Node>> deps2 = new EnumMap<>(DependencyKind.class);
for (DependencyKind dk : DependencyKind.values()) {
for (Node d : getDependencies(dk)) {
Set<Node> depsByKind = deps2.get(dk);
if (depsByKind == null) {
depsByKind = new LinkedHashSet<Node>();
depsByKind = new LinkedHashSet<>();
deps2.put(dk, depsByKind);
}
if (data.contains(d.data.first())) {
@ -1674,7 +1669,7 @@ public class Infer {
*/
void initNodes(Map<Type, Set<Type>> stuckDeps) {
//add nodes
nodes = new ArrayList<Node>();
nodes = new ArrayList<>();
for (Type t : inferenceContext.restvars()) {
nodes.add(new Node(t));
}
@ -1696,7 +1691,7 @@ public class Infer {
}
}
//merge cyclic nodes
ArrayList<Node> acyclicNodes = new ArrayList<Node>();
ArrayList<Node> acyclicNodes = new ArrayList<>();
for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
if (conSubGraph.length() > 1) {
Node root = conSubGraph.head;
@ -1753,8 +1748,7 @@ public class Infer {
/** list of inference vars in this context */
List<Type> inferencevars;
java.util.Map<FreeTypeListener, List<Type>> freeTypeListeners =
new java.util.HashMap<FreeTypeListener, List<Type>>();
Map<FreeTypeListener, List<Type>> freeTypeListeners = new HashMap<>();
List<FreeTypeListener> freetypeListeners = List.nil();
@ -1946,7 +1940,7 @@ public class Infer {
void notifyChange(List<Type> inferredVars) {
InferenceException thrownEx = null;
for (Map.Entry<FreeTypeListener, List<Type>> entry :
new HashMap<FreeTypeListener, List<Type>>(freeTypeListeners).entrySet()) {
new HashMap<>(freeTypeListeners).entrySet()) {
if (!Type.containsAny(entry.getValue(), inferencevars.diff(inferredVars))) {
try {
entry.getKey().typesInferred(this);
@ -2019,7 +2013,7 @@ public class Infer {
}
private void solve(GraphStrategy ss, Warner warn) {
solve(ss, new HashMap<Type, Set<Type>>(), warn);
solve(ss, new HashMap<>(), warn);
}
/**

View File

@ -106,8 +106,7 @@ public class LambdaToMethod extends TreeTranslator {
public static final int FLAG_BRIDGES = 1 << 2;
// <editor-fold defaultstate="collapsed" desc="Instantiating">
protected static final Context.Key<LambdaToMethod> unlambdaKey =
new Context.Key<LambdaToMethod>();
protected static final Context.Key<LambdaToMethod> unlambdaKey = new Context.Key<>();
public static LambdaToMethod instance(Context context) {
LambdaToMethod instance = context.get(unlambdaKey);
@ -161,7 +160,7 @@ public class LambdaToMethod extends TreeTranslator {
private KlassInfo(JCClassDecl clazz) {
this.clazz = clazz;
appendedMethodList = new ListBuffer<>();
deserializeCases = new HashMap<String, ListBuffer<JCStatement>>();
deserializeCases = new HashMap<>();
MethodType type = new MethodType(List.of(syms.serializedLambdaType), syms.objectType,
List.<Type>nil(), syms.methodClass);
deserMethodSym = makePrivateSyntheticMethod(STATIC, names.deserializeLambda, type, clazz.sym);
@ -204,7 +203,7 @@ public class LambdaToMethod extends TreeTranslator {
this.make = make;
this.attrEnv = env;
this.context = null;
this.contextMap = new HashMap<JCTree, TranslationContext<?>>();
this.contextMap = new HashMap<>();
return translate(cdef);
}
// </editor-fold>
@ -261,8 +260,8 @@ public class LambdaToMethod extends TreeTranslator {
{
Symbol owner = localContext.owner;
ListBuffer<Attribute.TypeCompound> ownerTypeAnnos = new ListBuffer<Attribute.TypeCompound>();
ListBuffer<Attribute.TypeCompound> lambdaTypeAnnos = new ListBuffer<Attribute.TypeCompound>();
ListBuffer<Attribute.TypeCompound> ownerTypeAnnos = new ListBuffer<>();
ListBuffer<Attribute.TypeCompound> lambdaTypeAnnos = new ListBuffer<>();
for (Attribute.TypeCompound tc : owner.getRawTypeAttributes()) {
if (tc.position.onLambda == tree) {
@ -1147,12 +1146,11 @@ public class LambdaToMethod extends TreeTranslator {
* maps for fake clinit symbols to be used as owners of lambda occurring in
* a static var init context
*/
private Map<ClassSymbol, Symbol> clinits =
new HashMap<ClassSymbol, Symbol>();
private Map<ClassSymbol, Symbol> clinits = new HashMap<>();
private JCClassDecl analyzeAndPreprocessClass(JCClassDecl tree) {
frameStack = List.nil();
localClassDefs = new HashMap<Symbol, JCClassDecl>();
localClassDefs = new HashMap<>();
return translate(tree);
}
@ -1180,7 +1178,7 @@ public class LambdaToMethod extends TreeTranslator {
try {
log.useSource(tree.sym.sourcefile);
syntheticMethodNameCounts = new SyntheticMethodNameCounter();
prevClinits = new HashMap<ClassSymbol, Symbol>();
prevClinits = new HashMap<>();
if (tree.sym.owner.kind == MTH) {
localClassDefs.put(tree.sym, tree);
}
@ -1352,7 +1350,7 @@ public class LambdaToMethod extends TreeTranslator {
// Build lambda parameters
// partially cloned from TreeMaker.Params until 8014021 is fixed
Symbol owner = owner();
ListBuffer<JCVariableDecl> paramBuff = new ListBuffer<JCVariableDecl>();
ListBuffer<JCVariableDecl> paramBuff = new ListBuffer<>();
int i = 0;
for (List<Type> l = ptypes; l.nonEmpty(); l = l.tail) {
JCVariableDecl param = make.Param(make.paramName(i++), l.head, owner);
@ -1773,11 +1771,11 @@ public class LambdaToMethod extends TreeTranslator {
}
translatedSymbols = new EnumMap<>(LambdaSymbolKind.class);
translatedSymbols.put(PARAM, new LinkedHashMap<Symbol, Symbol>());
translatedSymbols.put(LOCAL_VAR, new LinkedHashMap<Symbol, Symbol>());
translatedSymbols.put(CAPTURED_VAR, new LinkedHashMap<Symbol, Symbol>());
translatedSymbols.put(CAPTURED_THIS, new LinkedHashMap<Symbol, Symbol>());
translatedSymbols.put(TYPE_VAR, new LinkedHashMap<Symbol, Symbol>());
translatedSymbols.put(PARAM, new LinkedHashMap<>());
translatedSymbols.put(LOCAL_VAR, new LinkedHashMap<>());
translatedSymbols.put(CAPTURED_VAR, new LinkedHashMap<>());
translatedSymbols.put(CAPTURED_THIS, new LinkedHashMap<>());
translatedSymbols.put(TYPE_VAR, new LinkedHashMap<>());
}
/**
@ -2168,7 +2166,7 @@ public class LambdaToMethod extends TreeTranslator {
LOCAL_VAR, // original to translated lambda locals
CAPTURED_VAR, // variables in enclosing scope to translated synthetic parameters
CAPTURED_THIS, // class symbols to translated synthetic parameters (for captured member access)
TYPE_VAR; // original to translated lambda type variables
TYPE_VAR // original to translated lambda type variables
}
/**

View File

@ -59,8 +59,7 @@ import static com.sun.tools.javac.tree.JCTree.Tag.*;
* deletion without notice.</b>
*/
public class Lower extends TreeTranslator {
protected static final Context.Key<Lower> lowerKey =
new Context.Key<Lower>();
protected static final Context.Key<Lower> lowerKey = new Context.Key<>();
public static Lower instance(Context context) {
Lower instance = context.get(lowerKey);
@ -141,7 +140,7 @@ public class Lower extends TreeTranslator {
/** A hash table mapping local classes to a list of pruned trees.
*/
public Map<ClassSymbol, List<JCTree>> prunedTree = new WeakHashMap<ClassSymbol, List<JCTree>>();
public Map<ClassSymbol, List<JCTree>> prunedTree = new WeakHashMap<>();
/** A hash table mapping virtual accessed symbols in outer subclasses
* to the actually referred symbol in superclasses.
@ -396,7 +395,7 @@ public class Lower extends TreeTranslator {
}
}
Map<TypeSymbol,EnumMapping> enumSwitchMap = new LinkedHashMap<TypeSymbol,EnumMapping>();
Map<TypeSymbol,EnumMapping> enumSwitchMap = new LinkedHashMap<>();
EnumMapping mapForEnum(DiagnosticPosition pos, TypeSymbol enumClass) {
EnumMapping map = enumSwitchMap.get(enumClass);
@ -441,7 +440,7 @@ public class Lower extends TreeTranslator {
class EnumMapping {
EnumMapping(DiagnosticPosition pos, TypeSymbol forEnum) {
this.forEnum = forEnum;
this.values = new LinkedHashMap<VarSymbol,Integer>();
this.values = new LinkedHashMap<>();
this.pos = pos;
Name varName = names
.fromString(target.syntheticNameChar() +
@ -497,7 +496,7 @@ public class Lower extends TreeTranslator {
.setType(new ArrayType(syms.intType, syms.arrayClass));
// try { $SwitchMap$Color[red.ordinal()] = 1; } catch (java.lang.NoSuchFieldError ex) {}
ListBuffer<JCStatement> stmts = new ListBuffer<JCStatement>();
ListBuffer<JCStatement> stmts = new ListBuffer<>();
Symbol ordinalMethod = lookupMethod(pos,
names.ordinal,
forEnum.type,
@ -1654,7 +1653,7 @@ public class Lower extends TreeTranslator {
return block;
// Add resource declaration or expression to block statements
ListBuffer<JCStatement> stats = new ListBuffer<JCStatement>();
ListBuffer<JCStatement> stats = new ListBuffer<>();
JCTree resource = resources.head;
JCExpression expr = null;
if (resource instanceof JCVariableDecl) {
@ -2548,9 +2547,9 @@ public class Lower extends TreeTranslator {
// process each enumeration constant, adding implicit constructor parameters
int nextOrdinal = 0;
ListBuffer<JCExpression> values = new ListBuffer<JCExpression>();
ListBuffer<JCTree> enumDefs = new ListBuffer<JCTree>();
ListBuffer<JCTree> otherDefs = new ListBuffer<JCTree>();
ListBuffer<JCExpression> values = new ListBuffer<>();
ListBuffer<JCTree> enumDefs = new ListBuffer<>();
ListBuffer<JCTree> otherDefs = new ListBuffer<>();
for (List<JCTree> defs = tree.defs;
defs.nonEmpty();
defs=defs.tail) {
@ -2824,7 +2823,7 @@ public class Lower extends TreeTranslator {
}
//where
private Map<Symbol, Symbol> makeTranslationMap(JCMethodDecl tree) {
Map<Symbol, Symbol> translationMap = new HashMap<Symbol,Symbol>();
Map<Symbol, Symbol> translationMap = new HashMap<>();
for (JCVariableDecl vd : tree.params) {
Symbol p = vd.sym;
if (p != p.baseSymbol()) {
@ -3075,7 +3074,7 @@ public class Lower extends TreeTranslator {
List<JCExpression> args = _args;
if (parameters.isEmpty()) return args;
boolean anyChanges = false;
ListBuffer<JCExpression> result = new ListBuffer<JCExpression>();
ListBuffer<JCExpression> result = new ListBuffer<>();
while (parameters.tail.nonEmpty()) {
JCExpression arg = translate(args.head, parameters.head);
anyChanges |= (arg != args.head);
@ -3086,7 +3085,7 @@ public class Lower extends TreeTranslator {
Type parameter = parameters.head;
if (varargsElement != null) {
anyChanges = true;
ListBuffer<JCExpression> elems = new ListBuffer<JCExpression>();
ListBuffer<JCExpression> elems = new ListBuffer<>();
while (args.nonEmpty()) {
JCExpression arg = translate(args.head, varargsElement);
elems.append(arg);
@ -3611,7 +3610,7 @@ public class Lower extends TreeTranslator {
JCArrayAccess selector = make.Indexed(map.mapVar,
make.App(make.Select(tree.selector,
ordinalMethod)));
ListBuffer<JCCase> cases = new ListBuffer<JCCase>();
ListBuffer<JCCase> cases = new ListBuffer<>();
for (JCCase c : tree.cases) {
if (c.pat != null) {
VarSymbol label = (VarSymbol)TreeInfo.symbol(c.pat);
@ -3674,16 +3673,14 @@ public class Lower extends TreeTranslator {
* used instead of String.hashCode.
*/
ListBuffer<JCStatement> stmtList = new ListBuffer<JCStatement>();
ListBuffer<JCStatement> stmtList = new ListBuffer<>();
// Map from String case labels to their original position in
// the list of case labels.
Map<String, Integer> caseLabelToPosition =
new LinkedHashMap<String, Integer>(alternatives + 1, 1.0f);
Map<String, Integer> caseLabelToPosition = new LinkedHashMap<>(alternatives + 1, 1.0f);
// Map of hash codes to the string case labels having that hashCode.
Map<Integer, Set<String>> hashToString =
new LinkedHashMap<Integer, Set<String>>(alternatives + 1, 1.0f);
Map<Integer, Set<String>> hashToString = new LinkedHashMap<>(alternatives + 1, 1.0f);
int casePosition = 0;
for(JCCase oneCase : caseList) {
@ -3697,7 +3694,7 @@ public class Lower extends TreeTranslator {
Set<String> stringSet = hashToString.get(hashCode);
if (stringSet == null) {
stringSet = new LinkedHashSet<String>(1, 1.0f);
stringSet = new LinkedHashSet<>(1, 1.0f);
stringSet.add(labelExpr);
hashToString.put(hashCode, stringSet);
} else {
@ -3907,18 +3904,18 @@ public class Lower extends TreeTranslator {
currentMethodDef = null;
outermostClassDef = (cdef.hasTag(CLASSDEF)) ? (JCClassDecl)cdef : null;
outermostMemberDef = null;
this.translated = new ListBuffer<JCTree>();
classdefs = new HashMap<ClassSymbol,JCClassDecl>();
actualSymbols = new HashMap<Symbol,Symbol>();
freevarCache = new HashMap<ClassSymbol,List<VarSymbol>>();
this.translated = new ListBuffer<>();
classdefs = new HashMap<>();
actualSymbols = new HashMap<>();
freevarCache = new HashMap<>();
proxies = new Scope(syms.noSymbol);
twrVars = new Scope(syms.noSymbol);
outerThisStack = List.nil();
accessNums = new HashMap<Symbol,Integer>();
accessSyms = new HashMap<Symbol,MethodSymbol[]>();
accessConstrs = new HashMap<Symbol,MethodSymbol>();
accessNums = new HashMap<>();
accessSyms = new HashMap<>();
accessConstrs = new HashMap<>();
accessConstrTags = List.nil();
accessed = new ListBuffer<Symbol>();
accessed = new ListBuffer<>();
translate(cdef, (JCExpression)null);
for (List<Symbol> l = accessed.toList(); l.nonEmpty(); l = l.tail)
makeAccessible(l.head);

View File

@ -62,8 +62,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
* deletion without notice.</b>
*/
public class MemberEnter extends JCTree.Visitor implements Completer {
protected static final Context.Key<MemberEnter> memberEnterKey =
new Context.Key<MemberEnter>();
protected static final Context.Key<MemberEnter> memberEnterKey = new Context.Key<>();
/** A switch to determine whether we check for package/class conflicts
*/
@ -126,7 +125,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
/** A queue for classes whose members still need to be entered into the
* symbol table.
*/
ListBuffer<Env<AttrContext>> halfcompleted = new ListBuffer<Env<AttrContext>>();
ListBuffer<Env<AttrContext>> halfcompleted = new ListBuffer<>();
/** Set to true only when the first of a set of classes is
* processed from the half completed queue.
@ -178,7 +177,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
// enter imported types immediately
new Object() {
Set<Symbol> processed = new HashSet<Symbol>();
Set<Symbol> processed = new HashSet<>();
void importFrom(TypeSymbol tsym) {
if (tsym == null || !processed.add(tsym))
return;
@ -203,7 +202,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
// enter non-types before annotations that might use them
annotate.earlier(new Annotate.Worker() {
Set<Symbol> processed = new HashSet<Symbol>();
Set<Symbol> processed = new HashSet<>();
public String toString() {
return "import static " + tsym + ".*" + " in " + sourcefile;
@ -271,7 +270,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
// enter imported types immediately
new Object() {
Set<Symbol> processed = new HashSet<Symbol>();
Set<Symbol> processed = new HashSet<>();
void importFrom(TypeSymbol tsym) {
if (tsym == null || !processed.add(tsym))
return;
@ -297,7 +296,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
// enter non-types before annotations that might use them
annotate.earlier(new Annotate.Worker() {
Set<Symbol> processed = new HashSet<Symbol>();
Set<Symbol> processed = new HashSet<>();
boolean found = false;
public String toString() {
@ -378,7 +377,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
attr.attribTypeVariables(typarams, env);
// Enter and attribute value parameters.
ListBuffer<Type> argbuf = new ListBuffer<Type>();
ListBuffer<Type> argbuf = new ListBuffer<>();
for (List<JCVariableDecl> l = params; l.nonEmpty(); l = l.tail) {
memberEnter(l.head, env);
argbuf.append(l.head.vartype.type);
@ -397,7 +396,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
}
// Attribute thrown exceptions.
ListBuffer<Type> thrownbuf = new ListBuffer<Type>();
ListBuffer<Type> thrownbuf = new ListBuffer<>();
for (List<JCExpression> l = thrown; l.nonEmpty(); l = l.tail) {
Type exc = attr.attribType(l.head, env);
if (!exc.hasTag(TYPEVAR)) {
@ -591,7 +590,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
}
// Set m.params
ListBuffer<VarSymbol> params = new ListBuffer<VarSymbol>();
ListBuffer<VarSymbol> params = new ListBuffer<>();
JCVariableDecl lastParam = null;
for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
JCVariableDecl param = lastParam = l.head;
@ -915,10 +914,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
private void actualEnterAnnotations(List<JCAnnotation> annotations,
Env<AttrContext> env,
Symbol s) {
Map<TypeSymbol, ListBuffer<Attribute.Compound>> annotated =
new LinkedHashMap<TypeSymbol, ListBuffer<Attribute.Compound>>();
Map<Attribute.Compound, DiagnosticPosition> pos =
new HashMap<Attribute.Compound, DiagnosticPosition>();
Map<TypeSymbol, ListBuffer<Attribute.Compound>> annotated = new LinkedHashMap<>();
Map<Attribute.Compound, DiagnosticPosition> pos = new HashMap<>();
for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
JCAnnotation a = al.head;
@ -952,7 +949,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
}
s.setDeclarationAttributesWithCompletion(
annotate.new AnnotateRepeatedContext<Attribute.Compound>(env, annotated, pos, log, false));
annotate.new AnnotateRepeatedContext<>(env, annotated, pos, log, false));
}
/** Queue processing of an attribute default value. */
@ -1064,9 +1061,9 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
ct.supertype_field = modelMissingTypes(supertype, tree.extending, false);
// Determine interfaces.
ListBuffer<Type> interfaces = new ListBuffer<Type>();
ListBuffer<Type> interfaces = new ListBuffer<>();
ListBuffer<Type> all_interfaces = null; // lazy init
Set<Type> interfaceSet = new HashSet<Type>();
Set<Type> interfaceSet = new HashSet<>();
List<JCExpression> interfaceTrees = tree.implementing;
for (JCExpression iface : interfaceTrees) {
Type i = attr.attribBase(iface, baseEnv, false, true, true);
@ -1214,10 +1211,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
private void actualEnterTypeAnnotations(final List<JCAnnotation> annotations,
final Env<AttrContext> env,
final Symbol s) {
Map<TypeSymbol, ListBuffer<Attribute.TypeCompound>> annotated =
new LinkedHashMap<TypeSymbol, ListBuffer<Attribute.TypeCompound>>();
Map<Attribute.TypeCompound, DiagnosticPosition> pos =
new HashMap<Attribute.TypeCompound, DiagnosticPosition>();
Map<TypeSymbol, ListBuffer<Attribute.TypeCompound>> annotated = new LinkedHashMap<>();
Map<Attribute.TypeCompound, DiagnosticPosition> pos = new HashMap<>();
for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
JCAnnotation a = al.head;
@ -1245,7 +1240,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
if (s != null) {
s.appendTypeAttributesWithCompletion(
annotate.new AnnotateRepeatedContext<Attribute.TypeCompound>(env, annotated, pos, log, true));
annotate.new AnnotateRepeatedContext<>(env, annotated, pos, log, true));
}
}
@ -1448,7 +1443,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
}
List<Type> visit(List<? extends JCTree> trees) {
ListBuffer<Type> lb = new ListBuffer<Type>();
ListBuffer<Type> lb = new ListBuffer<>();
for (JCTree t: trees)
lb.append(visit(t));
return lb.toList();

View File

@ -78,8 +78,7 @@ import static com.sun.tools.javac.tree.JCTree.Tag.*;
* deletion without notice.</b>
*/
public class Resolve {
protected static final Context.Key<Resolve> resolveKey =
new Context.Key<Resolve>();
protected static final Context.Key<Resolve> resolveKey = new Context.Key<>();
Names names;
Log log;
@ -918,7 +917,7 @@ public class Resolve {
public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
return new MostSpecificCheck(strict, actuals);
}
};
}
/**
* Check context to be used during method applicability checks. A method check
@ -1616,7 +1615,7 @@ public class Resolve {
(flags & DEFAULT) != 0 ||
(flags & ABSTRACT) == 0);
}
};
}
/** Find best qualified method matching given name, type and value
* arguments.
@ -3780,7 +3779,7 @@ public class Resolve {
bestSoFar = c;
}
Assert.checkNonNull(bestSoFar);
return new Pair<Symbol, JCDiagnostic>(bestSoFar.sym, bestSoFar.details);
return new Pair<>(bestSoFar.sym, bestSoFar.details);
}
}
@ -3827,7 +3826,7 @@ public class Resolve {
} else if (filteredCandidates.size() == 1) {
Map.Entry<Symbol, JCDiagnostic> _e =
filteredCandidates.entrySet().iterator().next();
final Pair<Symbol, JCDiagnostic> p = new Pair<Symbol, JCDiagnostic>(_e.getKey(), _e.getValue());
final Pair<Symbol, JCDiagnostic> p = new Pair<>(_e.getKey(), _e.getValue());
JCDiagnostic d = new InapplicableSymbolError(resolveContext) {
@Override
protected Pair<Symbol, JCDiagnostic> errCandidate() {
@ -3846,7 +3845,7 @@ public class Resolve {
}
//where
private Map<Symbol, JCDiagnostic> mapCandidates() {
Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<Symbol, JCDiagnostic>();
Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<>();
for (Candidate c : resolveContext.candidates) {
if (c.isApplicable()) continue;
candidates.put(c.sym, c.details);
@ -3855,7 +3854,7 @@ public class Resolve {
}
Map<Symbol, JCDiagnostic> filterCandidates(Map<Symbol, JCDiagnostic> candidatesMap) {
Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<Symbol, JCDiagnostic>();
Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<>();
for (Map.Entry<Symbol, JCDiagnostic> _entry : candidatesMap.entrySet()) {
JCDiagnostic d = _entry.getValue();
if (!new Template(MethodCheckDiag.ARITY_MISMATCH.regex()).matches(d)) {
@ -4175,8 +4174,7 @@ public class Resolve {
};
/** rewriter map used for method resolution simplification */
static final Map<Template, DiagnosticRewriter> rewriters =
new LinkedHashMap<Template, DiagnosticRewriter>();
static final Map<Template, DiagnosticRewriter> rewriters = new LinkedHashMap<>();
static {
String argMismatchRegex = MethodCheckDiag.ARG_MISMATCH.regex();

View File

@ -43,8 +43,7 @@ import javax.tools.JavaFileObject;
*/
public class Todo extends AbstractQueue<Env<AttrContext>> {
/** The context key for the todo list. */
protected static final Context.Key<Todo> todoKey =
new Context.Key<Todo>();
protected static final Context.Key<Todo> todoKey = new Context.Key<>();
/** Get the Todo instance for this context. */
public static Todo instance(Context context) {
@ -98,7 +97,7 @@ public class Todo extends AbstractQueue<Env<AttrContext>> {
public Queue<Queue<Env<AttrContext>>> groupByFile() {
if (contentsByFile == null) {
contentsByFile = new LinkedList<Queue<Env<AttrContext>>>();
contentsByFile = new LinkedList<>();
for (Env<AttrContext> env: contents) {
addByFile(env);
}
@ -109,7 +108,7 @@ public class Todo extends AbstractQueue<Env<AttrContext>> {
private void addByFile(Env<AttrContext> env) {
JavaFileObject file = env.toplevel.sourcefile;
if (fileMap == null)
fileMap = new HashMap<JavaFileObject, FileQueue>();
fileMap = new HashMap<>();
FileQueue fq = fileMap.get(file);
if (fq == null) {
fq = new FileQueue();
@ -132,7 +131,7 @@ public class Todo extends AbstractQueue<Env<AttrContext>> {
}
}
LinkedList<Env<AttrContext>> contents = new LinkedList<Env<AttrContext>>();
LinkedList<Env<AttrContext>> contents = new LinkedList<>();
LinkedList<Queue<Env<AttrContext>>> contentsByFile;
Map<JavaFileObject, FileQueue> fileMap;
@ -167,6 +166,6 @@ public class Todo extends AbstractQueue<Env<AttrContext>> {
return (fileContents.size() == 0 ? null : fileContents.get(0));
}
LinkedList<Env<AttrContext>> fileContents = new LinkedList<Env<AttrContext>>();
LinkedList<Env<AttrContext>> fileContents = new LinkedList<>();
}
}

Some files were not shown because too many files have changed in this diff Show More