mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
8056021: checkin for JDK-8027262 breaks Checker Framework
Reviewed-by: jjg, mcimadamore
This commit is contained in:
parent
f211cac0cd
commit
053a9d56cd
30 changed files with 2041 additions and 2346 deletions
|
@ -151,7 +151,7 @@ public abstract class Attribute implements AnnotationValue {
|
||||||
* access this attribute.
|
* access this attribute.
|
||||||
*/
|
*/
|
||||||
public final List<Pair<MethodSymbol,Attribute>> values;
|
public final List<Pair<MethodSymbol,Attribute>> values;
|
||||||
public final TypeAnnotationPosition position;
|
public TypeAnnotationPosition position;
|
||||||
|
|
||||||
private boolean synthesized = false;
|
private boolean synthesized = false;
|
||||||
|
|
||||||
|
@ -179,9 +179,53 @@ public abstract class Attribute implements AnnotationValue {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TypeAnnotationPosition getPosition() {
|
public TypeAnnotationPosition getPosition() {
|
||||||
|
if (hasUnknownPosition()) {
|
||||||
|
if (values.size() != 0) {
|
||||||
|
Name valueName = values.head.fst.name.table.names.value;
|
||||||
|
Pair<MethodSymbol, Attribute> res = getElemPair(valueName);
|
||||||
|
position = res == null ? null : res.snd.getPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isContainerTypeCompound() {
|
||||||
|
if (isSynthesized() && values.size() == 1)
|
||||||
|
return getFirstEmbeddedTC() != null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Compound getFirstEmbeddedTC() {
|
||||||
|
if (values.size() == 1) {
|
||||||
|
Pair<MethodSymbol, Attribute> val = values.get(0);
|
||||||
|
if (val.fst.getSimpleName().contentEquals("value")
|
||||||
|
&& val.snd instanceof Array) {
|
||||||
|
Array arr = (Array) val.snd;
|
||||||
|
if (arr.values.length != 0
|
||||||
|
&& arr.values[0] instanceof Attribute.TypeCompound)
|
||||||
|
return (Attribute.TypeCompound) arr.values[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean tryFixPosition() {
|
||||||
|
if (!isContainerTypeCompound())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Compound from = getFirstEmbeddedTC();
|
||||||
|
if (from != null && from.position != null &&
|
||||||
|
from.position.type != TargetType.UNKNOWN) {
|
||||||
|
position = from.position;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUnknownPosition() {
|
||||||
|
return position.type == TargetType.UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
public void accept(Visitor v) { v.visitCompound(this); }
|
public void accept(Visitor v) { v.visitCompound(this); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -250,12 +294,6 @@ public abstract class Attribute implements AnnotationValue {
|
||||||
valmap.put(value.fst, value.snd);
|
valmap.put(value.fst, value.snd);
|
||||||
return valmap;
|
return valmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeCompound toTypeCompound() {
|
|
||||||
// It is safe to alias the position.
|
|
||||||
return new TypeCompound(this, this.position);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TypeCompound extends Compound {
|
public static class TypeCompound extends Compound {
|
||||||
|
|
|
@ -107,7 +107,10 @@ public enum TargetType {
|
||||||
CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT(0x4A, true),
|
CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT(0x4A, true),
|
||||||
|
|
||||||
/** For annotations on a type argument of a method reference. */
|
/** For annotations on a type argument of a method reference. */
|
||||||
METHOD_REFERENCE_TYPE_ARGUMENT(0x4B, true);
|
METHOD_REFERENCE_TYPE_ARGUMENT(0x4B, true),
|
||||||
|
|
||||||
|
/** For annotations with an unknown target. */
|
||||||
|
UNKNOWN(0xFF);
|
||||||
|
|
||||||
private static final int MAXIMUM_TARGET_TYPE_VALUE = 0x4B;
|
private static final int MAXIMUM_TARGET_TYPE_VALUE = 0x4B;
|
||||||
|
|
||||||
|
@ -147,15 +150,26 @@ public enum TargetType {
|
||||||
targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
|
targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
|
||||||
TargetType[] alltargets = values();
|
TargetType[] alltargets = values();
|
||||||
for (TargetType target : alltargets) {
|
for (TargetType target : alltargets) {
|
||||||
|
if (target.targetTypeValue != UNKNOWN.targetTypeValue)
|
||||||
targets[target.targetTypeValue] = target;
|
targets[target.targetTypeValue] = target;
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i <= MAXIMUM_TARGET_TYPE_VALUE; ++i) {
|
||||||
|
if (targets[i] == null)
|
||||||
|
targets[i] = UNKNOWN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidTargetTypeValue(int tag) {
|
public static boolean isValidTargetTypeValue(int tag) {
|
||||||
|
if (tag == UNKNOWN.targetTypeValue)
|
||||||
|
return true;
|
||||||
|
|
||||||
return (tag >= 0 && tag < targets.length);
|
return (tag >= 0 && tag < targets.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TargetType fromTargetTypeValue(int tag) {
|
public static TargetType fromTargetTypeValue(int tag) {
|
||||||
|
if (tag == UNKNOWN.targetTypeValue)
|
||||||
|
return UNKNOWN;
|
||||||
|
|
||||||
if (tag < 0 || tag >= targets.length)
|
if (tag < 0 || tag >= targets.length)
|
||||||
Assert.error("Unknown TargetType: " + tag);
|
Assert.error("Unknown TargetType: " + tag);
|
||||||
return targets[tag];
|
return targets[tag];
|
||||||
|
|
|
@ -256,6 +256,9 @@ public class TypeAnnotationPosition {
|
||||||
case METHOD_RETURN:
|
case METHOD_RETURN:
|
||||||
case FIELD:
|
case FIELD:
|
||||||
break;
|
break;
|
||||||
|
case UNKNOWN:
|
||||||
|
sb.append(", position UNKNOWN!");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.error("Unknown target type: " + type);
|
Assert.error("Unknown target type: " + type);
|
||||||
}
|
}
|
||||||
|
@ -658,11 +661,10 @@ public class TypeAnnotationPosition {
|
||||||
public static TypeAnnotationPosition
|
public static TypeAnnotationPosition
|
||||||
exceptionParameter(final List<TypePathEntry> location,
|
exceptionParameter(final List<TypePathEntry> location,
|
||||||
final JCLambda onLambda,
|
final JCLambda onLambda,
|
||||||
final int type_index,
|
|
||||||
final int pos) {
|
final int pos) {
|
||||||
return new TypeAnnotationPosition(TargetType.EXCEPTION_PARAMETER, pos,
|
return new TypeAnnotationPosition(TargetType.EXCEPTION_PARAMETER, pos,
|
||||||
Integer.MIN_VALUE, onLambda,
|
Integer.MIN_VALUE, onLambda,
|
||||||
type_index, Integer.MIN_VALUE,
|
Integer.MIN_VALUE, Integer.MIN_VALUE,
|
||||||
location);
|
location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,7 +677,7 @@ public class TypeAnnotationPosition {
|
||||||
public static TypeAnnotationPosition
|
public static TypeAnnotationPosition
|
||||||
exceptionParameter(final JCLambda onLambda,
|
exceptionParameter(final JCLambda onLambda,
|
||||||
final int pos) {
|
final int pos) {
|
||||||
return exceptionParameter(emptyPath, onLambda, Integer.MIN_VALUE, pos);
|
return exceptionParameter(emptyPath, onLambda, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -685,7 +687,7 @@ public class TypeAnnotationPosition {
|
||||||
*/
|
*/
|
||||||
public static TypeAnnotationPosition
|
public static TypeAnnotationPosition
|
||||||
exceptionParameter(final List<TypePathEntry> location) {
|
exceptionParameter(final List<TypePathEntry> location) {
|
||||||
return exceptionParameter(location, null, Integer.MIN_VALUE, -1);
|
return exceptionParameter(location, null, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1199,4 +1201,12 @@ public class TypeAnnotationPosition {
|
||||||
return methodTypeParameterBound(location, null, parameter_index,
|
return methodTypeParameterBound(location, null, parameter_index,
|
||||||
bound_index, -1);
|
bound_index, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Consider this deprecated on arrival. We eventually want to get
|
||||||
|
// rid of this value altogether. Do not use it for anything new.
|
||||||
|
public static final TypeAnnotationPosition unknown =
|
||||||
|
new TypeAnnotationPosition(TargetType.UNKNOWN, -1,
|
||||||
|
Integer.MIN_VALUE, null,
|
||||||
|
Integer.MIN_VALUE, Integer.MIN_VALUE,
|
||||||
|
emptyPath);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -94,6 +94,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
final Types types;
|
final Types types;
|
||||||
final JCDiagnostic.Factory diags;
|
final JCDiagnostic.Factory diags;
|
||||||
final Annotate annotate;
|
final Annotate annotate;
|
||||||
|
final TypeAnnotations typeAnnotations;
|
||||||
final DeferredLintHandler deferredLintHandler;
|
final DeferredLintHandler deferredLintHandler;
|
||||||
final TypeEnvs typeEnvs;
|
final TypeEnvs typeEnvs;
|
||||||
final Dependencies dependencies;
|
final Dependencies dependencies;
|
||||||
|
@ -124,6 +125,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
types = Types.instance(context);
|
types = Types.instance(context);
|
||||||
diags = JCDiagnostic.Factory.instance(context);
|
diags = JCDiagnostic.Factory.instance(context);
|
||||||
annotate = Annotate.instance(context);
|
annotate = Annotate.instance(context);
|
||||||
|
typeAnnotations = TypeAnnotations.instance(context);
|
||||||
deferredLintHandler = DeferredLintHandler.instance(context);
|
deferredLintHandler = DeferredLintHandler.instance(context);
|
||||||
typeEnvs = TypeEnvs.instance(context);
|
typeEnvs = TypeEnvs.instance(context);
|
||||||
dependencies = Dependencies.instance(context);
|
dependencies = Dependencies.instance(context);
|
||||||
|
@ -372,7 +374,8 @@ public class Attr extends JCTree.Visitor {
|
||||||
public Type attribImportQualifier(JCImport tree, Env<AttrContext> env) {
|
public Type attribImportQualifier(JCImport tree, Env<AttrContext> env) {
|
||||||
// Attribute qualifying package or class.
|
// Attribute qualifying package or class.
|
||||||
JCFieldAccess s = (JCFieldAccess)tree.qualid;
|
JCFieldAccess s = (JCFieldAccess)tree.qualid;
|
||||||
return attribTree(s.selected, env,
|
return attribTree(s.selected,
|
||||||
|
env,
|
||||||
new ResultInfo(tree.staticImport ? TYP : (TYP | PCK),
|
new ResultInfo(tree.staticImport ? TYP : (TYP | PCK),
|
||||||
Type.noType));
|
Type.noType));
|
||||||
}
|
}
|
||||||
|
@ -572,8 +575,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
/** Derived visitor method: attribute an expression tree.
|
/** Derived visitor method: attribute an expression tree.
|
||||||
*/
|
*/
|
||||||
public Type attribExpr(JCTree tree, Env<AttrContext> env, Type pt) {
|
public Type attribExpr(JCTree tree, Env<AttrContext> env, Type pt) {
|
||||||
return attribTree(tree, env,
|
return attribTree(tree, env, new ResultInfo(VAL, !pt.hasTag(ERROR) ? pt : Type.noType));
|
||||||
new ResultInfo(VAL, !pt.hasTag(ERROR) ? pt : Type.noType));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Derived visitor method: attribute an expression tree with
|
/** Derived visitor method: attribute an expression tree with
|
||||||
|
@ -585,7 +587,6 @@ public class Attr extends JCTree.Visitor {
|
||||||
|
|
||||||
/** Derived visitor method: attribute a type tree.
|
/** Derived visitor method: attribute a type tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Type attribType(JCTree tree, Env<AttrContext> env) {
|
public Type attribType(JCTree tree, Env<AttrContext> env) {
|
||||||
Type result = attribType(tree, env, Type.noType);
|
Type result = attribType(tree, env, Type.noType);
|
||||||
return result;
|
return result;
|
||||||
|
@ -600,7 +601,6 @@ public class Attr extends JCTree.Visitor {
|
||||||
|
|
||||||
/** Derived visitor method: attribute a statement or definition tree.
|
/** Derived visitor method: attribute a statement or definition tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Type attribStat(JCTree tree, Env<AttrContext> env) {
|
public Type attribStat(JCTree tree, Env<AttrContext> env) {
|
||||||
return attribTree(tree, env, statInfo);
|
return attribTree(tree, env, statInfo);
|
||||||
}
|
}
|
||||||
|
@ -669,8 +669,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
a.tsym.flags_field |= UNATTRIBUTED;
|
a.tsym.flags_field |= UNATTRIBUTED;
|
||||||
a.bound = Type.noType;
|
a.bound = Type.noType;
|
||||||
if (!tvar.bounds.isEmpty()) {
|
if (!tvar.bounds.isEmpty()) {
|
||||||
List<Type> bounds =
|
List<Type> bounds = List.of(attribType(tvar.bounds.head, env));
|
||||||
List.of(attribType(tvar.bounds.head, env));
|
|
||||||
for (JCExpression bound : tvar.bounds.tail)
|
for (JCExpression bound : tvar.bounds.tail)
|
||||||
bounds = bounds.prepend(attribType(bound, env));
|
bounds = bounds.prepend(attribType(bound, env));
|
||||||
types.setBounds(a, bounds.reverse());
|
types.setBounds(a, bounds.reverse());
|
||||||
|
@ -705,7 +704,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
* @param type The expected type, or null
|
* @param type The expected type, or null
|
||||||
* @see VarSymbol#setLazyConstValue
|
* @see VarSymbol#setLazyConstValue
|
||||||
*/
|
*/
|
||||||
public Object attribLazyConstantValue(final Env<AttrContext> env,
|
public Object attribLazyConstantValue(Env<AttrContext> env,
|
||||||
JCVariableDecl variable,
|
JCVariableDecl variable,
|
||||||
Type type) {
|
Type type) {
|
||||||
|
|
||||||
|
@ -824,7 +823,6 @@ public class Attr extends JCTree.Visitor {
|
||||||
c.flags_field |= NOOUTERTHIS;
|
c.flags_field |= NOOUTERTHIS;
|
||||||
}
|
}
|
||||||
attribClass(tree.pos(), c);
|
attribClass(tree.pos(), c);
|
||||||
|
|
||||||
result = tree.type = c.type;
|
result = tree.type = c.type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -867,9 +865,9 @@ public class Attr extends JCTree.Visitor {
|
||||||
|
|
||||||
ClassSymbol owner = env.enclClass.sym;
|
ClassSymbol owner = env.enclClass.sym;
|
||||||
if ((owner.flags() & ANNOTATION) != 0 &&
|
if ((owner.flags() & ANNOTATION) != 0 &&
|
||||||
tree.params.nonEmpty())
|
tree.params.nonEmpty())
|
||||||
log.error(tree.params.head.pos(),
|
log.error(tree.params.head.pos(),
|
||||||
"intf.annotation.members.cant.have.params");
|
"intf.annotation.members.cant.have.params");
|
||||||
|
|
||||||
// Attribute all value parameters.
|
// Attribute all value parameters.
|
||||||
for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
|
for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
|
||||||
|
@ -943,91 +941,56 @@ public class Attr extends JCTree.Visitor {
|
||||||
if (tree.name == names.init && owner.type != syms.objectType) {
|
if (tree.name == names.init && owner.type != syms.objectType) {
|
||||||
JCBlock body = tree.body;
|
JCBlock body = tree.body;
|
||||||
if (body.stats.isEmpty() ||
|
if (body.stats.isEmpty() ||
|
||||||
!TreeInfo.isSelfCall(body.stats.head)) {
|
!TreeInfo.isSelfCall(body.stats.head)) {
|
||||||
body.stats = body.stats.
|
body.stats = body.stats.
|
||||||
prepend(memberEnter.SuperCall(make.at(body.pos),
|
prepend(memberEnter.SuperCall(make.at(body.pos),
|
||||||
List.<Type>nil(),
|
List.<Type>nil(),
|
||||||
List.<JCVariableDecl>nil(),
|
List.<JCVariableDecl>nil(),
|
||||||
false));
|
false));
|
||||||
} else if ((env.enclClass.sym.flags() & ENUM) != 0 &&
|
} else if ((env.enclClass.sym.flags() & ENUM) != 0 &&
|
||||||
(tree.mods.flags & GENERATEDCONSTR) == 0 &&
|
(tree.mods.flags & GENERATEDCONSTR) == 0 &&
|
||||||
TreeInfo.isSuperCall(body.stats.head)) {
|
TreeInfo.isSuperCall(body.stats.head)) {
|
||||||
// enum constructors are not allowed to call super
|
// enum constructors are not allowed to call super
|
||||||
// directly, so make sure there aren't any super calls
|
// directly, so make sure there aren't any super calls
|
||||||
// in enum constructors, except in the compiler
|
// in enum constructors, except in the compiler
|
||||||
// generated one.
|
// generated one.
|
||||||
log.error(tree.body.stats.head.pos(),
|
log.error(tree.body.stats.head.pos(),
|
||||||
"call.to.super.not.allowed.in.enum.ctor",
|
"call.to.super.not.allowed.in.enum.ctor",
|
||||||
env.enclClass.sym);
|
env.enclClass.sym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attribute all type annotations in the body
|
||||||
|
annotate.annotateTypeLater(tree.body, localEnv, m, null);
|
||||||
|
annotate.flush();
|
||||||
|
|
||||||
// Attribute method body.
|
// Attribute method body.
|
||||||
attribStat(tree.body, localEnv);
|
attribStat(tree.body, localEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
localEnv.info.scope.leave();
|
localEnv.info.scope.leave();
|
||||||
result = tree.type = m.type;
|
result = tree.type = m.type;
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
chk.setLint(prevLint);
|
chk.setLint(prevLint);
|
||||||
chk.setMethod(prevMethod);
|
chk.setMethod(prevMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Annotate.PositionCreator getVarCreator(final JCVariableDecl tree) {
|
public void visitVarDef(JCVariableDecl tree) {
|
||||||
// Form the enclosing tree node, figure out what kind
|
|
||||||
// of definition we are looking at.
|
|
||||||
switch(env.tree.getTag()) {
|
|
||||||
case TRY:
|
|
||||||
// If it's a try, then we have a resource variable
|
|
||||||
return annotate.resourceVarCreator(tree.pos);
|
|
||||||
case CATCH:
|
|
||||||
// If it's a catch, then we have an exception parameter
|
|
||||||
return annotate.exceptionParamCreator(tree.pos);
|
|
||||||
case LAMBDA: {
|
|
||||||
// If it's a lambda, then we could have a local
|
|
||||||
// variable or a parameter.
|
|
||||||
final JCLambda lambda = (JCLambda) env.tree;
|
|
||||||
// We have to figure out what the index of the
|
|
||||||
// parameter is, and unfortunately, the visitor
|
|
||||||
// and tree APIs don't help us much here. If we
|
|
||||||
// don't find the declaration in the parameter
|
|
||||||
// list, then it must be a local variable.
|
|
||||||
//
|
|
||||||
// This could easily be replaced by an index
|
|
||||||
// parameter, which is -1 for non-indexed
|
|
||||||
// definitions.
|
|
||||||
int index = -1;
|
|
||||||
int i = 0;
|
|
||||||
for (List<JCVariableDecl> l = lambda.params;
|
|
||||||
l.nonEmpty(); l = l.tail, i++) {
|
|
||||||
if (l.head == tree) {
|
|
||||||
index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (index == -1) {
|
|
||||||
return annotate.localVarCreator(tree.pos);
|
|
||||||
} else {
|
|
||||||
return annotate.paramCreator(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
// The default case is to treat any declaration as a local
|
|
||||||
// variable.
|
|
||||||
return annotate.localVarCreator(tree.pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void visitVarDef(final JCVariableDecl tree) {
|
|
||||||
// Local variables have not been entered yet, so we need to do it now:
|
// Local variables have not been entered yet, so we need to do it now:
|
||||||
if (env.info.scope.owner.kind == MTH) {
|
if (env.info.scope.owner.kind == MTH) {
|
||||||
if (tree.sym != null) {
|
if (tree.sym != null) {
|
||||||
// parameters have already been entered
|
// parameters have already been entered
|
||||||
env.info.scope.enter(tree.sym);
|
env.info.scope.enter(tree.sym);
|
||||||
} else {
|
} else {
|
||||||
memberEnter.memberEnter(tree, env, getVarCreator(tree));
|
memberEnter.memberEnter(tree, env);
|
||||||
|
annotate.flush();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (tree.init != null) {
|
||||||
|
// Field initializer expression need to be entered.
|
||||||
|
annotate.annotateTypeLater(tree.init, env, tree.sym, tree.pos());
|
||||||
|
annotate.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1086,6 +1049,9 @@ public class Attr extends JCTree.Visitor {
|
||||||
env.dup(tree, env.info.dup(env.info.scope.dupUnshared(fakeOwner)));
|
env.dup(tree, env.info.dup(env.info.scope.dupUnshared(fakeOwner)));
|
||||||
|
|
||||||
if ((tree.flags & STATIC) != 0) localEnv.info.staticLevel++;
|
if ((tree.flags & STATIC) != 0) localEnv.info.staticLevel++;
|
||||||
|
// Attribute all type annotations in the block
|
||||||
|
annotate.annotateTypeLater(tree, localEnv, localEnv.info.scope.owner, null);
|
||||||
|
annotate.flush();
|
||||||
attribStats(tree.stats, localEnv);
|
attribStats(tree.stats, localEnv);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1449,21 +1415,17 @@ public class Attr extends JCTree.Visitor {
|
||||||
isBooleanOrNumeric(env, condTree.falsepart);
|
isBooleanOrNumeric(env, condTree.falsepart);
|
||||||
case APPLY:
|
case APPLY:
|
||||||
JCMethodInvocation speculativeMethodTree =
|
JCMethodInvocation speculativeMethodTree =
|
||||||
(JCMethodInvocation)deferredAttr.attribSpeculative(tree, env, unknownExprInfo,
|
(JCMethodInvocation)deferredAttr.attribSpeculative(tree, env, unknownExprInfo);
|
||||||
annotate.noCreator);
|
|
||||||
Type owntype = TreeInfo.symbol(speculativeMethodTree.meth).type.getReturnType();
|
Type owntype = TreeInfo.symbol(speculativeMethodTree.meth).type.getReturnType();
|
||||||
return types.unboxedTypeOrType(owntype).isPrimitive();
|
return types.unboxedTypeOrType(owntype).isPrimitive();
|
||||||
case NEWCLASS:
|
case NEWCLASS:
|
||||||
JCExpression className =
|
JCExpression className =
|
||||||
removeClassParams.translate(((JCNewClass)tree).clazz);
|
removeClassParams.translate(((JCNewClass)tree).clazz);
|
||||||
JCExpression speculativeNewClassTree =
|
JCExpression speculativeNewClassTree =
|
||||||
(JCExpression)deferredAttr.attribSpeculative(className,
|
(JCExpression)deferredAttr.attribSpeculative(className, env, unknownTypeInfo);
|
||||||
env,
|
|
||||||
unknownTypeInfo,
|
|
||||||
annotate.newObjCreator(tree.pos));
|
|
||||||
return types.unboxedTypeOrType(speculativeNewClassTree.type).isPrimitive();
|
return types.unboxedTypeOrType(speculativeNewClassTree.type).isPrimitive();
|
||||||
default:
|
default:
|
||||||
Type speculativeType = deferredAttr.attribSpeculative(tree, env, unknownExprInfo, annotate.noCreator).type;
|
Type speculativeType = deferredAttr.attribSpeculative(tree, env, unknownExprInfo).type;
|
||||||
speculativeType = types.unboxedTypeOrType(speculativeType);
|
speculativeType = types.unboxedTypeOrType(speculativeType);
|
||||||
return speculativeType.isPrimitive();
|
return speculativeType.isPrimitive();
|
||||||
}
|
}
|
||||||
|
@ -1724,28 +1686,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
// Attribute arguments, yielding list of argument types.
|
// Attribute arguments, yielding list of argument types.
|
||||||
attribArgs(tree.args, localEnv, argtypesBuf);
|
attribArgs(tree.args, localEnv, argtypesBuf);
|
||||||
argtypes = argtypesBuf.toList();
|
argtypes = argtypesBuf.toList();
|
||||||
|
typeargtypes = attribTypes(tree.typeargs, localEnv);
|
||||||
// Attribute and annotate the type arguments
|
|
||||||
ListBuffer<Type> typeargtypesbuf = new ListBuffer<>();
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (List<JCExpression> l = tree.typeargs;
|
|
||||||
l.nonEmpty(); l = l.tail, i++) {
|
|
||||||
final JCExpression arg = l.head;
|
|
||||||
try {
|
|
||||||
annotate.enterStart();
|
|
||||||
typeargtypesbuf.append(attribType(arg, localEnv));
|
|
||||||
annotate.annotateTypeLater(arg, localEnv,
|
|
||||||
localEnv.info.scope.owner,
|
|
||||||
tree.pos(),
|
|
||||||
annotate.constructorInvokeTypeArgCreator(i, tree.pos));
|
|
||||||
} finally {
|
|
||||||
annotate.enterDone();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typeargtypes =
|
|
||||||
chk.checkRefTypes(tree.typeargs, typeargtypesbuf.toList());
|
|
||||||
|
|
||||||
// Variable `site' points to the class in which the called
|
// Variable `site' points to the class in which the called
|
||||||
// constructor is defined.
|
// constructor is defined.
|
||||||
|
@ -1818,27 +1759,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
// Attribute the arguments, yielding list of argument types, ...
|
// Attribute the arguments, yielding list of argument types, ...
|
||||||
int kind = attribArgs(tree.args, localEnv, argtypesBuf);
|
int kind = attribArgs(tree.args, localEnv, argtypesBuf);
|
||||||
argtypes = argtypesBuf.toList();
|
argtypes = argtypesBuf.toList();
|
||||||
|
typeargtypes = attribAnyTypes(tree.typeargs, localEnv);
|
||||||
// Attribute and annotate the type arguments
|
|
||||||
ListBuffer<Type> typeargtypesbuf = new ListBuffer<>();
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (List<JCExpression> l = tree.typeargs;
|
|
||||||
l.nonEmpty(); l = l.tail, i++) {
|
|
||||||
final JCExpression arg = l.head;
|
|
||||||
try {
|
|
||||||
annotate.enterStart();
|
|
||||||
typeargtypesbuf.append(attribType(arg, localEnv));
|
|
||||||
annotate.annotateTypeLater(arg, localEnv,
|
|
||||||
localEnv.info.scope.owner,
|
|
||||||
tree.pos(),
|
|
||||||
annotate.methodInvokeTypeArgCreator(i, tree.pos));
|
|
||||||
} finally {
|
|
||||||
annotate.enterDone();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typeargtypes = typeargtypesbuf.toList();
|
|
||||||
|
|
||||||
// ... and attribute the method using as a prototype a methodtype
|
// ... and attribute the method using as a prototype a methodtype
|
||||||
// whose formal argument types is exactly the list of actual
|
// whose formal argument types is exactly the list of actual
|
||||||
|
@ -1863,7 +1784,6 @@ public class Attr extends JCTree.Visitor {
|
||||||
// current context. Also, capture the return type
|
// current context. Also, capture the return type
|
||||||
result = check(tree, capture(restype), VAL, resultInfo);
|
result = check(tree, capture(restype), VAL, resultInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
chk.validate(tree.typeargs, localEnv);
|
chk.validate(tree.typeargs, localEnv);
|
||||||
}
|
}
|
||||||
//where
|
//where
|
||||||
|
@ -1935,12 +1855,14 @@ public class Attr extends JCTree.Visitor {
|
||||||
annoclazzid = (JCAnnotatedType) clazzid;
|
annoclazzid = (JCAnnotatedType) clazzid;
|
||||||
clazzid = annoclazzid.underlyingType;
|
clazzid = annoclazzid.underlyingType;
|
||||||
}
|
}
|
||||||
} else if (clazz.hasTag(ANNOTATED_TYPE)) {
|
} else {
|
||||||
|
if (clazz.hasTag(ANNOTATED_TYPE)) {
|
||||||
annoclazzid = (JCAnnotatedType) clazz;
|
annoclazzid = (JCAnnotatedType) clazz;
|
||||||
clazzid = annoclazzid.underlyingType;
|
clazzid = annoclazzid.underlyingType;
|
||||||
} else {
|
} else {
|
||||||
clazzid = clazz;
|
clazzid = clazz;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JCExpression clazzid1 = clazzid; // The same in fully qualified form
|
JCExpression clazzid1 = clazzid; // The same in fully qualified form
|
||||||
|
|
||||||
|
@ -1962,12 +1884,11 @@ public class Attr extends JCTree.Visitor {
|
||||||
|
|
||||||
EndPosTable endPosTable = this.env.toplevel.endPositions;
|
EndPosTable endPosTable = this.env.toplevel.endPositions;
|
||||||
endPosTable.storeEnd(clazzid1, tree.getEndPosition(endPosTable));
|
endPosTable.storeEnd(clazzid1, tree.getEndPosition(endPosTable));
|
||||||
if (annoclazzid != null) {
|
if (clazz.hasTag(ANNOTATED_TYPE)) {
|
||||||
JCAnnotatedType annoType = annoclazzid;
|
JCAnnotatedType annoType = (JCAnnotatedType) clazz;
|
||||||
List<JCAnnotation> annos = annoclazzid.annotations;
|
List<JCAnnotation> annos = annoType.annotations;
|
||||||
|
|
||||||
if (clazz.hasTag(TYPEAPPLY)) {
|
|
||||||
|
|
||||||
|
if (annoType.underlyingType.hasTag(TYPEAPPLY)) {
|
||||||
clazzid1 = make.at(tree.pos).
|
clazzid1 = make.at(tree.pos).
|
||||||
TypeApply(clazzid1,
|
TypeApply(clazzid1,
|
||||||
((JCTypeApply) clazz).arguments);
|
((JCTypeApply) clazz).arguments);
|
||||||
|
@ -1984,32 +1905,12 @@ public class Attr extends JCTree.Visitor {
|
||||||
clazz = clazzid1;
|
clazz = clazzid1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type clazztype;
|
|
||||||
|
|
||||||
try {
|
|
||||||
annotate.enterStart();
|
|
||||||
// Attribute clazz expression and store
|
// Attribute clazz expression and store
|
||||||
// symbol + type back into the attributed tree.
|
// symbol + type back into the attributed tree.
|
||||||
clazztype = TreeInfo.isEnumInit(env.tree) ?
|
Type clazztype = TreeInfo.isEnumInit(env.tree) ?
|
||||||
attribIdentAsEnumType(env, (JCIdent)clazz) :
|
attribIdentAsEnumType(env, (JCIdent)clazz) :
|
||||||
attribType(clazz, env);
|
attribType(clazz, env);
|
||||||
|
|
||||||
if (cdef != null) {
|
|
||||||
// If we are looking at an anonymous class creation, then
|
|
||||||
// we are not allowed to have declaration annotations on
|
|
||||||
// the base type.
|
|
||||||
annotate.annotateStrictTypeLater(clazz, cdef.mods.annotations, localEnv,
|
|
||||||
env.info.scope.owner, tree.pos(),
|
|
||||||
annotate.newObjCreator(tree.pos));
|
|
||||||
} else {
|
|
||||||
// Otherwise, we are.
|
|
||||||
annotate.annotateTypeLater(clazz, localEnv, env.info.scope.owner,
|
|
||||||
tree.pos(), annotate.newObjCreator(tree.pos));
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
annotate.enterDone();
|
|
||||||
}
|
|
||||||
|
|
||||||
clazztype = chk.checkDiamond(tree, clazztype);
|
clazztype = chk.checkDiamond(tree, clazztype);
|
||||||
chk.validate(clazz, localEnv);
|
chk.validate(clazz, localEnv);
|
||||||
if (tree.encl != null) {
|
if (tree.encl != null) {
|
||||||
|
@ -2038,29 +1939,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
ListBuffer<Type> argtypesBuf = new ListBuffer<>();
|
ListBuffer<Type> argtypesBuf = new ListBuffer<>();
|
||||||
int pkind = attribArgs(tree.args, localEnv, argtypesBuf);
|
int pkind = attribArgs(tree.args, localEnv, argtypesBuf);
|
||||||
List<Type> argtypes = argtypesBuf.toList();
|
List<Type> argtypes = argtypesBuf.toList();
|
||||||
List<Type> typeargtypes;
|
List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
|
||||||
|
|
||||||
// Attribute and annotate the type arguments
|
|
||||||
ListBuffer<Type> typeargtypesbuf = new ListBuffer<>();
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (List<JCExpression> l = tree.typeargs;
|
|
||||||
l.nonEmpty(); l = l.tail, i++) {
|
|
||||||
final JCExpression arg = l.head;
|
|
||||||
try {
|
|
||||||
annotate.enterStart();
|
|
||||||
typeargtypesbuf.append(attribType(arg, localEnv));
|
|
||||||
annotate.annotateTypeLater(arg, localEnv,
|
|
||||||
localEnv.info.scope.owner,
|
|
||||||
tree.pos(),
|
|
||||||
annotate.constructorInvokeTypeArgCreator(i, tree.pos));
|
|
||||||
} finally {
|
|
||||||
annotate.enterDone();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typeargtypes =
|
|
||||||
chk.checkRefTypes(tree.typeargs, typeargtypesbuf.toList());
|
|
||||||
|
|
||||||
// If we have made no mistakes in the class type...
|
// If we have made no mistakes in the class type...
|
||||||
if (clazztype.hasTag(CLASS)) {
|
if (clazztype.hasTag(CLASS)) {
|
||||||
|
@ -2242,9 +2121,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
ta.arguments = List.nil();
|
ta.arguments = List.nil();
|
||||||
ResultInfo findDiamondResult = new ResultInfo(VAL,
|
ResultInfo findDiamondResult = new ResultInfo(VAL,
|
||||||
resultInfo.checkContext.inferenceContext().free(resultInfo.pt) ? Type.noType : pt());
|
resultInfo.checkContext.inferenceContext().free(resultInfo.pt) ? Type.noType : pt());
|
||||||
Type inferred = deferredAttr.attribSpeculative(tree, env,
|
Type inferred = deferredAttr.attribSpeculative(tree, env, findDiamondResult).type;
|
||||||
findDiamondResult,
|
|
||||||
annotate.newObjCreator(tree.pos)).type;
|
|
||||||
Type polyPt = allowPoly ?
|
Type polyPt = allowPoly ?
|
||||||
syms.objectType :
|
syms.objectType :
|
||||||
clazztype;
|
clazztype;
|
||||||
|
@ -2306,20 +2183,8 @@ public class Attr extends JCTree.Visitor {
|
||||||
Type owntype = types.createErrorType(tree.type);
|
Type owntype = types.createErrorType(tree.type);
|
||||||
Env<AttrContext> localEnv = env.dup(tree);
|
Env<AttrContext> localEnv = env.dup(tree);
|
||||||
Type elemtype;
|
Type elemtype;
|
||||||
|
|
||||||
for(List<JCAnnotation> dim : tree.dimAnnotations) {
|
|
||||||
this.attribAnnotationTypes(dim, localEnv);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tree.elemtype != null) {
|
if (tree.elemtype != null) {
|
||||||
try {
|
|
||||||
annotate.enterStart();
|
|
||||||
elemtype = attribType(tree.elemtype, localEnv);
|
elemtype = attribType(tree.elemtype, localEnv);
|
||||||
annotate.annotateTypeLater(tree, env, env.info.scope.owner, tree.pos(),
|
|
||||||
annotate.newObjCreator(tree.pos));
|
|
||||||
} finally {
|
|
||||||
annotate.enterDone();
|
|
||||||
}
|
|
||||||
chk.validate(tree.elemtype, localEnv);
|
chk.validate(tree.elemtype, localEnv);
|
||||||
owntype = elemtype;
|
owntype = elemtype;
|
||||||
for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
|
for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
|
||||||
|
@ -2340,7 +2205,6 @@ public class Attr extends JCTree.Visitor {
|
||||||
elemtype = types.createErrorType(pt());
|
elemtype = types.createErrorType(pt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tree.elems != null) {
|
if (tree.elems != null) {
|
||||||
attribExprs(tree.elems, localEnv, elemtype);
|
attribExprs(tree.elems, localEnv, elemtype);
|
||||||
owntype = new ArrayType(elemtype, syms.arrayClass,
|
owntype = new ArrayType(elemtype, syms.arrayClass,
|
||||||
|
@ -2737,8 +2601,6 @@ public class Attr extends JCTree.Visitor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitReference(final JCMemberReference that) {
|
public void visitReference(final JCMemberReference that) {
|
||||||
final boolean isConstructor = that.getName() == names.init;
|
|
||||||
|
|
||||||
if (pt().isErroneous() || (pt().hasTag(NONE) && pt() != Type.recoveryType)) {
|
if (pt().isErroneous() || (pt().hasTag(NONE) && pt() != Type.recoveryType)) {
|
||||||
if (pt().hasTag(NONE)) {
|
if (pt().hasTag(NONE)) {
|
||||||
//method reference only allowed in assignment or method invocation/cast context
|
//method reference only allowed in assignment or method invocation/cast context
|
||||||
|
@ -2749,20 +2611,9 @@ public class Attr extends JCTree.Visitor {
|
||||||
}
|
}
|
||||||
final Env<AttrContext> localEnv = env.dup(that);
|
final Env<AttrContext> localEnv = env.dup(that);
|
||||||
try {
|
try {
|
||||||
Type exprType;
|
|
||||||
try {
|
|
||||||
annotate.enterStart();
|
|
||||||
//attribute member reference qualifier - if this is a constructor
|
//attribute member reference qualifier - if this is a constructor
|
||||||
//reference, the expected kind must be a type
|
//reference, the expected kind must be a type
|
||||||
exprType = attribTree(that.expr, env, memberReferenceQualifierResult(that));
|
Type exprType = attribTree(that.expr, env, memberReferenceQualifierResult(that));
|
||||||
final Annotate.PositionCreator creator =
|
|
||||||
isConstructor ? annotate.constructorRefCreator(that.pos) :
|
|
||||||
annotate.methodRefCreator(that.pos);
|
|
||||||
annotate.annotateTypeLater(that.expr, localEnv, env.info.scope.owner,
|
|
||||||
that.pos(), creator);
|
|
||||||
} finally {
|
|
||||||
annotate.enterDone();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (that.getMode() == JCMemberReference.ReferenceMode.NEW) {
|
if (that.getMode() == JCMemberReference.ReferenceMode.NEW) {
|
||||||
exprType = chk.checkConstructorRefType(that.expr, exprType);
|
exprType = chk.checkConstructorRefType(that.expr, exprType);
|
||||||
|
@ -2792,24 +2643,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
//attrib type-arguments
|
//attrib type-arguments
|
||||||
List<Type> typeargtypes = List.nil();
|
List<Type> typeargtypes = List.nil();
|
||||||
if (that.typeargs != null) {
|
if (that.typeargs != null) {
|
||||||
try {
|
|
||||||
annotate.enterStart();
|
|
||||||
typeargtypes = attribTypes(that.typeargs, localEnv);
|
typeargtypes = attribTypes(that.typeargs, localEnv);
|
||||||
|
|
||||||
// Annotate type arguments
|
|
||||||
int i = 0;
|
|
||||||
for (List<JCExpression> l = that.typeargs;
|
|
||||||
l.nonEmpty(); l = l.tail, i++) {
|
|
||||||
final Annotate.PositionCreator typeArgCreator =
|
|
||||||
isConstructor ? annotate.constructorRefTypeArgCreator(i, that.pos) :
|
|
||||||
annotate.methodRefTypeArgCreator(i, that.pos);
|
|
||||||
final JCExpression arg = l.head;
|
|
||||||
annotate.annotateTypeLater(arg, env, env.info.scope.owner,
|
|
||||||
that.pos(), typeArgCreator);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
annotate.enterDone();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Type desc;
|
Type desc;
|
||||||
|
@ -3192,15 +3026,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitTypeCast(final JCTypeCast tree) {
|
public void visitTypeCast(final JCTypeCast tree) {
|
||||||
Type clazztype;
|
Type clazztype = attribType(tree.clazz, env);
|
||||||
try {
|
|
||||||
annotate.enterStart();
|
|
||||||
clazztype = attribType(tree.clazz, env);
|
|
||||||
annotate.annotateTypeLater(tree.clazz, env, env.info.scope.owner,
|
|
||||||
tree.pos(), annotate.castCreator(tree.pos));
|
|
||||||
} finally {
|
|
||||||
annotate.enterDone();
|
|
||||||
}
|
|
||||||
chk.validate(tree.clazz, env, false);
|
chk.validate(tree.clazz, env, false);
|
||||||
//a fresh environment is required for 292 inference to work properly ---
|
//a fresh environment is required for 292 inference to work properly ---
|
||||||
//see Infer.instantiatePolymorphicSignatureInstance()
|
//see Infer.instantiatePolymorphicSignatureInstance()
|
||||||
|
@ -3233,16 +3059,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
public void visitTypeTest(JCInstanceOf tree) {
|
public void visitTypeTest(JCInstanceOf tree) {
|
||||||
Type exprtype = chk.checkNullOrRefType(
|
Type exprtype = chk.checkNullOrRefType(
|
||||||
tree.expr.pos(), attribExpr(tree.expr, env));
|
tree.expr.pos(), attribExpr(tree.expr, env));
|
||||||
Type clazztype;
|
Type clazztype = attribType(tree.clazz, env);
|
||||||
try {
|
|
||||||
annotate.enterStart();
|
|
||||||
clazztype = attribType(tree.clazz, env);
|
|
||||||
annotate.annotateTypeLater(tree.clazz, env, env.info.scope.owner, tree.pos(),
|
|
||||||
annotate.instanceOfCreator(tree.pos));
|
|
||||||
} finally {
|
|
||||||
annotate.enterDone();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!clazztype.hasTag(TYPEVAR)) {
|
if (!clazztype.hasTag(TYPEVAR)) {
|
||||||
clazztype = chk.checkClassOrArrayType(tree.clazz.pos(), clazztype);
|
clazztype = chk.checkClassOrArrayType(tree.clazz.pos(), clazztype);
|
||||||
}
|
}
|
||||||
|
@ -3371,12 +3188,9 @@ public class Attr extends JCTree.Visitor {
|
||||||
if ((pkind() & (PCK | TYP)) == 0)
|
if ((pkind() & (PCK | TYP)) == 0)
|
||||||
site = capture(site); // Capture field access
|
site = capture(site); // Capture field access
|
||||||
|
|
||||||
if (skind == TYP) {
|
|
||||||
// If the qualifier is a type, annotate it
|
|
||||||
annotate.annotateTypeLater(tree, env, env.info.scope.owner,
|
|
||||||
tree.pos(), annotate.errorCreator);
|
|
||||||
Type elt = site;
|
|
||||||
// don't allow T.class T[].class, etc
|
// don't allow T.class T[].class, etc
|
||||||
|
if (skind == TYP) {
|
||||||
|
Type elt = site;
|
||||||
while (elt.hasTag(ARRAY))
|
while (elt.hasTag(ARRAY))
|
||||||
elt = ((ArrayType)elt).elemtype;
|
elt = ((ArrayType)elt).elemtype;
|
||||||
if (elt.hasTag(TYPEVAR)) {
|
if (elt.hasTag(TYPEVAR)) {
|
||||||
|
@ -4224,13 +4038,8 @@ public class Attr extends JCTree.Visitor {
|
||||||
Assert.error("should be handled in Annotate");
|
Assert.error("should be handled in Annotate");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This needs to be removed or otherwise changed, as it implicitly
|
|
||||||
* relies on the annotated types having previously been visited by
|
|
||||||
* Annotate.TypeAnnotate.
|
|
||||||
*/
|
|
||||||
public void visitAnnotatedType(JCAnnotatedType tree) {
|
public void visitAnnotatedType(JCAnnotatedType tree) {
|
||||||
Type underlyingType = attribTree(tree.getUnderlyingType(), env,
|
Type underlyingType = attribType(tree.getUnderlyingType(), env);
|
||||||
resultInfo);
|
|
||||||
this.attribAnnotationTypes(tree.annotations, env);
|
this.attribAnnotationTypes(tree.annotations, env);
|
||||||
annotateType(tree, tree.annotations);
|
annotateType(tree, tree.annotations);
|
||||||
result = tree.type = underlyingType;
|
result = tree.type = underlyingType;
|
||||||
|
@ -4249,10 +4058,8 @@ public class Attr extends JCTree.Visitor {
|
||||||
public void run() {
|
public void run() {
|
||||||
List<Attribute.TypeCompound> compounds = fromAnnotations(annotations);
|
List<Attribute.TypeCompound> compounds = fromAnnotations(annotations);
|
||||||
Assert.check(annotations.size() == compounds.size());
|
Assert.check(annotations.size() == compounds.size());
|
||||||
if (!tree.type.hasTag(TypeTag.PACKAGE)) {
|
|
||||||
tree.type = tree.type.annotatedType(compounds);
|
tree.type = tree.type.annotatedType(compounds);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4503,6 +4310,13 @@ public class Attr extends JCTree.Visitor {
|
||||||
checkForSerial(c)) {
|
checkForSerial(c)) {
|
||||||
checkSerialVersionUID(tree, c);
|
checkSerialVersionUID(tree, c);
|
||||||
}
|
}
|
||||||
|
if (allowTypeAnnos) {
|
||||||
|
// Correctly organize the postions of the type annotations
|
||||||
|
typeAnnotations.organizeTypeAnnotationsBodies(tree);
|
||||||
|
|
||||||
|
// Check type annotations applicability rules
|
||||||
|
validateTypeAnnotations(tree, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// where
|
// where
|
||||||
boolean checkForSerial(ClassSymbol c) {
|
boolean checkForSerial(ClassSymbol c) {
|
||||||
|
@ -4581,6 +4395,233 @@ public class Attr extends JCTree.Visitor {
|
||||||
return types.capture(type);
|
return types.capture(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validateTypeAnnotations(JCTree tree, boolean sigOnly) {
|
||||||
|
tree.accept(new TypeAnnotationsValidator(sigOnly));
|
||||||
|
}
|
||||||
|
//where
|
||||||
|
private final class TypeAnnotationsValidator extends TreeScanner {
|
||||||
|
|
||||||
|
private final boolean sigOnly;
|
||||||
|
public TypeAnnotationsValidator(boolean sigOnly) {
|
||||||
|
this.sigOnly = sigOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void visitAnnotation(JCAnnotation tree) {
|
||||||
|
chk.validateTypeAnnotation(tree, false);
|
||||||
|
super.visitAnnotation(tree);
|
||||||
|
}
|
||||||
|
public void visitAnnotatedType(JCAnnotatedType tree) {
|
||||||
|
if (!tree.underlyingType.type.isErroneous()) {
|
||||||
|
super.visitAnnotatedType(tree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void visitTypeParameter(JCTypeParameter tree) {
|
||||||
|
chk.validateTypeAnnotations(tree.annotations, true);
|
||||||
|
scan(tree.bounds);
|
||||||
|
// Don't call super.
|
||||||
|
// This is needed because above we call validateTypeAnnotation with
|
||||||
|
// false, which would forbid annotations on type parameters.
|
||||||
|
// super.visitTypeParameter(tree);
|
||||||
|
}
|
||||||
|
public void visitMethodDef(JCMethodDecl tree) {
|
||||||
|
if (tree.recvparam != null &&
|
||||||
|
!tree.recvparam.vartype.type.isErroneous()) {
|
||||||
|
checkForDeclarationAnnotations(tree.recvparam.mods.annotations,
|
||||||
|
tree.recvparam.vartype.type.tsym);
|
||||||
|
}
|
||||||
|
if (tree.restype != null && tree.restype.type != null) {
|
||||||
|
validateAnnotatedType(tree.restype, tree.restype.type);
|
||||||
|
}
|
||||||
|
if (sigOnly) {
|
||||||
|
scan(tree.mods);
|
||||||
|
scan(tree.restype);
|
||||||
|
scan(tree.typarams);
|
||||||
|
scan(tree.recvparam);
|
||||||
|
scan(tree.params);
|
||||||
|
scan(tree.thrown);
|
||||||
|
} else {
|
||||||
|
scan(tree.defaultValue);
|
||||||
|
scan(tree.body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void visitVarDef(final JCVariableDecl tree) {
|
||||||
|
//System.err.println("validateTypeAnnotations.visitVarDef " + tree);
|
||||||
|
if (tree.sym != null && tree.sym.type != null)
|
||||||
|
validateAnnotatedType(tree.vartype, tree.sym.type);
|
||||||
|
scan(tree.mods);
|
||||||
|
scan(tree.vartype);
|
||||||
|
if (!sigOnly) {
|
||||||
|
scan(tree.init);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void visitTypeCast(JCTypeCast tree) {
|
||||||
|
if (tree.clazz != null && tree.clazz.type != null)
|
||||||
|
validateAnnotatedType(tree.clazz, tree.clazz.type);
|
||||||
|
super.visitTypeCast(tree);
|
||||||
|
}
|
||||||
|
public void visitTypeTest(JCInstanceOf tree) {
|
||||||
|
if (tree.clazz != null && tree.clazz.type != null)
|
||||||
|
validateAnnotatedType(tree.clazz, tree.clazz.type);
|
||||||
|
super.visitTypeTest(tree);
|
||||||
|
}
|
||||||
|
public void visitNewClass(JCNewClass tree) {
|
||||||
|
if (tree.clazz.hasTag(ANNOTATED_TYPE)) {
|
||||||
|
checkForDeclarationAnnotations(((JCAnnotatedType) tree.clazz).annotations,
|
||||||
|
tree.clazz.type.tsym);
|
||||||
|
}
|
||||||
|
if (tree.def != null) {
|
||||||
|
checkForDeclarationAnnotations(tree.def.mods.annotations, tree.clazz.type.tsym);
|
||||||
|
}
|
||||||
|
if (tree.clazz.type != null) {
|
||||||
|
validateAnnotatedType(tree.clazz, tree.clazz.type);
|
||||||
|
}
|
||||||
|
super.visitNewClass(tree);
|
||||||
|
}
|
||||||
|
public void visitNewArray(JCNewArray tree) {
|
||||||
|
if (tree.elemtype != null && tree.elemtype.type != null) {
|
||||||
|
if (tree.elemtype.hasTag(ANNOTATED_TYPE)) {
|
||||||
|
checkForDeclarationAnnotations(((JCAnnotatedType) tree.elemtype).annotations,
|
||||||
|
tree.elemtype.type.tsym);
|
||||||
|
}
|
||||||
|
validateAnnotatedType(tree.elemtype, tree.elemtype.type);
|
||||||
|
}
|
||||||
|
super.visitNewArray(tree);
|
||||||
|
}
|
||||||
|
public void visitClassDef(JCClassDecl tree) {
|
||||||
|
//System.err.println("validateTypeAnnotations.visitClassDef " + tree);
|
||||||
|
if (sigOnly) {
|
||||||
|
scan(tree.mods);
|
||||||
|
scan(tree.typarams);
|
||||||
|
scan(tree.extending);
|
||||||
|
scan(tree.implementing);
|
||||||
|
}
|
||||||
|
for (JCTree member : tree.defs) {
|
||||||
|
if (member.hasTag(Tag.CLASSDEF)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
scan(member);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void visitBlock(JCBlock tree) {
|
||||||
|
if (!sigOnly) {
|
||||||
|
scan(tree.stats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* I would want to model this after
|
||||||
|
* com.sun.tools.javac.comp.Check.Validator.visitSelectInternal(JCFieldAccess)
|
||||||
|
* and override visitSelect and visitTypeApply.
|
||||||
|
* However, we only set the annotated type in the top-level type
|
||||||
|
* of the symbol.
|
||||||
|
* Therefore, we need to override each individual location where a type
|
||||||
|
* can occur.
|
||||||
|
*/
|
||||||
|
private void validateAnnotatedType(final JCTree errtree, final Type type) {
|
||||||
|
//System.err.println("Attr.validateAnnotatedType: " + errtree + " type: " + type);
|
||||||
|
|
||||||
|
if (type.isPrimitiveOrVoid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JCTree enclTr = errtree;
|
||||||
|
Type enclTy = type;
|
||||||
|
|
||||||
|
boolean repeat = true;
|
||||||
|
while (repeat) {
|
||||||
|
if (enclTr.hasTag(TYPEAPPLY)) {
|
||||||
|
List<Type> tyargs = enclTy.getTypeArguments();
|
||||||
|
List<JCExpression> trargs = ((JCTypeApply)enclTr).getTypeArguments();
|
||||||
|
if (trargs.length() > 0) {
|
||||||
|
// Nothing to do for diamonds
|
||||||
|
if (tyargs.length() == trargs.length()) {
|
||||||
|
for (int i = 0; i < tyargs.length(); ++i) {
|
||||||
|
validateAnnotatedType(trargs.get(i), tyargs.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the lengths don't match, it's either a diamond
|
||||||
|
// or some nested type that redundantly provides
|
||||||
|
// type arguments in the tree.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look at the clazz part of a generic type
|
||||||
|
enclTr = ((JCTree.JCTypeApply)enclTr).clazz;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enclTr.hasTag(SELECT)) {
|
||||||
|
enclTr = ((JCTree.JCFieldAccess)enclTr).getExpression();
|
||||||
|
if (enclTy != null &&
|
||||||
|
!enclTy.hasTag(NONE)) {
|
||||||
|
enclTy = enclTy.getEnclosingType();
|
||||||
|
}
|
||||||
|
} else if (enclTr.hasTag(ANNOTATED_TYPE)) {
|
||||||
|
JCAnnotatedType at = (JCTree.JCAnnotatedType) enclTr;
|
||||||
|
if (enclTy == null || enclTy.hasTag(NONE)) {
|
||||||
|
if (at.getAnnotations().size() == 1) {
|
||||||
|
log.error(at.underlyingType.pos(), "cant.type.annotate.scoping.1", at.getAnnotations().head.attribute);
|
||||||
|
} else {
|
||||||
|
ListBuffer<Attribute.Compound> comps = new ListBuffer<>();
|
||||||
|
for (JCAnnotation an : at.getAnnotations()) {
|
||||||
|
comps.add(an.attribute);
|
||||||
|
}
|
||||||
|
log.error(at.underlyingType.pos(), "cant.type.annotate.scoping", comps.toList());
|
||||||
|
}
|
||||||
|
repeat = false;
|
||||||
|
}
|
||||||
|
enclTr = at.underlyingType;
|
||||||
|
// enclTy doesn't need to be changed
|
||||||
|
} else if (enclTr.hasTag(IDENT)) {
|
||||||
|
repeat = false;
|
||||||
|
} else if (enclTr.hasTag(JCTree.Tag.WILDCARD)) {
|
||||||
|
JCWildcard wc = (JCWildcard) enclTr;
|
||||||
|
if (wc.getKind() == JCTree.Kind.EXTENDS_WILDCARD) {
|
||||||
|
validateAnnotatedType(wc.getBound(), ((WildcardType)enclTy).getExtendsBound());
|
||||||
|
} else if (wc.getKind() == JCTree.Kind.SUPER_WILDCARD) {
|
||||||
|
validateAnnotatedType(wc.getBound(), ((WildcardType)enclTy).getSuperBound());
|
||||||
|
} else {
|
||||||
|
// Nothing to do for UNBOUND
|
||||||
|
}
|
||||||
|
repeat = false;
|
||||||
|
} else if (enclTr.hasTag(TYPEARRAY)) {
|
||||||
|
JCArrayTypeTree art = (JCArrayTypeTree) enclTr;
|
||||||
|
validateAnnotatedType(art.getType(), ((ArrayType)enclTy).getComponentType());
|
||||||
|
repeat = false;
|
||||||
|
} else if (enclTr.hasTag(TYPEUNION)) {
|
||||||
|
JCTypeUnion ut = (JCTypeUnion) enclTr;
|
||||||
|
for (JCTree t : ut.getTypeAlternatives()) {
|
||||||
|
validateAnnotatedType(t, t.type);
|
||||||
|
}
|
||||||
|
repeat = false;
|
||||||
|
} else if (enclTr.hasTag(TYPEINTERSECTION)) {
|
||||||
|
JCTypeIntersection it = (JCTypeIntersection) enclTr;
|
||||||
|
for (JCTree t : it.getBounds()) {
|
||||||
|
validateAnnotatedType(t, t.type);
|
||||||
|
}
|
||||||
|
repeat = false;
|
||||||
|
} else if (enclTr.getKind() == JCTree.Kind.PRIMITIVE_TYPE ||
|
||||||
|
enclTr.getKind() == JCTree.Kind.ERRONEOUS) {
|
||||||
|
repeat = false;
|
||||||
|
} else {
|
||||||
|
Assert.error("Unexpected tree: " + enclTr + " with kind: " + enclTr.getKind() +
|
||||||
|
" within: "+ errtree + " with kind: " + errtree.getKind());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkForDeclarationAnnotations(List<? extends JCAnnotation> annotations,
|
||||||
|
Symbol sym) {
|
||||||
|
// Ensure that no declaration annotations are present.
|
||||||
|
// Note that a tree type might be an AnnotatedType with
|
||||||
|
// empty annotations, if only declaration annotations were given.
|
||||||
|
// This method will raise an error for such a type.
|
||||||
|
for (JCAnnotation ai : annotations) {
|
||||||
|
if (!ai.type.isErroneous() &&
|
||||||
|
typeAnnotations.annotationType(ai.attribute, sym) == TypeAnnotations.AnnotationType.DECLARATION) {
|
||||||
|
log.error(ai.pos(), "annotation.type.not.applicable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// <editor-fold desc="post-attribution visitor">
|
// <editor-fold desc="post-attribution visitor">
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -59,11 +59,6 @@ public class AttrContext {
|
||||||
*/
|
*/
|
||||||
boolean isSerializable = false;
|
boolean isSerializable = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Are we doing speculative attribution?
|
|
||||||
*/
|
|
||||||
boolean isSpeculative = false;
|
|
||||||
|
|
||||||
/** Are arguments to current function applications boxed into an array for varargs?
|
/** Are arguments to current function applications boxed into an array for varargs?
|
||||||
*/
|
*/
|
||||||
Resolve.MethodResolutionPhase pendingResolutionPhase = null;
|
Resolve.MethodResolutionPhase pendingResolutionPhase = null;
|
||||||
|
@ -100,7 +95,6 @@ public class AttrContext {
|
||||||
info.returnResult = returnResult;
|
info.returnResult = returnResult;
|
||||||
info.defaultSuperCallSite = defaultSuperCallSite;
|
info.defaultSuperCallSite = defaultSuperCallSite;
|
||||||
info.isSerializable = isSerializable;
|
info.isSerializable = isSerializable;
|
||||||
info.isSpeculative = isSpeculative;
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
package com.sun.tools.javac.comp;
|
package com.sun.tools.javac.comp;
|
||||||
|
|
||||||
import com.sun.source.tree.*;
|
|
||||||
import com.sun.source.tree.LambdaExpressionTree.BodyKind;
|
import com.sun.source.tree.LambdaExpressionTree.BodyKind;
|
||||||
import com.sun.tools.javac.code.*;
|
import com.sun.tools.javac.code.*;
|
||||||
import com.sun.tools.javac.tree.*;
|
import com.sun.tools.javac.tree.*;
|
||||||
|
@ -78,7 +77,6 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||||
final Types types;
|
final Types types;
|
||||||
final Flow flow;
|
final Flow flow;
|
||||||
final Names names;
|
final Names names;
|
||||||
final Annotate annotate;
|
|
||||||
final TypeEnvs typeEnvs;
|
final TypeEnvs typeEnvs;
|
||||||
|
|
||||||
public static DeferredAttr instance(Context context) {
|
public static DeferredAttr instance(Context context) {
|
||||||
|
@ -103,7 +101,6 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||||
flow = Flow.instance(context);
|
flow = Flow.instance(context);
|
||||||
names = Names.instance(context);
|
names = Names.instance(context);
|
||||||
stuckTree = make.Ident(names.empty).setType(Type.stuckType);
|
stuckTree = make.Ident(names.empty).setType(Type.stuckType);
|
||||||
annotate = Annotate.instance(context);
|
|
||||||
typeEnvs = TypeEnvs.instance(context);
|
typeEnvs = TypeEnvs.instance(context);
|
||||||
emptyDeferredAttrContext =
|
emptyDeferredAttrContext =
|
||||||
new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) {
|
new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) {
|
||||||
|
@ -139,8 +136,7 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||||
AttrMode mode;
|
AttrMode mode;
|
||||||
SpeculativeCache speculativeCache;
|
SpeculativeCache speculativeCache;
|
||||||
|
|
||||||
DeferredType(JCExpression tree,
|
DeferredType(JCExpression tree, Env<AttrContext> env) {
|
||||||
Env<AttrContext> env) {
|
|
||||||
super(null, noAnnotations);
|
super(null, noAnnotations);
|
||||||
this.tree = tree;
|
this.tree = tree;
|
||||||
this.env = attr.copyEnv(env);
|
this.env = attr.copyEnv(env);
|
||||||
|
@ -284,18 +280,12 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||||
//Note: if a symbol is imported twice we might do two identical
|
//Note: if a symbol is imported twice we might do two identical
|
||||||
//speculative rounds...
|
//speculative rounds...
|
||||||
Assert.check(dt.mode == null || dt.mode == AttrMode.SPECULATIVE);
|
Assert.check(dt.mode == null || dt.mode == AttrMode.SPECULATIVE);
|
||||||
JCTree speculativeTree = attribSpeculative(dt.tree, dt.env,
|
JCTree speculativeTree = attribSpeculative(dt.tree, dt.env, resultInfo);
|
||||||
resultInfo,
|
|
||||||
annotate.noCreator);
|
|
||||||
dt.speculativeCache.put(speculativeTree, resultInfo);
|
dt.speculativeCache.put(speculativeTree, resultInfo);
|
||||||
return speculativeTree.type;
|
return speculativeTree.type;
|
||||||
case CHECK:
|
case CHECK:
|
||||||
Assert.check(dt.mode != null);
|
Assert.check(dt.mode != null);
|
||||||
final boolean oldSpeculative = dt.env.info.isSpeculative;
|
return attr.attribTree(dt.tree, dt.env, resultInfo);
|
||||||
dt.env.info.isSpeculative = false;
|
|
||||||
Type out = attr.attribTree(dt.tree, dt.env, resultInfo);
|
|
||||||
dt.env.info.isSpeculative = oldSpeculative;
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
Assert.error();
|
Assert.error();
|
||||||
return null;
|
return null;
|
||||||
|
@ -372,13 +362,9 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||||
* restored after type-checking. All diagnostics (but critical ones) are
|
* restored after type-checking. All diagnostics (but critical ones) are
|
||||||
* disabled during speculative type-checking.
|
* disabled during speculative type-checking.
|
||||||
*/
|
*/
|
||||||
JCTree attribSpeculative(JCTree tree,
|
JCTree attribSpeculative(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
|
||||||
Env<AttrContext> env,
|
|
||||||
ResultInfo resultInfo,
|
|
||||||
Annotate.PositionCreator creator) {
|
|
||||||
final JCTree newTree = new TreeCopier<>(make).copy(tree);
|
final JCTree newTree = new TreeCopier<>(make).copy(tree);
|
||||||
Env<AttrContext> speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared(env.info.scope.owner)));
|
Env<AttrContext> speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared(env.info.scope.owner)));
|
||||||
speculativeEnv.info.isSpeculative = true;
|
|
||||||
Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
|
Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
|
||||||
new Log.DeferredDiagnosticHandler(log, new Filter<JCDiagnostic>() {
|
new Log.DeferredDiagnosticHandler(log, new Filter<JCDiagnostic>() {
|
||||||
public boolean accepts(final JCDiagnostic d) {
|
public boolean accepts(final JCDiagnostic d) {
|
||||||
|
@ -401,9 +387,6 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
attr.attribTree(newTree, speculativeEnv, resultInfo);
|
attr.attribTree(newTree, speculativeEnv, resultInfo);
|
||||||
annotate.typeAnnotateExprLater(newTree, speculativeEnv,
|
|
||||||
speculativeEnv.info.scope.owner,
|
|
||||||
newTree.pos(), creator);
|
|
||||||
unenterScanner.scan(newTree);
|
unenterScanner.scan(newTree);
|
||||||
return newTree;
|
return newTree;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -771,11 +754,8 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||||
checkContext.report(null, ex.getDiagnostic());
|
checkContext.report(null, ex.getDiagnostic());
|
||||||
}
|
}
|
||||||
Env<AttrContext> localEnv = env.dup(tree);
|
Env<AttrContext> localEnv = env.dup(tree);
|
||||||
JCExpression exprTree =
|
JCExpression exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), localEnv,
|
||||||
(JCExpression)attribSpeculative(tree.getQualifierExpression(),
|
attr.memberReferenceQualifierResult(tree));
|
||||||
localEnv,
|
|
||||||
attr.memberReferenceQualifierResult(tree),
|
|
||||||
annotate.methodRefCreator(tree.pos));
|
|
||||||
ListBuffer<Type> argtypes = new ListBuffer<>();
|
ListBuffer<Type> argtypes = new ListBuffer<>();
|
||||||
for (Type t : types.findDescriptorType(pt).getParameterTypes()) {
|
for (Type t : types.findDescriptorType(pt).getParameterTypes()) {
|
||||||
argtypes.append(Type.noType);
|
argtypes.append(Type.noType);
|
||||||
|
@ -1197,11 +1177,8 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||||
public void visitReference(JCMemberReference tree) {
|
public void visitReference(JCMemberReference tree) {
|
||||||
//perform arity-based check
|
//perform arity-based check
|
||||||
Env<AttrContext> localEnv = env.dup(tree);
|
Env<AttrContext> localEnv = env.dup(tree);
|
||||||
JCExpression exprTree =
|
JCExpression exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), localEnv,
|
||||||
(JCExpression)attribSpeculative(tree.getQualifierExpression(),
|
attr.memberReferenceQualifierResult(tree));
|
||||||
localEnv,
|
|
||||||
attr.memberReferenceQualifierResult(tree),
|
|
||||||
annotate.methodRefCreator(tree.pos));
|
|
||||||
JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree);
|
JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree);
|
||||||
mref2.expr = exprTree;
|
mref2.expr = exprTree;
|
||||||
Symbol res =
|
Symbol res =
|
||||||
|
@ -1345,7 +1322,7 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||||
return null;
|
return null;
|
||||||
site = resolvedReturnType.type;
|
site = resolvedReturnType.type;
|
||||||
} else {
|
} else {
|
||||||
site = attribSpeculative(rec, env, attr.unknownTypeExprInfo, annotate.noCreator).type;
|
site = attribSpeculative(rec, env, attr.unknownTypeExprInfo).type;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
site = env.enclClass.sym.type;
|
site = env.enclClass.sym.type;
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
package com.sun.tools.javac.comp;
|
package com.sun.tools.javac.comp;
|
||||||
|
|
||||||
import com.sun.tools.javac.tree.*;
|
import com.sun.tools.javac.tree.*;
|
||||||
import com.sun.tools.javac.tree.JCTree.JCLambda;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
@ -157,10 +156,4 @@ public class Env<A> implements Iterable<Env<A>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public JCLambda getLambda() {
|
|
||||||
Env<A> out = enclosing(JCTree.Tag.LAMBDA);
|
|
||||||
|
|
||||||
return out != null ? (JCLambda) out.tree : null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ import com.sun.tools.javac.util.DefinedBy.Api;
|
||||||
|
|
||||||
import com.sun.tools.javac.code.Symbol.*;
|
import com.sun.tools.javac.code.Symbol.*;
|
||||||
import com.sun.tools.javac.code.Type.*;
|
import com.sun.tools.javac.code.Type.*;
|
||||||
import com.sun.tools.javac.code.TypeAnnotationPosition.*;
|
|
||||||
import com.sun.tools.javac.tree.JCTree.*;
|
import com.sun.tools.javac.tree.JCTree.*;
|
||||||
|
|
||||||
import static com.sun.tools.javac.code.Flags.*;
|
import static com.sun.tools.javac.code.Flags.*;
|
||||||
|
@ -85,6 +84,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
private final TreeMaker make;
|
private final TreeMaker make;
|
||||||
private final Todo todo;
|
private final Todo todo;
|
||||||
private final Annotate annotate;
|
private final Annotate annotate;
|
||||||
|
private final TypeAnnotations typeAnnotations;
|
||||||
private final Types types;
|
private final Types types;
|
||||||
private final JCDiagnostic.Factory diags;
|
private final JCDiagnostic.Factory diags;
|
||||||
private final Source source;
|
private final Source source;
|
||||||
|
@ -112,6 +112,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
make = TreeMaker.instance(context);
|
make = TreeMaker.instance(context);
|
||||||
todo = Todo.instance(context);
|
todo = Todo.instance(context);
|
||||||
annotate = Annotate.instance(context);
|
annotate = Annotate.instance(context);
|
||||||
|
typeAnnotations = TypeAnnotations.instance(context);
|
||||||
types = Types.instance(context);
|
types = Types.instance(context);
|
||||||
diags = JCDiagnostic.Factory.instance(context);
|
diags = JCDiagnostic.Factory.instance(context);
|
||||||
source = Source.instance(context);
|
source = Source.instance(context);
|
||||||
|
@ -143,13 +144,6 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
*/
|
*/
|
||||||
boolean completionEnabled = true;
|
boolean completionEnabled = true;
|
||||||
|
|
||||||
/** The creator that will be used for any varDef's we visit. This
|
|
||||||
* is used to create the position for any type annotations (or
|
|
||||||
* annotations that potentially are type annotations) that we
|
|
||||||
* encounter.
|
|
||||||
*/
|
|
||||||
Annotate.PositionCreator creator;
|
|
||||||
|
|
||||||
/* ---------- Processing import clauses ----------------
|
/* ---------- Processing import clauses ----------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -278,7 +272,6 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Construct method type from method signature.
|
/** Construct method type from method signature.
|
||||||
* @param msym The MethodSymbol for the method.
|
|
||||||
* @param typarams The method's type parameters.
|
* @param typarams The method's type parameters.
|
||||||
* @param params The method's value parameters.
|
* @param params The method's value parameters.
|
||||||
* @param res The method's result type,
|
* @param res The method's result type,
|
||||||
|
@ -287,89 +280,33 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
* null if none given; TODO: or already set here?
|
* null if none given; TODO: or already set here?
|
||||||
* @param thrown The method's thrown exceptions.
|
* @param thrown The method's thrown exceptions.
|
||||||
* @param env The method's (local) environment.
|
* @param env The method's (local) environment.
|
||||||
* @param declAnnos The annotations on the method declaration,
|
|
||||||
* some of which may be type annotations on
|
|
||||||
* the return type.
|
|
||||||
* @param deferPos The deferred diagnostic position for error
|
|
||||||
* reporting.
|
|
||||||
*/
|
*/
|
||||||
Type signature(final MethodSymbol msym,
|
Type signature(MethodSymbol msym,
|
||||||
final List<JCTypeParameter> typarams,
|
List<JCTypeParameter> typarams,
|
||||||
final List<JCVariableDecl> params,
|
List<JCVariableDecl> params,
|
||||||
final JCTree res,
|
JCTree res,
|
||||||
final JCVariableDecl recvparam,
|
JCVariableDecl recvparam,
|
||||||
final List<JCExpression> thrown,
|
List<JCExpression> thrown,
|
||||||
final Env<AttrContext> env,
|
Env<AttrContext> env) {
|
||||||
final List<JCAnnotation> declAnnos,
|
|
||||||
final DiagnosticPosition deferPos) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// Enter and attribute type parameters.
|
// Enter and attribute type parameters.
|
||||||
List<Type> tvars = enter.classEnter(typarams, env);
|
List<Type> tvars = enter.classEnter(typarams, env);
|
||||||
attr.attribTypeVariables(typarams, env);
|
attr.attribTypeVariables(typarams, env);
|
||||||
|
|
||||||
// Handle type annotations on type parameters.
|
// Enter and attribute value parameters.
|
||||||
i = 0;
|
|
||||||
for (List<JCTypeParameter> l = typarams; l.nonEmpty();
|
|
||||||
l = l.tail, i++) {
|
|
||||||
final JCTypeParameter param = l.head;
|
|
||||||
annotate.annotateTypeLater(param, env, msym, deferPos,
|
|
||||||
annotate.methodTypeParamCreator(i));
|
|
||||||
// ...and bounds on type parameters.
|
|
||||||
int j = 0;
|
|
||||||
for (List<JCExpression> bounds = param.bounds;
|
|
||||||
bounds.nonEmpty(); bounds = bounds.tail, j++) {
|
|
||||||
annotate.annotateTypeLater(bounds.head, env, msym, deferPos,
|
|
||||||
annotate.methodTypeParamBoundCreator(param, i, j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enter and attribute value parameters. Type annotations get
|
|
||||||
// METHOD_FORMAL_PARAMETER positions.
|
|
||||||
ListBuffer<Type> argbuf = new ListBuffer<>();
|
ListBuffer<Type> argbuf = new ListBuffer<>();
|
||||||
i = 0;
|
for (List<JCVariableDecl> l = params; l.nonEmpty(); l = l.tail) {
|
||||||
for (List<JCVariableDecl> l = params; l.nonEmpty(); l = l.tail, i++) {
|
memberEnter(l.head, env);
|
||||||
// The types will get annotated by visitVarDef
|
|
||||||
memberEnter(l.head, env, annotate.paramCreator(i));
|
|
||||||
argbuf.append(l.head.vartype.type);
|
argbuf.append(l.head.vartype.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attribute result type, if one is given.
|
// Attribute result type, if one is given.
|
||||||
Type restype;
|
Type restype = res == null ? syms.voidType : attr.attribType(res, env);
|
||||||
|
|
||||||
if (res != null) {
|
|
||||||
// If we have any declaration annotations, they might
|
|
||||||
// be/also be type annotations on the return type. We
|
|
||||||
// pass them in, so they get classified and then attached
|
|
||||||
// to the method, or the return type, or both.
|
|
||||||
restype = attr.attribType(res, env);
|
|
||||||
annotate.annotateTypeLater(res, declAnnos, env, msym, deferPos,
|
|
||||||
annotate.returnCreator);
|
|
||||||
} else {
|
|
||||||
// For constructors, we don't actually have a type, so we
|
|
||||||
// can't have a type path (except for INNER_TYPE), and we
|
|
||||||
// don't have annotations on arrays, type arguments, and
|
|
||||||
// the like.
|
|
||||||
|
|
||||||
// The only type path we have is if we are in an inner type.
|
|
||||||
List<TypePathEntry> typepath = Annotate.makeInners(msym.owner.type);
|
|
||||||
TypeAnnotationPosition tapos =
|
|
||||||
TypeAnnotationPosition.methodReturn(typepath, env.getLambda(), -1);
|
|
||||||
|
|
||||||
// We don't have to walk down a type. We just have to do
|
|
||||||
// repeating annotation handling, then classify and attach
|
|
||||||
// the annotations.
|
|
||||||
annotate.annotateWithClassifyLater(declAnnos, env, msym,
|
|
||||||
deferPos, tapos);
|
|
||||||
restype = syms.voidType;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Attribute receiver type, if one is given.
|
// Attribute receiver type, if one is given.
|
||||||
Type recvtype;
|
Type recvtype;
|
||||||
if (recvparam!=null) {
|
if (recvparam!=null) {
|
||||||
// The type will get annotated by visitVarDef
|
memberEnter(recvparam, env);
|
||||||
memberEnter(recvparam, env, annotate.receiverCreator);
|
|
||||||
recvtype = recvparam.vartype.type;
|
recvtype = recvparam.vartype.type;
|
||||||
} else {
|
} else {
|
||||||
recvtype = null;
|
recvtype = null;
|
||||||
|
@ -377,12 +314,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
|
|
||||||
// Attribute thrown exceptions.
|
// Attribute thrown exceptions.
|
||||||
ListBuffer<Type> thrownbuf = new ListBuffer<>();
|
ListBuffer<Type> thrownbuf = new ListBuffer<>();
|
||||||
i = 0;
|
for (List<JCExpression> l = thrown; l.nonEmpty(); l = l.tail) {
|
||||||
for (List<JCExpression> l = thrown; l.nonEmpty(); l = l.tail, i++) {
|
|
||||||
Type exc = attr.attribType(l.head, env);
|
Type exc = attr.attribType(l.head, env);
|
||||||
// Annotate each exception type.
|
|
||||||
annotate.annotateTypeLater(l.head, env, msym, deferPos,
|
|
||||||
annotate.throwCreator(i));
|
|
||||||
if (!exc.hasTag(TYPEVAR)) {
|
if (!exc.hasTag(TYPEVAR)) {
|
||||||
exc = chk.checkClassType(l.head.pos(), exc);
|
exc = chk.checkClassType(l.head.pos(), exc);
|
||||||
} else if (exc.tsym.owner == msym) {
|
} else if (exc.tsym.owner == msym) {
|
||||||
|
@ -437,49 +370,33 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
/** Enter field and method definitions and process import
|
/** Enter field and method definitions and process import
|
||||||
* clauses, catching any completion failure exceptions.
|
* clauses, catching any completion failure exceptions.
|
||||||
*/
|
*/
|
||||||
protected void memberEnter(JCTree tree, Env<AttrContext> env,
|
protected void memberEnter(JCTree tree, Env<AttrContext> env) {
|
||||||
Annotate.PositionCreator creator) {
|
|
||||||
Env<AttrContext> prevEnv = this.env;
|
Env<AttrContext> prevEnv = this.env;
|
||||||
Annotate.PositionCreator prevCreator = this.creator;
|
|
||||||
try {
|
try {
|
||||||
this.env = env;
|
this.env = env;
|
||||||
this.creator = creator;
|
|
||||||
tree.accept(this);
|
tree.accept(this);
|
||||||
} catch (CompletionFailure ex) {
|
} catch (CompletionFailure ex) {
|
||||||
chk.completionError(tree.pos(), ex);
|
chk.completionError(tree.pos(), ex);
|
||||||
} finally {
|
} finally {
|
||||||
this.creator = prevCreator;
|
|
||||||
this.env = prevEnv;
|
this.env = prevEnv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void memberEnter(JCTree tree, Env<AttrContext> env) {
|
|
||||||
memberEnter(tree, env, annotate.noCreator);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Enter members from a list of trees.
|
/** Enter members from a list of trees.
|
||||||
*/
|
*/
|
||||||
void memberEnter(List<? extends JCTree> trees,
|
void memberEnter(List<? extends JCTree> trees, Env<AttrContext> env) {
|
||||||
Env<AttrContext> env,
|
|
||||||
Annotate.PositionCreator creator) {
|
|
||||||
for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail)
|
for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail)
|
||||||
memberEnter(l.head, env, creator);
|
memberEnter(l.head, env);
|
||||||
}
|
|
||||||
|
|
||||||
void memberEnter(List<? extends JCTree> trees,
|
|
||||||
Env<AttrContext> env) {
|
|
||||||
memberEnter(trees, env, annotate.noCreator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Enter members for a class.
|
/** Enter members for a class.
|
||||||
*/
|
*/
|
||||||
void finishClass(final JCClassDecl tree, final Env<AttrContext> env) {
|
void finishClass(JCClassDecl tree, Env<AttrContext> env) {
|
||||||
if ((tree.mods.flags & Flags.ENUM) != 0 &&
|
if ((tree.mods.flags & Flags.ENUM) != 0 &&
|
||||||
(types.supertype(tree.sym.type).tsym.flags() & Flags.ENUM) == 0) {
|
(types.supertype(tree.sym.type).tsym.flags() & Flags.ENUM) == 0) {
|
||||||
addEnumMembers(tree, env);
|
addEnumMembers(tree, env);
|
||||||
}
|
}
|
||||||
memberEnter(tree.defs, env, annotate.fieldCreator);
|
memberEnter(tree.defs, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add the implicit members for an enum type
|
/** Add the implicit members for an enum type
|
||||||
|
@ -554,7 +471,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// process package annotations
|
// process package annotations
|
||||||
annotate.annotateLater(tree.annotations, env, env.toplevel.packge);
|
annotate.annotateLater(tree.annotations, env, env.toplevel.packge, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// process the non-static imports and the static imports of types.
|
// process the non-static imports and the static imports of types.
|
||||||
|
@ -602,13 +519,15 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
|
|
||||||
Env<AttrContext> localEnv = methodEnv(tree, env);
|
Env<AttrContext> localEnv = methodEnv(tree, env);
|
||||||
|
|
||||||
|
annotate.enterStart();
|
||||||
|
try {
|
||||||
DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
|
DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
|
||||||
try {
|
try {
|
||||||
// Compute the method type
|
// Compute the method type
|
||||||
m.type = signature(m, tree.typarams, tree.params,
|
m.type = signature(m, tree.typarams, tree.params,
|
||||||
tree.restype, tree.recvparam,
|
tree.restype, tree.recvparam,
|
||||||
tree.thrown, localEnv,
|
tree.thrown,
|
||||||
tree.mods.annotations, tree.pos());
|
localEnv);
|
||||||
} finally {
|
} finally {
|
||||||
deferredLintHandler.setPos(prevLintPos);
|
deferredLintHandler.setPos(prevLintPos);
|
||||||
}
|
}
|
||||||
|
@ -635,9 +554,16 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
enclScope.enter(m);
|
enclScope.enter(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
annotate.annotateLater(tree.mods.annotations, localEnv, m, tree.pos());
|
||||||
|
// Visit the signature of the method. Note that
|
||||||
|
// TypeAnnotate doesn't descend into the body.
|
||||||
|
annotate.annotateTypeLater(tree, localEnv, m, tree.pos());
|
||||||
|
|
||||||
if (tree.defaultValue != null)
|
if (tree.defaultValue != null)
|
||||||
annotateDefaultValueLater(tree.defaultValue, localEnv,
|
annotateDefaultValueLater(tree.defaultValue, localEnv, m);
|
||||||
m, annotate.noCreator);
|
} finally {
|
||||||
|
annotate.enterDone();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a fresh environment for method bodies.
|
/** Create a fresh environment for method bodies.
|
||||||
|
@ -706,18 +632,10 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
chk.checkTransparentVar(tree.pos(), v, enclScope);
|
chk.checkTransparentVar(tree.pos(), v, enclScope);
|
||||||
enclScope.enter(v);
|
enclScope.enter(v);
|
||||||
}
|
}
|
||||||
if (TreeInfo.isReceiverParam(tree)) {
|
|
||||||
// If we are dealing with a receiver parameter, then
|
annotate.annotateLater(tree.mods.annotations, localEnv, v, tree.pos());
|
||||||
// we only allow base type annotations to be type
|
annotate.annotateTypeLater(tree.vartype, localEnv, v, tree.pos());
|
||||||
// annotations. Receivers are not allowed to have
|
|
||||||
// declaration annotations.
|
|
||||||
annotate.annotateStrictTypeLater(tree.vartype, tree.mods.annotations,
|
|
||||||
localEnv, v, tree.pos(), creator);
|
|
||||||
} else {
|
|
||||||
// Otherwise, we annotate the type.
|
|
||||||
annotate.annotateTypeLater(tree.vartype, tree.mods.annotations,
|
|
||||||
localEnv, v, tree.pos(), creator);
|
|
||||||
}
|
|
||||||
v.pos = tree.pos;
|
v.pos = tree.pos;
|
||||||
} finally {
|
} finally {
|
||||||
annotate.enterDone();
|
annotate.enterDone();
|
||||||
|
@ -889,8 +807,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
/** Queue processing of an attribute default value. */
|
/** Queue processing of an attribute default value. */
|
||||||
void annotateDefaultValueLater(final JCExpression defaultValue,
|
void annotateDefaultValueLater(final JCExpression defaultValue,
|
||||||
final Env<AttrContext> localEnv,
|
final Env<AttrContext> localEnv,
|
||||||
final MethodSymbol m,
|
final MethodSymbol m) {
|
||||||
final Annotate.PositionCreator creator) {
|
|
||||||
annotate.normal(new Annotate.Worker() {
|
annotate.normal(new Annotate.Worker() {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -979,38 +896,19 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
// create an environment for evaluating the base clauses
|
// create an environment for evaluating the base clauses
|
||||||
Env<AttrContext> baseEnv = baseEnv(tree, env);
|
Env<AttrContext> baseEnv = baseEnv(tree, env);
|
||||||
|
|
||||||
// Annotations.
|
if (tree.extending != null)
|
||||||
// In general, we cannot fully process annotations yet, but we
|
annotate.annotateTypeLater(tree.extending, baseEnv, sym, tree.pos());
|
||||||
// can attribute the annotation types and then check to see if the
|
for (JCExpression impl : tree.implementing)
|
||||||
// @Deprecated annotation is present.
|
annotate.annotateTypeLater(impl, baseEnv, sym, tree.pos());
|
||||||
attr.attribAnnotationTypes(tree.mods.annotations, baseEnv);
|
annotate.flush();
|
||||||
if (hasDeprecatedAnnotation(tree.mods.annotations))
|
|
||||||
c.flags_field |= DEPRECATED;
|
|
||||||
|
|
||||||
// Don't attach declaration annotations to anonymous
|
|
||||||
// classes, they get handled specially below.
|
|
||||||
if (!sym.isAnonymous()) {
|
|
||||||
annotate.annotateLater(tree.mods.annotations, baseEnv,
|
|
||||||
c, tree.pos());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine supertype.
|
// Determine supertype.
|
||||||
Type supertype;
|
Type supertype;
|
||||||
|
|
||||||
if (tree.extending != null) {
|
if (tree.extending != null) {
|
||||||
dependencies.push(AttributionKind.EXTENDS, tree.extending);
|
dependencies.push(AttributionKind.EXTENDS, tree.extending);
|
||||||
try {
|
try {
|
||||||
supertype = attr.attribBase(tree.extending, baseEnv,
|
supertype = attr.attribBase(tree.extending, baseEnv,
|
||||||
true, false, true);
|
true, false, true);
|
||||||
if (sym.isAnonymous()) {
|
|
||||||
annotate.annotateAnonClassDefLater(tree.extending,
|
|
||||||
tree.mods.annotations,
|
|
||||||
baseEnv, sym, tree.pos(),
|
|
||||||
annotate.extendsCreator);
|
|
||||||
} else {
|
|
||||||
annotate.annotateTypeLater(tree.extending, baseEnv, sym,
|
|
||||||
tree.pos(), annotate.extendsCreator);
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
dependencies.pop();
|
dependencies.pop();
|
||||||
}
|
}
|
||||||
|
@ -1029,7 +927,6 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
ListBuffer<Type> all_interfaces = null; // lazy init
|
ListBuffer<Type> all_interfaces = null; // lazy init
|
||||||
Set<Type> interfaceSet = new HashSet<>();
|
Set<Type> interfaceSet = new HashSet<>();
|
||||||
List<JCExpression> interfaceTrees = tree.implementing;
|
List<JCExpression> interfaceTrees = tree.implementing;
|
||||||
int i = 0;
|
|
||||||
for (JCExpression iface : interfaceTrees) {
|
for (JCExpression iface : interfaceTrees) {
|
||||||
dependencies.push(AttributionKind.IMPLEMENTS, iface);
|
dependencies.push(AttributionKind.IMPLEMENTS, iface);
|
||||||
try {
|
try {
|
||||||
|
@ -1042,19 +939,6 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
if (all_interfaces == null)
|
if (all_interfaces == null)
|
||||||
all_interfaces = new ListBuffer<Type>().appendList(interfaces);
|
all_interfaces = new ListBuffer<Type>().appendList(interfaces);
|
||||||
all_interfaces.append(modelMissingTypes(it, iface, true));
|
all_interfaces.append(modelMissingTypes(it, iface, true));
|
||||||
|
|
||||||
}
|
|
||||||
if (sym.isAnonymous()) {
|
|
||||||
// Note: if an anonymous class ever has more than
|
|
||||||
// one supertype for some reason, this will
|
|
||||||
// incorrectly attach tree.mods.annotations to ALL
|
|
||||||
// supertypes, not just the first.
|
|
||||||
annotate.annotateAnonClassDefLater(iface, tree.mods.annotations,
|
|
||||||
baseEnv, sym, tree.pos(),
|
|
||||||
annotate.implementsCreator(i++));
|
|
||||||
} else {
|
|
||||||
annotate.annotateTypeLater(iface, baseEnv, sym, tree.pos(),
|
|
||||||
annotate.implementsCreator(i++));
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
dependencies.pop();
|
dependencies.pop();
|
||||||
|
@ -1083,28 +967,22 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// class type parameters use baseEnv but everything uses env
|
// Annotations.
|
||||||
|
// In general, we cannot fully process annotations yet, but we
|
||||||
|
// can attribute the annotation types and then check to see if the
|
||||||
|
// @Deprecated annotation is present.
|
||||||
|
attr.attribAnnotationTypes(tree.mods.annotations, baseEnv);
|
||||||
|
if (hasDeprecatedAnnotation(tree.mods.annotations))
|
||||||
|
c.flags_field |= DEPRECATED;
|
||||||
|
annotate.annotateLater(tree.mods.annotations, baseEnv,
|
||||||
|
c, tree.pos());
|
||||||
|
|
||||||
chk.checkNonCyclicDecl(tree);
|
chk.checkNonCyclicDecl(tree);
|
||||||
|
|
||||||
|
// class type parameters use baseEnv but everything uses env
|
||||||
attr.attribTypeVariables(tree.typarams, baseEnv);
|
attr.attribTypeVariables(tree.typarams, baseEnv);
|
||||||
// Do this here, where we have the symbol.
|
for (JCTypeParameter tp : tree.typarams)
|
||||||
int j = 0;
|
annotate.annotateTypeLater(tp, baseEnv, sym, tree.pos());
|
||||||
for (List<JCTypeParameter> l = tree.typarams; l.nonEmpty();
|
|
||||||
l = l.tail, j++) {
|
|
||||||
final JCTypeParameter typaram = l.head;
|
|
||||||
annotate.annotateTypeLater(typaram, baseEnv, sym, tree.pos(),
|
|
||||||
annotate.typeParamCreator(j));
|
|
||||||
|
|
||||||
int k = 0;
|
|
||||||
for(List<JCExpression> b = typaram.bounds; b.nonEmpty();
|
|
||||||
b = b.tail, k++) {
|
|
||||||
final JCExpression bound = b.head;
|
|
||||||
annotate.annotateTypeLater(bound, baseEnv, sym, tree.pos(),
|
|
||||||
annotate.typeParamBoundCreator(typaram, j, k));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add default constructor if needed.
|
// Add default constructor if needed.
|
||||||
if ((c.flags() & INTERFACE) == 0 &&
|
if ((c.flags() & INTERFACE) == 0 &&
|
||||||
|
@ -1187,6 +1065,10 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||||
Env<AttrContext> toFinish = halfcompleted.next();
|
Env<AttrContext> toFinish = halfcompleted.next();
|
||||||
topLevels.add(toFinish.toplevel);
|
topLevels.add(toFinish.toplevel);
|
||||||
finish(toFinish);
|
finish(toFinish);
|
||||||
|
if (allowTypeAnnos) {
|
||||||
|
typeAnnotations.organizeTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree);
|
||||||
|
typeAnnotations.validateTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
isFirst = true;
|
isFirst = true;
|
||||||
|
|
|
@ -1588,6 +1588,8 @@ public class ClassReader {
|
||||||
return TypeAnnotationPosition.methodReturn(readTypePath());
|
return TypeAnnotationPosition.methodReturn(readTypePath());
|
||||||
case FIELD:
|
case FIELD:
|
||||||
return TypeAnnotationPosition.field(readTypePath());
|
return TypeAnnotationPosition.field(readTypePath());
|
||||||
|
case UNKNOWN:
|
||||||
|
throw new AssertionError("jvm.ClassReader: UNKNOWN target type should never occur!");
|
||||||
default:
|
default:
|
||||||
throw new AssertionError("jvm.ClassReader: Unknown target type for position: " + type);
|
throw new AssertionError("jvm.ClassReader: Unknown target type for position: " + type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -740,13 +740,25 @@ public class ClassWriter extends ClassFile {
|
||||||
ListBuffer<Attribute.TypeCompound> invisibles = new ListBuffer<>();
|
ListBuffer<Attribute.TypeCompound> invisibles = new ListBuffer<>();
|
||||||
|
|
||||||
for (Attribute.TypeCompound tc : typeAnnos) {
|
for (Attribute.TypeCompound tc : typeAnnos) {
|
||||||
Assert.checkNonNull(tc.position);
|
if (tc.hasUnknownPosition()) {
|
||||||
if (tc.position.type.isLocal() != inCode) {
|
boolean fixed = tc.tryFixPosition();
|
||||||
|
|
||||||
|
// Could we fix it?
|
||||||
|
if (!fixed) {
|
||||||
|
// This happens for nested types like @A Outer. @B Inner.
|
||||||
|
// For method parameters we get the annotation twice! Once with
|
||||||
|
// a valid position, once unknown.
|
||||||
|
// TODO: find a cleaner solution.
|
||||||
|
PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
|
||||||
|
pw.println("ClassWriter: Position UNKNOWN in type annotation: " + tc);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!tc.position.emitToClassfile()) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tc.position.type.isLocal() != inCode)
|
||||||
|
continue;
|
||||||
|
if (!tc.position.emitToClassfile())
|
||||||
|
continue;
|
||||||
switch (types.getRetention(tc)) {
|
switch (types.getRetention(tc)) {
|
||||||
case SOURCE: break;
|
case SOURCE: break;
|
||||||
case CLASS: invisibles.append(tc); break;
|
case CLASS: invisibles.append(tc); break;
|
||||||
|
@ -927,6 +939,8 @@ public class ClassWriter extends ClassFile {
|
||||||
case METHOD_RETURN:
|
case METHOD_RETURN:
|
||||||
case FIELD:
|
case FIELD:
|
||||||
break;
|
break;
|
||||||
|
case UNKNOWN:
|
||||||
|
throw new AssertionError("jvm.ClassWriter: UNKNOWN target type should never occur!");
|
||||||
default:
|
default:
|
||||||
throw new AssertionError("jvm.ClassWriter: Unknown target type for position: " + p);
|
throw new AssertionError("jvm.ClassWriter: Unknown target type for position: " + p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,6 +519,7 @@ public class Gen extends JCTree.Visitor {
|
||||||
ListBuffer<Attribute.TypeCompound> fieldTAs = new ListBuffer<>();
|
ListBuffer<Attribute.TypeCompound> fieldTAs = new ListBuffer<>();
|
||||||
ListBuffer<Attribute.TypeCompound> nonfieldTAs = new ListBuffer<>();
|
ListBuffer<Attribute.TypeCompound> nonfieldTAs = new ListBuffer<>();
|
||||||
for (TypeCompound ta : tas) {
|
for (TypeCompound ta : tas) {
|
||||||
|
Assert.check(ta.getPosition().type != TargetType.UNKNOWN);
|
||||||
if (ta.getPosition().type == TargetType.FIELD) {
|
if (ta.getPosition().type == TargetType.FIELD) {
|
||||||
fieldTAs.add(ta);
|
fieldTAs.add(ta);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1818,7 +1819,10 @@ public class Gen extends JCTree.Visitor {
|
||||||
|| code.meth.getKind() == javax.lang.model.element.ElementKind.STATIC_INIT;
|
|| code.meth.getKind() == javax.lang.model.element.ElementKind.STATIC_INIT;
|
||||||
|
|
||||||
for (Attribute.TypeCompound ta : meth.getRawTypeAttributes()) {
|
for (Attribute.TypeCompound ta : meth.getRawTypeAttributes()) {
|
||||||
if (ta.position != null && ta.position.matchesPos(treePos))
|
if (ta.hasUnknownPosition())
|
||||||
|
ta.tryFixPosition();
|
||||||
|
|
||||||
|
if (ta.position.matchesPos(treePos))
|
||||||
ta.position.updatePosOffset(code.cp);
|
ta.position.updatePosOffset(code.cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1826,7 +1830,10 @@ public class Gen extends JCTree.Visitor {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Attribute.TypeCompound ta : meth.owner.getRawTypeAttributes()) {
|
for (Attribute.TypeCompound ta : meth.owner.getRawTypeAttributes()) {
|
||||||
if (ta.position != null && ta.position.matchesPos(treePos))
|
if (ta.hasUnknownPosition())
|
||||||
|
ta.tryFixPosition();
|
||||||
|
|
||||||
|
if (ta.position.matchesPos(treePos))
|
||||||
ta.position.updatePosOffset(code.cp);
|
ta.position.updatePosOffset(code.cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1836,7 +1843,10 @@ public class Gen extends JCTree.Visitor {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (Attribute.TypeCompound ta : s.getRawTypeAttributes()) {
|
for (Attribute.TypeCompound ta : s.getRawTypeAttributes()) {
|
||||||
if (ta.position != null && ta.position.matchesPos(treePos))
|
if (ta.hasUnknownPosition())
|
||||||
|
ta.tryFixPosition();
|
||||||
|
|
||||||
|
if (ta.position.matchesPos(treePos))
|
||||||
ta.position.updatePosOffset(code.cp);
|
ta.position.updatePosOffset(code.cp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2208,8 +2218,8 @@ public class Gen extends JCTree.Visitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitTypeTest(JCInstanceOf tree) {
|
public void visitTypeTest(JCInstanceOf tree) {
|
||||||
genExpr(tree.expr, tree.expr.type).load();
|
|
||||||
setTypeAnnotationPositions(tree.pos);
|
setTypeAnnotationPositions(tree.pos);
|
||||||
|
genExpr(tree.expr, tree.expr.type).load();
|
||||||
code.emitop2(instanceof_, makeRef(tree.pos(), tree.clazz.type));
|
code.emitop2(instanceof_, makeRef(tree.pos(), tree.clazz.type));
|
||||||
result = items.makeStackItem(syms.booleanType);
|
result = items.makeStackItem(syms.booleanType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
* @summary Make sure that type annotations are displayed correctly
|
* @summary Make sure that type annotations are displayed correctly
|
||||||
* @author Bhavesh Patel
|
* @author Bhavesh Patel
|
||||||
* @library ../lib
|
* @library ../lib
|
||||||
* @ignore
|
* @ignore 8006735 output type annotations in javadoc
|
||||||
* @build JavadocTester
|
* @build JavadocTester
|
||||||
* @run main TestTypeAnnotations
|
* @run main TestTypeAnnotations
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* @bug 8026564
|
* @bug 8026564
|
||||||
* @summary The parts of a fully-qualified type can't be annotated.
|
* @summary The parts of a fully-qualified type can't be annotated.
|
||||||
* @author Werner Dietl
|
* @author Werner Dietl
|
||||||
|
* @ignore 8057679 clarify error messages trying to annotate scoping
|
||||||
* @compile/fail/ref=CantAnnotatePackages.out -XDrawDiagnostics CantAnnotatePackages.java
|
* @compile/fail/ref=CantAnnotatePackages.out -XDrawDiagnostics CantAnnotatePackages.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* @bug 8006733 8006775
|
* @bug 8006733 8006775
|
||||||
* @summary Ensure behavior for nested types is correct.
|
* @summary Ensure behavior for nested types is correct.
|
||||||
* @author Werner Dietl
|
* @author Werner Dietl
|
||||||
|
* @ignore 8057679 clarify error messages trying to annotate scoping
|
||||||
* @compile/fail/ref=CantAnnotateScoping.out -XDrawDiagnostics CantAnnotateScoping.java
|
* @compile/fail/ref=CantAnnotateScoping.out -XDrawDiagnostics CantAnnotateScoping.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
* @bug 8006733 8006775
|
* @bug 8006733 8006775
|
||||||
* @summary Ensure behavior for nested types is correct.
|
* @summary Ensure behavior for nested types is correct.
|
||||||
* @author Werner Dietl
|
* @author Werner Dietl
|
||||||
|
* @ignore 8057679 clarify error messages trying to annotate scoping
|
||||||
|
* @ignore 8057683 improve ordering of errors with type annotations
|
||||||
* @compile/fail/ref=CantAnnotateStaticClass2.out -XDrawDiagnostics CantAnnotateStaticClass2.java
|
* @compile/fail/ref=CantAnnotateStaticClass2.out -XDrawDiagnostics CantAnnotateStaticClass2.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
* @bug 8006733 8006775 8027262
|
* @bug 8006733 8006775 8027262
|
||||||
* @summary Ensure behavior for nested types is correct.
|
* @summary Ensure behavior for nested types is correct.
|
||||||
* @author Werner Dietl
|
* @author Werner Dietl
|
||||||
|
* @ignore 8057679 clarify error messages trying to annotate scoping
|
||||||
|
* @ignore 8057683 improve order of errors with type annotations
|
||||||
* @compile/fail/ref=CantAnnotateStaticClass3.out -XDrawDiagnostics CantAnnotateStaticClass3.java
|
* @compile/fail/ref=CantAnnotateStaticClass3.out -XDrawDiagnostics CantAnnotateStaticClass3.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
DeclarationAnnotation.java:13:21: compiler.err.annotation.type.not.applicable
|
||||||
DeclarationAnnotation.java:10:21: compiler.err.annotation.type.not.applicable
|
DeclarationAnnotation.java:10:21: compiler.err.annotation.type.not.applicable
|
||||||
DeclarationAnnotation.java:11:21: compiler.err.annotation.type.not.applicable
|
DeclarationAnnotation.java:11:21: compiler.err.annotation.type.not.applicable
|
||||||
DeclarationAnnotation.java:12:21: compiler.err.annotation.type.not.applicable
|
DeclarationAnnotation.java:12:21: compiler.err.annotation.type.not.applicable
|
||||||
DeclarationAnnotation.java:13:21: compiler.err.annotation.type.not.applicable
|
|
||||||
4 errors
|
4 errors
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
* @test
|
* @test
|
||||||
* @bug 8027262
|
* @bug 8027262
|
||||||
* @summary Stress test for type annotatons
|
* @summary Stress test for type annotatons
|
||||||
|
* @ignore 8057685 javac should not crash compiling type annotations
|
||||||
* @compile AllLocations.java
|
* @compile AllLocations.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.*;
|
||||||
* @bug 8006775
|
* @bug 8006775
|
||||||
* @summary repeating type annotations are possible
|
* @summary repeating type annotations are possible
|
||||||
* @author Werner Dietl
|
* @author Werner Dietl
|
||||||
|
* @ignore 8057683 improve ordering of errors with type annotations
|
||||||
* @compile/fail/ref=RepeatingTypeAnnotations.out -XDrawDiagnostics RepeatingTypeAnnotations.java
|
* @compile/fail/ref=RepeatingTypeAnnotations.out -XDrawDiagnostics RepeatingTypeAnnotations.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
* @test
|
* @test
|
||||||
* @bug 8008077 8029721 8042451 8043974
|
* @bug 8008077 8029721 8042451 8043974
|
||||||
* @summary Test population of reference info for lambda expressions
|
* @summary Test population of reference info for lambda expressions
|
||||||
* javac crash for annotated parameter type of lambda in a field
|
* javac crash for annotated parameter type of lambda in a field
|
||||||
|
* @ignore 8057687 emit correct byte code an attributes for type annotations
|
||||||
* @compile -g Driver.java ReferenceInfoUtil.java Lambda.java
|
* @compile -g Driver.java ReferenceInfoUtil.java Lambda.java
|
||||||
* @run main Driver Lambda
|
* @run main Driver Lambda
|
||||||
* @author Werner Dietl
|
* @author Werner Dietl
|
||||||
|
|
|
@ -27,6 +27,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||||
* @test
|
* @test
|
||||||
* @bug 8042451 8044009 8044010
|
* @bug 8042451 8044009 8044010
|
||||||
* @summary Test population of reference info for nested types
|
* @summary Test population of reference info for nested types
|
||||||
|
* @ignore 8057687 emit correct byte code an attributes for type annotations
|
||||||
* @compile -g Driver.java ReferenceInfoUtil.java NestedTypes.java
|
* @compile -g Driver.java ReferenceInfoUtil.java NestedTypes.java
|
||||||
* @run main Driver NestedTypes
|
* @run main Driver NestedTypes
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
* @bug 8013852
|
* @bug 8013852
|
||||||
* @summary Annotations on types
|
* @summary Annotations on types
|
||||||
* @library /tools/javac/lib
|
* @library /tools/javac/lib
|
||||||
* @ignore
|
* @ignore 8057688 type annotations in type argument position are lost
|
||||||
|
* @ignore 8031744 Annotations on many Language Model elements are not returned
|
||||||
* @build JavacTestingAbstractProcessor DPrinter BasicAnnoTests
|
* @build JavacTestingAbstractProcessor DPrinter BasicAnnoTests
|
||||||
* @compile/process -processor BasicAnnoTests -proc:only BasicAnnoTests.java
|
* @compile/process -processor BasicAnnoTests -proc:only BasicAnnoTests.java
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -34,6 +34,7 @@ class T6747671<E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@TA B @TA[] arr = new @TA B @TA [0];//JDK-8022567: raw warning (2)
|
@TA B @TA[] arr = new @TA B @TA [0];//JDK-8022567: raw warning (2)
|
||||||
|
//todo: 8057688 type annotations in type argument position are lost
|
||||||
Class<B[]> classes1;//no warning
|
Class<B[]> classes1;//no warning
|
||||||
Class<B>[] classes2;//no warning
|
Class<B>[] classes2;//no warning
|
||||||
|
|
||||||
|
|
|
@ -8,5 +8,5 @@ T6747671.java:32:9: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
|
||||||
T6747671.java:32:20: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
|
T6747671.java:32:20: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
|
||||||
T6747671.java:33:16: compiler.warn.raw.class.use: T6747671.A.Z, T6747671<E>.A<X>.Z<Y>
|
T6747671.java:33:16: compiler.warn.raw.class.use: T6747671.A.Z, T6747671<E>.A<X>.Z<Y>
|
||||||
T6747671.java:36:9: compiler.warn.raw.class.use: @T6747671.TA T6747671.B, T6747671.B<X>
|
T6747671.java:36:9: compiler.warn.raw.class.use: @T6747671.TA T6747671.B, T6747671.B<X>
|
||||||
T6747671.java:36:27: compiler.warn.raw.class.use: @T6747671.TA T6747671.B, T6747671.B<X>
|
T6747671.java:36:27: compiler.warn.raw.class.use: T6747671.B, T6747671.B<X>
|
||||||
11 warnings
|
11 warnings
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @compile/ref=T6480588.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast T6480588.java
|
* @compile/ref=T6480588.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast T6480588.java
|
||||||
* @run main VerifySuppressWarnings T6480588.java
|
* @run main VerifySuppressWarnings T6480588.java
|
||||||
*/
|
*/
|
||||||
|
// TODO: 8057683 improve ordering of errors with type annotations
|
||||||
@DeprecatedAnnotation
|
@DeprecatedAnnotation
|
||||||
class T6480588 extends DeprecatedClass implements DeprecatedInterface {
|
class T6480588 extends DeprecatedClass implements DeprecatedInterface {
|
||||||
@DeprecatedAnnotation
|
@DeprecatedAnnotation
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
T6480588.java:11:2: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package
|
|
||||||
T6480588.java:12:24: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
T6480588.java:12:24: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
||||||
T6480588.java:12:51: compiler.warn.has.been.deprecated: DeprecatedInterface, compiler.misc.unnamed.package
|
T6480588.java:12:51: compiler.warn.has.been.deprecated: DeprecatedInterface, compiler.misc.unnamed.package
|
||||||
|
T6480588.java:11:2: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package
|
||||||
T6480588.java:14:12: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
T6480588.java:14:12: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
||||||
T6480588.java:14:65: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
T6480588.java:14:65: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
||||||
T6480588.java:13:6: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package
|
T6480588.java:13:6: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package
|
||||||
|
@ -12,7 +12,7 @@ T6480588.java:17:35: compiler.warn.has.been.deprecated: DeprecatedClass, compile
|
||||||
T6480588.java:26:5: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
T6480588.java:26:5: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
||||||
T6480588.java:25:6: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package
|
T6480588.java:25:6: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package
|
||||||
T6480588.java:26:33: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
T6480588.java:26:33: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
||||||
T6480588.java:28:6: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package
|
|
||||||
T6480588.java:29:25: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
T6480588.java:29:25: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
|
||||||
T6480588.java:29:52: compiler.warn.has.been.deprecated: DeprecatedInterface, compiler.misc.unnamed.package
|
T6480588.java:29:52: compiler.warn.has.been.deprecated: DeprecatedInterface, compiler.misc.unnamed.package
|
||||||
|
T6480588.java:28:6: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package
|
||||||
17 warnings
|
17 warnings
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8021112
|
* @bug 8021112
|
||||||
* @summary Verify that \\@SuppressWarnings("unchecked") works for type annotations
|
* @summary Verify that \\@SuppressWarnings("unchecked") works for type annotations
|
||||||
|
* @ignore 8057683 improve ordering of errors with type annotations
|
||||||
* @build VerifySuppressWarnings
|
* @build VerifySuppressWarnings
|
||||||
* @compile/ref=TypeAnnotations.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast TypeAnnotations.java
|
* @compile/ref=TypeAnnotations.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast TypeAnnotations.java
|
||||||
* @run main VerifySuppressWarnings TypeAnnotations.java
|
* @run main VerifySuppressWarnings TypeAnnotations.java
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
* @test
|
* @test
|
||||||
* @bug 8005220
|
* @bug 8005220
|
||||||
* @summary javap must display repeating annotations
|
* @summary javap must display repeating annotations
|
||||||
|
* @ignore 8057687 emit correct byte code an attributes for type annotations
|
||||||
*/
|
*/
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue