mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 19:44:41 +02:00
8181370: Convert anonymous inner classes into lambdas/method references
Reviewed-by: jjg, rfield, mchung
This commit is contained in:
parent
5a0691c4e4
commit
c4e8276376
73 changed files with 485 additions and 773 deletions
|
@ -203,14 +203,11 @@ public class SelectToolTask extends Task {
|
||||||
if (toolName != null) {
|
if (toolName != null) {
|
||||||
toolChoice.setSelectedItem(tool);
|
toolChoice.setSelectedItem(tool);
|
||||||
}
|
}
|
||||||
toolChoice.addItemListener(new ItemListener() {
|
toolChoice.addItemListener(e -> {
|
||||||
@Override
|
ToolChoices tool1 = (ToolChoices)e.getItem();
|
||||||
public void itemStateChanged(ItemEvent e) {
|
argsField.setText(getDefaultArgsForTool(props, tool1));
|
||||||
ToolChoices tool = (ToolChoices)e.getItem();
|
|
||||||
argsField.setText(getDefaultArgsForTool(props, tool));
|
|
||||||
if (toolProperty != null)
|
if (toolProperty != null)
|
||||||
okButton.setEnabled(tool != ToolChoices.NONE);
|
okButton.setEnabled(tool1 != ToolChoices.NONE);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
fc.anchor = GridBagConstraints.EAST;
|
fc.anchor = GridBagConstraints.EAST;
|
||||||
|
|
||||||
|
@ -248,12 +245,9 @@ public class SelectToolTask extends Task {
|
||||||
final JOptionPane p = new JOptionPane(body);
|
final JOptionPane p = new JOptionPane(body);
|
||||||
okButton = new JButton("OK");
|
okButton = new JButton("OK");
|
||||||
okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.equals("")));
|
okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.equals("")));
|
||||||
okButton.addActionListener(new ActionListener() {
|
okButton.addActionListener(e -> {
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p);
|
JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p);
|
||||||
d.setVisible(false);
|
d.setVisible(false);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
p.setOptions(new Object[] { okButton });
|
p.setOptions(new Object[] { okButton });
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class PropertiesParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean run(String[] args, PrintStream out) {
|
public static boolean run(String[] args, PrintStream out) {
|
||||||
PropertiesParser pp = new PropertiesParser(msg -> out.println(msg));
|
PropertiesParser pp = new PropertiesParser(out::println);
|
||||||
return pp.run(args);
|
return pp.run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public class PropertiesParser {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
optionsMap.forEach((propfile, outfile) -> compilePropertyFile(propfile, outfile));
|
optionsMap.forEach(this::compilePropertyFile);
|
||||||
return true;
|
return true;
|
||||||
} catch (RuntimeException ex) {
|
} catch (RuntimeException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
|
|
@ -315,12 +315,7 @@ public class Messages {
|
||||||
*/
|
*/
|
||||||
private static class Table {
|
private static class Table {
|
||||||
|
|
||||||
private static final Comparator<Integer> DECREASING = new Comparator<Integer>() {
|
private static final Comparator<Integer> DECREASING = (o1, o2) -> o2.compareTo(o1);
|
||||||
|
|
||||||
public int compare(Integer o1, Integer o2) {
|
|
||||||
return o2.compareTo(o1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private final TreeMap<Integer, Set<String>> map = new TreeMap<>(DECREASING);
|
private final TreeMap<Integer, Set<String>> map = new TreeMap<>(DECREASING);
|
||||||
|
|
||||||
void put(String label, int n) {
|
void put(String label, int n) {
|
||||||
|
|
|
@ -97,15 +97,12 @@ public class JavacTaskImpl extends BasicJavacTask {
|
||||||
/* Internal version of call exposing Main.Result. */
|
/* Internal version of call exposing Main.Result. */
|
||||||
public Main.Result doCall() {
|
public Main.Result doCall() {
|
||||||
try {
|
try {
|
||||||
return handleExceptions(new Callable<Main.Result>() {
|
return handleExceptions(() -> {
|
||||||
@Override
|
|
||||||
public Main.Result call() throws Exception {
|
|
||||||
prepareCompiler(false);
|
prepareCompiler(false);
|
||||||
if (compiler.errorCount() > 0)
|
if (compiler.errorCount() > 0)
|
||||||
return Main.Result.ERROR;
|
return Main.Result.ERROR;
|
||||||
compiler.compile(args.getFileObjects(), args.getClassNames(), processors);
|
compiler.compile(args.getFileObjects(), args.getClassNames(), processors);
|
||||||
return (compiler.errorCount() > 0) ? Main.Result.ERROR : Main.Result.OK; // FIXME?
|
return (compiler.errorCount() > 0) ? Main.Result.ERROR : Main.Result.OK; // FIXME?
|
||||||
}
|
|
||||||
}, Main.Result.SYSERR, Main.Result.ABNORMAL);
|
}, Main.Result.SYSERR, Main.Result.ABNORMAL);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
@ -228,12 +225,7 @@ public class JavacTaskImpl extends BasicJavacTask {
|
||||||
|
|
||||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||||
public Iterable<? extends CompilationUnitTree> parse() {
|
public Iterable<? extends CompilationUnitTree> parse() {
|
||||||
return handleExceptions(new Callable<Iterable<? extends CompilationUnitTree>>() {
|
return handleExceptions(this::parseInternal, List.<CompilationUnitTree>nil(), List.<CompilationUnitTree>nil());
|
||||||
@Override
|
|
||||||
public Iterable<? extends CompilationUnitTree> call() {
|
|
||||||
return parseInternal();
|
|
||||||
}
|
|
||||||
}, List.<CompilationUnitTree>nil(), List.<CompilationUnitTree>nil());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterable<? extends CompilationUnitTree> parseInternal() {
|
private Iterable<? extends CompilationUnitTree> parseInternal() {
|
||||||
|
@ -360,12 +352,7 @@ public class JavacTaskImpl extends BasicJavacTask {
|
||||||
|
|
||||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||||
public Iterable<? extends Element> analyze() {
|
public Iterable<? extends Element> analyze() {
|
||||||
return handleExceptions(new Callable<Iterable<? extends Element>>() {
|
return handleExceptions(() -> analyze(null), List.<Element>nil(), List.<Element>nil());
|
||||||
@Override
|
|
||||||
public Iterable<? extends Element> call() {
|
|
||||||
return analyze(null);
|
|
||||||
}
|
|
||||||
}, List.<Element>nil(), List.<Element>nil());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -427,12 +414,7 @@ public class JavacTaskImpl extends BasicJavacTask {
|
||||||
|
|
||||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||||
public Iterable<? extends JavaFileObject> generate() {
|
public Iterable<? extends JavaFileObject> generate() {
|
||||||
return handleExceptions(new Callable<Iterable<? extends JavaFileObject>>() {
|
return handleExceptions(() -> generate(null), List.<JavaFileObject>nil(), List.<JavaFileObject>nil());
|
||||||
@Override
|
|
||||||
public Iterable<? extends JavaFileObject> call() {
|
|
||||||
return generate(null);
|
|
||||||
}
|
|
||||||
}, List.<JavaFileObject>nil(), List.<JavaFileObject>nil());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -163,12 +163,7 @@ public class ClassFinder {
|
||||||
/**
|
/**
|
||||||
* Completer that delegates to the complete-method of this class.
|
* Completer that delegates to the complete-method of this class.
|
||||||
*/
|
*/
|
||||||
private final Completer thisCompleter = new Completer() {
|
private final Completer thisCompleter = this::complete;
|
||||||
@Override
|
|
||||||
public void complete(Symbol sym) throws CompletionFailure {
|
|
||||||
ClassFinder.this.complete(sym);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public Completer getCompleter() {
|
public Completer getCompleter() {
|
||||||
return thisCompleter;
|
return thisCompleter;
|
||||||
|
@ -516,7 +511,7 @@ public class ClassFinder {
|
||||||
|
|
||||||
ModuleSymbol msym = p.modle;
|
ModuleSymbol msym = p.modle;
|
||||||
|
|
||||||
Assert.checkNonNull(msym, () -> p.toString());
|
Assert.checkNonNull(msym, p::toString);
|
||||||
|
|
||||||
msym.complete();
|
msym.complete();
|
||||||
|
|
||||||
|
|
|
@ -143,12 +143,7 @@ public abstract class Scope {
|
||||||
/** Returns true iff the given Symbol is in this scope, optionally checking outward scopes.
|
/** Returns true iff the given Symbol is in this scope, optionally checking outward scopes.
|
||||||
*/
|
*/
|
||||||
public boolean includes(final Symbol sym, LookupKind lookupKind) {
|
public boolean includes(final Symbol sym, LookupKind lookupKind) {
|
||||||
return getSymbolsByName(sym.name, new Filter<Symbol>() {
|
return getSymbolsByName(sym.name, t -> t == sym, lookupKind).iterator().hasNext();
|
||||||
@Override
|
|
||||||
public boolean accepts(Symbol t) {
|
|
||||||
return t == sym;
|
|
||||||
}
|
|
||||||
}, lookupKind).iterator().hasNext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true iff this scope does not contain any Symbol. Does not inspect outward scopes.
|
/** Returns true iff this scope does not contain any Symbol. Does not inspect outward scopes.
|
||||||
|
@ -574,11 +569,9 @@ public abstract class Scope {
|
||||||
|
|
||||||
public Iterable<Symbol> getSymbols(final Filter<Symbol> sf,
|
public Iterable<Symbol> getSymbols(final Filter<Symbol> sf,
|
||||||
final LookupKind lookupKind) {
|
final LookupKind lookupKind) {
|
||||||
return new Iterable<Symbol>() {
|
return () -> new Iterator<Symbol>() {
|
||||||
public Iterator<Symbol> iterator() {
|
|
||||||
return new Iterator<Symbol>() {
|
|
||||||
private ScopeImpl currScope = ScopeImpl.this;
|
private ScopeImpl currScope = ScopeImpl.this;
|
||||||
private Scope.Entry currEntry = elems;
|
private Entry currEntry = elems;
|
||||||
private int seenRemoveCount = currScope.removeCount;
|
private int seenRemoveCount = currScope.removeCount;
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
|
@ -610,10 +603,6 @@ public abstract class Scope {
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
skipToNextMatchingEntry();
|
skipToNextMatchingEntry();
|
||||||
if (lookupKind == RECURSIVE) {
|
if (lookupKind == RECURSIVE) {
|
||||||
|
@ -633,16 +622,12 @@ public abstract class Scope {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public Iterable<Symbol> getSymbolsByName(final Name name,
|
public Iterable<Symbol> getSymbolsByName(final Name name,
|
||||||
final Filter<Symbol> sf,
|
final Filter<Symbol> sf,
|
||||||
final LookupKind lookupKind) {
|
final LookupKind lookupKind) {
|
||||||
return new Iterable<Symbol>() {
|
return () -> new Iterator<Symbol>() {
|
||||||
public Iterator<Symbol> iterator() {
|
Entry currentEntry = lookup(name, sf);
|
||||||
return new Iterator<Symbol>() {
|
|
||||||
Scope.Entry currentEntry = lookup(name, sf);
|
|
||||||
int seenRemoveCount = currentEntry.scope != null ?
|
int seenRemoveCount = currentEntry.scope != null ?
|
||||||
currentEntry.scope.removeCount : -1;
|
currentEntry.scope.removeCount : -1;
|
||||||
|
|
||||||
|
@ -663,7 +648,7 @@ public abstract class Scope {
|
||||||
return doNext();
|
return doNext();
|
||||||
}
|
}
|
||||||
private Symbol doNext() {
|
private Symbol doNext() {
|
||||||
Scope.Entry prevEntry = currentEntry;
|
Entry prevEntry = currentEntry;
|
||||||
currentEntry = currentEntry.next(sf);
|
currentEntry = currentEntry.next(sf);
|
||||||
return prevEntry.sym;
|
return prevEntry.sym;
|
||||||
}
|
}
|
||||||
|
@ -672,8 +657,6 @@ public abstract class Scope {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public Scope getOrigin(Symbol s) {
|
public Scope getOrigin(Symbol s) {
|
||||||
for (Scope.Entry e = lookup(s.name); e.scope != null ; e = e.next()) {
|
for (Scope.Entry e = lookup(s.name); e.scope != null ; e = e.next()) {
|
||||||
|
|
|
@ -1549,11 +1549,7 @@ public abstract class Symbol extends AnnoConstruct implements Element {
|
||||||
final Attr attr,
|
final Attr attr,
|
||||||
final JCVariableDecl variable)
|
final JCVariableDecl variable)
|
||||||
{
|
{
|
||||||
setData(new Callable<Object>() {
|
setData((Callable<Object>)() -> attr.attribLazyConstantValue(env, variable, type));
|
||||||
public Object call() {
|
|
||||||
return attr.attribLazyConstantValue(env, variable, type);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1856,12 +1852,8 @@ public abstract class Symbol extends AnnoConstruct implements Element {
|
||||||
return implementation(origin, types, checkResult, implementation_filter);
|
return implementation(origin, types, checkResult, implementation_filter);
|
||||||
}
|
}
|
||||||
// where
|
// where
|
||||||
public static final Filter<Symbol> implementation_filter = new Filter<Symbol>() {
|
public static final Filter<Symbol> implementation_filter = s ->
|
||||||
public boolean accepts(Symbol s) {
|
s.kind == MTH && (s.flags() & SYNTHETIC) == 0;
|
||||||
return s.kind == MTH &&
|
|
||||||
(s.flags() & SYNTHETIC) == 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
|
public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
|
||||||
MethodSymbol res = types.implementation(this, origin, checkResult, implFilter);
|
MethodSymbol res = types.implementation(this, origin, checkResult, implFilter);
|
||||||
|
|
|
@ -590,7 +590,7 @@ public class Symtab {
|
||||||
arrayClass.members().enter(arrayCloneMethod);
|
arrayClass.members().enter(arrayCloneMethod);
|
||||||
|
|
||||||
if (java_base != noModule)
|
if (java_base != noModule)
|
||||||
java_base.completer = sym -> moduleCompleter.complete(sym); //bootstrap issues
|
java_base.completer = moduleCompleter::complete; //bootstrap issues
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +624,7 @@ public class Symtab {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassSymbol getClass(ModuleSymbol msym, Name flatName) {
|
public ClassSymbol getClass(ModuleSymbol msym, Name flatName) {
|
||||||
Assert.checkNonNull(msym, () -> flatName.toString());
|
Assert.checkNonNull(msym, flatName::toString);
|
||||||
return classes.getOrDefault(flatName, Collections.emptyMap()).get(msym);
|
return classes.getOrDefault(flatName, Collections.emptyMap()).get(msym);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,7 +757,8 @@ public class Symtab {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
unnamedPackage.modle = module;
|
unnamedPackage.modle = module;
|
||||||
unnamedPackage.completer = sym -> initialCompleter.complete(sym);
|
//we cannot use a method reference below, as initialCompleter might be null now
|
||||||
|
unnamedPackage.completer = s -> initialCompleter.complete(s);
|
||||||
module.unnamedPackage = unnamedPackage;
|
module.unnamedPackage = unnamedPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,7 +771,7 @@ public class Symtab {
|
||||||
if (msym == null) {
|
if (msym == null) {
|
||||||
msym = ModuleSymbol.create(name, names.module_info);
|
msym = ModuleSymbol.create(name, names.module_info);
|
||||||
addRootPackageFor(msym);
|
addRootPackageFor(msym);
|
||||||
msym.completer = sym -> moduleCompleter.complete(sym); //bootstrap issues
|
msym.completer = s -> moduleCompleter.complete(s); //bootstrap issues
|
||||||
modules.put(name, msym);
|
modules.put(name, msym);
|
||||||
}
|
}
|
||||||
return msym;
|
return msym;
|
||||||
|
|
|
@ -2138,11 +2138,9 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
|
||||||
UndetVarListener prevListener = listener;
|
UndetVarListener prevListener = listener;
|
||||||
try {
|
try {
|
||||||
//setup new listener for keeping track of changed bounds
|
//setup new listener for keeping track of changed bounds
|
||||||
listener = new UndetVarListener() {
|
listener = (uv, ib, t, _ignored) -> {
|
||||||
public void varBoundChanged(UndetVar uv, InferenceBound ib, Type t, boolean _ignored) {
|
|
||||||
Assert.check(uv == UndetVar.this);
|
Assert.check(uv == UndetVar.this);
|
||||||
boundsChanged.add(new Pair<>(ib, t));
|
boundsChanged.add(new Pair<>(ib, t));
|
||||||
}
|
|
||||||
};
|
};
|
||||||
for (Map.Entry<InferenceBound, List<Type>> _entry : bounds.entrySet()) {
|
for (Map.Entry<InferenceBound, List<Type>> _entry : bounds.entrySet()) {
|
||||||
InferenceBound ib = _entry.getKey();
|
InferenceBound ib = _entry.getKey();
|
||||||
|
|
|
@ -2651,12 +2651,8 @@ public class Attr extends JCTree.Visitor {
|
||||||
private void checkAccessibleTypes(final DiagnosticPosition pos, final Env<AttrContext> env,
|
private void checkAccessibleTypes(final DiagnosticPosition pos, final Env<AttrContext> env,
|
||||||
final InferenceContext inferenceContext, final List<Type> ts) {
|
final InferenceContext inferenceContext, final List<Type> ts) {
|
||||||
if (inferenceContext.free(ts)) {
|
if (inferenceContext.free(ts)) {
|
||||||
inferenceContext.addFreeTypeListener(ts, new FreeTypeListener() {
|
inferenceContext.addFreeTypeListener(ts,
|
||||||
@Override
|
solvedContext -> checkAccessibleTypes(pos, env, solvedContext, solvedContext.asInstTypes(ts)));
|
||||||
public void typesInferred(InferenceContext inferenceContext) {
|
|
||||||
checkAccessibleTypes(pos, env, inferenceContext, inferenceContext.asInstTypes(ts));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
for (Type t : ts) {
|
for (Type t : ts) {
|
||||||
rs.checkAccessibleType(env, t);
|
rs.checkAccessibleType(env, t);
|
||||||
|
@ -3094,12 +3090,9 @@ public class Attr extends JCTree.Visitor {
|
||||||
private void setFunctionalInfo(final Env<AttrContext> env, final JCFunctionalExpression fExpr,
|
private void setFunctionalInfo(final Env<AttrContext> env, final JCFunctionalExpression fExpr,
|
||||||
final Type pt, final Type descriptorType, final Type primaryTarget, final CheckContext checkContext) {
|
final Type pt, final Type descriptorType, final Type primaryTarget, final CheckContext checkContext) {
|
||||||
if (checkContext.inferenceContext().free(descriptorType)) {
|
if (checkContext.inferenceContext().free(descriptorType)) {
|
||||||
checkContext.inferenceContext().addFreeTypeListener(List.of(pt, descriptorType), new FreeTypeListener() {
|
checkContext.inferenceContext().addFreeTypeListener(List.of(pt, descriptorType),
|
||||||
public void typesInferred(InferenceContext inferenceContext) {
|
inferenceContext -> setFunctionalInfo(env, fExpr, pt, inferenceContext.asInstType(descriptorType),
|
||||||
setFunctionalInfo(env, fExpr, pt, inferenceContext.asInstType(descriptorType),
|
inferenceContext.asInstType(primaryTarget), checkContext));
|
||||||
inferenceContext.asInstType(primaryTarget), checkContext);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
ListBuffer<Type> targets = new ListBuffer<>();
|
ListBuffer<Type> targets = new ListBuffer<>();
|
||||||
if (pt.hasTag(CLASS)) {
|
if (pt.hasTag(CLASS)) {
|
||||||
|
@ -4574,13 +4567,8 @@ public class Attr extends JCTree.Visitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Filter<Symbol> anyNonAbstractOrDefaultMethod = new Filter<Symbol>() {
|
public static final Filter<Symbol> anyNonAbstractOrDefaultMethod = s ->
|
||||||
@Override
|
s.kind == MTH && (s.flags() & (DEFAULT | ABSTRACT)) != ABSTRACT;
|
||||||
public boolean accepts(Symbol s) {
|
|
||||||
return s.kind == MTH &&
|
|
||||||
(s.flags() & (DEFAULT | ABSTRACT)) != ABSTRACT;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/** get a diagnostic position for an attribute of Type t, or null if attribute missing */
|
/** get a diagnostic position for an attribute of Type t, or null if attribute missing */
|
||||||
private DiagnosticPosition getDiagnosticPosition(JCClassDecl tree, Type t) {
|
private DiagnosticPosition getDiagnosticPosition(JCClassDecl tree, Type t) {
|
||||||
|
|
|
@ -565,12 +565,8 @@ public class Check {
|
||||||
Type checkType(final DiagnosticPosition pos, final Type found, final Type req, final CheckContext checkContext) {
|
Type checkType(final DiagnosticPosition pos, final Type found, final Type req, final CheckContext checkContext) {
|
||||||
final InferenceContext inferenceContext = checkContext.inferenceContext();
|
final InferenceContext inferenceContext = checkContext.inferenceContext();
|
||||||
if (inferenceContext.free(req) || inferenceContext.free(found)) {
|
if (inferenceContext.free(req) || inferenceContext.free(found)) {
|
||||||
inferenceContext.addFreeTypeListener(List.of(req, found), new FreeTypeListener() {
|
inferenceContext.addFreeTypeListener(List.of(req, found),
|
||||||
@Override
|
solvedContext -> checkType(pos, solvedContext.asInstType(found), solvedContext.asInstType(req), checkContext));
|
||||||
public void typesInferred(InferenceContext inferenceContext) {
|
|
||||||
checkType(pos, inferenceContext.asInstType(found), inferenceContext.asInstType(req), checkContext);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (req.hasTag(ERROR))
|
if (req.hasTag(ERROR))
|
||||||
return req;
|
return req;
|
||||||
|
@ -614,13 +610,10 @@ public class Check {
|
||||||
&& types.isSameType(tree.expr.type, tree.clazz.type)
|
&& types.isSameType(tree.expr.type, tree.clazz.type)
|
||||||
&& !(ignoreAnnotatedCasts && TreeInfo.containsTypeAnnotation(tree.clazz))
|
&& !(ignoreAnnotatedCasts && TreeInfo.containsTypeAnnotation(tree.clazz))
|
||||||
&& !is292targetTypeCast(tree)) {
|
&& !is292targetTypeCast(tree)) {
|
||||||
deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
|
deferredLintHandler.report(() -> {
|
||||||
@Override
|
if (lint.isEnabled(LintCategory.CAST))
|
||||||
public void report() {
|
log.warning(LintCategory.CAST,
|
||||||
if (lint.isEnabled(Lint.LintCategory.CAST))
|
|
||||||
log.warning(Lint.LintCategory.CAST,
|
|
||||||
tree.pos(), "redundant.cast", tree.clazz.type);
|
tree.pos(), "redundant.cast", tree.clazz.type);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -953,11 +946,8 @@ public class Check {
|
||||||
// System.out.println("method : " + owntype);
|
// System.out.println("method : " + owntype);
|
||||||
// System.out.println("actuals: " + argtypes);
|
// System.out.println("actuals: " + argtypes);
|
||||||
if (inferenceContext.free(mtype)) {
|
if (inferenceContext.free(mtype)) {
|
||||||
inferenceContext.addFreeTypeListener(List.of(mtype), new FreeTypeListener() {
|
inferenceContext.addFreeTypeListener(List.of(mtype),
|
||||||
public void typesInferred(InferenceContext inferenceContext) {
|
solvedContext -> checkMethod(solvedContext.asInstType(mtype), sym, env, argtrees, argtypes, useVarargs, solvedContext));
|
||||||
checkMethod(inferenceContext.asInstType(mtype), sym, env, argtrees, argtypes, useVarargs, inferenceContext);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return mtype;
|
return mtype;
|
||||||
}
|
}
|
||||||
Type owntype = mtype;
|
Type owntype = mtype;
|
||||||
|
@ -2070,14 +2060,9 @@ public class Check {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Filter<Symbol> equalsHasCodeFilter = new Filter<Symbol>() {
|
private Filter<Symbol> equalsHasCodeFilter = s -> MethodSymbol.implementation_filter.accepts(s) &&
|
||||||
public boolean accepts(Symbol s) {
|
|
||||||
return MethodSymbol.implementation_filter.accepts(s) &&
|
|
||||||
(s.flags() & BAD_OVERRIDE) == 0;
|
(s.flags() & BAD_OVERRIDE) == 0;
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public void checkClassOverrideEqualsAndHashIfNeeded(DiagnosticPosition pos,
|
public void checkClassOverrideEqualsAndHashIfNeeded(DiagnosticPosition pos,
|
||||||
ClassSymbol someClass) {
|
ClassSymbol someClass) {
|
||||||
/* At present, annotations cannot possibly have a method that is override
|
/* At present, annotations cannot possibly have a method that is override
|
||||||
|
@ -3266,12 +3251,7 @@ public class Check {
|
||||||
if ( (s.isDeprecatedForRemoval()
|
if ( (s.isDeprecatedForRemoval()
|
||||||
|| s.isDeprecated() && !other.isDeprecated())
|
|| s.isDeprecated() && !other.isDeprecated())
|
||||||
&& (s.outermostClass() != other.outermostClass() || s.outermostClass() == null)) {
|
&& (s.outermostClass() != other.outermostClass() || s.outermostClass() == null)) {
|
||||||
deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
|
deferredLintHandler.report(() -> warnDeprecated(pos, s));
|
||||||
@Override
|
|
||||||
public void report() {
|
|
||||||
warnDeprecated(pos, s);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3410,12 +3390,7 @@ public class Check {
|
||||||
int opc = ((OperatorSymbol)operator).opcode;
|
int opc = ((OperatorSymbol)operator).opcode;
|
||||||
if (opc == ByteCodes.idiv || opc == ByteCodes.imod
|
if (opc == ByteCodes.idiv || opc == ByteCodes.imod
|
||||||
|| opc == ByteCodes.ldiv || opc == ByteCodes.lmod) {
|
|| opc == ByteCodes.ldiv || opc == ByteCodes.lmod) {
|
||||||
deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
|
deferredLintHandler.report(() -> warnDivZero(pos));
|
||||||
@Override
|
|
||||||
public void report() {
|
|
||||||
warnDivZero(pos);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3892,12 +3867,9 @@ public class Check {
|
||||||
|
|
||||||
void checkModuleExists(final DiagnosticPosition pos, ModuleSymbol msym) {
|
void checkModuleExists(final DiagnosticPosition pos, ModuleSymbol msym) {
|
||||||
if (msym.kind != MDL) {
|
if (msym.kind != MDL) {
|
||||||
deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
|
deferredLintHandler.report(() -> {
|
||||||
@Override
|
if (lint.isEnabled(LintCategory.MODULE))
|
||||||
public void report() {
|
|
||||||
if (lint.isEnabled(Lint.LintCategory.MODULE))
|
|
||||||
log.warning(LintCategory.MODULE, pos, Warnings.ModuleNotFound(msym));
|
log.warning(LintCategory.MODULE, pos, Warnings.ModuleNotFound(msym));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -507,12 +507,10 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
DeferredAttrDiagHandler(Log log, JCTree newTree) {
|
DeferredAttrDiagHandler(Log log, JCTree newTree) {
|
||||||
super(log, new Filter<JCDiagnostic>() {
|
super(log, d -> {
|
||||||
public boolean accepts(JCDiagnostic d) {
|
|
||||||
PosScanner posScanner = new PosScanner(d.getDiagnosticPosition());
|
PosScanner posScanner = new PosScanner(d.getDiagnosticPosition());
|
||||||
posScanner.scan(newTree);
|
posScanner.scan(newTree);
|
||||||
return posScanner.found;
|
return posScanner.found;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1008,11 +1006,7 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||||
final Filter<JCTree> treeFilter;
|
final Filter<JCTree> treeFilter;
|
||||||
|
|
||||||
FilterScanner(final Set<JCTree.Tag> validTags) {
|
FilterScanner(final Set<JCTree.Tag> validTags) {
|
||||||
this.treeFilter = new Filter<JCTree>() {
|
this.treeFilter = t -> validTags.contains(t.getTag());
|
||||||
public boolean accepts(JCTree t) {
|
|
||||||
return validTags.contains(t.getTag());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -415,7 +415,7 @@ public class Enter extends JCTree.Visitor {
|
||||||
if (c.owner != owner) {
|
if (c.owner != owner) {
|
||||||
//anonymous class loaded from a classfile may be recreated from source (see below)
|
//anonymous class loaded from a classfile may be recreated from source (see below)
|
||||||
//if this class is a member of such an anonymous class, fix the owner:
|
//if this class is a member of such an anonymous class, fix the owner:
|
||||||
Assert.check(owner.owner.kind != TYP, () -> owner.toString());
|
Assert.check(owner.owner.kind != TYP, owner::toString);
|
||||||
Assert.check(c.owner.kind == TYP, () -> c.owner.toString());
|
Assert.check(c.owner.kind == TYP, () -> c.owner.toString());
|
||||||
ClassSymbol cowner = (ClassSymbol) c.owner;
|
ClassSymbol cowner = (ClassSymbol) c.owner;
|
||||||
if (cowner.members_field != null) {
|
if (cowner.members_field != null) {
|
||||||
|
|
|
@ -123,11 +123,7 @@ public class InferenceContext {
|
||||||
* inference context
|
* inference context
|
||||||
*/
|
*/
|
||||||
List<Type> restvars() {
|
List<Type> restvars() {
|
||||||
return filterVars(new Filter<UndetVar>() {
|
return filterVars(uv -> uv.getInst() == null);
|
||||||
public boolean accepts(UndetVar uv) {
|
|
||||||
return uv.getInst() == null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,11 +131,7 @@ public class InferenceContext {
|
||||||
* inference context
|
* inference context
|
||||||
*/
|
*/
|
||||||
List<Type> instvars() {
|
List<Type> instvars() {
|
||||||
return filterVars(new Filter<UndetVar>() {
|
return filterVars(uv -> uv.getInst() != null);
|
||||||
public boolean accepts(UndetVar uv) {
|
|
||||||
return uv.getInst() != null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,13 +139,9 @@ public class InferenceContext {
|
||||||
* declared bounds).
|
* declared bounds).
|
||||||
*/
|
*/
|
||||||
final List<Type> boundedVars() {
|
final List<Type> boundedVars() {
|
||||||
return filterVars(new Filter<UndetVar>() {
|
return filterVars(uv -> uv.getBounds(InferenceBound.UPPER)
|
||||||
public boolean accepts(UndetVar uv) {
|
|
||||||
return uv.getBounds(InferenceBound.UPPER)
|
|
||||||
.diff(uv.getDeclaredBounds())
|
.diff(uv.getDeclaredBounds())
|
||||||
.appendList(uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)).nonEmpty();
|
.appendList(uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)).nonEmpty());
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the corresponding inference variables.
|
/* Returns the corresponding inference variables.
|
||||||
|
@ -341,11 +329,7 @@ public class InferenceContext {
|
||||||
//set up listeners to notify original inference contexts as
|
//set up listeners to notify original inference contexts as
|
||||||
//propagated vars are inferred in new context
|
//propagated vars are inferred in new context
|
||||||
for (Type t : inferencevars) {
|
for (Type t : inferencevars) {
|
||||||
that.freeTypeListeners.put(new FreeTypeListener() {
|
that.freeTypeListeners.put(inferenceContext -> InferenceContext.this.notifyChange(), List.of(t));
|
||||||
public void typesInferred(InferenceContext inferenceContext) {
|
|
||||||
InferenceContext.this.notifyChange();
|
|
||||||
}
|
|
||||||
}, List.of(t));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2254,25 +2254,15 @@ public class Lower extends TreeTranslator {
|
||||||
final JCFieldAccess s = (JCFieldAccess)lval;
|
final JCFieldAccess s = (JCFieldAccess)lval;
|
||||||
Symbol lid = TreeInfo.symbol(s.selected);
|
Symbol lid = TreeInfo.symbol(s.selected);
|
||||||
if (lid != null && lid.kind == TYP) return builder.build(lval);
|
if (lid != null && lid.kind == TYP) return builder.build(lval);
|
||||||
return abstractRval(s.selected, new TreeBuilder() {
|
return abstractRval(s.selected, selected -> builder.build(make.Select(selected, s.sym)));
|
||||||
public JCExpression build(final JCExpression selected) {
|
|
||||||
return builder.build(make.Select(selected, s.sym));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
case INDEXED: {
|
case INDEXED: {
|
||||||
final JCArrayAccess i = (JCArrayAccess)lval;
|
final JCArrayAccess i = (JCArrayAccess)lval;
|
||||||
return abstractRval(i.indexed, new TreeBuilder() {
|
return abstractRval(i.indexed, indexed -> abstractRval(i.index, syms.intType, index -> {
|
||||||
public JCExpression build(final JCExpression indexed) {
|
|
||||||
return abstractRval(i.index, syms.intType, new TreeBuilder() {
|
|
||||||
public JCExpression build(final JCExpression index) {
|
|
||||||
JCExpression newLval = make.Indexed(indexed, index);
|
JCExpression newLval = make.Indexed(indexed, index);
|
||||||
newLval.setType(i.type);
|
newLval.setType(i.type);
|
||||||
return builder.build(newLval);
|
return builder.build(newLval);
|
||||||
}
|
}));
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
case TYPECAST: {
|
case TYPECAST: {
|
||||||
return abstractLval(((JCTypeCast)lval).expr, builder);
|
return abstractLval(((JCTypeCast)lval).expr, builder);
|
||||||
|
@ -2283,11 +2273,7 @@ public class Lower extends TreeTranslator {
|
||||||
|
|
||||||
// evaluate and discard the first expression, then evaluate the second.
|
// evaluate and discard the first expression, then evaluate the second.
|
||||||
JCExpression makeComma(final JCExpression expr1, final JCExpression expr2) {
|
JCExpression makeComma(final JCExpression expr1, final JCExpression expr2) {
|
||||||
return abstractRval(expr1, new TreeBuilder() {
|
return abstractRval(expr1, discarded -> expr2);
|
||||||
public JCExpression build(final JCExpression discarded) {
|
|
||||||
return expr2;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
@ -3195,9 +3181,8 @@ public class Lower extends TreeTranslator {
|
||||||
// boxing required; need to rewrite as x = (unbox typeof x)(x op y);
|
// boxing required; need to rewrite as x = (unbox typeof x)(x op y);
|
||||||
// or if x == (typeof x)z then z = (unbox typeof x)((typeof x)z op y)
|
// or if x == (typeof x)z then z = (unbox typeof x)((typeof x)z op y)
|
||||||
// (but without recomputing x)
|
// (but without recomputing x)
|
||||||
JCTree newTree = abstractLval(tree.lhs, new TreeBuilder() {
|
JCTree newTree = abstractLval(tree.lhs, lhs -> {
|
||||||
public JCExpression build(final JCExpression lhs) {
|
Tag newTag = tree.getTag().noAssignOp();
|
||||||
JCTree.Tag newTag = tree.getTag().noAssignOp();
|
|
||||||
// Erasure (TransTypes) can change the type of
|
// Erasure (TransTypes) can change the type of
|
||||||
// tree.lhs. However, we can still get the
|
// tree.lhs. However, we can still get the
|
||||||
// unerased type of tree.lhs as it is stored
|
// unerased type of tree.lhs as it is stored
|
||||||
|
@ -3220,7 +3205,6 @@ public class Lower extends TreeTranslator {
|
||||||
make.TypeCast(types.unboxedType(tree.type), opResult) :
|
make.TypeCast(types.unboxedType(tree.type), opResult) :
|
||||||
opResult;
|
opResult;
|
||||||
return make.Assign(lhs, newRhs).setType(tree.type);
|
return make.Assign(lhs, newRhs).setType(tree.type);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
result = translate(newTree);
|
result = translate(newTree);
|
||||||
return;
|
return;
|
||||||
|
@ -3287,11 +3271,8 @@ public class Lower extends TreeTranslator {
|
||||||
// translate to tmp1=lval(e); tmp2=tmp1; (typeof tree)tmp1 OP 1; tmp2
|
// translate to tmp1=lval(e); tmp2=tmp1; (typeof tree)tmp1 OP 1; tmp2
|
||||||
// where OP is += or -=
|
// where OP is += or -=
|
||||||
final boolean cast = TreeInfo.skipParens(tree.arg).hasTag(TYPECAST);
|
final boolean cast = TreeInfo.skipParens(tree.arg).hasTag(TYPECAST);
|
||||||
return abstractLval(tree.arg, new TreeBuilder() {
|
return abstractLval(tree.arg, tmp1 -> abstractRval(tmp1, tree.arg.type, tmp2 -> {
|
||||||
public JCExpression build(final JCExpression tmp1) {
|
Tag opcode = (tree.hasTag(POSTINC))
|
||||||
return abstractRval(tmp1, tree.arg.type, new TreeBuilder() {
|
|
||||||
public JCExpression build(final JCExpression tmp2) {
|
|
||||||
JCTree.Tag opcode = (tree.hasTag(POSTINC))
|
|
||||||
? PLUS_ASG : MINUS_ASG;
|
? PLUS_ASG : MINUS_ASG;
|
||||||
//"tmp1" and "tmp2" may refer to the same instance
|
//"tmp1" and "tmp2" may refer to the same instance
|
||||||
//(for e.g. <Class>.super.<ident>). But further processing may
|
//(for e.g. <Class>.super.<ident>). But further processing may
|
||||||
|
@ -3305,10 +3286,7 @@ public class Lower extends TreeTranslator {
|
||||||
lhs,
|
lhs,
|
||||||
make.Literal(1));
|
make.Literal(1));
|
||||||
return makeComma(update, tmp2);
|
return makeComma(update, tmp2);
|
||||||
}
|
}));
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitUnary(JCUnary tree) {
|
public void visitUnary(JCUnary tree) {
|
||||||
|
|
|
@ -424,12 +424,7 @@ public class Modules extends JCTree.Visitor {
|
||||||
checkNoAllModulePath();
|
checkNoAllModulePath();
|
||||||
defaultModule.complete();
|
defaultModule.complete();
|
||||||
// Question: why not do completeModule here?
|
// Question: why not do completeModule here?
|
||||||
defaultModule.completer = new Completer() {
|
defaultModule.completer = sym -> completeModule((ModuleSymbol) sym);
|
||||||
@Override
|
|
||||||
public void complete(Symbol sym) throws CompletionFailure {
|
|
||||||
completeModule((ModuleSymbol) sym);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
rootModules.add(defaultModule);
|
rootModules.add(defaultModule);
|
||||||
break;
|
break;
|
||||||
|
@ -1522,7 +1517,7 @@ public class Modules extends JCTree.Visitor {
|
||||||
current.complete();
|
current.complete();
|
||||||
if ((current.flags() & Flags.ACYCLIC) != 0)
|
if ((current.flags() & Flags.ACYCLIC) != 0)
|
||||||
continue;
|
continue;
|
||||||
Assert.checkNonNull(current.requires, () -> current.toString());
|
Assert.checkNonNull(current.requires, current::toString);
|
||||||
for (RequiresDirective dep : current.requires) {
|
for (RequiresDirective dep : current.requires) {
|
||||||
if (!dep.flags.contains(RequiresFlag.EXTRA))
|
if (!dep.flags.contains(RequiresFlag.EXTRA))
|
||||||
queue = queue.prepend(dep.module);
|
queue = queue.prepend(dep.module);
|
||||||
|
|
|
@ -296,7 +296,7 @@ public class Operators {
|
||||||
*/
|
*/
|
||||||
private OperatorSymbol[] initOperators() {
|
private OperatorSymbol[] initOperators() {
|
||||||
OperatorSymbol[] operators = operatorSuppliers.stream()
|
OperatorSymbol[] operators = operatorSuppliers.stream()
|
||||||
.map(op -> op.get())
|
.map(Supplier::get)
|
||||||
.toArray(OperatorSymbol[]::new);
|
.toArray(OperatorSymbol[]::new);
|
||||||
alternatives = Optional.of(operators);
|
alternatives = Optional.of(operators);
|
||||||
operatorSuppliers = null; //let GC do its work
|
operatorSuppliers = null; //let GC do its work
|
||||||
|
|
|
@ -881,12 +881,8 @@ public class Resolve {
|
||||||
*/
|
*/
|
||||||
private void varargsAccessible(final Env<AttrContext> env, final Type t, final InferenceContext inferenceContext) {
|
private void varargsAccessible(final Env<AttrContext> env, final Type t, final InferenceContext inferenceContext) {
|
||||||
if (inferenceContext.free(t)) {
|
if (inferenceContext.free(t)) {
|
||||||
inferenceContext.addFreeTypeListener(List.of(t), new FreeTypeListener() {
|
inferenceContext.addFreeTypeListener(List.of(t),
|
||||||
@Override
|
solvedContext -> varargsAccessible(env, solvedContext.asInstType(t), solvedContext));
|
||||||
public void typesInferred(InferenceContext inferenceContext) {
|
|
||||||
varargsAccessible(env, inferenceContext.asInstType(t), inferenceContext);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
if (!isAccessible(env, types.erasure(t))) {
|
if (!isAccessible(env, types.erasure(t))) {
|
||||||
Symbol location = env.enclClass.sym;
|
Symbol location = env.enclClass.sym;
|
||||||
|
@ -1851,9 +1847,7 @@ public class Resolve {
|
||||||
* errors if some of the not-needed supertypes are missing/ill-formed).
|
* errors if some of the not-needed supertypes are missing/ill-formed).
|
||||||
*/
|
*/
|
||||||
Iterable<TypeSymbol> superclasses(final Type intype) {
|
Iterable<TypeSymbol> superclasses(final Type intype) {
|
||||||
return new Iterable<TypeSymbol>() {
|
return () -> new Iterator<TypeSymbol>() {
|
||||||
public Iterator<TypeSymbol> iterator() {
|
|
||||||
return new Iterator<TypeSymbol>() {
|
|
||||||
|
|
||||||
List<TypeSymbol> seen = List.nil();
|
List<TypeSymbol> seen = List.nil();
|
||||||
TypeSymbol currentSym = symbolFor(intype);
|
TypeSymbol currentSym = symbolFor(intype);
|
||||||
|
@ -1893,8 +1887,6 @@ public class Resolve {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Find unqualified method matching given name, type and value arguments.
|
/** Find unqualified method matching given name, type and value arguments.
|
||||||
* @param env The current environment.
|
* @param env The current environment.
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import com.sun.tools.javac.util.Context;
|
import com.sun.tools.javac.util.Context;
|
||||||
|
import com.sun.tools.javac.util.Context.Factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Caching implementation of FSInfo.
|
* Caching implementation of FSInfo.
|
||||||
|
@ -47,12 +48,10 @@ public class CacheFSInfo extends FSInfo {
|
||||||
* Register a Context.Factory to create a CacheFSInfo.
|
* Register a Context.Factory to create a CacheFSInfo.
|
||||||
*/
|
*/
|
||||||
public static void preRegister(Context context) {
|
public static void preRegister(Context context) {
|
||||||
context.put(FSInfo.class, new Context.Factory<FSInfo>() {
|
context.put(FSInfo.class, (Factory<FSInfo>)c -> {
|
||||||
public FSInfo make(Context c) {
|
|
||||||
FSInfo instance = new CacheFSInfo();
|
FSInfo instance = new CacheFSInfo();
|
||||||
c.put(FSInfo.class, instance);
|
c.put(FSInfo.class, instance);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
|
||||||
import com.sun.tools.javac.file.RelativePath.RelativeFile;
|
import com.sun.tools.javac.file.RelativePath.RelativeFile;
|
||||||
import com.sun.tools.javac.util.Assert;
|
import com.sun.tools.javac.util.Assert;
|
||||||
import com.sun.tools.javac.util.Context;
|
import com.sun.tools.javac.util.Context;
|
||||||
|
import com.sun.tools.javac.util.Context.Factory;
|
||||||
import com.sun.tools.javac.util.DefinedBy;
|
import com.sun.tools.javac.util.DefinedBy;
|
||||||
import com.sun.tools.javac.util.DefinedBy.Api;
|
import com.sun.tools.javac.util.DefinedBy.Api;
|
||||||
import com.sun.tools.javac.util.List;
|
import com.sun.tools.javac.util.List;
|
||||||
|
@ -134,12 +135,8 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||||
* Register a Context.Factory to create a JavacFileManager.
|
* Register a Context.Factory to create a JavacFileManager.
|
||||||
*/
|
*/
|
||||||
public static void preRegister(Context context) {
|
public static void preRegister(Context context) {
|
||||||
context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
|
context.put(JavaFileManager.class,
|
||||||
@Override
|
(Factory<JavaFileManager>)c -> new JavacFileManager(c, true, null));
|
||||||
public JavaFileManager make(Context c) {
|
|
||||||
return new JavacFileManager(c, true, null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -272,7 +272,7 @@ public class Locations {
|
||||||
}
|
}
|
||||||
|
|
||||||
try (Stream<Path> s = Files.list(dir)) {
|
try (Stream<Path> s = Files.list(dir)) {
|
||||||
s.filter(dirEntry -> isArchive(dirEntry))
|
s.filter(Locations.this::isArchive)
|
||||||
.forEach(dirEntry -> addFile(dirEntry, warn));
|
.forEach(dirEntry -> addFile(dirEntry, warn));
|
||||||
} catch (IOException ignore) {
|
} catch (IOException ignore) {
|
||||||
}
|
}
|
||||||
|
@ -946,7 +946,7 @@ public class Locations {
|
||||||
if (searchPath == null)
|
if (searchPath == null)
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
||||||
return () -> new ModulePathIterator();
|
return ModulePathIterator::new;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -365,16 +365,8 @@ public class Pool {
|
||||||
Assert.check(!refSym.owner.isInterface() || interfaceOwner);
|
Assert.check(!refSym.owner.isInterface() || interfaceOwner);
|
||||||
}
|
}
|
||||||
//where
|
//where
|
||||||
Filter<Name> nonInitFilter = new Filter<Name>() {
|
Filter<Name> nonInitFilter = n -> (n != n.table.names.init && n != n.table.names.clinit);
|
||||||
public boolean accepts(Name n) {
|
|
||||||
return n != n.table.names.init && n != n.table.names.clinit;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Filter<Name> initFilter = new Filter<Name>() {
|
Filter<Name> initFilter = n -> n == n.table.names.init;
|
||||||
public boolean accepts(Name n) {
|
|
||||||
return n == n.table.names.init;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,12 +337,7 @@ public class JavaCompiler {
|
||||||
* SourceCompleter that delegates to the readSourceFile method of this class.
|
* SourceCompleter that delegates to the readSourceFile method of this class.
|
||||||
*/
|
*/
|
||||||
protected final Symbol.Completer sourceCompleter =
|
protected final Symbol.Completer sourceCompleter =
|
||||||
new Symbol.Completer() {
|
sym -> readSourceFile((ClassSymbol) sym);
|
||||||
@Override
|
|
||||||
public void complete(Symbol sym) throws CompletionFailure {
|
|
||||||
readSourceFile((ClassSymbol) sym);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
protected final ModuleFinder.ModuleInfoSourceFileCompleter moduleInfoSourceFileCompleter =
|
protected final ModuleFinder.ModuleInfoSourceFileCompleter moduleInfoSourceFileCompleter =
|
||||||
fo -> (ModuleSymbol) readSourceFile(parseImplicitFile(fo), null, tl -> {
|
fo -> (ModuleSymbol) readSourceFile(parseImplicitFile(fo), null, tl -> {
|
||||||
|
|
|
@ -71,11 +71,7 @@ public class FilteredMemberList extends AbstractList<Symbol> {
|
||||||
|
|
||||||
// A more efficient implementation than AbstractList's.
|
// A more efficient implementation than AbstractList's.
|
||||||
public Iterator<Symbol> iterator() {
|
public Iterator<Symbol> iterator() {
|
||||||
return scope.getSymbols(new Filter<Symbol>() {
|
return scope.getSymbols(t -> !unwanted(t), NON_RECURSIVE).iterator();
|
||||||
public boolean accepts(Symbol t) {
|
|
||||||
return !unwanted(t);
|
|
||||||
}
|
|
||||||
}, NON_RECURSIVE).iterator();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1718,11 +1718,7 @@ public class JavacParser implements Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Accepts all identifier-like tokens */
|
/** Accepts all identifier-like tokens */
|
||||||
protected Filter<TokenKind> LAX_IDENTIFIER = new Filter<TokenKind>() {
|
protected Filter<TokenKind> LAX_IDENTIFIER = t -> t == IDENTIFIER || t == UNDERSCORE || t == ASSERT || t == ENUM;
|
||||||
public boolean accepts(TokenKind t) {
|
|
||||||
return t == IDENTIFIER || t == UNDERSCORE || t == ASSERT || t == ENUM;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ParensResult {
|
enum ParensResult {
|
||||||
CAST,
|
CAST,
|
||||||
|
|
|
@ -324,7 +324,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||||
if (platformProvider != null) {
|
if (platformProvider != null) {
|
||||||
platformProcessors = platformProvider.getAnnotationProcessors()
|
platformProcessors = platformProvider.getAnnotationProcessors()
|
||||||
.stream()
|
.stream()
|
||||||
.map(ap -> ap.getPlugin())
|
.map(PluginInfo::getPlugin)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
List<Iterator<? extends Processor>> iterators = List.of(processorIterator,
|
List<Iterator<? extends Processor>> iterators = List.of(processorIterator,
|
||||||
|
|
|
@ -73,11 +73,7 @@ public class JCDiagnostic implements Diagnostic<JavaFileObject> {
|
||||||
|
|
||||||
final Options options = Options.instance(context);
|
final Options options = Options.instance(context);
|
||||||
initOptions(options);
|
initOptions(options);
|
||||||
options.addListener(new Runnable() {
|
options.addListener(() -> initOptions(options));
|
||||||
public void run() {
|
|
||||||
initOptions(options);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initOptions(Options options) {
|
private void initOptions(Options options) {
|
||||||
|
|
|
@ -557,8 +557,8 @@ public class List<A> extends AbstractCollection<A> implements java.util.List<A>
|
||||||
*/
|
*/
|
||||||
public static <Z> Collector<Z, ListBuffer<Z>, List<Z>> collector() {
|
public static <Z> Collector<Z, ListBuffer<Z>, List<Z>> collector() {
|
||||||
return Collector.of(ListBuffer::new,
|
return Collector.of(ListBuffer::new,
|
||||||
(buf, el)->buf.add(el),
|
ListBuffer::add,
|
||||||
(buf1, buf2)-> { buf1.addAll(buf2); return buf1; },
|
(buf1, buf2)-> { buf1.addAll(buf2); return buf1; },
|
||||||
buf->buf.toList());
|
ListBuffer::toList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,12 +364,7 @@ public class Log extends AbstractLog {
|
||||||
|
|
||||||
final Options options = Options.instance(context);
|
final Options options = Options.instance(context);
|
||||||
initOptions(options);
|
initOptions(options);
|
||||||
options.addListener(new Runnable() {
|
options.addListener(() -> initOptions(options));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
initOptions(options);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// where
|
// where
|
||||||
private void initOptions(Options options) {
|
private void initOptions(Options options) {
|
||||||
|
|
|
@ -310,15 +310,12 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask {
|
||||||
|
|
||||||
private DiagnosticListener<JavaFileObject> getDiagnosticListenerForWriter(Writer w) {
|
private DiagnosticListener<JavaFileObject> getDiagnosticListenerForWriter(Writer w) {
|
||||||
final PrintWriter pw = getPrintWriterForWriter(w);
|
final PrintWriter pw = getPrintWriterForWriter(w);
|
||||||
return new DiagnosticListener<JavaFileObject> () {
|
return diagnostic -> {
|
||||||
@DefinedBy(Api.COMPILER)
|
|
||||||
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
|
|
||||||
if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
|
if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
|
||||||
pw.print(getMessage("err.prefix"));
|
pw.print(getMessage("err.prefix"));
|
||||||
pw.print(" ");
|
pw.print(" ");
|
||||||
}
|
}
|
||||||
pw.println(diagnostic.getMessage(null));
|
pw.println(diagnostic.getMessage(null));
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -487,7 +487,7 @@ public class JavacState {
|
||||||
Set<String> deps = pkg.typeDependencies()
|
Set<String> deps = pkg.typeDependencies()
|
||||||
.values()
|
.values()
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(s -> s.stream())
|
.flatMap(Collection::stream)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
for (String dep : deps) {
|
for (String dep : deps) {
|
||||||
String depPkg = ":" + dep.substring(0, dep.lastIndexOf('.'));
|
String depPkg = ":" + dep.substring(0, dep.lastIndexOf('.'));
|
||||||
|
|
|
@ -53,6 +53,7 @@ import javax.lang.model.element.TypeElement;
|
||||||
import javax.lang.model.element.VariableElement;
|
import javax.lang.model.element.VariableElement;
|
||||||
import javax.lang.model.type.DeclaredType;
|
import javax.lang.model.type.DeclaredType;
|
||||||
import javax.lang.model.type.TypeKind;
|
import javax.lang.model.type.TypeKind;
|
||||||
|
import javax.lang.model.type.TypeMirror;
|
||||||
import javax.lang.model.util.ElementFilter;
|
import javax.lang.model.util.ElementFilter;
|
||||||
import javax.tools.JavaCompiler;
|
import javax.tools.JavaCompiler;
|
||||||
import javax.tools.JavaFileManager;
|
import javax.tools.JavaFileManager;
|
||||||
|
@ -240,7 +241,7 @@ public abstract class JavadocHelper implements AutoCloseable {
|
||||||
List<String> throwsList =
|
List<String> throwsList =
|
||||||
executableElement.getThrownTypes()
|
executableElement.getThrownTypes()
|
||||||
.stream()
|
.stream()
|
||||||
.map(exc -> exc.toString())
|
.map(TypeMirror::toString)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
Set<String> missingParams = new HashSet<>(parameters);
|
Set<String> missingParams = new HashSet<>(parameters);
|
||||||
Set<String> missingThrows = new HashSet<>(throwsList);
|
Set<String> missingThrows = new HashSet<>(throwsList);
|
||||||
|
|
|
@ -31,6 +31,7 @@ import javax.tools.JavaFileObject;
|
||||||
import com.sun.tools.javac.code.Symbol.PackageSymbol;
|
import com.sun.tools.javac.code.Symbol.PackageSymbol;
|
||||||
import com.sun.tools.javac.code.ClassFinder;
|
import com.sun.tools.javac.code.ClassFinder;
|
||||||
import com.sun.tools.javac.util.Context;
|
import com.sun.tools.javac.util.Context;
|
||||||
|
import com.sun.tools.javac.util.Context.Factory;
|
||||||
|
|
||||||
/** Javadoc uses an extended class finder that records package.html entries
|
/** Javadoc uses an extended class finder that records package.html entries
|
||||||
*
|
*
|
||||||
|
@ -52,11 +53,7 @@ public class JavadocClassFinder extends ClassFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void preRegister(Context context) {
|
public static void preRegister(Context context) {
|
||||||
context.put(classFinderKey, new Context.Factory<ClassFinder>() {
|
context.put(classFinderKey, (Factory<ClassFinder>)JavadocClassFinder::new);
|
||||||
public ClassFinder make(Context c) {
|
|
||||||
return new JavadocClassFinder(c);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DocEnv docenv;
|
private DocEnv docenv;
|
||||||
|
|
|
@ -58,11 +58,7 @@ public class JavadocEnter extends Enter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void preRegister(Context context) {
|
public static void preRegister(Context context) {
|
||||||
context.put(enterKey, new Context.Factory<Enter>() {
|
context.put(enterKey, (Context.Factory<Enter>)JavadocEnter::new);
|
||||||
public Enter make(Context c) {
|
|
||||||
return new JavadocEnter(c);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JavadocEnter(Context context) {
|
protected JavadocEnter(Context context) {
|
||||||
|
|
|
@ -57,11 +57,7 @@ public class JavadocMemberEnter extends MemberEnter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void preRegister(Context context) {
|
public static void preRegister(Context context) {
|
||||||
context.put(memberEnterKey, new Context.Factory<MemberEnter>() {
|
context.put(memberEnterKey, (Context.Factory<MemberEnter>)JavadocMemberEnter::new);
|
||||||
public MemberEnter make(Context c) {
|
|
||||||
return new JavadocMemberEnter(c);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final DocEnv docenv;
|
final DocEnv docenv;
|
||||||
|
|
|
@ -27,6 +27,7 @@ package com.sun.tools.javadoc.main;
|
||||||
|
|
||||||
import com.sun.tools.javac.comp.*;
|
import com.sun.tools.javac.comp.*;
|
||||||
import com.sun.tools.javac.util.*;
|
import com.sun.tools.javac.util.*;
|
||||||
|
import com.sun.tools.javac.util.Context.Factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Javadoc's own todo queue doesn't queue its inputs, as javadoc
|
* Javadoc's own todo queue doesn't queue its inputs, as javadoc
|
||||||
|
@ -42,11 +43,7 @@ import com.sun.tools.javac.util.*;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class JavadocTodo extends Todo {
|
public class JavadocTodo extends Todo {
|
||||||
public static void preRegister(Context context) {
|
public static void preRegister(Context context) {
|
||||||
context.put(todoKey, new Context.Factory<Todo>() {
|
context.put(todoKey, (Factory<Todo>)JavadocTodo::new);
|
||||||
public Todo make(Context c) {
|
|
||||||
return new JavadocTodo(c);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JavadocTodo(Context context) {
|
protected JavadocTodo(Context context) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import java.util.ResourceBundle;
|
||||||
|
|
||||||
import com.sun.javadoc.*;
|
import com.sun.javadoc.*;
|
||||||
import com.sun.tools.javac.util.Context;
|
import com.sun.tools.javac.util.Context;
|
||||||
|
import com.sun.tools.javac.util.Context.Factory;
|
||||||
import com.sun.tools.javac.util.JCDiagnostic;
|
import com.sun.tools.javac.util.JCDiagnostic;
|
||||||
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
|
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
|
||||||
import com.sun.tools.javac.util.JavacMessages;
|
import com.sun.tools.javac.util.JavacMessages;
|
||||||
|
@ -66,27 +67,18 @@ public class Messager extends Log implements DocErrorReporter {
|
||||||
|
|
||||||
public static void preRegister(Context context,
|
public static void preRegister(Context context,
|
||||||
final String programName) {
|
final String programName) {
|
||||||
context.put(logKey, new Context.Factory<Log>() {
|
context.put(logKey, (Factory<Log>)c -> new Messager(c, programName));
|
||||||
public Log make(Context c) {
|
|
||||||
return new Messager(c,
|
|
||||||
programName);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
public static void preRegister(Context context,
|
public static void preRegister(Context context,
|
||||||
final String programName,
|
final String programName,
|
||||||
final PrintWriter errWriter,
|
final PrintWriter errWriter,
|
||||||
final PrintWriter warnWriter,
|
final PrintWriter warnWriter,
|
||||||
final PrintWriter noticeWriter) {
|
final PrintWriter noticeWriter) {
|
||||||
context.put(logKey, new Context.Factory<Log>() {
|
context.put(logKey, (Factory<Log>)c -> new Messager(c,
|
||||||
public Log make(Context c) {
|
|
||||||
return new Messager(c,
|
|
||||||
programName,
|
programName,
|
||||||
errWriter,
|
errWriter,
|
||||||
warnWriter,
|
warnWriter,
|
||||||
noticeWriter);
|
noticeWriter));
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ExitJavadoc extends Error {
|
public class ExitJavadoc extends Error {
|
||||||
|
|
|
@ -258,7 +258,7 @@ public abstract class AbstractMemberWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!set.isEmpty()) {
|
if (!set.isEmpty()) {
|
||||||
String mods = set.stream().map(m -> m.toString()).collect(Collectors.joining(" "));
|
String mods = set.stream().map(Modifier::toString).collect(Collectors.joining(" "));
|
||||||
htmltree.addContent(mods);
|
htmltree.addContent(mods);
|
||||||
htmltree.addContent(Contents.SPACE);
|
htmltree.addContent(Contents.SPACE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,9 +263,7 @@ public abstract class AbstractDoclet implements Doclet {
|
||||||
generateClassFiles(classtree);
|
generateClassFiles(classtree);
|
||||||
SortedSet<PackageElement> packages = new TreeSet<>(utils.makePackageComparator());
|
SortedSet<PackageElement> packages = new TreeSet<>(utils.makePackageComparator());
|
||||||
packages.addAll(configuration.getSpecifiedPackageElements());
|
packages.addAll(configuration.getSpecifiedPackageElements());
|
||||||
configuration.modulePackages.values().stream().forEach(pset -> {
|
configuration.modulePackages.values().stream().forEach(packages::addAll);
|
||||||
packages.addAll(pset);
|
|
||||||
});
|
|
||||||
for (PackageElement pkg : packages) {
|
for (PackageElement pkg : packages) {
|
||||||
generateClassFiles(utils.getAllClasses(pkg), classtree);
|
generateClassFiles(utils.getAllClasses(pkg), classtree);
|
||||||
}
|
}
|
||||||
|
|
|
@ -529,9 +529,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
|
||||||
buildInheritedSummary(writer, visibleMemberMap, summaryTreeList);
|
buildInheritedSummary(writer, visibleMemberMap, summaryTreeList);
|
||||||
if (!summaryTreeList.isEmpty()) {
|
if (!summaryTreeList.isEmpty()) {
|
||||||
Content memberTree = writer.getMemberSummaryHeader(typeElement, memberSummaryTree);
|
Content memberTree = writer.getMemberSummaryHeader(typeElement, memberSummaryTree);
|
||||||
summaryTreeList.stream().forEach((aSummaryTreeList) -> {
|
summaryTreeList.stream().forEach(memberTree::addContent);
|
||||||
memberTree.addContent(aSummaryTreeList);
|
|
||||||
});
|
|
||||||
writer.addMemberTree(memberSummaryTree, memberTree);
|
writer.addMemberTree(memberSummaryTree, memberTree);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -533,7 +533,7 @@ public class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
void addModifers(Set<Modifier> modifiers) {
|
void addModifers(Set<Modifier> modifiers) {
|
||||||
String s = set.stream().map(m -> m.toString()).collect(Collectors.joining(" "));
|
String s = set.stream().map(Modifier::toString).collect(Collectors.joining(" "));
|
||||||
sb.append(s);
|
sb.append(s);
|
||||||
if (!s.isEmpty())
|
if (!s.isEmpty())
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
|
|
@ -255,13 +255,9 @@ public abstract class LinkFactory {
|
||||||
vars.add(t.asType());
|
vars.add(t.asType());
|
||||||
});
|
});
|
||||||
} else if (linkInfo.type != null && utils.isDeclaredType(linkInfo.type)) {
|
} else if (linkInfo.type != null && utils.isDeclaredType(linkInfo.type)) {
|
||||||
((DeclaredType)linkInfo.type).getTypeArguments().stream().forEach((t) -> {
|
((DeclaredType)linkInfo.type).getTypeArguments().stream().forEach(vars::add);
|
||||||
vars.add(t);
|
|
||||||
});
|
|
||||||
} else if (ctype != null && utils.isDeclaredType(ctype)) {
|
} else if (ctype != null && utils.isDeclaredType(ctype)) {
|
||||||
((DeclaredType)ctype).getTypeArguments().stream().forEach((t) -> {
|
((DeclaredType)ctype).getTypeArguments().stream().forEach(vars::add);
|
||||||
vars.add(t);
|
|
||||||
});
|
|
||||||
} else if (linkInfo.typeElement != null) {
|
} else if (linkInfo.typeElement != null) {
|
||||||
linkInfo.typeElement.getTypeParameters().stream().forEach((t) -> {
|
linkInfo.typeElement.getTypeParameters().stream().forEach((t) -> {
|
||||||
vars.add(t.asType());
|
vars.add(t.asType());
|
||||||
|
|
|
@ -373,7 +373,7 @@ public class ElementsTable {
|
||||||
// scan for modules with qualified subpackages
|
// scan for modules with qualified subpackages
|
||||||
((List<String>)opts.computeIfAbsent(ToolOption.SUBPACKAGES, v -> Collections.EMPTY_LIST))
|
((List<String>)opts.computeIfAbsent(ToolOption.SUBPACKAGES, v -> Collections.EMPTY_LIST))
|
||||||
.stream()
|
.stream()
|
||||||
.map((packageName) -> new ModulePackage(packageName))
|
.map(ModulePackage::new)
|
||||||
.forEachOrdered((mpkg) -> {
|
.forEachOrdered((mpkg) -> {
|
||||||
subPackages.add(mpkg);
|
subPackages.add(mpkg);
|
||||||
if (mpkg.hasModule()) {
|
if (mpkg.hasModule()) {
|
||||||
|
@ -420,7 +420,7 @@ public class ElementsTable {
|
||||||
*/
|
*/
|
||||||
ElementsTable packages(Collection<String> packageNames) {
|
ElementsTable packages(Collection<String> packageNames) {
|
||||||
packageNames.stream()
|
packageNames.stream()
|
||||||
.map((packageName) -> new ModulePackage(packageName))
|
.map(ModulePackage::new)
|
||||||
.forEachOrdered((mpkg) -> cmdLinePackages.add(mpkg));
|
.forEachOrdered((mpkg) -> cmdLinePackages.add(mpkg));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -443,7 +443,7 @@ public class ElementsTable {
|
||||||
private void computeSubpackages() throws ToolException {
|
private void computeSubpackages() throws ToolException {
|
||||||
((List<String>) opts.computeIfAbsent(ToolOption.EXCLUDE, v -> Collections.EMPTY_LIST))
|
((List<String>) opts.computeIfAbsent(ToolOption.EXCLUDE, v -> Collections.EMPTY_LIST))
|
||||||
.stream()
|
.stream()
|
||||||
.map((packageName) -> new ModulePackage(packageName))
|
.map(ModulePackage::new)
|
||||||
.forEachOrdered((mpkg) -> excludePackages.add(mpkg));
|
.forEachOrdered((mpkg) -> excludePackages.add(mpkg));
|
||||||
|
|
||||||
excludePackages.forEach((p) -> {
|
excludePackages.forEach((p) -> {
|
||||||
|
|
|
@ -33,6 +33,7 @@ import com.sun.tools.javac.api.JavacTrees;
|
||||||
import com.sun.tools.javac.code.Symbol.PackageSymbol;
|
import com.sun.tools.javac.code.Symbol.PackageSymbol;
|
||||||
import com.sun.tools.javac.code.ClassFinder;
|
import com.sun.tools.javac.code.ClassFinder;
|
||||||
import com.sun.tools.javac.util.Context;
|
import com.sun.tools.javac.util.Context;
|
||||||
|
import com.sun.tools.javac.util.Context.Factory;
|
||||||
|
|
||||||
/** Javadoc uses an extended class finder that records package.html entries
|
/** Javadoc uses an extended class finder that records package.html entries
|
||||||
*
|
*
|
||||||
|
@ -53,11 +54,7 @@ public class JavadocClassFinder extends ClassFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void preRegister(Context context) {
|
public static void preRegister(Context context) {
|
||||||
context.put(classFinderKey, new Context.Factory<ClassFinder>() {
|
context.put(classFinderKey, (Factory<ClassFinder>)JavadocClassFinder::new);
|
||||||
public ClassFinder make(Context c) {
|
|
||||||
return new JavadocClassFinder(c);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ToolEnvironment toolEnv;
|
private ToolEnvironment toolEnv;
|
||||||
|
|
|
@ -57,11 +57,7 @@ public class JavadocEnter extends Enter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void preRegister(Context context) {
|
public static void preRegister(Context context) {
|
||||||
context.put(enterKey, new Context.Factory<Enter>() {
|
context.put(enterKey, (Context.Factory<Enter>)JavadocEnter::new);
|
||||||
public Enter make(Context c) {
|
|
||||||
return new JavadocEnter(c);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JavadocEnter(Context context) {
|
protected JavadocEnter(Context context) {
|
||||||
|
|
|
@ -56,11 +56,7 @@ public class JavadocMemberEnter extends MemberEnter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void preRegister(Context context) {
|
public static void preRegister(Context context) {
|
||||||
context.put(memberEnterKey, new Context.Factory<MemberEnter>() {
|
context.put(memberEnterKey, (Context.Factory<MemberEnter>)JavadocMemberEnter::new);
|
||||||
public MemberEnter make(Context c) {
|
|
||||||
return new JavadocMemberEnter(c);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final ToolEnvironment toolEnv;
|
final ToolEnvironment toolEnv;
|
||||||
|
|
|
@ -27,6 +27,7 @@ package jdk.javadoc.internal.tool;
|
||||||
|
|
||||||
import com.sun.tools.javac.comp.*;
|
import com.sun.tools.javac.comp.*;
|
||||||
import com.sun.tools.javac.util.*;
|
import com.sun.tools.javac.util.*;
|
||||||
|
import com.sun.tools.javac.util.Context.Factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Javadoc's own todo queue doesn't queue its inputs, as javadoc
|
* Javadoc's own todo queue doesn't queue its inputs, as javadoc
|
||||||
|
@ -41,11 +42,7 @@ import com.sun.tools.javac.util.*;
|
||||||
*/
|
*/
|
||||||
public class JavadocTodo extends Todo {
|
public class JavadocTodo extends Todo {
|
||||||
public static void preRegister(Context context) {
|
public static void preRegister(Context context) {
|
||||||
context.put(todoKey, new Context.Factory<Todo>() {
|
context.put(todoKey, (Factory<Todo>)JavadocTodo::new);
|
||||||
public Todo make(Context c) {
|
|
||||||
return new JavadocTodo(c);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JavadocTodo(Context context) {
|
protected JavadocTodo(Context context) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.util.ResourceBundle;
|
||||||
import javax.lang.model.element.Element;
|
import javax.lang.model.element.Element;
|
||||||
import javax.tools.Diagnostic.Kind;
|
import javax.tools.Diagnostic.Kind;
|
||||||
|
|
||||||
|
import com.sun.tools.javac.util.Context.Factory;
|
||||||
import jdk.javadoc.doclet.Reporter;
|
import jdk.javadoc.doclet.Reporter;
|
||||||
import com.sun.source.tree.CompilationUnitTree;
|
import com.sun.source.tree.CompilationUnitTree;
|
||||||
import com.sun.source.util.DocSourcePositions;
|
import com.sun.source.util.DocSourcePositions;
|
||||||
|
@ -73,20 +74,12 @@ public class Messager extends Log implements Reporter {
|
||||||
|
|
||||||
public static void preRegister(Context context,
|
public static void preRegister(Context context,
|
||||||
final String programName) {
|
final String programName) {
|
||||||
context.put(logKey, new Context.Factory<Log>() {
|
context.put(logKey, (Factory<Log>)c -> new Messager(c, programName));
|
||||||
public Log make(Context c) {
|
|
||||||
return new Messager(c, programName);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void preRegister(Context context, final String programName,
|
public static void preRegister(Context context, final String programName,
|
||||||
final PrintWriter outWriter, final PrintWriter errWriter) {
|
final PrintWriter outWriter, final PrintWriter errWriter) {
|
||||||
context.put(logKey, new Context.Factory<Log>() {
|
context.put(logKey, (Factory<Log>)c -> new Messager(c, programName, outWriter, errWriter));
|
||||||
public Log make(Context c) {
|
|
||||||
return new Messager(c, programName, outWriter, errWriter);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -211,7 +211,7 @@ public class Start extends ToolOption.Helper {
|
||||||
Stream.of(ToolOption.values())
|
Stream.of(ToolOption.values())
|
||||||
.filter(opt -> opt.kind == kind)
|
.filter(opt -> opt.kind == kind)
|
||||||
.sorted(comp)
|
.sorted(comp)
|
||||||
.forEach(opt -> showToolOption(opt));
|
.forEach(this::showToolOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showToolOption(ToolOption option) {
|
void showToolOption(ToolOption option) {
|
||||||
|
@ -241,7 +241,7 @@ public class Start extends ToolOption.Helper {
|
||||||
doclet.getSupportedOptions().stream()
|
doclet.getSupportedOptions().stream()
|
||||||
.filter(opt -> opt.getKind() == kind)
|
.filter(opt -> opt.getKind() == kind)
|
||||||
.sorted(comp)
|
.sorted(comp)
|
||||||
.forEach(opt -> showDocletOption(opt));
|
.forEach(this::showDocletOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showDocletOption(Doclet.Option option) {
|
void showDocletOption(Doclet.Option option) {
|
||||||
|
|
|
@ -103,9 +103,7 @@ public class Code_attribute extends Attribute {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<Instruction> getInstructions() {
|
public Iterable<Instruction> getInstructions() {
|
||||||
return new Iterable<Instruction>() {
|
return () -> new Iterator<Instruction>() {
|
||||||
public Iterator<Instruction> iterator() {
|
|
||||||
return new Iterator<Instruction>() {
|
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return (next != null);
|
return (next != null);
|
||||||
|
@ -132,9 +130,6 @@ public class Code_attribute extends Attribute {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int max_stack;
|
public final int max_stack;
|
||||||
public final int max_locals;
|
public final int max_locals;
|
||||||
public final int code_length;
|
public final int code_length;
|
||||||
|
|
|
@ -313,9 +313,7 @@ public class ConstantPool {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<CPInfo> entries() {
|
public Iterable<CPInfo> entries() {
|
||||||
return new Iterable<CPInfo>() {
|
return () -> new Iterator<CPInfo>() {
|
||||||
public Iterator<CPInfo> iterator() {
|
|
||||||
return new Iterator<CPInfo>() {
|
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return next < pool.length;
|
return next < pool.length;
|
||||||
|
@ -343,8 +341,6 @@ public class ConstantPool {
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private CPInfo[] pool;
|
private CPInfo[] pool;
|
||||||
|
|
||||||
|
|
|
@ -248,11 +248,7 @@ public class Dependencies {
|
||||||
boolean transitiveClosure)
|
boolean transitiveClosure)
|
||||||
throws ClassFileNotFoundException {
|
throws ClassFileNotFoundException {
|
||||||
final Set<Dependency> results = new HashSet<>();
|
final Set<Dependency> results = new HashSet<>();
|
||||||
Recorder r = new Recorder() {
|
Recorder r = results::add;
|
||||||
public void addDependency(Dependency d) {
|
|
||||||
results.add(d);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
findAllDependencies(classFinder, rootClassNames, transitiveClosure, r);
|
findAllDependencies(classFinder, rootClassNames, transitiveClosure, r);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
@ -565,7 +561,7 @@ public class Dependencies {
|
||||||
private Map<String,Location> locations = new ConcurrentHashMap<>();
|
private Map<String,Location> locations = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
Location getLocation(String className) {
|
Location getLocation(String className) {
|
||||||
return locations.computeIfAbsent(className, cn -> new SimpleLocation(cn));
|
return locations.computeIfAbsent(className, SimpleLocation::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Visitor implements ConstantPool.Visitor<Void,Void>, Type.Visitor<Void, Void> {
|
class Visitor implements ConstantPool.Visitor<Void,Void>, Type.Visitor<Void, Void> {
|
||||||
|
|
|
@ -408,8 +408,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||||
|
|
||||||
private DiagnosticListener<JavaFileObject> getDiagnosticListenerForWriter(Writer w) {
|
private DiagnosticListener<JavaFileObject> getDiagnosticListenerForWriter(Writer w) {
|
||||||
final PrintWriter pw = getPrintWriterForWriter(w);
|
final PrintWriter pw = getPrintWriterForWriter(w);
|
||||||
return new DiagnosticListener<JavaFileObject> () {
|
return diagnostic -> {
|
||||||
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
|
|
||||||
switch (diagnostic.getKind()) {
|
switch (diagnostic.getKind()) {
|
||||||
case ERROR:
|
case ERROR:
|
||||||
pw.print(getMessage("err.prefix"));
|
pw.print(getMessage("err.prefix"));
|
||||||
|
@ -423,7 +422,6 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||||
}
|
}
|
||||||
pw.print(" ");
|
pw.print(" ");
|
||||||
pw.println(diagnostic.getMessage(null));
|
pw.println(diagnostic.getMessage(null));
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,11 +147,7 @@ public class ClassFileReader implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<ClassFile> getClassFiles() throws IOException {
|
public Iterable<ClassFile> getClassFiles() throws IOException {
|
||||||
return new Iterable<ClassFile>() {
|
return FileIterator::new;
|
||||||
public Iterator<ClassFile> iterator() {
|
|
||||||
return new FileIterator();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ClassFile readClassFile(Path p) throws IOException {
|
protected ClassFile readClassFile(Path p) throws IOException {
|
||||||
|
@ -232,7 +228,7 @@ public class ClassFileReader implements Closeable {
|
||||||
protected Set<String> scan() {
|
protected Set<String> scan() {
|
||||||
try (Stream<Path> stream = Files.walk(path, Integer.MAX_VALUE)) {
|
try (Stream<Path> stream = Files.walk(path, Integer.MAX_VALUE)) {
|
||||||
return stream.filter(ClassFileReader::isClass)
|
return stream.filter(ClassFileReader::isClass)
|
||||||
.map(f -> path.relativize(f))
|
.map(path::relativize)
|
||||||
.map(Path::toString)
|
.map(Path::toString)
|
||||||
.map(p -> p.replace(File.separatorChar, '/'))
|
.map(p -> p.replace(File.separatorChar, '/'))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
@ -264,11 +260,7 @@ public class ClassFileReader implements Closeable {
|
||||||
|
|
||||||
public Iterable<ClassFile> getClassFiles() throws IOException {
|
public Iterable<ClassFile> getClassFiles() throws IOException {
|
||||||
final Iterator<ClassFile> iter = new DirectoryIterator();
|
final Iterator<ClassFile> iter = new DirectoryIterator();
|
||||||
return new Iterable<ClassFile>() {
|
return () -> iter;
|
||||||
public Iterator<ClassFile> iterator() {
|
|
||||||
return iter;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectoryIterator implements Iterator<ClassFile> {
|
class DirectoryIterator implements Iterator<ClassFile> {
|
||||||
|
@ -387,11 +379,7 @@ public class ClassFileReader implements Closeable {
|
||||||
|
|
||||||
public Iterable<ClassFile> getClassFiles() throws IOException {
|
public Iterable<ClassFile> getClassFiles() throws IOException {
|
||||||
final Iterator<ClassFile> iter = new JarFileIterator(this, jarfile);
|
final Iterator<ClassFile> iter = new JarFileIterator(this, jarfile);
|
||||||
return new Iterable<ClassFile>() {
|
return () -> iter;
|
||||||
public Iterator<ClassFile> iterator() {
|
|
||||||
return iter;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import com.sun.tools.classfile.AccessFlags;
|
||||||
import com.sun.tools.classfile.ClassFile;
|
import com.sun.tools.classfile.ClassFile;
|
||||||
import com.sun.tools.classfile.ConstantPoolException;
|
import com.sun.tools.classfile.ConstantPoolException;
|
||||||
import com.sun.tools.classfile.Dependencies;
|
import com.sun.tools.classfile.Dependencies;
|
||||||
|
import com.sun.tools.classfile.Dependencies.ClassFileError;
|
||||||
import com.sun.tools.classfile.Dependency;
|
import com.sun.tools.classfile.Dependency;
|
||||||
import com.sun.tools.classfile.Dependency.Location;
|
import com.sun.tools.classfile.Dependency.Location;
|
||||||
|
|
||||||
|
@ -172,8 +173,7 @@ class DependencyFinder {
|
||||||
parsedArchives.get(finder).add(archive);
|
parsedArchives.get(finder).add(archive);
|
||||||
|
|
||||||
trace("parsing %s %s%n", archive.getName(), archive.path());
|
trace("parsing %s %s%n", archive.getName(), archive.path());
|
||||||
FutureTask<Set<Location>> task = new FutureTask<>(new Callable<>() {
|
FutureTask<Set<Location>> task = new FutureTask<>(() -> {
|
||||||
public Set<Location> call() throws Exception {
|
|
||||||
Set<Location> targets = new HashSet<>();
|
Set<Location> targets = new HashSet<>();
|
||||||
for (ClassFile cf : archive.reader().getClassFiles()) {
|
for (ClassFile cf : archive.reader().getClassFiles()) {
|
||||||
if (cf.access_flags.is(AccessFlags.ACC_MODULE))
|
if (cf.access_flags.is(AccessFlags.ACC_MODULE))
|
||||||
|
@ -183,7 +183,7 @@ class DependencyFinder {
|
||||||
try {
|
try {
|
||||||
classFileName = cf.getName();
|
classFileName = cf.getName();
|
||||||
} catch (ConstantPoolException e) {
|
} catch (ConstantPoolException e) {
|
||||||
throw new Dependencies.ClassFileError(e);
|
throw new ClassFileError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter source class/archive
|
// filter source class/archive
|
||||||
|
@ -208,7 +208,6 @@ class DependencyFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
return targets;
|
return targets;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
tasks.add(task);
|
tasks.add(task);
|
||||||
pool.submit(task);
|
pool.submit(task);
|
||||||
|
|
|
@ -209,7 +209,7 @@ public final class Graph<T> {
|
||||||
visited.add(node);
|
visited.add(node);
|
||||||
edges.get(node).stream()
|
edges.get(node).stream()
|
||||||
.filter(e -> includeAdjacent || !node.equals(u) || !e.equals(v))
|
.filter(e -> includeAdjacent || !node.equals(u) || !e.equals(v))
|
||||||
.forEach(e -> stack.push(e));
|
.forEach(stack::push);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert !visited.contains(v);
|
assert !visited.contains(v);
|
||||||
|
|
|
@ -394,10 +394,7 @@ public class JdepsConfiguration implements AutoCloseable {
|
||||||
ModuleDescriptor descriptor = dropHashes(ModuleDescriptor.read(bin));
|
ModuleDescriptor descriptor = dropHashes(ModuleDescriptor.read(bin));
|
||||||
String mn = descriptor.name();
|
String mn = descriptor.name();
|
||||||
URI uri = URI.create("jrt:/" + path.getFileName().toString());
|
URI uri = URI.create("jrt:/" + path.getFileName().toString());
|
||||||
Supplier<ModuleReader> readerSupplier = new Supplier<>() {
|
Supplier<ModuleReader> readerSupplier = () -> new ModuleReader() {
|
||||||
@Override
|
|
||||||
public ModuleReader get() {
|
|
||||||
return new ModuleReader() {
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<URI> find(String name) throws IOException {
|
public Optional<URI> find(String name) throws IOException {
|
||||||
return name.equals(mn)
|
return name.equals(mn)
|
||||||
|
@ -413,8 +410,6 @@ public class JdepsConfiguration implements AutoCloseable {
|
||||||
public void close() {
|
public void close() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return new ModuleReference(descriptor, uri) {
|
return new ModuleReference(descriptor, uri) {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -889,14 +889,10 @@ class JdepsTask {
|
||||||
if (!ok && !options.nowarning) {
|
if (!ok && !options.nowarning) {
|
||||||
reportError("err.missing.dependences");
|
reportError("err.missing.dependences");
|
||||||
builder.visitMissingDeps(
|
builder.visitMissingDeps(
|
||||||
new Analyzer.Visitor() {
|
(origin, originArchive, target, targetArchive) -> {
|
||||||
@Override
|
|
||||||
public void visitDependence(String origin, Archive originArchive,
|
|
||||||
String target, Archive targetArchive) {
|
|
||||||
if (builder.notFound(targetArchive))
|
if (builder.notFound(targetArchive))
|
||||||
log.format(" %-50s -> %-50s %s%n",
|
log.format(" %-50s -> %-50s %s%n",
|
||||||
origin, target, targetArchive.getName());
|
origin, target, targetArchive.getName());
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
|
|
|
@ -69,11 +69,7 @@ public class ModuleExportsAnalyzer extends DepsAnalyzer {
|
||||||
|
|
||||||
// A visitor to record the module-level dependences as well as
|
// A visitor to record the module-level dependences as well as
|
||||||
// use of JDK internal APIs
|
// use of JDK internal APIs
|
||||||
Analyzer.Visitor visitor = new Analyzer.Visitor() {
|
Analyzer.Visitor visitor = (origin, originArchive, target, targetArchive) -> {
|
||||||
@Override
|
|
||||||
public void visitDependence(String origin, Archive originArchive,
|
|
||||||
String target, Archive targetArchive)
|
|
||||||
{
|
|
||||||
Set<String> jdkInternals =
|
Set<String> jdkInternals =
|
||||||
deps.computeIfAbsent(originArchive, _k -> new HashMap<>())
|
deps.computeIfAbsent(originArchive, _k -> new HashMap<>())
|
||||||
.computeIfAbsent(targetArchive, _k -> new HashSet<>());
|
.computeIfAbsent(targetArchive, _k -> new HashSet<>());
|
||||||
|
@ -84,7 +80,6 @@ public class ModuleExportsAnalyzer extends DepsAnalyzer {
|
||||||
// use of JDK internal APIs
|
// use of JDK internal APIs
|
||||||
jdkInternals.add(target);
|
jdkInternals.add(target);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// visit the dependences
|
// visit the dependences
|
||||||
|
|
|
@ -150,6 +150,6 @@ enum Profile {
|
||||||
}
|
}
|
||||||
System.out.println("All JDK modules:-");
|
System.out.println("All JDK modules:-");
|
||||||
JDK.stream().sorted(Comparator.comparing(Module::name))
|
JDK.stream().sorted(Comparator.comparing(Module::name))
|
||||||
.forEach(m -> System.out.println(m));
|
.forEach(System.out::println);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,7 +141,7 @@ class ArgTokenizer {
|
||||||
*/
|
*/
|
||||||
int optionCount() {
|
int optionCount() {
|
||||||
return (int) options.entrySet().stream()
|
return (int) options.entrySet().stream()
|
||||||
.filter(e -> e.getValue())
|
.filter(Entry::getValue)
|
||||||
.count();
|
.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ class ConsoleIOContext extends IOContext {
|
||||||
|
|
||||||
boolean smart = allowSmart &&
|
boolean smart = allowSmart &&
|
||||||
suggestions.stream()
|
suggestions.stream()
|
||||||
.anyMatch(s -> s.matchesType());
|
.anyMatch(Suggestion::matchesType);
|
||||||
|
|
||||||
lastTest = test;
|
lastTest = test;
|
||||||
lastCursor = cursor;
|
lastCursor = cursor;
|
||||||
|
@ -133,16 +133,16 @@ class ConsoleIOContext extends IOContext {
|
||||||
|
|
||||||
suggestions.stream()
|
suggestions.stream()
|
||||||
.filter(s -> !smart || s.matchesType())
|
.filter(s -> !smart || s.matchesType())
|
||||||
.map(s -> s.continuation())
|
.map(Suggestion::continuation)
|
||||||
.forEach(result::add);
|
.forEach(result::add);
|
||||||
|
|
||||||
boolean onlySmart = suggestions.stream()
|
boolean onlySmart = suggestions.stream()
|
||||||
.allMatch(s -> s.matchesType());
|
.allMatch(Suggestion::matchesType);
|
||||||
|
|
||||||
if (smart && !onlySmart) {
|
if (smart && !onlySmart) {
|
||||||
Optional<String> prefix =
|
Optional<String> prefix =
|
||||||
suggestions.stream()
|
suggestions.stream()
|
||||||
.map(s -> s.continuation())
|
.map(Suggestion::continuation)
|
||||||
.reduce(ConsoleIOContext::commonPrefix);
|
.reduce(ConsoleIOContext::commonPrefix);
|
||||||
|
|
||||||
String prefixStr = prefix.orElse("").substring(cursor - anchor[0]);
|
String prefixStr = prefix.orElse("").substring(cursor - anchor[0]);
|
||||||
|
@ -281,7 +281,7 @@ class ConsoleIOContext extends IOContext {
|
||||||
term.isAnsiSupported());
|
term.isAnsiSupported());
|
||||||
Function<Documentation, String> convertor;
|
Function<Documentation, String> convertor;
|
||||||
if (firstInvocation) {
|
if (firstInvocation) {
|
||||||
convertor = d -> d.signature();
|
convertor = Documentation::signature;
|
||||||
} else {
|
} else {
|
||||||
convertor = d -> formatter.formatJavadoc(d.signature(), d.javadoc()) +
|
convertor = d -> formatter.formatJavadoc(d.signature(), d.javadoc()) +
|
||||||
(d.javadoc() == null ? repl.messageFormat("jshell.console.no.javadoc")
|
(d.javadoc() == null ? repl.messageFormat("jshell.console.no.javadoc")
|
||||||
|
|
|
@ -38,10 +38,8 @@ import jdk.jshell.SourceCodeAnalysis.Suggestion;
|
||||||
|
|
||||||
class ContinuousCompletionProvider implements CompletionProvider {
|
class ContinuousCompletionProvider implements CompletionProvider {
|
||||||
|
|
||||||
static final BiPredicate<String, String> STARTSWITH_MATCHER =
|
static final BiPredicate<String, String> STARTSWITH_MATCHER = String::startsWith;
|
||||||
(word, input) -> word.startsWith(input);
|
static final BiPredicate<String, String> PERFECT_MATCHER = String::equals;
|
||||||
static final BiPredicate<String, String> PERFECT_MATCHER =
|
|
||||||
(word, input) -> word.equals(input);
|
|
||||||
|
|
||||||
private final Supplier<Map<String, CompletionProvider>> wordCompletionProviderSupplier;
|
private final Supplier<Map<String, CompletionProvider>> wordCompletionProviderSupplier;
|
||||||
private final BiPredicate<String, String> matcher;
|
private final BiPredicate<String, String> matcher;
|
||||||
|
|
|
@ -882,7 +882,7 @@ class Feedback {
|
||||||
|
|
||||||
void showTruncationSettings(Mode sm) {
|
void showTruncationSettings(Mode sm) {
|
||||||
if (sm == null) {
|
if (sm == null) {
|
||||||
modeMap.values().forEach(m -> showTruncationSettings(m));
|
modeMap.values().forEach(this::showTruncationSettings);
|
||||||
} else {
|
} else {
|
||||||
List<Mode.Setting> trunc = sm.cases.get(TRUNCATION_FIELD);
|
List<Mode.Setting> trunc = sm.cases.get(TRUNCATION_FIELD);
|
||||||
if (trunc != null) {
|
if (trunc != null) {
|
||||||
|
@ -897,7 +897,7 @@ class Feedback {
|
||||||
|
|
||||||
void showPromptSettings(Mode sm) {
|
void showPromptSettings(Mode sm) {
|
||||||
if (sm == null) {
|
if (sm == null) {
|
||||||
modeMap.values().forEach(m -> showPromptSettings(m));
|
modeMap.values().forEach(this::showPromptSettings);
|
||||||
} else {
|
} else {
|
||||||
hard("/set prompt %s %s %s",
|
hard("/set prompt %s %s %s",
|
||||||
sm.name,
|
sm.name,
|
||||||
|
@ -908,7 +908,7 @@ class Feedback {
|
||||||
|
|
||||||
void showModeSettings(String umode, String msg) {
|
void showModeSettings(String umode, String msg) {
|
||||||
if (umode == null) {
|
if (umode == null) {
|
||||||
modeMap.values().forEach(n -> showModeSettings(n));
|
modeMap.values().forEach(this::showModeSettings);
|
||||||
} else {
|
} else {
|
||||||
Mode m;
|
Mode m;
|
||||||
String retained = retainedMap.get(umode);
|
String retained = retainedMap.get(umode);
|
||||||
|
@ -1272,7 +1272,7 @@ class Feedback {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (at.isQuoted() ||
|
if (at.isQuoted() ||
|
||||||
!id.codePoints().allMatch(cp -> Character.isJavaIdentifierPart(cp))) {
|
!id.codePoints().allMatch(Character::isJavaIdentifierPart)) {
|
||||||
errorat(err, id);
|
errorat(err, id);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1307,8 +1307,8 @@ class Feedback {
|
||||||
// Failing an exact match, go searching
|
// Failing an exact match, go searching
|
||||||
Mode[] matches = modeMap.entrySet().stream()
|
Mode[] matches = modeMap.entrySet().stream()
|
||||||
.filter(e -> e.getKey().startsWith(umode))
|
.filter(e -> e.getKey().startsWith(umode))
|
||||||
.map(e -> e.getValue())
|
.map(Entry::getValue)
|
||||||
.toArray(size -> new Mode[size]);
|
.toArray(Mode[]::new);
|
||||||
if (matches.length == 1) {
|
if (matches.length == 1) {
|
||||||
return matches[0];
|
return matches[0];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -452,7 +452,7 @@ public class JShellTool implements MessageHandler {
|
||||||
<T> void hardPairs(Stream<T> stream, Function<T, String> a, Function<T, String> b) {
|
<T> void hardPairs(Stream<T> stream, Function<T, String> a, Function<T, String> b) {
|
||||||
Map<String, String> a2b = stream.collect(toMap(a, b,
|
Map<String, String> a2b = stream.collect(toMap(a, b,
|
||||||
(m1, m2) -> m1,
|
(m1, m2) -> m1,
|
||||||
() -> new LinkedHashMap<>()));
|
LinkedHashMap::new));
|
||||||
for (Entry<String, String> e : a2b.entrySet()) {
|
for (Entry<String, String> e : a2b.entrySet()) {
|
||||||
hard("%s", e.getKey());
|
hard("%s", e.getKey());
|
||||||
rawout(prefix(e.getValue(), feedback.getPre() + "\t", feedback.getPost()));
|
rawout(prefix(e.getValue(), feedback.getPre() + "\t", feedback.getPost()));
|
||||||
|
@ -953,7 +953,7 @@ public class JShellTool implements MessageHandler {
|
||||||
.stream()
|
.stream()
|
||||||
.filter(filter)
|
.filter(filter)
|
||||||
.filter(command -> command.command.startsWith(cmd))
|
.filter(command -> command.command.startsWith(cmd))
|
||||||
.toArray(size -> new Command[size]);
|
.toArray(Command[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Path toPathResolvingUserHome(String pathString) {
|
private static Path toPathResolvingUserHome(String pathString) {
|
||||||
|
@ -1125,7 +1125,7 @@ public class JShellTool implements MessageHandler {
|
||||||
? Stream.of(String.valueOf(k.id()) + " ", ((DeclarationSnippet) k).name() + " ")
|
? Stream.of(String.valueOf(k.id()) + " ", ((DeclarationSnippet) k).name() + " ")
|
||||||
: Stream.of(String.valueOf(k.id()) + " "))
|
: Stream.of(String.valueOf(k.id()) + " "))
|
||||||
.filter(k -> k.startsWith(argPrefix))
|
.filter(k -> k.startsWith(argPrefix))
|
||||||
.map(k -> new ArgSuggestion(k))
|
.map(ArgSuggestion::new)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1154,7 +1154,7 @@ public class JShellTool implements MessageHandler {
|
||||||
result = new FixedCompletionProvider(commands.values().stream()
|
result = new FixedCompletionProvider(commands.values().stream()
|
||||||
.filter(cmd -> cmd.kind.showInHelp || cmd.kind == CommandKind.HELP_SUBJECT)
|
.filter(cmd -> cmd.kind.showInHelp || cmd.kind == CommandKind.HELP_SUBJECT)
|
||||||
.map(c -> c.command + " ")
|
.map(c -> c.command + " ")
|
||||||
.toArray(size -> new String[size]))
|
.toArray(String[]::new))
|
||||||
.completionSuggestions(code, cursor, anchor);
|
.completionSuggestions(code, cursor, anchor);
|
||||||
} else if (code.startsWith("/se")) {
|
} else if (code.startsWith("/se")) {
|
||||||
result = new FixedCompletionProvider(SET_SUBCOMMANDS)
|
result = new FixedCompletionProvider(SET_SUBCOMMANDS)
|
||||||
|
@ -1264,33 +1264,33 @@ public class JShellTool implements MessageHandler {
|
||||||
|
|
||||||
{
|
{
|
||||||
registerCommand(new Command("/list",
|
registerCommand(new Command("/list",
|
||||||
arg -> cmdList(arg),
|
this::cmdList,
|
||||||
snippetWithOptionCompletion(SNIPPET_HISTORY_OPTION_COMPLETION_PROVIDER,
|
snippetWithOptionCompletion(SNIPPET_HISTORY_OPTION_COMPLETION_PROVIDER,
|
||||||
this::allSnippets)));
|
this::allSnippets)));
|
||||||
registerCommand(new Command("/edit",
|
registerCommand(new Command("/edit",
|
||||||
arg -> cmdEdit(arg),
|
this::cmdEdit,
|
||||||
snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
|
snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
|
||||||
this::allSnippets)));
|
this::allSnippets)));
|
||||||
registerCommand(new Command("/drop",
|
registerCommand(new Command("/drop",
|
||||||
arg -> cmdDrop(arg),
|
this::cmdDrop,
|
||||||
snippetCompletion(this::dropableSnippets),
|
snippetCompletion(this::dropableSnippets),
|
||||||
CommandKind.REPLAY));
|
CommandKind.REPLAY));
|
||||||
registerCommand(new Command("/save",
|
registerCommand(new Command("/save",
|
||||||
arg -> cmdSave(arg),
|
this::cmdSave,
|
||||||
saveCompletion()));
|
saveCompletion()));
|
||||||
registerCommand(new Command("/open",
|
registerCommand(new Command("/open",
|
||||||
arg -> cmdOpen(arg),
|
this::cmdOpen,
|
||||||
FILE_COMPLETION_PROVIDER));
|
FILE_COMPLETION_PROVIDER));
|
||||||
registerCommand(new Command("/vars",
|
registerCommand(new Command("/vars",
|
||||||
arg -> cmdVars(arg),
|
this::cmdVars,
|
||||||
snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
|
snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
|
||||||
this::allVarSnippets)));
|
this::allVarSnippets)));
|
||||||
registerCommand(new Command("/methods",
|
registerCommand(new Command("/methods",
|
||||||
arg -> cmdMethods(arg),
|
this::cmdMethods,
|
||||||
snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
|
snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
|
||||||
this::allMethodSnippets)));
|
this::allMethodSnippets)));
|
||||||
registerCommand(new Command("/types",
|
registerCommand(new Command("/types",
|
||||||
arg -> cmdTypes(arg),
|
this::cmdTypes,
|
||||||
snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
|
snippetWithOptionCompletion(SNIPPET_OPTION_COMPLETION_PROVIDER,
|
||||||
this::allTypeSnippets)));
|
this::allTypeSnippets)));
|
||||||
registerCommand(new Command("/imports",
|
registerCommand(new Command("/imports",
|
||||||
|
@ -1303,24 +1303,24 @@ public class JShellTool implements MessageHandler {
|
||||||
arg -> cmdReset(),
|
arg -> cmdReset(),
|
||||||
EMPTY_COMPLETION_PROVIDER));
|
EMPTY_COMPLETION_PROVIDER));
|
||||||
registerCommand(new Command("/reload",
|
registerCommand(new Command("/reload",
|
||||||
arg -> cmdReload(arg),
|
this::cmdReload,
|
||||||
reloadCompletion()));
|
reloadCompletion()));
|
||||||
registerCommand(new Command("/classpath",
|
registerCommand(new Command("/classpath",
|
||||||
arg -> cmdClasspath(arg),
|
this::cmdClasspath,
|
||||||
classPathCompletion(),
|
classPathCompletion(),
|
||||||
CommandKind.REPLAY));
|
CommandKind.REPLAY));
|
||||||
registerCommand(new Command("/history",
|
registerCommand(new Command("/history",
|
||||||
arg -> cmdHistory(),
|
arg -> cmdHistory(),
|
||||||
EMPTY_COMPLETION_PROVIDER));
|
EMPTY_COMPLETION_PROVIDER));
|
||||||
registerCommand(new Command("/debug",
|
registerCommand(new Command("/debug",
|
||||||
arg -> cmdDebug(arg),
|
this::cmdDebug,
|
||||||
EMPTY_COMPLETION_PROVIDER,
|
EMPTY_COMPLETION_PROVIDER,
|
||||||
CommandKind.HIDDEN));
|
CommandKind.HIDDEN));
|
||||||
registerCommand(new Command("/help",
|
registerCommand(new Command("/help",
|
||||||
arg -> cmdHelp(arg),
|
this::cmdHelp,
|
||||||
helpCompletion()));
|
helpCompletion()));
|
||||||
registerCommand(new Command("/set",
|
registerCommand(new Command("/set",
|
||||||
arg -> cmdSet(arg),
|
this::cmdSet,
|
||||||
new ContinuousCompletionProvider(Map.of(
|
new ContinuousCompletionProvider(Map.of(
|
||||||
// need more completion for format for usability
|
// need more completion for format for usability
|
||||||
"format", feedback.modeCompletions(),
|
"format", feedback.modeCompletions(),
|
||||||
|
@ -1335,7 +1335,7 @@ public class JShellTool implements MessageHandler {
|
||||||
STARTSWITH_MATCHER)));
|
STARTSWITH_MATCHER)));
|
||||||
registerCommand(new Command("/?",
|
registerCommand(new Command("/?",
|
||||||
"help.quest",
|
"help.quest",
|
||||||
arg -> cmdHelp(arg),
|
this::cmdHelp,
|
||||||
helpCompletion(),
|
helpCompletion(),
|
||||||
CommandKind.NORMAL));
|
CommandKind.NORMAL));
|
||||||
registerCommand(new Command("/!",
|
registerCommand(new Command("/!",
|
||||||
|
@ -1450,7 +1450,7 @@ public class JShellTool implements MessageHandler {
|
||||||
}
|
}
|
||||||
String[] matches = Arrays.stream(subs)
|
String[] matches = Arrays.stream(subs)
|
||||||
.filter(s -> s.startsWith(sub))
|
.filter(s -> s.startsWith(sub))
|
||||||
.toArray(size -> new String[size]);
|
.toArray(String[]::new);
|
||||||
if (matches.length == 0) {
|
if (matches.length == 0) {
|
||||||
// There are no matching sub-commands
|
// There are no matching sub-commands
|
||||||
errormsg("jshell.err.arg", cmd, sub);
|
errormsg("jshell.err.arg", cmd, sub);
|
||||||
|
@ -1784,7 +1784,7 @@ public class JShellTool implements MessageHandler {
|
||||||
if (subject != null) {
|
if (subject != null) {
|
||||||
Command[] matches = commands.values().stream()
|
Command[] matches = commands.values().stream()
|
||||||
.filter(c -> c.command.startsWith(subject))
|
.filter(c -> c.command.startsWith(subject))
|
||||||
.toArray(size -> new Command[size]);
|
.toArray(Command[]::new);
|
||||||
if (matches.length == 1) {
|
if (matches.length == 1) {
|
||||||
String cmd = matches[0].command;
|
String cmd = matches[0].command;
|
||||||
if (cmd.equals("/set")) {
|
if (cmd.equals("/set")) {
|
||||||
|
@ -2414,7 +2414,7 @@ public class JShellTool implements MessageHandler {
|
||||||
*/
|
*/
|
||||||
List<Diag> errorsOnly(List<Diag> diagnostics) {
|
List<Diag> errorsOnly(List<Diag> diagnostics) {
|
||||||
return diagnostics.stream()
|
return diagnostics.stream()
|
||||||
.filter(d -> d.isError())
|
.filter(Diag::isError)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,7 @@ public final class StopDetectingInputStream extends InputStream {
|
||||||
throw new IllegalStateException("Already initialized.");
|
throw new IllegalStateException("Already initialized.");
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
Thread reader = new Thread() {
|
Thread reader = new Thread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
int read;
|
int read;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -61,14 +59,14 @@ public final class StopDetectingInputStream extends InputStream {
|
||||||
//an external editor is running. At the same time, it needs to run while the
|
//an external editor is running. At the same time, it needs to run while the
|
||||||
//user's code is running (so Ctrl-C is detected). Hence waiting here until
|
//user's code is running (so Ctrl-C is detected). Hence waiting here until
|
||||||
//there is a confirmed need for input.
|
//there is a confirmed need for input.
|
||||||
StopDetectingInputStream.State currentState = waitInputNeeded();
|
State currentState = waitInputNeeded();
|
||||||
if (currentState == StopDetectingInputStream.State.CLOSED) {
|
if (currentState == State.CLOSED) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((read = input.read()) == (-1)) {
|
if ((read = input.read()) == (-1)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (read == 3 && currentState == StopDetectingInputStream.State.BUFFER) {
|
if (read == 3 && currentState == State.BUFFER) {
|
||||||
stop.run();
|
stop.run();
|
||||||
} else {
|
} else {
|
||||||
write(read);
|
write(read);
|
||||||
|
@ -79,8 +77,7 @@ public final class StopDetectingInputStream extends InputStream {
|
||||||
} finally {
|
} finally {
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
};
|
|
||||||
reader.setDaemon(true);
|
reader.setDaemon(true);
|
||||||
reader.start();
|
reader.start();
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,6 @@ class ClassTracker {
|
||||||
|
|
||||||
// Lookup the ClassInfo by class name, create if it does not exist.
|
// Lookup the ClassInfo by class name, create if it does not exist.
|
||||||
ClassInfo get(String className) {
|
ClassInfo get(String className) {
|
||||||
return map.computeIfAbsent(className, k -> new ClassInfo(k));
|
return map.computeIfAbsent(className, ClassInfo::new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ final class DiagList extends ArrayList<Diag> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAll(Collection<? extends Diag> c) {
|
public boolean addAll(Collection<? extends Diag> c) {
|
||||||
return c.stream().filter(d -> add(d)).count() > 0;
|
return c.stream().filter(this::add).count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,7 +110,7 @@ final class DiagList extends ArrayList<Diag> {
|
||||||
Snippet snn = d.snippetOrNull();
|
Snippet snn = d.snippetOrNull();
|
||||||
return snn == u.snippet();
|
return snn == u.snippet();
|
||||||
})
|
})
|
||||||
.collect(Collectors.toCollection(() -> new DiagList()));
|
.collect(Collectors.toCollection(DiagList::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasErrors() {
|
boolean hasErrors() {
|
||||||
|
|
|
@ -635,7 +635,7 @@ class Eval {
|
||||||
while (true) {
|
while (true) {
|
||||||
state.debug(DBG_GEN, "compileAndLoad %s\n", ins);
|
state.debug(DBG_GEN, "compileAndLoad %s\n", ins);
|
||||||
|
|
||||||
ins.stream().forEach(u -> u.initialize());
|
ins.stream().forEach(Unit::initialize);
|
||||||
ins.stream().forEach(u -> u.setWrap(ins, ins));
|
ins.stream().forEach(u -> u.setWrap(ins, ins));
|
||||||
AnalyzeTask at = state.taskFactory.new AnalyzeTask(outerWrapSet(ins));
|
AnalyzeTask at = state.taskFactory.new AnalyzeTask(outerWrapSet(ins));
|
||||||
ins.stream().forEach(u -> u.setDiagnostics(at));
|
ins.stream().forEach(u -> u.setDiagnostics(at));
|
||||||
|
@ -654,7 +654,7 @@ class Eval {
|
||||||
boolean success;
|
boolean success;
|
||||||
while (true) {
|
while (true) {
|
||||||
List<Unit> legit = ins.stream()
|
List<Unit> legit = ins.stream()
|
||||||
.filter(u -> u.isDefined())
|
.filter(Unit::isDefined)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
state.debug(DBG_GEN, "compileAndLoad ins = %s -- legit = %s\n",
|
state.debug(DBG_GEN, "compileAndLoad ins = %s -- legit = %s\n",
|
||||||
ins, legit);
|
ins, legit);
|
||||||
|
@ -693,7 +693,7 @@ class Eval {
|
||||||
// loop by replacing all that have been replaced
|
// loop by replacing all that have been replaced
|
||||||
if (!toReplace.isEmpty()) {
|
if (!toReplace.isEmpty()) {
|
||||||
replaced.addAll(toReplace);
|
replaced.addAll(toReplace);
|
||||||
replaced.stream().forEach(u -> u.markForReplacement());
|
replaced.stream().forEach(Unit::markForReplacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
success = toReplace.isEmpty();
|
success = toReplace.isEmpty();
|
||||||
|
@ -703,7 +703,7 @@ class Eval {
|
||||||
|
|
||||||
// add any new dependencies to the working set
|
// add any new dependencies to the working set
|
||||||
List<Unit> newDependencies = ins.stream()
|
List<Unit> newDependencies = ins.stream()
|
||||||
.flatMap(u -> u.effectedDependents())
|
.flatMap(Unit::effectedDependents)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
state.debug(DBG_GEN, "compileAndLoad %s -- deps: %s success: %s\n",
|
state.debug(DBG_GEN, "compileAndLoad %s -- deps: %s success: %s\n",
|
||||||
ins, newDependencies, success);
|
ins, newDependencies, success);
|
||||||
|
@ -711,7 +711,7 @@ class Eval {
|
||||||
// all classes that could not be directly loaded (because they
|
// all classes that could not be directly loaded (because they
|
||||||
// are new) have been redefined, and no new dependnencies were
|
// are new) have been redefined, and no new dependnencies were
|
||||||
// identified
|
// identified
|
||||||
ins.stream().forEach(u -> u.finish());
|
ins.stream().forEach(Unit::finish);
|
||||||
return ins;
|
return ins;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import javax.lang.model.element.Element;
|
import javax.lang.model.element.Element;
|
||||||
|
@ -280,7 +281,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis {
|
||||||
String requiredPrefix = identifier;
|
String requiredPrefix = identifier;
|
||||||
return computeSuggestions(codeWrap, cursor, anchor).stream()
|
return computeSuggestions(codeWrap, cursor, anchor).stream()
|
||||||
.filter(s -> s.continuation().startsWith(requiredPrefix) && !s.continuation().equals(REPL_DOESNOTMATTER_CLASS_NAME))
|
.filter(s -> s.continuation().startsWith(requiredPrefix) && !s.continuation().equals(REPL_DOESNOTMATTER_CLASS_NAME))
|
||||||
.sorted(Comparator.comparing(s -> s.continuation()))
|
.sorted(Comparator.comparing(Suggestion::continuation))
|
||||||
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
|
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,7 +510,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis {
|
||||||
@Override
|
@Override
|
||||||
public List<SnippetWrapper> wrappers(String input) {
|
public List<SnippetWrapper> wrappers(String input) {
|
||||||
return proc.eval.sourceToSnippetsWithWrappers(input).stream()
|
return proc.eval.sourceToSnippetsWithWrappers(input).stream()
|
||||||
.map(sn -> wrapper(sn))
|
.map(this::wrapper)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,7 +638,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis {
|
||||||
return IS_STATIC.or(IS_CLASS).or(IS_INTERFACE).negate().test(el) ||
|
return IS_STATIC.or(IS_CLASS).or(IS_INTERFACE).negate().test(el) ||
|
||||||
IS_PACKAGE.test(encl);
|
IS_PACKAGE.test(encl);
|
||||||
};
|
};
|
||||||
private final Function<Element, Iterable<? extends Element>> IDENTITY = el -> Collections.singletonList(el);
|
private final Function<Element, Iterable<? extends Element>> IDENTITY = Collections::singletonList;
|
||||||
private final Function<Boolean, String> DEFAULT_PAREN = hasParams -> hasParams ? "(" : "()";
|
private final Function<Boolean, String> DEFAULT_PAREN = hasParams -> hasParams ? "(" : "()";
|
||||||
private final Function<Boolean, String> NO_PAREN = hasParams -> "";
|
private final Function<Boolean, String> NO_PAREN = hasParams -> "";
|
||||||
|
|
||||||
|
@ -831,7 +832,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis {
|
||||||
};
|
};
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Element> result = Util.stream(scopeIterable)
|
List<Element> result = Util.stream(scopeIterable)
|
||||||
.flatMap(s -> localElements(s))
|
.flatMap(this::localElements)
|
||||||
.flatMap(el -> Util.stream((Iterable<Element>)elementConvertor.apply(el)))
|
.flatMap(el -> Util.stream((Iterable<Element>)elementConvertor.apply(el)))
|
||||||
.collect(toCollection(ArrayList :: new));
|
.collect(toCollection(ArrayList :: new));
|
||||||
result.addAll(listPackages(at, ""));
|
result.addAll(listPackages(at, ""));
|
||||||
|
@ -1186,7 +1187,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis {
|
||||||
|
|
||||||
try (JavadocHelper helper = JavadocHelper.create(at.task, findSources())) {
|
try (JavadocHelper helper = JavadocHelper.create(at.task, findSources())) {
|
||||||
result = elements.map(el -> constructDocumentation(at, helper, el, computeJavadoc))
|
result = elements.map(el -> constructDocumentation(at, helper, el, computeJavadoc))
|
||||||
.filter(r -> r != null)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
proc.debug(ex, "JavadocHelper.close()");
|
proc.debug(ex, "JavadocHelper.close()");
|
||||||
|
|
|
@ -168,11 +168,11 @@ final class Unit {
|
||||||
// Snippets to add to imports
|
// Snippets to add to imports
|
||||||
Collection<Snippet> plus = plusUnfiltered.stream()
|
Collection<Snippet> plus = plusUnfiltered.stream()
|
||||||
.filter(u -> !units.contains(u))
|
.filter(u -> !units.contains(u))
|
||||||
.map(u -> u.snippet())
|
.map(Unit::snippet)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
// Snippets to wrap in an outer
|
// Snippets to wrap in an outer
|
||||||
List<Snippet> snippets = units.stream()
|
List<Snippet> snippets = units.stream()
|
||||||
.map(u -> u.snippet())
|
.map(Unit::snippet)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
// Snippet wraps to wrap in an outer
|
// Snippet wraps to wrap in an outer
|
||||||
List<Wrap> wraps = units.stream()
|
List<Wrap> wraps = units.stream()
|
||||||
|
@ -305,8 +305,8 @@ final class Unit {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ClassBytecodes[] cbcs = toRedefine.stream()
|
ClassBytecodes[] cbcs = toRedefine.stream()
|
||||||
.map(ci -> ci.toClassBytecodes())
|
.map(ClassInfo::toClassBytecodes)
|
||||||
.toArray(size -> new ClassBytecodes[size]);
|
.toArray(ClassBytecodes[]::new);
|
||||||
try {
|
try {
|
||||||
state.executionControl().redefine(cbcs);
|
state.executionControl().redefine(cbcs);
|
||||||
state.classTracker.markLoaded(cbcs);
|
state.classTracker.markLoaded(cbcs);
|
||||||
|
|
|
@ -359,7 +359,7 @@ abstract class Wrap implements GeneralWrap {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CompoundWrap(" + Arrays.stream(os).map(u -> u.toString()).collect(joining(",")) + ")";
|
return "CompoundWrap(" + Arrays.stream(os).map(Object::toString).collect(joining(",")) + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class RemoteExecutionControl extends DirectExecutionControl implements Ex
|
||||||
outputs.put("out", st -> System.setOut(new PrintStream(st, true)));
|
outputs.put("out", st -> System.setOut(new PrintStream(st, true)));
|
||||||
outputs.put("err", st -> System.setErr(new PrintStream(st, true)));
|
outputs.put("err", st -> System.setErr(new PrintStream(st, true)));
|
||||||
Map<String, Consumer<InputStream>> input = new HashMap<>();
|
Map<String, Consumer<InputStream>> input = new HashMap<>();
|
||||||
input.put("in", st -> System.setIn(st));
|
input.put("in", System::setIn);
|
||||||
forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, outStream, outputs, input);
|
forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, outStream, outputs, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue