Merge
This commit is contained in:
commit
b2a5eb6f28
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -68,7 +68,15 @@ public final class TaskEvent
|
||||
/**
|
||||
* For events relating to an individual annotation processing round.
|
||||
**/
|
||||
ANNOTATION_PROCESSING_ROUND
|
||||
ANNOTATION_PROCESSING_ROUND,
|
||||
/**
|
||||
* Sent before parsing first source file, and after writing the last output file.
|
||||
* This event is not sent when using {@link JavacTask#parse()},
|
||||
* {@link JavacTask#analyze()} or {@link JavacTask#generate()}.
|
||||
*
|
||||
* @since 1.9
|
||||
*/
|
||||
COMPILATION,
|
||||
}
|
||||
|
||||
public TaskEvent(Kind kind) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -202,9 +202,6 @@ public class ClientCodeWrapper {
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Wrapper classes">
|
||||
|
||||
// FIXME: all these classes should be converted to use multi-catch when
|
||||
// that is available in the bootstrap compiler.
|
||||
|
||||
protected class WrappedJavaFileManager implements JavaFileManager {
|
||||
protected JavaFileManager clientJavaFileManager;
|
||||
WrappedJavaFileManager(JavaFileManager clientJavaFileManager) {
|
||||
|
@ -161,6 +161,15 @@ public class JavacTaskImpl extends BasicJavacTask {
|
||||
compilerMain.log = Log.instance(context);
|
||||
compilerMain.setOptions(Options.instance(context));
|
||||
compilerMain.filenames = new LinkedHashSet<>();
|
||||
compilerMain.deferredFileManagerOptions = new LinkedHashMap<>();
|
||||
// The following line is conceptually wrong. It should not refer to args
|
||||
// which may include inappropriate file manager options.
|
||||
// (Ideally, args should not even be passed into JavacTaskImpl at all.)
|
||||
// The "no filenames in args" check should have been handled by the use of
|
||||
// the GrumpyHelper in JavacTool.getTask, but processArgs also has some
|
||||
// additional checking, which should be factored out and called separately.
|
||||
// If we fix this, then filenames and deferredFileManagerOptions in Main
|
||||
// can revert to being protected or private, not public.
|
||||
Collection<File> filenames = compilerMain.processArgs(CommandLine.parse(args), classNames);
|
||||
if (filenames != null && !filenames.isEmpty())
|
||||
throw new IllegalArgumentException("Malformed arguments " + toString(filenames, " "));
|
||||
|
@ -142,7 +142,7 @@ public abstract class Attribute implements AnnotationValue {
|
||||
* access this attribute.
|
||||
*/
|
||||
public final List<Pair<MethodSymbol,Attribute>> values;
|
||||
public TypeAnnotationPosition position;
|
||||
public final TypeAnnotationPosition position;
|
||||
|
||||
private boolean synthesized = false;
|
||||
|
||||
@ -170,53 +170,9 @@ public abstract class Attribute implements AnnotationValue {
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
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); }
|
||||
|
||||
/**
|
||||
@ -280,6 +236,12 @@ public abstract class Attribute implements AnnotationValue {
|
||||
valmap.put(value.fst, value.snd);
|
||||
return valmap;
|
||||
}
|
||||
|
||||
public TypeCompound toTypeCompound() {
|
||||
// It is safe to alias the position.
|
||||
return new TypeCompound(this, this.position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TypeCompound extends Compound {
|
||||
|
@ -296,7 +296,8 @@ public class Flags {
|
||||
ModifierFlags = ((long)StandardFlags & ~INTERFACE) | DEFAULT,
|
||||
InterfaceMethodMask = ABSTRACT | STATIC | PUBLIC | STRICTFP | DEFAULT,
|
||||
AnnotationTypeElementMask = ABSTRACT | PUBLIC,
|
||||
LocalVarFlags = FINAL | PARAMETER;
|
||||
LocalVarFlags = FINAL | PARAMETER,
|
||||
ReceiverParamFlags = PARAMETER;
|
||||
|
||||
|
||||
public static Set<Modifier> asModifierSet(long flags) {
|
||||
|
@ -107,10 +107,7 @@ public enum TargetType {
|
||||
CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT(0x4A, true),
|
||||
|
||||
/** For annotations on a type argument of a method reference. */
|
||||
METHOD_REFERENCE_TYPE_ARGUMENT(0x4B, true),
|
||||
|
||||
/** For annotations with an unknown target. */
|
||||
UNKNOWN(0xFF);
|
||||
METHOD_REFERENCE_TYPE_ARGUMENT(0x4B, true);
|
||||
|
||||
private static final int MAXIMUM_TARGET_TYPE_VALUE = 0x4B;
|
||||
|
||||
@ -150,26 +147,15 @@ public enum TargetType {
|
||||
targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
|
||||
TargetType[] alltargets = values();
|
||||
for (TargetType target : alltargets) {
|
||||
if (target.targetTypeValue != UNKNOWN.targetTypeValue)
|
||||
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) {
|
||||
if (tag == UNKNOWN.targetTypeValue)
|
||||
return true;
|
||||
|
||||
return (tag >= 0 && tag < targets.length);
|
||||
}
|
||||
|
||||
public static TargetType fromTargetTypeValue(int tag) {
|
||||
if (tag == UNKNOWN.targetTypeValue)
|
||||
return UNKNOWN;
|
||||
|
||||
if (tag < 0 || tag >= targets.length)
|
||||
Assert.error("Unknown TargetType: " + tag);
|
||||
return targets[tag];
|
||||
|
@ -259,9 +259,6 @@ public class TypeAnnotationPosition {
|
||||
case METHOD_RETURN:
|
||||
case FIELD:
|
||||
break;
|
||||
case UNKNOWN:
|
||||
sb.append(", position UNKNOWN!");
|
||||
break;
|
||||
default:
|
||||
Assert.error("Unknown target type: " + type);
|
||||
}
|
||||
@ -428,7 +425,7 @@ public class TypeAnnotationPosition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@code TypeAnnotationPosition} for a method receiver.
|
||||
* Create a {@code TypeAnnotationPosition} for a method receiver parameter.
|
||||
*
|
||||
* @param location The type path.
|
||||
* @param onLambda The lambda for this parameter.
|
||||
@ -445,7 +442,7 @@ public class TypeAnnotationPosition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@code TypeAnnotationPosition} for a method receiver.
|
||||
* Create a {@code TypeAnnotationPosition} for a method receiver parameter.
|
||||
*
|
||||
* @param location The type path.
|
||||
*/
|
||||
@ -455,7 +452,7 @@ public class TypeAnnotationPosition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@code TypeAnnotationPosition} for a method receiver.
|
||||
* Create a {@code TypeAnnotationPosition} for a method receiver parameter.
|
||||
*
|
||||
* @param pos The position from the associated tree node.
|
||||
*/
|
||||
@ -664,10 +661,11 @@ public class TypeAnnotationPosition {
|
||||
public static TypeAnnotationPosition
|
||||
exceptionParameter(final List<TypePathEntry> location,
|
||||
final JCLambda onLambda,
|
||||
final int type_index,
|
||||
final int pos) {
|
||||
return new TypeAnnotationPosition(TargetType.EXCEPTION_PARAMETER, pos,
|
||||
Integer.MIN_VALUE, onLambda,
|
||||
Integer.MIN_VALUE, Integer.MIN_VALUE,
|
||||
type_index, Integer.MIN_VALUE,
|
||||
location);
|
||||
}
|
||||
|
||||
@ -680,7 +678,7 @@ public class TypeAnnotationPosition {
|
||||
public static TypeAnnotationPosition
|
||||
exceptionParameter(final JCLambda onLambda,
|
||||
final int pos) {
|
||||
return exceptionParameter(emptyPath, onLambda, pos);
|
||||
return exceptionParameter(emptyPath, onLambda, Integer.MIN_VALUE, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -690,7 +688,7 @@ public class TypeAnnotationPosition {
|
||||
*/
|
||||
public static TypeAnnotationPosition
|
||||
exceptionParameter(final List<TypePathEntry> location) {
|
||||
return exceptionParameter(location, null, -1);
|
||||
return exceptionParameter(location, null, Integer.MIN_VALUE, -1);
|
||||
}
|
||||
|
||||
|
||||
@ -1204,12 +1202,4 @@ public class TypeAnnotationPosition {
|
||||
return methodTypeParameterBound(location, null, parameter_index,
|
||||
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
@ -1212,17 +1212,38 @@ public class Types {
|
||||
TypeRelation isSameTypeLoose = new LooseSameTypeVisitor();
|
||||
|
||||
private class LooseSameTypeVisitor extends SameTypeVisitor {
|
||||
|
||||
/** cache of the type-variable pairs being (recursively) tested. */
|
||||
private Set<TypePair> cache = new HashSet<>();
|
||||
|
||||
@Override
|
||||
boolean sameTypeVars(TypeVar tv1, TypeVar tv2) {
|
||||
return tv1.tsym == tv2.tsym && visit(tv1.getUpperBound(), tv2.getUpperBound());
|
||||
return tv1.tsym == tv2.tsym && checkSameBounds(tv1, tv2);
|
||||
}
|
||||
@Override
|
||||
protected boolean containsTypes(List<Type> ts1, List<Type> ts2) {
|
||||
return containsTypeEquivalent(ts1, ts2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Since type-variable bounds can be recursive, we need to protect against
|
||||
* infinite loops - where the same bounds are checked over and over recursively.
|
||||
*/
|
||||
private boolean checkSameBounds(TypeVar tv1, TypeVar tv2) {
|
||||
TypePair p = new TypePair(tv1, tv2, true);
|
||||
if (cache.add(p)) {
|
||||
try {
|
||||
return visit(tv1.getUpperBound(), tv2.getUpperBound());
|
||||
} finally {
|
||||
cache.remove(p);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Strict type-equality relation - type variables are considered
|
||||
* equals if they share the same object identity.
|
||||
*/
|
||||
@ -3396,9 +3417,16 @@ public class Types {
|
||||
class TypePair {
|
||||
final Type t1;
|
||||
final Type t2;
|
||||
boolean strict;
|
||||
|
||||
TypePair(Type t1, Type t2) {
|
||||
this(t1, t2, false);
|
||||
}
|
||||
|
||||
TypePair(Type t1, Type t2, boolean strict) {
|
||||
this.t1 = t1;
|
||||
this.t2 = t2;
|
||||
this.strict = strict;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
@ -3409,8 +3437,8 @@ public class Types {
|
||||
if (!(obj instanceof TypePair))
|
||||
return false;
|
||||
TypePair typePair = (TypePair)obj;
|
||||
return isSameType(t1, typePair.t1)
|
||||
&& isSameType(t2, typePair.t2);
|
||||
return isSameType(t1, typePair.t1, strict)
|
||||
&& isSameType(t2, typePair.t2, strict);
|
||||
}
|
||||
}
|
||||
Set<TypePair> mergeCache = new HashSet<>();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -91,7 +91,6 @@ public class Attr extends JCTree.Visitor {
|
||||
final Types types;
|
||||
final JCDiagnostic.Factory diags;
|
||||
final Annotate annotate;
|
||||
final TypeAnnotations typeAnnotations;
|
||||
final DeferredLintHandler deferredLintHandler;
|
||||
|
||||
public static Attr instance(Context context) {
|
||||
@ -120,7 +119,6 @@ public class Attr extends JCTree.Visitor {
|
||||
types = Types.instance(context);
|
||||
diags = JCDiagnostic.Factory.instance(context);
|
||||
annotate = Annotate.instance(context);
|
||||
typeAnnotations = TypeAnnotations.instance(context);
|
||||
deferredLintHandler = DeferredLintHandler.instance(context);
|
||||
|
||||
Options options = Options.instance(context);
|
||||
@ -137,6 +135,7 @@ public class Attr extends JCTree.Visitor {
|
||||
allowTypeAnnos = source.allowTypeAnnotations();
|
||||
allowLambda = source.allowLambda();
|
||||
allowDefaultMethods = source.allowDefaultMethods();
|
||||
allowStaticInterfaceMethods = source.allowStaticInterfaceMethods();
|
||||
sourceName = source.name;
|
||||
relax = (options.isSet("-retrofit") ||
|
||||
options.isSet("-relax"));
|
||||
@ -194,6 +193,10 @@ public class Attr extends JCTree.Visitor {
|
||||
*/
|
||||
boolean allowDefaultMethods;
|
||||
|
||||
/** Switch: static interface methods enabled?
|
||||
*/
|
||||
boolean allowStaticInterfaceMethods;
|
||||
|
||||
/** Switch: allow references to surrounding object from anonymous
|
||||
* objects during constructor call?
|
||||
*/
|
||||
@ -434,8 +437,7 @@ public class Attr extends JCTree.Visitor {
|
||||
public Type attribImportQualifier(JCImport tree, Env<AttrContext> env) {
|
||||
// Attribute qualifying package or class.
|
||||
JCFieldAccess s = (JCFieldAccess)tree.qualid;
|
||||
return attribTree(s.selected,
|
||||
env,
|
||||
return attribTree(s.selected, env,
|
||||
new ResultInfo(tree.staticImport ? TYP : (TYP | PCK),
|
||||
Type.noType));
|
||||
}
|
||||
@ -638,7 +640,8 @@ public class Attr extends JCTree.Visitor {
|
||||
/** Derived visitor method: attribute an expression tree.
|
||||
*/
|
||||
public Type attribExpr(JCTree tree, Env<AttrContext> env, Type pt) {
|
||||
return attribTree(tree, env, new ResultInfo(VAL, !pt.hasTag(ERROR) ? pt : Type.noType));
|
||||
return attribTree(tree, env,
|
||||
new ResultInfo(VAL, !pt.hasTag(ERROR) ? pt : Type.noType));
|
||||
}
|
||||
|
||||
/** Derived visitor method: attribute an expression tree with
|
||||
@ -650,6 +653,7 @@ public class Attr extends JCTree.Visitor {
|
||||
|
||||
/** Derived visitor method: attribute a type tree.
|
||||
*/
|
||||
|
||||
public Type attribType(JCTree tree, Env<AttrContext> env) {
|
||||
Type result = attribType(tree, env, Type.noType);
|
||||
return result;
|
||||
@ -664,6 +668,7 @@ public class Attr extends JCTree.Visitor {
|
||||
|
||||
/** Derived visitor method: attribute a statement or definition tree.
|
||||
*/
|
||||
|
||||
public Type attribStat(JCTree tree, Env<AttrContext> env) {
|
||||
return attribTree(tree, env, statInfo);
|
||||
}
|
||||
@ -731,7 +736,8 @@ public class Attr extends JCTree.Visitor {
|
||||
a.tsym.flags_field |= UNATTRIBUTED;
|
||||
a.bound = Type.noType;
|
||||
if (!tvar.bounds.isEmpty()) {
|
||||
List<Type> bounds = List.of(attribType(tvar.bounds.head, env));
|
||||
List<Type> bounds =
|
||||
List.of(attribType(tvar.bounds.head, env));
|
||||
for (JCExpression bound : tvar.bounds.tail)
|
||||
bounds = bounds.prepend(attribType(bound, env));
|
||||
types.setBounds(a, bounds.reverse());
|
||||
@ -765,7 +771,7 @@ public class Attr extends JCTree.Visitor {
|
||||
* @param type The expected type, or null
|
||||
* @see VarSymbol#setLazyConstValue
|
||||
*/
|
||||
public Object attribLazyConstantValue(Env<AttrContext> env,
|
||||
public Object attribLazyConstantValue(final Env<AttrContext> env,
|
||||
JCVariableDecl variable,
|
||||
Type type) {
|
||||
|
||||
@ -884,6 +890,7 @@ public class Attr extends JCTree.Visitor {
|
||||
c.flags_field |= NOOUTERTHIS;
|
||||
}
|
||||
attribClass(tree.pos(), c);
|
||||
|
||||
result = tree.type = c.type;
|
||||
}
|
||||
}
|
||||
@ -1021,10 +1028,6 @@ public class Attr extends JCTree.Visitor {
|
||||
}
|
||||
}
|
||||
|
||||
// Attribute all type annotations in the body
|
||||
annotate.annotateTypeLater(tree.body, localEnv, m, null);
|
||||
annotate.flush();
|
||||
|
||||
// Attribute method body.
|
||||
attribStat(tree.body, localEnv);
|
||||
}
|
||||
@ -1038,21 +1041,59 @@ public class Attr extends JCTree.Visitor {
|
||||
}
|
||||
}
|
||||
|
||||
public void visitVarDef(JCVariableDecl tree) {
|
||||
public Annotate.PositionCreator getVarCreator(final 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:
|
||||
if (env.info.scope.owner.kind == MTH) {
|
||||
if (tree.sym != null) {
|
||||
// parameters have already been entered
|
||||
env.info.scope.enter(tree.sym);
|
||||
} else {
|
||||
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();
|
||||
memberEnter.memberEnter(tree, env, getVarCreator(tree));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1103,17 +1144,15 @@ public class Attr extends JCTree.Visitor {
|
||||
// Block is a static or instance initializer;
|
||||
// let the owner of the environment be a freshly
|
||||
// created BLOCK-method.
|
||||
Env<AttrContext> localEnv =
|
||||
final Env<AttrContext> localEnv =
|
||||
env.dup(tree, env.info.dup(env.info.scope.dupUnshared()));
|
||||
localEnv.info.scope.owner =
|
||||
new MethodSymbol(tree.flags | BLOCK |
|
||||
env.info.scope.owner.flags() & STRICTFP, names.empty, null,
|
||||
env.info.scope.owner);
|
||||
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();
|
||||
if ((tree.flags & STATIC) != 0) localEnv.info.staticLevel++;
|
||||
attribStats(tree.stats, localEnv);
|
||||
|
||||
{
|
||||
// Store init and clinit type annotations with the ClassSymbol
|
||||
@ -1126,8 +1165,6 @@ public class Attr extends JCTree.Visitor {
|
||||
cs.appendInitTypeAttributes(tas);
|
||||
}
|
||||
}
|
||||
|
||||
attribStats(tree.stats, localEnv);
|
||||
} else {
|
||||
// Create a new local environment with a local scope.
|
||||
Env<AttrContext> localEnv =
|
||||
@ -1481,17 +1518,21 @@ public class Attr extends JCTree.Visitor {
|
||||
isBooleanOrNumeric(env, condTree.falsepart);
|
||||
case APPLY:
|
||||
JCMethodInvocation speculativeMethodTree =
|
||||
(JCMethodInvocation)deferredAttr.attribSpeculative(tree, env, unknownExprInfo);
|
||||
(JCMethodInvocation)deferredAttr.attribSpeculative(tree, env, unknownExprInfo,
|
||||
annotate.noCreator);
|
||||
Type owntype = TreeInfo.symbol(speculativeMethodTree.meth).type.getReturnType();
|
||||
return types.unboxedTypeOrType(owntype).isPrimitive();
|
||||
case NEWCLASS:
|
||||
JCExpression className =
|
||||
removeClassParams.translate(((JCNewClass)tree).clazz);
|
||||
JCExpression speculativeNewClassTree =
|
||||
(JCExpression)deferredAttr.attribSpeculative(className, env, unknownTypeInfo);
|
||||
(JCExpression)deferredAttr.attribSpeculative(className,
|
||||
env,
|
||||
unknownTypeInfo,
|
||||
annotate.newObjCreator(tree.pos));
|
||||
return types.unboxedTypeOrType(speculativeNewClassTree.type).isPrimitive();
|
||||
default:
|
||||
Type speculativeType = deferredAttr.attribSpeculative(tree, env, unknownExprInfo).type;
|
||||
Type speculativeType = deferredAttr.attribSpeculative(tree, env, unknownExprInfo, annotate.noCreator).type;
|
||||
speculativeType = types.unboxedTypeOrType(speculativeType);
|
||||
return speculativeType.isPrimitive();
|
||||
}
|
||||
@ -1754,7 +1795,28 @@ public class Attr extends JCTree.Visitor {
|
||||
// Attribute arguments, yielding list of argument types.
|
||||
attribArgs(tree.args, localEnv, argtypesBuf);
|
||||
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
|
||||
// constructor is defined.
|
||||
@ -1827,7 +1889,27 @@ public class Attr extends JCTree.Visitor {
|
||||
// Attribute the arguments, yielding list of argument types, ...
|
||||
int kind = attribArgs(tree.args, localEnv, argtypesBuf);
|
||||
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
|
||||
// whose formal argument types is exactly the list of actual
|
||||
@ -1852,6 +1934,7 @@ public class Attr extends JCTree.Visitor {
|
||||
// current context. Also, capture the return type
|
||||
result = check(tree, capture(restype), VAL, resultInfo);
|
||||
}
|
||||
|
||||
chk.validate(tree.typeargs, localEnv);
|
||||
}
|
||||
//where
|
||||
@ -1927,14 +2010,12 @@ public class Attr extends JCTree.Visitor {
|
||||
annoclazzid = (JCAnnotatedType) clazzid;
|
||||
clazzid = annoclazzid.underlyingType;
|
||||
}
|
||||
} else {
|
||||
if (clazz.hasTag(ANNOTATED_TYPE)) {
|
||||
} else if (clazz.hasTag(ANNOTATED_TYPE)) {
|
||||
annoclazzid = (JCAnnotatedType) clazz;
|
||||
clazzid = annoclazzid.underlyingType;
|
||||
} else {
|
||||
clazzid = clazz;
|
||||
}
|
||||
}
|
||||
|
||||
JCExpression clazzid1 = clazzid; // The same in fully qualified form
|
||||
|
||||
@ -1956,11 +2037,12 @@ public class Attr extends JCTree.Visitor {
|
||||
|
||||
EndPosTable endPosTable = this.env.toplevel.endPositions;
|
||||
endPosTable.storeEnd(clazzid1, tree.getEndPosition(endPosTable));
|
||||
if (clazz.hasTag(ANNOTATED_TYPE)) {
|
||||
JCAnnotatedType annoType = (JCAnnotatedType) clazz;
|
||||
List<JCAnnotation> annos = annoType.annotations;
|
||||
if (annoclazzid != null) {
|
||||
JCAnnotatedType annoType = annoclazzid;
|
||||
List<JCAnnotation> annos = annoclazzid.annotations;
|
||||
|
||||
if (clazz.hasTag(TYPEAPPLY)) {
|
||||
|
||||
if (annoType.underlyingType.hasTag(TYPEAPPLY)) {
|
||||
clazzid1 = make.at(tree.pos).
|
||||
TypeApply(clazzid1,
|
||||
((JCTypeApply) clazz).arguments);
|
||||
@ -1977,12 +2059,32 @@ public class Attr extends JCTree.Visitor {
|
||||
clazz = clazzid1;
|
||||
}
|
||||
|
||||
Type clazztype;
|
||||
|
||||
try {
|
||||
annotate.enterStart();
|
||||
// Attribute clazz expression and store
|
||||
// symbol + type back into the attributed tree.
|
||||
Type clazztype = TreeInfo.isEnumInit(env.tree) ?
|
||||
clazztype = TreeInfo.isEnumInit(env.tree) ?
|
||||
attribIdentAsEnumType(env, (JCIdent)clazz) :
|
||||
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);
|
||||
chk.validate(clazz, localEnv);
|
||||
if (tree.encl != null) {
|
||||
@ -2011,7 +2113,29 @@ public class Attr extends JCTree.Visitor {
|
||||
ListBuffer<Type> argtypesBuf = new ListBuffer<>();
|
||||
int pkind = attribArgs(tree.args, localEnv, argtypesBuf);
|
||||
List<Type> argtypes = argtypesBuf.toList();
|
||||
List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
|
||||
List<Type> typeargtypes;
|
||||
|
||||
// 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 (clazztype.hasTag(CLASS)) {
|
||||
@ -2194,7 +2318,9 @@ public class Attr extends JCTree.Visitor {
|
||||
ta.arguments = List.nil();
|
||||
ResultInfo findDiamondResult = new ResultInfo(VAL,
|
||||
resultInfo.checkContext.inferenceContext().free(resultInfo.pt) ? Type.noType : pt());
|
||||
Type inferred = deferredAttr.attribSpeculative(tree, env, findDiamondResult).type;
|
||||
Type inferred = deferredAttr.attribSpeculative(tree, env,
|
||||
findDiamondResult,
|
||||
annotate.newObjCreator(tree.pos)).type;
|
||||
Type polyPt = allowPoly ?
|
||||
syms.objectType :
|
||||
clazztype;
|
||||
@ -2256,8 +2382,20 @@ public class Attr extends JCTree.Visitor {
|
||||
Type owntype = types.createErrorType(tree.type);
|
||||
Env<AttrContext> localEnv = env.dup(tree);
|
||||
Type elemtype;
|
||||
|
||||
for(List<JCAnnotation> dim : tree.dimAnnotations) {
|
||||
this.attribAnnotationTypes(dim, localEnv);
|
||||
}
|
||||
|
||||
if (tree.elemtype != null) {
|
||||
try {
|
||||
annotate.enterStart();
|
||||
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);
|
||||
owntype = elemtype;
|
||||
for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
|
||||
@ -2278,6 +2416,7 @@ public class Attr extends JCTree.Visitor {
|
||||
elemtype = types.createErrorType(pt());
|
||||
}
|
||||
}
|
||||
|
||||
if (tree.elems != null) {
|
||||
attribExprs(tree.elems, localEnv, elemtype);
|
||||
owntype = new ArrayType(elemtype, syms.arrayClass,
|
||||
@ -2672,6 +2811,8 @@ public class Attr extends JCTree.Visitor {
|
||||
|
||||
@Override
|
||||
public void visitReference(final JCMemberReference that) {
|
||||
final boolean isConstructor = that.getName() == names.init;
|
||||
|
||||
if (pt().isErroneous() || (pt().hasTag(NONE) && pt() != Type.recoveryType)) {
|
||||
if (pt().hasTag(NONE)) {
|
||||
//method reference only allowed in assignment or method invocation/cast context
|
||||
@ -2682,9 +2823,20 @@ public class Attr extends JCTree.Visitor {
|
||||
}
|
||||
final Env<AttrContext> localEnv = env.dup(that);
|
||||
try {
|
||||
Type exprType;
|
||||
try {
|
||||
annotate.enterStart();
|
||||
//attribute member reference qualifier - if this is a constructor
|
||||
//reference, the expected kind must be a type
|
||||
Type exprType = attribTree(that.expr, env, memberReferenceQualifierResult(that));
|
||||
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) {
|
||||
exprType = chk.checkConstructorRefType(that.expr, exprType);
|
||||
@ -2714,7 +2866,24 @@ public class Attr extends JCTree.Visitor {
|
||||
//attrib type-arguments
|
||||
List<Type> typeargtypes = List.nil();
|
||||
if (that.typeargs != null) {
|
||||
try {
|
||||
annotate.enterStart();
|
||||
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;
|
||||
@ -3088,7 +3257,15 @@ public class Attr extends JCTree.Visitor {
|
||||
}
|
||||
|
||||
public void visitTypeCast(final JCTypeCast tree) {
|
||||
Type clazztype = attribType(tree.clazz, env);
|
||||
Type clazztype;
|
||||
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);
|
||||
//a fresh environment is required for 292 inference to work properly ---
|
||||
//see Infer.instantiatePolymorphicSignatureInstance()
|
||||
@ -3121,7 +3298,16 @@ public class Attr extends JCTree.Visitor {
|
||||
public void visitTypeTest(JCInstanceOf tree) {
|
||||
Type exprtype = chk.checkNullOrRefType(
|
||||
tree.expr.pos(), attribExpr(tree.expr, env));
|
||||
Type clazztype = attribType(tree.clazz, env);
|
||||
Type clazztype;
|
||||
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)) {
|
||||
clazztype = chk.checkClassOrArrayType(tree.clazz.pos(), clazztype);
|
||||
}
|
||||
@ -3250,9 +3436,12 @@ public class Attr extends JCTree.Visitor {
|
||||
if ((pkind() & (PCK | TYP)) == 0)
|
||||
site = capture(site); // Capture field access
|
||||
|
||||
// don't allow T.class T[].class, etc
|
||||
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
|
||||
while (elt.hasTag(ARRAY))
|
||||
elt = ((ArrayType)elt).elemtype;
|
||||
if (elt.hasTag(TYPEVAR)) {
|
||||
@ -3334,6 +3523,10 @@ public class Attr extends JCTree.Visitor {
|
||||
tree.pos(), site, sym.name, true);
|
||||
}
|
||||
}
|
||||
if (!allowStaticInterfaceMethods && sitesym.isInterface() &&
|
||||
sym.isStatic() && sym.kind == MTH) {
|
||||
log.error(tree.pos(), "static.intf.method.invoke.not.supported.in.source", sourceName);
|
||||
}
|
||||
} else if (sym.kind != ERR && (sym.flags() & STATIC) != 0 && sym.name != names._class) {
|
||||
// If the qualified item is not a type and the selected item is static, report
|
||||
// a warning. Make allowance for the class of an array type e.g. Object[].class)
|
||||
@ -4081,8 +4274,13 @@ public class Attr extends JCTree.Visitor {
|
||||
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) {
|
||||
Type underlyingType = attribType(tree.getUnderlyingType(), env);
|
||||
Type underlyingType = attribTree(tree.getUnderlyingType(), env,
|
||||
resultInfo);
|
||||
this.attribAnnotationTypes(tree.annotations, env);
|
||||
annotateType(tree, tree.annotations);
|
||||
result = tree.type = underlyingType;
|
||||
@ -4101,8 +4299,10 @@ public class Attr extends JCTree.Visitor {
|
||||
public void run() {
|
||||
List<Attribute.TypeCompound> compounds = fromAnnotations(annotations);
|
||||
Assert.check(annotations.size() == compounds.size());
|
||||
if (!tree.type.hasTag(TypeTag.PACKAGE)) {
|
||||
tree.type = tree.type.annotatedType(compounds);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -4353,13 +4553,6 @@ public class Attr extends JCTree.Visitor {
|
||||
checkForSerial(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
|
||||
boolean checkForSerial(ClassSymbol c) {
|
||||
@ -4433,233 +4626,6 @@ public class Attr extends JCTree.Visitor {
|
||||
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">
|
||||
|
||||
/**
|
||||
|
@ -58,6 +58,11 @@ public class AttrContext {
|
||||
*/
|
||||
boolean isSerializable = false;
|
||||
|
||||
/**
|
||||
* Are we doing speculative attribution?
|
||||
*/
|
||||
boolean isSpeculative = false;
|
||||
|
||||
/** Are arguments to current function applications boxed into an array for varargs?
|
||||
*/
|
||||
Resolve.MethodResolutionPhase pendingResolutionPhase = null;
|
||||
@ -94,6 +99,7 @@ public class AttrContext {
|
||||
info.returnResult = returnResult;
|
||||
info.defaultSuperCallSite = defaultSuperCallSite;
|
||||
info.isSerializable = isSerializable;
|
||||
info.isSpeculative = isSpeculative;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -1041,7 +1041,9 @@ public class Check {
|
||||
|
||||
switch (sym.kind) {
|
||||
case VAR:
|
||||
if (sym.owner.kind != TYP)
|
||||
if (TreeInfo.isReceiverParam(tree))
|
||||
mask = ReceiverParamFlags;
|
||||
else if (sym.owner.kind != TYP)
|
||||
mask = LocalVarFlags;
|
||||
else if ((sym.owner.flags_field & INTERFACE) != 0)
|
||||
mask = implicit = InterfaceVarFlags;
|
||||
@ -1818,6 +1820,11 @@ public class Check {
|
||||
Type t1,
|
||||
Type t2,
|
||||
Type site) {
|
||||
if ((site.tsym.flags() & COMPOUND) != 0) {
|
||||
// special case for intersections: need to eliminate wildcards in supertypes
|
||||
t1 = types.capture(t1);
|
||||
t2 = types.capture(t2);
|
||||
}
|
||||
return firstIncompatibility(pos, t1, t2, site) == null;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
package com.sun.tools.javac.comp;
|
||||
|
||||
import com.sun.source.tree.*;
|
||||
import com.sun.source.tree.LambdaExpressionTree.BodyKind;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.tree.*;
|
||||
@ -76,6 +77,7 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||
final Types types;
|
||||
final Flow flow;
|
||||
final Names names;
|
||||
final Annotate annotate;
|
||||
|
||||
public static DeferredAttr instance(Context context) {
|
||||
DeferredAttr instance = context.get(deferredAttrKey);
|
||||
@ -99,6 +101,7 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||
flow = Flow.instance(context);
|
||||
names = Names.instance(context);
|
||||
stuckTree = make.Ident(names.empty).setType(Type.stuckType);
|
||||
annotate = Annotate.instance(context);
|
||||
emptyDeferredAttrContext =
|
||||
new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) {
|
||||
@Override
|
||||
@ -133,7 +136,8 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||
AttrMode mode;
|
||||
SpeculativeCache speculativeCache;
|
||||
|
||||
DeferredType(JCExpression tree, Env<AttrContext> env) {
|
||||
DeferredType(JCExpression tree,
|
||||
Env<AttrContext> env) {
|
||||
super(null, noAnnotations);
|
||||
this.tree = tree;
|
||||
this.env = attr.copyEnv(env);
|
||||
@ -277,12 +281,18 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||
//Note: if a symbol is imported twice we might do two identical
|
||||
//speculative rounds...
|
||||
Assert.check(dt.mode == null || dt.mode == AttrMode.SPECULATIVE);
|
||||
JCTree speculativeTree = attribSpeculative(dt.tree, dt.env, resultInfo);
|
||||
JCTree speculativeTree = attribSpeculative(dt.tree, dt.env,
|
||||
resultInfo,
|
||||
annotate.noCreator);
|
||||
dt.speculativeCache.put(speculativeTree, resultInfo);
|
||||
return speculativeTree.type;
|
||||
case CHECK:
|
||||
Assert.check(dt.mode != null);
|
||||
return attr.attribTree(dt.tree, dt.env, resultInfo);
|
||||
final boolean oldSpeculative = dt.env.info.isSpeculative;
|
||||
dt.env.info.isSpeculative = false;
|
||||
Type out = attr.attribTree(dt.tree, dt.env, resultInfo);
|
||||
dt.env.info.isSpeculative = oldSpeculative;
|
||||
return out;
|
||||
}
|
||||
Assert.error();
|
||||
return null;
|
||||
@ -359,9 +369,13 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||
* restored after type-checking. All diagnostics (but critical ones) are
|
||||
* disabled during speculative type-checking.
|
||||
*/
|
||||
JCTree attribSpeculative(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
|
||||
JCTree attribSpeculative(JCTree tree,
|
||||
Env<AttrContext> env,
|
||||
ResultInfo resultInfo,
|
||||
Annotate.PositionCreator creator) {
|
||||
final JCTree newTree = new TreeCopier<>(make).copy(tree);
|
||||
Env<AttrContext> speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared()));
|
||||
speculativeEnv.info.isSpeculative = true;
|
||||
speculativeEnv.info.scope.owner = env.info.scope.owner;
|
||||
Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
|
||||
new Log.DeferredDiagnosticHandler(log, new Filter<JCDiagnostic>() {
|
||||
@ -385,6 +399,9 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||
});
|
||||
try {
|
||||
attr.attribTree(newTree, speculativeEnv, resultInfo);
|
||||
annotate.typeAnnotateExprLater(newTree, speculativeEnv,
|
||||
speculativeEnv.info.scope.owner,
|
||||
newTree.pos(), creator);
|
||||
unenterScanner.scan(newTree);
|
||||
return newTree;
|
||||
} finally {
|
||||
@ -741,8 +758,11 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||
checkContext.report(null, ex.getDiagnostic());
|
||||
}
|
||||
Env<AttrContext> localEnv = env.dup(tree);
|
||||
JCExpression exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), localEnv,
|
||||
attr.memberReferenceQualifierResult(tree));
|
||||
JCExpression exprTree =
|
||||
(JCExpression)attribSpeculative(tree.getQualifierExpression(),
|
||||
localEnv,
|
||||
attr.memberReferenceQualifierResult(tree),
|
||||
annotate.methodRefCreator(tree.pos));
|
||||
ListBuffer<Type> argtypes = new ListBuffer<>();
|
||||
for (Type t : types.findDescriptorType(pt).getParameterTypes()) {
|
||||
argtypes.append(Type.noType);
|
||||
@ -1164,8 +1184,11 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||
public void visitReference(JCMemberReference tree) {
|
||||
//perform arity-based check
|
||||
Env<AttrContext> localEnv = env.dup(tree);
|
||||
JCExpression exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), localEnv,
|
||||
attr.memberReferenceQualifierResult(tree));
|
||||
JCExpression exprTree =
|
||||
(JCExpression)attribSpeculative(tree.getQualifierExpression(),
|
||||
localEnv,
|
||||
attr.memberReferenceQualifierResult(tree),
|
||||
annotate.methodRefCreator(tree.pos));
|
||||
JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree);
|
||||
mref2.expr = exprTree;
|
||||
Symbol res =
|
||||
@ -1309,7 +1332,7 @@ public class DeferredAttr extends JCTree.Visitor {
|
||||
return null;
|
||||
site = resolvedReturnType.type;
|
||||
} else {
|
||||
site = attribSpeculative(rec, env, attr.unknownTypeExprInfo).type;
|
||||
site = attribSpeculative(rec, env, attr.unknownTypeExprInfo, annotate.noCreator).type;
|
||||
}
|
||||
} else {
|
||||
site = env.enclClass.sym.type;
|
||||
|
@ -26,6 +26,7 @@
|
||||
package com.sun.tools.javac.comp;
|
||||
|
||||
import com.sun.tools.javac.tree.*;
|
||||
import com.sun.tools.javac.tree.JCTree.JCLambda;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
@ -156,4 +157,10 @@ 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;
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,9 @@ import com.sun.tools.javac.jvm.*;
|
||||
import com.sun.tools.javac.tree.*;
|
||||
import com.sun.tools.javac.util.*;
|
||||
|
||||
import com.sun.tools.javac.code.Type.*;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.code.Type.*;
|
||||
import com.sun.tools.javac.code.TypeAnnotationPosition.*;
|
||||
import com.sun.tools.javac.tree.JCTree.*;
|
||||
|
||||
import static com.sun.tools.javac.code.Flags.*;
|
||||
@ -75,7 +76,6 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
private final TreeMaker make;
|
||||
private final Todo todo;
|
||||
private final Annotate annotate;
|
||||
private final TypeAnnotations typeAnnotations;
|
||||
private final Types types;
|
||||
private final JCDiagnostic.Factory diags;
|
||||
private final Source source;
|
||||
@ -101,7 +101,6 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
make = TreeMaker.instance(context);
|
||||
todo = Todo.instance(context);
|
||||
annotate = Annotate.instance(context);
|
||||
typeAnnotations = TypeAnnotations.instance(context);
|
||||
types = Types.instance(context);
|
||||
diags = JCDiagnostic.Factory.instance(context);
|
||||
source = Source.instance(context);
|
||||
@ -131,6 +130,13 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
*/
|
||||
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 ----------------
|
||||
*/
|
||||
|
||||
@ -348,6 +354,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
}
|
||||
|
||||
/** Construct method type from method signature.
|
||||
* @param msym The MethodSymbol for the method.
|
||||
* @param typarams The method's type parameters.
|
||||
* @param params The method's value parameters.
|
||||
* @param res The method's result type,
|
||||
@ -356,33 +363,89 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
* null if none given; TODO: or already set here?
|
||||
* @param thrown The method's thrown exceptions.
|
||||
* @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(MethodSymbol msym,
|
||||
List<JCTypeParameter> typarams,
|
||||
List<JCVariableDecl> params,
|
||||
JCTree res,
|
||||
JCVariableDecl recvparam,
|
||||
List<JCExpression> thrown,
|
||||
Env<AttrContext> env) {
|
||||
Type signature(final MethodSymbol msym,
|
||||
final List<JCTypeParameter> typarams,
|
||||
final List<JCVariableDecl> params,
|
||||
final JCTree res,
|
||||
final JCVariableDecl recvparam,
|
||||
final List<JCExpression> thrown,
|
||||
final Env<AttrContext> env,
|
||||
final List<JCAnnotation> declAnnos,
|
||||
final DiagnosticPosition deferPos) {
|
||||
int i;
|
||||
|
||||
// Enter and attribute type parameters.
|
||||
List<Type> tvars = enter.classEnter(typarams, env);
|
||||
attr.attribTypeVariables(typarams, env);
|
||||
|
||||
// Enter and attribute value parameters.
|
||||
// Handle type annotations on type 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<>();
|
||||
for (List<JCVariableDecl> l = params; l.nonEmpty(); l = l.tail) {
|
||||
memberEnter(l.head, env);
|
||||
i = 0;
|
||||
for (List<JCVariableDecl> l = params; l.nonEmpty(); l = l.tail, i++) {
|
||||
// The types will get annotated by visitVarDef
|
||||
memberEnter(l.head, env, annotate.paramCreator(i));
|
||||
argbuf.append(l.head.vartype.type);
|
||||
}
|
||||
|
||||
// Attribute result type, if one is given.
|
||||
Type restype = res == null ? syms.voidType : attr.attribType(res, env);
|
||||
Type restype;
|
||||
|
||||
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.
|
||||
Type recvtype;
|
||||
if (recvparam!=null) {
|
||||
memberEnter(recvparam, env);
|
||||
// The type will get annotated by visitVarDef
|
||||
memberEnter(recvparam, env, annotate.receiverCreator);
|
||||
recvtype = recvparam.vartype.type;
|
||||
} else {
|
||||
recvtype = null;
|
||||
@ -390,8 +453,12 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
|
||||
// Attribute thrown exceptions.
|
||||
ListBuffer<Type> thrownbuf = new ListBuffer<>();
|
||||
for (List<JCExpression> l = thrown; l.nonEmpty(); l = l.tail) {
|
||||
i = 0;
|
||||
for (List<JCExpression> l = thrown; l.nonEmpty(); l = l.tail, i++) {
|
||||
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)) {
|
||||
exc = chk.checkClassType(l.head.pos(), exc);
|
||||
} else if (exc.tsym.owner == msym) {
|
||||
@ -420,33 +487,49 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
/** Enter field and method definitions and process import
|
||||
* 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;
|
||||
Annotate.PositionCreator prevCreator = this.creator;
|
||||
try {
|
||||
this.env = env;
|
||||
this.creator = creator;
|
||||
tree.accept(this);
|
||||
} catch (CompletionFailure ex) {
|
||||
chk.completionError(tree.pos(), ex);
|
||||
} finally {
|
||||
this.creator = prevCreator;
|
||||
this.env = prevEnv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void memberEnter(JCTree tree, Env<AttrContext> env) {
|
||||
memberEnter(tree, env, annotate.noCreator);
|
||||
}
|
||||
|
||||
/** Enter members from a list of trees.
|
||||
*/
|
||||
void memberEnter(List<? extends JCTree> trees, Env<AttrContext> env) {
|
||||
void memberEnter(List<? extends JCTree> trees,
|
||||
Env<AttrContext> env,
|
||||
Annotate.PositionCreator creator) {
|
||||
for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail)
|
||||
memberEnter(l.head, env);
|
||||
memberEnter(l.head, env, creator);
|
||||
}
|
||||
|
||||
void memberEnter(List<? extends JCTree> trees,
|
||||
Env<AttrContext> env) {
|
||||
memberEnter(trees, env, annotate.noCreator);
|
||||
}
|
||||
|
||||
/** Enter members for a class.
|
||||
*/
|
||||
void finishClass(JCClassDecl tree, Env<AttrContext> env) {
|
||||
void finishClass(final JCClassDecl tree, final Env<AttrContext> env) {
|
||||
if ((tree.mods.flags & Flags.ENUM) != 0 &&
|
||||
(types.supertype(tree.sym.type).tsym.flags() & Flags.ENUM) == 0) {
|
||||
addEnumMembers(tree, env);
|
||||
}
|
||||
memberEnter(tree.defs, env);
|
||||
memberEnter(tree.defs, env, annotate.fieldCreator);
|
||||
}
|
||||
|
||||
/** Add the implicit members for an enum type
|
||||
@ -521,7 +604,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
}
|
||||
}
|
||||
// process package annotations
|
||||
annotate.annotateLater(tree.annotations, env, env.toplevel.packge, null);
|
||||
annotate.annotateLater(tree.annotations, env, env.toplevel.packge);
|
||||
}
|
||||
|
||||
// process the non-static imports and the static imports of types.
|
||||
@ -567,15 +650,13 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
|
||||
Env<AttrContext> localEnv = methodEnv(tree, env);
|
||||
|
||||
annotate.enterStart();
|
||||
try {
|
||||
DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
|
||||
try {
|
||||
// Compute the method type
|
||||
m.type = signature(m, tree.typarams, tree.params,
|
||||
tree.restype, tree.recvparam,
|
||||
tree.thrown,
|
||||
localEnv);
|
||||
tree.thrown, localEnv,
|
||||
tree.mods.annotations, tree.pos());
|
||||
} finally {
|
||||
deferredLintHandler.setPos(prevLintPos);
|
||||
}
|
||||
@ -602,16 +683,9 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
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)
|
||||
annotateDefaultValueLater(tree.defaultValue, localEnv, m);
|
||||
} finally {
|
||||
annotate.enterDone();
|
||||
}
|
||||
annotateDefaultValueLater(tree.defaultValue, localEnv,
|
||||
m, annotate.noCreator);
|
||||
}
|
||||
|
||||
/** Create a fresh environment for method bodies.
|
||||
@ -646,22 +720,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype);
|
||||
} else {
|
||||
attr.attribType(tree.vartype, localEnv);
|
||||
if (tree.nameexpr != null) {
|
||||
attr.attribExpr(tree.nameexpr, localEnv);
|
||||
MethodSymbol m = localEnv.enclMethod.sym;
|
||||
if (m.isConstructor()) {
|
||||
Type outertype = m.owner.owner.type;
|
||||
if (outertype.hasTag(TypeTag.CLASS)) {
|
||||
checkType(tree.vartype, outertype, "incorrect.constructor.receiver.type");
|
||||
checkType(tree.nameexpr, outertype, "incorrect.constructor.receiver.name");
|
||||
} else {
|
||||
log.error(tree, "receiver.parameter.not.applicable.constructor.toplevel.class");
|
||||
}
|
||||
} else {
|
||||
checkType(tree.vartype, m.owner.type, "incorrect.receiver.type");
|
||||
checkType(tree.nameexpr, m.owner.type, "incorrect.receiver.name");
|
||||
}
|
||||
}
|
||||
if (TreeInfo.isReceiverParam(tree))
|
||||
checkReceiver(tree, localEnv);
|
||||
}
|
||||
} finally {
|
||||
deferredLintHandler.setPos(prevLintPos);
|
||||
@ -695,8 +755,18 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
chk.checkTransparentVar(tree.pos(), v, enclScope);
|
||||
enclScope.enter(v);
|
||||
}
|
||||
annotate.annotateLater(tree.mods.annotations, localEnv, v, tree.pos());
|
||||
annotate.annotateTypeLater(tree.vartype, env, v, tree.pos());
|
||||
if (TreeInfo.isReceiverParam(tree)) {
|
||||
// If we are dealing with a receiver parameter, then
|
||||
// we only allow base type annotations to be type
|
||||
// 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;
|
||||
} finally {
|
||||
annotate.enterDone();
|
||||
@ -708,6 +778,26 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
log.error(tree, diag, type, tree.type);
|
||||
}
|
||||
}
|
||||
void checkReceiver(JCVariableDecl tree, Env<AttrContext> localEnv) {
|
||||
attr.attribExpr(tree.nameexpr, localEnv);
|
||||
MethodSymbol m = localEnv.enclMethod.sym;
|
||||
if (m.isConstructor()) {
|
||||
Type outertype = m.owner.owner.type;
|
||||
if (outertype.hasTag(TypeTag.METHOD)) {
|
||||
// we have a local inner class
|
||||
outertype = m.owner.owner.owner.type;
|
||||
}
|
||||
if (outertype.hasTag(TypeTag.CLASS)) {
|
||||
checkType(tree.vartype, outertype, "incorrect.constructor.receiver.type");
|
||||
checkType(tree.nameexpr, outertype, "incorrect.constructor.receiver.name");
|
||||
} else {
|
||||
log.error(tree, "receiver.parameter.not.applicable.constructor.toplevel.class");
|
||||
}
|
||||
} else {
|
||||
checkType(tree.vartype, m.owner.type, "incorrect.receiver.type");
|
||||
checkType(tree.nameexpr, m.owner.type, "incorrect.receiver.name");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean needsLazyConstValue(JCTree tree) {
|
||||
InitTreeVisitor initTreeVisitor = new InitTreeVisitor();
|
||||
@ -849,7 +939,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
/** Queue processing of an attribute default value. */
|
||||
void annotateDefaultValueLater(final JCExpression defaultValue,
|
||||
final Env<AttrContext> localEnv,
|
||||
final MethodSymbol m) {
|
||||
final MethodSymbol m,
|
||||
final Annotate.PositionCreator creator) {
|
||||
annotate.normal(new Annotate.Worker() {
|
||||
@Override
|
||||
public String toString() {
|
||||
@ -936,22 +1027,44 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
// create an environment for evaluating the base clauses
|
||||
Env<AttrContext> baseEnv = baseEnv(tree, env);
|
||||
|
||||
if (tree.extending != null)
|
||||
annotate.annotateTypeLater(tree.extending, baseEnv, sym, tree.pos());
|
||||
for (JCExpression impl : tree.implementing)
|
||||
annotate.annotateTypeLater(impl, baseEnv, sym, tree.pos());
|
||||
annotate.flush();
|
||||
// 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;
|
||||
|
||||
// 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.
|
||||
Type supertype =
|
||||
(tree.extending != null)
|
||||
? attr.attribBase(tree.extending, baseEnv, true, false, true)
|
||||
: ((tree.mods.flags & Flags.ENUM) != 0)
|
||||
Type supertype;
|
||||
|
||||
if (tree.extending != null) {
|
||||
supertype = attr.attribBase(tree.extending, baseEnv,
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
supertype = ((tree.mods.flags & Flags.ENUM) != 0)
|
||||
? attr.attribBase(enumBase(tree.pos, c), baseEnv,
|
||||
true, false, false)
|
||||
: (c.fullname == names.java_lang_Object)
|
||||
? Type.noType
|
||||
: syms.objectType;
|
||||
}
|
||||
ct.supertype_field = modelMissingTypes(supertype, tree.extending, false);
|
||||
|
||||
// Determine interfaces.
|
||||
@ -959,18 +1072,33 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
ListBuffer<Type> all_interfaces = null; // lazy init
|
||||
Set<Type> interfaceSet = new HashSet<>();
|
||||
List<JCExpression> interfaceTrees = tree.implementing;
|
||||
int i = 0;
|
||||
for (JCExpression iface : interfaceTrees) {
|
||||
Type i = attr.attribBase(iface, baseEnv, false, true, true);
|
||||
if (i.hasTag(CLASS)) {
|
||||
interfaces.append(i);
|
||||
if (all_interfaces != null) all_interfaces.append(i);
|
||||
chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet);
|
||||
Type it = attr.attribBase(iface, baseEnv, false, true, true);
|
||||
if (it.hasTag(CLASS)) {
|
||||
interfaces.append(it);
|
||||
if (all_interfaces != null) all_interfaces.append(it);
|
||||
chk.checkNotRepeated(iface.pos(), types.erasure(it), interfaceSet);
|
||||
} else {
|
||||
if (all_interfaces == null)
|
||||
all_interfaces = new ListBuffer<Type>().appendList(interfaces);
|
||||
all_interfaces.append(modelMissingTypes(i, 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++));
|
||||
}
|
||||
}
|
||||
|
||||
if ((c.flags_field & ANNOTATION) != 0) {
|
||||
ct.interfaces_field = List.of(syms.annotationType);
|
||||
ct.all_interfaces_field = ct.interfaces_field;
|
||||
@ -993,22 +1121,28 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
}
|
||||
}
|
||||
|
||||
// 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());
|
||||
// class type parameters use baseEnv but everything uses env
|
||||
|
||||
chk.checkNonCyclicDecl(tree);
|
||||
|
||||
attr.attribTypeVariables(tree.typarams, baseEnv);
|
||||
// Do this here, where we have the symbol.
|
||||
for (JCTypeParameter tp : tree.typarams)
|
||||
annotate.annotateTypeLater(tp, baseEnv, sym, tree.pos());
|
||||
int j = 0;
|
||||
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.
|
||||
if ((c.flags() & INTERFACE) == 0 &&
|
||||
@ -1088,10 +1222,6 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
while (halfcompleted.nonEmpty()) {
|
||||
Env<AttrContext> toFinish = halfcompleted.next();
|
||||
finish(toFinish);
|
||||
if (allowTypeAnnos) {
|
||||
typeAnnotations.organizeTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree);
|
||||
typeAnnotations.validateTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
isFirst = true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -158,11 +158,6 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||
symbolFileEnabled = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultBootClassPath() {
|
||||
return locations.isDefaultBootClassPath();
|
||||
}
|
||||
|
||||
public JavaFileObject getFileForInput(String name) {
|
||||
return getRegularFile(new File(name));
|
||||
}
|
||||
@ -579,15 +574,6 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||
}
|
||||
}
|
||||
|
||||
private String defaultEncodingName;
|
||||
private String getDefaultEncodingName() {
|
||||
if (defaultEncodingName == null) {
|
||||
defaultEncodingName =
|
||||
new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding();
|
||||
}
|
||||
return defaultEncodingName;
|
||||
}
|
||||
|
||||
public ClassLoader getClassLoader(Location location) {
|
||||
nullCheck(location);
|
||||
Iterable<? extends File> path = getLocation(location);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -22,12 +22,10 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.javac.file;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Iterator;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
@ -38,64 +36,72 @@ import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileManager.Location;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.StandardLocation;
|
||||
|
||||
import com.sun.tools.javac.code.Lint;
|
||||
import com.sun.tools.javac.main.Option;
|
||||
import com.sun.tools.javac.util.ListBuffer;
|
||||
import com.sun.tools.javac.util.Log;
|
||||
import com.sun.tools.javac.util.Options;
|
||||
import com.sun.tools.javac.util.StringUtils;
|
||||
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import static javax.tools.StandardLocation.*;
|
||||
import static com.sun.tools.javac.main.Option.*;
|
||||
import static javax.tools.StandardLocation.CLASS_PATH;
|
||||
import static javax.tools.StandardLocation.PLATFORM_CLASS_PATH;
|
||||
import static javax.tools.StandardLocation.SOURCE_PATH;
|
||||
|
||||
/** This class converts command line arguments, environment variables
|
||||
* and system properties (in File.pathSeparator-separated String form)
|
||||
* into a boot class path, user class path, and source path (in
|
||||
* {@code Collection<String>} form).
|
||||
import static com.sun.tools.javac.main.Option.BOOTCLASSPATH;
|
||||
import static com.sun.tools.javac.main.Option.DJAVA_ENDORSED_DIRS;
|
||||
import static com.sun.tools.javac.main.Option.DJAVA_EXT_DIRS;
|
||||
import static com.sun.tools.javac.main.Option.ENDORSEDDIRS;
|
||||
import static com.sun.tools.javac.main.Option.EXTDIRS;
|
||||
import static com.sun.tools.javac.main.Option.XBOOTCLASSPATH;
|
||||
import static com.sun.tools.javac.main.Option.XBOOTCLASSPATH_APPEND;
|
||||
import static com.sun.tools.javac.main.Option.XBOOTCLASSPATH_PREPEND;
|
||||
|
||||
/**
|
||||
* This class converts command line arguments, environment variables and system properties (in
|
||||
* File.pathSeparator-separated String form) into a boot class path, user class path, and source
|
||||
* path (in {@code Collection<String>} form).
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
* <p>
|
||||
* <b>This is NOT part of any supported API. If you write code that depends on this, you do so at
|
||||
* your own risk. This code and its internal interfaces are subject to change or deletion without
|
||||
* notice.</b>
|
||||
*/
|
||||
public class Locations {
|
||||
|
||||
/** The log to use for warning output */
|
||||
/**
|
||||
* The log to use for warning output
|
||||
*/
|
||||
private Log log;
|
||||
|
||||
/** Collection of command-line options */
|
||||
private Options options;
|
||||
|
||||
/** Handler for -Xlint options */
|
||||
private Lint lint;
|
||||
|
||||
/** Access to (possibly cached) file info */
|
||||
/**
|
||||
* Access to (possibly cached) file info
|
||||
*/
|
||||
private FSInfo fsInfo;
|
||||
|
||||
/** Whether to warn about non-existent path elements */
|
||||
/**
|
||||
* Whether to warn about non-existent path elements
|
||||
*/
|
||||
private boolean warn;
|
||||
|
||||
// TODO: remove need for this
|
||||
private boolean inited = false; // TODO? caching bad?
|
||||
|
||||
public Locations() {
|
||||
initHandlers();
|
||||
}
|
||||
|
||||
public void update(Log log, Options options, Lint lint, FSInfo fsInfo) {
|
||||
// could replace Lint by "boolean warn"
|
||||
public void update(Log log, Lint lint, FSInfo fsInfo) {
|
||||
this.log = log;
|
||||
this.options = options;
|
||||
this.lint = lint;
|
||||
warn = lint.isEnabled(Lint.LintCategory.PATH);
|
||||
this.fsInfo = fsInfo;
|
||||
}
|
||||
|
||||
@ -104,14 +110,14 @@ public class Locations {
|
||||
}
|
||||
|
||||
public boolean isDefaultBootClassPath() {
|
||||
BootClassPathLocationHandler h =
|
||||
(BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH);
|
||||
BootClassPathLocationHandler h
|
||||
= (BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH);
|
||||
return h.isDefault();
|
||||
}
|
||||
|
||||
boolean isDefaultBootClassPathRtJar(File file) {
|
||||
BootClassPathLocationHandler h =
|
||||
(BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH);
|
||||
BootClassPathLocationHandler h
|
||||
= (BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH);
|
||||
return h.isDefaultRtJar(file);
|
||||
}
|
||||
|
||||
@ -127,6 +133,7 @@ public class Locations {
|
||||
|
||||
/**
|
||||
* Split a path into its elements. Empty path elements will be ignored.
|
||||
*
|
||||
* @param path The path to be split
|
||||
* @return The elements of the path
|
||||
*/
|
||||
@ -135,12 +142,13 @@ public class Locations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a path into its elements. If emptyPathDefault is not null, all
|
||||
* empty elements in the path, including empty elements at either end of
|
||||
* the path, will be replaced with the value of emptyPathDefault.
|
||||
* Split a path into its elements. If emptyPathDefault is not null, all empty elements in the
|
||||
* path, including empty elements at either end of the path, will be replaced with the value of
|
||||
* emptyPathDefault.
|
||||
*
|
||||
* @param path The path to be split
|
||||
* @param emptyPathDefault The value to substitute for empty path elements,
|
||||
* or null, to ignore empty path elements
|
||||
* @param emptyPathDefault The value to substitute for empty path elements, or null, to ignore
|
||||
* empty path elements
|
||||
* @return The elements of the path
|
||||
*/
|
||||
private static Iterable<File> getPathEntries(String path, File emptyPathDefault) {
|
||||
@ -148,33 +156,38 @@ public class Locations {
|
||||
int start = 0;
|
||||
while (start <= path.length()) {
|
||||
int sep = path.indexOf(File.pathSeparatorChar, start);
|
||||
if (sep == -1)
|
||||
if (sep == -1) {
|
||||
sep = path.length();
|
||||
if (start < sep)
|
||||
}
|
||||
if (start < sep) {
|
||||
entries.add(new File(path.substring(start, sep)));
|
||||
else if (emptyPathDefault != null)
|
||||
} else if (emptyPathDefault != null) {
|
||||
entries.add(emptyPathDefault);
|
||||
}
|
||||
start = sep + 1;
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility class to help evaluate a path option.
|
||||
* Duplicate entries are ignored, jar class paths can be expanded.
|
||||
* Utility class to help evaluate a path option. Duplicate entries are ignored, jar class paths
|
||||
* can be expanded.
|
||||
*/
|
||||
private class Path extends LinkedHashSet<File> {
|
||||
|
||||
private static final long serialVersionUID = 0;
|
||||
|
||||
private boolean expandJarClassPaths = false;
|
||||
private Set<File> canonicalValues = new HashSet<>();
|
||||
private final Set<File> canonicalValues = new HashSet<>();
|
||||
|
||||
public Path expandJarClassPaths(boolean x) {
|
||||
expandJarClassPaths = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** What to use when path element is the empty string */
|
||||
/**
|
||||
* What to use when path element is the empty string
|
||||
*/
|
||||
private File emptyPathDefault = null;
|
||||
|
||||
public Path emptyPathDefault(File x) {
|
||||
@ -182,15 +195,15 @@ public class Locations {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Path() { super(); }
|
||||
|
||||
public Path addDirectories(String dirs, boolean warn) {
|
||||
boolean prev = expandJarClassPaths;
|
||||
expandJarClassPaths = true;
|
||||
try {
|
||||
if (dirs != null)
|
||||
for (File dir : getPathEntries(dirs))
|
||||
if (dirs != null) {
|
||||
for (File dir : getPathEntries(dirs)) {
|
||||
addDirectory(dir, warn);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
} finally {
|
||||
expandJarClassPaths = prev;
|
||||
@ -203,19 +216,22 @@ public class Locations {
|
||||
|
||||
private void addDirectory(File dir, boolean warn) {
|
||||
if (!dir.isDirectory()) {
|
||||
if (warn)
|
||||
if (warn) {
|
||||
log.warning(Lint.LintCategory.PATH,
|
||||
"dir.path.element.not.found", dir);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
File[] files = dir.listFiles();
|
||||
if (files == null)
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File direntry : files) {
|
||||
if (isArchive(direntry))
|
||||
if (isArchive(direntry)) {
|
||||
addFile(direntry, warn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,8 +248,9 @@ public class Locations {
|
||||
|
||||
public Path addFiles(Iterable<? extends File> files, boolean warn) {
|
||||
if (files != null) {
|
||||
for (File file: files)
|
||||
for (File file : files) {
|
||||
addFile(file, warn);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -248,7 +265,7 @@ public class Locations {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! fsInfo.exists(file)) {
|
||||
if (!fsInfo.exists(file)) {
|
||||
/* No such file or directory exists */
|
||||
if (warn) {
|
||||
log.warning(Lint.LintCategory.PATH,
|
||||
@ -288,12 +305,13 @@ public class Locations {
|
||||
}
|
||||
|
||||
/* Now what we have left is either a directory or a file name
|
||||
conforming to archive naming convention */
|
||||
conforming to archive naming convention */
|
||||
super.add(file);
|
||||
canonicalValues.add(canonFile);
|
||||
|
||||
if (expandJarClassPaths && fsInfo.isFile(file))
|
||||
if (expandJarClassPaths && fsInfo.isFile(file)) {
|
||||
addJarClassPath(file, warn);
|
||||
}
|
||||
}
|
||||
|
||||
// Adds referenced classpath elements from a jar's Class-Path
|
||||
@ -302,7 +320,7 @@ public class Locations {
|
||||
// filenames, but if we do, we should redo all path-related code.
|
||||
private void addJarClassPath(File jarFile, boolean warn) {
|
||||
try {
|
||||
for (File f: fsInfo.getJarClassPath(jarFile)) {
|
||||
for (File f : fsInfo.getJarClassPath(jarFile)) {
|
||||
addFile(f, warn);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -312,53 +330,56 @@ public class Locations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for handling support for the representation of Locations.
|
||||
* Implementations are responsible for handling the interactions between
|
||||
* the command line options for a location, and API access via setLocation.
|
||||
* Base class for handling support for the representation of Locations. Implementations are
|
||||
* responsible for handling the interactions between the command line options for a location,
|
||||
* and API access via setLocation.
|
||||
*
|
||||
* @see #initHandlers
|
||||
* @see #getHandler
|
||||
*/
|
||||
protected abstract class LocationHandler {
|
||||
|
||||
final Location location;
|
||||
final Set<Option> options;
|
||||
|
||||
/**
|
||||
* Create a handler. The location and options provide a way to map
|
||||
* from a location or an option to the corresponding handler.
|
||||
* Create a handler. The location and options provide a way to map from a location or an
|
||||
* option to the corresponding handler.
|
||||
*
|
||||
* @param location the location for which this is the handler
|
||||
* @param options the options affecting this location
|
||||
* @see #initHandlers
|
||||
*/
|
||||
protected LocationHandler(Location location, Option... options) {
|
||||
this.location = location;
|
||||
this.options = options.length == 0 ?
|
||||
EnumSet.noneOf(Option.class):
|
||||
EnumSet.copyOf(Arrays.asList(options));
|
||||
this.options = options.length == 0
|
||||
? EnumSet.noneOf(Option.class)
|
||||
: EnumSet.copyOf(Arrays.asList(options));
|
||||
}
|
||||
|
||||
// TODO: TEMPORARY, while Options still used for command line options
|
||||
void update(Options optionTable) {
|
||||
for (Option o: options) {
|
||||
String v = optionTable.get(o);
|
||||
if (v != null) {
|
||||
handleOption(o, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @see JavaFileManager#handleOption */
|
||||
/**
|
||||
* @see JavaFileManager#handleOption
|
||||
*/
|
||||
abstract boolean handleOption(Option option, String value);
|
||||
/** @see StandardJavaFileManager#getLocation */
|
||||
|
||||
/**
|
||||
* @see StandardJavaFileManager#getLocation
|
||||
*/
|
||||
abstract Collection<File> getLocation();
|
||||
/** @see StandardJavaFileManager#setLocation */
|
||||
|
||||
/**
|
||||
* @see StandardJavaFileManager#setLocation
|
||||
*/
|
||||
abstract void setLocation(Iterable<? extends File> files) throws IOException;
|
||||
}
|
||||
|
||||
/**
|
||||
* General purpose implementation for output locations,
|
||||
* such as -d/CLASS_OUTPUT and -s/SOURCE_OUTPUT.
|
||||
* All options are treated as equivalent (i.e. aliases.)
|
||||
* The value is a single file, possibly null.
|
||||
* General purpose implementation for output locations, such as -d/CLASS_OUTPUT and
|
||||
* -s/SOURCE_OUTPUT. All options are treated as equivalent (i.e. aliases.) The value is a single
|
||||
* file, possibly null.
|
||||
*/
|
||||
private class OutputLocationHandler extends LocationHandler {
|
||||
|
||||
private File outputDir;
|
||||
|
||||
OutputLocationHandler(Location location, Option... options) {
|
||||
@ -367,14 +388,15 @@ public class Locations {
|
||||
|
||||
@Override
|
||||
boolean handleOption(Option option, String value) {
|
||||
if (!options.contains(option))
|
||||
if (!options.contains(option)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: could/should validate outputDir exists and is a directory
|
||||
// need to decide how best to report issue for benefit of
|
||||
// direct API call on JavaFileManager.handleOption(specifies IAE)
|
||||
// vs. command line decoding.
|
||||
outputDir = new File(value);
|
||||
outputDir = (value == null) ? null : new File(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -389,27 +411,30 @@ public class Locations {
|
||||
outputDir = null;
|
||||
} else {
|
||||
Iterator<? extends File> pathIter = files.iterator();
|
||||
if (!pathIter.hasNext())
|
||||
if (!pathIter.hasNext()) {
|
||||
throw new IllegalArgumentException("empty path for directory");
|
||||
}
|
||||
File dir = pathIter.next();
|
||||
if (pathIter.hasNext())
|
||||
if (pathIter.hasNext()) {
|
||||
throw new IllegalArgumentException("path too long for directory");
|
||||
if (!dir.exists())
|
||||
}
|
||||
if (!dir.exists()) {
|
||||
throw new FileNotFoundException(dir + ": does not exist");
|
||||
else if (!dir.isDirectory())
|
||||
} else if (!dir.isDirectory()) {
|
||||
throw new IOException(dir + ": not a directory");
|
||||
}
|
||||
outputDir = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* General purpose implementation for search path locations,
|
||||
* such as -sourcepath/SOURCE_PATH and -processorPath/ANNOTATION_PROCESS_PATH.
|
||||
* All options are treated as equivalent (i.e. aliases.)
|
||||
* General purpose implementation for search path locations, such as -sourcepath/SOURCE_PATH and
|
||||
* -processorPath/ANNOTATION_PROCESS_PATH. All options are treated as equivalent (i.e. aliases.)
|
||||
* The value is an ordered set of files and/or directories.
|
||||
*/
|
||||
private class SimpleLocationHandler extends LocationHandler {
|
||||
|
||||
protected Collection<File> searchPath;
|
||||
|
||||
SimpleLocationHandler(Location location, Option... options) {
|
||||
@ -418,10 +443,11 @@ public class Locations {
|
||||
|
||||
@Override
|
||||
boolean handleOption(Option option, String value) {
|
||||
if (!options.contains(option))
|
||||
if (!options.contains(option)) {
|
||||
return false;
|
||||
searchPath = value == null ? null :
|
||||
Collections.unmodifiableCollection(createPath().addFiles(value));
|
||||
}
|
||||
searchPath = value == null ? null
|
||||
: Collections.unmodifiableCollection(createPath().addFiles(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -451,11 +477,11 @@ public class Locations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtype of SimpleLocationHandler for -classpath/CLASS_PATH.
|
||||
* If no value is given, a default is provided, based on system properties
|
||||
* and other values.
|
||||
* Subtype of SimpleLocationHandler for -classpath/CLASS_PATH. If no value is given, a default
|
||||
* is provided, based on system properties and other values.
|
||||
*/
|
||||
private class ClassPathLocationHandler extends SimpleLocationHandler {
|
||||
|
||||
ClassPathLocationHandler() {
|
||||
super(StandardLocation.CLASS_PATH,
|
||||
Option.CLASSPATH, Option.CP);
|
||||
@ -472,15 +498,20 @@ public class Locations {
|
||||
String cp = value;
|
||||
|
||||
// CLASSPATH environment variable when run from `javac'.
|
||||
if (cp == null) cp = System.getProperty("env.class.path");
|
||||
if (cp == null) {
|
||||
cp = System.getProperty("env.class.path");
|
||||
}
|
||||
|
||||
// If invoked via a java VM (not the javac launcher), use the
|
||||
// platform class path
|
||||
if (cp == null && System.getProperty("application.home") == null)
|
||||
if (cp == null && System.getProperty("application.home") == null) {
|
||||
cp = System.getProperty("java.class.path");
|
||||
}
|
||||
|
||||
// Default to current working directory.
|
||||
if (cp == null) cp = ".";
|
||||
if (cp == null) {
|
||||
cp = ".";
|
||||
}
|
||||
|
||||
return createPath().addFiles(cp);
|
||||
}
|
||||
@ -488,38 +519,37 @@ public class Locations {
|
||||
@Override
|
||||
protected Path createPath() {
|
||||
return new Path()
|
||||
.expandJarClassPaths(true) // Only search user jars for Class-Paths
|
||||
.emptyPathDefault(new File(".")); // Empty path elt ==> current directory
|
||||
.expandJarClassPaths(true) // Only search user jars for Class-Paths
|
||||
.emptyPathDefault(new File(".")); // Empty path elt ==> current directory
|
||||
}
|
||||
|
||||
private void lazy() {
|
||||
if (searchPath == null)
|
||||
if (searchPath == null) {
|
||||
setLocation(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom subtype of LocationHandler for PLATFORM_CLASS_PATH.
|
||||
* Various options are supported for different components of the
|
||||
* platform class path.
|
||||
* Setting a value with setLocation overrides all existing option values.
|
||||
* Setting any option overrides any value set with setLocation, and reverts
|
||||
* to using default values for options that have not been set.
|
||||
* Setting -bootclasspath or -Xbootclasspath overrides any existing
|
||||
* value for -Xbootclasspath/p: and -Xbootclasspath/a:.
|
||||
* Custom subtype of LocationHandler for PLATFORM_CLASS_PATH. Various options are supported for
|
||||
* different components of the platform class path. Setting a value with setLocation overrides
|
||||
* all existing option values. Setting any option overrides any value set with setLocation, and
|
||||
* reverts to using default values for options that have not been set. Setting -bootclasspath or
|
||||
* -Xbootclasspath overrides any existing value for -Xbootclasspath/p: and -Xbootclasspath/a:.
|
||||
*/
|
||||
private class BootClassPathLocationHandler extends LocationHandler {
|
||||
|
||||
private Collection<File> searchPath;
|
||||
final Map<Option, String> optionValues = new EnumMap<>(Option.class);
|
||||
|
||||
/**
|
||||
* rt.jar as found on the default bootclasspath.
|
||||
* If the user specified a bootclasspath, null is used.
|
||||
* rt.jar as found on the default bootclasspath. If the user specified a bootclasspath, null
|
||||
* is used.
|
||||
*/
|
||||
private File defaultBootClassPathRtJar = null;
|
||||
|
||||
/**
|
||||
* Is bootclasspath the default?
|
||||
* Is bootclasspath the default?
|
||||
*/
|
||||
private boolean isDefaultBootClassPath;
|
||||
|
||||
@ -544,8 +574,9 @@ public class Locations {
|
||||
|
||||
@Override
|
||||
boolean handleOption(Option option, String value) {
|
||||
if (!options.contains(option))
|
||||
if (!options.contains(option)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
option = canonicalize(option);
|
||||
optionValues.put(option, value);
|
||||
@ -557,20 +588,20 @@ public class Locations {
|
||||
return true;
|
||||
}
|
||||
// where
|
||||
// TODO: would be better if option aliasing was handled at a higher
|
||||
// level
|
||||
private Option canonicalize(Option option) {
|
||||
switch (option) {
|
||||
case XBOOTCLASSPATH:
|
||||
return Option.BOOTCLASSPATH;
|
||||
case DJAVA_ENDORSED_DIRS:
|
||||
return Option.ENDORSEDDIRS;
|
||||
case DJAVA_EXT_DIRS:
|
||||
return Option.EXTDIRS;
|
||||
default:
|
||||
return option;
|
||||
}
|
||||
// TODO: would be better if option aliasing was handled at a higher
|
||||
// level
|
||||
private Option canonicalize(Option option) {
|
||||
switch (option) {
|
||||
case XBOOTCLASSPATH:
|
||||
return Option.BOOTCLASSPATH;
|
||||
case DJAVA_ENDORSED_DIRS:
|
||||
return Option.ENDORSEDDIRS;
|
||||
case DJAVA_EXT_DIRS:
|
||||
return Option.EXTDIRS;
|
||||
default:
|
||||
return option;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
Collection<File> getLocation() {
|
||||
@ -602,10 +633,11 @@ public class Locations {
|
||||
String xbootclasspathAppendOpt = optionValues.get(XBOOTCLASSPATH_APPEND);
|
||||
path.addFiles(xbootclasspathPrependOpt);
|
||||
|
||||
if (endorseddirsOpt != null)
|
||||
if (endorseddirsOpt != null) {
|
||||
path.addDirectories(endorseddirsOpt);
|
||||
else
|
||||
} else {
|
||||
path.addDirectories(System.getProperty("java.endorsed.dirs"), false);
|
||||
}
|
||||
|
||||
if (bootclasspathOpt != null) {
|
||||
path.addFiles(bootclasspathOpt);
|
||||
@ -615,8 +647,9 @@ public class Locations {
|
||||
path.addFiles(files, false);
|
||||
File rt_jar = new File("rt.jar");
|
||||
for (File file : getPathEntries(files)) {
|
||||
if (new File(file.getName()).equals(rt_jar))
|
||||
if (new File(file.getName()).equals(rt_jar)) {
|
||||
defaultBootClassPathRtJar = file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -625,22 +658,24 @@ public class Locations {
|
||||
// Strictly speaking, standard extensions are not bootstrap
|
||||
// classes, but we treat them identically, so we'll pretend
|
||||
// that they are.
|
||||
if (extdirsOpt != null)
|
||||
if (extdirsOpt != null) {
|
||||
path.addDirectories(extdirsOpt);
|
||||
else
|
||||
} else {
|
||||
path.addDirectories(System.getProperty("java.ext.dirs"), false);
|
||||
}
|
||||
|
||||
isDefaultBootClassPath =
|
||||
(xbootclasspathPrependOpt == null) &&
|
||||
(bootclasspathOpt == null) &&
|
||||
(xbootclasspathAppendOpt == null);
|
||||
isDefaultBootClassPath
|
||||
= (xbootclasspathPrependOpt == null)
|
||||
&& (bootclasspathOpt == null)
|
||||
&& (xbootclasspathAppendOpt == null);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
private void lazy() {
|
||||
if (searchPath == null)
|
||||
if (searchPath == null) {
|
||||
searchPath = Collections.unmodifiableCollection(computePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -661,14 +696,15 @@ public class Locations {
|
||||
new OutputLocationHandler((StandardLocation.NATIVE_HEADER_OUTPUT), Option.H)
|
||||
};
|
||||
|
||||
for (LocationHandler h: handlers) {
|
||||
for (LocationHandler h : handlers) {
|
||||
handlersForLocation.put(h.location, h);
|
||||
for (Option o: h.options)
|
||||
for (Option o : h.options) {
|
||||
handlersForOption.put(o, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean handleOption(Option option, String value) {
|
||||
public boolean handleOption(Option option, String value) {
|
||||
LocationHandler h = handlersForOption.get(option);
|
||||
return (h == null ? false : h.handleOption(option, value));
|
||||
}
|
||||
@ -679,8 +715,9 @@ public class Locations {
|
||||
}
|
||||
|
||||
File getOutputLocation(Location location) {
|
||||
if (!location.isOutputLocation())
|
||||
if (!location.isOutputLocation()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
LocationHandler h = getHandler(location);
|
||||
return ((OutputLocationHandler) h).outputDir;
|
||||
}
|
||||
@ -688,10 +725,11 @@ public class Locations {
|
||||
void setLocation(Location location, Iterable<? extends File> files) throws IOException {
|
||||
LocationHandler h = getHandler(location);
|
||||
if (h == null) {
|
||||
if (location.isOutputLocation())
|
||||
if (location.isOutputLocation()) {
|
||||
h = new OutputLocationHandler(location);
|
||||
else
|
||||
} else {
|
||||
h = new SimpleLocationHandler(location);
|
||||
}
|
||||
handlersForLocation.put(location, h);
|
||||
}
|
||||
h.setLocation(files);
|
||||
@ -699,33 +737,21 @@ public class Locations {
|
||||
|
||||
protected LocationHandler getHandler(Location location) {
|
||||
location.getClass(); // null check
|
||||
lazy();
|
||||
return handlersForLocation.get(location);
|
||||
}
|
||||
|
||||
// TOGO
|
||||
protected void lazy() {
|
||||
if (!inited) {
|
||||
warn = lint.isEnabled(Lint.LintCategory.PATH);
|
||||
|
||||
for (LocationHandler h: handlersForLocation.values()) {
|
||||
h.update(options);
|
||||
}
|
||||
|
||||
inited = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** Is this the name of an archive file? */
|
||||
/**
|
||||
* Is this the name of an archive file?
|
||||
*/
|
||||
private boolean isArchive(File file) {
|
||||
String n = StringUtils.toLowerCase(file.getName());
|
||||
return fsInfo.isFile(file)
|
||||
&& (n.endsWith(".jar") || n.endsWith(".zip"));
|
||||
&& (n.endsWith(".jar") || n.endsWith(".zip"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method for converting a search path string to an array
|
||||
* of directory and JAR file URLs.
|
||||
* Utility method for converting a search path string to an array of directory and JAR file
|
||||
* URLs.
|
||||
*
|
||||
* Note that this method is called by apt and the DocletInvoker.
|
||||
*
|
||||
@ -747,8 +773,7 @@ public class Locations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the directory or JAR file URL corresponding to the specified
|
||||
* local file name.
|
||||
* Returns the directory or JAR file URL corresponding to the specified local file name.
|
||||
*
|
||||
* @param file the File object
|
||||
* @return the resulting directory or JAR file URL, or null if unknown
|
||||
|
@ -1611,8 +1611,6 @@ public class ClassReader {
|
||||
return TypeAnnotationPosition.methodReturn(readTypePath());
|
||||
case FIELD:
|
||||
return TypeAnnotationPosition.field(readTypePath());
|
||||
case UNKNOWN:
|
||||
throw new AssertionError("jvm.ClassReader: UNKNOWN target type should never occur!");
|
||||
default:
|
||||
throw new AssertionError("jvm.ClassReader: Unknown target type for position: " + type);
|
||||
}
|
||||
|
@ -768,25 +768,13 @@ public class ClassWriter extends ClassFile {
|
||||
ListBuffer<Attribute.TypeCompound> invisibles = new ListBuffer<>();
|
||||
|
||||
for (Attribute.TypeCompound tc : typeAnnos) {
|
||||
if (tc.hasUnknownPosition()) {
|
||||
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);
|
||||
Assert.checkNonNull(tc.position);
|
||||
if (tc.position.type.isLocal() != inCode) {
|
||||
continue;
|
||||
}
|
||||
if (!tc.position.emitToClassfile()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tc.position.type.isLocal() != inCode)
|
||||
continue;
|
||||
if (!tc.position.emitToClassfile())
|
||||
continue;
|
||||
switch (types.getRetention(tc)) {
|
||||
case SOURCE: break;
|
||||
case CLASS: invisibles.append(tc); break;
|
||||
@ -967,8 +955,6 @@ public class ClassWriter extends ClassFile {
|
||||
case METHOD_RETURN:
|
||||
case FIELD:
|
||||
break;
|
||||
case UNKNOWN:
|
||||
throw new AssertionError("jvm.ClassWriter: UNKNOWN target type should never occur!");
|
||||
default:
|
||||
throw new AssertionError("jvm.ClassWriter: Unknown target type for position: " + p);
|
||||
}
|
||||
|
@ -557,7 +557,6 @@ public class Gen extends JCTree.Visitor {
|
||||
ListBuffer<Attribute.TypeCompound> fieldTAs = new ListBuffer<>();
|
||||
ListBuffer<Attribute.TypeCompound> nonfieldTAs = new ListBuffer<>();
|
||||
for (TypeCompound ta : tas) {
|
||||
Assert.check(ta.getPosition().type != TargetType.UNKNOWN);
|
||||
if (ta.getPosition().type == TargetType.FIELD) {
|
||||
fieldTAs.add(ta);
|
||||
} else {
|
||||
@ -1931,10 +1930,7 @@ public class Gen extends JCTree.Visitor {
|
||||
|| code.meth.getKind() == javax.lang.model.element.ElementKind.STATIC_INIT;
|
||||
|
||||
for (Attribute.TypeCompound ta : meth.getRawTypeAttributes()) {
|
||||
if (ta.hasUnknownPosition())
|
||||
ta.tryFixPosition();
|
||||
|
||||
if (ta.position.matchesPos(treePos))
|
||||
if (ta.position != null && ta.position.matchesPos(treePos))
|
||||
ta.position.updatePosOffset(code.cp);
|
||||
}
|
||||
|
||||
@ -1942,10 +1938,7 @@ public class Gen extends JCTree.Visitor {
|
||||
return;
|
||||
|
||||
for (Attribute.TypeCompound ta : meth.owner.getRawTypeAttributes()) {
|
||||
if (ta.hasUnknownPosition())
|
||||
ta.tryFixPosition();
|
||||
|
||||
if (ta.position.matchesPos(treePos))
|
||||
if (ta.position != null && ta.position.matchesPos(treePos))
|
||||
ta.position.updatePosOffset(code.cp);
|
||||
}
|
||||
|
||||
@ -1955,10 +1948,7 @@ public class Gen extends JCTree.Visitor {
|
||||
continue;
|
||||
|
||||
for (Attribute.TypeCompound ta : s.getRawTypeAttributes()) {
|
||||
if (ta.hasUnknownPosition())
|
||||
ta.tryFixPosition();
|
||||
|
||||
if (ta.position.matchesPos(treePos))
|
||||
if (ta.position != null && ta.position.matchesPos(treePos))
|
||||
ta.position.updatePosOffset(code.cp);
|
||||
}
|
||||
}
|
||||
@ -2330,8 +2320,8 @@ public class Gen extends JCTree.Visitor {
|
||||
}
|
||||
|
||||
public void visitTypeTest(JCInstanceOf tree) {
|
||||
setTypeAnnotationPositions(tree.pos);
|
||||
genExpr(tree.expr, tree.expr.type).load();
|
||||
setTypeAnnotationPositions(tree.pos);
|
||||
code.emitop2(instanceof_, makeRef(tree.pos(), tree.clazz.type));
|
||||
result = items.makeStackItem(syms.booleanType);
|
||||
}
|
||||
|
@ -394,6 +394,7 @@ public class JavaCompiler {
|
||||
processPcks = options.isSet("process.packages");
|
||||
werror = options.isSet(WERROR);
|
||||
|
||||
// Should this be with other option checking, in Main
|
||||
if (source.compareTo(Source.DEFAULT) < 0) {
|
||||
if (options.isUnset(XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option)) {
|
||||
if (fileManager instanceof BaseFileManager) {
|
||||
@ -403,6 +404,7 @@ public class JavaCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
// Should this be with other option checking, in Main
|
||||
checkForObsoleteOptions(target);
|
||||
|
||||
verboseCompilePolicy = options.isSet("verboseCompilePolicy");
|
||||
@ -434,6 +436,7 @@ public class JavaCompiler {
|
||||
log.setDiagnosticFormatter(RichDiagnosticFormatter.instance(context));
|
||||
}
|
||||
|
||||
// Should this be with other option checking, in Main
|
||||
private void checkForObsoleteOptions(Target target) {
|
||||
// Unless lint checking on options is disabled, check for
|
||||
// obsolete source and target options.
|
||||
@ -829,6 +832,10 @@ public class JavaCompiler {
|
||||
List<String> classnames,
|
||||
Iterable<? extends Processor> processors)
|
||||
{
|
||||
if (!taskListener.isEmpty()) {
|
||||
taskListener.started(new TaskEvent(TaskEvent.Kind.COMPILATION));
|
||||
}
|
||||
|
||||
if (processors != null && processors.iterator().hasNext())
|
||||
explicitAnnotationProcessingRequested = true;
|
||||
// as a JavaCompiler can only be used once, throw an exception if
|
||||
@ -902,6 +909,9 @@ public class JavaCompiler {
|
||||
printCount("error", errorCount());
|
||||
printCount("warn", warningCount());
|
||||
}
|
||||
if (!taskListener.isEmpty()) {
|
||||
taskListener.finished(new TaskEvent(TaskEvent.Kind.COMPILATION));
|
||||
}
|
||||
close();
|
||||
if (procEnvImpl != null)
|
||||
procEnvImpl.close();
|
||||
|
@ -33,8 +33,9 @@ import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.processing.Processor;
|
||||
@ -56,6 +57,7 @@ import com.sun.tools.javac.util.*;
|
||||
import com.sun.tools.javac.util.Log.PrefixKind;
|
||||
import com.sun.tools.javac.util.Log.WriterKind;
|
||||
import com.sun.tools.javac.util.ServiceLoader;
|
||||
|
||||
import static com.sun.tools.javac.main.Option.*;
|
||||
|
||||
/** This class provides a command line interface to the javac compiler.
|
||||
@ -120,6 +122,13 @@ public class Main {
|
||||
options.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFileManagerOption(Option option, String value) {
|
||||
options.put(option.getText(), value);
|
||||
deferredFileManagerOptions.put(option, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String name) {
|
||||
options.remove(name);
|
||||
@ -172,11 +181,13 @@ public class Main {
|
||||
|
||||
/** The list of source files to process
|
||||
*/
|
||||
public Set<File> filenames = null; // XXX sb protected
|
||||
public Set<File> filenames = null; // XXX should be protected or private
|
||||
|
||||
/** List of class files names passed on the command line
|
||||
*/
|
||||
public ListBuffer<String> classnames = null; // XXX sb protected
|
||||
protected ListBuffer<String> classnames = null;
|
||||
|
||||
public Map<Option, String> deferredFileManagerOptions; // XXX should be protected or private
|
||||
|
||||
/** Report a usage error.
|
||||
*/
|
||||
@ -395,6 +406,7 @@ public class Main {
|
||||
|
||||
filenames = new LinkedHashSet<>();
|
||||
classnames = new ListBuffer<>();
|
||||
deferredFileManagerOptions = new LinkedHashMap<>();
|
||||
JavaCompiler comp = null;
|
||||
/*
|
||||
* TODO: Logic below about what is an acceptable command line
|
||||
@ -446,6 +458,11 @@ public class Main {
|
||||
if (batchMode)
|
||||
CacheFSInfo.preRegister(context);
|
||||
|
||||
fileManager = context.get(JavaFileManager.class);
|
||||
if (fileManager instanceof BaseFileManager) {
|
||||
((BaseFileManager) fileManager).handleOptions(deferredFileManagerOptions);
|
||||
}
|
||||
|
||||
// FIXME: this code will not be invoked if using JavacTask.parse/analyze/generate
|
||||
// invoke any available plugins
|
||||
String plugins = options.get(PLUGIN);
|
||||
@ -511,8 +528,6 @@ public class Main {
|
||||
comp.closeables = comp.closeables.prepend(log.getWriter(WriterKind.NOTICE));
|
||||
}
|
||||
|
||||
fileManager = context.get(JavaFileManager.class);
|
||||
|
||||
if (!files.isEmpty()) {
|
||||
// add filenames to fileObjects
|
||||
comp = JavaCompiler.instance(context);
|
||||
|
@ -83,6 +83,7 @@ public enum Option {
|
||||
|
||||
XLINT_CUSTOM("-Xlint:", EXTENDED, BASIC, ANYOF, getXLintChoices()) {
|
||||
private static final String LINT_KEY_FORMAT = " %-19s %s";
|
||||
@Override
|
||||
void help(Log log, OptionKind kind) {
|
||||
if (this.kind != kind)
|
||||
return;
|
||||
@ -667,6 +668,8 @@ public enum Option {
|
||||
}
|
||||
}
|
||||
helper.put(option, arg);
|
||||
if (group == OptionGroup.FILEMANAGER)
|
||||
helper.handleFileManagerOption(this, arg);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -50,6 +50,9 @@ public abstract class OptionHelper {
|
||||
/** Remove any prior value for an option. */
|
||||
public abstract void remove(String name);
|
||||
|
||||
/** Handle a file manager option. */
|
||||
public abstract boolean handleFileManagerOption(Option option, String value);
|
||||
|
||||
/** Get access to the Log for the compilation. */
|
||||
public abstract Log getLog();
|
||||
|
||||
@ -98,6 +101,11 @@ public abstract class OptionHelper {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFileManagerOption(Option option, String value) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
@Override
|
||||
void error(String key, Object... args) {
|
||||
throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -167,11 +167,6 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
|
||||
return getClassLoader(lb.toArray(new URL[lb.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultBootClassPath() {
|
||||
return locations.isDefaultBootClassPath();
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Location handling">
|
||||
|
||||
public boolean hasLocation(Location location) {
|
||||
|
@ -2404,6 +2404,11 @@ compiler.err.static.intf.methods.not.supported.in.source=\
|
||||
static interface methods are not supported in -source {0}\n\
|
||||
(use -source 8 or higher to enable static interface methods)
|
||||
|
||||
# 0: string
|
||||
compiler.err.static.intf.method.invoke.not.supported.in.source=\
|
||||
static interface method invocations are not supported in -source {0}\n\
|
||||
(use -source 8 or higher to enable static interface method invocations)
|
||||
|
||||
########################################
|
||||
# Diagnostics for verbose resolution
|
||||
# used by Resolve (debug only)
|
||||
|
@ -135,6 +135,14 @@ public class TreeInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isReceiverParam(JCTree tree) {
|
||||
if (tree.hasTag(VARDEF)) {
|
||||
return ((JCVariableDecl)tree).nameexpr != null;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Is there a constructor declaration in the given list of trees?
|
||||
*/
|
||||
public static boolean hasConstructors(List<JCTree> trees) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package com.sun.tools.javac.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
@ -47,6 +46,8 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.JavaFileObject.Kind;
|
||||
|
||||
@ -64,7 +65,7 @@ import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
|
||||
* There are no references here to file-system specific objects such as
|
||||
* java.io.File or java.nio.file.Path.
|
||||
*/
|
||||
public abstract class BaseFileManager {
|
||||
public abstract class BaseFileManager implements JavaFileManager {
|
||||
protected BaseFileManager(Charset charset) {
|
||||
this.charset = charset;
|
||||
byteBufferCache = new ByteBufferCache();
|
||||
@ -73,12 +74,13 @@ public abstract class BaseFileManager {
|
||||
|
||||
/**
|
||||
* Set the context for JavacPathFileManager.
|
||||
* @param context the context containing items to be associated with the file manager
|
||||
*/
|
||||
public void setContext(Context context) {
|
||||
log = Log.instance(context);
|
||||
options = Options.instance(context);
|
||||
classLoaderClass = options.get("procloader");
|
||||
locations.update(log, options, Lint.instance(context), FSInfo.instance(context));
|
||||
locations.update(log, Lint.instance(context), FSInfo.instance(context));
|
||||
}
|
||||
|
||||
protected Locations createLocations() {
|
||||
@ -123,14 +125,19 @@ public abstract class BaseFileManager {
|
||||
Class<?>[] constrArgTypes = { URL[].class, ClassLoader.class };
|
||||
Constructor<? extends ClassLoader> constr = loader.getConstructor(constrArgTypes);
|
||||
return constr.newInstance(urls, thisClassLoader);
|
||||
} catch (Throwable t) {
|
||||
} catch (ReflectiveOperationException t) {
|
||||
// ignore errors loading user-provided class loader, fall through
|
||||
}
|
||||
}
|
||||
return new URLClassLoader(urls, thisClassLoader);
|
||||
}
|
||||
|
||||
public boolean isDefaultBootClassPath() {
|
||||
return locations.isDefaultBootClassPath();
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Option handling">
|
||||
@Override
|
||||
public boolean handleOption(String current, Iterator<String> remaining) {
|
||||
OptionHelper helper = new GrumpyHelper(log) {
|
||||
@Override
|
||||
@ -147,7 +154,13 @@ public abstract class BaseFileManager {
|
||||
public void remove(String name) {
|
||||
options.remove(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFileManagerOption(Option option, String value) {
|
||||
return handleOption(option, value);
|
||||
}
|
||||
};
|
||||
|
||||
for (Option o: javacFileManagerOptions) {
|
||||
if (o.matches(current)) {
|
||||
if (o.hasArg()) {
|
||||
@ -159,7 +172,7 @@ public abstract class BaseFileManager {
|
||||
if (!o.process(helper, current))
|
||||
return true;
|
||||
}
|
||||
// operand missing, or process returned false
|
||||
// operand missing, or process returned true
|
||||
throw new IllegalArgumentException(current);
|
||||
}
|
||||
}
|
||||
@ -170,6 +183,7 @@ public abstract class BaseFileManager {
|
||||
private static final Set<Option> javacFileManagerOptions =
|
||||
Option.getJavacFileManagerOptions();
|
||||
|
||||
@Override
|
||||
public int isSupportedOption(String option) {
|
||||
for (Option o : javacFileManagerOptions) {
|
||||
if (o.matches(option))
|
||||
@ -178,7 +192,27 @@ public abstract class BaseFileManager {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public abstract boolean isDefaultBootClassPath();
|
||||
/**
|
||||
* Common back end for OptionHelper handleFileManagerOption.
|
||||
* @param option the option whose value to be set
|
||||
* @param value the value for the option
|
||||
* @return true if successful, and false otherwise
|
||||
*/
|
||||
public boolean handleOption(Option option, String value) {
|
||||
return locations.handleOption(option, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call handleOption for collection of options and corresponding values.
|
||||
* @param map a collection of options and corresponding values
|
||||
* @return true if all the calls are successful
|
||||
*/
|
||||
public boolean handleOptions(Map<Option, String> map) {
|
||||
boolean ok = true;
|
||||
for (Map.Entry<Option, String> e: map.entrySet())
|
||||
ok = ok & handleOption(e.getKey(), e.getValue());
|
||||
return ok;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
@ -205,10 +239,7 @@ public abstract class BaseFileManager {
|
||||
CharsetDecoder decoder;
|
||||
try {
|
||||
decoder = getDecoder(encodingName, ignoreEncodingErrors);
|
||||
} catch (IllegalCharsetNameException e) {
|
||||
log.error("unsupported.encoding", encodingName);
|
||||
return (CharBuffer)CharBuffer.allocate(1).flip();
|
||||
} catch (UnsupportedCharsetException e) {
|
||||
} catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
|
||||
log.error("unsupported.encoding", encodingName);
|
||||
return (CharBuffer)CharBuffer.allocate(1).flip();
|
||||
}
|
||||
@ -286,6 +317,9 @@ public abstract class BaseFileManager {
|
||||
// <editor-fold defaultstate="collapsed" desc="ByteBuffers">
|
||||
/**
|
||||
* Make a byte buffer from an input stream.
|
||||
* @param in the stream
|
||||
* @return a byte buffer containing the contents of the stream
|
||||
* @throws IOException if an error occurred while reading the stream
|
||||
*/
|
||||
public ByteBuffer makeByteBuffer(InputStream in)
|
||||
throws IOException {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,18 +32,23 @@ import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.main.CommandLine;
|
||||
import com.sun.tools.javac.main.Option;
|
||||
import com.sun.tools.javac.util.BaseFileManager;
|
||||
import com.sun.tools.javac.util.ClientCodeException;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.List;
|
||||
import com.sun.tools.javac.util.ListBuffer;
|
||||
import com.sun.tools.javac.util.Log;
|
||||
import com.sun.tools.javac.util.Options;
|
||||
|
||||
import static com.sun.tools.javac.code.Flags.*;
|
||||
|
||||
/**
|
||||
@ -71,7 +76,7 @@ public class Start extends ToolOption.Helper {
|
||||
private static final String standardDocletClassName =
|
||||
"com.sun.tools.doclets.standard.Standard";
|
||||
|
||||
private long defaultFilter = PUBLIC | PROTECTED;
|
||||
private final long defaultFilter = PUBLIC | PROTECTED;
|
||||
|
||||
private final Messager messager;
|
||||
|
||||
@ -324,6 +329,15 @@ public class Start extends ToolOption.Helper {
|
||||
javaNames.append(arg);
|
||||
}
|
||||
}
|
||||
|
||||
if (fileManager == null) {
|
||||
JavacFileManager.preRegister(context);
|
||||
fileManager = context.get(JavaFileManager.class);
|
||||
}
|
||||
if (fileManager instanceof BaseFileManager) {
|
||||
((BaseFileManager) fileManager).handleOptions(fileManagerOpts);
|
||||
}
|
||||
|
||||
compOpts.notifyListeners();
|
||||
|
||||
if (javaNames.isEmpty() && subPackages.isEmpty() && isEmpty(fileObjects)) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,10 +25,14 @@
|
||||
|
||||
package com.sun.tools.javadoc;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.sun.tools.javac.code.Flags;
|
||||
import com.sun.tools.javac.main.Option;
|
||||
import com.sun.tools.javac.util.ListBuffer;
|
||||
import com.sun.tools.javac.util.Options;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
|
||||
/**
|
||||
@ -45,42 +49,42 @@ public enum ToolOption {
|
||||
BOOTCLASSPATH("-bootclasspath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setCompilerOpt(opt, arg);
|
||||
helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
CLASSPATH("-classpath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setCompilerOpt(opt, arg);
|
||||
helper.setFileManagerOpt(Option.CLASSPATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
CP("-cp", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setCompilerOpt(opt, arg);
|
||||
helper.setFileManagerOpt(Option.CP, arg);
|
||||
}
|
||||
},
|
||||
|
||||
EXTDIRS("-extdirs", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setCompilerOpt(opt, arg);
|
||||
helper.setFileManagerOpt(Option.EXTDIRS, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SOURCEPATH("-sourcepath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setCompilerOpt(opt, arg);
|
||||
helper.setFileManagerOpt(Option.SOURCEPATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SYSCLASSPATH("-sysclasspath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setCompilerOpt("-bootclasspath", arg);
|
||||
helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
@ -274,6 +278,9 @@ public enum ToolOption {
|
||||
/** Excluded packages, from -exclude. */
|
||||
final ListBuffer<String> excludedPackages = new ListBuffer<>();
|
||||
|
||||
// File manager options
|
||||
final Map<Option, String> fileManagerOpts = new LinkedHashMap<>();
|
||||
|
||||
/** javac options, set by various options. */
|
||||
Options compOpts; // = Options.instance(context)
|
||||
|
||||
@ -306,7 +313,7 @@ public enum ToolOption {
|
||||
|
||||
abstract void usageError(String msg, Object... args);
|
||||
|
||||
protected void addToList(ListBuffer<String> list, String str){
|
||||
void addToList(ListBuffer<String> list, String str){
|
||||
StringTokenizer st = new StringTokenizer(str, ":");
|
||||
String current;
|
||||
while(st.hasMoreTokens()){
|
||||
@ -315,18 +322,22 @@ public enum ToolOption {
|
||||
}
|
||||
}
|
||||
|
||||
protected void setFilter(long filterBits) {
|
||||
void setFilter(long filterBits) {
|
||||
if (showAccess != null) {
|
||||
usageError("main.incompatible.access.flags");
|
||||
}
|
||||
showAccess = new ModifierFilter(filterBits);
|
||||
}
|
||||
|
||||
private void setCompilerOpt(String opt, String arg) {
|
||||
void setCompilerOpt(String opt, String arg) {
|
||||
if (compOpts.get(opt) != null) {
|
||||
usageError("main.option.already.seen", opt);
|
||||
}
|
||||
compOpts.put(opt, arg);
|
||||
}
|
||||
|
||||
void setFileManagerOpt(Option opt, String arg) {
|
||||
fileManagerOpts.put(opt, arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -54,13 +54,13 @@ public class T6358024 extends AbstractProcessor {
|
||||
|
||||
test(fm, f,
|
||||
new Option[] { new Option("-d", ".")},
|
||||
7);
|
||||
8);
|
||||
|
||||
test(fm, f,
|
||||
new Option[] { new XOption("-XprintRounds"),
|
||||
new Option("-processorpath", "."),
|
||||
new Option("-processor", self) },
|
||||
12);
|
||||
13);
|
||||
}
|
||||
|
||||
static void test(JavacFileManager fm, JavaFileObject f, Option[] opts, int expect) throws Throwable {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -57,12 +57,8 @@ public class T6358166 extends AbstractProcessor {
|
||||
|
||||
static void test(JavacFileManager fm, JavaFileObject f, String... args) throws Throwable {
|
||||
Context context = new Context();
|
||||
fm.setContext(context);
|
||||
|
||||
Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
|
||||
compilerMain.setOptions(Options.instance(context));
|
||||
compilerMain.filenames = new LinkedHashSet<File>();
|
||||
compilerMain.processArgs(args);
|
||||
Main compilerMain = initCompilerMain(context, fm, args);
|
||||
|
||||
JavaCompiler c = JavaCompiler.instance(context);
|
||||
|
||||
@ -76,6 +72,19 @@ public class T6358166 extends AbstractProcessor {
|
||||
throw new AssertionError("elapsed time is suspect: " + msec);
|
||||
}
|
||||
|
||||
static Main initCompilerMain(Context context, JavacFileManager fm, String... args) {
|
||||
fm.setContext(context);
|
||||
context.put(JavaFileManager.class, fm);
|
||||
|
||||
Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
|
||||
compilerMain.setOptions(Options.instance(context));
|
||||
compilerMain.filenames = new LinkedHashSet<File>();
|
||||
compilerMain.deferredFileManagerOptions = new LinkedHashMap<>();
|
||||
compilerMain.processArgs(args);
|
||||
fm.handleOptions(compilerMain.deferredFileManagerOptions);
|
||||
return compilerMain;
|
||||
}
|
||||
|
||||
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
|
||||
return true;
|
||||
}
|
||||
|
@ -68,12 +68,9 @@ public class T6358168 extends AbstractProcessor {
|
||||
|
||||
static void testNoAnnotationProcessing(JavacFileManager fm, JavaFileObject f) throws Throwable {
|
||||
Context context = new Context();
|
||||
fm.setContext(context);
|
||||
|
||||
Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
|
||||
compilerMain.setOptions(Options.instance(context));
|
||||
compilerMain.filenames = new LinkedHashSet<File>();
|
||||
compilerMain.processArgs(new String[] { "-d", "." });
|
||||
String[] args = { "-d", "." };
|
||||
Main compilerMain = initCompilerMain(context, fm, args);
|
||||
|
||||
JavaCompiler compiler = JavaCompiler.instance(context);
|
||||
compiler.compile(List.of(f));
|
||||
@ -87,16 +84,14 @@ public class T6358168 extends AbstractProcessor {
|
||||
|
||||
static void testAnnotationProcessing(JavacFileManager fm, JavaFileObject f) throws Throwable {
|
||||
Context context = new Context();
|
||||
fm.setContext(context);
|
||||
|
||||
Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
|
||||
compilerMain.setOptions(Options.instance(context));
|
||||
compilerMain.filenames = new LinkedHashSet<File>();
|
||||
compilerMain.processArgs(new String[] {
|
||||
"-XprintRounds",
|
||||
"-processorpath", testClasses,
|
||||
"-processor", self,
|
||||
"-d", "."});
|
||||
String[] args = {
|
||||
"-XprintRounds",
|
||||
"-processorpath", testClasses,
|
||||
"-processor", self,
|
||||
"-d", "."
|
||||
};
|
||||
Main compilerMain = initCompilerMain(context, fm, args);
|
||||
|
||||
JavaCompiler compiler = JavaCompiler.instance(context);
|
||||
compiler.compile(List.of(f));
|
||||
@ -108,6 +103,19 @@ public class T6358168 extends AbstractProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
static Main initCompilerMain(Context context, JavacFileManager fm, String... args) {
|
||||
fm.setContext(context);
|
||||
context.put(JavaFileManager.class, fm);
|
||||
|
||||
Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
|
||||
compilerMain.setOptions(Options.instance(context));
|
||||
compilerMain.filenames = new LinkedHashSet<File>();
|
||||
compilerMain.deferredFileManagerOptions = new LinkedHashMap<>();
|
||||
compilerMain.processArgs(args);
|
||||
fm.handleOptions(compilerMain.deferredFileManagerOptions);
|
||||
return compilerMain;
|
||||
}
|
||||
|
||||
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,8 +29,11 @@
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.tools.*;
|
||||
|
||||
import com.sun.source.util.*;
|
||||
import com.sun.source.util.TaskEvent.Kind;
|
||||
import com.sun.tools.javac.api.*;
|
||||
|
||||
|
||||
@ -59,16 +62,13 @@ public class T6395974 {
|
||||
task.setTaskListener(tl);
|
||||
|
||||
task.call();
|
||||
|
||||
if (tl.event != null)
|
||||
throw new AssertionError("Unexpected TaskListener event: " + tl.event);
|
||||
}
|
||||
|
||||
static class MyTaskListener implements TaskListener {
|
||||
public void started(TaskEvent e) {
|
||||
System.err.println("Started: " + e);
|
||||
if (event == null)
|
||||
event = e;
|
||||
if (e.getKind() != Kind.COMPILATION) {
|
||||
throw new AssertionError("Unexpected TaskListener event: " + e);
|
||||
}
|
||||
}
|
||||
public void finished(TaskEvent e) {
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
Started TaskEvent[COMPILATION,null,null]
|
||||
Started TaskEvent[ANNOTATION_PROCESSING,null,null]
|
||||
Started TaskEvent[PARSE,T6403466.java,null]
|
||||
Finished TaskEvent[PARSE,T6403466.java,null]
|
||||
@ -40,3 +41,4 @@ Started TaskEvent[ANALYZE,T6403466Wrapper.java,T6403466Wrapper]
|
||||
Finished TaskEvent[ANALYZE,T6403466Wrapper.java,T6403466Wrapper]
|
||||
Started TaskEvent[GENERATE,T6403466Wrapper.java,T6403466Wrapper]
|
||||
Finished TaskEvent[GENERATE,T6403466Wrapper.java,T6403466Wrapper]
|
||||
Finished TaskEvent[COMPILATION,null,null]
|
||||
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8027886
|
||||
* @summary Receiver parameters must not be final
|
||||
* @compile/fail/ref=FinalReceiverTest.out -XDrawDiagnostics FinalReceiverTest.java
|
||||
*/
|
||||
|
||||
class FinalReceiverTest {
|
||||
void m() {
|
||||
class Inner {
|
||||
Inner(final FinalReceiverTest FinalReceiverTest.this) {}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
FinalReceiverTest.java:11:43: compiler.err.mod.not.allowed.here: final
|
||||
1 error
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8029042
|
||||
* @summary Receiver parameter not supported on local class constructor
|
||||
* @compile LocalInnerReceiverTest.java
|
||||
*/
|
||||
|
||||
class LocalInnerReceiverTest {
|
||||
void m() {
|
||||
class Inner {
|
||||
Inner(LocalInnerReceiverTest LocalInnerReceiverTest.this) {}
|
||||
}
|
||||
}
|
||||
}
|
@ -35,9 +35,41 @@ import java.io.*;
|
||||
* @compile TargetTypes.java
|
||||
*/
|
||||
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface A {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface A {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface B {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface C {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface D {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface E {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface F {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface G {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface H {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface I {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface J {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface K {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface L {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface M {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface N {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface O {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface P {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface Q {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface R {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface S {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface U {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface V {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface W {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface X {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface Y {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface Z {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AA {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AB {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AC {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AD {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AE {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AF {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AG {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AH {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AI {}
|
||||
@Target({TYPE_USE, TYPE_PARAMETER, TYPE}) @Retention(RetentionPolicy.RUNTIME) @interface AJ {}
|
||||
|
||||
/** wildcard bound */
|
||||
class T0x1C {
|
||||
@ -46,75 +78,75 @@ class T0x1C {
|
||||
|
||||
/** wildcard bound generic/array */
|
||||
class T0x1D<T> {
|
||||
void m0x1D(List<? extends @A List<int[]>> lst) {}
|
||||
void m0x1D(List<? extends @B List<int[]>> lst) {}
|
||||
}
|
||||
|
||||
/** typecast */
|
||||
class T0x00 {
|
||||
void m0x00(Long l1) {
|
||||
Object l2 = (@A Long) l1;
|
||||
Object l2 = (@C Long) l1;
|
||||
}
|
||||
}
|
||||
|
||||
/** typecast generic/array */
|
||||
class T0x01<T> {
|
||||
void m0x01(List<T> list) {
|
||||
List<T> l = (List<@A T>) list;
|
||||
List<T> l = (List<@D T>) list;
|
||||
}
|
||||
}
|
||||
|
||||
/** instanceof */
|
||||
class T0x02 {
|
||||
boolean m0x02(String s) {
|
||||
return (s instanceof @A String);
|
||||
return (s instanceof @E String);
|
||||
}
|
||||
}
|
||||
|
||||
/** object creation (new) */
|
||||
class T0x04 {
|
||||
void m0x04() {
|
||||
new @A ArrayList<String>();
|
||||
new @F ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
/** local variable */
|
||||
class T0x08 {
|
||||
void m0x08() {
|
||||
@A String s = null;
|
||||
@G String s = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** method parameter generic/array */
|
||||
class T0x0D {
|
||||
void m0x0D(HashMap<@A Object, List<@A List<@A Class>>> s1) {}
|
||||
void m0x0D(HashMap<@H Object, List<@I List<@J Class>>> s1) {}
|
||||
}
|
||||
|
||||
/** method receiver */
|
||||
class T0x06 {
|
||||
void m0x06(@A T0x06 this) {}
|
||||
void m0x06(@K T0x06 this) {}
|
||||
}
|
||||
|
||||
/** method return type generic/array */
|
||||
class T0x0B {
|
||||
Class<@A Object> m0x0B() { return null; }
|
||||
Class<@L Object> m0x0B() { return null; }
|
||||
}
|
||||
|
||||
/** field generic/array */
|
||||
class T0x0F {
|
||||
HashMap<@A Object, @A Object> c1;
|
||||
HashMap<@M Object, @N Object> c1;
|
||||
}
|
||||
|
||||
/** method type parameter */
|
||||
class T0x20<T, U> {
|
||||
<@A T, @A U> void m0x20() {}
|
||||
<@O T, @P U> void m0x20() {}
|
||||
}
|
||||
|
||||
/** class type parameter */
|
||||
class T0x22<@A T, @A U> {
|
||||
class T0x22<@Q T, @R U> {
|
||||
}
|
||||
|
||||
/** class type parameter bound */
|
||||
class T0x10<T extends @A Object> {
|
||||
class T0x10<T extends @S Object> {
|
||||
}
|
||||
|
||||
/** method type parameter bound */
|
||||
@ -123,43 +155,43 @@ class T0x12<T> {
|
||||
}
|
||||
|
||||
/** class type parameter bound generic/array */
|
||||
class T0x11<T extends List<@A T>> {
|
||||
class T0x11<T extends List<@U T>> {
|
||||
}
|
||||
|
||||
|
||||
/** method type parameter bound generic/array */
|
||||
class T0x13 {
|
||||
static <T extends Comparable<@A T>> T m0x13() {
|
||||
static <T extends Comparable<@V T>> T m0x13() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** class extends/implements generic/array */
|
||||
class T0x15<T> extends ArrayList<@A T> {
|
||||
class T0x15<T> extends ArrayList<@W T> {
|
||||
}
|
||||
|
||||
/** type test (instanceof) generic/array */
|
||||
class T0x03<T> {
|
||||
void m0x03(T typeObj, Object obj) {
|
||||
boolean ok = obj instanceof String @A [];
|
||||
boolean ok = obj instanceof String @X [];
|
||||
}
|
||||
}
|
||||
|
||||
/** object creation (new) generic/array */
|
||||
class T0x05<T> {
|
||||
void m0x05() {
|
||||
new ArrayList<@A T>();
|
||||
new ArrayList<@Y T>();
|
||||
}
|
||||
}
|
||||
|
||||
/** local variable generic/array */
|
||||
class T0x09<T> {
|
||||
void g() {
|
||||
List<@A String> l = null;
|
||||
List<@Z String> l = null;
|
||||
}
|
||||
|
||||
void a() {
|
||||
String @A [] as = null;
|
||||
String @AA [] as = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,14 +200,14 @@ class T0x19 {
|
||||
<T> T0x19() {}
|
||||
|
||||
void g() {
|
||||
new <List<@A String>> T0x19();
|
||||
new <List<@AB String>> T0x19();
|
||||
}
|
||||
}
|
||||
|
||||
/** type argument in method call generic/array */
|
||||
class T0x1B<T> {
|
||||
void m0x1B() {
|
||||
Collections.<T @A []>emptyList();
|
||||
Collections.<T @AC []>emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +216,7 @@ class T0x18<T> {
|
||||
<T> T0x18() {}
|
||||
|
||||
void m() {
|
||||
new <@A Integer> T0x18();
|
||||
new <@AD Integer> T0x18();
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,15 +224,15 @@ class T0x18<T> {
|
||||
class T0x1A<T,U> {
|
||||
public static <T, U> T m() { return null; }
|
||||
static void m0x1A() {
|
||||
T0x1A.<@A Integer, @A Short>m();
|
||||
T0x1A.<@AE Integer, @AF Short>m();
|
||||
}
|
||||
}
|
||||
|
||||
/** class extends/implements */
|
||||
class T0x14 extends @A Object implements @A Serializable, @A Cloneable {
|
||||
class T0x14 extends @AG Object implements @AH Serializable, @AI Cloneable {
|
||||
}
|
||||
|
||||
/** exception type in throws */
|
||||
class T0x16 {
|
||||
void m0x16() throws @A Exception {}
|
||||
void m0x16() throws @AJ Exception {}
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ public class ClassfileTestHelper {
|
||||
|
||||
//Makes debugging much easier. Set to 'false' for less output.
|
||||
public Boolean verbose = true;
|
||||
void println(String msg) { if (verbose) System.out.println(msg); }
|
||||
void print(String msg) { if (verbose) System.out.print(msg); }
|
||||
void println(String msg) { if (verbose) System.err.println(msg); }
|
||||
void print(String msg) { if (verbose) System.err.print(msg); }
|
||||
|
||||
File writeTestFile(String fname, String source) throws IOException {
|
||||
File f = new File(fname);
|
||||
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8027262
|
||||
* @summary A class expression cannot be annotated.
|
||||
* @compile/fail/ref=AnnotatedClassExpr.out -XDrawDiagnostics AnnotatedClassExpr.java
|
||||
*/
|
||||
import java.lang.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
class AnnotatedClassExpr {
|
||||
static void main() {
|
||||
Object o1 = @A int.class;
|
||||
}
|
||||
}
|
||||
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface A { }
|
@ -0,0 +1,2 @@
|
||||
AnnotatedClassExpr.java:12:29: compiler.err.no.annotations.on.dot.class
|
||||
1 error
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8006775
|
||||
* @bug 8006775 8027262
|
||||
* @summary Import clauses cannot use annotations.
|
||||
* @author Werner Dietl
|
||||
* @ignore
|
||||
* @compile/fail/ref=AnnotatedImport.out -XDrawDiagnostics AnnotatedImport.java
|
||||
*/
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
AnnotatedImport.java:9:13: compiler.err.expected: token.identifier
|
||||
AnnotatedImport.java:9:14: compiler.err.expected3: class, interface, enum
|
||||
AnnotatedImport.java:10:7: compiler.err.expected: token.identifier
|
||||
AnnotatedImport.java:10:10: compiler.err.expected: ';'
|
||||
AnnotatedImport.java:11:18: compiler.err.expected: token.identifier
|
||||
AnnotatedImport.java:11:19: compiler.err.expected3: class, interface, enum
|
||||
AnnotatedImport.java:10:13: compiler.err.expected: token.identifier
|
||||
AnnotatedImport.java:10:16: compiler.err.expected3: class, interface, enum
|
||||
AnnotatedImport.java:11:7: compiler.err.expected: token.identifier
|
||||
AnnotatedImport.java:11:11: compiler.err.expected3: class, interface, enum
|
||||
AnnotatedImport.java:12:18: compiler.err.expected: token.identifier
|
||||
AnnotatedImport.java:12:21: compiler.err.expected3: class, interface, enum
|
||||
6 errors
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8006775
|
||||
* @bug 8006775 8027262
|
||||
* @summary Package declarations cannot use annotations.
|
||||
* @author Werner Dietl
|
||||
* @ignore
|
||||
* @compile/fail/ref=AnnotatedPackage1.out -XDrawDiagnostics AnnotatedPackage1.java
|
||||
*/
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
AnnotatedPackage1.java:9:14: compiler.err.expected: token.identifier
|
||||
AnnotatedPackage1.java:9:16: compiler.err.expected3: class, interface, enum
|
||||
AnnotatedPackage1.java:9:17: compiler.err.expected3: class, interface, enum
|
||||
2 errors
|
||||
|
@ -1,5 +1,5 @@
|
||||
CantAnnotatePackages.java:19:14: compiler.err.cant.resolve.location: kindname.class, java, , , (compiler.misc.location: kindname.class, CantAnnotatePackages, null)
|
||||
CantAnnotatePackages.java:20:9: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null)
|
||||
CantAnnotatePackages.java:21:14: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null)
|
||||
CantAnnotatePackages.java:14:18: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
4 errors
|
||||
CantAnnotatePackages.java:14:13: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotatePackages.java:19:18: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotatePackages.java:20:19: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotatePackages.java:21:24: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
4 errors
|
||||
|
@ -1,12 +1,14 @@
|
||||
CantAnnotateScoping.java:61:9: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null)
|
||||
CantAnnotateScoping.java:66:9: compiler.err.cant.resolve.location: kindname.class, XXX, , , (compiler.misc.location: kindname.package, java, null)
|
||||
CantAnnotateScoping.java:70:9: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null)
|
||||
CantAnnotateScoping.java:66:18: compiler.err.doesnt.exist: java.XXX
|
||||
CantAnnotateScoping.java:38:14: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotateScoping.java:47:18: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotateScoping.java:56:37: compiler.err.cant.type.annotate.scoping: @TA,@TA2
|
||||
CantAnnotateScoping.java:40:14: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotateScoping.java:42:34: compiler.err.cant.type.annotate.scoping: @TA,@DA,@TA2
|
||||
CantAnnotateScoping.java:40:19: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotateScoping.java:47:13: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotateScoping.java:56:32: compiler.err.cant.type.annotate.scoping: @TA,@TA2
|
||||
CantAnnotateScoping.java:61:19: compiler.err.cant.type.annotate.scoping.1: @DA
|
||||
CantAnnotateScoping.java:70:19: compiler.err.cant.type.annotate.scoping.1: @TA
|
||||
CantAnnotateScoping.java:61:11: compiler.err.annotation.type.not.applicable
|
||||
CantAnnotateScoping.java:66:11: compiler.err.annotation.type.not.applicable
|
||||
CantAnnotateScoping.java:42:39: compiler.err.cant.type.annotate.scoping: @TA,@DA,@TA2
|
||||
CantAnnotateScoping.java:42:25: compiler.err.annotation.type.not.applicable
|
||||
CantAnnotateScoping.java:44:38: compiler.err.cant.type.annotate.scoping: @TA,@DA
|
||||
CantAnnotateScoping.java:44:43: compiler.err.cant.type.annotate.scoping: @TA,@DA
|
||||
CantAnnotateScoping.java:44:34: compiler.err.annotation.type.not.applicable
|
||||
11 errors
|
||||
13 errors
|
@ -12,14 +12,49 @@ import java.util.HashMap;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
class Top {
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface TA {}
|
||||
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface TB {}
|
||||
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface TC {}
|
||||
@Target(ElementType.TYPE_USE) @interface TA {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB1 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB2 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB3 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB4 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB5 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB6 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB7 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB8 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB9 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB10 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB11 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB12 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB13 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB14 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB15 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB16 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB17 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB18 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB19 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB20 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB21 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB22 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB23 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB24 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB25 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB26 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB27 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB28 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB29 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB30 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB31 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB32 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB33 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB34 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB35 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB36 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB37 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB38 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB39 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB40 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TB41 {}
|
||||
@Target(ElementType.TYPE_USE) @interface TC {}
|
||||
|
||||
class Outer {
|
||||
class Inner {
|
||||
@ -34,63 +69,63 @@ class Top {
|
||||
|
||||
// All combinations are OK
|
||||
|
||||
Top.@TB Outer f1;
|
||||
@TB Outer.Inner f1a;
|
||||
Top.@TB1 Outer f1;
|
||||
@TB2 Outer.Inner f1a;
|
||||
Outer. @TC Inner f1b;
|
||||
@TB Outer. @TC Inner f1c;
|
||||
@TB3 Outer. @TC Inner f1c;
|
||||
|
||||
@TA Top. @TB Outer f2;
|
||||
@TA Top. @TB Outer.Inner f2a;
|
||||
@TA Top. @TB4 Outer f2;
|
||||
@TA Top. @TB5 Outer.Inner f2a;
|
||||
@TA Top. Outer. @TC Inner f2b;
|
||||
@TA Top. @TB Outer. @TC Inner f2c;
|
||||
@TA Top. @TB6 Outer. @TC Inner f2c;
|
||||
|
||||
@TB Outer f1r() { return null; }
|
||||
@TB Outer.Inner f1ra() { return null; }
|
||||
@TB7 Outer f1r() { return null; }
|
||||
@TB8 Outer.Inner f1ra() { return null; }
|
||||
Outer. @TC Inner f1rb() { return null; }
|
||||
@TB Outer. @TC Inner f1rc() { return null; }
|
||||
@TB9 Outer. @TC Inner f1rc() { return null; }
|
||||
|
||||
void f1param(@TB Outer p,
|
||||
@TB Outer.Inner p1,
|
||||
void f1param(@TB41 Outer p,
|
||||
@TB10 Outer.Inner p1,
|
||||
Outer. @TC Inner p2,
|
||||
@TB Outer. @TC Inner p3) { }
|
||||
@TB11 Outer. @TC Inner p3) { }
|
||||
|
||||
void f1cast(Object o) {
|
||||
Object l;
|
||||
l = (@TB Outer) o;
|
||||
l = (@TB Outer.Inner) o;
|
||||
l = (@TB12 Outer) o;
|
||||
l = (@TB13 Outer.Inner) o;
|
||||
l = (Outer. @TC Inner) o;
|
||||
l = (@TB Outer. @TC Inner) o;
|
||||
l = (@TB14 Outer. @TC Inner) o;
|
||||
}
|
||||
|
||||
List<@TB Outer> g1;
|
||||
List<@TB Outer.Inner> g1a;
|
||||
List<@TB15 Outer> g1;
|
||||
List<@TB16 Outer.Inner> g1a;
|
||||
List<Outer. @TC Inner> g1b;
|
||||
List<@TB Outer. @TC Inner> g1c;
|
||||
List<@TB17 Outer. @TC Inner> g1c;
|
||||
|
||||
List<@TA Top. @TB Outer> g2;
|
||||
List<@TA Top. @TB Outer.Inner> g2a;
|
||||
List<@TA Top. @TB18 Outer> g2;
|
||||
List<@TA Top. @TB19 Outer.Inner> g2a;
|
||||
List<@TA Top. Outer. @TC Inner> g2b;
|
||||
List<@TA Top. @TB Outer. @TC Inner> g2c;
|
||||
List<@TA Top. @TB20 Outer. @TC Inner> g2c;
|
||||
|
||||
List<@TB Outer> g1r() { return null; }
|
||||
List<@TB Outer.Inner> g1ra() { return null; }
|
||||
List<@TB21 Outer> g1r() { return null; }
|
||||
List<@TB22 Outer.Inner> g1ra() { return null; }
|
||||
List<Outer. @TC Inner> g1rb() { return null; }
|
||||
List<@TB Outer. @TC Inner> g1rc() { return null; }
|
||||
List<@TB23 Outer. @TC Inner> g1rc() { return null; }
|
||||
|
||||
void g1param(List<@TB Outer> p,
|
||||
List<@TB Outer.Inner> p1,
|
||||
void g1param(List<@TB24 Outer> p,
|
||||
List<@TB25 Outer.Inner> p1,
|
||||
List<Outer. @TC Inner> p2,
|
||||
List<@TB Outer. @TC Inner> p3) { }
|
||||
List<@TB26 Outer. @TC Inner> p3) { }
|
||||
|
||||
void g1new(Object o) {
|
||||
Object l;
|
||||
l = new @TB ArrayList<@TB Outer>();
|
||||
l = new @TB ArrayList<@TB Outer.Inner>();
|
||||
l = new @TB HashMap<String, Outer. @TC Inner>();
|
||||
l = new @TB HashMap<String, @TB Outer. Inner>();
|
||||
l = new @TB HashMap<String, @TB Outer. @TC Inner>();
|
||||
l = new @TB HashMap<String, @TA Top. Outer. @TC Inner>();
|
||||
l = new @TB HashMap<String, @TA Top. @TB Outer. Inner>();
|
||||
l = new @TB HashMap<String, @TA Top. @TB Outer. @TC Inner>();
|
||||
l = new @TB27 ArrayList<@TB28 Outer>();
|
||||
l = new @TB29 ArrayList<@TB30 Outer.Inner>();
|
||||
l = new @TB31 HashMap<String, Outer. @TC Inner>();
|
||||
l = new @TB32 HashMap<String, @TB33 Outer. Inner>();
|
||||
l = new @TB34 HashMap<String, @TB35 Outer. @TC Inner>();
|
||||
l = new @TB36 HashMap<String, @TA Top. Outer. @TC Inner>();
|
||||
l = new @TB37 HashMap<String, @TA Top. @TB38 Outer. Inner>();
|
||||
l = new @TB39 HashMap<String, @TA Top. @TB40 Outer. @TC Inner>();
|
||||
}
|
||||
}
|
||||
|
@ -1,65 +1,72 @@
|
||||
CantAnnotateStaticClass2.java:44:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:45:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:52:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:53:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:55:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:56:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:57:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:58:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:60:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:61:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:62:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:64:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:65:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:66:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:52:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:53:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:55:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:56:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:57:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:57:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:58:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:58:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:60:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:61:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:62:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:64:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:65:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:65:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:66:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:66:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:71:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:72:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:79:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:80:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:79:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:80:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:87:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:89:24: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:89:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:91:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:93:24: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:57:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:58:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:65:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:66:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:120:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:121:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:128:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:129:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:131:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:133:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:134:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:135:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:137:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:138:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:139:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:141:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:142:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:143:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:149:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:150:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:157:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:158:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:165:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:167:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:169:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:171:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:105:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:107:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:112:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:114:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:184:35: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:186:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:187:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:192:35: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:194:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:195:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:199:35: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:200:38: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:201:41: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:202:44: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:203:44: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:204:49: compiler.err.cant.type.annotate.scoping: @Top.TA,@Top.TB,@Top.TC
|
||||
64 errors
|
||||
CantAnnotateStaticClass2.java:93:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:120:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:121:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:128:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:129:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:131:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:133:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:134:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:134:28: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:135:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:135:28: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:137:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:138:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:139:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:141:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:142:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:142:28: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:143:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:143:28: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:149:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:150:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:157:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:158:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:165:27: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:167:27: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:169:27: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:171:27: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:105:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:107:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:112:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:114:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:184:40: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:186:46: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:187:46: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:192:40: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:194:46: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:195:46: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:199:38: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:200:38: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:200:49: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:201:44: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:202:44: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:202:55: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:203:44: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass2.java:203:55: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass2.java:204:52: compiler.err.cant.type.annotate.scoping: @Top.TA,@Top.TB,@Top.TC
|
||||
71 errors
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8006733 8006775
|
||||
* @bug 8006733 8006775 8027262
|
||||
* @summary Ensure behavior for nested types is correct.
|
||||
* @author Werner Dietl
|
||||
* @ignore
|
||||
* @compile/fail/ref=CantAnnotateStaticClass3.out -XDrawDiagnostics CantAnnotateStaticClass3.java
|
||||
*/
|
||||
|
||||
|
@ -1,83 +1,92 @@
|
||||
CantAnnotateStaticClass3.java:44:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:45:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:46:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:52:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:53:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:54:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:56:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:57:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:58:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:59:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:61:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:62:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:63:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:65:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:66:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:67:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:52:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:53:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:54:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:56:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:57:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:57:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:58:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:58:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:59:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:59:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:61:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:62:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:63:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:65:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:65:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:66:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:66:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:67:12: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:67:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:71:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:72:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:73:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:79:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:80:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:81:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:79:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:80:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:81:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:84:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:86:24: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:86:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:88:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:90:24: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:90:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:92:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:94:24: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:57:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:58:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:59:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:65:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:66:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:67:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:99:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:101:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:106:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:108:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:113:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:115:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:120:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:121:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:122:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:128:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:129:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:130:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:132:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:134:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:135:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:136:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:138:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:139:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:140:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:142:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:143:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:144:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:149:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:150:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:151:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:157:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:158:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:159:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:162:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:164:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:166:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:168:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:170:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:172:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:177:35: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:179:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:180:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:185:35: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:187:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:188:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:193:35: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:195:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:196:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:200:35: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:201:38: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:202:41: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:203:44: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:204:44: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
82 errors
|
||||
CantAnnotateStaticClass3.java:94:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:120:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:121:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:122:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:128:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:129:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:130:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:132:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:134:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:134:28: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:135:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:135:28: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:136:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:136:28: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:138:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:139:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:140:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:142:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:142:28: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:143:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:143:28: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:144:17: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:144:28: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:149:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:150:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:151:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:157:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:158:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:159:19: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:162:27: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:164:27: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:166:27: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:168:27: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:170:27: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:172:27: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:99:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:101:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:106:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:108:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:113:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:115:23: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:177:40: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:179:46: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:180:46: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:185:40: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:187:46: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:188:46: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:193:40: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:195:46: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:196:46: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:200:38: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:201:38: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:201:49: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:202:44: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:203:44: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:203:55: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
CantAnnotateStaticClass3.java:204:44: compiler.err.cant.type.annotate.scoping.1: @Top.TA
|
||||
CantAnnotateStaticClass3.java:204:55: compiler.err.cant.type.annotate.scoping.1: @Top.TB
|
||||
91 errors
|
||||
|
@ -10,7 +10,7 @@ class DeclarationAnnotation {
|
||||
Object e1 = new @DA int[5];
|
||||
Object e2 = new @DA String[42];
|
||||
Object e3 = new @DA Object();
|
||||
Object ok = new @DA Object() { };
|
||||
Object e4 = new @DA Object() { };
|
||||
}
|
||||
|
||||
@interface DA { }
|
||||
|
@ -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:11: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
|
||||
|
@ -5,10 +5,13 @@
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
|
||||
*/
|
||||
import java.lang.annotation.*;
|
||||
|
||||
class MissingAnnotationValue {
|
||||
void test() {
|
||||
String @A [] s;
|
||||
}
|
||||
}
|
||||
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface A { int field(); }
|
||||
|
@ -1,2 +1,2 @@
|
||||
MissingAnnotationValue.java:10:12: compiler.err.annotation.missing.default.value: A, field
|
||||
MissingAnnotationValue.java:12:12: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
|
@ -5,10 +5,13 @@
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
|
||||
*/
|
||||
import java.lang.annotation.*;
|
||||
|
||||
class MissingAnnotationValue {
|
||||
void innermethod() {
|
||||
class Inner<@A K> { }
|
||||
}
|
||||
}
|
||||
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface A { int field(); }
|
||||
|
@ -1,2 +1,2 @@
|
||||
MissingAnnotationValue.java:10:17: compiler.err.annotation.missing.default.value: A, field
|
||||
MissingAnnotationValue.java:12:17: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
|
@ -5,10 +5,13 @@
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
|
||||
*/
|
||||
import java.lang.annotation.*;
|
||||
|
||||
class MissingAnnotationValue {
|
||||
void test() {
|
||||
String[] a = new String @A [5];
|
||||
}
|
||||
}
|
||||
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface A { int field(); }
|
||||
|
@ -1,2 +1,2 @@
|
||||
MissingAnnotationValue.java:10:29: compiler.err.annotation.missing.default.value: A, field
|
||||
MissingAnnotationValue.java:12:29: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
|
@ -5,8 +5,13 @@
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
|
||||
*/
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
class MissingAnnotationValue {
|
||||
void test(@A MissingAnnotationValue this) { }
|
||||
}
|
||||
|
||||
@Target({TYPE_USE})
|
||||
@interface A { int field(); }
|
||||
|
@ -1,2 +1,2 @@
|
||||
MissingAnnotationValue.java:9:13: compiler.err.annotation.missing.default.value: A, field
|
||||
MissingAnnotationValue.java:13:13: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
|
@ -5,8 +5,11 @@
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
|
||||
*/
|
||||
import java.lang.annotation.*;
|
||||
|
||||
class MissingAnnotationValue<K> {
|
||||
MissingAnnotationValue<@A String> l;
|
||||
}
|
||||
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface A { int field(); }
|
||||
|
@ -1,2 +1,2 @@
|
||||
MissingAnnotationValue.java:9:26: compiler.err.annotation.missing.default.value: A, field
|
||||
MissingAnnotationValue.java:11:26: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
|
@ -5,7 +5,10 @@
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
|
||||
*/
|
||||
import java.lang.annotation.*;
|
||||
|
||||
class MissingAnnotationValue<@A K> {
|
||||
}
|
||||
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface A { int field(); }
|
||||
|
@ -1,2 +1,2 @@
|
||||
MissingAnnotationValue.java:8:30: compiler.err.annotation.missing.default.value: A, field
|
||||
MissingAnnotationValue.java:10:30: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
|
@ -5,8 +5,11 @@
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
|
||||
*/
|
||||
import java.lang.annotation.*;
|
||||
|
||||
class MissingAnnotationValue<K> {
|
||||
MissingAnnotationValue<@A ?> l;
|
||||
}
|
||||
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface A { int field(); }
|
||||
|
@ -1,2 +1,2 @@
|
||||
MissingAnnotationValue.java:9:26: compiler.err.annotation.missing.default.value: A, field
|
||||
MissingAnnotationValue.java:11:26: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
|
@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8027262
|
||||
* @summary Stress test for type annotatons
|
||||
* @compile AllLocations.java
|
||||
*/
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import java.io.*;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class AllLocations {
|
||||
|
||||
public class ParamStream<T> extends FileOutputStream {
|
||||
public ParamStream(File f) throws FileNotFoundException { super(f); }
|
||||
}
|
||||
|
||||
public class Inner<S> {
|
||||
public Inner() {}
|
||||
public <@A T> Inner(@B Object o) {}
|
||||
public <@C T> Object g(Inner<@D S> this, Object @E [] o) {
|
||||
return new @F int @G [5];
|
||||
}
|
||||
}
|
||||
|
||||
public <@H T extends @I Inner<@J ? extends @K String>> AllLocations(Object o) {}
|
||||
|
||||
public @L Object @M [] @N [] arr = new @O Object @P [5] @Q [5];
|
||||
|
||||
public Inner<@R ? extends @S Inner<@T ? extends @U Integer>> inner;
|
||||
|
||||
public Function func(@V AllLocations this) {
|
||||
try (final ParamStream<@W Integer @X []> fs = new ParamStream<@Y Integer @Z []>(new File("testfile"))) {
|
||||
return @AA AllLocations.Inner<@AB String>::<@AC Integer>new;
|
||||
} catch(@AD Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public <@AE T extends @AF Inner<@AG Integer @AH []>> Function func2() {
|
||||
arr[0][0] = new @AI Inner((@AJ Object) arr[0]);
|
||||
return Ext.f((@AK Object) arr[0]) instanceof @AL Inner @AM [] @AN [] ?
|
||||
@AO @AP Ext::<@AQ @AR Integer> f :
|
||||
@AS @AT Ext::<@AU @AV Integer> f;
|
||||
}
|
||||
|
||||
public Object func3(Object @AW [] arr) {
|
||||
Inner<@AX ? extends @AY Inner<@AZ ? extends @BA Integer>> loc;
|
||||
if (arr[0] instanceof @BB Inner @BC [] @BD [])
|
||||
return this.<Inner<@BE Integer @BF []>> func4();
|
||||
else
|
||||
return new <@BG Inner<@BH Integer>> @BI Inner<@BJ Inner<@BK Integer>>(null);
|
||||
}
|
||||
|
||||
public <@BL T extends @BO Inner<@BP Integer @BQ []>>
|
||||
@BR Inner<@BS Inner<@BT String>> func4() {
|
||||
return (@BU Inner<@BV Inner<@BW String>>)
|
||||
new <@BX Inner<@BY Integer>> @BZ Inner<@CA Inner<@CB String>>(null) {};
|
||||
}
|
||||
|
||||
{ Inner<@CC ? extends @CD Inner<@CE ? extends @CF Integer>> loc =
|
||||
new @CG Inner<@CH Inner<@CI Integer>>() {};
|
||||
Ext.func(Ext.func(@CJ WeakReference::new));
|
||||
Ext.func(Ext.func(@CK Ext::<@CL Integer>f));
|
||||
Ext.func((@CM Object a) -> { @CN Object b = a; return b; });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Ext {
|
||||
public static <@CO T> Object f(Object o) {
|
||||
return null;
|
||||
}
|
||||
public static Function func(Function f) { return f; }
|
||||
}
|
||||
|
||||
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface A { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface B { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface C { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface D { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface E { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface F { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface G { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface H { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface I { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface J { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface K { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface L { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface M { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface N { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface O { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface P { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface Q { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface R { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface S { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface T { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface U { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface V { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface W { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface X { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface Y { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface Z { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AA { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AB { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AC { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AD { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AE { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AF { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AG { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AH { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AI { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AJ { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AK { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AL { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AM { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AN { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AO { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AP { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AQ { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AR { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AS { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AT { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AU { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AV { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AW { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AX { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AY { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface AZ { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BA { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BB { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BC { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BD { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BE { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BF { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BG { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BH { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BI { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BJ { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BK { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BL { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BM { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BN { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BO { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BP { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BQ { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BR { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BS { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BT { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BU { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BV { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BW { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BX { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BY { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BZ { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CA { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CB { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CC { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CD { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CE { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CF { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CG { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CH { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CI { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CJ { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CK { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CL { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CM { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CN { }
|
||||
@Retention(RUNTIME) @Target({TYPE_USE}) @interface CO { }
|
@ -52,28 +52,40 @@ class Expressions {
|
||||
}
|
||||
|
||||
void objectCreationArray() {
|
||||
Object a1 = new @A String [] [] { };
|
||||
Object a2 = new @A String [1] [];
|
||||
Object a3 = new @A String [1] [2];
|
||||
Object a1 = new @C String [] [] { };
|
||||
Object a2 = new @D String [1] [];
|
||||
Object a3 = new @E String [1] [2];
|
||||
|
||||
Object b1 = new @A String @B(0) [] [] { };
|
||||
Object b2 = new @A String @B(0) [1] [];
|
||||
Object b3 = new @A String @B(0) [1] [2];
|
||||
Object b1 = new @F String @B(1) [] [] { };
|
||||
Object b2 = new @G String @B(2) [1] [];
|
||||
Object b3 = new @H String @B(3) [1] [2];
|
||||
|
||||
Object c1 = new @A String [] @B(0) [] { };
|
||||
Object c2 = new @A String [1] @B(0) [];
|
||||
Object c3 = new @A String [1] @B(0) [2];
|
||||
Object c1 = new @I String [] @B(4) [] { };
|
||||
Object c2 = new @J String [1] @B(5) [];
|
||||
Object c3 = new @K String [1] @B(6) [2];
|
||||
|
||||
Object d1 = new @A String @B(0) [] @B(0) [] { };
|
||||
Object d2 = new @A String @B(0) [1] @B(0) [];
|
||||
Object d3 = new @A String @B(0) [1] @B(0) [2];
|
||||
Object d1 = new @L String @B(7) [] @B(8) [] { };
|
||||
Object d2 = new @M String @B(9) [1] @B(10) [];
|
||||
Object d3 = new @N String @B(11) [1] @B(12) [2];
|
||||
|
||||
Object rand = new @A String @B(value = 0) [1] @B(value = 0) [2];
|
||||
Object rand = new @O String @B(value = 13) [1] @B(value = 14) [2];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface A { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface C { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface D { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface E { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface F { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface G { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface H { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface I { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface J { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface K { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface L { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface M { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface N { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface O { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
|
||||
@interface A { }
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
|
||||
@interface B { int value(); }
|
||||
@interface B { int value(); }
|
||||
|
@ -128,6 +128,7 @@ class Test1 {
|
||||
MyList<Outer . @Cv("Data") Static> f9;
|
||||
// Illegal:
|
||||
// MyList<@A Outer . @Cv("Data") Static> f9;
|
||||
|
||||
}
|
||||
|
||||
class Test2 {
|
||||
|
@ -54,14 +54,6 @@ class WithValue {
|
||||
<T extends Runnable> void accept(@B("m") WithValue this, T r) throws Exception { }
|
||||
}
|
||||
|
||||
class WithFinal {
|
||||
void plain(final @B("m") WithFinal this) { }
|
||||
<T> void generic(final @B("m") WithFinal this) { }
|
||||
void withException(final @B("m") WithFinal this) throws Exception { }
|
||||
String nonVoid(final @B("m") WithFinal this) { return null; }
|
||||
<T extends Runnable> void accept(final @B("m") WithFinal this, T r) throws Exception { }
|
||||
}
|
||||
|
||||
class WithBody {
|
||||
Object f;
|
||||
|
||||
|
@ -17,12 +17,12 @@ RepeatingTypeAnnotations.java:89:18: compiler.err.duplicate.annotation.missing.c
|
||||
RepeatingTypeAnnotations.java:89:33: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
RepeatingTypeAnnotations.java:93:19: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
RepeatingTypeAnnotations.java:93:35: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
RepeatingTypeAnnotations.java:97:34: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
RepeatingTypeAnnotations.java:97:19: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
RepeatingTypeAnnotations.java:101:26: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
RepeatingTypeAnnotations.java:97:34: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
RepeatingTypeAnnotations.java:101:37: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
RepeatingTypeAnnotations.java:101:72: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
RepeatingTypeAnnotations.java:101:26: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
RepeatingTypeAnnotations.java:101:56: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
RepeatingTypeAnnotations.java:101:72: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
|
||||
- compiler.note.unchecked.filename: RepeatingTypeAnnotations.java
|
||||
- compiler.note.unchecked.recompile
|
||||
25 errors
|
||||
|
@ -25,72 +25,110 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for class extends clauses
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java ClassExtends.java
|
||||
* @run main Driver ClassExtends
|
||||
*/
|
||||
public class ClassExtends {
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1),
|
||||
@TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1)
|
||||
@TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
|
||||
public String regularClass() {
|
||||
return "class Test extends @TA Object implements Cloneable, @TB Runnable {"
|
||||
return "class %TEST_CLASS_NAME% extends @TA Object implements Cloneable, @TB Runnable {"
|
||||
+ " public void run() { } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
|
||||
genericLocation = { 3, 1 })
|
||||
})
|
||||
@TADescription(annotation = "RTAs", type = CLASS_EXTENDS, typeIndex = -1)
|
||||
@TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1)
|
||||
public String regularClassRepeatableAnnotation() {
|
||||
return "class %TEST_CLASS_NAME% extends @RTA @RTA Object implements Cloneable, @RTB @RTB Runnable {"
|
||||
+ " public void run() { } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
|
||||
genericLocation = { 3, 1 })
|
||||
public String regularClassExtendsParametrized() {
|
||||
return "class Test extends HashMap<@TA String, String> implements Cloneable, Map<String, @TB String>{ } ";
|
||||
return "class %TEST_CLASS_NAME% extends HashMap<@TA String, String> implements Cloneable, Map<String, @TB String>{ } ";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1),
|
||||
@TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "RTAs", type = CLASS_EXTENDS, typeIndex = -1,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1,
|
||||
genericLocation = { 3, 1 })
|
||||
public String regularClassExtendsParametrizedRepeatableAnnotation() {
|
||||
return "class %TEST_CLASS_NAME% extends HashMap<@RTA @RTA String, String> implements Cloneable, Map<String, @RTB @RTB String>{ } ";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1)
|
||||
@TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
|
||||
public String abstractClass() {
|
||||
return "abstract class Test extends @TA Date implements Cloneable, @TB Runnable {"
|
||||
return "abstract class %TEST_CLASS_NAME% extends @TA Date implements Cloneable, @TB Runnable {"
|
||||
+ " public void run() { } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
|
||||
genericLocation = { 3, 1 })
|
||||
})
|
||||
@TADescription(annotation = "RTAs", type = CLASS_EXTENDS, typeIndex = -1)
|
||||
@TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1)
|
||||
public String abstractClassRepeatableAnnotation() {
|
||||
return "abstract class %TEST_CLASS_NAME% extends @RTA @RTA Date implements Cloneable, @RTB @RTB Runnable {"
|
||||
+ " public void run() { } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CLASS_EXTENDS, typeIndex = -1,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1,
|
||||
genericLocation = { 3, 1 })
|
||||
public String abstractClassExtendsParametrized() {
|
||||
return "abstract class Test extends HashMap<@TA String, String> implements Cloneable, Map<String, @TB String>{ } ";
|
||||
return "abstract class %TEST_CLASS_NAME% extends HashMap<@RTA @RTA String, String> implements Cloneable, Map<String, @RTB @RTB String>{ } ";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
|
||||
public String regularInterface() {
|
||||
return "interface Test extends Cloneable, @TB Runnable { }";
|
||||
return "interface %TEST_CLASS_NAME% extends Cloneable, @TB Runnable { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CLASS_EXTENDS, typeIndex = 1)
|
||||
public String regularInterfaceRepetableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME% extends Cloneable, @RTA @RTA Runnable { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
|
||||
genericLocation = { 3, 1 })
|
||||
public String regularInterfaceExtendsParametrized() {
|
||||
return "interface Test extends Cloneable, Map<String, @TB String>{ } ";
|
||||
return "interface %TEST_CLASS_NAME% extends Cloneable, Map<String, @TB String>{ } ";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1,
|
||||
genericLocation = { 3, 1 })
|
||||
public String regularInterfaceExtendsParametrizedRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME% extends Cloneable, Map<String, @RTB @RTB String>{ } ";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
|
||||
public String regularEnum() {
|
||||
return "enum Test implements Cloneable, @TB Runnable { TEST; public void run() { } }";
|
||||
return "enum %TEST_CLASS_NAME% implements Cloneable, @TB Runnable { TEST; public void run() { } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1)
|
||||
public String regularEnumRepeatableAnnotation() {
|
||||
return "enum %TEST_CLASS_NAME% implements Cloneable, @RTB @RTB Runnable { TEST; public void run() { } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
|
||||
genericLocation = { 3, 0 })
|
||||
public String regularEnumExtendsParametrized() {
|
||||
return
|
||||
"enum Test implements Cloneable, Comparator<@TB String> { TEST; "
|
||||
"enum %TEST_CLASS_NAME% implements Cloneable, Comparator<@TB String> { TEST; "
|
||||
+ "public int compare(String a, String b) { return 0; }}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1,
|
||||
genericLocation = { 3, 0 })
|
||||
public String regularEnumExtendsParametrizedRepeatableAnnotation() {
|
||||
return
|
||||
"enum %TEST_CLASS_NAME% implements Cloneable, Comparator<@RTB @RTB String> { TEST; "
|
||||
+ "public int compare(String a, String b) { return 0; }}";
|
||||
}
|
||||
}
|
||||
|
@ -25,134 +25,232 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for class type parameters
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java ClassTypeParam.java
|
||||
* @run main Driver ClassTypeParam
|
||||
*/
|
||||
public class ClassTypeParam {
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
})
|
||||
public String regularClass() {
|
||||
return "class Test<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularClass1() {
|
||||
return "class %TEST_CLASS_NAME%<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularClass2() {
|
||||
return "class Test<@TA K extends @TB Date, @TC V extends @TE Cloneable> { }";
|
||||
return "class %TEST_CLASS_NAME%<@TA K extends @TB Date, @TC V extends @TE Cloneable> { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
public String regularClassParameterized() {
|
||||
return "class Test<K extends @TA Map<String, @TB String>, V extends @TC List<@TD List<@TE Object>>> { }";
|
||||
return "class %TEST_CLASS_NAME%<K extends @TA Map<String, @TB String>, V extends @TC List<@TD List<@TE Object>>> { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
|
||||
@TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
|
||||
@TADescription(annotation = "TG", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
@TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "TG", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
public String regularClassParameterized2() {
|
||||
return "class Test<K extends @TG Object & @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
|
||||
return "class %TEST_CLASS_NAME%<K extends @TG Object & @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String abstractClass() {
|
||||
return "abstract class Test<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
|
||||
return "abstract class %TEST_CLASS_NAME%<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
|
||||
@TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
@TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
public String abstractClassParameterized() {
|
||||
return "abstract class Test<K extends @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
|
||||
return "abstract class %TEST_CLASS_NAME%<K extends @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularInterface() {
|
||||
return "interface Test<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
|
||||
return "interface %TEST_CLASS_NAME%<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
public String regularInterfaceParameterized() {
|
||||
return "interface Test<K extends @TA Map<String, @TB String>, V extends @TC List<@TD List<@TE Object>>> { }";
|
||||
return "interface %TEST_CLASS_NAME%<K extends @TA Map<String, @TB String>, V extends @TC List<@TD List<@TE Object>>> { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
|
||||
@TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
|
||||
@TADescription(annotation = "TG", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
@TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "TG", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
public String regularInterfaceParameterized2() {
|
||||
return "interface Test<K extends @TG Object & @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
|
||||
return "interface %TEST_CLASS_NAME%<K extends @TG Object & @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN)
|
||||
public String useInReturn1() {
|
||||
return "class Test<T> { @TA T m() { throw new RuntimeException(); } }";
|
||||
return "class %TEST_CLASS_NAME%<T> { @TA T m() { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {3, 0})
|
||||
public String useInReturn2() {
|
||||
return "class Test<T> { Class<@TA T> m() { throw new RuntimeException(); } }";
|
||||
return "class %TEST_CLASS_NAME%<T> { Class<@TA T> m() { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0, genericLocation = {3, 0})
|
||||
public String useInParam1() {
|
||||
return "class Test<T> { void m(Class<@TA T> p) { throw new RuntimeException(); } }";
|
||||
return "class %TEST_CLASS_NAME%<T> { void m(Class<@TA T> p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0, genericLocation = {3, 0})
|
||||
public String useInParam2() {
|
||||
return "class Test { void m(Class<@TA Object> p) { throw new RuntimeException(); } }";
|
||||
return "class %TEST_CLASS_NAME% { void m(Class<@TA Object> p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CLASS_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = CLASS_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "RTEs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularClassRepeatableAnnotation1() {
|
||||
return "class %TEST_CLASS_NAME%<@RTA @RTA K extends @RTB @RTB Date, @RTC @RTC V extends @RTD @RTD Object & @RTE @RTE Cloneable> { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CLASS_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = CLASS_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTEs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularClassRepeatableAnnotation2() {
|
||||
return "class %TEST_CLASS_NAME%<@RTA @RTA K extends @RTB @RTB Date, @RTC @RTC V extends @RTE @RTE Cloneable> { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "RTCs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "RTEs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
public String regularClassParameterizedRepeatableAnnotation() {
|
||||
return "class %TEST_CLASS_NAME%<K extends @RTA @RTA Map<String, @RTB @RTB String>," +
|
||||
" V extends @RTC @RTC List<@RTD @RTD List<@RTE @RTE Object>>> { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "RTCs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "RTEs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
@TADescription(annotation = "RTFs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "RTGs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
public String regularClassParameterizedRepeatableAnnotation2() {
|
||||
return "class %TEST_CLASS_NAME%<K extends @RTG @RTG Object & @RTA @RTA Map<String, @RTB @RTB String>," +
|
||||
" V extends @RTF @RTF Object & @RTC @RTC List<@RTD @RTD List<@RTE @RTE Object>>> { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CLASS_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = CLASS_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "RTEs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String abstractClassRepeatableAnnotation() {
|
||||
return "abstract class %TEST_CLASS_NAME%<@RTA @RTA K extends @RTB @RTB Date," +
|
||||
" @RTC @RTC V extends @RTD @RTD Object & @RTE @RTE Cloneable> { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "RTCs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "RTEs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
@TADescription(annotation = "RTFs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
public String abstractClassParameterizedRepeatableAnnotation() {
|
||||
return "abstract class %TEST_CLASS_NAME%<K extends @RTA @RTA Map<String, @RTB @RTB String>," +
|
||||
" V extends @RTF @RTF Object & @RTC @RTC List<@RTD @RTD List<@RTE @RTE Object>>> { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CLASS_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = CLASS_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "RTEs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularInterfaceRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME%<@RTA @RTA K extends @RTB @RTB Date," +
|
||||
" @RTC @RTC V extends @RTD @RTD Object & @RTE @RTE Cloneable> { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "RTCs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "RTEs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
public String regularInterfaceParameterizedRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME%<K extends @RTA @RTA Map<String, @RTB @RTB String>," +
|
||||
" V extends @RTC @RTC List<@RTD @RTD List<@RTE @RTE Object>>> { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "RTCs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "RTEs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
@TADescription(annotation = "RTFs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "RTGs", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
public String regularInterfaceParameterizedRepeatableAnnotation2() {
|
||||
return "interface %TEST_CLASS_NAME%<K extends @RTG @RTG Object & @RTA @RTA Map<String, @RTB @RTB String>," +
|
||||
" V extends @RTF @RTF Object & @RTC @RTC List<@RTD @RTD List<@RTE @RTE Object>>> { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN)
|
||||
public String useInReturnRepeatableAnnotation1() {
|
||||
return "class %TEST_CLASS_NAME%<T> { @RTA @RTA T m() { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN, genericLocation = {3, 0})
|
||||
public String useInReturnRepeatableAnnotation2() {
|
||||
return "class %TEST_CLASS_NAME%<T> { Class<@RTA @RTA T> m() { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0, genericLocation = {3, 0})
|
||||
public String useInParamRepeatableAnnotation1() {
|
||||
return "class %TEST_CLASS_NAME%<T> { void m(Class<@RTA @RTA T> p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0, genericLocation = {3, 0})
|
||||
public String useInParamRepeatableAnnotation2() {
|
||||
return "class %TEST_CLASS_NAME% { void m(Class<@RTA @RTA Object> p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for constructor invocation type argument
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java ConstructorInvocationTypeArgument.java
|
||||
* @run main Driver ConstructorInvocationTypeArgument
|
||||
*/
|
||||
|
||||
import static com.sun.tools.classfile.TypeAnnotation.TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT;
|
||||
|
||||
public class ConstructorInvocationTypeArgument {
|
||||
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 4)
|
||||
@TADescription(annotation = "TB", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 0)
|
||||
public String generic1() {
|
||||
return "class %TEST_CLASS_NAME% { <T> %TEST_CLASS_NAME%(int i) { new <@TA T>%TEST_CLASS_NAME%(); }" +
|
||||
" <T> %TEST_CLASS_NAME%() { <@TB String>this(0); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 0)
|
||||
public String generic2() {
|
||||
return "class Super { <T> Super(int i) { } } " +
|
||||
"class %TEST_CLASS_NAME% extends Super { <T> %TEST_CLASS_NAME%() { <@TA String>super(0); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 4)
|
||||
@TADescription(annotation = "RTBs", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 0)
|
||||
public String genericRepeatableAnnotation1() {
|
||||
return "class %TEST_CLASS_NAME% { <T> %TEST_CLASS_NAME%(int i) { new <@RTA @RTA T>%TEST_CLASS_NAME%(); }" +
|
||||
" <T> %TEST_CLASS_NAME%() { <@RTB @RTB String>this(0); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 0)
|
||||
public String genericRepeatableAnnotation2() {
|
||||
return "class Super { <T> Super(int i) { } } " +
|
||||
"class %TEST_CLASS_NAME% extends Super { <T> %TEST_CLASS_NAME%() { <@RTA @RTA String>super(0); } }";
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8026791
|
||||
* @bug 8026791 8042451
|
||||
* @summary Test population of reference info for constructor results
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java Constructors.java
|
||||
* @run main Driver Constructors
|
||||
@ -33,52 +33,44 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
public class Constructors {
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN),
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
public String regularClass() {
|
||||
return "class Test { @TA Test() {}" +
|
||||
" @TB Test(@TC int b) {} }";
|
||||
return "class %TEST_CLASS_NAME% { @TA %TEST_CLASS_NAME%() {}" +
|
||||
" @TB %TEST_CLASS_NAME%(@TC int b) {} }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {1, 0}),
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
})
|
||||
@TestClass("Test$Inner")
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TestClass("%TEST_CLASS_NAME%$Inner")
|
||||
public String innerClass() {
|
||||
return "class Test { class Inner {" +
|
||||
return "class %TEST_CLASS_NAME% { class Inner {" +
|
||||
" @TA Inner() {}" +
|
||||
" @TB Inner(@TC int b) {}" +
|
||||
" } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RECEIVER),
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}),
|
||||
@TADescription(annotation = "TC", type = METHOD_RECEIVER),
|
||||
@TADescription(annotation = "TD", type = METHOD_RETURN, genericLocation = {1, 0}),
|
||||
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
})
|
||||
@TestClass("Test$Inner")
|
||||
@TADescription(annotation = "TA", type = METHOD_RECEIVER)
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "TC", type = METHOD_RECEIVER)
|
||||
@TADescription(annotation = "TD", type = METHOD_RETURN, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TestClass("%TEST_CLASS_NAME%$Inner")
|
||||
public String innerClass2() {
|
||||
return "class Test { class Inner {" +
|
||||
" @TB Inner(@TA Test Test.this) {}" +
|
||||
" @TD Inner(@TC Test Test.this, @TE int b) {}" +
|
||||
return "class %TEST_CLASS_NAME% { class Inner {" +
|
||||
" @TB Inner(@TA %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this) {}" +
|
||||
" @TD Inner(@TC %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this, @TE int b) {}" +
|
||||
" } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RECEIVER),
|
||||
@TADescription(annotation = "TB", type = METHOD_RECEIVER, genericLocation = {1, 0}),
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}),
|
||||
@TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0}),
|
||||
@TADescription(annotation = "TE", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}),
|
||||
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_RECEIVER)
|
||||
@TADescription(annotation = "TB", type = METHOD_RECEIVER, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
|
||||
@TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "TE", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
|
||||
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TestClass("Outer$Middle$Inner")
|
||||
public String innerClass3() {
|
||||
return "class Outer { class Middle { class Inner {" +
|
||||
@ -87,24 +79,49 @@ public class Constructors {
|
||||
" } } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 4),
|
||||
@TADescription(annotation = "TB", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 0)
|
||||
})
|
||||
public String generic1() {
|
||||
return "class Test { <T> Test(int i) { new <@TA T>Test(); }" +
|
||||
" <T> Test() { <@TB String>this(0); } }";
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
public String regularClassRepeatableAnnotation() {
|
||||
return "class %TEST_CLASS_NAME% { @RTA @RTA %TEST_CLASS_NAME%() {}" +
|
||||
" @RTB @RTB %TEST_CLASS_NAME%(@RTC @RTC int b) {} }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 0)
|
||||
})
|
||||
public String generic2() {
|
||||
return "class Super { <T> Super(int i) { } } " +
|
||||
"class Test extends Super { <T> Test() { <@TA String>super(0); } }";
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TestClass("%TEST_CLASS_NAME%$Inner")
|
||||
public String innerClassRepeatableAnnotation() {
|
||||
return "class %TEST_CLASS_NAME% { class Inner {" +
|
||||
" @RTA @RTA Inner() {}" +
|
||||
" @RTB @RTB Inner(@RTC @RTC int b) {}" +
|
||||
" } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RECEIVER)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RECEIVER)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_RETURN, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "RTEs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TestClass("%TEST_CLASS_NAME%$Inner")
|
||||
public String innerClassRepeatableAnnotation2() {
|
||||
return "class %TEST_CLASS_NAME% { class Inner {" +
|
||||
" @RTB @RTB Inner(@RTA @RTA %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this) {}" +
|
||||
" @RTD @RTD Inner(@RTC @RTC %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this, @RTE @RTE int b) {}" +
|
||||
" } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RECEIVER)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RECEIVER, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
|
||||
@TADescription(annotation = "RTDs", type = METHOD_RECEIVER, genericLocation = {1, 0})
|
||||
@TADescription(annotation = "RTEs", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
|
||||
@TADescription(annotation = "RTFs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TestClass("Outer$Middle$Inner")
|
||||
public String innerClassRepatableAnnotation3() {
|
||||
return "class Outer { class Middle { class Inner {" +
|
||||
" @RTC @RTC Inner(@RTA @RTA Outer. @RTB @RTB Middle Middle.this) {}" +
|
||||
" @RTE @RTE Inner(@RTD @RTD Middle Outer.Middle.this, @RTF @RTF int b) {}" +
|
||||
" } } }";
|
||||
}
|
||||
}
|
||||
|
@ -40,51 +40,75 @@ import com.sun.tools.classfile.ClassFile;
|
||||
import com.sun.tools.classfile.TypeAnnotation;
|
||||
import com.sun.tools.classfile.TypeAnnotation.TargetType;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
public class Driver {
|
||||
|
||||
private static final PrintStream out = System.err;
|
||||
|
||||
private final Object testObject;
|
||||
|
||||
public Driver(Class<?> clazz) throws IllegalAccessException, InstantiationException {
|
||||
testObject = clazz.newInstance();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length == 0 || args.length > 1)
|
||||
throw new IllegalArgumentException("Usage: java Driver <test-name>");
|
||||
String name = args[0];
|
||||
Class<?> clazz = Class.forName(name);
|
||||
new Driver().runDriver(clazz.newInstance());
|
||||
new Driver(Class.forName(name)).runDriver();
|
||||
}
|
||||
|
||||
String[][] extraParamsCombinations = new String[][] {
|
||||
private final String[][] extraParamsCombinations = new String[][] {
|
||||
new String[] { },
|
||||
new String[] { "-g" },
|
||||
};
|
||||
|
||||
protected void runDriver(Object object) throws Exception {
|
||||
private final String[] retentionPolicies = {RetentionPolicy.CLASS.toString(), RetentionPolicy.RUNTIME.toString()};
|
||||
|
||||
protected void runDriver() {
|
||||
int passed = 0, failed = 0;
|
||||
Class<?> clazz = object.getClass();
|
||||
Class<?> clazz = testObject.getClass();
|
||||
out.println("Tests for " + clazz.getName());
|
||||
|
||||
// Find methods
|
||||
for (Method method : clazz.getMethods()) {
|
||||
Map<String, TypeAnnotation.Position> expected = expectedOf(method);
|
||||
if (expected == null)
|
||||
continue;
|
||||
if (method.getReturnType() != String.class)
|
||||
throw new IllegalArgumentException("Test method needs to return a string: " + method);
|
||||
String testClass = testClassOf(method);
|
||||
try {
|
||||
Map<String, TypeAnnotation.Position> expected = expectedOf(method);
|
||||
if (expected == null)
|
||||
continue;
|
||||
if (method.getReturnType() != String.class)
|
||||
throw new IllegalArgumentException("Test method needs to return a string: " + method);
|
||||
|
||||
for (String[] extraParams : extraParamsCombinations) {
|
||||
try {
|
||||
String compact = (String)method.invoke(object);
|
||||
String fullFile = wrap(compact);
|
||||
ClassFile cf = compileAndReturn(fullFile, testClass, extraParams);
|
||||
List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
|
||||
ReferenceInfoUtil.compare(expected, actual, cf);
|
||||
out.println("PASSED: " + method.getName());
|
||||
++passed;
|
||||
} catch (Throwable e) {
|
||||
out.println("FAILED: " + method.getName());
|
||||
out.println(" " + e.toString());
|
||||
++failed;
|
||||
String compact = (String) method.invoke(testObject);
|
||||
for (String retentionPolicy : retentionPolicies) {
|
||||
String testClassName = getTestClassName(method, retentionPolicy);
|
||||
String testClass = testClassOf(method, testClassName);
|
||||
String fullFile = wrap(compact, new HashMap<String, String>() {{
|
||||
put("%RETENTION_POLICY%", retentionPolicy);
|
||||
put("%TEST_CLASS_NAME%", testClassName);
|
||||
}});
|
||||
for (String[] extraParams : extraParamsCombinations) {
|
||||
try {
|
||||
ClassFile cf = compileAndReturn(fullFile, testClass, extraParams);
|
||||
List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
|
||||
ReferenceInfoUtil.compare(expected, actual, cf);
|
||||
out.format("PASSED: %s %s%n", testClassName, Arrays.toString(extraParams));
|
||||
++passed;
|
||||
} catch (Throwable e) {
|
||||
out.format("FAILED: %s %s%n", testClassName, Arrays.toString(extraParams));
|
||||
out.println(fullFile);
|
||||
out.println(" " + e.toString());
|
||||
e.printStackTrace(out);
|
||||
++failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
out.println("FAILED: " + method.getName());
|
||||
out.println(" " + e.toString());
|
||||
e.printStackTrace(out);
|
||||
++failed;
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +130,7 @@ public class Driver {
|
||||
return null;
|
||||
|
||||
Map<String, TypeAnnotation.Position> result =
|
||||
new HashMap<String, TypeAnnotation.Position>();
|
||||
new HashMap<>();
|
||||
|
||||
if (ta != null)
|
||||
result.putAll(expectedOf(ta));
|
||||
@ -149,33 +173,42 @@ public class Driver {
|
||||
}
|
||||
|
||||
private List<Integer> wrapIntArray(int[] ints) {
|
||||
List<Integer> list = new ArrayList<Integer>(ints.length);
|
||||
List<Integer> list = new ArrayList<>(ints.length);
|
||||
for (int i : ints)
|
||||
list.add(i);
|
||||
return list;
|
||||
}
|
||||
|
||||
private String testClassOf(Method m) {
|
||||
private String getTestClassName(Method m, String retentionPolicy) {
|
||||
return format("%s_%s_%s", testObject.getClass().getSimpleName(),
|
||||
m.getName(), retentionPolicy);
|
||||
}
|
||||
|
||||
private String testClassOf(Method m, String testClassName) {
|
||||
TestClass tc = m.getAnnotation(TestClass.class);
|
||||
if (tc != null) {
|
||||
return tc.value();
|
||||
return tc.value().replace("%TEST_CLASS_NAME%", testClassName);
|
||||
} else {
|
||||
return "Test";
|
||||
return testClassName;
|
||||
}
|
||||
}
|
||||
|
||||
private ClassFile compileAndReturn(String fullFile, String testClass, String... extraParams) throws Exception {
|
||||
File source = writeTestFile(fullFile);
|
||||
File clazzFile = compileTestFile(source, testClass);
|
||||
File source = writeTestFile(fullFile, testClass);
|
||||
File clazzFile = compileTestFile(source, testClass, extraParams);
|
||||
return ClassFile.read(clazzFile);
|
||||
}
|
||||
|
||||
protected File writeTestFile(String fullFile) throws IOException {
|
||||
File f = new File("Test.java");
|
||||
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
|
||||
out.println(fullFile);
|
||||
out.close();
|
||||
return f;
|
||||
protected File writeTestFile(String fullFile, String testClass) throws IOException {
|
||||
File f = new File(getClassDir(), format("%s.java", testClass));
|
||||
try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)))) {
|
||||
out.println(fullFile);
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
private String getClassDir() {
|
||||
return System.getProperty("test.classes", Driver.class.getResource(".").getPath());
|
||||
}
|
||||
|
||||
protected File compileTestFile(File f, String testClass, String... extraParams) {
|
||||
@ -185,20 +218,15 @@ public class Driver {
|
||||
int rc = com.sun.tools.javac.Main.compile(options.toArray(new String[options.size()]));
|
||||
if (rc != 0)
|
||||
throw new Error("compilation failed. rc=" + rc);
|
||||
String path;
|
||||
if (f.getParent() != null) {
|
||||
path = f.getParent();
|
||||
} else {
|
||||
path = "";
|
||||
}
|
||||
|
||||
return new File(path + testClass + ".class");
|
||||
String path = f.getParent() != null ? f.getParent() : "";
|
||||
return new File(path, format("%s.class", testClass));
|
||||
}
|
||||
|
||||
private String wrap(String compact) {
|
||||
private String wrap(String compact, Map<String, String> replacements) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
// Automatically import java.util
|
||||
sb.append("\nimport java.io.*;");
|
||||
sb.append("\nimport java.util.*;");
|
||||
sb.append("\nimport java.lang.annotation.*;");
|
||||
|
||||
@ -208,7 +236,7 @@ public class Driver {
|
||||
&& !compact.contains("interface")
|
||||
&& !compact.contains("enum");
|
||||
if (isSnippet)
|
||||
sb.append("class Test {\n");
|
||||
sb.append("class %TEST_CLASS_NAME% {\n");
|
||||
|
||||
sb.append(compact);
|
||||
sb.append("\n");
|
||||
@ -224,41 +252,102 @@ public class Driver {
|
||||
}
|
||||
|
||||
// create A ... F annotation declarations
|
||||
sb.append("\n@interface A {}");
|
||||
sb.append("\n@interface B {}");
|
||||
sb.append("\n@interface C {}");
|
||||
sb.append("\n@interface D {}");
|
||||
sb.append("\n@interface E {}");
|
||||
sb.append("\n@interface F {}");
|
||||
sb.append("\n@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface A {}");
|
||||
sb.append("\n@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface B {}");
|
||||
sb.append("\n@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface C {}");
|
||||
sb.append("\n@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface D {}");
|
||||
sb.append("\n@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface E {}");
|
||||
sb.append("\n@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface F {}");
|
||||
|
||||
// create TA ... TF proper type annotations
|
||||
sb.append("\n");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TA {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TB {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TC {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TD {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TE {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TF {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TG {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TH {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TI {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TJ {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TK {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TL {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TM {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
" @Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TA {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TB {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TC {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TD {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TE {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TF {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TG {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TH {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TI {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TJ {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TK {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TL {}");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface TM {}");
|
||||
|
||||
// create RTA, RTAs, RTB, RTBs for repeating type annotations
|
||||
// create RT?, RT?s for repeating type annotations
|
||||
sb.append("\n");
|
||||
sb.append("\n@Repeatable(RTAs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTA {}");
|
||||
sb.append("\n@Repeatable(RTBs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTB {}");
|
||||
sb.append("\n@Repeatable(RTAs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTA {}");
|
||||
sb.append("\n@Repeatable(RTBs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTB {}");
|
||||
sb.append("\n@Repeatable(RTCs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTC {}");
|
||||
sb.append("\n@Repeatable(RTDs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTD {}");
|
||||
sb.append("\n@Repeatable(RTEs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTE {}");
|
||||
sb.append("\n@Repeatable(RTFs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTF {}");
|
||||
sb.append("\n@Repeatable(RTGs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTG {}");
|
||||
sb.append("\n@Repeatable(RTHs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTH {}");
|
||||
sb.append("\n@Repeatable(RTIs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTI {}");
|
||||
sb.append("\n@Repeatable(RTJs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTJ {}");
|
||||
sb.append("\n@Repeatable(RTKs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTK {}");
|
||||
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTAs { RTA[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTBs { RTB[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTAs { RTA[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTBs { RTB[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTCs { RTC[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTDs { RTD[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTEs { RTE[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTFs { RTF[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTGs { RTG[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTHs { RTH[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTIs { RTI[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTJs { RTJ[] value(); }");
|
||||
sb.append("\n@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" +
|
||||
"@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface RTKs { RTK[] value(); }");
|
||||
|
||||
sb.append("\n@Target(value={ElementType.TYPE,ElementType.FIELD,ElementType.METHOD,ElementType.PARAMETER,ElementType.CONSTRUCTOR,ElementType.LOCAL_VARIABLE})");
|
||||
sb.append("\n@interface Decl {}");
|
||||
sb.append("\n@Target(value={ElementType.TYPE,ElementType.FIELD,ElementType.METHOD," +
|
||||
"ElementType.PARAMETER,ElementType.CONSTRUCTOR,ElementType.LOCAL_VARIABLE})");
|
||||
sb.append("\n@Retention(RetentionPolicy.%RETENTION_POLICY%) @interface Decl {}");
|
||||
|
||||
return sb.toString();
|
||||
return replaceAll(sb.toString(), replacements);
|
||||
}
|
||||
|
||||
private String replaceAll(String src, Map<String, String> replacements) {
|
||||
for (Map.Entry<String, String> entry : replacements.entrySet()) {
|
||||
src = src.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
public static final int NOT_SET = -888;
|
||||
@ -267,6 +356,7 @@ public class Driver {
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Repeatable(TADescriptions.class)
|
||||
@interface TADescription {
|
||||
String annotation();
|
||||
|
||||
@ -296,5 +386,5 @@ public class Driver {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@interface TestClass {
|
||||
String value() default "Test";
|
||||
String value();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8028576
|
||||
* @bug 8028576 8042451
|
||||
* @summary Test population of reference info for exception parameters
|
||||
* @author Werner Dietl
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java
|
||||
@ -43,11 +43,9 @@ public class ExceptionParameters {
|
||||
return "void finalException() { try { new Object(); } catch(final @TA Exception e) { } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
|
||||
@TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
public String multipleExceptions1() {
|
||||
return "void multipleExceptions() { " +
|
||||
"try { new Object(); } catch(@TA Exception e) { }" +
|
||||
@ -56,11 +54,9 @@ public class ExceptionParameters {
|
||||
" }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
|
||||
@TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
public String multipleExceptions2() {
|
||||
return "void multipleExceptions() { " +
|
||||
" try { new Object(); " +
|
||||
@ -71,11 +67,9 @@ public class ExceptionParameters {
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
|
||||
@TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
public String multipleExceptions3() {
|
||||
return "void multipleExceptions() { " +
|
||||
" try { new Object(); " +
|
||||
@ -87,4 +81,48 @@ public class ExceptionParameters {
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
|
||||
public String exceptionRepeatableAnnoation() {
|
||||
return "void exception() { try { new Object(); } catch(@RTA @RTA Exception e) { } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "RTCs", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
public String multipleExceptionsRepeatableAnnotation1() {
|
||||
return "void multipleExceptions() { " +
|
||||
"try { new Object(); } catch(@RTA @RTA Exception e) { }" +
|
||||
"try { new Object(); } catch(@RTB @RTB Exception e) { }" +
|
||||
"try { new Object(); } catch(@RTC @RTC Exception e) { }" +
|
||||
" }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "RTCs", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
public String multipleExceptionsRepeatableAnnotation2() {
|
||||
return "void multipleExceptions() { " +
|
||||
" try { new Object(); " +
|
||||
" try { new Object(); " +
|
||||
" try { new Object(); } catch(@RTA @RTA Exception e) { }" +
|
||||
" } catch(@RTB @RTB Exception e) { }" +
|
||||
" } catch(@RTC @RTC Exception e) { }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "RTCs", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
public String multipleExceptionsRepeatableAnnotation3() {
|
||||
return "void multipleExceptions() { " +
|
||||
" try { new Object(); " +
|
||||
" } catch(@RTA @RTA Exception e1) { "+
|
||||
" try { new Object(); " +
|
||||
" } catch(@RTB @RTB Exception e2) {" +
|
||||
" try { new Object(); } catch(@RTC @RTC Exception e3) { }" +
|
||||
" }" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
@ -25,12 +25,12 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for field
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java Fields.java
|
||||
* @run main Driver Fields
|
||||
*/
|
||||
public class Fields {
|
||||
|
||||
// field types
|
||||
@TADescription(annotation = "TA", type = FIELD)
|
||||
public String fieldAsPrimitive() {
|
||||
@ -42,37 +42,31 @@ public class Fields {
|
||||
return "@TA Object test;";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = FIELD),
|
||||
@TADescription(annotation = "TB", type = FIELD,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TC", type = FIELD,
|
||||
genericLocation = { 3, 1 }),
|
||||
@TADescription(annotation = "TD", type = FIELD,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
})
|
||||
@TADescription(annotation = "TA", type = FIELD)
|
||||
@TADescription(annotation = "TB", type = FIELD,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TC", type = FIELD,
|
||||
genericLocation = { 3, 1 })
|
||||
@TADescription(annotation = "TD", type = FIELD,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
public String fieldAsParametrized() {
|
||||
return "@TA Map<@TB String, @TC List<@TD String>> test;";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = FIELD),
|
||||
@TADescription(annotation = "TB", type = FIELD,
|
||||
genericLocation = { 0, 0 }),
|
||||
@TADescription(annotation = "TC", type = FIELD,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
})
|
||||
@TADescription(annotation = "TA", type = FIELD)
|
||||
@TADescription(annotation = "TB", type = FIELD,
|
||||
genericLocation = { 0, 0 })
|
||||
@TADescription(annotation = "TC", type = FIELD,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
public String fieldAsArray() {
|
||||
return "@TC String @TA [] @TB [] test;";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = FIELD),
|
||||
@TADescription(annotation = "TB", type = FIELD,
|
||||
genericLocation = { 0, 0 }),
|
||||
@TADescription(annotation = "TC", type = FIELD,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
})
|
||||
@TADescription(annotation = "TA", type = FIELD)
|
||||
@TADescription(annotation = "TB", type = FIELD,
|
||||
genericLocation = { 0, 0 })
|
||||
@TADescription(annotation = "TC", type = FIELD,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
public String fieldAsArrayOld() {
|
||||
return "@TC String test @TA [] @TB [];";
|
||||
}
|
||||
@ -89,40 +83,108 @@ public class Fields {
|
||||
|
||||
// Smoke tests
|
||||
@TADescription(annotation = "TA", type = FIELD)
|
||||
public String interfacefieldAsObject() {
|
||||
return "interface Test { @TA String test = null; }";
|
||||
public String interfaceFieldAsObject() {
|
||||
return "interface %TEST_CLASS_NAME% { @TA String test = null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = FIELD)
|
||||
public String abstractfieldAsObject() {
|
||||
return "abstract class Test { @TA String test; }";
|
||||
public String abstractFieldAsObject() {
|
||||
return "abstract class %TEST_CLASS_NAME% { @TA String test; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = FIELD),
|
||||
@TADescription(annotation = "TB", type = FIELD,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TC", type = FIELD,
|
||||
genericLocation = { 3, 1 }),
|
||||
@TADescription(annotation = "TD", type = FIELD,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
})
|
||||
public String interfacefieldAsParametrized() {
|
||||
return "interface Test { @TA Map<@TB String, @TC List<@TD String>> test = null; }";
|
||||
@TADescription(annotation = "TA", type = FIELD)
|
||||
@TADescription(annotation = "TB", type = FIELD,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TC", type = FIELD,
|
||||
genericLocation = { 3, 1 })
|
||||
@TADescription(annotation = "TD", type = FIELD,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
public String interfaceFieldAsParametrized() {
|
||||
return "interface %TEST_CLASS_NAME% { @TA Map<@TB String, @TC List<@TD String>> test = null; }";
|
||||
}
|
||||
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = FIELD),
|
||||
@TADescription(annotation = "TB", type = FIELD,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TC", type = FIELD,
|
||||
genericLocation = { 3, 1 }),
|
||||
@TADescription(annotation = "TD", type = FIELD,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
})
|
||||
@TADescription(annotation = "TA", type = FIELD)
|
||||
@TADescription(annotation = "TB", type = FIELD,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TC", type = FIELD,
|
||||
genericLocation = { 3, 1 })
|
||||
@TADescription(annotation = "TD", type = FIELD,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
public String staticFieldAsParametrized() {
|
||||
return "static @TA Map<@TB String, @TC List<@TD String>> test;";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = FIELD)
|
||||
public String fieldAsPrimitiveRepeatableAnnotation() {
|
||||
return "@RTA @RTA int test;";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = FIELD)
|
||||
public String fieldAsObjectRepeatableAnnotation() {
|
||||
return "@RTA @RTA Object test;";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = FIELD)
|
||||
@TADescription(annotation = "RTBs", type = FIELD,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTCs", type = FIELD,
|
||||
genericLocation = { 3, 1 })
|
||||
@TADescription(annotation = "RTDs", type = FIELD,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
public String fieldAsParametrizedRepeatableAnnotation() {
|
||||
return "@RTA @RTA Map<@RTB @RTB String, @RTC @RTC List<@RTD @RTD String>> test;";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = FIELD)
|
||||
@TADescription(annotation = "RTBs", type = FIELD,
|
||||
genericLocation = { 0, 0 })
|
||||
@TADescription(annotation = "RTCs", type = FIELD,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
public String fieldAsArrayRepeatableAnnotation() {
|
||||
return "@RTC @RTC String @RTA @RTA [] @RTB @RTB [] test;";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = FIELD)
|
||||
@TADescription(annotation = "RTBs", type = FIELD,
|
||||
genericLocation = { 0, 0 })
|
||||
@TADescription(annotation = "RTCs", type = FIELD,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
public String fieldAsArrayOldRepeatableAnnotation() {
|
||||
return "@RTC @RTC String test @RTA @RTA [] @RTB @RTB [];";
|
||||
}
|
||||
|
||||
// Smoke tests
|
||||
@TADescription(annotation = "RTAs", type = FIELD)
|
||||
public String interfaceFieldAsObjectRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME% { @RTA @RTA String test = null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = FIELD)
|
||||
public String abstractFieldAsObjectRepeatableAnnotation() {
|
||||
return "abstract class %TEST_CLASS_NAME% { @RTA @RTA String test; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = FIELD)
|
||||
@TADescription(annotation = "RTBs", type = FIELD,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTCs", type = FIELD,
|
||||
genericLocation = { 3, 1 })
|
||||
@TADescription(annotation = "RTDs", type = FIELD,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
public String interfaceFieldAsParametrizedRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME% { @RTA @RTA Map<@RTB @RTB String, @RTC @RTC List<@RTD @RTD String>> test = null; }";
|
||||
}
|
||||
|
||||
|
||||
@TADescription(annotation = "RTAs", type = FIELD)
|
||||
@TADescription(annotation = "RTBs", type = FIELD,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTCs", type = FIELD,
|
||||
genericLocation = { 3, 1 })
|
||||
@TADescription(annotation = "RTDs", type = FIELD,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
public String staticFieldAsParametrizedRepeatableAnnotation() {
|
||||
return "static @RTA @RTA Map<@RTB @RTB String, @RTC @RTC List<@RTD @RTD String>> test;";
|
||||
}
|
||||
}
|
||||
|
@ -25,98 +25,89 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test that the examples from the manual are stored as expected
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java FromSpecification.java
|
||||
* @run main Driver FromSpecification
|
||||
*/
|
||||
public class FromSpecification {
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0, 2, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 1}, paramIndex = 0),
|
||||
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0, 2, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 1}, paramIndex = 0)
|
||||
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 1, 3, 0}, paramIndex = 0)
|
||||
})
|
||||
public String testSpec1() {
|
||||
return "void test(@TA Map<@TB ? extends @TC String, @TD List<@TE Object>> a) { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {0, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {0, 0, 0, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TI", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {0, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {0, 0, 0, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TI", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {0, 0, 0, 0, 0, 0}, paramIndex = 0)
|
||||
})
|
||||
public String testSpec2() {
|
||||
return "void test(@TI String @TF [] @TG [] @TH [] a) { }";
|
||||
}
|
||||
|
||||
// Note first "1, 0" for top-level class Test.
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TJ", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0, 1, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TK", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TL", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TM", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TJ", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0, 1, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TK", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TL", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TM", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0}, paramIndex = 0)
|
||||
})
|
||||
public String testSpec3() {
|
||||
return "class Test { class O1 { class O2 { class O3 { class NestedStatic {} } } }" +
|
||||
return "class %TEST_CLASS_NAME% { class O1 { class O2 { class O3 { class NestedStatic {} } } }" +
|
||||
"void test(@TM O1.@TL O2.@TK O3.@TJ NestedStatic a) { } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0, 3, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0, 3, 0, 0, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0, 3, 0, 0, 0, 0, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0, 3, 0, 0, 0, 0, 0, 0, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 1}, paramIndex = 0),
|
||||
@TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0, 3, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0, 3, 0, 0, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0, 3, 0, 0, 0, 0, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 0, 3, 0, 0, 0, 0, 0, 0, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 1}, paramIndex = 0)
|
||||
@TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {3, 1, 3, 0}, paramIndex = 0)
|
||||
})
|
||||
public String testSpec4() {
|
||||
return "void test(@TA Map<@TB Comparable<@TF Object @TC [] @TD [] @TE []>, @TG List<@TH String>> a) { }";
|
||||
}
|
||||
|
||||
// Note first "1, 0" for top-level class Test.
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0, 1, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0, 1, 0, 3, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0, 1, 0, 3, 1}, paramIndex = 0),
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 3, 0}, paramIndex = 0),
|
||||
@TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 3, 1}, paramIndex = 0),
|
||||
@TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0, 1, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0, 1, 0, 3, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0, 1, 0, 3, 1}, paramIndex = 0)
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 1, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 3, 0}, paramIndex = 0)
|
||||
@TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0, 1, 0, 3, 1}, paramIndex = 0)
|
||||
@TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {1, 0}, paramIndex = 0)
|
||||
})
|
||||
public String testSpec5() {
|
||||
return "class Test { class O1 { class O2<A, B> { class O3 { class Nested<X, Y> {} } } }" +
|
||||
return "class %TEST_CLASS_NAME% { class O1 { class O2<A, B> { class O3 { class Nested<X, Y> {} } } }" +
|
||||
"void test(@TH O1.@TE O2<@TF String, @TG String>.@TD O3.@TA Nested<@TB String, @TC String> a) { } }";
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8013852
|
||||
* @bug 8013852 8042451
|
||||
* @summary Test population of reference info for instance and class initializers
|
||||
* @author Werner Dietl
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java Initializers.java
|
||||
@ -33,63 +33,98 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
*/
|
||||
public class Initializers {
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
public String instanceInit1() {
|
||||
return "class Test { { Object o = new @TA ArrayList<@TB String>(); } }";
|
||||
public String instanceInit1() {
|
||||
return "class %TEST_CLASS_NAME% { { Object o = new @TA ArrayList<@TB String>(); } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TD", type = NEW,
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
public String instanceInit2() {
|
||||
return "class Test { Object f = new @TA ArrayList<@TB String>(); " +
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TD", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String instanceInit2() {
|
||||
return "class %TEST_CLASS_NAME% { Object f = new @TA ArrayList<@TB String>(); " +
|
||||
" { Object o = new @TC ArrayList<@TD String>(); } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
public String staticInit1() {
|
||||
return "class Test { static { Object o = new @TA ArrayList<@TB String>(); } }";
|
||||
public String staticInit1() {
|
||||
return "class %TEST_CLASS_NAME% { static { Object o = new @TA ArrayList<@TB String>(); } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TD", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TF", type = NEW,
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
public String staticInit2() {
|
||||
return "class Test { Object f = new @TA ArrayList<@TB String>(); " +
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TD", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TF", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String staticInit2() {
|
||||
return "class %TEST_CLASS_NAME% { Object f = new @TA ArrayList<@TB String>(); " +
|
||||
" static Object g = new @TC ArrayList<@TD String>(); " +
|
||||
" static { Object o = new @TE ArrayList<@TF String>(); } }";
|
||||
}
|
||||
|
||||
// TODO: test interaction with several constructors, especially non-initial constuctors.
|
||||
// I don't think this kind of test is possible here.
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST,
|
||||
typeIndex = 0, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
})
|
||||
public String lazyConstantCast1() {
|
||||
return "class Test { public static final Object o = (@TA Object) null; }";
|
||||
@TADescription(annotation = "TA", type = CAST,
|
||||
typeIndex = 0, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String lazyConstantCast1() {
|
||||
return "class %TEST_CLASS_NAME% { public static final Object o = (@TA Object) null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String instanceInitRepeatableAnnotation1() {
|
||||
return "class %TEST_CLASS_NAME% { { Object o = new @RTA @RTA ArrayList<@RTB @RTB String>(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTCs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTDs", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String instanceInitRepeatableAnnotation2() {
|
||||
return "class %TEST_CLASS_NAME% { Object f = new @RTA @RTA ArrayList<@RTB @RTB String>(); " +
|
||||
" { Object o = new @RTC @RTC ArrayList<@RTD @RTD String>(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String staticInitRepeatableAnnotation1() {
|
||||
return "class %TEST_CLASS_NAME% { static { Object o = new @RTA @RTA ArrayList<@RTB @RTB String>(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTCs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTDs", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTEs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTFs", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String staticInitRepeatableAnnotation2() {
|
||||
return "class %TEST_CLASS_NAME% { Object f = new @RTA @RTA ArrayList<@RTB @RTB String>(); " +
|
||||
" static Object g = new @RTC @RTC ArrayList<@RTD @RTD String>(); " +
|
||||
" static { Object o = new @RTE @RTE ArrayList<@RTF @RTF String>(); } }";
|
||||
}
|
||||
|
||||
// TODO: test interaction with several constructors, especially non-initial constructors.
|
||||
// I don't think this kind of test is possible here.
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST,
|
||||
typeIndex = 0, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String lazyConstantCastRepeatableAnnotation1() {
|
||||
return "class %TEST_CLASS_NAME% { public static final Object o = (@RTA @RTA Object) null; }";
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8008077 8029721
|
||||
* @bug 8008077 8029721 8042451 8043974
|
||||
* @summary Test population of reference info for lambda expressions
|
||||
* javac crash for annotated parameter type of lambda in a field
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java Lambda.java
|
||||
@ -35,64 +35,58 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
public class Lambda {
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = METHOD_REFERENCE,
|
||||
@TADescription(annotation = "TA", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
public String returnMethodRef1() {
|
||||
return
|
||||
"class Lambda {" +
|
||||
" public String getName() { return \"Lambda!\"; }" +
|
||||
"}" +
|
||||
|
||||
"class Test {" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" java.util.function.Function<Lambda, String> lambda() {" +
|
||||
" return @TA @TB Lambda::getName;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = METHOD_REFERENCE,
|
||||
@TADescription(annotation = "TA", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TC", type = METHOD_REFERENCE,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TC", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TD", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 1 }),
|
||||
@TADescription(annotation = "TE", type = METHOD_REFERENCE,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TD", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 1 })
|
||||
})
|
||||
@TADescription(annotation = "TE", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 1})
|
||||
public String returnMethodRef2() {
|
||||
return
|
||||
"class Lambda<S, T> {" +
|
||||
" public String getName() { return \"Lambda!\"; }" +
|
||||
"}" +
|
||||
|
||||
"class Test {" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" java.util.function.Function<Lambda<Integer, Float>, String> lambda() {" +
|
||||
" return @TA Lambda<@TB @TC Integer, @TD @TE Float>::getName;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "CTA", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "CTB", type = METHOD_REFERENCE,
|
||||
@TADescription(annotation = "CTA", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "CTB", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "CTC", type = METHOD_REFERENCE,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "CTC", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 1 })
|
||||
})
|
||||
genericLocation = { 3, 1 })
|
||||
public String returnMethodRef3() {
|
||||
return
|
||||
"class Lambda<S, T> {" +
|
||||
@ -114,7 +108,7 @@ public class Lambda {
|
||||
" String name();" +
|
||||
"}" +
|
||||
|
||||
"class Test {" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" java.util.function.Function<Lambda<Integer, Float>, String> lambda() {" +
|
||||
" return @CTA(\"x\") Lambda<@CTB(age = 5) Integer, @CTC(name = \"y\") Float>::getName;" +
|
||||
" }" +
|
||||
@ -122,64 +116,58 @@ public class Lambda {
|
||||
}
|
||||
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = CONSTRUCTOR_REFERENCE,
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
public String returnConstructorRef1() {
|
||||
return
|
||||
"class Lambda {" +
|
||||
" Lambda() { }" +
|
||||
"}" +
|
||||
|
||||
"class Test {" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" Runnable lambda() {" +
|
||||
" return @TA @TB Lambda::new;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = CONSTRUCTOR_REFERENCE,
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TC", type = CONSTRUCTOR_REFERENCE,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TC", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TD", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 1 }),
|
||||
@TADescription(annotation = "TE", type = CONSTRUCTOR_REFERENCE,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TD", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 1 })
|
||||
})
|
||||
@TADescription(annotation = "TE", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 1 })
|
||||
public String returnConstructorRef2() {
|
||||
return
|
||||
"class Lambda<S, T> {" +
|
||||
" Lambda() { }" +
|
||||
"}" +
|
||||
|
||||
"class Test {" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" Runnable lambda() {" +
|
||||
" return @TA Lambda<@TB @TC Integer, @TD @TE Float>::new;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "CTA", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "CTB", type = CONSTRUCTOR_REFERENCE,
|
||||
@TADescription(annotation = "CTA", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "CTB", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "CTC", type = CONSTRUCTOR_REFERENCE,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "CTC", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 1 })
|
||||
})
|
||||
genericLocation = { 3, 1 })
|
||||
public String returnConstructorRef3() {
|
||||
return
|
||||
"class Lambda<S, T> {" +
|
||||
@ -201,7 +189,7 @@ public class Lambda {
|
||||
" String name();" +
|
||||
"}" +
|
||||
|
||||
"class Test {" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" Runnable lambda() {" +
|
||||
" return @CTA(\"x\") Lambda<@CTB(age = 5) Integer, @CTC(name = \"y\") Float>::new;" +
|
||||
" }" +
|
||||
@ -209,14 +197,12 @@ public class Lambda {
|
||||
}
|
||||
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_REFERENCE_TYPE_ARGUMENT,
|
||||
@TADescription(annotation = "TA", type = METHOD_REFERENCE_TYPE_ARGUMENT,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_REFERENCE_TYPE_ARGUMENT,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_REFERENCE_TYPE_ARGUMENT,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 1)
|
||||
})
|
||||
public String returnMethodRefTA1() {
|
||||
return
|
||||
"interface Lambda {" +
|
||||
@ -227,21 +213,19 @@ public class Lambda {
|
||||
" public <S, T> void generic(S p1, T p2) {}" +
|
||||
"}" +
|
||||
|
||||
"class Test {" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" Lambda lambda(LambdaImpl r) {" +
|
||||
" return r::<@TA Object, @TB Object>generic;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT,
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 1)
|
||||
})
|
||||
public String returnConstructorRefTA2() {
|
||||
return
|
||||
"interface Lambda {" +
|
||||
@ -253,57 +237,222 @@ public class Lambda {
|
||||
" public <S, T> void generic(S p1, T p2) {}" +
|
||||
"}" +
|
||||
|
||||
"class Test {" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" Lambda lambda() {" +
|
||||
" return LambdaImpl::<@TA Object, @TB Object>new;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 1),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 1, genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TD", type = LOCAL_VARIABLE,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 1)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 1, genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TD", type = LOCAL_VARIABLE,
|
||||
lvarOffset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
lvarLength = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
lvarIndex = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TE", type = CAST,
|
||||
lvarIndex = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TE", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
})
|
||||
public String returnLambdaExpr1() {
|
||||
return
|
||||
"interface LambdaInt {" +
|
||||
" void lambda(Object p1, List<Object> p2);" +
|
||||
"}" +
|
||||
"class Test {" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" LambdaInt getLambda() {" +
|
||||
" return (@TA Object x, @TB List<@TC Object> y) -> { @TD Object l = null; System.out.println((@TE Object) l); };" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0)})
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0)
|
||||
public String lambdaField1() {
|
||||
return
|
||||
"class Test {" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" java.util.function.IntUnaryOperator field = (@TA int y) -> 1;" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0)})
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0)
|
||||
public String lambdaField2() {
|
||||
return
|
||||
"class Test {" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" static java.util.function.IntUnaryOperator field = (@TA int y) -> 1;" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnMethodRefRepeatableAnnotation1() {
|
||||
return
|
||||
"class Lambda {" +
|
||||
" public String getName() { return \"Lambda!\"; }" +
|
||||
"}" +
|
||||
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" java.util.function.Function<Lambda, String> lambda() {" +
|
||||
" return @RTA @RTA Lambda::getName;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTCs", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTDs", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 1 })
|
||||
@TADescription(annotation = "RTEs", type = METHOD_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 1})
|
||||
public String returnMethodRefRepeatableAnnotation2() {
|
||||
return
|
||||
"class Lambda<S, T> {" +
|
||||
" public String getName() { return \"Lambda!\"; }" +
|
||||
"}" +
|
||||
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" java.util.function.Function<Lambda<Integer, Float>, String> lambda() {" +
|
||||
" return @RTA @RTA Lambda<@RTB @RTB @RTC @RTC Integer, @RTD @RTD @RTE @RTE Float>::getName;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnConstructorRefRepeatable1() {
|
||||
return
|
||||
"class Lambda {" +
|
||||
" Lambda() { }" +
|
||||
"}" +
|
||||
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" Runnable lambda() {" +
|
||||
" return @RTA @RTA Lambda::new;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTCs", type = CONSTRUCTOR_REFERENCE,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = { 3, 1 })
|
||||
public String returnConstructorRefRepeatable2() {
|
||||
return
|
||||
"class Lambda<S, T> {" +
|
||||
" Lambda() { }" +
|
||||
"}" +
|
||||
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" Runnable lambda() {" +
|
||||
" return @RTA @RTA Lambda<@RTB @RTB Integer, @RTC @RTC Float>::new;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_REFERENCE_TYPE_ARGUMENT,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_REFERENCE_TYPE_ARGUMENT,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 1)
|
||||
public String returnMethodRefTARepeatableAnnotation1() {
|
||||
return
|
||||
"interface Lambda {" +
|
||||
" <S, T> void generic(S p1, T p2);" +
|
||||
"}" +
|
||||
|
||||
"class LambdaImpl implements Lambda {" +
|
||||
" public <S, T> void generic(S p1, T p2) {}" +
|
||||
"}" +
|
||||
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" Lambda lambda(LambdaImpl r) {" +
|
||||
" return r::<@RTA @RTA Object, @RTB @RTB Object>generic;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 1)
|
||||
public String returnConstructorRefTARepeatableAnnotation2() {
|
||||
return
|
||||
"interface Lambda {" +
|
||||
" <S, T> void generic(S p1, T p2);" +
|
||||
"}" +
|
||||
|
||||
"class LambdaImpl implements Lambda {" +
|
||||
" <S, T> LambdaImpl(S p1, T p2) {}" +
|
||||
" public <S, T> void generic(S p1, T p2) {}" +
|
||||
"}" +
|
||||
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" Lambda lambda() {" +
|
||||
" return LambdaImpl::<@RTA @RTA Object, @RTB @RTB Object>new;" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 1)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 1, genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTDs", type = LOCAL_VARIABLE,
|
||||
lvarOffset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
lvarLength = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
lvarIndex = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTEs", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String returnLambdaExprRepeatableAnnotation1() {
|
||||
return
|
||||
"interface LambdaInt {" +
|
||||
" void lambda(Object p1, List<Object> p2);" +
|
||||
"}" +
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" LambdaInt getLambda() {" +
|
||||
" return (@RTA @RTA Object x, @RTB @RTB List<@RTC @RTC Object> y) ->" +
|
||||
" { @RTD @RTD Object l = null; System.out.println((@RTE @RTE Object) l); };" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0)
|
||||
public String lambdaFieldRepeatableAnnotation1() {
|
||||
return
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" java.util.function.IntUnaryOperator field = (@RTA @RTA int y) -> 1;" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0)
|
||||
public String lambdaFieldRepeatableAnnotation2() {
|
||||
return
|
||||
"class %TEST_CLASS_NAME% {" +
|
||||
" static java.util.function.IntUnaryOperator field = (@RTA @RTA int y) -> 1;" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for method invocation type arguments
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java MethodInvocationTypeArgument.java
|
||||
* @run main Driver MethodInvocationTypeArgument
|
||||
*/
|
||||
|
||||
import static com.sun.tools.classfile.TypeAnnotation.TargetType.METHOD_INVOCATION_TYPE_ARGUMENT;
|
||||
import static java.lang.System.lineSeparator;
|
||||
|
||||
public class MethodInvocationTypeArgument {
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 4)
|
||||
@TADescription(annotation = "TB", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 1, offset = 4)
|
||||
@TADescription(annotation = "TC", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 2, offset = 4)
|
||||
@TADescription(annotation = "TD", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 24)
|
||||
@TADescription(annotation = "TE", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 1, offset = 24)
|
||||
@TADescription(annotation = "TF", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 2, offset = 24)
|
||||
public String genericMethod() {
|
||||
return
|
||||
"public <T1, T2, T3> void function(T1 t1, T2 t2, T3 t3) {}" + lineSeparator() +
|
||||
"{ new %TEST_CLASS_NAME%().<@TA Integer, @TB String, @TC Double>function(0, \"\", 0.0); " + lineSeparator() +
|
||||
" this.<@TD Integer, @TE String, @TF Double>function(0, \"\", 0.0); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 1, offset = 0)
|
||||
@TADescription(annotation = "TC", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 2, offset = 0)
|
||||
public String genericStaticMethod() {
|
||||
return
|
||||
"public static <T1, T2, T3> void staticFunction(T1 t1, T2 t2, T3 t3) {}" + lineSeparator() +
|
||||
"static { %TEST_CLASS_NAME%.<@TA Integer, @TB String, @TC Double>staticFunction(0, \"\", 0.0); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 4)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 1, offset = 4)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 20)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 1, offset = 20)
|
||||
public String genericMethodRepeatableAnnotation() {
|
||||
return
|
||||
"public <T1, T2> void function(T1 t1, T2 t2) {}" + lineSeparator() +
|
||||
"{ new %TEST_CLASS_NAME%().<@RTA @RTA Integer, @RTB @RTB String>" +
|
||||
"function(0, \"\"); " + lineSeparator() +
|
||||
" this.<@RTC @RTC Integer, @RTD @RTD String>function(0, \"\"); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 1, offset = 0)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 2, offset = 0)
|
||||
public String genericStaticMethodRepeatableAnnotation() {
|
||||
return
|
||||
"public static <T1, T2, T3> void staticFunction(T1 t1, T2 t2, T3 t3) {}" + lineSeparator() +
|
||||
"static { %TEST_CLASS_NAME%.<@RTA @RTA Integer, @RTB @RTB String, @RTC @RTC Double>staticFunction(0, \"\", 0.0); }";
|
||||
}
|
||||
|
||||
}
|
@ -25,6 +25,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for method parameters
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java MethodParameters.java
|
||||
* @run main Driver MethodParameters
|
||||
@ -41,97 +42,83 @@ public class MethodParameters {
|
||||
return "void test(Object b, @TA Object a) { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0 }, paramIndex = 0)
|
||||
})
|
||||
public String methodParamAsParametrized() {
|
||||
return "void test(@TA Map<@TB String, @TC List<@TD String>> a) { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0, 2, 0 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0, 2, 0 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0, 2, 0, 3, 0 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0, 2, 0, 3, 0, 2, 0 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TI", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0, 2, 0, 3, 1 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TJ", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0, 2, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0, 2, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0, 2, 0, 3, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0, 2, 0, 3, 0, 2, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TI", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0, 2, 0, 3, 1 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TJ", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0, 2, 0, 3, 1, 2, 0 }, paramIndex = 0)
|
||||
})
|
||||
public String methodParamAsWildcard() {
|
||||
return "void test(@TA Map<@TB ? extends @TC String," +
|
||||
" @TD List<@TE ? extends @TF Map<@TG ? super @TH String," +
|
||||
" @TI ? extends @TJ Object>>> a) { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0, 0, 0 }, paramIndex = 1)
|
||||
})
|
||||
public String methodParamAsArray() {
|
||||
return "void test(Object b, @TC String @TA [] @TB [] a) { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
})
|
||||
public String methodParamAsArray2() {
|
||||
return "void test(Object b, @TA @TB String [] a) { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
})
|
||||
public String methodParamAsArray3() {
|
||||
return "void test(Object b, @TA @TB @TC String [] a) { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0, 0, 0 }, paramIndex = 1)
|
||||
})
|
||||
public String methodParamAsVararg() {
|
||||
return "void test(Object b, @TC String @TA [] @TB ... a) { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0, 0, 0 }, paramIndex = 1)
|
||||
})
|
||||
public String methodParamAsFQVararg() {
|
||||
return "void test(Object b, java.lang.@TC String @TA [] @TB ... a) { }";
|
||||
}
|
||||
@ -148,26 +135,125 @@ public class MethodParameters {
|
||||
|
||||
// Smoke tests
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
public String interfacemethodParamAsObject() {
|
||||
return "interface Test { void test(@TA Object a); }";
|
||||
public String interfaceMethodParamAsObject() {
|
||||
return "interface %TEST_CLASS_NAME% { void test(@TA Object a); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 2)
|
||||
public String abstractmethodParamAsObject() {
|
||||
return "abstract class Test { abstract void test(Object b, Object c, @TA Object a); }";
|
||||
public String abstractMethodParamAsObject() {
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract void test(Object b, Object c, @TA Object a); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1 }, paramIndex = 0),
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1 }, paramIndex = 0)
|
||||
@TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0 }, paramIndex = 0)
|
||||
})
|
||||
public String interfacemethodParamAsParametrized() {
|
||||
return "interface Test { void test(@TA Map<@TB String, @TC List<@TD String>> a); }";
|
||||
public String interfaceMethodParamAsParametrized() {
|
||||
return "interface %TEST_CLASS_NAME% { void test(@TA Map<@TB String, @TC List<@TD String>> a); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
public String methodParamAsPrimitiveRepeatableAnnotation() {
|
||||
return "void test(@RTA @RTA int a) { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
|
||||
public String methodParamAsObjectRepeatableAnnotation() {
|
||||
return "void test(Object b, @RTA @RTA Object a) { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1 }, paramIndex = 0)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0 }, paramIndex = 0)
|
||||
public String methodParamAsParametrizedRepeatableAnnotation() {
|
||||
return "void test(@RTA @RTA Map<@RTB @RTB String, @RTC @RTC List<@RTD @RTD String>> a) { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0, 2, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1 }, paramIndex = 0)
|
||||
@TADescription(annotation = "RTEs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "RTFs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0, 2, 0 }, paramIndex = 0)
|
||||
public String methodParamAsWildcardRepeatableAnnotation() {
|
||||
return "void test(@RTA @RTA Map<@RTB @RTB ? extends @RTC @RTC String," +
|
||||
" @RTD @RTD List<@RTE @RTE ? super @RTF @RTF String>> a) { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0, 0, 0 }, paramIndex = 1)
|
||||
public String methodParamAsArrayRepeatableAnnotation() {
|
||||
return "void test(Object b, @RTC @RTC String @RTA @RTA [] @RTB @RTB [] a) { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
public String methodParamAsArrayRepeatableAnnotation2() {
|
||||
return "void test(Object b, @RTA @RTA @RTB @RTB String [] a) { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
public String methodParamAsArrayRepeatableAnnotation3() {
|
||||
return "void test(Object b, @RTA @RTA @RTB @RTB String [] a) { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0, 0, 0 }, paramIndex = 1)
|
||||
public String methodParamAsVarargRepeatableAnnoattion() {
|
||||
return "void test(Object b, @RTC @RTC String @RTA @RTA [] @RTB @RTB ... a) { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0 }, paramIndex = 1)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 0, 0, 0, 0 }, paramIndex = 1)
|
||||
public String methodParamAsFQVarargRepeatableAnnotation() {
|
||||
return "void test(Object b, java.lang.@RTC @RTC String @RTA @RTA [] @RTB @RTB ... a) { }";
|
||||
}
|
||||
|
||||
// Smoke tests
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
public String interfaceMethodParamAsObjectRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME% { void test(@RTA @RTA Object a); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER, paramIndex = 2)
|
||||
public String abstractMethodParamAsObjectRepeatableAnnotation() {
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract void test(Object b, Object c, @RTA @RTA Object a); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 0 }, paramIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1 }, paramIndex = 0)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = { 3, 1, 3, 0 }, paramIndex = 0)
|
||||
public String interfaceMethodParamAsParametrizedRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME% { void test(@RTA @RTA Map<@RTB @RTB String, @RTC @RTC List<@RTD @RTD String>> a); }";
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for method receivers
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java MethodReceivers.java
|
||||
* @run main Driver MethodReceivers
|
||||
@ -33,47 +34,87 @@ public class MethodReceivers {
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_RECEIVER)
|
||||
public String regularMethod() {
|
||||
return "class Test { void test(@TA Test this) { } }";
|
||||
return "class %TEST_CLASS_NAME% { void test(@TA %TEST_CLASS_NAME% this) { } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_RECEIVER)
|
||||
public String abstractMethod() {
|
||||
return "abstract class Test { abstract void test(@TA Test this); }";
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract void test(@TA %TEST_CLASS_NAME% this); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_RECEIVER)
|
||||
public String interfaceMethod() {
|
||||
return "interface Test { void test(@TA Test this); }";
|
||||
return "interface %TEST_CLASS_NAME% { void test(@TA %TEST_CLASS_NAME% this); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_RECEIVER)
|
||||
public String regularWithThrows() {
|
||||
return "class Test { void test(@TA Test this) throws Exception { } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RECEIVER,
|
||||
genericLocation = {}),
|
||||
@TADescription(annotation = "TB", type = METHOD_RECEIVER,
|
||||
genericLocation = {1, 0})
|
||||
})
|
||||
@TestClass("TestOuter$TestInner")
|
||||
public String nestedtypes1() {
|
||||
return "class TestOuter { class TestInner { void test(@TA TestOuter. @TB TestInner this) { } } }";
|
||||
return "class %TEST_CLASS_NAME% { void test(@TA %TEST_CLASS_NAME% this) throws Exception { } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_RECEIVER,
|
||||
genericLocation = {})
|
||||
@TestClass("TestOuter$TestInner")
|
||||
@TADescription(annotation = "TB", type = METHOD_RECEIVER,
|
||||
genericLocation = {1, 0})
|
||||
@TestClass("%TEST_CLASS_NAME%$TestInner")
|
||||
public String nestedtypes1() {
|
||||
return "class %TEST_CLASS_NAME% { class TestInner { void test(@TA %TEST_CLASS_NAME%. @TB TestInner this) { } } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_RECEIVER,
|
||||
genericLocation = {})
|
||||
@TestClass("%TEST_CLASS_NAME%$TestInner")
|
||||
public String nestedtypes2() {
|
||||
return "class TestOuter { class TestInner { void test(@TA TestOuter.TestInner this) { } } }";
|
||||
return "class %TEST_CLASS_NAME% { class TestInner { void test(@TA %TEST_CLASS_NAME%.TestInner this) { } } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TB", type = METHOD_RECEIVER,
|
||||
genericLocation = {1, 0})
|
||||
@TestClass("TestOuter$TestInner")
|
||||
@TestClass("%TEST_CLASS_NAME%$TestInner")
|
||||
public String nestedtypes3() {
|
||||
return "class TestOuter { class TestInner { void test(TestOuter. @TB TestInner this) { } } }";
|
||||
return "class %TEST_CLASS_NAME% { class TestInner { void test(%TEST_CLASS_NAME%. @TB TestInner this) { } } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RECEIVER)
|
||||
public String regularMethodRepeatableAnnotation() {
|
||||
return "class %TEST_CLASS_NAME% { void test(@RTA @RTA %TEST_CLASS_NAME% this) { } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RECEIVER)
|
||||
public String abstractMethodRepeatablaAnnotation() {
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract void test(@RTA @RTA %TEST_CLASS_NAME% this); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RECEIVER)
|
||||
public String interfaceMethodRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME% { void test(@RTA @RTA %TEST_CLASS_NAME% this); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RECEIVER)
|
||||
public String regularWithThrowsRepeatableAnnotation() {
|
||||
return "class %TEST_CLASS_NAME% { void test(@RTA @RTA %TEST_CLASS_NAME% this) throws Exception { } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RECEIVER,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RECEIVER,
|
||||
genericLocation = {1, 0})
|
||||
@TestClass("%TEST_CLASS_NAME%$TestInner")
|
||||
public String nestedtypesRepeatableAnnotation1() {
|
||||
return "class %TEST_CLASS_NAME% { class TestInner { void test(@RTA @RTA %TEST_CLASS_NAME%. @RTB @RTB TestInner this) { } } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RECEIVER,
|
||||
genericLocation = {})
|
||||
@TestClass("%TEST_CLASS_NAME%$TestInner")
|
||||
public String nestedtypesRepeatableAnnotation2() {
|
||||
return "class %TEST_CLASS_NAME% { class TestInner { void test(@RTA @RTA %TEST_CLASS_NAME%.TestInner this) { } } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RECEIVER,
|
||||
genericLocation = {1, 0})
|
||||
@TestClass("%TEST_CLASS_NAME%$TestInner")
|
||||
public String nestedtypesRepeatableAnnotation3() {
|
||||
return "class %TEST_CLASS_NAME% { class TestInner { void test(%TEST_CLASS_NAME%. @RTB @RTB TestInner this) { } } }";
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for method return
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java MethodReturns.java
|
||||
* @run main Driver MethodReturns
|
||||
@ -42,37 +43,31 @@ public class MethodReturns {
|
||||
return "@TA Object test() { return null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN),
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1 }),
|
||||
@TADescription(annotation = "TD", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1 })
|
||||
@TADescription(annotation = "TD", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
public String methodReturnAsParametrized() {
|
||||
return "@TA Map<@TB String, @TC List<@TD String>> test() { return null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN),
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0 }),
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0 })
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
public String methodReturnAsArray() {
|
||||
return "@TC String @TA [] @TB [] test() { return null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN),
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0 }),
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0 })
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
public String methodReturnAsArrayOld() {
|
||||
return "@TC String test() @TA [] @TB [] { return null; }";
|
||||
}
|
||||
@ -90,97 +85,206 @@ public class MethodReturns {
|
||||
// Smoke tests
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN)
|
||||
public String interfaceMethodReturnAsObject() {
|
||||
return "interface Test { @TA Object test(); }";
|
||||
return "interface %TEST_CLASS_NAME% { @TA Object test(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN)
|
||||
public String abstractMethodReturnAsObject() {
|
||||
return "abstract class Test { abstract @TA Object test(); }";
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract @TA Object test(); }";
|
||||
}
|
||||
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN),
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1 }),
|
||||
@TADescription(annotation = "TD", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1 })
|
||||
@TADescription(annotation = "TD", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
public String interfaceMethodReturnAsParametrized() {
|
||||
return "interface Test { @TA Map<@TB String, @TC List<@TD String>> test(); }";
|
||||
return "interface %TEST_CLASS_NAME% { @TA Map<@TB String, @TC List<@TD String>> test(); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0 }),
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0 }),
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 }),
|
||||
@TADescription(annotation = "TD", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 0 }),
|
||||
@TADescription(annotation = "TE", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1 }),
|
||||
@TADescription(annotation = "TF", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1, 2, 0 })
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0 })
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 })
|
||||
@TADescription(annotation = "TD", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 0 })
|
||||
@TADescription(annotation = "TE", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1 })
|
||||
@TADescription(annotation = "TF", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1, 2, 0 })
|
||||
public String methodReturnAsNestedWildcard() {
|
||||
return "Set<@TA ? extends @TB GOuter<String, String>. @TC GInner<@TD String, @TE ? super @TF Object>> entrySet() { return null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 1, 0, 3, 0 }),
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 1, 0, 3, 1 }),
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 1, 0, 3, 1, 2, 0 })
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 1, 0, 3, 0 })
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 1, 0, 3, 1 })
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 1, 0, 3, 1, 2, 0 })
|
||||
public String methodReturnAsNestedWildcard2() {
|
||||
return "class GOuter<X, Y> { class GInner<X, Y> {} } " +
|
||||
"class Test<K> { Set<GOuter<String, String>.GInner<@TA K, @TB ? extends @TC Object>> entrySet() { return null; } }";
|
||||
"class %TEST_CLASS_NAME%<K> { Set<GOuter<String, String>.GInner<@TA K, @TB ? extends @TC Object>> entrySet() { return null; } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0 }),
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 }),
|
||||
})
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0 })
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 })
|
||||
public String methodReturnAsNestedWildcard3() {
|
||||
return "Set<? extends @TB GOuter<String, String>. @TC GInner<String, Object>> entrySet() { return null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 }),
|
||||
})
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 })
|
||||
public String methodReturnAsNestedWildcard4() {
|
||||
return "Set<? extends GOuter<String, String>. @TC GInner<String, Object>> entrySet() { return null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0 }),
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 }),
|
||||
})
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0 })
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 })
|
||||
public String methodReturnAsNestedWildcard5() {
|
||||
return "Set<? extends @TB Outer. @TC Inner> entrySet() { return null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 0 }),
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1 }),
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 }),
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 0 })
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1 })
|
||||
@TADescription(annotation = "TC", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 })
|
||||
public String methodReturnAsNestedWildcard6() {
|
||||
return "Set<? extends GOuter<String, String>. @TC GInner<@TA String, @TB Object>> entrySet() { return null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN)
|
||||
public String methodReturnAsPrimitiveRepeatableAnnotation() {
|
||||
return "@RTA @RTA int test() { return 0; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN)
|
||||
public String methodReturnAsObjectRepeatableAnnotation() {
|
||||
return "@RTA @RTA Object test() { return null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1 })
|
||||
@TADescription(annotation = "RTDs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
public String methodReturnAsParametrizedRepeatableAnnotation() {
|
||||
return "@RTA @RTA Map<@RTB @RTB String, @RTC @RTC List<@RTD @RTD String>> test() { return null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0 })
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
public String methodReturnAsArrayRepeatableAnnotation() {
|
||||
return "@RTC @RTC String @RTA @RTA [] @RTB @RTB [] test() { return null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0 })
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RETURN,
|
||||
genericLocation = { 0, 0, 0, 0 })
|
||||
public String methodReturnAsArrayOldRepeatableAnnotation() {
|
||||
return "@RTC @RTC String test() @RTA @RTA [] @RTB @RTB [] { return null; }";
|
||||
}
|
||||
|
||||
// Smoke tests
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN)
|
||||
public String interfaceMethodReturnAsObjectRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME% { @RTA @RTA Object test(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN)
|
||||
public String abstractMethodReturnAsObjectRepeatableAnnotation() {
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract @RTA @RTA Object test(); }";
|
||||
}
|
||||
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1 })
|
||||
@TADescription(annotation = "RTDs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 1, 3, 0 })
|
||||
public String interfaceMethodReturnAsParametrizedRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME% { @RTA @RTA Map<@RTB @RTB String, @RTC @RTC List<@RTD @RTD String>> test(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0 })
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0 })
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 })
|
||||
@TADescription(annotation = "RTDs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 0 })
|
||||
@TADescription(annotation = "RTEs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1 })
|
||||
@TADescription(annotation = "RTFs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1, 2, 0 })
|
||||
public String methodReturnAsNestedWildcardRepeatableAnnotation() {
|
||||
return "Set<@RTA @RTA ? extends @RTB @RTB GOuter<String, String>. @RTC @RTC GInner<@RTD @RTD String," +
|
||||
" @RTE @RTE ? super @RTF @RTF Object>> entrySet() { return null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 1, 0, 3, 0 })
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 1, 0, 3, 1 })
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 1, 0, 3, 1, 2, 0 })
|
||||
public String methodReturnAsNestedWildcardRepeatableAnnotation2() {
|
||||
return "class GOuter<X, Y> { class GInner<X, Y> {} } " +
|
||||
"class %TEST_CLASS_NAME%<K> { Set<GOuter<String, String>.GInner<@RTA @RTA K," +
|
||||
" @RTB @RTB ? extends @RTC @RTC Object>> entrySet() { return null; } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0 })
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 })
|
||||
public String methodReturnAsNestedWildcardRepeatableAnnotation3() {
|
||||
return "Set<? extends @RTB @RTB GOuter<String, String>. @RTC @RTC GInner<String, Object>> entrySet() { return null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 })
|
||||
public String methodReturnAsNestedWildcardRepeatableAnnotation4() {
|
||||
return "Set<? extends GOuter<String, String>. @RTC @RTC GInner<String, Object>> entrySet() { return null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0 })
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 })
|
||||
public String methodReturnAsNestedWildcardRepeatableAnnotation5() {
|
||||
return "Set<? extends @RTB @RTB Outer. @RTC @RTC Inner> entrySet() { return null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 0 })
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1 })
|
||||
@TADescription(annotation = "RTCs", type = METHOD_RETURN,
|
||||
genericLocation = { 3, 0, 2, 0, 1, 0 })
|
||||
public String methodReturnAsNestedWildcardRepeatableAnnotation6() {
|
||||
return "Set<? extends GOuter<String, String>. @RTC @RTC GInner<@RTA @RTA String," +
|
||||
" @RTB @RTB Object>> entrySet() { return null; }";
|
||||
}
|
||||
}
|
||||
|
@ -25,53 +25,46 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for method exception clauses
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java MethodThrows.java
|
||||
* @run main Driver MethodThrows
|
||||
*/
|
||||
public class MethodThrows {
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = THROWS, typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = THROWS, typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
|
||||
public String regularMethod() {
|
||||
return "class Test { void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception { } }";
|
||||
return "class %TEST_CLASS_NAME% { void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception { } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = THROWS, typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = THROWS, typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
|
||||
public String abstractMethod() {
|
||||
return "abstract class Test { abstract void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception; }";
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = THROWS, typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = THROWS, typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
|
||||
public String interfaceMethod() {
|
||||
return "interface Test { void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception; }";
|
||||
return "interface %TEST_CLASS_NAME% { void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = THROWS, typeIndex = 0,
|
||||
genericLocation = {}),
|
||||
@TADescription(annotation = "TB", type = THROWS, typeIndex = 0,
|
||||
genericLocation = {1, 0}),
|
||||
@TADescription(annotation = "TC", type = THROWS, typeIndex = 0,
|
||||
genericLocation = {1, 0, 1, 0}),
|
||||
@TADescription(annotation = "TD", type = THROWS, typeIndex = 1,
|
||||
genericLocation = {}),
|
||||
@TADescription(annotation = "TE", type = THROWS, typeIndex = 1,
|
||||
genericLocation = {1, 0}),
|
||||
@TADescription(annotation = "TF", type = THROWS, typeIndex = 1,
|
||||
genericLocation = {1, 0, 1, 0})
|
||||
})
|
||||
@TADescription(annotation = "TA", type = THROWS, typeIndex = 0,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "TB", type = THROWS, typeIndex = 0,
|
||||
genericLocation = {1, 0})
|
||||
@TADescription(annotation = "TC", type = THROWS, typeIndex = 0,
|
||||
genericLocation = {1, 0, 1, 0})
|
||||
@TADescription(annotation = "TD", type = THROWS, typeIndex = 1,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "TE", type = THROWS, typeIndex = 1,
|
||||
genericLocation = {1, 0})
|
||||
@TADescription(annotation = "TF", type = THROWS, typeIndex = 1,
|
||||
genericLocation = {1, 0, 1, 0})
|
||||
public String NestedTypes() {
|
||||
return "class Outer { class Middle { class Inner1 extends Exception {}" +
|
||||
" class Inner2 extends Exception{} } }" +
|
||||
"class Test { void test() throws @TA Outer.@TB Middle.@TC Inner1, @TD Outer.@TE Middle.@TF Inner2 { } }";
|
||||
"class %TEST_CLASS_NAME% { void test() throws @TA Outer.@TB Middle.@TC Inner1, @TD Outer.@TE Middle.@TF Inner2 { } }";
|
||||
}
|
||||
}
|
||||
|
@ -22,230 +22,387 @@
|
||||
*/
|
||||
|
||||
import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
import static java.lang.System.lineSeparator;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for method type parameters
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java MethodTypeParam.java
|
||||
* @run main Driver MethodTypeParam
|
||||
*/
|
||||
public class MethodTypeParam {
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1),
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularClass() {
|
||||
return "<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> void test() { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1),
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularClass2() {
|
||||
return "<@TA K extends @TB Date, @TC V extends @TE Cloneable> void test() { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
|
||||
@TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
@TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
public String regularClassParameterized() {
|
||||
return "<K extends @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> void test() { }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1),
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String abstractClass() {
|
||||
return "abstract class Test { abstract <@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> void test(); }";
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract <@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> void test(); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
|
||||
@TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
|
||||
@TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
@TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
public String abstractClassParameterized() {
|
||||
return "abstract class Test { abstract <K extends @TG Object & @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> void test(); }";
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract <K extends @TG Object & @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> void test(); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
public String abstractClassParameterized2() {
|
||||
return "abstract class Test { abstract <K extends @TA Map<String, @TB String>, V extends @TC List<@TD List<@TE Object>>> void test(); }";
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract <K extends @TA Map<String, @TB String>, V extends @TC List<@TD List<@TE Object>>> void test(); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String abstractClassParameterized3() {
|
||||
return "abstract class Test { abstract <K extends @TA List<String>, V extends @TB List<Object>> void test(); }";
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract <K extends @TA List<String>, V extends @TB List<Object>> void test(); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1),
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularInterface() {
|
||||
return "interface Test { <@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> void test(); }";
|
||||
return "interface %TEST_CLASS_NAME% { <@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> void test(); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
|
||||
@TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
|
||||
@TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
|
||||
@TADescription(annotation = "TH", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TI", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
@TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "TH", type = METHOD_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TI", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
public String regularInterfaceParameterized() {
|
||||
return "interface Test { <@TH K extends @TG Object & @TA Map<String, @TB String>, @TI V extends @TF Object & @TC List<@TD List<@TE Object>>> void test(); }";
|
||||
return "interface %TEST_CLASS_NAME% { <@TH K extends @TG Object & @TA Map<String, @TB String>, @TI V extends @TF Object & @TC List<@TD List<@TE Object>>> void test(); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
|
||||
@TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
|
||||
@TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
@TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
public String regularInterfaceParameterized2() {
|
||||
return "interface Test { <@TF K extends @TA Map<String, @TB String>, @TG V extends @TC List<@TD List<@TE Object>>> void test(); }";
|
||||
return "interface %TEST_CLASS_NAME% { <@TF K extends @TA Map<String, @TB String>, @TG V extends @TC List<@TD List<@TE Object>>> void test(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN)
|
||||
public String useInReturn1() {
|
||||
return "class Test { <T> @TA T m() { throw new RuntimeException(); } }";
|
||||
return "class %TEST_CLASS_NAME% { <T> @TA T m() { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {3, 0})
|
||||
public String useInReturn2() {
|
||||
return "class Test { <T> Class<@TA T> m() { throw new RuntimeException(); } }";
|
||||
return "class %TEST_CLASS_NAME% { <T> Class<@TA T> m() { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN)
|
||||
})
|
||||
public String useInReturn3() {
|
||||
return "class Test { <T extends @TA Object> @TB T m() { throw new RuntimeException(); } }";
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_RETURN)
|
||||
public String useInReturn3() {
|
||||
return "class %TEST_CLASS_NAME% { <T extends @TA Object> @TB T m() { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0, genericLocation = {3, 0})
|
||||
public String useInParam1() {
|
||||
return "class Test { <T> void m(Class<@TA T> p) { throw new RuntimeException(); } }";
|
||||
return "class %TEST_CLASS_NAME% { <T> void m(Class<@TA T> p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0, genericLocation = {3, 0})
|
||||
public String useInParam2() {
|
||||
return "class Test { void m(Class<@TA Object> p) { throw new RuntimeException(); } }";
|
||||
return "class %TEST_CLASS_NAME% { void m(Class<@TA Object> p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 2),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 2)
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
public String useInParam3() {
|
||||
return "interface IA {} " +
|
||||
"interface IB<XB> {} " +
|
||||
"interface IC<XC> {} " +
|
||||
"class Test { <T extends @TA IB<IA> & @TB IC<IA>> void m(@TC T p) { throw new RuntimeException(); } }";
|
||||
"class %TEST_CLASS_NAME% { <T extends @TA IB<IA> & @TB IC<IA>> void m(@TC T p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 1,
|
||||
genericLocation = {}),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 2,
|
||||
genericLocation = {}),
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0)
|
||||
})
|
||||
public String useInParam4() {
|
||||
return "class Test {" +
|
||||
return "class %TEST_CLASS_NAME% {" +
|
||||
" interface IA {} " +
|
||||
" interface IB<XB> {} " +
|
||||
" interface IC<XC> {} " +
|
||||
" <T extends @TA IB<IA> & @TB IC<IA>> void m(@TC T p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 0,
|
||||
genericLocation = {}),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 0,
|
||||
genericLocation = {1, 0}),
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
genericLocation = {1, 0})
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 0,
|
||||
genericLocation = {1, 0, 3, 0}),
|
||||
})
|
||||
public String useInParam5() {
|
||||
return "class Test {" +
|
||||
genericLocation = {1, 0, 3, 0})
|
||||
public String useInParam5() {
|
||||
return "class %TEST_CLASS_NAME% {" +
|
||||
" interface IA {} " +
|
||||
" class CB<XC> {} " +
|
||||
" <T extends @TA Test. @TB CB<@TC IA>> void m(T p) { throw new RuntimeException(); } }";
|
||||
" <T extends @TA %TEST_CLASS_NAME%. @TB CB<@TC IA>> void m(T p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER,
|
||||
paramIndex = 0),
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
@TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER,
|
||||
paramIndex = 0)
|
||||
@TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 0,
|
||||
genericLocation = {}),
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 0,
|
||||
genericLocation = {1, 0, 3, 0}),
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
genericLocation = {1, 0, 3, 0})
|
||||
@TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 1,
|
||||
genericLocation = {}),
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 1,
|
||||
genericLocation = {3, 0})
|
||||
})
|
||||
public String useInParam6() {
|
||||
return "class Test {" +
|
||||
return "class %TEST_CLASS_NAME% {" +
|
||||
" interface IA {} " +
|
||||
" interface IB<XB> {} " +
|
||||
" class CC<XC> {} " +
|
||||
" interface ID<XD> {} " +
|
||||
" <@TA T extends @TB Test.CC<@TC IA> & Test. @TD ID<@TE IA>> void m(T p) { throw new RuntimeException(); } }";
|
||||
" <@TA T extends @TB %TEST_CLASS_NAME%.CC<@TC IA> & %TEST_CLASS_NAME%. @TD ID<@TE IA>> void m(T p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "RTEs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularClassRepeatableAnnotation() {
|
||||
return "<@RTA @RTA K extends @RTB @RTB Date, @RTC @RTC V extends @RTD @RTD Object & @RTE @RTE Cloneable> void test() { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTEs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularClassRepeatableAnnotation2() {
|
||||
return "<@RTA @RTA K extends @RTB @RTB Date, @RTC @RTC V extends @RTE @RTE Cloneable> void test() { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "RTCs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "RTEs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
@TADescription(annotation = "RTFs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
public String regularClassParameterizedRepeatableAnnotation() {
|
||||
return "<K extends @RTA @RTA Map<String, @RTB @RTB String>, V extends @RTF @RTF Object" +
|
||||
" & @RTC @RTC List<@RTD @RTD List<@RTE @RTE Object>>> void test() { }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "RTEs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String abstractClassRepeatableAnnotation() {
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract <@RTA @RTA K extends @RTB @RTB Date," +
|
||||
" @RTC @RTC V extends @RTD @RTD Object & @RTE @RTE Cloneable> void test(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "RTCs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "RTEs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "RTFs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
public String abstractClassParameterizedRepeatableAnnotation() {
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract <K extends @RTE @RTE Object &" +
|
||||
" @RTA @RTA Map<String, @RTB @RTB String>, V extends @RTF @RTF Object &" +
|
||||
" @RTC @RTC List<@RTD @RTD Object>> void test(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "RTCs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "RTEs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
|
||||
public String abstractClassParameterizedRepeatableAnnotation2() {
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract <K extends @RTA @RTA Map<String, @RTB @RTB String>," +
|
||||
" V extends @RTC @RTC List<@RTD @RTD List<@RTE @RTE Object>>> void test(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String abstractClassParameterizedRepeatableAnnotation3() {
|
||||
return "abstract class %TEST_CLASS_NAME% { abstract <K extends @RTA @RTA List<String>," +
|
||||
" V extends @RTB @RTB List<Object>> void test(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER, paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
|
||||
@TADescription(annotation = "RTEs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
public String regularInterfaceRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME% { <@RTA @RTA K extends @RTB @RTB Date," +
|
||||
" @RTC @RTC V extends @RTD @RTD Object & @RTE @RTE Cloneable> void test(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1})
|
||||
@TADescription(annotation = "RTCs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
|
||||
@TADescription(annotation = "RTDs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0})
|
||||
@TADescription(annotation = "RTEs", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
|
||||
@TADescription(annotation = "RTFs", type = METHOD_TYPE_PARAMETER, paramIndex = 0)
|
||||
public String regularInterfaceParameterizedRepeatableAnnotation() {
|
||||
return "interface %TEST_CLASS_NAME% { <@RTF @RTF K extends @RTA @RTA Map<String, @RTB @RTB String>," +
|
||||
" @RTE @RTE V extends @RTC @RTC List<@RTD @RTD Object>> void test(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN)
|
||||
public String useInReturnRepeatableAnnotation1() {
|
||||
return "class %TEST_CLASS_NAME% { <T> @RTA @RTA T m() { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_RETURN, genericLocation = {3, 0})
|
||||
public String useInReturnRepeatableAnnotation2() {
|
||||
return "class %TEST_CLASS_NAME% { <T> Class<@RTA @RTA T> m() { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_RETURN)
|
||||
public String useInReturnRepeatableAnnotation3() {
|
||||
return "class %TEST_CLASS_NAME% { <T extends @RTA @RTA Object> @RTB @RTB T m() { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0, genericLocation = {3, 0})
|
||||
public String useInParamRepeatableAnnotation1() {
|
||||
return "class %TEST_CLASS_NAME% { <T> void m(Class<@RTA @RTA T> p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0, genericLocation = {3, 0})
|
||||
public String useInParamRepeatableAnnotation2() {
|
||||
return "class %TEST_CLASS_NAME% { void m(Class<@RTA @RTA Object> p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 2)
|
||||
@TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
|
||||
public String useInParamRepeatableAnnotation3() {
|
||||
return "interface IA {} " +
|
||||
"interface IB<XB> {} " +
|
||||
"interface IC<XC> {} " +
|
||||
"class %TEST_CLASS_NAME% { <T extends @RTA @RTA IB<IA> & @RTB @RTB IC<IA>>" +
|
||||
" void m(@RTC @RTC T p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 1,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 2,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER,
|
||||
paramIndex = 0)
|
||||
public String useInParamRepeatableAnnotation4() {
|
||||
return "class %TEST_CLASS_NAME% {" +
|
||||
" interface IA {} " +
|
||||
" interface IB<XB> {} " +
|
||||
" interface IC<XC> {} " +
|
||||
" <T extends @RTA @RTA IB<IA> & @RTB @RTB IC<IA>>" +
|
||||
" void m(@RTC @RTC T p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 0,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 0,
|
||||
genericLocation = {1, 0})
|
||||
@TADescription(annotation = "RTCs", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 0,
|
||||
genericLocation = {1, 0, 3, 0})
|
||||
public String useInParamRepeatableAnnotation5() {
|
||||
return "class %TEST_CLASS_NAME% {" +
|
||||
" interface IA {} " +
|
||||
" class CB<XC> {} " +
|
||||
" <T extends @RTA @RTA %TEST_CLASS_NAME%. @RTB @RTB" +
|
||||
" CB<@RTC @RTC IA>> void m(T p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = METHOD_TYPE_PARAMETER,
|
||||
paramIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 0,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "RTCs", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 0,
|
||||
genericLocation = {1, 0, 3, 0})
|
||||
@TADescription(annotation = "RTDs", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 1,
|
||||
genericLocation = {})
|
||||
@TADescription(annotation = "RTEs", type = METHOD_TYPE_PARAMETER_BOUND,
|
||||
paramIndex = 0, boundIndex = 1,
|
||||
genericLocation = {3, 0})
|
||||
public String useInParamRepeatableAnnotation6() {
|
||||
return "class %TEST_CLASS_NAME% {" +
|
||||
" interface IA {} " +
|
||||
" interface IB<XB> {} " +
|
||||
" class CC<XC> {} " +
|
||||
" interface ID<XD> {} " +
|
||||
" <@RTA @RTA T extends @RTB @RTB %TEST_CLASS_NAME%.CC<@RTC @RTC IA> &" +
|
||||
" %TEST_CLASS_NAME%. @RTD @RTD ID<@RTE @RTE IA>> void m(T p) { throw new RuntimeException(); } }";
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8006732 8006775
|
||||
* @bug 8006732 8006775 8042451
|
||||
* @summary Test population of reference info for multicatch exception parameters
|
||||
* @author Werner Dietl
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java MultiCatch.java
|
||||
@ -33,35 +33,59 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
*/
|
||||
public class MultiCatch {
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
public String multiCatch1() {
|
||||
return "void multiCatch1() { " +
|
||||
"try { new Object(); } catch (@TA NullPointerException | @TB IndexOutOfBoundsException e) { e.toString(); } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
|
||||
@TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2),
|
||||
})
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
public String multiCatch2() {
|
||||
return "void multiCatch2() { " +
|
||||
"try { new Object(); } catch (@TA NullPointerException | @TB IndexOutOfBoundsException | @TC IllegalArgumentException e) { e.toString(); } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
|
||||
@TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2),
|
||||
@TADescription(annotation = "TD", type = EXCEPTION_PARAMETER, exceptionIndex = 2),
|
||||
@TADescription(annotation = "TE", type = EXCEPTION_PARAMETER, exceptionIndex = 3),
|
||||
})
|
||||
@TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
@TADescription(annotation = "TD", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
@TADescription(annotation = "TE", type = EXCEPTION_PARAMETER, exceptionIndex = 3)
|
||||
public String multiCatch3() {
|
||||
return "void multiCatch3() { " +
|
||||
"try { new Object(); } catch (NullPointerException e1) {}" +
|
||||
"try { new Object(); } catch (@TA @TB NullPointerException | @TC @TD IndexOutOfBoundsException | @TE IllegalArgumentException e2) { e2.toString(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
public String multiCatchRepeatableAnnotation1() {
|
||||
return "void multiCatch1() { " +
|
||||
"try { new Object(); } catch (@RTA @RTA NullPointerException |" +
|
||||
" @RTB @RTB IndexOutOfBoundsException e) { e.toString(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "RTCs", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
public String multiCatchRepeatableAnnotation2() {
|
||||
return "void multiCatch2() { " +
|
||||
"try { new Object(); } catch (@RTA @RTA NullPointerException |" +
|
||||
" @RTB @RTB IndexOutOfBoundsException | @RTC @RTC IllegalArgumentException e) { e.toString(); } }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
|
||||
@TADescription(annotation = "RTCs", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
@TADescription(annotation = "RTDs", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
|
||||
@TADescription(annotation = "RTEs", type = EXCEPTION_PARAMETER, exceptionIndex = 3)
|
||||
public String multiCatchRepeatableAnnotation3() {
|
||||
return "void multiCatch3() { " +
|
||||
"try { new Object(); } catch (NullPointerException e1) {}" +
|
||||
"try { new Object(); } catch (@RTA @RTA @RTB @RTB NullPointerException |" +
|
||||
" @RTC @RTC @RTD @RTD IndexOutOfBoundsException |" +
|
||||
" @RTE @RTE IllegalArgumentException e2) { e2.toString(); } }";
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,6 +25,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for new object creations
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java NewObjects.java
|
||||
* @run main Driver NewObjects
|
||||
@ -36,11 +37,9 @@ public class NewObjects {
|
||||
return "Object returnObject() { return new @TA String(); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnObjectGeneric() {
|
||||
return "Object returnObjectGeneric() { return new @TA ArrayList<@TB String>(); }";
|
||||
}
|
||||
@ -50,13 +49,11 @@ public class NewObjects {
|
||||
return "void initObject() { Object a = new @TA String(); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TC", type = NEW,
|
||||
genericLocation = { 3, 1 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TC", type = NEW,
|
||||
genericLocation = { 3, 1 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String initObjectGeneric() {
|
||||
return "void initObjectGeneric() { Object a = new @TA HashMap<@TB String, @TC String>(); }";
|
||||
}
|
||||
@ -66,90 +63,182 @@ public class NewObjects {
|
||||
return "void eqtestObject() { if (null == new @TA String()); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String eqtestObjectGeneric() {
|
||||
return "void eqtestObjectGeneric() { if (null == new @TA ArrayList<@TB String >()); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0}),
|
||||
@TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0})
|
||||
@TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnNewArray1() {
|
||||
return "Object returnNewArray1() { return new @TA String @TB[1]; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0}),
|
||||
@TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0}),
|
||||
})
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0})
|
||||
@TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0})
|
||||
public String returnNewArray2() {
|
||||
return "Object returnNewArray2() { return new @TA String @TB [1] @TC [2]; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0}),
|
||||
@TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0}),
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TD", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0}),
|
||||
})
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0})
|
||||
@TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0})
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TD", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0})
|
||||
public String returnNewArray3() {
|
||||
return "Object returnNewArray3() { return new @TA Outer. @TB Inner @TC [1] @TD [2]; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0}),
|
||||
@TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0}),
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0, 1, 0}),
|
||||
@TADescription(annotation = "TD", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0}),
|
||||
})
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0})
|
||||
@TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0})
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0, 1, 0})
|
||||
@TADescription(annotation = "TD", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0})
|
||||
public String returnNewArray4() {
|
||||
return "Object returnNewArray4() { return new @TA Outer. @TB Middle. @TC MInner @TD [1] @TE [2]; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0, 0, 0}),
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0, 0, 0, 1, 0}),
|
||||
@TADescription(annotation = "TD", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0}),
|
||||
@TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TF", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0}),
|
||||
})
|
||||
@TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0, 0, 0})
|
||||
@TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0, 0, 0, 1, 0})
|
||||
@TADescription(annotation = "TD", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0})
|
||||
@TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TF", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0})
|
||||
public String returnNewArray5() {
|
||||
return "Object returnNewArray5() { return new @TA ArrayList<@TB Outer. @TC Middle. @TD MInner @TE [] @TF []>(); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0}),
|
||||
@TADescription(annotation = "TB", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0}),
|
||||
@TADescription(annotation = "TC", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TD", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0}),
|
||||
})
|
||||
@TADescription(annotation = "TA", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0})
|
||||
@TADescription(annotation = "TB", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0})
|
||||
@TADescription(annotation = "TC", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TD", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0})
|
||||
public String arrayField() {
|
||||
return "@TA Outer. @TB Inner @TC [] @TD [] f;";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnObjectRepeatableAnnotation() {
|
||||
return "Object returnObject() { return new @RTA @RTA String(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnObjectGenericRepeatableAnnotation() {
|
||||
return "Object returnObjectGeneric() { return new @RTA @RTA ArrayList<@RTB @RTB String>(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String initObjectRepeatableAnnotation() {
|
||||
return "void initObject() { Object a = new @RTA @RTA String(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTCs", type = NEW,
|
||||
genericLocation = { 3, 1 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String initObjectGenericRepeatableAnnotation() {
|
||||
return "void initObjectGeneric() { Object a = new @RTA @RTA HashMap<@RTB @RTB String, @RTC @RTC String>(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String eqtestObjectRepeatableAnnotation() {
|
||||
return "void eqtestObject() { if (null == new @RTA @RTA String()); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = NEW,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String eqtestObjectGenericRepeatableAnnotation() {
|
||||
return "void eqtestObjectGeneric() { if (null == new @RTA @RTA ArrayList<@RTB @RTB String >()); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0})
|
||||
@TADescription(annotation = "RTBs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnNewArrayRepeatableAnnotation1() {
|
||||
return "Object returnNewArray1() { return new @RTA @RTA String @RTB @RTB[1]; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0})
|
||||
@TADescription(annotation = "RTBs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTCs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0})
|
||||
public String returnNewArrayRepeatableAnnotation2() {
|
||||
return "Object returnNewArray2() { return new @RTA @RTA String @RTB @RTB [1] @RTC @RTC [2]; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0})
|
||||
@TADescription(annotation = "RTBs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0})
|
||||
@TADescription(annotation = "RTCs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTDs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0})
|
||||
public String returnNewArrayRepeatableAnnotation3() {
|
||||
return "Object returnNewArray3() { return new @RTA @RTA Outer. @RTB @RTB Inner @RTC @RTC [1] @RTD @RTD [2]; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0})
|
||||
@TADescription(annotation = "RTBs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0})
|
||||
@TADescription(annotation = "RTCs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0, 1, 0})
|
||||
@TADescription(annotation = "RTDs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTEs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0})
|
||||
public String returnNewArrayRepeatableAnnotation4() {
|
||||
return "Object returnNewArray4() { return new @RTA @RTA Outer." +
|
||||
" @RTB @RTB Middle. @RTC @RTC MInner @RTD @RTD [1] @RTE @RTE [2]; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0, 0, 0})
|
||||
@TADescription(annotation = "RTCs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0, 0, 0, 1, 0})
|
||||
@TADescription(annotation = "RTDs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0})
|
||||
@TADescription(annotation = "RTEs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0})
|
||||
@TADescription(annotation = "RTFs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {3, 0, 0, 0})
|
||||
public String returnNewArrayRepeatableAnnotation5() {
|
||||
return "Object returnNewArray5() { return new @RTA @RTA ArrayList<@RTB @RTB Outer." +
|
||||
" @RTC @RTC Middle. @RTD @RTD MInner @RTE @RTE [] @RTF @RTF []>(); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0})
|
||||
@TADescription(annotation = "RTBs", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0, 0, 0, 1, 0})
|
||||
@TADescription(annotation = "RTCs", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTDs", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
genericLocation = {0, 0})
|
||||
public String arrayFieldRepeatableAnnotation() {
|
||||
return "@RTA @RTA Outer. @RTB @RTB Inner @RTC @RTC [] @RTD @RTD [] f;";
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class ReferenceInfoUtil {
|
||||
public static final int IGNORE_VALUE = -321;
|
||||
|
||||
public static List<TypeAnnotation> extendedAnnotationsOf(ClassFile cf) {
|
||||
List<TypeAnnotation> annos = new ArrayList<TypeAnnotation>();
|
||||
List<TypeAnnotation> annos = new ArrayList<>();
|
||||
findAnnotations(cf, annos);
|
||||
return annos;
|
||||
}
|
||||
@ -119,128 +119,6 @@ public class ReferenceInfoUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////// TA Position Builder ///////////////////////
|
||||
/* TODO: comment out this dead code. Was this unfinished code that was
|
||||
* supposed to be used somewhere? The tests pass without this.
|
||||
private static class TAPositionBuilder {
|
||||
private TypeAnnotation.Position pos = new TypeAnnotation.Position();
|
||||
|
||||
private TAPositionBuilder() { }
|
||||
|
||||
public TypeAnnotation.Position build() { return pos; }
|
||||
|
||||
public static TAPositionBuilder ofType(TypeAnnotation.TargetType type) {
|
||||
TAPositionBuilder builder = new TAPositionBuilder();
|
||||
builder.pos.type = type;
|
||||
return builder;
|
||||
}
|
||||
|
||||
public TAPositionBuilder atOffset(int offset) {
|
||||
switch (pos.type) {
|
||||
// type cast
|
||||
case TYPECAST:
|
||||
// instanceof
|
||||
case INSTANCEOF:
|
||||
// new expression
|
||||
case NEW:
|
||||
pos.offset = offset;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid field for given type: " + pos.type);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public TAPositionBuilder atLocalPosition(int offset, int length, int index) {
|
||||
switch (pos.type) {
|
||||
// local variable
|
||||
case LOCAL_VARIABLE:
|
||||
pos.lvarOffset = new int[] { offset };
|
||||
pos.lvarLength = new int[] { length };
|
||||
pos.lvarIndex = new int[] { index };
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid field for given type: " + pos.type);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public TAPositionBuilder atParameterIndex(int index) {
|
||||
switch (pos.type) {
|
||||
// type parameters
|
||||
case CLASS_TYPE_PARAMETER:
|
||||
case METHOD_TYPE_PARAMETER:
|
||||
// method parameter
|
||||
case METHOD_FORMAL_PARAMETER:
|
||||
pos.parameter_index = index;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid field for given type: " + pos.type);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public TAPositionBuilder atParamBound(int param, int bound) {
|
||||
switch (pos.type) {
|
||||
// type parameters bounds
|
||||
case CLASS_TYPE_PARAMETER_BOUND:
|
||||
case METHOD_TYPE_PARAMETER_BOUND:
|
||||
pos.parameter_index = param;
|
||||
pos.bound_index = bound;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid field for given type: " + pos.type);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public TAPositionBuilder atWildcardPosition(TypeAnnotation.Position pos) {
|
||||
switch (pos.type) {
|
||||
// wildcards
|
||||
case WILDCARD_BOUND:
|
||||
pos.wildcard_position = pos;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid field for given type: " + pos.type);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public TAPositionBuilder atTypeIndex(int index) {
|
||||
switch (pos.type) {
|
||||
// class extends or implements clauses
|
||||
case CLASS_EXTENDS:
|
||||
// throws
|
||||
case THROWS:
|
||||
pos.type_index = index;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid field for given type: " + pos.type);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public TAPositionBuilder atOffsetWithIndex(int offset, int index) {
|
||||
switch (pos.type) {
|
||||
// method type argument: wasn't specified
|
||||
case NEW_TYPE_ARGUMENT:
|
||||
case METHOD_TYPE_ARGUMENT:
|
||||
pos.offset = offset;
|
||||
pos.type_index = index;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid field for given type: " + pos.type);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public TAPositionBuilder atGenericLocation(Integer ...loc) {
|
||||
pos.location = Arrays.asList(loc);
|
||||
pos.type = pos.type.getGenericComplement();
|
||||
return this;
|
||||
}
|
||||
}*/
|
||||
|
||||
/////////////////////// Equality testing /////////////////////
|
||||
private static boolean areEquals(int a, int b) {
|
||||
return a == b || a == IGNORE_VALUE || b == IGNORE_VALUE;
|
||||
@ -264,21 +142,18 @@ public class ReferenceInfoUtil {
|
||||
}
|
||||
|
||||
public static boolean areEquals(TypeAnnotation.Position p1, TypeAnnotation.Position p2) {
|
||||
if (p1 == p2)
|
||||
return true;
|
||||
if (p1 == null || p2 == null)
|
||||
return false;
|
||||
return p1 == p2 || !(p1 == null || p2 == null) &&
|
||||
p1.type == p2.type &&
|
||||
(p1.location.equals(p2.location)) &&
|
||||
areEquals(p1.offset, p2.offset) &&
|
||||
areEquals(p1.lvarOffset, p2.lvarOffset) &&
|
||||
areEquals(p1.lvarLength, p2.lvarLength) &&
|
||||
areEquals(p1.lvarIndex, p2.lvarIndex) &&
|
||||
areEquals(p1.bound_index, p2.bound_index) &&
|
||||
areEquals(p1.parameter_index, p2.parameter_index) &&
|
||||
areEquals(p1.type_index, p2.type_index) &&
|
||||
areEquals(p1.exception_index, p2.exception_index);
|
||||
|
||||
return ((p1.type == p2.type)
|
||||
&& (p1.location.equals(p2.location))
|
||||
&& areEquals(p1.offset, p2.offset)
|
||||
&& areEquals(p1.lvarOffset, p2.lvarOffset)
|
||||
&& areEquals(p1.lvarLength, p2.lvarLength)
|
||||
&& areEquals(p1.lvarIndex, p2.lvarIndex)
|
||||
&& areEquals(p1.bound_index, p2.bound_index)
|
||||
&& areEquals(p1.parameter_index, p2.parameter_index)
|
||||
&& areEquals(p1.type_index, p2.type_index)
|
||||
&& areEquals(p1.exception_index, p2.exception_index));
|
||||
}
|
||||
|
||||
private static TypeAnnotation findAnnotation(String name, List<TypeAnnotation> annotations, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
|
||||
@ -306,9 +181,6 @@ public class ReferenceInfoUtil {
|
||||
if (actual == null)
|
||||
throw new ComparisionException("Expected annotation not found: " + aName);
|
||||
|
||||
// TODO: you currently get an exception if the test case does not use all necessary
|
||||
// annotation attributes, e.g. forgetting the offset for a local variable.
|
||||
// It would be nicer to give an understandable warning instead.
|
||||
if (!areEquals(expected, actual.position)) {
|
||||
throw new ComparisionException("Unexpected position for annotation : " + aName +
|
||||
"\n Expected: " + expected.toString() +
|
||||
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for resource variable
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java ResourceVariable.java
|
||||
* @run main Driver ResourceVariable
|
||||
*/
|
||||
|
||||
import static com.sun.tools.classfile.TypeAnnotation.TargetType.RESOURCE_VARIABLE;
|
||||
import static java.lang.System.lineSeparator;
|
||||
|
||||
public class ResourceVariable {
|
||||
|
||||
@TADescription(annotation = "TA", type = RESOURCE_VARIABLE,
|
||||
lvarOffset = {10}, lvarLength = {118}, lvarIndex = {1})
|
||||
@TADescription(annotation = "TB", type = RESOURCE_VARIABLE,
|
||||
lvarOffset = {22}, lvarLength = {35}, lvarIndex = {3})
|
||||
public String testResourceVariable() {
|
||||
return
|
||||
"public void f() throws IOException {" + lineSeparator() +
|
||||
" try (@TA InputStream is1 = new FileInputStream(\"\")) {" + lineSeparator() +
|
||||
" try (@TB InputStream is2 = new FileInputStream(\"\")) {}" + lineSeparator() +
|
||||
" }" + lineSeparator() +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = RESOURCE_VARIABLE,
|
||||
lvarOffset = {10}, lvarLength = {30}, lvarIndex = {1})
|
||||
public String testRepeatedAnnotation1() {
|
||||
return
|
||||
"public void f() throws IOException {" + lineSeparator() +
|
||||
" try (@RTA @RTA InputStream is1 = new FileInputStream(\"\")) {}" + lineSeparator() +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = RESOURCE_VARIABLE,
|
||||
lvarOffset = {10}, lvarLength = {30}, lvarIndex = {1})
|
||||
public String testRepeatedAnnotation2() {
|
||||
return
|
||||
"public void f() throws IOException {" + lineSeparator() +
|
||||
" try (@RTAs({@RTA, @RTA}) InputStream is1 = new FileInputStream(\"\")) {}" + lineSeparator() +
|
||||
"}";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "TA", type = RESOURCE_VARIABLE,
|
||||
lvarOffset = {10}, lvarLength = {118}, lvarIndex = {1})
|
||||
@TADescription(annotation = "TB", type = RESOURCE_VARIABLE,
|
||||
lvarOffset = {22}, lvarLength = {35}, lvarIndex = {3})
|
||||
public String testSeveralVariablesInTryWithResources() {
|
||||
return
|
||||
"public void f() throws IOException {" + lineSeparator() +
|
||||
" try (@TA InputStream is1 = new FileInputStream(\"\");" + lineSeparator() +
|
||||
" @TB InputStream is2 = new FileInputStream(\"\")) {}" + lineSeparator() +
|
||||
"}";
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for type casts
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java TypeCasts.java
|
||||
* @run main Driver TypeCasts
|
||||
@ -37,27 +38,23 @@ public class TypeCasts {
|
||||
return "Object returnObject() { return (@TA String)null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TC", type = CAST,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TC", type = CAST,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String returnObjectArray() {
|
||||
return "Object returnObjectArray() { return (@TC String @TA [] @TB [])null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String returnObjectGeneric() {
|
||||
return "Object returnObjectGeneric() { return (@TA List<@TB String>)null; }";
|
||||
}
|
||||
@ -68,13 +65,11 @@ public class TypeCasts {
|
||||
return "Object returnPrim() { return (@TA int)0; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String returnPrimArray() {
|
||||
return "Object returnPrimArray() { return (@TB int @TA [])null; }";
|
||||
}
|
||||
@ -85,24 +80,20 @@ public class TypeCasts {
|
||||
return "void initObject() { Object a = (@TA String)null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String initObjectArray() {
|
||||
return "void initObjectArray() { Object a = (@TB String @TA [])null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String initObjectGeneric() {
|
||||
return "void initObjectGeneric() { Object a = (@TA List<@TB String>)null; }";
|
||||
}
|
||||
@ -113,13 +104,11 @@ public class TypeCasts {
|
||||
return "void initPrim() { Object a = (@TA int)0; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String initPrimArray() {
|
||||
return "void initPrimArray() { Object a = (@TB int @TA [])null; }";
|
||||
}
|
||||
@ -130,24 +119,20 @@ public class TypeCasts {
|
||||
return "void eqtestObject() { if (null == (@TA String)null); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String eqtestObjectArray() {
|
||||
return "void eqtestObjectArray() { if (null == (@TB String @TA [])null); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String eqtestObjectGeneric() {
|
||||
return "void eqtestObjectGeneric() { if (null == (@TA List<@TB String >)null); }";
|
||||
}
|
||||
@ -159,42 +144,182 @@ public class TypeCasts {
|
||||
return "void eqtestPrim(int a) { if (0 == (@TA int)a); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String eqtestPrimArray() {
|
||||
return "void eqtestPrimArray() { if (null == (@TB int @TA [])null); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1),
|
||||
@TADescription(annotation = "TC", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1,
|
||||
genericLocation = {3, 0})
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1)
|
||||
@TADescription(annotation = "TC", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1,
|
||||
genericLocation = {3, 0})
|
||||
public String intersection1() {
|
||||
return "void intersection() { Object o = (@TA String & @TB Comparable<@TC String>) null; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 0),
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1),
|
||||
@TADescription(annotation = "TC", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1,
|
||||
genericLocation = {3, 0}),
|
||||
@TADescription(annotation = "TD", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 2),
|
||||
})
|
||||
@TADescription(annotation = "TA", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 0)
|
||||
@TADescription(annotation = "TB", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1)
|
||||
@TADescription(annotation = "TC", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1,
|
||||
genericLocation = {3, 0})
|
||||
@TADescription(annotation = "TD", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 2)
|
||||
public String intersection2() {
|
||||
return "void intersection() { Object o = (@TA String & @TB Comparable<@TC String> & @TD CharSequence) null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String returnObjectRepeatableAnnotation() {
|
||||
return "Object returnObject() { return (@RTA @RTA String)null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTCs", type = CAST,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String returnObjectArrayRepeatableAnnotation() {
|
||||
return "Object returnObjectArray() { return (@RTC @RTC String @RTA @RTA [] @RTB @RTB [])null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CAST,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String returnObjectGenericRepeatableAnnotation() {
|
||||
return "Object returnObjectGeneric() { return (@RTA @RTA List<@RTB @RTB String>)null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String returnPrimRepeatableAnnotation() {
|
||||
return "Object returnPrim() { return (@RTA @RTA int)0; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String returnPrimArrayRepeatableAnnotation() {
|
||||
return "Object returnPrimArray() { return (@RTB @RTB int @RTA @RTA [])null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String initObjectRepeatableAnnotation() {
|
||||
return "void initObject() { Object a = (@RTA @RTA String)null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String initObjectArrayRepeatableAnnotation() {
|
||||
return "void initObjectArray() { Object a = (@RTB @RTB String @RTA @RTA [])null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CAST,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String initObjectGenericRepeatableAnnotation() {
|
||||
return "void initObjectGeneric() { Object a = (@RTA @RTA List<@RTB @RTB String>)null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String initPrimRepeatableAnnotation() {
|
||||
return "void initPrim() { Object a = (@RTA @RTA int)0; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String initPrimArrayRepeatableAnnotation() {
|
||||
return "void initPrimArray() { Object a = (@RTB @RTB int @RTA @RTA [])null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String eqtestObjectRepeatableAnnotation() {
|
||||
return "void eqtestObject() { if (null == (@RTA @RTA String)null); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String eqtestObjectArrayRepeatableAnnotation() {
|
||||
return "void eqtestObjectArray() { if (null == (@RTB @RTB String @RTA @RTA [])null); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CAST,
|
||||
genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String eqtestObjectGenericRepeatableAnnotation() {
|
||||
return "void eqtestObjectGeneric() { if (null == (@RTA @RTA List<@RTB @RTB String >)null); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
// compiler optimizes away compile time constants casts
|
||||
public String eqtestPrimRepeatableAnnotation() {
|
||||
return "void eqtestPrim(int a) { if (0 == (@RTA @RTA int)a); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CAST,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
|
||||
typeIndex = 0)
|
||||
public String eqtestPrimArrayRepeatableAnnotation() {
|
||||
return "void eqtestPrimArray() { if (null == (@RTB @RTB int @RTA @RTA [])null); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1)
|
||||
@TADescription(annotation = "RTCs", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1,
|
||||
genericLocation = {3, 0})
|
||||
public String intersectionRepeatableAnnotation1() {
|
||||
return "void intersection() { Object o = (@RTA @RTA String & @RTB @RTB Comparable<@RTC @RTC String>) null; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 0)
|
||||
@TADescription(annotation = "RTBs", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1)
|
||||
@TADescription(annotation = "RTCs", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1,
|
||||
genericLocation = {3, 0})
|
||||
@TADescription(annotation = "RTDs", type = CAST,
|
||||
offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 2)
|
||||
public String intersectionRepeatableAnnotation2() {
|
||||
return "void intersection() { Object o = (@RTA @RTA String & @RTB @RTB Comparable<@RTC @RTC String> &" +
|
||||
" @RTD @RTD CharSequence) null; }";
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8042451
|
||||
* @summary Test population of reference info for class literals
|
||||
* @compile -g Driver.java ReferenceInfoUtil.java TypeTests.java
|
||||
* @run main Driver TypeTests
|
||||
@ -36,26 +37,22 @@ public class TypeTests {
|
||||
return "Object returnObject() { return null instanceof @TA String; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnObjectArray() {
|
||||
return "Object returnObjectArray() { return null instanceof @TC String @TA [] @TB []; }";
|
||||
}
|
||||
|
||||
// no type test for primitives
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnPrimArray() {
|
||||
return "Object returnPrimArray() { return null instanceof @TC int @TA [] @TB []; }";
|
||||
}
|
||||
@ -68,26 +65,22 @@ public class TypeTests {
|
||||
return "void initObject() { Object a = null instanceof @TA String; }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String initObjectArray() {
|
||||
return "void initObjectArray() { Object a = null instanceof @TC String @TA [] @TB []; }";
|
||||
}
|
||||
|
||||
// no primitive instanceof
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String initPrimArray() {
|
||||
return "void initPrimArray() { Object a = null instanceof @TC int @TA [] @TB []; }";
|
||||
}
|
||||
@ -100,26 +93,22 @@ public class TypeTests {
|
||||
return "void eqtestObject() { if (true == (null instanceof @TA String)); }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String eqtestObjectArray() {
|
||||
return "void eqtestObjectArray() { if (true == (null instanceof @TC String @TA [] @TB [])); }";
|
||||
}
|
||||
|
||||
// no primitives
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
})
|
||||
@TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TB", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "TC", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String eqtestPrimArray() {
|
||||
return "void eqtestPrimArray() { if (true == (null instanceof @TC int @TA [] @TB [])); }";
|
||||
}
|
||||
@ -127,4 +116,72 @@ public class TypeTests {
|
||||
// no void
|
||||
// no void array
|
||||
|
||||
@TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnObjectRepeatableAnnotation() {
|
||||
return "Object returnObject() { return null instanceof @RTA @RTA String; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTCs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnObjectArrayRepeatableAnnotation() {
|
||||
return "Object returnObjectArray() { return null instanceof @RTC @RTC String @RTA @RTA [] @RTB @RTB []; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTCs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String returnPrimArrayRepeatableAnnotation() {
|
||||
return "Object returnPrimArrayRepeatableAnnotation() { return null instanceof @RTC @RTC int @RTA @RTA [] @RTB @RTB []; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String initObjectRepeatableAnnotation() {
|
||||
return "void initObject() { Object a = null instanceof @RTA @RTA String; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTCs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String initObjectArrayRepeatableAnnotation() {
|
||||
return "void initObjectArray() { Object a = null instanceof @RTC @RTC String @RTA @RTA [] @RTB @RTB []; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTCs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String initPrimArrayRepeatableAnnotation() {
|
||||
return "void initPrimArray() { Object a = null instanceof @RTC @RTC int @RTA @RTA [] @RTB @RTB []; }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String eqtestObjectRepeatableAnnotation() {
|
||||
return "void eqtestObject() { if (true == (null instanceof @RTA @RTA String)); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTCs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String eqtestObjectArrayRepeatableAnnotation() {
|
||||
return "void eqtestObjectArray() { if (true == (null instanceof @RTC @RTC String @RTA @RTA [] @RTB @RTB [])); }";
|
||||
}
|
||||
|
||||
@TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTBs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
@TADescription(annotation = "RTCs", type = INSTANCEOF,
|
||||
genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
|
||||
public String eqtestPrimArrayRepeatableAnnotation() {
|
||||
return "void eqtestPrimArray() { if (true == (null instanceof @RTC @RTC int @RTA @RTA [] @RTB @RTB [])); }";
|
||||
}
|
||||
}
|
||||
|
632
langtools/test/tools/javac/api/TestSearchPaths.java
Normal file
632
langtools/test/tools/javac/api/TestSearchPaths.java
Normal file
@ -0,0 +1,632 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7026941
|
||||
* @summary path options ignored when reusing filemanager across tasks
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaCompiler.CompilationTask;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.SimpleJavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.StandardLocation;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import static javax.tools.StandardLocation.*;
|
||||
|
||||
/**
|
||||
* Test for combinations of using javac command-line options and fileManager setLocation
|
||||
* calls to affect the locations available in the fileManager.
|
||||
*
|
||||
* Using a single Java compiler and file manager, for each of the standard locations,
|
||||
* a series of operations is performed, using either compiler options or setLocation
|
||||
* calls. Each operation includes a compilation, and then a check for the value of
|
||||
* the standard location available in the file manager.
|
||||
*
|
||||
* The operations generate and use unique files to minimize the possibility of false
|
||||
* positive results.
|
||||
*/
|
||||
public class TestSearchPaths {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
TestSearchPaths t = new TestSearchPaths();
|
||||
t.run();
|
||||
}
|
||||
|
||||
void run() throws Exception {
|
||||
compiler = ToolProvider.getSystemJavaCompiler();
|
||||
fileManager = compiler.getStandardFileManager(null, null, null);
|
||||
|
||||
// basic output path
|
||||
testClassOutput();
|
||||
|
||||
// basic search paths
|
||||
testClassPath();
|
||||
testSourcePath();
|
||||
testPlatformClassPath();
|
||||
|
||||
// annotation processing
|
||||
testAnnotationProcessorPath();
|
||||
testSourceOutput();
|
||||
|
||||
// javah equivalent
|
||||
testNativeHeaderOutput();
|
||||
|
||||
// future-proof: guard against new StandardLocations being added
|
||||
if (!tested.equals(EnumSet.allOf(StandardLocation.class))) {
|
||||
error("not all standard locations have been tested");
|
||||
out.println("not yet tested: " + EnumSet.complementOf(tested));
|
||||
}
|
||||
|
||||
if (errors > 0) {
|
||||
throw new Exception(errors + " errors occurred");
|
||||
}
|
||||
}
|
||||
|
||||
void testClassOutput() throws IOException {
|
||||
String test = "testClassOutput";
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
File classes = createDir(test + "/" + i + "/classes");
|
||||
List<String> options;
|
||||
switch (i) {
|
||||
default:
|
||||
options = getOptions("-d", classes.getPath());
|
||||
break;
|
||||
|
||||
case 3:
|
||||
setLocation(CLASS_OUTPUT, classes);
|
||||
options = null;
|
||||
break;
|
||||
}
|
||||
List<JavaFileObject> sources = getSources("class C" + i + " { }");
|
||||
callTask(options, sources);
|
||||
checkPath(CLASS_OUTPUT, Mode.EQUALS, classes);
|
||||
checkFile(CLASS_OUTPUT, "C" + i + ".class");
|
||||
}
|
||||
|
||||
tested.add(CLASS_OUTPUT);
|
||||
}
|
||||
|
||||
void testClassPath() throws IOException {
|
||||
String test = "testClassPath";
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
File classes = createDir(test + "/" + i + "/classes");
|
||||
File classpath = new File("testClassOutput/" + i + "/classes");
|
||||
List<String> options;
|
||||
switch (i) {
|
||||
default:
|
||||
options = getOptions("-d", classes.getPath(), "-classpath", classpath.getPath());
|
||||
break;
|
||||
|
||||
case 3:
|
||||
setLocation(CLASS_PATH, classpath);
|
||||
options = getOptions("-d", classes.getPath());
|
||||
break;
|
||||
|
||||
case 4:
|
||||
options = getOptions("-d", classes.getPath(), "-cp", classpath.getPath());
|
||||
break;
|
||||
}
|
||||
List<JavaFileObject> sources = getSources("class D" + i + " { C" + i + " c; }");
|
||||
callTask(options, sources);
|
||||
checkPath(CLASS_PATH, Mode.EQUALS, classpath);
|
||||
checkFile(CLASS_OUTPUT, "D" + i + ".class");
|
||||
}
|
||||
|
||||
tested.add(CLASS_PATH);
|
||||
}
|
||||
|
||||
void testSourcePath() throws IOException {
|
||||
String test = "testSourcePath";
|
||||
setLocation(CLASS_PATH); // empty
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
File src = createDir(test + "/" + i + "/src");
|
||||
writeFile(src, "C" + i + ".java", "class C" + i + "{ }");
|
||||
File classes = createDir(test + "/" + i + "/classes");
|
||||
File srcpath = src;
|
||||
List<String> options;
|
||||
switch (i) {
|
||||
default:
|
||||
options = getOptions("-d", classes.getPath(), "-sourcepath", srcpath.getPath());
|
||||
break;
|
||||
|
||||
case 3:
|
||||
setLocation(SOURCE_PATH, srcpath);
|
||||
options = getOptions("-d", classes.getPath());
|
||||
break;
|
||||
}
|
||||
List<JavaFileObject> sources = getSources("class D" + i + " { C" + i + " c; }");
|
||||
callTask(options, sources);
|
||||
checkPath(SOURCE_PATH, Mode.EQUALS, srcpath);
|
||||
checkFile(CLASS_OUTPUT, "D" + i + ".class");
|
||||
}
|
||||
|
||||
tested.add(SOURCE_PATH);
|
||||
}
|
||||
|
||||
void testPlatformClassPath() throws IOException {
|
||||
String test = "testPlatformClassPath";
|
||||
|
||||
List<File> defaultPath = getLocation(PLATFORM_CLASS_PATH);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (File f: defaultPath) {
|
||||
if (sb.length() > 0)
|
||||
sb.append(File.pathSeparator);
|
||||
sb.append(f);
|
||||
}
|
||||
String defaultPathString = sb.toString();
|
||||
|
||||
setLocation(CLASS_PATH); // empty
|
||||
setLocation(SOURCE_PATH); // empty
|
||||
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
File classes = createDir(test + "/" + i + "/classes");
|
||||
File testJars = createDir(test + "/" + i + "/testJars");
|
||||
File testClasses = createDir(test + "/" + i + "/testClasses");
|
||||
callTask(getOptions("-d", testClasses.getPath()), getSources("class C" + i + " { }"));
|
||||
|
||||
List<String> options;
|
||||
Mode mode;
|
||||
List<File> match;
|
||||
String reference = "C" + i + " c;";
|
||||
|
||||
File jar;
|
||||
|
||||
switch (i) {
|
||||
case 1:
|
||||
options = getOptions("-d", classes.getPath(), "-Xbootclasspath/p:" + testClasses);
|
||||
mode = Mode.STARTS_WITH;
|
||||
match = Arrays.asList(testClasses);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// the default values for -extdirs and -endorseddirs come after the bootclasspath;
|
||||
// so to check -Xbootclasspath/a: we specify empty values for those options.
|
||||
options = getOptions("-d", classes.getPath(),
|
||||
"-Xbootclasspath/a:" + testClasses,
|
||||
"-extdirs", "",
|
||||
"-endorseddirs", "");
|
||||
mode = Mode.ENDS_WITH;
|
||||
match = Arrays.asList(testClasses);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
options = getOptions("-d", classes.getPath(), "-Xbootclasspath:" + defaultPathString);
|
||||
mode = Mode.EQUALS;
|
||||
match = defaultPath;
|
||||
reference = "";
|
||||
break;
|
||||
|
||||
case 4:
|
||||
fileManager.setLocation(PLATFORM_CLASS_PATH, null);
|
||||
jar = new File(testJars, "j" + i + ".jar");
|
||||
writeJar(jar, testClasses, "C" + i + ".class");
|
||||
options = getOptions("-d", classes.getPath(), "-endorseddirs", testJars.getPath());
|
||||
mode = Mode.CONTAINS;
|
||||
match = Arrays.asList(jar);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
fileManager.setLocation(PLATFORM_CLASS_PATH, null);
|
||||
jar = new File(testJars, "j" + i + ".jar");
|
||||
writeJar(jar, testClasses, "C" + i + ".class");
|
||||
options = getOptions("-d", classes.getPath(), "-Djava.endorsed.dirs=" + testJars.getPath());
|
||||
mode = Mode.CONTAINS;
|
||||
match = Arrays.asList(jar);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
fileManager.setLocation(PLATFORM_CLASS_PATH, null);
|
||||
jar = new File(testJars, "j" + i + ".jar");
|
||||
writeJar(jar, testClasses, "C" + i + ".class");
|
||||
options = getOptions("-d", classes.getPath(), "-extdirs", testJars.getPath());
|
||||
mode = Mode.CONTAINS;
|
||||
match = Arrays.asList(jar);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
fileManager.setLocation(PLATFORM_CLASS_PATH, null);
|
||||
jar = new File(testJars, "j" + i + ".jar");
|
||||
writeJar(jar, testClasses, "C" + i + ".class");
|
||||
options = getOptions("-d", classes.getPath(), "-Djava.ext.dirs=" + testJars.getPath());
|
||||
mode = Mode.CONTAINS;
|
||||
match = Arrays.asList(jar);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
setLocation(PLATFORM_CLASS_PATH, defaultPath);
|
||||
options = getOptions("-d", classes.getPath());
|
||||
mode = Mode.EQUALS;
|
||||
match = defaultPath;
|
||||
reference = "";
|
||||
break;
|
||||
|
||||
default:
|
||||
options = getOptions("-d", classes.getPath(), "-bootclasspath", defaultPathString);
|
||||
mode = Mode.EQUALS;
|
||||
match = defaultPath;
|
||||
reference = "";
|
||||
break;
|
||||
}
|
||||
List<JavaFileObject> sources = getSources("class D" + i + " { " + reference + " }");
|
||||
|
||||
callTask(options, sources);
|
||||
checkPath(PLATFORM_CLASS_PATH, mode, match);
|
||||
checkFile(CLASS_OUTPUT, "D" + i + ".class");
|
||||
}
|
||||
|
||||
tested.add(PLATFORM_CLASS_PATH);
|
||||
}
|
||||
|
||||
void testAnnotationProcessorPath() throws IOException {
|
||||
String test = "testAnnotationProcessorPath";
|
||||
|
||||
String template =
|
||||
"import java.util.*;\n"
|
||||
+ "import javax.annotation.processing.*;\n"
|
||||
+ "import javax.lang.model.*;\n"
|
||||
+ "import javax.lang.model.element.*;\n"
|
||||
+ "@SupportedAnnotationTypes(\"*\")\n"
|
||||
+ "public class A%d extends AbstractProcessor {\n"
|
||||
+ " public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {\n"
|
||||
+ " return true;\n"
|
||||
+ " }\n"
|
||||
+ " public SourceVersion getSupportedSourceVersion() {\n"
|
||||
+ " return SourceVersion.latest();\n"
|
||||
+ " }\n"
|
||||
+ "}";
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
File classes = createDir(test + "/" + i + "/classes");
|
||||
File annodir = createDir(test + "/" + i + "/processors");
|
||||
callTask(getOptions("-d", annodir.getPath()), getSources(String.format(template, i)));
|
||||
File annopath = annodir;
|
||||
List<String> options;
|
||||
switch (i) {
|
||||
default:
|
||||
options = getOptions("-d", classes.getPath(),
|
||||
"-processorpath", annopath.getPath(),
|
||||
"-processor", "A" + i);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
setLocation(ANNOTATION_PROCESSOR_PATH, annopath);
|
||||
options = getOptions("-d", classes.getPath(),
|
||||
"-processor", "A" + i);
|
||||
break;
|
||||
}
|
||||
List<JavaFileObject> sources = getSources("class D" + i + " { }");
|
||||
callTask(options, sources);
|
||||
checkPath(ANNOTATION_PROCESSOR_PATH, Mode.EQUALS, annopath);
|
||||
checkFile(CLASS_OUTPUT, "D" + i + ".class");
|
||||
}
|
||||
|
||||
tested.add(ANNOTATION_PROCESSOR_PATH);
|
||||
}
|
||||
|
||||
void testSourceOutput() throws IOException {
|
||||
String test = "testAnnotationProcessorPath";
|
||||
|
||||
String source =
|
||||
"import java.io.*;\n"
|
||||
+ "import java.util.*;\n"
|
||||
+ "import javax.annotation.processing.*;\n"
|
||||
+ "import javax.lang.model.*;\n"
|
||||
+ "import javax.lang.model.element.*;\n"
|
||||
+ "import javax.tools.*;\n"
|
||||
+ "@SupportedOptions(\"name\")\n"
|
||||
+ "@SupportedAnnotationTypes(\"*\")\n"
|
||||
+ "public class A extends AbstractProcessor {\n"
|
||||
+ " int round = 0;\n"
|
||||
+ " public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {\n"
|
||||
+ " if (round++ == 0) try {\n"
|
||||
+ " String name = processingEnv.getOptions().get(\"name\");\n"
|
||||
+ " JavaFileObject fo = processingEnv.getFiler().createSourceFile(name);\n"
|
||||
+ " try (Writer out = fo.openWriter()) {\n"
|
||||
+ " out.write(\"class \" + name + \" { }\");\n"
|
||||
+ " }\n"
|
||||
+ " } catch (IOException e) { throw new Error(e); }\n"
|
||||
+ " return true;\n"
|
||||
+ " }\n"
|
||||
+ " public SourceVersion getSupportedSourceVersion() {\n"
|
||||
+ " return SourceVersion.latest();\n"
|
||||
+ " }\n"
|
||||
+ "}";
|
||||
|
||||
File annodir = createDir(test + "/processors");
|
||||
callTask(getOptions("-d", annodir.getPath()), getSources(source));
|
||||
setLocation(ANNOTATION_PROCESSOR_PATH, annodir);
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
File classes = createDir(test + "/" + i + "/classes");
|
||||
File genSrc = createDir(test + "/" + "/genSrc");
|
||||
List<String> options;
|
||||
switch (i) {
|
||||
default:
|
||||
options = getOptions("-d", classes.getPath(),
|
||||
"-processor", "A", "-Aname=G" + i,
|
||||
"-s", genSrc.getPath());
|
||||
break;
|
||||
|
||||
case 3:
|
||||
setLocation(SOURCE_OUTPUT, genSrc);
|
||||
options = getOptions("-d", classes.getPath(),
|
||||
"-processor", "A", "-Aname=G" + i);
|
||||
break;
|
||||
}
|
||||
List<JavaFileObject> sources = getSources("class D" + i + " { }");
|
||||
callTask(options, sources);
|
||||
checkPath(SOURCE_OUTPUT, Mode.EQUALS, genSrc);
|
||||
checkFile(CLASS_OUTPUT, "D" + i + ".class");
|
||||
checkFile(CLASS_OUTPUT, "G" + i + ".class");
|
||||
}
|
||||
tested.add(SOURCE_OUTPUT);
|
||||
}
|
||||
|
||||
void testNativeHeaderOutput() throws IOException {
|
||||
String test = "testNativeHeaderOutput";
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
File classes = createDir(test + "/" + i + "/classes");
|
||||
File headers = createDir(test + "/" + i + "/hdrs");
|
||||
List<String> options;
|
||||
switch (i) {
|
||||
default:
|
||||
options = getOptions("-d", classes.getPath(), "-h", headers.getPath());
|
||||
break;
|
||||
|
||||
case 3:
|
||||
setLocation(NATIVE_HEADER_OUTPUT, headers);
|
||||
options = getOptions("-d", classes.getPath());
|
||||
break;
|
||||
}
|
||||
List<JavaFileObject> sources = getSources("class C" + i + " { native void m(); }");
|
||||
callTask(options, sources);
|
||||
checkPath(NATIVE_HEADER_OUTPUT, Mode.EQUALS, headers);
|
||||
checkFile(NATIVE_HEADER_OUTPUT, "C" + i + ".h");
|
||||
}
|
||||
|
||||
tested.add(StandardLocation.NATIVE_HEADER_OUTPUT);
|
||||
}
|
||||
|
||||
List<String> getOptions(String... args) {
|
||||
return Arrays.asList(args);
|
||||
}
|
||||
|
||||
List<JavaFileObject> getSources(String... sources) {
|
||||
List<JavaFileObject> list = new ArrayList<>();
|
||||
for (String s: sources)
|
||||
list.add(getSource(s));
|
||||
return list;
|
||||
}
|
||||
|
||||
JavaFileObject getSource(final String source) {
|
||||
return new SimpleJavaFileObject(getURIFromSource(source), JavaFileObject.Kind.SOURCE) {
|
||||
@Override
|
||||
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
|
||||
return source;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void callTask(List<String> options, List<JavaFileObject> files) {
|
||||
out.print("compile: ");
|
||||
if (options != null) {
|
||||
for (String o: options) {
|
||||
if (o.length() > 64) {
|
||||
o = o.substring(0, 32) + "..." + o.substring(o.length() - 32);
|
||||
}
|
||||
out.print(" " + o);
|
||||
}
|
||||
}
|
||||
for (JavaFileObject f: files)
|
||||
out.print(" " + f.getName());
|
||||
out.println();
|
||||
CompilationTask t = compiler.getTask(out, fileManager, null, options, null, files);
|
||||
boolean ok = t.call();
|
||||
if (!ok)
|
||||
error("compilation failed");
|
||||
}
|
||||
|
||||
enum Mode { EQUALS, CONTAINS, STARTS_WITH, ENDS_WITH };
|
||||
|
||||
void checkFile(StandardLocation l, String path) {
|
||||
if (!l.isOutputLocation()) {
|
||||
error("Not an output location: " + l);
|
||||
return;
|
||||
}
|
||||
|
||||
List<File> files = getLocation(l);
|
||||
if (files == null) {
|
||||
error("location is unset: " + l);
|
||||
return;
|
||||
}
|
||||
|
||||
if (files.size() != 1)
|
||||
error("unexpected number of entries on " + l + ": " + files.size());
|
||||
|
||||
File f = new File(files.get(0), path);
|
||||
if (!f.exists())
|
||||
error("file not found: " + f);
|
||||
}
|
||||
|
||||
void checkPath(StandardLocation l, Mode m, File expect) {
|
||||
checkPath(l, m, Arrays.asList(expect));
|
||||
}
|
||||
|
||||
void checkPath(StandardLocation l, Mode m, List<File> expect) {
|
||||
List<File> files = getLocation(l);
|
||||
if (files == null) {
|
||||
error("location is unset: " + l);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (m) {
|
||||
case EQUALS:
|
||||
if (!Objects.equals(files, expect)) {
|
||||
error("location does not match the expected files: " + l);
|
||||
out.println("found: " + files);
|
||||
out.println("expect: " + expect);
|
||||
}
|
||||
break;
|
||||
|
||||
case CONTAINS:
|
||||
int containsIndex = Collections.indexOfSubList(files, expect);
|
||||
if (containsIndex == -1) {
|
||||
error("location does not contain the expected files: " + l);
|
||||
out.println("found: " + files);
|
||||
out.println("expect: " + expect);
|
||||
}
|
||||
break;
|
||||
|
||||
case STARTS_WITH:
|
||||
int startsIndex = Collections.indexOfSubList(files, expect);
|
||||
if (startsIndex != 0) {
|
||||
error("location does not start with the expected files: " + l);
|
||||
out.println("found: " + files);
|
||||
out.println("expect: " + expect);
|
||||
}
|
||||
break;
|
||||
|
||||
case ENDS_WITH:
|
||||
int endsIndex = Collections.lastIndexOfSubList(files, expect);
|
||||
if (endsIndex != files.size() - expect.size()) {
|
||||
error("location does not end with the expected files: " + l);
|
||||
out.println("found: " + files);
|
||||
out.println("expect: " + expect);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
List<File> getLocation(StandardLocation l) {
|
||||
Iterable<? extends File> iter = fileManager.getLocation(l);
|
||||
if (iter == null)
|
||||
return null;
|
||||
List<File> files = new ArrayList<>();
|
||||
for (File f: iter)
|
||||
files.add(f);
|
||||
return files;
|
||||
}
|
||||
|
||||
void setLocation(StandardLocation l, File... files) throws IOException {
|
||||
fileManager.setLocation(l, Arrays.asList(files));
|
||||
}
|
||||
|
||||
void setLocation(StandardLocation l, List<File> files) throws IOException {
|
||||
fileManager.setLocation(l, files);
|
||||
}
|
||||
|
||||
void writeFile(File dir, String path, String body) throws IOException {
|
||||
try (FileWriter w = new FileWriter(new File(dir, path))) {
|
||||
w.write(body);
|
||||
}
|
||||
}
|
||||
|
||||
void writeJar(File jar, File dir, String... entries) throws IOException {
|
||||
try (JarOutputStream j = new JarOutputStream(Files.newOutputStream(jar.toPath()))) {
|
||||
for (String entry: entries) {
|
||||
j.putNextEntry(new JarEntry(entry));
|
||||
j.write(Files.readAllBytes(dir.toPath().resolve(entry)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern packagePattern
|
||||
= Pattern.compile("package\\s+(((?:\\w+\\.)*)(?:\\w+))");
|
||||
private static final Pattern classPattern
|
||||
= Pattern.compile("(?:public\\s+)?(?:class|enum|interface)\\s+(\\w+)");
|
||||
|
||||
|
||||
private static URI getURIFromSource(String source) {
|
||||
String packageName = null;
|
||||
|
||||
Matcher matcher = packagePattern.matcher(source);
|
||||
if (matcher.find()) {
|
||||
packageName = matcher.group(1).replace(".", "/");
|
||||
}
|
||||
|
||||
matcher = classPattern.matcher(source);
|
||||
if (matcher.find()) {
|
||||
String className = matcher.group(1);
|
||||
String path = ((packageName == null) ? "" : packageName + "/") + className + ".java";
|
||||
return URI.create("myfo:///" + path);
|
||||
} else {
|
||||
throw new Error("Could not extract the java class "
|
||||
+ "name from the provided source");
|
||||
}
|
||||
}
|
||||
|
||||
File createDir(String path) {
|
||||
File dir = new File(path);
|
||||
dir.mkdirs();
|
||||
return dir;
|
||||
}
|
||||
|
||||
JavaCompiler compiler;
|
||||
StandardJavaFileManager fileManager;
|
||||
|
||||
/**
|
||||
* Map for recording which standard locations have been tested.
|
||||
*/
|
||||
EnumSet<StandardLocation> tested = EnumSet.noneOf(StandardLocation.class);
|
||||
|
||||
/**
|
||||
* Logging stream. Used directly with test and for getTask calls.
|
||||
*/
|
||||
final PrintWriter out = new PrintWriter(System.err, true);
|
||||
|
||||
/**
|
||||
* Count of errors so far.
|
||||
*/
|
||||
int errors;
|
||||
|
||||
void error(String message) {
|
||||
errors++;
|
||||
out.println("Error: " + message);
|
||||
}
|
||||
}
|
148
langtools/test/tools/javac/api/taskListeners/CompileEvent.java
Normal file
148
langtools/test/tools/javac/api/taskListeners/CompileEvent.java
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8033414
|
||||
* @summary Verify that the TaskEvent.COMPILATION is fired properly.
|
||||
* @run main CompileEvent
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.tools.*;
|
||||
|
||||
import com.sun.source.util.*;
|
||||
import com.sun.tools.javac.Main;
|
||||
import com.sun.tools.javac.api.BasicJavacTask;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.Log;
|
||||
import com.sun.tools.javac.util.Log.WriterKind;
|
||||
|
||||
public class CompileEvent {
|
||||
|
||||
public static void main(String... args) throws IOException {
|
||||
new CompileEvent().run();
|
||||
}
|
||||
|
||||
void run() throws IOException {
|
||||
String testClasses = System.getProperty("test.classes");
|
||||
File pluginRegistration =
|
||||
new File(testClasses + "/META-INF/services/com.sun.source.util.Plugin");
|
||||
pluginRegistration.getParentFile().mkdirs();
|
||||
try (Writer metaInfRegistration = new FileWriter(pluginRegistration)) {
|
||||
metaInfRegistration.write("CompileEvent$PluginImpl");
|
||||
}
|
||||
File test = new File(testClasses + "/Test.java");
|
||||
test.getParentFile().mkdirs();
|
||||
try (Writer testFileWriter = new FileWriter(test)) {
|
||||
testFileWriter.write("public class Test { }");
|
||||
}
|
||||
|
||||
StringWriter out;
|
||||
|
||||
//test events fired to listeners registered from plugins
|
||||
//when starting compiler using Main.compile
|
||||
out = new StringWriter();
|
||||
int mainResult = Main.compile(new String[] {
|
||||
"-Xplugin:compile-event", "-processorpath", testClasses, test.getAbsolutePath()
|
||||
}, new PrintWriter(out, true));
|
||||
if (mainResult != 0)
|
||||
throw new AssertionError("Compilation failed unexpectedly, exit code: " + mainResult);
|
||||
assertOutput(out);
|
||||
|
||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||
Iterable<? extends JavaFileObject> testFileObjects = fm.getJavaFileObjects(test);
|
||||
|
||||
//test events fired to listeners registered from plugins
|
||||
//when starting compiler using JavaCompiler.getTak(...).call
|
||||
List<String> options =
|
||||
Arrays.asList("-Xplugin:compile-event", "-processorpath", testClasses);
|
||||
out = new StringWriter();
|
||||
boolean compResult = comp.getTask(out, null, null, options, null, testFileObjects).call();
|
||||
if (!compResult)
|
||||
throw new AssertionError("Compilation failed unexpectedly.");
|
||||
assertOutput(out);
|
||||
}
|
||||
|
||||
void assertOutput(StringWriter out) {
|
||||
String lineSeparator = System.getProperty("line.separator");
|
||||
if (!out.toString().trim().replace(lineSeparator, "\n").equals(EXPECTED)) {
|
||||
throw new AssertionError("Unexpected events: " + out.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static final String EXPECTED =
|
||||
"started(COMPILATION)\n" +
|
||||
"started(PARSE:Test.java)\n" +
|
||||
"finished(PARSE:Test.java)\n" +
|
||||
"started(ENTER:Test.java)\n" +
|
||||
"finished(ENTER:Test.java)\n" +
|
||||
"started(ANALYZE:Test.java:Test)\n" +
|
||||
"finished(ANALYZE:Test.java:Test)\n" +
|
||||
"started(GENERATE:Test.java:Test)\n" +
|
||||
"finished(GENERATE:Test.java:Test)\n" +
|
||||
"finished(COMPILATION)";
|
||||
|
||||
private static class TaskListenerImpl implements TaskListener {
|
||||
private final PrintWriter out;
|
||||
public TaskListenerImpl(PrintWriter out) {
|
||||
this.out = out;
|
||||
}
|
||||
@Override public void started(TaskEvent e) {
|
||||
dumpTaskEvent("started", e);
|
||||
}
|
||||
@Override public void finished(TaskEvent e) {
|
||||
dumpTaskEvent("finished", e);
|
||||
}
|
||||
private void dumpTaskEvent(String type, TaskEvent e) {
|
||||
StringBuilder data = new StringBuilder();
|
||||
data.append(type);
|
||||
data.append("(");
|
||||
data.append(e.getKind());
|
||||
if (e.getSourceFile() != null) {
|
||||
data.append(":");
|
||||
data.append(new File(e.getSourceFile().getName()).getName());
|
||||
}
|
||||
if (e.getTypeElement()!= null) {
|
||||
data.append(":");
|
||||
data.append(e.getTypeElement().getQualifiedName());
|
||||
}
|
||||
data.append(")");
|
||||
out.println(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class PluginImpl implements Plugin {
|
||||
@Override public String getName() {
|
||||
return "compile-event";
|
||||
}
|
||||
@Override public void init(JavacTask task, String... args) {
|
||||
Context context = ((BasicJavacTask) task).getContext();
|
||||
Log log = Log.instance(context);
|
||||
task.addTaskListener(new TaskListenerImpl(log.getWriter(WriterKind.NOTICE)));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -287,10 +287,16 @@ public class TestSimpleAddRemove {
|
||||
found = "{}";
|
||||
break;
|
||||
case REMOVE_IN_PROCESSOR:
|
||||
found = "{PARSE=1:1, ENTER=2:2, ANNOTATION_PROCESSING=1:0, ANNOTATION_PROCESSING_ROUND=2:1}";
|
||||
if (ck == CompileKind.CALL)
|
||||
found = "{PARSE=1:1, ENTER=2:2, ANNOTATION_PROCESSING=1:0, ANNOTATION_PROCESSING_ROUND=2:1, COMPILATION=1:0}";
|
||||
else
|
||||
found = "{PARSE=1:1, ENTER=2:2, ANNOTATION_PROCESSING=1:0, ANNOTATION_PROCESSING_ROUND=2:1}";
|
||||
break;
|
||||
case REMOVE_IN_LISTENER:
|
||||
found = "{PARSE=1:1, ENTER=3:3, ANALYZE=1:1, GENERATE=1:0, ANNOTATION_PROCESSING=1:1, ANNOTATION_PROCESSING_ROUND=2:2}";
|
||||
if (ck == CompileKind.CALL)
|
||||
found = "{PARSE=1:1, ENTER=3:3, ANALYZE=1:1, GENERATE=1:0, ANNOTATION_PROCESSING=1:1, ANNOTATION_PROCESSING_ROUND=2:2, COMPILATION=1:0}";
|
||||
else
|
||||
found = "{PARSE=1:1, ENTER=3:3, ANALYZE=1:1, GENERATE=1:0, ANNOTATION_PROCESSING=1:1, ANNOTATION_PROCESSING_ROUND=2:2}";
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
@ -302,7 +308,10 @@ public class TestSimpleAddRemove {
|
||||
switch (rk) {
|
||||
// Remove will fail (too early), so events to end will be recorded
|
||||
case REMOVE_IN_TASK:
|
||||
found = "{ENTER=2:2, ANALYZE=1:1, GENERATE=1:1, ANNOTATION_PROCESSING=0:1, ANNOTATION_PROCESSING_ROUND=1:2}";
|
||||
if (ck == CompileKind.CALL)
|
||||
found = "{ENTER=2:2, ANALYZE=1:1, GENERATE=1:1, ANNOTATION_PROCESSING=0:1, ANNOTATION_PROCESSING_ROUND=1:2, COMPILATION=0:1}";
|
||||
else
|
||||
found = "{ENTER=2:2, ANALYZE=1:1, GENERATE=1:1, ANNOTATION_PROCESSING=0:1, ANNOTATION_PROCESSING_ROUND=1:2}";
|
||||
break;
|
||||
case REMOVE_IN_PROCESSOR:
|
||||
found = "{ENTER=1:1, ANNOTATION_PROCESSING_ROUND=1:1}";
|
||||
@ -321,7 +330,10 @@ public class TestSimpleAddRemove {
|
||||
// Remove will fail (too early, so events to end will be recorded
|
||||
case REMOVE_IN_TASK:
|
||||
case REMOVE_IN_PROCESSOR:
|
||||
found = "{ANALYZE=0:1, GENERATE=1:1}";
|
||||
if (ck == CompileKind.CALL)
|
||||
found = "{ANALYZE=0:1, GENERATE=1:1, COMPILATION=0:1}";
|
||||
else
|
||||
found = "{ANALYZE=0:1, GENERATE=1:1}";
|
||||
break;
|
||||
// Remove will succeed during "GENERATE.finished" event
|
||||
case REMOVE_IN_LISTENER:
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user