8250625: Compiler implementation of Pattern Matching for instanceof (Final)
Reviewed-by: vromero
This commit is contained in:
parent
60e4aca846
commit
18bc95ba51
@ -54,7 +54,6 @@ public @interface PreviewFeature {
|
|||||||
public boolean essentialAPI() default false;
|
public boolean essentialAPI() default false;
|
||||||
|
|
||||||
public enum Feature {
|
public enum Feature {
|
||||||
PATTERN_MATCHING_IN_INSTANCEOF,
|
|
||||||
// 8242284:
|
// 8242284:
|
||||||
// The TEXT_BLOCKS enum constant is not used in the JDK 15 codebase, but
|
// The TEXT_BLOCKS enum constant is not used in the JDK 15 codebase, but
|
||||||
// exists to support the bootcycle build of JDK 15. The bootcycle build
|
// exists to support the bootcycle build of JDK 15. The bootcycle build
|
||||||
|
@ -121,20 +121,9 @@ public enum ElementKind {
|
|||||||
RECORD_COMPONENT,
|
RECORD_COMPONENT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@preview Associated with pattern matching for {@code
|
* A binding variable in a pattern.
|
||||||
* instanceof}, a preview feature of the Java language.
|
* @since 16
|
||||||
*
|
|
||||||
* This enum constant is associated with <i>pattern
|
|
||||||
* matching for {@code instanceof}</i>, a preview
|
|
||||||
* feature of the Java language. Preview features
|
|
||||||
* may be removed in a future release, or upgraded to permanent
|
|
||||||
* features of the Java language.}
|
|
||||||
*
|
|
||||||
* A binding variable in a pattern .
|
|
||||||
* @since 14
|
|
||||||
*/
|
*/
|
||||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.PATTERN_MATCHING_IN_INSTANCEOF,
|
|
||||||
essentialAPI=false)
|
|
||||||
BINDING_VARIABLE;
|
BINDING_VARIABLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,34 +25,17 @@
|
|||||||
|
|
||||||
package com.sun.source.tree;
|
package com.sun.source.tree;
|
||||||
|
|
||||||
import javax.lang.model.element.Name;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@preview Associated with pattern matching for instanceof, a preview feature of
|
|
||||||
* the Java language.
|
|
||||||
*
|
|
||||||
* This interface is associated with <i>pattern matching for instanceof</i>, a preview
|
|
||||||
* feature of the Java language. Preview features
|
|
||||||
* may be removed in a future release, or upgraded to permanent
|
|
||||||
* features of the Java language.}
|
|
||||||
*
|
|
||||||
* A binding pattern tree
|
* A binding pattern tree
|
||||||
*
|
*
|
||||||
* @since 14
|
* @since 16
|
||||||
*/
|
*/
|
||||||
public interface BindingPatternTree extends PatternTree {
|
public interface BindingPatternTree extends PatternTree {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the bind variable.
|
* Returns the binding variable.
|
||||||
* @return the type
|
* @return the binding variable
|
||||||
*/
|
*/
|
||||||
Tree getType();
|
VariableTree getVariable();
|
||||||
|
|
||||||
/**
|
|
||||||
* A binding variable name.
|
|
||||||
* @return the name of the binding variable
|
|
||||||
*/
|
|
||||||
Name getBinding();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,18 +49,11 @@ public interface InstanceOfTree extends ExpressionTree {
|
|||||||
/**
|
/**
|
||||||
* Returns the type for which to check.
|
* Returns the type for which to check.
|
||||||
* @return the type
|
* @return the type
|
||||||
|
* @see #getPattern()
|
||||||
*/
|
*/
|
||||||
Tree getType();
|
Tree getType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@preview Associated with pattern matching for instanceof, a preview feature of
|
|
||||||
* the Java language.
|
|
||||||
*
|
|
||||||
* This method is associated with <i>pattern matching for instanceof</i>, a preview
|
|
||||||
* feature of the Java language. Preview features
|
|
||||||
* may be removed in a future release, or upgraded to permanent
|
|
||||||
* features of the Java language.}
|
|
||||||
*
|
|
||||||
* Returns the tested pattern, or null if this instanceof does not use
|
* Returns the tested pattern, or null if this instanceof does not use
|
||||||
* a pattern.
|
* a pattern.
|
||||||
*
|
*
|
||||||
@ -77,7 +70,7 @@ public interface InstanceOfTree extends ExpressionTree {
|
|||||||
* returns null.
|
* returns null.
|
||||||
*
|
*
|
||||||
* @return the tested pattern, or null if this instanceof does not use a pattern
|
* @return the tested pattern, or null if this instanceof does not use a pattern
|
||||||
* @since 14
|
* @since 16
|
||||||
*/
|
*/
|
||||||
PatternTree getPattern();
|
PatternTree getPattern();
|
||||||
}
|
}
|
||||||
|
@ -26,17 +26,9 @@
|
|||||||
package com.sun.source.tree;
|
package com.sun.source.tree;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@preview Associated with pattern matching for instanceof, a preview feature of
|
|
||||||
* the Java language.
|
|
||||||
*
|
|
||||||
* This interface is associated with <i>pattern matching for instanceof</i>, a preview
|
|
||||||
* feature of the Java language. Preview features
|
|
||||||
* may be removed in a future release, or upgraded to permanent
|
|
||||||
* features of the Java language.}
|
|
||||||
*
|
|
||||||
* A tree node used as the base class for the different kinds of
|
* A tree node used as the base class for the different kinds of
|
||||||
* statements.
|
* patterns.
|
||||||
*
|
*
|
||||||
* @since 14
|
* @since 16
|
||||||
*/
|
*/
|
||||||
public interface PatternTree extends Tree {}
|
public interface PatternTree extends Tree {}
|
||||||
|
@ -220,17 +220,9 @@ public interface Tree {
|
|||||||
PARENTHESIZED(ParenthesizedTree.class),
|
PARENTHESIZED(ParenthesizedTree.class),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@preview Associated with pattern matching for instanceof, a preview feature of
|
|
||||||
* the Java language.
|
|
||||||
*
|
|
||||||
* This enum constant is associated with <i>pattern matching for instanceof</i>, a preview
|
|
||||||
* feature of the Java language. Preview features
|
|
||||||
* may be removed in a future release, or upgraded to permanent
|
|
||||||
* features of the Java language.}
|
|
||||||
*
|
|
||||||
* Used for instances of {@link BindingPatternTree}.
|
* Used for instances of {@link BindingPatternTree}.
|
||||||
*
|
*
|
||||||
* @since 14
|
* @since 16
|
||||||
*/
|
*/
|
||||||
BINDING_PATTERN(BindingPatternTree.class),
|
BINDING_PATTERN(BindingPatternTree.class),
|
||||||
|
|
||||||
|
@ -258,19 +258,11 @@ public interface TreeVisitor<R,P> {
|
|||||||
R visitLiteral(LiteralTree node, P p);
|
R visitLiteral(LiteralTree node, P p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@preview Associated with pattern matching for instanceof, a preview feature of
|
|
||||||
* the Java language.
|
|
||||||
*
|
|
||||||
* This method is associated with <i>pattern matching for instanceof</i>, a preview
|
|
||||||
* feature of the Java language. Preview features
|
|
||||||
* may be removed in a future release, or upgraded to permanent
|
|
||||||
* features of the Java language.}
|
|
||||||
*
|
|
||||||
* Visits an BindingPattern node.
|
* Visits an BindingPattern node.
|
||||||
* @param node the node being visited
|
* @param node the node being visited
|
||||||
* @param p a parameter value
|
* @param p a parameter value
|
||||||
* @return a result value
|
* @return a result value
|
||||||
* @since 14
|
* @since 16
|
||||||
*/
|
*/
|
||||||
R visitBindingPattern(BindingPatternTree node, P p);
|
R visitBindingPattern(BindingPatternTree node, P p);
|
||||||
|
|
||||||
|
@ -691,7 +691,7 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public R visitBindingPattern(BindingPatternTree node, P p) {
|
public R visitBindingPattern(BindingPatternTree node, P p) {
|
||||||
return scan(node.getType(), p);
|
return scan(node.getVariable(), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -165,9 +165,7 @@ public class Preview {
|
|||||||
* @return true, if given feature is a preview feature.
|
* @return true, if given feature is a preview feature.
|
||||||
*/
|
*/
|
||||||
public boolean isPreview(Feature feature) {
|
public boolean isPreview(Feature feature) {
|
||||||
if (feature == Feature.PATTERN_MATCHING_IN_INSTANCEOF ||
|
if (feature == Feature.SEALED_CLASSES)
|
||||||
feature == Feature.REIFIABLE_TYPES_INSTANCEOF ||
|
|
||||||
feature == Feature.SEALED_CLASSES)
|
|
||||||
return true;
|
return true;
|
||||||
//Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).
|
//Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).
|
||||||
//When real preview features will be added, this method can be implemented to return 'true'
|
//When real preview features will be added, this method can be implemented to return 'true'
|
||||||
|
@ -1855,7 +1855,7 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
|
|||||||
public static class BindingSymbol extends VarSymbol {
|
public static class BindingSymbol extends VarSymbol {
|
||||||
|
|
||||||
public BindingSymbol(Name name, Type type, Symbol owner) {
|
public BindingSymbol(Name name, Type type, Symbol owner) {
|
||||||
super(Flags.FINAL | Flags.HASINIT | Flags.MATCH_BINDING, name, type, owner);
|
super(Flags.HASINIT | Flags.MATCH_BINDING, name, type, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAliasFor(BindingSymbol b) {
|
public boolean isAliasFor(BindingSymbol b) {
|
||||||
|
@ -951,9 +951,8 @@ public class TypeAnnotations {
|
|||||||
" within frame " + frame);
|
" within frame " + frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
case BINDING_PATTERN:
|
|
||||||
case VARIABLE:
|
case VARIABLE:
|
||||||
VarSymbol v = frame.hasTag(Tag.BINDINGPATTERN) ? ((JCBindingPattern) frame).symbol : ((JCVariableDecl) frame).sym;
|
VarSymbol v = ((JCVariableDecl) frame).sym;
|
||||||
if (v.getKind() != ElementKind.FIELD) {
|
if (v.getKind() != ElementKind.FIELD) {
|
||||||
appendTypeAnnotationsToOwner(v, v.getRawTypeAttributes());
|
appendTypeAnnotationsToOwner(v, v.getRawTypeAttributes());
|
||||||
}
|
}
|
||||||
|
@ -308,8 +308,6 @@ public class Attr extends JCTree.Visitor {
|
|||||||
isAssignableAsBlankFinal(v, env)))) {
|
isAssignableAsBlankFinal(v, env)))) {
|
||||||
if (v.isResourceVariable()) { //TWR resource
|
if (v.isResourceVariable()) { //TWR resource
|
||||||
log.error(pos, Errors.TryResourceMayNotBeAssigned(v));
|
log.error(pos, Errors.TryResourceMayNotBeAssigned(v));
|
||||||
} else if ((v.flags() & MATCH_BINDING) != 0) {
|
|
||||||
log.error(pos, Errors.PatternBindingMayNotBeAssigned(v));
|
|
||||||
} else {
|
} else {
|
||||||
log.error(pos, Errors.CantAssignValToFinalVar(v));
|
log.error(pos, Errors.CantAssignValToFinalVar(v));
|
||||||
}
|
}
|
||||||
@ -3933,10 +3931,14 @@ public class Attr extends JCTree.Visitor {
|
|||||||
if (tree.pattern.getTag() == BINDINGPATTERN) {
|
if (tree.pattern.getTag() == BINDINGPATTERN) {
|
||||||
attribTree(tree.pattern, env, unknownExprInfo);
|
attribTree(tree.pattern, env, unknownExprInfo);
|
||||||
clazztype = tree.pattern.type;
|
clazztype = tree.pattern.type;
|
||||||
|
if (types.isSubtype(exprtype, clazztype) &&
|
||||||
|
!exprtype.isErroneous() && !clazztype.isErroneous()) {
|
||||||
|
log.error(tree.pos(), Errors.InstanceofPatternNoSubtype(clazztype, exprtype));
|
||||||
|
}
|
||||||
JCBindingPattern pattern = (JCBindingPattern) tree.pattern;
|
JCBindingPattern pattern = (JCBindingPattern) tree.pattern;
|
||||||
typeTree = pattern.vartype;
|
typeTree = pattern.var.vartype;
|
||||||
if (!clazztype.hasTag(TYPEVAR)) {
|
if (!clazztype.hasTag(TYPEVAR)) {
|
||||||
clazztype = chk.checkClassOrArrayType(pattern.vartype.pos(), clazztype);
|
clazztype = chk.checkClassOrArrayType(pattern.var.vartype.pos(), clazztype);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
clazztype = attribType(tree.pattern, env);
|
clazztype = attribType(tree.pattern, env);
|
||||||
@ -3962,7 +3964,9 @@ public class Attr extends JCTree.Visitor {
|
|||||||
valid = true;
|
valid = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error(typeTree.pos(), Errors.IllegalGenericTypeForInstof);
|
log.error(DiagnosticFlag.SOURCE_LEVEL, tree.pos(),
|
||||||
|
Feature.REIFIABLE_TYPES_INSTANCEOF.error(this.sourceName));
|
||||||
|
allowReifiableTypesInInstanceof = true;
|
||||||
}
|
}
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
clazztype = types.createErrorType(clazztype);
|
clazztype = types.createErrorType(clazztype);
|
||||||
@ -3975,15 +3979,17 @@ public class Attr extends JCTree.Visitor {
|
|||||||
|
|
||||||
public void visitBindingPattern(JCBindingPattern tree) {
|
public void visitBindingPattern(JCBindingPattern tree) {
|
||||||
ResultInfo varInfo = new ResultInfo(KindSelector.TYP, resultInfo.pt, resultInfo.checkContext);
|
ResultInfo varInfo = new ResultInfo(KindSelector.TYP, resultInfo.pt, resultInfo.checkContext);
|
||||||
tree.type = attribTree(tree.vartype, env, varInfo);
|
tree.type = tree.var.type = attribTree(tree.var.vartype, env, varInfo);
|
||||||
VarSymbol v = tree.symbol = new BindingSymbol(tree.name, tree.vartype.type, env.info.scope.owner);
|
BindingSymbol v = new BindingSymbol(tree.var.name, tree.var.vartype.type, env.info.scope.owner);
|
||||||
if (chk.checkUnique(tree.pos(), v, env.info.scope)) {
|
v.pos = tree.pos;
|
||||||
chk.checkTransparentVar(tree.pos(), v, env.info.scope);
|
tree.var.sym = v;
|
||||||
|
if (chk.checkUnique(tree.var.pos(), v, env.info.scope)) {
|
||||||
|
chk.checkTransparentVar(tree.var.pos(), v, env.info.scope);
|
||||||
}
|
}
|
||||||
annotate.queueScanTreeAndTypeAnnotate(tree.vartype, env, v, tree.pos());
|
annotate.queueScanTreeAndTypeAnnotate(tree.var.vartype, env, v, tree.var.pos());
|
||||||
annotate.flush();
|
annotate.flush();
|
||||||
result = tree.type;
|
result = tree.type;
|
||||||
matchBindings = new MatchBindings(List.of(tree.symbol), List.nil());
|
matchBindings = new MatchBindings(List.of(v), List.nil());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitIndexed(JCArrayAccess tree) {
|
public void visitIndexed(JCArrayAccess tree) {
|
||||||
@ -5733,9 +5739,9 @@ public class Attr extends JCTree.Visitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitBindingPattern(JCBindingPattern that) {
|
public void visitBindingPattern(JCBindingPattern that) {
|
||||||
if (that.symbol == null) {
|
if (that.var.sym == null) {
|
||||||
that.symbol = new BindingSymbol(that.name, that.type, syms.noSymbol);
|
that.var.sym = new BindingSymbol(that.var.name, that.var.type, syms.noSymbol);
|
||||||
that.symbol.adr = 0;
|
that.var.sym.adr = 0;
|
||||||
}
|
}
|
||||||
super.visitBindingPattern(that);
|
super.visitBindingPattern(that);
|
||||||
}
|
}
|
||||||
|
@ -1875,7 +1875,8 @@ public class Flow {
|
|||||||
void checkInit(DiagnosticPosition pos, VarSymbol sym, Error errkey) {
|
void checkInit(DiagnosticPosition pos, VarSymbol sym, Error errkey) {
|
||||||
if ((sym.adr >= firstadr || sym.owner.kind != TYP) &&
|
if ((sym.adr >= firstadr || sym.owner.kind != TYP) &&
|
||||||
trackable(sym) &&
|
trackable(sym) &&
|
||||||
!inits.isMember(sym.adr)) {
|
!inits.isMember(sym.adr) &&
|
||||||
|
(sym.flags_field & CLASH) == 0) {
|
||||||
log.error(pos, errkey);
|
log.error(pos, errkey);
|
||||||
inits.incl(sym.adr);
|
inits.incl(sym.adr);
|
||||||
}
|
}
|
||||||
@ -2758,6 +2759,12 @@ public class Flow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitBindingPattern(JCBindingPattern tree) {
|
||||||
|
super.visitBindingPattern(tree);
|
||||||
|
initParam(tree.var);
|
||||||
|
}
|
||||||
|
|
||||||
void referenced(Symbol sym) {
|
void referenced(Symbol sym) {
|
||||||
unrefdResources.remove(sym);
|
unrefdResources.remove(sym);
|
||||||
}
|
}
|
||||||
|
@ -148,6 +148,7 @@ public class MatchBindingsComputer extends TreeScanner {
|
|||||||
(v1.flags() & CLASH) == 0 &&
|
(v1.flags() & CLASH) == 0 &&
|
||||||
(v2.flags() & CLASH) == 0) {
|
(v2.flags() & CLASH) == 0) {
|
||||||
log.error(pos, Errors.MatchBindingExists);
|
log.error(pos, Errors.MatchBindingExists);
|
||||||
|
v2.flags_field |= CLASH;
|
||||||
list = list.append(v2);
|
list = list.append(v2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,6 +167,7 @@ public class MatchBindingsComputer extends TreeScanner {
|
|||||||
(ov.flags() & CLASH) == 0 &&
|
(ov.flags() & CLASH) == 0 &&
|
||||||
(v.flags() & CLASH) == 0) {
|
(v.flags() & CLASH) == 0) {
|
||||||
log.error(pos, Errors.MatchBindingExists);
|
log.error(pos, Errors.MatchBindingExists);
|
||||||
|
v.flags_field |= CLASH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list = list.append(v);
|
list = list.append(v);
|
||||||
|
@ -153,20 +153,20 @@ public class TransPatterns extends TreeTranslator {
|
|||||||
//=>
|
//=>
|
||||||
//(let T' N$temp = E; N$temp instanceof T && (N = (T) N$temp == (T) N$temp))
|
//(let T' N$temp = E; N$temp instanceof T && (N = (T) N$temp == (T) N$temp))
|
||||||
JCBindingPattern patt = (JCBindingPattern)tree.pattern;
|
JCBindingPattern patt = (JCBindingPattern)tree.pattern;
|
||||||
VarSymbol pattSym = patt.symbol;
|
VarSymbol pattSym = patt.var.sym;
|
||||||
Type tempType = tree.expr.type.hasTag(BOT) ?
|
Type tempType = tree.expr.type.hasTag(BOT) ?
|
||||||
syms.objectType
|
syms.objectType
|
||||||
: tree.expr.type;
|
: tree.expr.type;
|
||||||
VarSymbol temp = new VarSymbol(pattSym.flags() | Flags.SYNTHETIC,
|
VarSymbol temp = new VarSymbol(pattSym.flags() | Flags.SYNTHETIC,
|
||||||
names.fromString(pattSym.name.toString() + target.syntheticNameChar() + "temp"),
|
names.fromString(pattSym.name.toString() + target.syntheticNameChar() + "temp"),
|
||||||
tempType,
|
tempType,
|
||||||
patt.symbol.owner);
|
patt.var.sym.owner);
|
||||||
JCExpression translatedExpr = translate(tree.expr);
|
JCExpression translatedExpr = translate(tree.expr);
|
||||||
Type castTargetType = types.boxedTypeOrType(pattSym.erasure(types));
|
Type castTargetType = types.boxedTypeOrType(pattSym.erasure(types));
|
||||||
|
|
||||||
result = makeTypeTest(make.Ident(temp), make.Type(castTargetType));
|
result = makeTypeTest(make.Ident(temp), make.Type(castTargetType));
|
||||||
|
|
||||||
VarSymbol bindingVar = bindingContext.bindingDeclared(patt.symbol);
|
VarSymbol bindingVar = bindingContext.bindingDeclared((BindingSymbol) patt.var.sym);
|
||||||
if (bindingVar != null) { //TODO: cannot be null here?
|
if (bindingVar != null) { //TODO: cannot be null here?
|
||||||
JCAssign fakeInit = (JCAssign)make.at(tree.pos).Assign(
|
JCAssign fakeInit = (JCAssign)make.at(tree.pos).Assign(
|
||||||
make.Ident(bindingVar), convert(make.Ident(temp), castTargetType)).setType(bindingVar.erasure(types));
|
make.Ident(bindingVar), convert(make.Ident(temp), castTargetType)).setType(bindingVar.erasure(types));
|
||||||
|
@ -568,9 +568,7 @@ public class TransTypes extends TreeTranslator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void visitBindingPattern(JCBindingPattern tree) {
|
public void visitBindingPattern(JCBindingPattern tree) {
|
||||||
if (tree.vartype != null) {
|
tree.var = translate(tree.var, null);
|
||||||
tree.vartype = translate(tree.vartype, null);
|
|
||||||
}
|
|
||||||
result = tree;
|
result = tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,13 +257,10 @@ public class TreeDiffer extends TreeScanner {
|
|||||||
@Override
|
@Override
|
||||||
public void visitBindingPattern(JCBindingPattern tree) {
|
public void visitBindingPattern(JCBindingPattern tree) {
|
||||||
JCBindingPattern that = (JCBindingPattern) parameter;
|
JCBindingPattern that = (JCBindingPattern) parameter;
|
||||||
result =
|
result = scan(tree.var, that.var);
|
||||||
scan(tree.vartype, that.vartype)
|
|
||||||
&& tree.name == that.name;
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
equiv.put(tree.symbol, that.symbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -106,12 +106,6 @@ public class TreeHasher extends TreeScanner {
|
|||||||
super.visitSelect(tree);
|
super.visitSelect(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitBindingPattern(JCTree.JCBindingPattern tree) {
|
|
||||||
symbolHashes.computeIfAbsent(tree.symbol, k -> symbolHashes.size());
|
|
||||||
super.visitBindingPattern(tree);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitVarDef(JCVariableDecl tree) {
|
public void visitVarDef(JCVariableDecl tree) {
|
||||||
symbolHashes.computeIfAbsent(tree.sym, k -> symbolHashes.size());
|
symbolHashes.computeIfAbsent(tree.sym, k -> symbolHashes.size());
|
||||||
|
@ -932,10 +932,18 @@ public class JavacParser implements Parser {
|
|||||||
if (token.kind == INSTANCEOF) {
|
if (token.kind == INSTANCEOF) {
|
||||||
int pos = token.pos;
|
int pos = token.pos;
|
||||||
nextToken();
|
nextToken();
|
||||||
JCTree pattern = parseType();
|
int typePos = token.pos;
|
||||||
|
JCExpression type = parseType();
|
||||||
|
JCTree pattern;
|
||||||
if (token.kind == IDENTIFIER) {
|
if (token.kind == IDENTIFIER) {
|
||||||
checkSourceLevel(token.pos, Feature.PATTERN_MATCHING_IN_INSTANCEOF);
|
checkSourceLevel(token.pos, Feature.PATTERN_MATCHING_IN_INSTANCEOF);
|
||||||
pattern = toP(F.at(token.pos).BindingPattern(ident(), pattern));
|
JCModifiers mods = F.at(Position.NOPOS).Modifiers(0);
|
||||||
|
JCVariableDecl var = toP(F.at(token.pos).VarDef(mods, ident(), type, null));
|
||||||
|
TreeInfo.getStartPos(var);
|
||||||
|
pattern = toP(F.at(typePos).BindingPattern(var));
|
||||||
|
TreeInfo.getStartPos(pattern);
|
||||||
|
} else {
|
||||||
|
pattern = type;
|
||||||
}
|
}
|
||||||
odStack[top] = F.at(pos).TypeTest(odStack[top], pattern);
|
odStack[top] = F.at(pos).TypeTest(odStack[top], pattern);
|
||||||
} else {
|
} else {
|
||||||
|
@ -545,10 +545,6 @@ compiler.err.final.parameter.may.not.be.assigned=\
|
|||||||
compiler.err.try.resource.may.not.be.assigned=\
|
compiler.err.try.resource.may.not.be.assigned=\
|
||||||
auto-closeable resource {0} may not be assigned
|
auto-closeable resource {0} may not be assigned
|
||||||
|
|
||||||
# 0: symbol
|
|
||||||
compiler.err.pattern.binding.may.not.be.assigned=\
|
|
||||||
pattern binding {0} may not be assigned
|
|
||||||
|
|
||||||
# 0: symbol
|
# 0: symbol
|
||||||
compiler.err.multicatch.parameter.may.not.be.assigned=\
|
compiler.err.multicatch.parameter.may.not.be.assigned=\
|
||||||
multi-catch parameter {0} may not be assigned
|
multi-catch parameter {0} may not be assigned
|
||||||
@ -620,9 +616,6 @@ compiler.err.illegal.self.ref=\
|
|||||||
compiler.warn.self.ref=\
|
compiler.warn.self.ref=\
|
||||||
self-reference in initializer of variable ''{0}''
|
self-reference in initializer of variable ''{0}''
|
||||||
|
|
||||||
compiler.err.illegal.generic.type.for.instof=\
|
|
||||||
illegal generic type for instanceof
|
|
||||||
|
|
||||||
# 0: type
|
# 0: type
|
||||||
compiler.err.illegal.initializer.for.type=\
|
compiler.err.illegal.initializer.for.type=\
|
||||||
illegal initializer for {0}
|
illegal initializer for {0}
|
||||||
@ -1418,6 +1411,10 @@ compiler.misc.varargs.trustme.on.reifiable.varargs=\
|
|||||||
compiler.err.instanceof.reifiable.not.safe=\
|
compiler.err.instanceof.reifiable.not.safe=\
|
||||||
{0} cannot be safely cast to {1}
|
{0} cannot be safely cast to {1}
|
||||||
|
|
||||||
|
# 0: type, 1: type
|
||||||
|
compiler.err.instanceof.pattern.no.subtype=\
|
||||||
|
pattern type {0} is a subtype of expression type {1}
|
||||||
|
|
||||||
# 0: symbol
|
# 0: symbol
|
||||||
compiler.misc.varargs.trustme.on.non.varargs.meth=\
|
compiler.misc.varargs.trustme.on.non.varargs.meth=\
|
||||||
Method {0} is not a varargs method.
|
Method {0} is not a varargs method.
|
||||||
|
@ -2164,7 +2164,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
|||||||
@DefinedBy(Api.COMPILER_TREE)
|
@DefinedBy(Api.COMPILER_TREE)
|
||||||
public Kind getKind() { return Kind.INSTANCE_OF; }
|
public Kind getKind() { return Kind.INSTANCE_OF; }
|
||||||
@DefinedBy(Api.COMPILER_TREE)
|
@DefinedBy(Api.COMPILER_TREE)
|
||||||
public JCTree getType() { return pattern instanceof JCPattern ? pattern.hasTag(BINDINGPATTERN) ? ((JCBindingPattern) pattern).vartype : null : pattern; }
|
public JCTree getType() { return pattern instanceof JCPattern ? pattern.hasTag(BINDINGPATTERN) ? ((JCBindingPattern) pattern).var.vartype : null : pattern; }
|
||||||
|
|
||||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||||
public JCPattern getPattern() {
|
public JCPattern getPattern() {
|
||||||
@ -2188,31 +2188,19 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
|||||||
*/
|
*/
|
||||||
public static abstract class JCPattern extends JCTree
|
public static abstract class JCPattern extends JCTree
|
||||||
implements PatternTree {
|
implements PatternTree {
|
||||||
public JCExpression constExpression() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class JCBindingPattern extends JCPattern
|
public static class JCBindingPattern extends JCPattern
|
||||||
implements BindingPatternTree {
|
implements BindingPatternTree {
|
||||||
public Name name;
|
public JCVariableDecl var;
|
||||||
public BindingSymbol symbol;
|
|
||||||
public JCTree vartype;
|
|
||||||
|
|
||||||
protected JCBindingPattern(Name name, BindingSymbol symbol, JCTree vartype) {
|
protected JCBindingPattern(JCVariableDecl var) {
|
||||||
this.name = name;
|
this.var = var;
|
||||||
this.symbol = symbol;
|
|
||||||
this.vartype = vartype;
|
|
||||||
}
|
|
||||||
|
|
||||||
@DefinedBy(Api.COMPILER_TREE)
|
|
||||||
public Name getBinding() {
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||||
public Tree getType() {
|
public VariableTree getVariable() {
|
||||||
return vartype;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -3211,7 +3199,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
|||||||
JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs);
|
JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs);
|
||||||
JCTypeCast TypeCast(JCTree expr, JCExpression type);
|
JCTypeCast TypeCast(JCTree expr, JCExpression type);
|
||||||
JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
|
JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
|
||||||
JCBindingPattern BindingPattern(Name name, JCTree vartype);
|
JCBindingPattern BindingPattern(JCVariableDecl var);
|
||||||
JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
|
JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
|
||||||
JCFieldAccess Select(JCExpression selected, Name selector);
|
JCFieldAccess Select(JCExpression selected, Name selector);
|
||||||
JCIdent Ident(Name idname);
|
JCIdent Ident(Name idname);
|
||||||
|
@ -895,9 +895,7 @@ public class Pretty extends JCTree.Visitor {
|
|||||||
|
|
||||||
public void visitBindingPattern(JCBindingPattern patt) {
|
public void visitBindingPattern(JCBindingPattern patt) {
|
||||||
try {
|
try {
|
||||||
printExpr(patt.vartype);
|
printExpr(patt.var);
|
||||||
print(" ");
|
|
||||||
print(patt.name);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UncheckedIOException(e);
|
throw new UncheckedIOException(e);
|
||||||
}
|
}
|
||||||
|
@ -493,8 +493,8 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
|
|||||||
@DefinedBy(Api.COMPILER_TREE)
|
@DefinedBy(Api.COMPILER_TREE)
|
||||||
public JCTree visitBindingPattern(BindingPatternTree node, P p) {
|
public JCTree visitBindingPattern(BindingPatternTree node, P p) {
|
||||||
JCBindingPattern t = (JCBindingPattern) node;
|
JCBindingPattern t = (JCBindingPattern) node;
|
||||||
JCTree vartype = copy(t.vartype, p);
|
JCVariableDecl var = copy(t.var, p);
|
||||||
return M.at(t.pos).BindingPattern(t.name, vartype);
|
return M.at(t.pos).BindingPattern(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DefinedBy(Api.COMPILER_TREE)
|
@DefinedBy(Api.COMPILER_TREE)
|
||||||
|
@ -39,6 +39,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
|
|||||||
|
|
||||||
import static com.sun.tools.javac.code.Flags.*;
|
import static com.sun.tools.javac.code.Flags.*;
|
||||||
import static com.sun.tools.javac.code.Kinds.Kind.*;
|
import static com.sun.tools.javac.code.Kinds.Kind.*;
|
||||||
|
import com.sun.tools.javac.code.Symbol.VarSymbol;
|
||||||
import static com.sun.tools.javac.code.TypeTag.BOT;
|
import static com.sun.tools.javac.code.TypeTag.BOT;
|
||||||
import static com.sun.tools.javac.tree.JCTree.Tag.*;
|
import static com.sun.tools.javac.tree.JCTree.Tag.*;
|
||||||
import static com.sun.tools.javac.tree.JCTree.Tag.BLOCK;
|
import static com.sun.tools.javac.tree.JCTree.Tag.BLOCK;
|
||||||
@ -535,7 +536,7 @@ public class TreeInfo {
|
|||||||
}
|
}
|
||||||
case BINDINGPATTERN: {
|
case BINDINGPATTERN: {
|
||||||
JCBindingPattern node = (JCBindingPattern)tree;
|
JCBindingPattern node = (JCBindingPattern)tree;
|
||||||
return getStartPos(node.vartype);
|
return getStartPos(node.var);
|
||||||
}
|
}
|
||||||
case ERRONEOUS: {
|
case ERRONEOUS: {
|
||||||
JCErroneous node = (JCErroneous)tree;
|
JCErroneous node = (JCErroneous)tree;
|
||||||
@ -926,8 +927,6 @@ public class TreeInfo {
|
|||||||
if (node.type != null)
|
if (node.type != null)
|
||||||
return node.type.tsym;
|
return node.type.tsym;
|
||||||
return null;
|
return null;
|
||||||
case BINDINGPATTERN:
|
|
||||||
return ((JCBindingPattern) node).symbol;
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -476,8 +476,8 @@ public class TreeMaker implements JCTree.Factory {
|
|||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JCBindingPattern BindingPattern(Name name, JCTree vartype) {
|
public JCBindingPattern BindingPattern(JCVariableDecl var) {
|
||||||
JCBindingPattern tree = new JCBindingPattern(name, null, vartype);
|
JCBindingPattern tree = new JCBindingPattern(var);
|
||||||
tree.pos = pos;
|
tree.pos = pos;
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
@ -304,8 +304,7 @@ public class TreeScanner extends Visitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void visitBindingPattern(JCBindingPattern tree) {
|
public void visitBindingPattern(JCBindingPattern tree) {
|
||||||
if (tree.vartype != null)
|
scan(tree.var);
|
||||||
scan(tree.vartype);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitIndexed(JCArrayAccess tree) {
|
public void visitIndexed(JCArrayAccess tree) {
|
||||||
|
@ -359,7 +359,7 @@ public class TreeTranslator extends JCTree.Visitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void visitBindingPattern(JCBindingPattern tree) {
|
public void visitBindingPattern(JCBindingPattern tree) {
|
||||||
tree.vartype = translate(tree.vartype);
|
tree.var = translate(tree.var);
|
||||||
result = tree;
|
result = tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
0
test/langtools/tools/javac/T4881267-old.out
Normal file
0
test/langtools/tools/javac/T4881267-old.out
Normal file
@ -1,2 +1,2 @@
|
|||||||
T4881267.java:10:34: compiler.err.illegal.generic.type.for.instof
|
T4881267.java:10:21: compiler.err.instanceof.reifiable.not.safe: java.lang.Object, T
|
||||||
1 error
|
1 error
|
||||||
|
@ -399,14 +399,14 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper {
|
|||||||
case src7p: // (repeating) type annotations in use of instanceof with type test pattern
|
case src7p: // (repeating) type annotations in use of instanceof with type test pattern
|
||||||
/*
|
/*
|
||||||
* class Test10{
|
* class Test10{
|
||||||
* String data = "test";
|
* Object data = "test";
|
||||||
* boolean dataIsString = ( data instanceof @A @B @A @B String str);
|
* boolean dataIsString = ( data instanceof @A @B @A @B String str);
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
source = new String( source +
|
source = new String( source +
|
||||||
"// " + src.description + "\n" +
|
"// " + src.description + "\n" +
|
||||||
"class "+ testname + "{\n" +
|
"class "+ testname + "{\n" +
|
||||||
" String data = \"test\";\n" +
|
" Object data = \"test\";\n" +
|
||||||
" boolean dataIsString = ( data instanceof _As_ _Bs_ String str && str.isEmpty());\n" +
|
" boolean dataIsString = ( data instanceof _As_ _Bs_ String str && str.isEmpty());\n" +
|
||||||
"}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
|
"}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
|
||||||
"\n\n";
|
"\n\n";
|
||||||
@ -455,7 +455,7 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper {
|
|||||||
source = new String( source +
|
source = new String( source +
|
||||||
"// " + src.description + "\n" +
|
"// " + src.description + "\n" +
|
||||||
"class "+ testname + "{\n" +
|
"class "+ testname + "{\n" +
|
||||||
" String data = \"test\";\n" +
|
" Object data = \"test\";\n" +
|
||||||
" Boolean isString() { \n" +
|
" Boolean isString() { \n" +
|
||||||
" if( data instanceof _As_ _Bs_ String str)\n" +
|
" if( data instanceof _As_ _Bs_ String str)\n" +
|
||||||
" return true;\n" +
|
" return true;\n" +
|
||||||
|
@ -161,7 +161,6 @@ compiler.misc.locn.module_source_path # fragment uninter
|
|||||||
compiler.misc.locn.system_modules # fragment uninteresting in and of itself
|
compiler.misc.locn.system_modules # fragment uninteresting in and of itself
|
||||||
compiler.misc.locn.upgrade_module_path # fragment uninteresting in and of itself
|
compiler.misc.locn.upgrade_module_path # fragment uninteresting in and of itself
|
||||||
compiler.misc.inferred.do.not.conform.to.eq.bounds # hard to generate, could probably be removed
|
compiler.misc.inferred.do.not.conform.to.eq.bounds # hard to generate, could probably be removed
|
||||||
compiler.err.feature.not.supported.in.source # Generated for using diamond before source 7
|
|
||||||
|
|
||||||
# The following are new module-related messages, that need new examples to be created
|
# The following are new module-related messages, that need new examples to be created
|
||||||
compiler.err.duplicate.module.on.path
|
compiler.err.duplicate.module.on.path
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -21,14 +21,13 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// key: compiler.err.feature.not.supported.in.source.plural
|
||||||
// key: compiler.misc.feature.reifiable.types.instanceof
|
// key: compiler.misc.feature.reifiable.types.instanceof
|
||||||
// key: compiler.warn.preview.feature.use.plural
|
// options: -source 15 -Xlint:-options
|
||||||
// options: --enable-preview -source ${jdk.version} -Xlint:preview
|
|
||||||
|
|
||||||
class PatternMatchingInstanceof {
|
import java.util.*;
|
||||||
boolean m(I<String> i) {
|
|
||||||
return i instanceof C<String>;
|
class FeatureReifiableTypesInstanceof {
|
||||||
}
|
List o;
|
||||||
interface I<T> {}
|
boolean b = (o instanceof List<String>);
|
||||||
class C<T> implements I<T> {}
|
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -21,11 +21,10 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.illegal.generic.type.for.instof
|
// key: compiler.err.instanceof.pattern.no.subtype
|
||||||
|
|
||||||
import java.util.*;
|
class InstanceofPatternNoSubtype {
|
||||||
|
boolean test(Object o) {
|
||||||
class IllegalInstanceof {
|
return o instanceof Object obj;
|
||||||
List o;
|
}
|
||||||
boolean b = (o instanceof List<String>);
|
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -22,9 +22,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.instanceof.reifiable.not.safe
|
// key: compiler.err.instanceof.reifiable.not.safe
|
||||||
// key: compiler.note.preview.filename
|
|
||||||
// key: compiler.note.preview.recompile
|
|
||||||
// options: --enable-preview -source ${jdk.version}
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -22,9 +22,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.match.binding.exists
|
// key: compiler.err.match.binding.exists
|
||||||
// key: compiler.note.preview.filename
|
|
||||||
// key: compiler.note.preview.recompile
|
|
||||||
// options: --enable-preview -source ${jdk.version}
|
|
||||||
|
|
||||||
class MatchBindingExists {
|
class MatchBindingExists {
|
||||||
public void test(Object o1, Object o2) {
|
public void test(Object o1, Object o2) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -22,8 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.misc.feature.pattern.matching.instanceof
|
// key: compiler.misc.feature.pattern.matching.instanceof
|
||||||
// key: compiler.warn.preview.feature.use
|
// key: compiler.err.feature.not.supported.in.source
|
||||||
// options: --enable-preview -source ${jdk.version} -Xlint:preview
|
// options: -source 15 -Xlint:-options
|
||||||
|
|
||||||
class PatternMatchingInstanceof {
|
class PatternMatchingInstanceof {
|
||||||
boolean m(Object o) {
|
boolean m(Object o) {
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
InstanceOf2.java:12:48: compiler.err.illegal.generic.type.for.instof
|
InstanceOf2.java:12:29: compiler.err.instanceof.reifiable.not.safe: java.lang.Class<compiler.misc.type.captureof: 1, ? extends InstanceOf2>, java.lang.Class<InstanceOf2>
|
||||||
1 error
|
1 error
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* @summary the type in an instanceof expression must be reifiable
|
* @summary the type in an instanceof expression must be reifiable
|
||||||
* @author seligman
|
* @author seligman
|
||||||
*
|
*
|
||||||
* @compile/fail/ref=InstanceOf3.out -XDrawDiagnostics InstanceOf3.java
|
* @compile/fail/ref=InstanceOf3.out -XDrawDiagnostics -source 15 -Xlint:-options InstanceOf3.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class InstanceOf3 {
|
public class InstanceOf3 {
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
InstanceOf3.java:12:48: compiler.err.illegal.generic.type.for.instof
|
InstanceOf3.java:12:32: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.reifiable.types.instanceof), 15, 16
|
||||||
1 error
|
1 error
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
BadTest.java:19:50: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: List<java.lang.Object>, List<Cell<java.lang.String>>)
|
||||||
|
BadTest.java:23:48: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: List<java.lang.Object>, List<java.lang.String>)
|
||||||
|
BadTest.java:24:54: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: List<java.lang.Object>, List<Cell<java.lang.String>>)
|
||||||
|
BadTest.java:26:38: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.reifiable.types.instanceof), 15, 16
|
||||||
|
4 errors
|
@ -3,6 +3,7 @@
|
|||||||
* @summary Negative regression test from odersky
|
* @summary Negative regression test from odersky
|
||||||
* @author odersky
|
* @author odersky
|
||||||
*
|
*
|
||||||
|
* @compile/fail/ref=BadTest-old.out -XDrawDiagnostics -source 15 -Xlint:-options BadTest.java
|
||||||
* @compile/fail/ref=BadTest.out -XDrawDiagnostics BadTest.java
|
* @compile/fail/ref=BadTest.out -XDrawDiagnostics BadTest.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
BadTest.java:18:50: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: List<java.lang.Object>, List<Cell<java.lang.String>>)
|
BadTest.java:19:50: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: List<java.lang.Object>, List<Cell<java.lang.String>>)
|
||||||
BadTest.java:22:48: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: List<java.lang.Object>, List<java.lang.String>)
|
BadTest.java:23:48: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: List<java.lang.Object>, List<java.lang.String>)
|
||||||
BadTest.java:23:54: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: List<java.lang.Object>, List<Cell<java.lang.String>>)
|
BadTest.java:24:54: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: List<java.lang.Object>, List<Cell<java.lang.String>>)
|
||||||
BadTest.java:25:53: compiler.err.illegal.generic.type.for.instof
|
BadTest.java:26:35: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: List<java.lang.Object>, List<java.lang.String>)
|
||||||
4 errors
|
4 errors
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Clashing bindings are reported correctly
|
* @summary Clashing bindings are reported correctly
|
||||||
* @compile/fail/ref=BindingsExistTest.out -XDrawDiagnostics --enable-preview -source ${jdk.version} BindingsExistTest.java
|
* @compile/fail/ref=BindingsExistTest.out -XDrawDiagnostics BindingsExistTest.java
|
||||||
*/
|
*/
|
||||||
public class BindingsExistTest {
|
public class BindingsExistTest {
|
||||||
public void t(Object o1, Object o2) {
|
public void t(Object o1, Object o2) {
|
||||||
|
@ -4,6 +4,4 @@ BindingsExistTest.java:16:35: compiler.err.already.defined: kindname.variable, k
|
|||||||
BindingsExistTest.java:19:34: compiler.err.already.defined: kindname.variable, s2, kindname.method, t(java.lang.Object,java.lang.Object)
|
BindingsExistTest.java:19:34: compiler.err.already.defined: kindname.variable, s2, kindname.method, t(java.lang.Object,java.lang.Object)
|
||||||
BindingsExistTest.java:22:20: compiler.err.already.defined: kindname.variable, s3, kindname.method, t(java.lang.Object,java.lang.Object)
|
BindingsExistTest.java:22:20: compiler.err.already.defined: kindname.variable, s3, kindname.method, t(java.lang.Object,java.lang.Object)
|
||||||
BindingsExistTest.java:28:16: compiler.err.already.defined: kindname.variable, s4, kindname.method, t(java.lang.Object,java.lang.Object)
|
BindingsExistTest.java:28:16: compiler.err.already.defined: kindname.variable, s4, kindname.method, t(java.lang.Object,java.lang.Object)
|
||||||
- compiler.note.preview.filename: BindingsExistTest.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
6 errors
|
6 errors
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Basic tests for bindings from instanceof
|
* @summary Basic tests for bindings from instanceof
|
||||||
* @compile --enable-preview -source ${jdk.version} BindingsTest1.java
|
* @compile BindingsTest1.java
|
||||||
* @run main/othervm --enable-preview BindingsTest1
|
* @run main BindingsTest1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class BindingsTest1 {
|
public class BindingsTest1 {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Basic tests for bindings from instanceof - tests for merging pattern variables
|
* @summary Basic tests for bindings from instanceof - tests for merging pattern variables
|
||||||
* @compile/fail/ref=BindingsTest1Merging.out -XDrawDiagnostics --enable-preview -source ${jdk.version} BindingsTest1Merging.java
|
* @compile/fail/ref=BindingsTest1Merging.out -XDrawDiagnostics BindingsTest1Merging.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class BindingsTest1Merging {
|
public class BindingsTest1Merging {
|
||||||
|
@ -7,6 +7,4 @@ BindingsTest1Merging.java:44:21: compiler.err.match.binding.exists
|
|||||||
BindingsTest1Merging.java:50:36: compiler.err.match.binding.exists
|
BindingsTest1Merging.java:50:36: compiler.err.match.binding.exists
|
||||||
BindingsTest1Merging.java:56:39: compiler.err.match.binding.exists
|
BindingsTest1Merging.java:56:39: compiler.err.match.binding.exists
|
||||||
BindingsTest1Merging.java:62:42: compiler.err.match.binding.exists
|
BindingsTest1Merging.java:62:42: compiler.err.match.binding.exists
|
||||||
- compiler.note.preview.filename: BindingsTest1Merging.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
9 errors
|
9 errors
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Ensure that scopes arising from conditionalExpressions are handled corrected.
|
* @summary Ensure that scopes arising from conditionalExpressions are handled corrected.
|
||||||
* @compile/fail/ref=BindingsTest2.out -XDrawDiagnostics -XDshould-stop.at=FLOW --enable-preview -source ${jdk.version} BindingsTest2.java
|
* @compile/fail/ref=BindingsTest2.out -XDrawDiagnostics -XDshould-stop.at=FLOW BindingsTest2.java
|
||||||
*/
|
*/
|
||||||
public class BindingsTest2 {
|
public class BindingsTest2 {
|
||||||
public static boolean Ktrue() { return true; }
|
public static boolean Ktrue() { return true; }
|
||||||
|
@ -49,6 +49,4 @@ BindingsTest2.java:241:17: compiler.err.cant.resolve.location: kindname.variable
|
|||||||
BindingsTest2.java:135:17: compiler.err.unreachable.stmt
|
BindingsTest2.java:135:17: compiler.err.unreachable.stmt
|
||||||
BindingsTest2.java:160:17: compiler.err.unreachable.stmt
|
BindingsTest2.java:160:17: compiler.err.unreachable.stmt
|
||||||
BindingsTest2.java:185:17: compiler.err.unreachable.stmt
|
BindingsTest2.java:185:17: compiler.err.unreachable.stmt
|
||||||
- compiler.note.preview.filename: BindingsTest2.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
51 errors
|
51 errors
|
@ -95,10 +95,7 @@ public class BreakAndLoops extends ComboInstance<BreakAndLoops> {
|
|||||||
case "NESTED" -> brk;
|
case "NESTED" -> brk;
|
||||||
case "BODY" -> innerLabel;
|
case "BODY" -> innerLabel;
|
||||||
default -> throw new UnsupportedOperationException(pname);
|
default -> throw new UnsupportedOperationException(pname);
|
||||||
})
|
});
|
||||||
.withOption("--enable-preview")
|
|
||||||
.withOption("-source")
|
|
||||||
.withOption(String.valueOf(Runtime.version().feature()));
|
|
||||||
|
|
||||||
task.generate(result -> {
|
task.generate(result -> {
|
||||||
boolean shouldPass;
|
boolean shouldPass;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamicopyright/
|
* @test /nodynamicopyright/
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Match which involves a cast conversion
|
* @summary Match which involves a cast conversion
|
||||||
* @compile/fail/ref=CastConversionMatch.out -XDrawDiagnostics --enable-preview -source ${jdk.version} CastConversionMatch.java
|
* @compile/fail/ref=CastConversionMatch.out -XDrawDiagnostics CastConversionMatch.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CastConversionMatch {
|
public class CastConversionMatch {
|
||||||
|
@ -1,4 +1,2 @@
|
|||||||
CastConversionMatch.java:11:26: compiler.err.type.found.req: int, (compiler.misc.type.req.class.array)
|
CastConversionMatch.java:11:26: compiler.err.type.found.req: int, (compiler.misc.type.req.class.array)
|
||||||
- compiler.note.preview.filename: CastConversionMatch.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
1 error
|
1 error
|
||||||
|
@ -85,10 +85,7 @@ public class ConditionalTest extends ComboInstance<ConditionalTest> {
|
|||||||
case "TRUE" -> trueSec;
|
case "TRUE" -> trueSec;
|
||||||
case "FALSE" -> falseSec;
|
case "FALSE" -> falseSec;
|
||||||
default -> throw new UnsupportedOperationException(pname);
|
default -> throw new UnsupportedOperationException(pname);
|
||||||
})
|
});
|
||||||
.withOption("--enable-preview")
|
|
||||||
.withOption("-source")
|
|
||||||
.withOption(String.valueOf(Runtime.version().feature()));
|
|
||||||
|
|
||||||
task.analyze(result -> {
|
task.analyze(result -> {
|
||||||
boolean shouldPass;
|
boolean shouldPass;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Basic pattern bindings scope test
|
* @summary Basic pattern bindings scope test
|
||||||
* @compile/fail/ref=DuplicateBindingTest.out -XDrawDiagnostics --enable-preview -source ${jdk.version} DuplicateBindingTest.java
|
* @compile/fail/ref=DuplicateBindingTest.out -XDrawDiagnostics DuplicateBindingTest.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DuplicateBindingTest {
|
public class DuplicateBindingTest {
|
||||||
@ -10,17 +10,17 @@ public class DuplicateBindingTest {
|
|||||||
int f;
|
int f;
|
||||||
|
|
||||||
public static boolean main(String[] args) {
|
public static boolean main(String[] args) {
|
||||||
|
Object o1 = "";
|
||||||
|
Object o2 = "";
|
||||||
|
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
int s;
|
int s;
|
||||||
if (args[0] instanceof String s) { // NOT OK. Redef same scope.
|
if (o1 instanceof String s) { // NOT OK. Redef same scope.
|
||||||
}
|
}
|
||||||
if (args[0] instanceof String f) { // OK to redef field.
|
if (o1 instanceof String f) { // OK to redef field.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object o1 = "";
|
|
||||||
Object o2 = "";
|
|
||||||
|
|
||||||
if (o1 instanceof String s && o2 instanceof String s) {} //error - already in scope on RHS (in scope due to LHS when true)
|
if (o1 instanceof String s && o2 instanceof String s) {} //error - already in scope on RHS (in scope due to LHS when true)
|
||||||
if (o1 instanceof String s && !(o2 instanceof String s)) {} //error - already in scope on RHS (in scope due to LHS when true)
|
if (o1 instanceof String s && !(o2 instanceof String s)) {} //error - already in scope on RHS (in scope due to LHS when true)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
DuplicateBindingTest.java:16:43: compiler.err.already.defined: kindname.variable, s, kindname.method, main(java.lang.String[])
|
DuplicateBindingTest.java:18:38: compiler.err.already.defined: kindname.variable, s, kindname.method, main(java.lang.String[])
|
||||||
DuplicateBindingTest.java:25:60: compiler.err.match.binding.exists
|
DuplicateBindingTest.java:25:60: compiler.err.match.binding.exists
|
||||||
DuplicateBindingTest.java:26:62: compiler.err.match.binding.exists
|
DuplicateBindingTest.java:26:62: compiler.err.match.binding.exists
|
||||||
DuplicateBindingTest.java:27:39: compiler.err.match.binding.exists
|
DuplicateBindingTest.java:27:39: compiler.err.match.binding.exists
|
||||||
@ -22,6 +22,4 @@ DuplicateBindingTest.java:50:102: compiler.err.match.binding.exists
|
|||||||
DuplicateBindingTest.java:51:73: compiler.err.match.binding.exists
|
DuplicateBindingTest.java:51:73: compiler.err.match.binding.exists
|
||||||
DuplicateBindingTest.java:54:69: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, DuplicateBindingTest, null)
|
DuplicateBindingTest.java:54:69: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, DuplicateBindingTest, null)
|
||||||
DuplicateBindingTest.java:55:44: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, DuplicateBindingTest, null)
|
DuplicateBindingTest.java:55:44: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, DuplicateBindingTest, null)
|
||||||
- compiler.note.preview.filename: DuplicateBindingTest.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
24 errors
|
24 errors
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8187420 8231827
|
* @bug 8187420 8231827
|
||||||
* @summary Error message mentions relevant types transposed
|
* @summary Error message mentions relevant types transposed
|
||||||
* @compile/fail/ref=EnsureTypesOrderTest.out -XDrawDiagnostics --enable-preview -source ${jdk.version} EnsureTypesOrderTest.java
|
* @compile/fail/ref=EnsureTypesOrderTest.out -XDrawDiagnostics EnsureTypesOrderTest.java
|
||||||
*/
|
*/
|
||||||
public class EnsureTypesOrderTest {
|
public class EnsureTypesOrderTest {
|
||||||
public static void main(String [] args) {
|
public static void main(String [] args) {
|
||||||
|
@ -1,4 +1,2 @@
|
|||||||
EnsureTypesOrderTest.java:9:13: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String[], java.lang.String)
|
EnsureTypesOrderTest.java:9:13: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String[], java.lang.String)
|
||||||
- compiler.note.preview.filename: EnsureTypesOrderTest.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
1 error
|
1 error
|
@ -25,8 +25,8 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary All example code from "Pattern Matching for Java" document, released April 2017, adjusted to current state (no switches, etc)
|
* @summary All example code from "Pattern Matching for Java" document, released April 2017, adjusted to current state (no switches, etc)
|
||||||
* @compile --enable-preview -source ${jdk.version} ExamplesFromProposal.java
|
* @compile ExamplesFromProposal.java
|
||||||
* @run main/othervm --enable-preview ExamplesFromProposal
|
* @run main ExamplesFromProposal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface Node {
|
interface Node {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Ensure that in type test patterns, the predicate is not trivially provable false.
|
* @summary Ensure that in type test patterns, the predicate is not trivially provable false.
|
||||||
* @compile/fail/ref=ImpossibleTypeTest.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ImpossibleTypeTest.java
|
* @compile/fail/ref=ImpossibleTypeTest.out -XDrawDiagnostics ImpossibleTypeTest.java
|
||||||
*/
|
*/
|
||||||
public class ImpossibleTypeTest {
|
public class ImpossibleTypeTest {
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
ImpossibleTypeTest.java:14:13: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String)
|
ImpossibleTypeTest.java:14:13: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String)
|
||||||
ImpossibleTypeTest.java:17:26: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, ImpossibleTypeTest, null)
|
ImpossibleTypeTest.java:17:26: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, ImpossibleTypeTest, null)
|
||||||
- compiler.note.preview.filename: ImpossibleTypeTest.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
2 errors
|
2 errors
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Ensure the LV table entries are generated for bindings
|
* @summary Ensure the LV table entries are generated for bindings
|
||||||
* @modules jdk.jdeps/com.sun.tools.classfile
|
* @modules jdk.jdeps/com.sun.tools.classfile
|
||||||
* @compile -g --enable-preview -source ${jdk.version} LocalVariableTable.java
|
* @compile -g LocalVariableTable.java
|
||||||
* @run main/othervm --enable-preview LocalVariableTable
|
* @run main LocalVariableTable
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Basic pattern bindings scope test
|
* @summary Basic pattern bindings scope test
|
||||||
* @compile/fail/ref=MatchBindingScopeTest.out -XDrawDiagnostics --enable-preview -source ${jdk.version} MatchBindingScopeTest.java
|
* @compile/fail/ref=MatchBindingScopeTest.out -XDrawDiagnostics MatchBindingScopeTest.java
|
||||||
*/
|
*/
|
||||||
public class MatchBindingScopeTest {
|
public class MatchBindingScopeTest {
|
||||||
|
|
||||||
|
@ -11,6 +11,4 @@ MatchBindingScopeTest.java:56:48: compiler.err.cant.resolve.location: kindname.v
|
|||||||
MatchBindingScopeTest.java:57:32: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
|
MatchBindingScopeTest.java:57:32: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
|
||||||
MatchBindingScopeTest.java:62:23: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
|
MatchBindingScopeTest.java:62:23: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
|
||||||
MatchBindingScopeTest.java:65:23: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
|
MatchBindingScopeTest.java:65:23: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
|
||||||
- compiler.note.preview.filename: MatchBindingScopeTest.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
13 errors
|
13 errors
|
22
test/langtools/tools/javac/patterns/NoSubtypeCheck.java
Normal file
22
test/langtools/tools/javac/patterns/NoSubtypeCheck.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* @test /nodynamiccopyright/
|
||||||
|
* @bug 8250625
|
||||||
|
* @summary Verify pattern matching test which is always true produces an error
|
||||||
|
* @compile/fail/ref=NoSubtypeCheck.out -XDrawDiagnostics NoSubtypeCheck.java
|
||||||
|
*/
|
||||||
|
public class NoSubtypeCheck {
|
||||||
|
|
||||||
|
public static void main(Object o, String s, List<String> l) {
|
||||||
|
boolean b1 = o instanceof Object v1;
|
||||||
|
boolean b2 = o instanceof String v2;
|
||||||
|
boolean b3 = s instanceof Object v3;
|
||||||
|
boolean b4 = s instanceof String v4;
|
||||||
|
boolean b5 = l instanceof List<String> v5;
|
||||||
|
boolean b6 = l instanceof List2<String> v6;
|
||||||
|
boolean b7 = undef instanceof String v7;
|
||||||
|
boolean b8 = o instanceof Undef v7;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface List<T> {}
|
||||||
|
public interface List2<T> extends List<T> {}
|
||||||
|
}
|
7
test/langtools/tools/javac/patterns/NoSubtypeCheck.out
Normal file
7
test/langtools/tools/javac/patterns/NoSubtypeCheck.out
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
NoSubtypeCheck.java:10:24: compiler.err.instanceof.pattern.no.subtype: java.lang.Object, java.lang.Object
|
||||||
|
NoSubtypeCheck.java:12:24: compiler.err.instanceof.pattern.no.subtype: java.lang.Object, java.lang.String
|
||||||
|
NoSubtypeCheck.java:13:24: compiler.err.instanceof.pattern.no.subtype: java.lang.String, java.lang.String
|
||||||
|
NoSubtypeCheck.java:14:24: compiler.err.instanceof.pattern.no.subtype: NoSubtypeCheck.List<java.lang.String>, NoSubtypeCheck.List<java.lang.String>
|
||||||
|
NoSubtypeCheck.java:16:22: compiler.err.cant.resolve.location: kindname.variable, undef, , , (compiler.misc.location: kindname.class, NoSubtypeCheck, null)
|
||||||
|
NoSubtypeCheck.java:17:35: compiler.err.cant.resolve.location: kindname.class, Undef, , , (compiler.misc.location: kindname.class, NoSubtypeCheck, null)
|
||||||
|
6 errors
|
@ -27,8 +27,8 @@
|
|||||||
* @summary Verify there are no unnecessary checkcasts and conditions generated
|
* @summary Verify there are no unnecessary checkcasts and conditions generated
|
||||||
* for the pattern matching in instanceof.
|
* for the pattern matching in instanceof.
|
||||||
* @modules jdk.jdeps/com.sun.tools.classfile
|
* @modules jdk.jdeps/com.sun.tools.classfile
|
||||||
* @compile --enable-preview -source ${jdk.version} NoUnnecessaryCast.java
|
* @compile NoUnnecessaryCast.java
|
||||||
* @run main/othervm --enable-preview NoUnnecessaryCast
|
* @run main NoUnnecessaryCast
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Testing pattern matching against the null constant
|
* @summary Testing pattern matching against the null constant
|
||||||
* @compile --enable-preview -source ${jdk.version} NullsInPatterns.java
|
* @compile/fail/ref=NullsInPatterns.out -XDrawDiagnostics NullsInPatterns.java
|
||||||
* @run main/othervm --enable-preview NullsInPatterns
|
|
||||||
*/
|
*/
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
3
test/langtools/tools/javac/patterns/NullsInPatterns.out
Normal file
3
test/langtools/tools/javac/patterns/NullsInPatterns.out
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
NullsInPatterns.java:35:18: compiler.err.instanceof.pattern.no.subtype: java.util.List, compiler.misc.type.null
|
||||||
|
NullsInPatterns.java:46:18: compiler.err.instanceof.pattern.no.subtype: java.util.List<?>, compiler.misc.type.null
|
||||||
|
2 errors
|
@ -26,7 +26,7 @@
|
|||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Check proper positions.
|
* @summary Check proper positions.
|
||||||
* @build PatternMatchPosTest
|
* @build PatternMatchPosTest
|
||||||
* @compile/ref=PatternMatchPosTest.out -processor PatternMatchPosTest -Xlint:unchecked -XDrawDiagnostics --enable-preview -source ${jdk.version} PatternMatchPosTestData.java
|
* @compile/ref=PatternMatchPosTest.out -processor PatternMatchPosTest -Xlint:unchecked -XDrawDiagnostics PatternMatchPosTestData.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -85,8 +85,10 @@ public class PatternMatchPosTest extends AbstractProcessor {
|
|||||||
if (print) {
|
if (print) {
|
||||||
int start = (int) sp.getStartPosition(dataPath.getCompilationUnit(), tree);
|
int start = (int) sp.getStartPosition(dataPath.getCompilationUnit(), tree);
|
||||||
int end = (int) sp.getEndPosition(dataPath.getCompilationUnit(), tree);
|
int end = (int) sp.getEndPosition(dataPath.getCompilationUnit(), tree);
|
||||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE,
|
if (start != (-1) || end != (-1)) {
|
||||||
text.substring(start, end));
|
processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE,
|
||||||
|
text.substring(start, end));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.scan(tree, p);
|
return super.scan(tree, p);
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
- compiler.note.proc.messager: o instanceof String s
|
- compiler.note.proc.messager: o instanceof String s
|
||||||
- compiler.note.proc.messager: o
|
- compiler.note.proc.messager: o
|
||||||
- compiler.note.proc.messager: String s
|
- compiler.note.proc.messager: String s
|
||||||
|
- compiler.note.proc.messager: String s
|
||||||
- compiler.note.proc.messager: String
|
- compiler.note.proc.messager: String
|
||||||
- compiler.note.proc.messager: (o instanceof java.lang.String s)
|
- compiler.note.proc.messager: (o instanceof java.lang.String s)
|
||||||
- compiler.note.proc.messager: o instanceof java.lang.String s
|
- compiler.note.proc.messager: o instanceof java.lang.String s
|
||||||
- compiler.note.proc.messager: o
|
- compiler.note.proc.messager: o
|
||||||
- compiler.note.proc.messager: java.lang.String s
|
- compiler.note.proc.messager: java.lang.String s
|
||||||
|
- compiler.note.proc.messager: java.lang.String s
|
||||||
- compiler.note.proc.messager: java.lang.String
|
- compiler.note.proc.messager: java.lang.String
|
||||||
- compiler.note.proc.messager: java.lang
|
- compiler.note.proc.messager: java.lang
|
||||||
- compiler.note.proc.messager: java
|
- compiler.note.proc.messager: java
|
||||||
- compiler.note.preview.filename: PatternMatchPosTestData.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Basic pattern test
|
* @summary Basic pattern test
|
||||||
* @compile --enable-preview -source ${jdk.version} PatternTypeTest2.java
|
* @compile PatternTypeTest2.java
|
||||||
* @run main/othervm --enable-preview PatternTypeTest2
|
* @run main PatternTypeTest2
|
||||||
*/
|
*/
|
||||||
public class PatternTypeTest2 {
|
public class PatternTypeTest2 {
|
||||||
|
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* @test /nodynamiccopyright/
|
|
||||||
* @bug 8231827
|
|
||||||
* @summary Ensure that in type test patterns, the predicate is not trivially provable false.
|
|
||||||
* @compile/fail/ref=PatternVariablesAreFinal.out -XDrawDiagnostics --enable-preview -source ${jdk.version} PatternVariablesAreFinal.java
|
|
||||||
*/
|
|
||||||
public class PatternVariablesAreFinal {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Object o = 32;
|
|
||||||
if (o instanceof String s) {
|
|
||||||
s = "hello again";
|
|
||||||
System.out.println(s);
|
|
||||||
}
|
|
||||||
System.out.println("test complete");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
PatternVariablesAreFinal.java:11:13: compiler.err.pattern.binding.may.not.be.assigned: s
|
|
||||||
- compiler.note.preview.filename: PatternVariablesAreFinal.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
1 error
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -21,15 +21,24 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.pattern.binding.may.not.be.assigned
|
/*
|
||||||
// key: compiler.note.preview.filename
|
* @test
|
||||||
// key: compiler.note.preview.recompile
|
* @bug 8231827
|
||||||
// options: --enable-preview -source ${jdk.version}
|
* @summary Pattern variables are non-final.
|
||||||
|
* @compile/fail/ref=PatternVariablesAreNonFinal.out -XDrawDiagnostics PatternVariablesAreNonFinal.java
|
||||||
class ResourceMayNotBeAssigned {
|
*/
|
||||||
void m(Object o) {
|
public class PatternVariablesAreNonFinal {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Object o = 32;
|
||||||
if (o instanceof String s) {
|
if (o instanceof String s) {
|
||||||
s = "";
|
s = "hello again";
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
System.err.println(s);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
System.out.println("test complete");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
PatternVariablesAreNonFinal.java:38:40: compiler.err.cant.ref.non.effectively.final.var: s, (compiler.misc.inner.cls)
|
||||||
|
1 error
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,11 +24,11 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Pattern variables are final so should be allowed to be referenced in an inner class
|
* @summary Pattern variables can be effectivelly final so should be allowed to be referenced in an inner class
|
||||||
* @compile --enable-preview -source ${jdk.version} PatternVariablesAreFinal2.java
|
* @compile PatternVariablesAreNonFinal2.java
|
||||||
* @run main/othervm --enable-preview PatternVariablesAreFinal2
|
* @run main PatternVariablesAreNonFinal2
|
||||||
*/
|
*/
|
||||||
public class PatternVariablesAreFinal2 {
|
public class PatternVariablesAreNonFinal2 {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Object o = "42";
|
Object o = "42";
|
||||||
if (o instanceof String s) {
|
if (o instanceof String s) {
|
||||||
@ -36,5 +36,9 @@ public class PatternVariablesAreFinal2 {
|
|||||||
void run() { System.err.println(s); }
|
void run() { System.err.println(s); }
|
||||||
}.run();
|
}.run();
|
||||||
}
|
}
|
||||||
|
if (o instanceof String s) {
|
||||||
|
s = "hello again";
|
||||||
|
System.out.println(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -105,7 +105,7 @@ public class PatternsSimpleVisitorTest {
|
|||||||
|
|
||||||
StringWriter out = new StringWriter();
|
StringWriter out = new StringWriter();
|
||||||
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
||||||
List.of("--enable-preview", "-source", Integer.toString(Runtime.version().feature())), null,
|
null, null,
|
||||||
Arrays.asList(new MyFileObject(code)));
|
Arrays.asList(new MyFileObject(code)));
|
||||||
return ct.parse().iterator().next();
|
return ct.parse().iterator().next();
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Verify behavior w.r.t. non-reifiable types and type test patterns in instanceof
|
* @summary Verify behavior w.r.t. non-reifiable types and type test patterns in instanceof
|
||||||
* @compile/fail/ref=Reifiable.out --enable-preview -source ${jdk.version} -XDrawDiagnostics Reifiable.java
|
* @compile/fail/ref=Reifiable.out -XDrawDiagnostics Reifiable.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Reifiable implements ReifiableI {
|
public class Reifiable implements ReifiableI {
|
||||||
|
@ -2,6 +2,4 @@ Reifiable.java:10:16: compiler.err.instanceof.reifiable.not.safe: java.lang.Obje
|
|||||||
Reifiable.java:12:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: Reifiable.List<java.lang.String>, Reifiable.ListImpl<Reifiable>)
|
Reifiable.java:12:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: Reifiable.List<java.lang.String>, Reifiable.ListImpl<Reifiable>)
|
||||||
Reifiable.java:13:39: compiler.err.not.within.bounds: java.lang.String, T
|
Reifiable.java:13:39: compiler.err.not.within.bounds: java.lang.String, T
|
||||||
Reifiable.java:14:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: Reifiable.List<Reifiable>, Reifiable.Unrelated<Reifiable>)
|
Reifiable.java:14:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: Reifiable.List<Reifiable>, Reifiable.Unrelated<Reifiable>)
|
||||||
- compiler.note.preview.filename: Reifiable.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
4 errors
|
4 errors
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
ReifiableOld.java:12:37: compiler.err.illegal.generic.type.for.instof
|
ReifiableOld.java:11:18: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.reifiable.types.instanceof), 15, 16
|
||||||
ReifiableOld.java:13:38: compiler.err.illegal.generic.type.for.instof
|
ReifiableOld.java:13:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: ReifiableOld.List<java.lang.String>, ReifiableOld.ListImpl<ReifiableOld>)
|
||||||
ReifiableOld.java:14:38: compiler.err.illegal.generic.type.for.instof
|
ReifiableOld.java:14:39: compiler.err.not.within.bounds: java.lang.String, T
|
||||||
ReifiableOld.java:15:38: compiler.err.illegal.generic.type.for.instof
|
ReifiableOld.java:15:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: ReifiableOld.List<ReifiableOld>, ReifiableOld.Unrelated<ReifiableOld>)
|
||||||
ReifiableOld.java:15:39: compiler.err.not.within.bounds: java.lang.String, T
|
4 errors
|
||||||
ReifiableOld.java:16:39: compiler.err.illegal.generic.type.for.instof
|
|
||||||
6 errors
|
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8231827
|
* @bug 8231827
|
||||||
* @summary Verify behavior w.r.t. non-reifiable types in instanceof
|
* @summary Verify behavior w.r.t. non-reifiable types in instanceof
|
||||||
* @compile/fail/ref=ReifiableOld-old.out -source 13 -Xlint:-options -XDrawDiagnostics ReifiableOld.java
|
* @compile/fail/ref=ReifiableOld-old.out -source 15 -Xlint:-options -XDrawDiagnostics ReifiableOld.java
|
||||||
* @compile/fail/ref=ReifiableOld-old.out -source ${jdk.version} -XDrawDiagnostics ReifiableOld.java
|
* @compile/fail/ref=ReifiableOld.out -XDrawDiagnostics ReifiableOld.java
|
||||||
* @compile/fail/ref=ReifiableOld.out --enable-preview -source ${jdk.version} -XDrawDiagnostics ReifiableOld.java
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ReifiableOld implements ReifiableOldI {
|
public class ReifiableOld implements ReifiableOldI {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
ReifiableOld.java:12:16: compiler.err.instanceof.reifiable.not.safe: java.lang.Object, ReifiableOld.ListImpl<ReifiableOld>
|
ReifiableOld.java:11:16: compiler.err.instanceof.reifiable.not.safe: java.lang.Object, ReifiableOld.ListImpl<ReifiableOld>
|
||||||
ReifiableOld.java:14:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: ReifiableOld.List<java.lang.String>, ReifiableOld.ListImpl<ReifiableOld>)
|
ReifiableOld.java:13:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: ReifiableOld.List<java.lang.String>, ReifiableOld.ListImpl<ReifiableOld>)
|
||||||
ReifiableOld.java:15:39: compiler.err.not.within.bounds: java.lang.String, T
|
ReifiableOld.java:14:39: compiler.err.not.within.bounds: java.lang.String, T
|
||||||
ReifiableOld.java:16:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: ReifiableOld.List<ReifiableOld>, ReifiableOld.Unrelated<ReifiableOld>)
|
ReifiableOld.java:15:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: ReifiableOld.List<ReifiableOld>, ReifiableOld.Unrelated<ReifiableOld>)
|
||||||
- compiler.note.preview.filename: ReifiableOld.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
4 errors
|
4 errors
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8187429 8231827
|
* @bug 8187429 8231827
|
||||||
* @summary Missing unchecked conversion warning
|
* @summary Missing unchecked conversion warning
|
||||||
* @compile/fail/ref=UncheckedWarningOnMatchesTest.out -Xlint:unchecked -Werror -XDrawDiagnostics --enable-preview -source ${jdk.version} UncheckedWarningOnMatchesTest.java
|
* @compile/fail/ref=UncheckedWarningOnMatchesTest.out -Xlint:unchecked -Werror -XDrawDiagnostics UncheckedWarningOnMatchesTest.java
|
||||||
*/
|
*/
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -1,4 +1,2 @@
|
|||||||
UncheckedWarningOnMatchesTest.java:14:13: compiler.err.instanceof.reifiable.not.safe: java.lang.Object, java.util.ArrayList<java.lang.Integer>
|
UncheckedWarningOnMatchesTest.java:14:13: compiler.err.instanceof.reifiable.not.safe: java.lang.Object, java.util.ArrayList<java.lang.Integer>
|
||||||
- compiler.note.preview.filename: UncheckedWarningOnMatchesTest.java
|
|
||||||
- compiler.note.preview.recompile
|
|
||||||
1 error
|
1 error
|
||||||
|
@ -98,10 +98,7 @@ public class ScopeTest extends JavacTemplateTestBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertOK(String block) {
|
private void assertOK(String block) {
|
||||||
String sourceVersion = Integer.toString(Runtime.version().feature());
|
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
addCompileOptions("--enable-preview", "-source", sourceVersion);
|
|
||||||
program(block);
|
program(block);
|
||||||
try {
|
try {
|
||||||
compile();
|
compile();
|
||||||
@ -113,10 +110,7 @@ public class ScopeTest extends JavacTemplateTestBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertFail(String expectedDiag, String block) {
|
private void assertFail(String expectedDiag, String block) {
|
||||||
String sourceVersion = Integer.toString(Runtime.version().feature());
|
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
addCompileOptions("--enable-preview", "-source", sourceVersion);
|
|
||||||
program(block);
|
program(block);
|
||||||
try {
|
try {
|
||||||
compile();
|
compile();
|
||||||
|
@ -105,20 +105,20 @@ public class TestBindingVariable extends JavacTestingAbstractProcessor implement
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Void visitBindingPattern(BindingPatternTree node, Void p) {
|
public Void visitBindingPattern(BindingPatternTree node, Void p) {
|
||||||
handleCurrentTreeAsBindingVar();
|
handleTreeAsBindingVar(new TreePath(getCurrentPath(), node.getVariable()));
|
||||||
return super.visitBindingPattern(node, p);
|
return super.visitBindingPattern(node, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitIdentifier(IdentifierTree node, Void p) {
|
public Void visitIdentifier(IdentifierTree node, Void p) {
|
||||||
if (node.getName().contentEquals("bindingVar")) {
|
if (node.getName().contentEquals("bindingVar")) {
|
||||||
handleCurrentTreeAsBindingVar();
|
handleTreeAsBindingVar(getCurrentPath());
|
||||||
}
|
}
|
||||||
return super.visitIdentifier(node, p);
|
return super.visitIdentifier(node, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCurrentTreeAsBindingVar() {
|
private void handleTreeAsBindingVar(TreePath tp) {
|
||||||
Element element = trees.getElement(getCurrentPath());
|
Element element = trees.getElement(tp);
|
||||||
|
|
||||||
System.out.println("Name: " + element.getSimpleName() +
|
System.out.println("Name: " + element.getSimpleName() +
|
||||||
"\tKind: " + element.getKind());
|
"\tKind: " + element.getKind());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user