--- a/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.
- */
-
-package com.sun.source.tree;
-
-import java.util.List;
-
-/**
- * A tree node for an annotated type
- *
- * For example:
- * <pre>
- * {@code @}<em>annotationType String</em>
- * {@code @}<em>annotationType</em> ( <em>arguments</em> ) <em>Date</em>
- * </pre>
- *
- * @see "JSR 308: Annotations on Java Types"
- *
- * @author Mahmood Ali
- * @since 1.7
- */
-public interface AnnotatedTypeTree extends ExpressionTree {
- List<? extends AnnotationTree> getAnnotations();
- ExpressionTree getUnderlyingType();
-}
--- a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java Tue Oct 19 15:02:48 2010 -0700
@@ -53,7 +53,7 @@
Tree getReturnType();
List<? extends TypeParameterTree> getTypeParameters();
List<? extends VariableTree> getParameters();
- List<? extends AnnotationTree> getReceiverAnnotations();
+//308 List<? extends AnnotationTree> getReceiverAnnotations();
List<? extends ExpressionTree> getThrows();
BlockTree getBody();
Tree getDefaultValue(); // for annotation types
--- a/langtools/src/share/classes/com/sun/source/tree/Tree.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java Tue Oct 19 15:02:48 2010 -0700
@@ -46,7 +46,7 @@
*/
public enum Kind {
- ANNOTATED_TYPE(AnnotatedTypeTree.class),
+//308 ANNOTATED_TYPE(AnnotatedTypeTree.class),
/**
* Used for instances of {@link AnnotationTree}.
--- a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java Tue Oct 19 15:02:48 2010 -0700
@@ -57,7 +57,7 @@
* @since 1.6
*/
public interface TreeVisitor<R,P> {
- R visitAnnotatedType(AnnotatedTypeTree node, P p);
+//308 R visitAnnotatedType(AnnotatedTypeTree node, P p);
R visitAnnotation(AnnotationTree node, P p);
R visitMethodInvocation(MethodInvocationTree node, P p);
R visitAssert(AssertTree node, P p);
--- a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java Tue Oct 19 15:02:48 2010 -0700
@@ -47,5 +47,5 @@
public interface TypeParameterTree extends Tree {
Name getName();
List<? extends Tree> getBounds();
- List<? extends AnnotationTree> getAnnotations();
+//308 List<? extends AnnotationTree> getAnnotations();
}
--- a/langtools/src/share/classes/com/sun/source/util/AbstractTypeProcessor.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,245 +0,0 @@
-/*
- * Copyright (c) 2009, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.
- */
-
-package com.sun.source.util;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.processing.*;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.ElementFilter;
-
-import com.sun.tools.javac.processing.JavacProcessingEnvironment;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.Log;
-
-import com.sun.source.tree.ClassTree;
-
-/**
- * This class is an abstract annotation processor designed to be a
- * convenient superclass for concrete "type processors", processors that
- * require the type information in the processed source.
- *
- * <p>Type processing occurs in one round after the tool (e.g. java compiler)
- * analyzes the source (all sources taken as input to the tool and sources
- * generated by other annotation processors).
- *
- * <p>The tool infrastructure will interact with classes extending this abstract
- * class as follows:
- *
- * <ol>
- * [1-3: Identical to {@link Processor} life cycle]
- *
- * <li>If an existing {@code Processor} object is not being used, to
- * create an instance of a processor the tool calls the no-arg
- * constructor of the processor class.
- *
- * <li>Next, the tool calls the {@link #init init} method with
- * an appropriate {@code ProcessingEnvironment}.
- *
- * <li>Afterwards, the tool calls {@link #getSupportedAnnotationTypes
- * getSupportedAnnotationTypes}, {@link #getSupportedOptions
- * getSupportedOptions}, and {@link #getSupportedSourceVersion
- * getSupportedSourceVersion}. These methods are only called once per
- * run, not on each round.
- *
- * [4-5Unique to {@code AbstractTypeProcessor} subclasses]
- *
- * <li>For each class containing a supported annotation, the tool calls
- * {@link #typeProcess(TypeElement, TreePath) typeProcess} method on the
- * {@code Processor}. The class is guaranteed to be type-checked Java code
- * and all the tree type and symbol information is resolved.
- *
- * <li>Finally, the tools calls the
- * {@link #typeProcessingOver() typeProcessingOver} method
- * on the {@code Processor}.
- *
- * </ol>
- *
- * <p>The tool is permitted to ask type processors to process a class once
- * it is analyzed before the rest of classes are analyzed. The tool is also
- * permitted to stop type processing immediately if any errors are raised,
- * without invoking {@code typeProcessingOver}
- *
- * <p>A subclass may override any of the methods in this class, as long as the
- * general {@link javax.annotation.processing.Processor Processor}
- * contract is obeyed, with one notable exception.
- * {@link #process(Set, RoundEnvironment)} may not be overridden, as it
- * is called during the regular annotation phase before classes are analyzed.
- *
- * @author Mahmood Ali
- * @since 1.7
- */
-public abstract class AbstractTypeProcessor extends AbstractProcessor {
- private final Set<Name> elements = new HashSet<Name>();
- private boolean hasInvokedTypeProcessingOver = false;
- private JavacProcessingEnvironment env;
- private final AttributionTaskListener listener = new AttributionTaskListener();
-
- /**
- * Constructor for subclasses to call.
- */
- protected AbstractTypeProcessor() { }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void init(ProcessingEnvironment env) {
- super.init(env);
- this.env = (JavacProcessingEnvironment)env;
- prepareContext(this.env.getContext());
- }
-
- /**
- * The use of this method is obsolete in type processors. The method is
- * called during regular annotation processing phase only.
- */
- @Override
- public final boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
- for (TypeElement elem : ElementFilter.typesIn(roundEnv.getRootElements())) {
- elements.add(elem.getQualifiedName());
- }
- return false;
- }
-
- /**
- * Processes a fully analyzed class that contains a supported annotation
- * (look {@link #getSupportedAnnotationTypes()}).
- *
- * <p>The passed class is always a valid type-checked Java code.
- *
- * @param element element of the analyzed class
- * @param tree the tree path to the element, with the leaf being a
- * {@link ClassTree}
- */
- public abstract void typeProcess(TypeElement element, TreePath tree);
-
- /**
- * A method to be called once all the classes are processed and no error
- * is reported.
- *
- * <p>Subclasses may override this method to do any aggregate analysis
- * (e.g. generate report, persistence) or resource deallocation.
- *
- * <p>If an error (a Java error or a processor error) is reported, this
- * method is not guaranteed to be invoked.
- */
- public void typeProcessingOver() { }
-
- /**
- * adds a listener for attribution.
- */
- private void prepareContext(Context context) {
- TaskListener otherListener = context.get(TaskListener.class);
- if (otherListener == null) {
- context.put(TaskListener.class, listener);
- } else {
- // handle cases of multiple listeners
- context.put(TaskListener.class, (TaskListener)null);
- TaskListeners listeners = new TaskListeners();
- listeners.add(otherListener);
- listeners.add(listener);
- context.put(TaskListener.class, listeners);
- }
- }
-
- /**
- * A task listener that invokes the processor whenever a class is fully
- * analyzed.
- */
- private final class AttributionTaskListener implements TaskListener {
-
- @Override
- public void finished(TaskEvent e) {
- Log log = Log.instance(env.getContext());
-
- if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) {
- typeProcessingOver();
- hasInvokedTypeProcessingOver = true;
- }
-
- if (e.getKind() != TaskEvent.Kind.ANALYZE)
- return;
-
- if (e.getTypeElement() == null)
- throw new AssertionError("event task without a type element");
- if (e.getCompilationUnit() == null)
- throw new AssertionError("even task without compilation unit");
-
- if (!elements.remove(e.getTypeElement().getQualifiedName()))
- return;
-
- if (log.nerrors != 0)
- return;
-
- TypeElement elem = e.getTypeElement();
- TreePath p = Trees.instance(env).getPath(elem);
-
- typeProcess(elem, p);
-
- if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) {
- typeProcessingOver();
- hasInvokedTypeProcessingOver = true;
- }
- }
-
- @Override
- public void started(TaskEvent e) { }
-
- }
-
- /**
- * A task listener multiplexer.
- */
- private static class TaskListeners implements TaskListener {
- private final List<TaskListener> listeners = new ArrayList<TaskListener>();
-
- public void add(TaskListener listener) {
- listeners.add(listener);
- }
-
- public void remove(TaskListener listener) {
- listeners.remove(listener);
- }
-
- @Override
- public void finished(TaskEvent e) {
- for (TaskListener listener : listeners)
- listener.finished(e);
- }
-
- @Override
- public void started(TaskEvent e) {
- for (TaskListener listener : listeners)
- listener.started(e);
- }
- }
-}
--- a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Tue Oct 19 15:02:48 2010 -0700
@@ -248,9 +248,9 @@
return defaultAction(node, p);
}
- public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
- return defaultAction(node, p);
- }
+//308 public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
+//308 return defaultAction(node, p);
+//308 }
public R visitErroneous(ErroneousTree node, P p) {
return defaultAction(node, p);
--- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java Tue Oct 19 15:02:48 2010 -0700
@@ -138,7 +138,7 @@
r = scanAndReduce(node.getReturnType(), p, r);
r = scanAndReduce(node.getTypeParameters(), p, r);
r = scanAndReduce(node.getParameters(), p, r);
- r = scanAndReduce(node.getReceiverAnnotations(), p, r);
+//308 r = scanAndReduce(node.getReceiverAnnotations(), p, r);
r = scanAndReduce(node.getThrows(), p, r);
r = scanAndReduce(node.getBody(), p, r);
r = scanAndReduce(node.getDefaultValue(), p, r);
@@ -361,8 +361,8 @@
}
public R visitTypeParameter(TypeParameterTree node, P p) {
- R r = scan(node.getAnnotations(), p);
- r = scanAndReduce(node.getBounds(), p, r);
+ R r = scan(node.getBounds(), p);
+//308 R r = scanAndReduce(node.getAnnotations(), p, r);
return r;
}
@@ -380,11 +380,11 @@
return r;
}
- public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
- R r = scan(node.getAnnotations(), p);
- r = scanAndReduce(node.getUnderlyingType(), p, r);
- return r;
- }
+//308 public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
+//308 R r = scan(node.getAnnotations(), p);
+//308 r = scanAndReduce(node.getUnderlyingType(), p, r);
+//308 return r;
+//308 }
public R visitOther(Tree node, P p) {
return null;
--- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Oct 19 15:02:48 2010 -0700
@@ -55,8 +55,8 @@
}
public void taFillAndLift(JCClassDecl tree, boolean visitBodies) {
- new TypeAnnotationPositions().scan(tree);
- new TypeAnnotationLift().scan(tree);
+//308 new TypeAnnotationPositions().scan(tree);
+//308 new TypeAnnotationLift().scan(tree);
}
private static class TypeAnnotationPositions extends TreeScanner {
@@ -208,11 +208,11 @@
}
return p;
- case ANNOTATED_TYPE: {
- List<JCTree> newPath = path.tail;
- return resolveFrame(newPath.head, newPath.tail.head,
- newPath, p);
- }
+//308 case ANNOTATED_TYPE: {
+//308 List<JCTree> newPath = path.tail;
+//308 return resolveFrame(newPath.head, newPath.tail.head,
+//308 newPath, p);
+//308 }
case METHOD_INVOCATION: {
JCMethodInvocation invocation = (JCMethodInvocation)frame;
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Oct 19 15:02:48 2010 -0700
@@ -75,42 +75,6 @@
/** The name table. */
private Names names;
- // Because of javac's limited lookahead, some contexts are ambiguous in
- // the presence of type annotations even though they are not ambiguous
- // in the absence of type annotations. Consider this code:
- // void m(String [] m) { }
- // void m(String ... m) { }
- // After parsing "String", javac calls bracketsOpt which immediately
- // returns if the next character is not '['. Similarly, javac can see
- // if the next token is ... and in that case parse an ellipsis. But in
- // the presence of type annotations:
- // void m(String @A [] m) { }
- // void m(String @A ... m) { }
- // no finite lookahead is enough to determine whether to read array
- // levels or an ellipsis. Furthermore, if you call bracketsOpt, then
- // bracketsOpt first reads all the leading annotations and only then
- // discovers that it needs to fail. bracketsOpt needs a way to push
- // back the extra annotations that it read. (But, bracketsOpt should
- // not *always* be allowed to push back extra annotations that it finds
- // -- in most contexts, any such extra annotation is an error.
- // Another similar case occurs with arrays and receiver annotations:
- // String b() @Array [] @Receiver { }
- // String b() @Receiver { }
- //
- // The following two variables permit type annotations that have
- // already been read to be stored for later use. Alternate
- // implementations are possible but would cause much larger changes to
- // the parser.
- /** Type annotations that have already been read but have not yet been used. **/
- private List<JCTypeAnnotation> typeAnnotationsPushedBack = null;
- /**
- * If the parser notices extra annotations, then it either immediately
- * issues an error (if this variable is false) or places the extra
- * annotations in variable typeAnnotationsPushedBack (if this variable
- * is true).
- */
- private boolean permitTypeAnnotationsPushBack = false;
-
/** Construct a parser from a given scanner, tree factory and log.
*/
protected JavacParser(ParserFactory fac,
@@ -134,19 +98,13 @@
this.allowTWR = source.allowTryWithResources();
this.allowDiamond = source.allowDiamond();
this.allowMulticatch = source.allowMulticatch();
- this.allowTypeAnnotations = source.allowTypeAnnotations();
this.keepDocComments = keepDocComments;
if (keepDocComments)
docComments = new HashMap<JCTree,String>();
this.keepLineMap = keepLineMap;
this.errorTree = F.Erroneous();
- this.debugJSR308 = fac.options.get("TA:parser") != null;
}
- /** Switch: debug output for type-annotations operations
- */
- boolean debugJSR308;
-
/** Switch: Should generics be recognized?
*/
boolean allowGenerics;
@@ -183,10 +141,6 @@
*/
boolean allowAnnotations;
- /** Switch: should we recognize type annotations?
- */
- boolean allowTypeAnnotations;
-
/** Switch: should we recognize automatic resource management?
*/
boolean allowTWR;
@@ -620,33 +574,7 @@
return term(EXPR);
}
- /**
- * parses (optional) type annotations followed by a type. If the
- * annotations are present before the type and are not consumed during array
- * parsing, this method returns a {@link JCAnnotatedType} consisting of
- * these annotations and the underlying type. Otherwise, it returns the
- * underlying type.
- *
- * <p>
- *
- * Note that this method sets {@code mode} to {@code TYPE} first, before
- * parsing annotations.
- */
public JCExpression parseType() {
- List<JCTypeAnnotation> annotations = typeAnnotationsOpt();
- return parseType(annotations);
- }
-
- public JCExpression parseType(List<JCTypeAnnotation> annotations) {
- JCExpression result = unannotatedType();
-
- if (!annotations.isEmpty())
- result = F.AnnotatedType(annotations, result);
-
- return result;
- }
-
- public JCExpression unannotatedType() {
return term(TYPE);
}
@@ -895,8 +823,8 @@
* | [TypeArguments] THIS [Arguments]
* | [TypeArguments] SUPER SuperSuffix
* | NEW [TypeArguments] Creator
- * | [Annotations] Ident { "." Ident }
- * [ [Annotations] "[" ( "]" BracketsOpt "." CLASS | Expression "]" )
+ * | Ident { "." Ident }
+ * [ "[" ( "]" BracketsOpt "." CLASS | Expression "]" )
* | Arguments
* | "." ( CLASS | THIS | [TypeArguments] SUPER Arguments | NEW [TypeArguments] InnerCreator )
* ]
@@ -1047,62 +975,23 @@
typeArgs = null;
} else return illegal();
break;
- case MONKEYS_AT:
-
- // only annotated targetting class literals or cast types are valid
- List<JCTypeAnnotation> typeAnnos = typeAnnotationsOpt();
- if (typeAnnos.isEmpty()) {
- // else there would be no '@'
- throw new AssertionError("type annos is empty");
- }
-
- JCExpression expr = term3();
-
- // Type annotations: If term3 just parsed a non-type, expect a
- // class literal (and issue a syntax error if there is no class
- // literal). Otherwise, create a JCAnnotatedType.
- if ((mode & TYPE) == 0) {
- if (expr.getTag() != JCTree.SELECT)
- return illegal(typeAnnos.head.pos);
- JCFieldAccess sel = (JCFieldAccess)expr;
- if (sel.name != names._class)
- return illegal();
- else {
- sel.selected = F.AnnotatedType(typeAnnos, sel.selected);
- t = expr;
- }
- } else {
- // type annotation targeting a cast
- t = toP(F.at(S.pos()).AnnotatedType(typeAnnos, expr));
- }
- break;
case IDENTIFIER: case ASSERT: case ENUM:
if (typeArgs != null) return illegal();
t = toP(F.at(S.pos()).Ident(ident()));
loop: while (true) {
pos = S.pos();
- final List<JCTypeAnnotation> annos = typeAnnotationsOpt();
-
- // need to report an error later if LBRACKET is for array
- // index access rather than array creation level
- if (!annos.isEmpty() && S.token() != LBRACKET && S.token() != ELLIPSIS)
- return illegal(annos.head.pos);
switch (S.token()) {
case LBRACKET:
S.nextToken();
-
if (S.token() == RBRACKET) {
-
S.nextToken();
-
- t = bracketsOpt(t, annos);
+ t = bracketsOpt(t);
t = toP(F.at(pos).TypeArray(t));
t = bracketsSuffix(t);
} else {
if ((mode & EXPR) != 0) {
mode = EXPR;
JCExpression t1 = term();
- if (!annos.isEmpty()) t = illegal(annos.head.pos);
t = to(F.at(pos).Indexed(t, t1));
}
accept(RBRACKET);
@@ -1155,14 +1044,6 @@
// typeArgs saved for next loop iteration.
t = toP(F.at(pos).Select(t, ident()));
break;
- case ELLIPSIS:
- if (this.permitTypeAnnotationsPushBack) {
- this.typeAnnotationsPushedBack = annos;
- } else if (annos.nonEmpty()) {
- // Don't return here -- error recovery attempt
- illegal(annos.head.pos);
- }
- break loop;
default:
break loop;
}
@@ -1201,18 +1082,14 @@
if (typeArgs != null) illegal();
while (true) {
int pos1 = S.pos();
-
- final List<JCTypeAnnotation> annos = typeAnnotationsOpt();
-
if (S.token() == LBRACKET) {
S.nextToken();
-
if ((mode & TYPE) != 0) {
int oldmode = mode;
mode = TYPE;
if (S.token() == RBRACKET) {
S.nextToken();
- t = bracketsOpt(t, annos);
+ t = bracketsOpt(t);
t = toP(F.at(pos1).TypeArray(t));
return t;
}
@@ -1247,12 +1124,6 @@
typeArgs = null;
}
} else {
- if (!annos.isEmpty()) {
- if (permitTypeAnnotationsPushBack)
- typeAnnotationsPushedBack = annos;
- else
- return illegal(annos.head.pos);
- }
break;
}
}
@@ -1262,7 +1133,6 @@
S.token() == PLUSPLUS ? JCTree.POSTINC : JCTree.POSTDEC, t));
S.nextToken();
}
-
return toP(t);
}
@@ -1400,26 +1270,24 @@
}
/** TypeArgument = Type
- * | [Annotations] "?"
- * | [Annotations] "?" EXTENDS Type {"&" Type}
- * | [Annotations] "?" SUPER Type
+ * | "?"
+ * | "?" EXTENDS Type {"&" Type}
+ * | "?" SUPER Type
*/
JCExpression typeArgument() {
- List<JCTypeAnnotation> annotations = typeAnnotationsOpt();
- if (S.token() != QUES) return parseType(annotations);
+ if (S.token() != QUES) return parseType();
int pos = S.pos();
S.nextToken();
- JCExpression result;
if (S.token() == EXTENDS) {
TypeBoundKind t = to(F.at(pos).TypeBoundKind(BoundKind.EXTENDS));
S.nextToken();
JCExpression bound = parseType();
- result = F.at(pos).Wildcard(t, bound);
+ return F.at(pos).Wildcard(t, bound);
} else if (S.token() == SUPER) {
TypeBoundKind t = to(F.at(pos).TypeBoundKind(BoundKind.SUPER));
S.nextToken();
JCExpression bound = parseType();
- result = F.at(pos).Wildcard(t, bound);
+ return F.at(pos).Wildcard(t, bound);
} else if (S.token() == IDENTIFIER) {
//error recovery
reportSyntaxError(S.prevEndPos(), "expected3",
@@ -1427,14 +1295,11 @@
TypeBoundKind t = F.at(Position.NOPOS).TypeBoundKind(BoundKind.UNBOUND);
JCExpression wc = toP(F.at(pos).Wildcard(t, null));
JCIdent id = toP(F.at(S.pos()).Ident(ident()));
- result = F.at(pos).Erroneous(List.<JCTree>of(wc, id));
+ return F.at(pos).Erroneous(List.<JCTree>of(wc, id));
} else {
TypeBoundKind t = toP(F.at(pos).TypeBoundKind(BoundKind.UNBOUND));
- result = toP(F.at(pos).Wildcard(t, null));
+ return toP(F.at(pos).Wildcard(t, null));
}
- if (!annotations.isEmpty())
- result = toP(F.at(annotations.head.pos).AnnotatedType(annotations,result));
- return result;
}
JCTypeApply typeArguments(JCExpression t) {
@@ -1443,47 +1308,21 @@
return toP(F.at(pos).TypeApply(t, args));
}
- /**
- * BracketsOpt = { [Annotations] "[" "]" }
- *
- * <p>
- *
- * <code>annotations</code> is the list of annotations targeting
- * the expression <code>t</code>.
+ /** BracketsOpt = {"[" "]"}
*/
- private JCExpression bracketsOpt(JCExpression t,
- List<JCTypeAnnotation> annotations) {
- List<JCTypeAnnotation> nextLevelAnnotations = typeAnnotationsOpt();
-
+ private JCExpression bracketsOpt(JCExpression t) {
if (S.token() == LBRACKET) {
int pos = S.pos();
S.nextToken();
-
- JCExpression orig = t;
- t = bracketsOptCont(t, pos, nextLevelAnnotations);
- } else if (!nextLevelAnnotations.isEmpty()) {
- if (permitTypeAnnotationsPushBack) {
- this.typeAnnotationsPushedBack = nextLevelAnnotations;
- } else
- return illegal(nextLevelAnnotations.head.pos);
+ t = bracketsOptCont(t, pos);
+ F.at(pos);
}
-
- int apos = S.pos();
- if (!annotations.isEmpty())
- t = F.at(apos).AnnotatedType(annotations, t);
return t;
}
- /** BracketsOpt = {"[" TypeAnnotations "]"}
- */
- private JCExpression bracketsOpt(JCExpression t) {
- return bracketsOpt(t, List.<JCTypeAnnotation>nil());
- }
-
- private JCArrayTypeTree bracketsOptCont(JCExpression t, int pos,
- List<JCTypeAnnotation> annotations) {
+ private JCArrayTypeTree bracketsOptCont(JCExpression t, int pos) {
accept(RBRACKET);
- t = bracketsOpt(t, annotations);
+ t = bracketsOpt(t);
return toP(F.at(pos).TypeArray(t));
}
@@ -1517,29 +1356,18 @@
return t;
}
- /** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
+ /** Creator = Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
*/
JCExpression creator(int newpos, List<JCExpression> typeArgs) {
-
- List<JCTypeAnnotation> newAnnotations = typeAnnotationsOpt();
-
switch (S.token()) {
case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT:
case DOUBLE: case BOOLEAN:
- if (typeArgs == null) {
- if (newAnnotations.isEmpty())
- return arrayCreatorRest(newpos, basicType());
- else
- return arrayCreatorRest(newpos, F.AnnotatedType(newAnnotations, basicType()));
- }
+ if (typeArgs == null)
+ return arrayCreatorRest(newpos, basicType());
break;
default:
}
JCExpression t = qualident();
- // handle type annotations for non primitive arrays
- if (!newAnnotations.isEmpty())
- t = F.AnnotatedType(newAnnotations, t);
-
int oldmode = mode;
mode = TYPE | DIAMOND;
if (S.token() == LT) {
@@ -1556,7 +1384,7 @@
}
}
mode = oldmode;
- if (S.token() == LBRACKET || S.token() == MONKEYS_AT) {
+ if (S.token() == LBRACKET) {
JCExpression e = arrayCreatorRest(newpos, t);
if (typeArgs != null) {
int pos = newpos;
@@ -1572,15 +1400,7 @@
}
return e;
} else if (S.token() == LPAREN) {
- JCNewClass newClass = classCreatorRest(newpos, null, typeArgs, t);
- if (newClass.def != null) {
- assert newClass.def.mods.annotations.isEmpty();
- if (newAnnotations.nonEmpty()) {
- newClass.def.mods.pos = earlier(newClass.def.mods.pos, newAnnotations.head.pos);
- newClass.def.mods.annotations = List.convert(JCAnnotation.class, newAnnotations);
- }
- }
- return newClass;
+ return classCreatorRest(newpos, null, typeArgs, t);
} else {
reportSyntaxError(S.pos(), "expected2",
LPAREN, LBRACKET);
@@ -1603,67 +1423,34 @@
return classCreatorRest(newpos, encl, typeArgs, t);
}
- /** ArrayCreatorRest = [Annotations] "[" ( "]" BracketsOpt ArrayInitializer
- * | Expression "]" {[Annotations] "[" Expression "]"} BracketsOpt )
+ /** ArrayCreatorRest = "[" ( "]" BracketsOpt ArrayInitializer
+ * | Expression "]" {"[" Expression "]"} BracketsOpt )
*/
JCExpression arrayCreatorRest(int newpos, JCExpression elemtype) {
-
- List<JCTypeAnnotation> topAnnos = List.nil();
- if (elemtype.getTag() == JCTree.ANNOTATED_TYPE) {
- JCAnnotatedType atype = (JCAnnotatedType) elemtype;
- topAnnos = atype.annotations;
- elemtype = atype.underlyingType;
- }
-
- List<JCTypeAnnotation> annos = typeAnnotationsOpt();
-
accept(LBRACKET);
-
if (S.token() == RBRACKET) {
accept(RBRACKET);
-
- elemtype = bracketsOpt(elemtype, annos);
-
+ elemtype = bracketsOpt(elemtype);
if (S.token() == LBRACE) {
- JCNewArray na = (JCNewArray)arrayInitializer(newpos, elemtype);
-
- na.annotations = topAnnos;
-
- return na;
+ return arrayInitializer(newpos, elemtype);
} else {
return syntaxError(S.pos(), "array.dimension.missing");
}
} else {
ListBuffer<JCExpression> dims = new ListBuffer<JCExpression>();
-
- // maintain array dimension type annotations
- ListBuffer<List<JCTypeAnnotation>> dimAnnotations = ListBuffer.lb();
- dimAnnotations.append(annos);
-
dims.append(parseExpression());
accept(RBRACKET);
- while (S.token() == LBRACKET
- || (S.token() == MONKEYS_AT)) {
- List<JCTypeAnnotation> maybeDimAnnos = typeAnnotationsOpt();
+ while (S.token() == LBRACKET) {
int pos = S.pos();
S.nextToken();
if (S.token() == RBRACKET) {
- elemtype = bracketsOptCont(elemtype, pos, maybeDimAnnos);
+ elemtype = bracketsOptCont(elemtype, pos);
} else {
- if (S.token() == RBRACKET) { // no dimension
- elemtype = bracketsOptCont(elemtype, pos, maybeDimAnnos);
- } else {
- dimAnnotations.append(maybeDimAnnos);
- dims.append(parseExpression());
- accept(RBRACKET);
- }
+ dims.append(parseExpression());
+ accept(RBRACKET);
}
}
-
- JCNewArray na = toP(F.at(newpos).NewArray(elemtype, dims.toList(), null));
- na.annotations = topAnnos;
- na.dimAnnotations = dimAnnotations.toList();
- return na;
+ return toP(F.at(newpos).NewArray(elemtype, dims.toList(), null));
}
}
@@ -2142,32 +1929,17 @@
new ListBuffer<JCExpressionStatement>()).toList();
}
- enum AnnotationKind { DEFAULT_ANNO, TYPE_ANNO };
-
/** AnnotationsOpt = { '@' Annotation }
*/
- List<JCAnnotation> annotationsOpt(AnnotationKind kind) {
+ List<JCAnnotation> annotationsOpt() {
if (S.token() != MONKEYS_AT) return List.nil(); // optimization
ListBuffer<JCAnnotation> buf = new ListBuffer<JCAnnotation>();
- int prevmode = mode;
while (S.token() == MONKEYS_AT) {
int pos = S.pos();
S.nextToken();
- buf.append(annotation(pos, kind));
+ buf.append(annotation(pos));
}
- lastmode = mode;
- mode = prevmode;
- List<JCAnnotation> annotations = buf.toList();
-
- if (debugJSR308 && kind == AnnotationKind.TYPE_ANNO)
- System.out.println("TA: parsing " + annotations
- + " in " + log.currentSourceFile());
- return annotations;
- }
-
- List<JCTypeAnnotation> typeAnnotationsOpt() {
- List<JCAnnotation> annotations = annotationsOpt(AnnotationKind.TYPE_ANNO);
- return List.convert(JCTypeAnnotation.class, annotations);
+ return buf.toList();
}
/** ModifiersOpt = { Modifier }
@@ -2219,7 +1991,7 @@
if (flag == Flags.ANNOTATION) {
checkAnnotations();
if (S.token() != INTERFACE) {
- JCAnnotation ann = annotation(lastPos, AnnotationKind.DEFAULT_ANNO);
+ JCAnnotation ann = annotation(lastPos);
// if first modifier is an annotation, set pos to annotation's.
if (flags == 0 && annotations.isEmpty())
pos = ann.pos;
@@ -2250,18 +2022,12 @@
/** Annotation = "@" Qualident [ "(" AnnotationFieldValues ")" ]
* @param pos position of "@" token
*/
- JCAnnotation annotation(int pos, AnnotationKind kind) {
+ JCAnnotation annotation(int pos) {
// accept(AT); // AT consumed by caller
checkAnnotations();
- if (kind == AnnotationKind.TYPE_ANNO)
- checkTypeAnnotations();
JCTree ident = qualident();
List<JCExpression> fieldValues = annotationFieldValuesOpt();
- JCAnnotation ann;
- if (kind == AnnotationKind.DEFAULT_ANNO)
- ann = F.at(pos).Annotation(ident, fieldValues);
- else
- ann = F.at(pos).TypeAnnotation(ident, fieldValues);
+ JCAnnotation ann = F.at(pos).Annotation(ident, fieldValues);
storeEnd(ann, S.prevEndPos());
return ann;
}
@@ -2314,7 +2080,7 @@
case MONKEYS_AT:
pos = S.pos();
S.nextToken();
- return annotation(pos, AnnotationKind.DEFAULT_ANNO);
+ return annotation(pos);
case LBRACE:
pos = S.pos();
accept(LBRACE);
@@ -2705,7 +2471,7 @@
S.resetDeprecatedFlag();
}
int pos = S.pos();
- List<JCAnnotation> annotations = annotationsOpt(AnnotationKind.DEFAULT_ANNO);
+ List<JCAnnotation> annotations = annotationsOpt();
JCModifiers mods = F.at(annotations.isEmpty() ? Position.NOPOS : pos).Modifiers(flags, annotations);
List<JCExpression> typeArgs = typeArgumentsOpt();
int identPos = S.pos();
@@ -2802,25 +2568,15 @@
} else {
pos = S.pos();
List<JCTypeParameter> typarams = typeParametersOpt();
- List<JCAnnotation> annosAfterParams = annotationsOpt(AnnotationKind.DEFAULT_ANNO);
-
Name name = S.name();
pos = S.pos();
JCExpression type;
boolean isVoid = S.token() == VOID;
if (isVoid) {
- if (annosAfterParams.nonEmpty())
- illegal(annosAfterParams.head.pos);
type = to(F.at(pos).TypeIdent(TypeTags.VOID));
S.nextToken();
} else {
- if (annosAfterParams.nonEmpty()) {
- mods.annotations = mods.annotations.appendList(annosAfterParams);
- if (mods.pos == Position.NOPOS)
- mods.pos = mods.annotations.head.pos;
- }
- // method returns types are un-annotated types
- type = unannotatedType();
+ type = parseType();
}
if (S.token() == LPAREN && !isInterface && type.getTag() == JCTree.IDENT) {
if (isInterface || name != className)
@@ -2856,15 +2612,15 @@
}
/** MethodDeclaratorRest =
- * FormalParameters BracketsOpt [Annotations] [Throws TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";")
+ * FormalParameters BracketsOpt [Throws TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";")
* VoidMethodDeclaratorRest =
- * FormalParameters [Annotations] [Throws TypeList] ( MethodBody | ";")
+ * FormalParameters [Throws TypeList] ( MethodBody | ";")
* InterfaceMethodDeclaratorRest =
- * FormalParameters BracketsOpt [Annotations] [THROWS TypeList] ";"
+ * FormalParameters BracketsOpt [THROWS TypeList] ";"
* VoidInterfaceMethodDeclaratorRest =
- * FormalParameters [Annotations] [THROWS TypeList] ";"
+ * FormalParameters [THROWS TypeList] ";"
* ConstructorDeclaratorRest =
- * "(" FormalParameterListOpt ")" [Annotations] [THROWS TypeList] MethodBody
+ * "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody
*/
JCTree methodDeclaratorRest(int pos,
JCModifiers mods,
@@ -2874,22 +2630,7 @@
boolean isInterface, boolean isVoid,
String dc) {
List<JCVariableDecl> params = formalParameters();
-
- List<JCTypeAnnotation> receiverAnnotations;
- if (!isVoid) {
- // need to distinguish between receiver anno and array anno
- // look at typeAnnotationsPushedBack comment
- this.permitTypeAnnotationsPushBack = true;
- type = methodReturnArrayRest(type);
- this.permitTypeAnnotationsPushBack = false;
- if (typeAnnotationsPushedBack == null)
- receiverAnnotations = List.nil();
- else
- receiverAnnotations = typeAnnotationsPushedBack;
- typeAnnotationsPushedBack = null;
- } else
- receiverAnnotations = typeAnnotationsOpt();
-
+ if (!isVoid) type = bracketsOpt(type);
List<JCExpression> thrown = List.nil();
if (S.token() == THROWS) {
S.nextToken();
@@ -2919,51 +2660,20 @@
JCMethodDecl result =
toP(F.at(pos).MethodDef(mods, name, type, typarams,
- params, receiverAnnotations, thrown,
+ params, thrown,
body, defaultValue));
attach(result, dc);
return result;
}
- /** Parses the array levels after the format parameters list, and append
- * them to the return type, while preseving the order of type annotations
- */
- private JCExpression methodReturnArrayRest(JCExpression type) {
- if (type.getTag() != JCTree.TYPEARRAY)
- return bracketsOpt(type);
-
- JCArrayTypeTree baseArray = (JCArrayTypeTree)type;
- while (TreeInfo.typeIn(baseArray.elemtype) instanceof JCArrayTypeTree)
- baseArray = (JCArrayTypeTree)TreeInfo.typeIn(baseArray.elemtype);
-
- if (baseArray.elemtype.getTag() == JCTree.ANNOTATED_TYPE) {
- JCAnnotatedType at = (JCAnnotatedType)baseArray.elemtype;
- at.underlyingType = bracketsOpt(at.underlyingType);
- } else {
- baseArray.elemtype = bracketsOpt(baseArray.elemtype);
- }
-
- return type;
- }
-
- /** QualidentList = [Annotations] Qualident {"," [Annotations] Qualident}
+ /** QualidentList = Qualident {"," Qualident}
*/
List<JCExpression> qualidentList() {
ListBuffer<JCExpression> ts = new ListBuffer<JCExpression>();
-
- List<JCTypeAnnotation> typeAnnos = typeAnnotationsOpt();
- if (!typeAnnos.isEmpty())
- ts.append(F.AnnotatedType(typeAnnos, qualident()));
- else
- ts.append(qualident());
+ ts.append(qualident());
while (S.token() == COMMA) {
S.nextToken();
-
- typeAnnos = typeAnnotationsOpt();
- if (!typeAnnos.isEmpty())
- ts.append(F.AnnotatedType(typeAnnos, qualident()));
- else
- ts.append(qualident());
+ ts.append(qualident());
}
return ts.toList();
}
@@ -2987,13 +2697,12 @@
}
}
- /** TypeParameter = [Annotations] TypeVariable [TypeParameterBound]
+ /** TypeParameter = TypeVariable [TypeParameterBound]
* TypeParameterBound = EXTENDS Type {"&" Type}
* TypeVariable = Ident
*/
JCTypeParameter typeParameter() {
int pos = S.pos();
- List<JCTypeAnnotation> annos = typeAnnotationsOpt();
Name name = ident();
ListBuffer<JCExpression> bounds = new ListBuffer<JCExpression>();
if (S.token() == EXTENDS) {
@@ -3004,7 +2713,7 @@
bounds.append(parseType());
}
}
- return toP(F.at(pos).TypeParameter(name, bounds.toList(), annos));
+ return toP(F.at(pos).TypeParameter(name, bounds.toList()));
}
/** FormalParameters = "(" [ FormalParameterList ] ")"
@@ -3038,31 +2747,12 @@
*/
JCVariableDecl formalParameter() {
JCModifiers mods = optFinal(Flags.PARAMETER);
- // need to distinguish between vararg annos and array annos
- // look at typeAnnotaitonsPushedBack comment
- this.permitTypeAnnotationsPushBack = true;
JCExpression type = parseType();
- this.permitTypeAnnotationsPushBack = false;
-
if (S.token() == ELLIPSIS) {
- List<JCTypeAnnotation> varargsAnnos = typeAnnotationsPushedBack;
- typeAnnotationsPushedBack = null;
checkVarargs();
mods.flags |= Flags.VARARGS;
- // insert var arg type annotations
- if (varargsAnnos != null && varargsAnnos.nonEmpty())
- type = F.at(S.pos()).AnnotatedType(varargsAnnos, type);
type = to(F.at(S.pos()).TypeArray(type));
-
S.nextToken();
- } else {
- // if not a var arg, then typeAnnotationsPushedBack should be null
- if (typeAnnotationsPushedBack != null
- && !typeAnnotationsPushedBack.isEmpty()) {
- reportSyntaxError(typeAnnotationsPushedBack.head.pos,
- "illegal.start.of.type");
- }
- typeAnnotationsPushedBack = null;
}
return variableDeclaratorId(mods, type);
}
@@ -3259,12 +2949,6 @@
allowAnnotations = true;
}
}
- void checkTypeAnnotations() {
- if (!allowTypeAnnotations) {
- log.error(S.pos(), "type.annotations.not.supported.in.source", source.name);
- allowTypeAnnotations = true;
- }
- }
void checkDiamond() {
if (!allowDiamond) {
log.error(S.pos(), "diamond.not.supported.in.source", source.name);
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Oct 19 15:02:48 2010 -0700
@@ -49,11 +49,11 @@
import javax.tools.JavaFileObject;
import javax.tools.DiagnosticListener;
-import com.sun.tools.javac.api.JavacTrees;
-import com.sun.source.util.AbstractTypeProcessor;
+//308 import com.sun.source.util.AbstractTypeProcessor;
import com.sun.source.util.TaskEvent;
import com.sun.source.util.TaskListener;
import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.api.JavacTrees;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.file.JavacFileManager;
@@ -712,7 +712,7 @@
}
if (matchedNames.size() > 0 || ps.contributed) {
- foundTypeProcessors = foundTypeProcessors || (ps.processor instanceof AbstractTypeProcessor);
+//308 foundTypeProcessors = foundTypeProcessors || (ps.processor instanceof AbstractTypeProcessor);
boolean processingResult = callProcessor(ps.processor, typeElements, renv);
ps.contributed = true;
ps.removeSupportedOptions(unmatchedProcessorOptions);
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Oct 19 15:02:48 2010 -0700
@@ -1299,9 +1299,9 @@
annotations are not supported in -source {0}\n\
(use -source 5 or higher to enable annotations)
-compiler.err.type.annotations.not.supported.in.source=\
- type annotations are not supported in -source {0}\n\
-(use -source 7 or higher to enable type annotations)
+#308 compiler.err.type.annotations.not.supported.in.source=\
+#308 type annotations are not supported in -source {0}\n\
+#308 (use -source 7 or higher to enable type annotations)
compiler.err.foreach.not.supported.in.source=\
for-each loops are not supported in -source {0}\n\
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Tue Oct 19 15:02:48 2010 -0700
@@ -2067,17 +2067,23 @@
}
}
- public static class JCAnnotatedType extends JCExpression implements com.sun.source.tree.AnnotatedTypeTree {
+ public static class JCAnnotatedType extends JCExpression
+//308 implements com.sun.source.tree.AnnotatedTypeTree
+ {
public List<JCTypeAnnotation> annotations;
public JCExpression underlyingType;
protected JCAnnotatedType(List<JCTypeAnnotation> annotations, JCExpression underlyingType) {
- this.annotations = annotations;
- this.underlyingType = underlyingType;
+ throw new UnsupportedOperationException();
+//308 this.annotations = annotations;
+//308 this.underlyingType = underlyingType;
}
@Override
public void accept(Visitor v) { v.visitAnnotatedType(this); }
- public Kind getKind() { return Kind.ANNOTATED_TYPE; }
+ public Kind getKind() {
+ throw new UnsupportedOperationException();
+//308 return Kind.ANNOTATED_TYPE;
+ }
public List<JCTypeAnnotation> getAnnotations() {
return annotations;
}
@@ -2086,7 +2092,8 @@
}
@Override
public <R,D> R accept(TreeVisitor<R,D> v, D d) {
- return v.visitAnnotatedType(this, d);
+ throw new UnsupportedOperationException();
+//308 return v.visitAnnotatedType(this, d);
}
@Override
public int getTag() {
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Tue Oct 19 15:02:48 2010 -0700
@@ -71,12 +71,12 @@
return lb.toList();
}
- public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) {
- JCAnnotatedType t = (JCAnnotatedType) node;
- List<JCTypeAnnotation> annotations = copy(t.annotations, p);
- JCExpression underlyingType = copy(t.underlyingType, p);
- return M.at(t.pos).AnnotatedType(annotations, underlyingType);
- }
+//308 public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) {
+//308 JCAnnotatedType t = (JCAnnotatedType) node;
+//308 List<JCTypeAnnotation> annotations = copy(t.annotations, p);
+//308 JCExpression underlyingType = copy(t.underlyingType, p);
+//308 return M.at(t.pos).AnnotatedType(annotations, underlyingType);
+//308 }
public JCTree visitAnnotation(AnnotationTree node, P p) {
JCAnnotation t = (JCAnnotation) node;
--- a/langtools/test/tools/javac/T6985181.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2010, 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 6985181
- * @summary Annotations lost from classfile
- */
-
-import java.io.*;
-import java.util.*;
-
-public class T6985181 {
- public static void main(String... args) throws Exception{
- new T6985181().run();
- }
-
- public void run() throws Exception {
- String code = "@interface Simple { }\ninterface Test<@Simple T> { }";
-
- File srcFile = writeFile("Test.java", code);
- File classesDir = new File("classes");
- classesDir.mkdirs();
- compile("-d", classesDir.getPath(), srcFile.getPath());
- String out = javap(new File(classesDir, srcFile.getName().replace(".java", ".class")));
- if (!out.contains("RuntimeInvisibleTypeAnnotations"))
- throw new Exception("RuntimeInvisibleTypeAnnotations not found");
- }
-
- void compile(String... args) throws Exception {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- int rc = com.sun.tools.javac.Main.compile(args, pw);
- pw.close();
- String out = sw.toString();
- if (out.length() > 0)
- System.err.println(out);
- if (rc != 0)
- throw new Exception("Compilation failed: rc=" + rc);
- }
-
- String javap(File classFile) throws Exception {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String[] args = { "-v", classFile.getPath() };
- int rc = com.sun.tools.javap.Main.run(args, pw);
- pw.close();
- String out = sw.toString();
- if (out.length() > 0)
- System.err.println(out);
- if (rc != 0)
- throw new Exception("javap failed: rc=" + rc);
- return out;
- }
-
- File writeFile(String path, String body) throws IOException {
- File f = new File(path);
- FileWriter out = new FileWriter(f);
- try {
- out.write(body);
- } finally {
- out.close();
- }
- return f;
- }
-}
--- a/langtools/test/tools/javac/annotations/6881115/T6881115.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/test/tools/javac/annotations/6881115/T6881115.java Tue Oct 19 15:02:48 2010 -0700
@@ -16,5 +16,5 @@
}
@A(b = @B(b2 = 1, b2 = 2),
b_arr = {@B(), @B(b2 = 1, b2 = 2)})
-class T6881115<@A(b = @B(b2 = 1, b2 = 2),
- b_arr = {@B(), @B(b2 = 1, b2 = 2)}) X> {}
+class T6881115</*308 @A(b = @B(b2 = 1, b2 = 2),
+ b_arr = {@B(), @B(b2 = 1, b2 = 2)})*/ X> {}
--- a/langtools/test/tools/javac/annotations/6881115/T6881115.out Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/test/tools/javac/annotations/6881115/T6881115.out Tue Oct 19 15:02:48 2010 -0700
@@ -8,9 +8,4 @@
T6881115.java:18:13: compiler.err.annotation.missing.default.value.1: B, b1,b2
T6881115.java:18:30: compiler.err.duplicate.annotation.member.value: b2, B
T6881115.java:18:19: compiler.err.annotation.missing.default.value: B, b1
-T6881115.java:19:34: compiler.err.duplicate.annotation.member.value: b2, B
-T6881115.java:19:23: compiler.err.annotation.missing.default.value: B, b1
-T6881115.java:20:28: compiler.err.annotation.missing.default.value.1: B, b1,b2
-T6881115.java:20:45: compiler.err.duplicate.annotation.member.value: b2, B
-T6881115.java:20:34: compiler.err.annotation.missing.default.value: B, b1
-15 errors
+10 errors
--- a/langtools/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2010, 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.
- */
-
-// key: compiler.err.type.annotations.not.supported.in.source
-// options: -source 6
-
-@interface Anno { }
-
-class TypeAnnotationsNotSupported {
- void m() {
- int i = (@Anno int) 3.14;
- }
-}
--- a/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java Tue Oct 19 15:02:48 2010 -0700
@@ -78,7 +78,7 @@
@Nesting(LOCAL)
class LocalClass{};
- Object o = new @Nesting(ANONYMOUS) Object() { // An anonymous annotated class
+ Object o = new /*@Nesting(ANONYMOUS)*/ Object() { // An anonymous annotated class
public String toString() {
return "I have no name!";
}
@@ -95,9 +95,10 @@
for(Class<?> clazz : classes) {
String name = clazz.getName();
+ Nesting anno = clazz.getAnnotation(Nesting.class);
System.out.format("%s is %s%n",
clazz.getName(),
- clazz.getAnnotation(Nesting.class).value());
+ anno == null ? "(unset/ANONYMOUS)" : anno.value());
testClassName(name);
}
}
@@ -161,8 +162,8 @@
typeElt.getQualifiedName().toString(),
typeElt.getKind().toString(),
nestingKind.toString());
-
- if (typeElt.getAnnotation(Nesting.class).value() != nestingKind) {
+ Nesting anno = typeElt.getAnnotation(Nesting.class);
+ if ((anno == null ? NestingKind.ANONYMOUS : anno.value()) != nestingKind) {
throw new RuntimeException("Mismatch of expected and reported nesting kind.");
}
}
--- a/langtools/test/tools/javac/tree/TreePosTest.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/test/tools/javac/tree/TreePosTest.java Tue Oct 19 15:02:48 2010 -0700
@@ -357,7 +357,9 @@
check("encl.start <= start", encl, self, encl.start <= self.start);
check("start <= pos", encl, self, self.start <= self.pos);
if (!(self.tag == JCTree.TYPEARRAY
- && (encl.tag == JCTree.VARDEF || encl.tag == JCTree.TYPEARRAY))) {
+ && (encl.tag == JCTree.VARDEF ||
+ encl.tag == JCTree.METHODDEF ||
+ encl.tag == JCTree.TYPEARRAY))) {
check("encl.pos <= start || end <= encl.pos",
encl, self, encl.pos <= self.start || self.end <= encl.pos);
}
--- a/langtools/test/tools/javac/treeannotests/AnnoTreeTests.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2010, 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
- * @build DA TA Test TestProcessor
- * @compile -proc:only -processor TestProcessor AnnoTreeTests.java
- */
-
-@Test(6)
-class AnnoTreeTests {
- // primitive types
- @DA("int") int i1;
- int i2 = (@TA("int") int) 0;
-
- // simple array types
- @DA("int[]") int[] a1;
- int @TA("int") [] a2;
- int[] a3 = (@TA("int[]") int[]) a1;
- int[] a4 = (int @TA("int") []) a1;
-
- // multi-dimensional array types
- // (still to come)
-}
--- a/langtools/test/tools/javac/typeAnnotations/6967002/T6967002.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2010, 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 6967002
- * @summary JDK7 b99 javac compilation error (java.lang.AssertionError)
- * @author Maurizio Cimadamore
- * @compile/fail/ref=T6967002.out -XDrawDiagnostics T6967002.java
- */
-class Test {
- private static void m(byte[] octets) {
- return m(octets..., ?);
- }
-}
--- a/langtools/test/tools/javac/typeAnnotations/6967002/T6967002.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-T6967002.java:33:22: compiler.err.expected: ')'
-T6967002.java:33:25: compiler.err.illegal.start.of.expr
-T6967002.java:33:28: compiler.err.illegal.start.of.expr
-T6967002.java:33:29: compiler.err.illegal.start.of.expr
-T6967002.java:33:27: compiler.err.not.stmt
-T6967002.java:33:30: compiler.err.expected: ';'
-T6967002.java:35:2: compiler.err.premature.eof
-7 errors
--- a/langtools/test/tools/javac/typeAnnotations/InnerClass.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2009, 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 6843077
- * @summary compiler crashes when visiting inner classes
- * @author Mahmood Ali
- * @compile -source 1.7 InnerClass.java
- */
-
-class InnerClass {
-
- InnerClass() {}
- InnerClass(Object o) {}
-
- private void a() {
- new Object() {
- public <R> void method() { }
- };
- }
-
- Object f1 = new InnerClass() {
- <R> void method() { }
- };
-
- Object f2 = new InnerClass() {
- <@A R> void method() { }
- };
-
- Object f3 = new InnerClass(null) {
- <R> void method() { }
- };
-
- Object f4 = new InnerClass(null) {
- <@A R> void method() { }
- };
- @interface A { }
-}
--- a/langtools/test/tools/javac/typeAnnotations/MultipleTargets.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary check that type annotations may appear on void method if it is a
- * method annotation too.
- * @author Mahmood Ali
- * @compile -source 1.7 MultipleTargets.java
- */
-
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-class TypeUseTarget<K extends @A Object> {
- @A void voidMethod() { }
-}
-
-@Target({ElementType.TYPE_USE, ElementType.METHOD})
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/TypeParameterTarget.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary check that type annotations may appear on all type parameter
- * @author Mahmood Ali
- * @compile -source 1.7 TypeParameterTarget.java
- */
-
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-class TypeUseTarget<@A K extends Object> {
- String[] field;
-
- <@A K, @A V> String genericMethod(K k) { return null; }
-}
-
-interface MyInterface { }
-
-@interface MyAnnotation { }
-
-@Target(ElementType.TYPE_PARAMETER)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/TypeUseTarget.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary check that type annotations may appear on all type declarations
- * @author Mahmood Ali
- * @compile -source 1.7 TypeUseTarget.java
- */
-
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-@A
-class TypeUseTarget<K extends @A Object> {
- @A String @A [] field;
-
- @A String test(@A String param, @A String @A ... vararg) @A {
- @A Object o = new @A String @A [3];
- TypeUseTarget<@A String> target;
- return (@A String) null;
- }
-
- <K> @A String genericMethod(K k) { return null; }
-}
-
-@A
-interface MyInterface { }
-
-@A
-@interface MyAnnotation { }
-
-@Target(ElementType.TYPE_USE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/attribution/Scopes.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary test scopes of attribution
- * @author Mahmood Ali
- * @compile -source 1.7 Scopes.java
- */
-class Scopes {
-
- void test() @A(VALUE) { }
- void test1() @A(value=VALUE) { }
-
- private static final int VALUE = 1;
- @interface A { int value(); }
-}
--- a/langtools/test/tools/javac/typeAnnotations/classfile/DeadCode.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 2009, 2010, 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.
- */
-
-import java.io.*;
-import java.net.URL;
-import java.util.List;
-
-import com.sun.tools.classfile.*;
-
-/*
- * @test
- * @bug 6917130
- * @summary test that optimized away annotations are not emited to classfile
- */
-
-public class DeadCode {
- public static void main(String[] args) throws Exception {
- new DeadCode().run();
- }
-
- public void run() throws Exception {
- ClassFile cf = getClassFile("DeadCode$Test.class");
- test(cf);
- for (Field f : cf.fields) {
- test(cf, f);
- }
- for (Method m: cf.methods) {
- test(cf, m);
- }
-
- countAnnotations();
-
- if (errors > 0)
- throw new Exception(errors + " errors found");
- System.out.println("PASSED");
- }
-
- ClassFile getClassFile(String name) throws IOException, ConstantPoolException {
- URL url = getClass().getResource(name);
- InputStream in = url.openStream();
- try {
- return ClassFile.read(in);
- } finally {
- in.close();
- }
- }
-
- /************ Helper annotations counting methods ******************/
- void test(ClassFile cf) {
- test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Method m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Field m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, String name, boolean visible) {
- int index = cf.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = cf.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Method m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Field m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- void countAnnotations() {
- int expected_all = expected_visibles + expected_invisibles;
-
- if (expected_all != all) {
- errors++;
- System.err.println("expected " + expected_all
- + " annotations but found " + all);
- }
-
- if (expected_visibles != visibles) {
- errors++;
- System.err.println("expected " + expected_visibles
- + " visibles annotations but found " + visibles);
- }
-
- if (expected_invisibles != invisibles) {
- errors++;
- System.err.println("expected " + expected_invisibles
- + " invisibles annotations but found " + invisibles);
- }
-
- }
-
- int errors;
- int all;
- int visibles;
- int invisibles;
-
- /*********************** Test class *************************/
- static int expected_invisibles = 1;
- static int expected_visibles = 0;
- static class Test {
- @interface A {}
-
- void test() {
- List<? extends @A Object> o = null;
- o.toString();
-
- @A String m;
- if (false) {
- @A String a;
- @A String b = "m";
- b.toString();
- List<? extends @A Object> c = null;
- c.toString();
- }
- }
- }
-
-}
--- a/langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary test that only java 7 allows type annotations
- * @author Mahmood Ali
- * @compile/fail/ref=AnnotationVersion.out -XDrawDiagnostics -source 1.6 AnnotationVersion.java
- */
-class AnnotationVersion {
- public void method() @A { }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-AnnotationVersion.java:9:25: compiler.err.type.annotations.not.supported.in.source: 1.6
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary test incomplete array declaration
- * @author Mahmood Ali
- * @compile/fail/ref=IncompleteArray.out -XDrawDiagnostics -source 1.7 IncompleteArray.java
- */
-class IncompleteArray {
- int @A [] @A var;
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-IncompleteArray.java:9:13: compiler.err.illegal.start.of.type
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary test incomplete vararg declaration
- * @author Mahmood Ali
- * @compile/fail/ref=IncompleteVararg.out -XDrawDiagnostics -source 1.7 IncompleteVararg.java
- */
-class IncompleteArray {
- // the last variable may be vararg
- void method(int @A test) { }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-IncompleteVararg.java:10:19: compiler.err.illegal.start.of.type
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/IndexArray.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary test indexing of an array
- * @author Mahmood Ali
- * @compile/fail/ref=IndexArray.out -XDrawDiagnostics -source 1.7 IndexArray.java
- */
-class IndexArray {
- int[] var;
- int a = var @A [1];
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/IndexArray.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-IndexArray.java:10:15: compiler.err.illegal.start.of.expr
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/LintCast.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-import java.util.List;
-
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary test that compiler doesn't warn about annotated redundant casts
- * @author Mahmood Ali
- * @compile/ref=LintCast.out -Xlint:cast -XDrawDiagnostics -source 1.7 LintCast.java
- */
-class LintCast {
- void unparameterized() {
- String s = "m";
- String s1 = (String)s;
- String s2 = (@A String)s;
- }
-
- void parameterized() {
- List<String> l = null;
- List<String> l1 = (List<String>)l;
- List<String> l2 = (List<@A String>)l;
- }
-
- void array() {
- int @A [] a = null;
- int[] a1 = (int[])a;
- int[] a2 = (int @A [])a;
- }
-
- void sameAnnotations() {
- @A String annotated = null;
- String unannotated = null;
-
- // compiler ignore annotated casts even if redundant
- @A String anno1 = (@A String)annotated;
-
- // warn if redundant without an annotation
- String anno2 = (String)annotated;
- String unanno2 = (String)unannotated;
- }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/LintCast.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-LintCast.java:13:21: compiler.warn.redundant.cast: java.lang.String
-LintCast.java:19:27: compiler.warn.redundant.cast: java.util.List<java.lang.String>
-LintCast.java:25:20: compiler.warn.redundant.cast: int[]
-LintCast.java:37:24: compiler.warn.redundant.cast: java.lang.String
-LintCast.java:38:26: compiler.warn.redundant.cast: java.lang.String
-5 warnings
--- a/langtools/test/tools/javac/typeAnnotations/failures/OldArray.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 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 6843077
- * @summary test old array syntax
- * @author Mahmood Ali
- * @compile/fail -XDrawDiagnostics -source 1.7 OldArray.java
- */
-class OldArray {
- String [@A] s() { return null; }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/Scopes.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check that A is accessible in the class type parameters
- * @author Mahmood Ali
- * @compile/fail/ref=Scopes.out -XDrawDiagnostics -source 1.7 Scopes.java
- */
-class Scopes<T extends @UniqueInner Object> {
- @interface UniqueInner { };
-}
--- a/langtools/test/tools/javac/typeAnnotations/failures/Scopes.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-Scopes.java:8:25: compiler.err.cant.resolve: kindname.class, UniqueInner, ,
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/StaticFields.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary static field access isn't a valid location
- * @author Mahmood Ali
- * @compile/fail/ref=StaticFields.out -XDrawDiagnostics -source 1.7 StaticFields.java
- */
-class C {
- int f;
- int a = @A C.f;
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/StaticFields.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-StaticFields.java:10:17: compiler.err.illegal.start.of.expr
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary static methods don't have receivers
- * @author Mahmood Ali
- * @compile/fail/ref=StaticMethods.out -XDrawDiagnostics -source 1.7 StaticMethods.java
- */
-class StaticMethods {
- static void main() @A { }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-StaticMethods.java:9:22: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/VoidGenericMethod.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary test type annotation on void generic methods
- * @author Mahmood Ali
- * @compile/fail -source 1.7 VoidGenericMethod.java
- */
-class VoidGenericMethod {
- public <T> @A void method() { }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077 6919944
- * @summary check for duplicate annotation values
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
- */
-class DuplicateAnnotationValue {
- void test() {
- Object a = String @A(value = 2, value = 1) [].class;
- }
-}
-
-@interface A { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateAnnotationValue.java:10:37: compiler.err.duplicate.annotation.member.value: value, A
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for duplicate annotations
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
- */
-
-class DuplicateTypeAnnotation {
- void test() {
- Object a = String @A @A [].class;
- }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateTypeAnnotation.java:11:26: compiler.err.duplicate.annotation
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for invalid annotatins given the target
- * @author Mahmood Ali
- * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
- */
-
-class InvalidLocation {
- void test() {
- Object a = String @A [].class;
- }
-}
-
-@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-InvalidLocation.java:11:23: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for missing annotation value
- * @author Mahmood Ali
- * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
- */
-class MissingAnnotationValue {
- void test() {
- Object a = String @A [].class;
- }
-}
-
-@interface A { int field(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-MissingAnnotationValue.java:10:23: compiler.err.annotation.missing.default.value: A, field
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077 6919944
- * @summary check for duplicate annotation values
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
- */
-class DuplicateAnnotationValue {
- void test() {
- String @A(value = 2, value = 1) [] s;
- }
-}
-
-@interface A { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateAnnotationValue.java:10:26: compiler.err.duplicate.annotation.member.value: value, A
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for duplicate annotations
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
- */
-
-class DuplicateTypeAnnotation {
- void test() {
- String @A @A [] s;
- }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateTypeAnnotation.java:11:15: compiler.err.duplicate.annotation
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for invalid annotatins given the target
- * @author Mahmood Ali
- * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
- */
-
-class InvalidLocation {
- void test() {
- String @A [] s;
- }
-}
-
-@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-InvalidLocation.java:11:12: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for missing annotation value
- * @author Mahmood Ali
- * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
- */
-class MissingAnnotationValue {
- void test() {
- String @A [] s;
- }
-}
-
-@interface A { int field(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-MissingAnnotationValue.java:10:12: compiler.err.annotation.missing.default.value: A, field
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077 6919944
- * @summary check for duplicate annotation values for type parameter
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
- */
-class DuplicateAnnotationValue {
- void method() {
- class Inner<@A(value = 2, value = 1) K> {}
- }
-}
-
-@interface A { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateAnnotationValue.java:10:31: compiler.err.duplicate.annotation.member.value: value, A
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for duplicate annotations
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
- */
-class DuplicateTypeAnno {
- void innermethod() {
- class Inner<@A @A K> { }
- }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateTypeAnnotation.java:10:20: compiler.err.duplicate.annotation
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for invalid annotatins given the target
- * @author Mahmood Ali
- * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
- */
-class InvalidLocation {
- void innermethod() {
- class Inner<@A K> {}
- }
-}
-
-@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-InvalidLocation.java:10:17: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for missing annotation value
- * @author Mahmood Ali
- * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
- */
-class MissingAnnotationValue {
- void innermethod() {
- class Inner<@A K> { }
- }
-}
-
-@interface A { int field(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-MissingAnnotationValue.java:10:17: compiler.err.annotation.missing.default.value: A, field
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077 6919944
- * @summary check for duplicate annotation values
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
- */
-class DuplicateAnnotationValue {
- void test() {
- String[] a = new String @A(value = 2, value = 1) [5] ;
- }
-}
-
-@interface A { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateAnnotationValue.java:10:43: compiler.err.duplicate.annotation.member.value: value, A
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for duplicate annotations
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
- */
-
-class DuplicateTypeAnnotation {
- void test() {
- String[] a = new String @A @A [5] ;
- }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateTypeAnnotation.java:11:32: compiler.err.duplicate.annotation
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for invalid annotatins given the target
- * @author Mahmood Ali
- * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
- */
-
-class InvalidLocation {
- void test() {
- String[] s = new String @A [5] ;
- }
-}
-
-@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-InvalidLocation.java:11:29: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for missing annotation value
- * @author Mahmood Ali
- * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
- */
-class MissingAnnotationValue {
- void test() {
- String[] a = new String @A [5];
- }
-}
-
-@interface A { int field(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-MissingAnnotationValue.java:10:29: compiler.err.annotation.missing.default.value: A, field
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077 6919944
- * @summary check for duplicate annotation values for type parameter
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
- */
-class DuplicateAnnotationValue<K extends @A(value = 2, value = 1) Object> {
-}
-
-@interface A { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateAnnotationValue.java:8:56: compiler.err.duplicate.annotation.member.value: value, A
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for duplicate annotations
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
- */
-
-class DuplicateTypeAnno<K extends @A @A Object> {
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateTypeAnnotation.java:9:38: compiler.err.duplicate.annotation
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for invalid annotatins given the target
- * @author Mahmood Ali
- * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
- */
-
-class InvalidLocation<K extends @A Object> {
-}
-
-@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-InvalidLocation.java:9:33: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for missing annotation value
- * @author Mahmood Ali
- * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
- */
-class MissingAnnotationValue<K extends @A Object> {
-}
-
-@interface A { int field(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-MissingAnnotationValue.java:8:40: compiler.err.annotation.missing.default.value: A, field
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077 6919944
- * @summary check for duplicate annotation values in receiver
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
- */
-class DuplicateAnnotationValue {
- void test() @A(value = 2, value = 1) { }
-}
-
-@interface A { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateAnnotationValue.java:9:29: compiler.err.duplicate.annotation.member.value: value, A
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for duplicate annotations in receiver
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
- */
-
-class DuplicateTypeAnnotation {
- void test() @A @A { }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateTypeAnnotation.java:10:18: compiler.err.duplicate.annotation
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for invalid annotatins given the target
- * @author Mahmood Ali
- * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
- */
-
-class InvalidLocation {
- void test() @A {
- }
-}
-
-@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-InvalidLocation.java:10:15: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for missing annotation value
- * @author Mahmood Ali
- * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
- */
-class MissingAnnotationValue {
- void test() @A { }
-}
-
-@interface A { int field(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-MissingAnnotationValue.java:9:15: compiler.err.annotation.missing.default.value: A, field
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for Duplicate annotation value
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
- */
-class DuplicateAnnotationValue {
- void test() {
- new @A String();
- }
-}
-
-@interface A { int field(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateAnnotationValue.java:10:9: compiler.err.annotation.missing.default.value: A, field
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for duplicate annotations
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
- */
-
-class DuplicateTypeAnnotation {
- void test() {
- new @A @A String();
- }
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateTypeAnnotation.java:11:12: compiler.err.duplicate.annotation
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for invalid annotatins given the target
- * @author Mahmood Ali
- * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
- */
-
-class InvalidLocation {
- void test() {
- new @A String();
- }
-}
-
-@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-InvalidLocation.java:11:9: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for missing annotation value
- * @author Mahmood Ali
- * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
- */
-class MissingAnnotationValue {
- void test() {
- new @A String();
- }
-}
-
-@interface A { int field(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-MissingAnnotationValue.java:10:9: compiler.err.annotation.missing.default.value: A, field
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077 6919944
- * @summary check for duplicate annotation values for type parameter
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
- */
-class DuplicateAnnotationValue<K> {
- DuplicateAnnotationValue<@A(value = 2, value = 1) String> l;
-}
-
-@interface A { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateAnnotationValue.java:9:42: compiler.err.duplicate.annotation.member.value: value, A
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for duplicate annotations
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
- */
-
-class DuplicateTypeAnno<K> {
- DuplicateTypeAnno<@A @A String> l;
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateTypeAnnotation.java:10:24: compiler.err.duplicate.annotation
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for invalid annotatins given the target
- * @author Mahmood Ali
- * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
- */
-
-class InvalidLocation<K> {
- InvalidLocation<@A String> l;
-}
-
-@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-InvalidLocation.java:10:19: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for missing annotation value
- * @author Mahmood Ali
- * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
- */
-class MissingAnnotationValue<K> {
- MissingAnnotationValue<@A String> l;
-}
-
-@interface A { int field(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-MissingAnnotationValue.java:9:26: compiler.err.annotation.missing.default.value: A, field
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077 6919944
- * @summary check for duplicate annotation values for type parameter
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
- */
-class DuplicateAnnotationValue<@A(value = 2, value = 1) K> {
-}
-
-@interface A { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateAnnotationValue.java:8:46: compiler.err.duplicate.annotation.member.value: value, A
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for duplicate annotations
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
- */
-
-class DuplicateTypeAnno<@A @A K> {
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateTypeAnnotation.java:9:28: compiler.err.duplicate.annotation
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for invalid annotatins given the target
- * @author Mahmood Ali
- * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
- */
-
-class InvalidLocation<@A K> {
-}
-
-@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-InvalidLocation.java:9:23: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for missing annotation value
- * @author Mahmood Ali
- * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
- */
-class MissingAnnotationValue<@A K> {
-}
-
-@interface A { int field(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-MissingAnnotationValue.java:8:30: compiler.err.annotation.missing.default.value: A, field
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077 6919944
- * @summary check for duplicate annotation values for type parameter
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
- */
-class DuplicateAnnotationValue<K> {
- DuplicateAnnotationValue<@A(value = 2, value = 1) ?> l;
-}
-
-@interface A { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateAnnotationValue.java:9:42: compiler.err.duplicate.annotation.member.value: value, A
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for duplicate annotations
- * @author Mahmood Ali
- * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
- */
-
-class DuplicateTypeAnno<K> {
- DuplicateTypeAnno<@A @A ?> l;
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-DuplicateTypeAnnotation.java:10:24: compiler.err.duplicate.annotation
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for invalid annotatins given the target
- * @author Mahmood Ali
- * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
- */
-
-class InvalidLocation<K> {
- InvalidLocation<@A ?> l;
-}
-
-@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-InvalidLocation.java:10:19: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary check for missing annotation value
- * @author Mahmood Ali
- * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
- */
-class MissingAnnotationValue<K> {
- MissingAnnotationValue<@A ?> l;
-}
-
-@interface A { int field(); }
--- a/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-MissingAnnotationValue.java:9:26: compiler.err.annotation.missing.default.value: A, field
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary test invalid location of TypeUse
- * @author Mahmood Ali
- * @compile/fail/ref=Constructor.out -XDrawDiagnostics -source 1.7 Constructor.java
- */
-
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-class Constructor {
- @A Constructor() { }
-}
-
-@Target(ElementType.TYPE_USE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-Constructor.java:13:3: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary test incomplete array declaration
- * @author Mahmood Ali
- * @compile/fail/ref=IncompleteArray.out -XDrawDiagnostics -source 1.7 IncompleteArray.java
- */
-class IncompleteArray {
- int @A [] @A var;
-}
-
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-IncompleteArray.java:9:13: compiler.err.illegal.start.of.type
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary test invalid location of TypeUse
- * @author Mahmood Ali
- * @compile/fail/ref=NotTypeParameter.out -XDrawDiagnostics -source 1.7 NotTypeParameter.java
- */
-
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-class VoidMethod<@A K> {
- @A void test() { }
-}
-
-@Target(ElementType.TYPE_USE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-NotTypeParameter.java:13:3: compiler.err.annotation.type.not.applicable
-NotTypeParameter.java:12:18: compiler.err.annotation.type.not.applicable
-2 errors
--- a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary test invalid location of TypeUse
- * @author Mahmood Ali
- * @compile/fail/ref=NotTypeUse.out -XDrawDiagnostics -source 1.7 NotTypeUse.java
- */
-
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-class VoidMethod {
- @A void test() { }
-}
-
-@Target(ElementType.TYPE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-NotTypeUse.java:13:3: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6843077
- * @summary test invalid location of TypeUse
- * @author Mahmood Ali
- * @compile/fail/ref=VoidMethod.out -XDrawDiagnostics -source 1.7 VoidMethod.java
- */
-
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-class VoidMethod {
- @A void test() { }
-}
-
-@Target(ElementType.TYPE_USE)
-@interface A { }
--- a/langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.out Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-VoidMethod.java:13:3: compiler.err.annotation.type.not.applicable
-1 error
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.java Tue Oct 19 11:47:17 2010 +0530
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.java Tue Oct 19 15:02:48 2010 -0700
@@ -27,7 +27,7 @@
* @bug 6843077
* @summary random tests for new locations
* @author Matt Papi
- * @compile -source 1.7 BasicTest.java
+ * @compile/fail/ref=BasicTest.out -XDrawDiagnostics BasicTest.java
*/
import java.util.*;
@@ -38,6 +38,8 @@
@interface C {}
@interface D {}
+//308: Test inverted to verify that type annotations can not be parsed yet.
+
/**
* Tests basic JSR 308 parser functionality. We don't really care about what
* the parse tree looks like, just that these annotations can be parsed.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out Tue Oct 19 15:02:48 2010 -0700
@@ -0,0 +1,66 @@
+BasicTest.java:47:27: compiler.err.illegal.start.of.type
+BasicTest.java:47:28: compiler.err.expected: '{'
+BasicTest.java:47:36: compiler.err.expected: token.identifier
+BasicTest.java:47:38: compiler.err.illegal.start.of.type
+BasicTest.java:47:45: compiler.err.expected: token.identifier
+BasicTest.java:47:47: compiler.err.expected: ';'
+BasicTest.java:47:62: compiler.err.expected: token.identifier
+BasicTest.java:47:84: compiler.err.expected: token.identifier
+BasicTest.java:52:22: compiler.err.illegal.start.of.expr
+BasicTest.java:52:31: compiler.err.expected: ';'
+BasicTest.java:52:37: compiler.err.expected: token.identifier
+BasicTest.java:53:21: compiler.err.illegal.start.of.expr
+BasicTest.java:53:23: compiler.err.expected: ';'
+BasicTest.java:53:30: compiler.err.expected: token.identifier
+BasicTest.java:53:32: compiler.err.illegal.start.of.type
+BasicTest.java:53:37: compiler.err.expected: token.identifier
+BasicTest.java:53:38: compiler.err.expected: ';'
+BasicTest.java:56:17: compiler.err.expected: token.identifier
+BasicTest.java:56:23: compiler.err.expected: token.identifier
+BasicTest.java:56:24: compiler.err.expected2: '(', '['
+BasicTest.java:56:25: compiler.err.expected: ';'
+BasicTest.java:56:27: compiler.err.invalid.meth.decl.ret.type.req
+BasicTest.java:56:34: compiler.err.illegal.start.of.type
+BasicTest.java:58:34: compiler.err.illegal.start.of.type
+BasicTest.java:61:16: compiler.err.illegal.start.of.type
+BasicTest.java:61:18: compiler.err.expected: ';'
+BasicTest.java:61:24: compiler.err.illegal.start.of.type
+BasicTest.java:61:26: compiler.err.expected: ';'
+BasicTest.java:61:33: compiler.err.expected: token.identifier
+BasicTest.java:61:34: compiler.err.illegal.start.of.type
+BasicTest.java:61:35: compiler.err.expected: token.identifier
+BasicTest.java:61:37: compiler.err.expected: ';'
+BasicTest.java:61:45: compiler.err.expected: token.identifier
+BasicTest.java:61:50: compiler.err.expected: token.identifier
+BasicTest.java:62:16: compiler.err.expected: token.identifier
+BasicTest.java:62:17: compiler.err.expected2: '(', '['
+BasicTest.java:62:18: compiler.err.expected: ';'
+BasicTest.java:62:28: compiler.err.illegal.start.of.type
+BasicTest.java:62:30: compiler.err.expected: ';'
+BasicTest.java:62:36: compiler.err.illegal.start.of.type
+BasicTest.java:62:38: compiler.err.expected: ';'
+BasicTest.java:62:45: compiler.err.expected: token.identifier
+BasicTest.java:62:46: compiler.err.illegal.start.of.type
+BasicTest.java:62:47: compiler.err.expected: token.identifier
+BasicTest.java:62:49: compiler.err.expected: ';'
+BasicTest.java:62:57: compiler.err.expected: token.identifier
+BasicTest.java:62:58: compiler.err.illegal.start.of.type
+BasicTest.java:62:59: compiler.err.expected: token.identifier
+BasicTest.java:64:25: compiler.err.illegal.start.of.type
+BasicTest.java:64:27: compiler.err.expected: ';'
+BasicTest.java:64:34: compiler.err.expected: token.identifier
+BasicTest.java:64:38: compiler.err.expected: token.identifier
+BasicTest.java:64:41: compiler.err.illegal.start.of.expr
+BasicTest.java:64:50: compiler.err.expected: ';'
+BasicTest.java:64:56: compiler.err.expected: token.identifier
+BasicTest.java:69:17: compiler.err.expected: ';'
+BasicTest.java:69:24: compiler.err.illegal.start.of.type
+BasicTest.java:69:30: compiler.err.expected: ';'
+BasicTest.java:69:59: compiler.err.expected: token.identifier
+BasicTest.java:69:74: compiler.err.expected: ';'
+BasicTest.java:74:22: compiler.err.expected: token.identifier
+BasicTest.java:74:24: compiler.err.expected: ';'
+BasicTest.java:74:25: compiler.err.illegal.start.of.type
+BasicTest.java:74:33: compiler.err.expected: ';'
+BasicTest.java:77:2: compiler.err.premature.eof
+65 errors
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/ClassExtends.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: class extends/implements
- * @author Mahmood Ali
- * @compile -source 1.7 ClassExtends.java
- */
-abstract class MyClass extends @A ParameterizedClass<@B String>
- implements @B CharSequence, @A ParameterizedInterface<@B String> { }
-
-interface MyInterface extends @A ParameterizedInterface<@A String>,
- @B CharSequence { }
-
-class ParameterizedClass<K> {}
-interface ParameterizedInterface<K> {}
-@interface A {}
-@interface B {}
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/ClassLiterals.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: class literals
- * @author Mahmood Ali
- * @compile -source 1.7 ClassLiterals.java
- */
-
-class ClassLiterals {
-
- public static void main(String[] args) {
- if (String.class != @A String.class) throw new Error();
- if (@A int.class != int.class) throw new Error();
- if (@A int.class != Integer.TYPE) throw new Error();
- if (@A int @B(0) [].class != int[].class) throw new Error();
-
- if (String[].class != @A String[].class) throw new Error();
- if (String[].class != String @A [].class) throw new Error();
- if (@A int[].class != int[].class) throw new Error();
- if (@A int @B(0) [].class != int[].class) throw new Error();
- }
-}
-
-@interface A {}
-@interface B { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/ClassParameters.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: class type parameter bounds
- * @author Mahmood Ali
- * @compile -source 1.7 ClassParameters.java
- */
-class Unannotated<K> { }
-
-class ExtendsBound<K extends @A String> { }
-class ExtendsGeneric<K extends @A Unannotated<@B String>> { }
-class TwoBounds<K extends @A String, V extends @B String> { }
-
-class Complex1<K extends @A String&Runnable> { }
-class Complex2<K extends String & @B Runnable> { }
-class ComplexBoth<K extends @A String & @A Runnable> { }
-
-class Outer {
- void inner() {
- class Unannotated<K> { }
-
- class ExtendsBound<K extends @A String> { }
- class ExtendsGeneric<K extends @A Unannotated<@B String>> { }
- class TwoBounds<K extends @A String, V extends @B String> { }
-
- class Complex1<K extends @A String&Runnable> { }
- class Complex2<K extends String & @B Runnable> { }
- class ComplexBoth<K extends @A String & @A Runnable> { }
- }
-}
-
-@interface A { }
-@interface B { }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/ConstructorTypeArgs.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: constructor type args
- * @author Mahmood Ali
- * @compile -source 1.7 ConstructorTypeArgs.java
- */
-
-class ConstructorTypeArgs {
- void oneArg() {
- new @A MyList<@A String>();
- new MyList<@A MyList<@B(0) String>>();
- }
-
- void twoArg() {
- new MyMap<String, String>();
- new MyMap<@A String, @B(0) MyList<@A String>>();
- }
-
- void withArraysIn() {
- new MyList<String[]>();
- new MyList<@A String @B(0) [] @A []>();
-
- new MyMap<@A String[], @B(0) MyList<@A String> @A []>();
- }
-}
-
-class MyList<E> { }
-class MyMap<K, V> { }
-
-@interface A { }
-@interface B { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/Expressions.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: expressions
- * @author Mahmood Ali
- * @compile -source 1.7 Expressions.java
- */
-class Expressions {
- void instanceOf() {
- Object o = null;
- boolean a = o instanceof @A String;
- boolean b = o instanceof @B(0) String;
- }
-
- void instanceOfArray() {
- Object o = null;
- boolean a1 = o instanceof @A String [];
- boolean a2 = o instanceof @B(0) String [];
-
- boolean b1 = o instanceof String @A [];
- boolean b2 = o instanceof String @B(0) [];
- }
-
- void objectCreation() {
- new @A String();
- new @B(0) String();
- }
-
- void objectCreationArray() {
- Object a1 = new @A String [] [] { };
- Object a2 = new @A String [1] [];
- Object a3 = new @A 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 c1 = new @A String [] @B(0) [] { };
- Object c2 = new @A String [1] @B(0) [];
- Object c3 = new @A String [1] @B(0) [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 rand = new @A String @B(value = 0) [1] @B(value = 0) [2];
-
- }
-}
-
-@interface A { }
-@interface B { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/Fields.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: field type array/generics
- * @author Mahmood Ali
- * @compile -source 1.7 Fields.java
- */
-
-class DefaultScope {
- Parameterized<String, String> unannotated;
- Parameterized<@A String, String> firstTypeArg;
- Parameterized<String, @A String> secondTypeArg;
- Parameterized<@A String, @B String> bothTypeArgs;
-
- Parameterized<@A Parameterized<@A String, @B String>, @B String>
- nestedParameterized;
-
- @A String [] array1;
- @A String @B [] array1Deep;
- @A String [] [] array2;
- @A String @A [] @B [] array2Deep;
- String @A [] [] array2First;
- String [] @B [] array2Second;
-}
-
-class ModifiedScoped {
- public final Parameterized<String, String> unannotated = null;
- public final Parameterized<@A String, String> firstTypeArg = null;
- public final Parameterized<String, @A String> secondTypeArg = null;
- public final Parameterized<@A String, @B String> bothTypeArgs = null;
-
- public final Parameterized<@A Parameterized<@A String, @B String>, @B String>
- nestedParameterized = null;
-
- public final @A String [] array1 = null;
- public final @A String @B [] array1Deep = null;
- public final @A String [] [] array2 = null;
- public final @A String @A [] @B [] array2Deep = null;
- public final String @A [] [] array2First = null;
- public final String [] @B [] array2Second = null;
-}
-
-class Parameterized<K, V> { }
-
-@interface A { }
-@interface B { }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/LocalVariables.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: local variables array/generics
- * @author Mahmood Ali
- * @compile -source 1.7 LocalVariables.java
- */
-
-class DefaultScope {
- void parameterized() {
- Parameterized<String, String> unannotated;
- Parameterized<@A String, String> firstTypeArg;
- Parameterized<String, @A String> secondTypeArg;
- Parameterized<@A String, @B String> bothTypeArgs;
-
- Parameterized<@A Parameterized<@A String, @B String>, @B String>
- nestedParameterized;
- }
-
- void arrays() {
- @A String [] array1;
- @A String @B [] array1Deep;
- @A String [] [] array2;
- @A String @A [] @B [] array2Deep;
- String @A [] [] array2First;
- String [] @B [] array2Second;
- }
-}
-
-class ModifiedVars {
- void parameterized() {
- final Parameterized<String, String> unannotated = null;
- final Parameterized<@A String, String> firstTypeArg = null;
- final Parameterized<String, @A String> secondTypeArg = null;
- final Parameterized<@A String, @B String> bothTypeArgs = null;
-
- final Parameterized<@A Parameterized<@A String, @B String>, @B String>
- nestedParameterized = null;
- }
-
- void arrays() {
- final @A String [] array1 = null;
- final @A String @B [] array1Deep = null;
- final @A String [] [] array2 = null;
- final @A String @A [] @B [] array2Deep = null;
- final String @A [] [] array2First = null;
- final String [] @B [] array2Second = null;
- }
-}
-
-class Parameterized<K, V> { }
-
-@interface A { }
-@interface B { }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/MethodReturnType.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: method return type array/generics
- * @author Mahmood Ali
- * @compile -source 1.7 MethodReturnType.java
- */
-
-class DefaultScope {
- Parameterized<String, String> unannotated() { return null; }
- Parameterized<@A String, String> firstTypeArg() { return null; }
- Parameterized<String, @A String> secondTypeArg() { return null; }
- Parameterized<@A String, @B String> bothTypeArgs() { return null; }
-
- Parameterized<@A Parameterized<@A String, @B String>, @B String>
- nestedParameterized() { return null; }
-
- public <T> @A String method() { return null; }
-
- @A String [] array1() { return null; }
- @A String @B [] array1Deep() { return null; }
- @A String [] [] array2() { return null; }
- @A String @A [] @B [] array2Deep() { return null; }
- String @A [] [] array2First() { return null; }
- String [] @B [] array2Second() { return null; }
-}
-
-class ModifiedScoped {
- public final Parameterized<String, String> unannotated() { return null; }
- public final Parameterized<@A String, String> firstTypeArg() { return null; }
- public final Parameterized<String, @A String> secondTypeArg() { return null; }
- public final Parameterized<@A String, @B String> bothTypeArgs() { return null; }
-
- public final Parameterized<@A Parameterized<@A String, @B String>, @B String>
- nestedParameterized() { return null; }
-
- public final @A String [] array1() { return null; }
- public final @A String @B [] array1Deep() { return null; }
- public final @A String [] [] array2() { return null; }
- public final @A String @A [] @B [] array2Deep() { return null; }
- public final String @A [] [] array2First() { return null; }
- public final String [] @B [] array2Second() { return null; }
-}
-
-class Parameterized<K, V> { }
-
-@interface A { }
-@interface B { }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeArgs.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: method type args
- * @author Mahmood Ali
- * @compile -source 1.7 MethodTypeArgs.java
- */
-
-class MethodTypeArgs {
- void oneArg() {
- this.<@A String>newList();
- this.<@A MyList<@B(0) String>>newList();
-
- MethodTypeArgs.<@A String>newList();
- MethodTypeArgs.<@A MyList<@B(0) String>>newList();
- }
-
- void twoArg() {
- this.<String, String>newMap();
- this.<@A String, @B(0) MyList<@A String>>newMap();
-
- MethodTypeArgs.<String, String>newMap();
- MethodTypeArgs.<@A String, @B(0) MyList<@A String>>newMap();
- }
-
- void withArraysIn() {
- this.<String[]>newList();
- this.<@A String @B(0) [] @A []>newList();
-
- this.<@A String[], @B(0) MyList<@A String> @A []>newMap();
- }
-
- static <E> void newList() { }
- static <K, V> void newMap() { }
-}
-
-class MyList<E> { }
-@interface A { }
-@interface B { int value(); }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeParameters.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: method type parameter bounds
- * @author Mahmood Ali
- * @compile -source 1.7 MethodTypeParameters.java
- */
-
-class UnscopedUnmodified {
- <K extends @A String> void methodExtends() {}
- <K extends @A Parameterized<@B String>> void nestedExtends() {}
- <K extends @A String, V extends @A Parameterized<@B String>> void dual() {}
- <K extends String, V extends Parameterized<@B String>> void dualOneAnno() {}
-}
-
-class PublicModifiedMethods {
- public final <K extends @A String> void methodExtends() {}
- public final <K extends @A Parameterized<@B String>> void nestedExtends() {}
- public final <K extends @A String, V extends @A Parameterized<@B String>> void dual() {}
- public final <K extends String, V extends Parameterized<@B String>> void dualOneAnno() {}
-}
-
-class Parameterized<K> { }
-@interface A { }
-@interface B { }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/Parameters.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: parameter type array/generics
- * @author Mahmood Ali
- * @compile -source 1.7 Parameters.java
- */
-
-class Parameters {
- void unannotated(Parameterized<String, String> a) {}
- void firstTypeArg(Parameterized<@A String, String> a) {}
- void secondTypeArg(Parameterized<String, @A String> a) {}
- void bothTypeArgs(Parameterized<@A String, @B String> both) {}
-
- void nestedParameterized(Parameterized<@A Parameterized<@A String, @B String>, @B String> a) {}
-
- void array1(@A String [] a) {}
- void array1Deep(@A String @B [] a) {}
- void array2(@A String [] [] a) {}
- void array2Deep(@A String @A [] @B [] a) {}
- void array2First(String @A [] [] a) {}
- void array2Second(String [] @B [] a) {}
-}
-
-class Parameterized<K, V> { }
-
-@interface A { }
-@interface B { }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/Receivers.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: receivers
- * @author Mahmood Ali
- * @compile -source 1.7 Receivers.java
- */
-class DefaultUnmodified {
- void plain() @A { }
- <T> void generic() @A { }
- void withException() @A throws Exception { }
- String nonVoid() @A { return null; }
- <T extends Runnable> void accept(T r) @A throws Exception { }
-}
-
-class PublicModified {
- public final void plain() @A { }
- public final <T> void generic() @A { }
- public final void withException() @A throws Exception { }
- public final String nonVoid() @A { return null; }
- public final <T extends Runnable> void accept(T r) @A throws Exception { }
-}
-
-class WithValue {
- void plain() @B("m") { }
- <T> void generic() @B("m") { }
- void withException() @B("m") throws Exception { }
- String nonVoid() @B("m") { return null; }
- <T extends Runnable> void accept(T r) @B("m") throws Exception { }
-}
-
-@interface A {}
-@interface B { String value(); }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/Throws.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: throw clauses
- * @author Mahmood Ali
- * @compile -source 1.7 Throws.java
- */
-class DefaultUnmodified {
- void oneException() throws @A Exception {}
- void twoExceptions() throws @A RuntimeException, @A Exception {}
-}
-
-class PublicModified {
- public final void oneException(String a) throws @A Exception {}
- public final void twoExceptions(String a) throws @A RuntimeException, @A Exception {}
-}
-
-class WithValue {
- void oneException() throws @B("m") Exception {}
- void twoExceptions() throws @B(value="m") RuntimeException, @A Exception {}
-}
-
-@interface A {}
-@interface B { String value(); }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/TypeCasts.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: type casts
- * @author Mahmood Ali
- * @compile -source 1.7 TypeCasts.java
- */
-class TypeCasts {
- void methodA() {
- String s = (@A String) null;
- Object o = (@A Class<@A String>) null;
- }
-
- void methodB() {
- String s = (@B("m") String) null;
- Object o = (@B("m") Class<@B("m") String>) null;
- }
-}
-
-@interface A { }
-@interface B { String value(); }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/TypeParameters.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: class and method type parameters
- * @author Mahmood Ali
- * @compile -source 1.7 TypeParameters.java
- */
-
-class Unannotated<K> { }
-class OneAnnotated<@A K> { }
-class TwoAnnotated<@A K, @A V> { }
-class SecondAnnotated<K, @A V extends String> { }
-
-class TestMethods {
- <K> void unannotated() { }
- <@A K> void oneAnnotated() { }
- <@A K, @B("m") V> void twoAnnotated() { }
- <K, @A V extends @A String> void secondAnnotated() { }
-}
-
-class UnannotatedB<K> { }
-class OneAnnotatedB<@B("m") K> { }
-class TwoAnnotatedB<@B("m") K, @B("m") V> { }
-class SecondAnnotatedB<K, @B("m") V extends @B("m") String> { }
-
-@interface A { }
-@interface B { String value(); }
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/Wildcards.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2008, 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 6843077
- * @summary new type annotation location: wildcard bound
- * @author Mahmood Ali
- * @compile -source 1.7 Wildcards.java
- */
-class BoundTest {
- void wcExtends(MyList<? extends @A String> l) { }
- void wcSuper(MyList<? super @A String> l) { }
-
- MyList<? extends @A String> returnWcExtends() { return null; }
- MyList<? super @A String> returnWcSuper() { return null; }
- MyList<? extends @A MyList<? super @B("m") String>> complex() { return null; }
-}
-
-class BoundWithValue {
- void wcExtends(MyList<? extends @B("m") String> l) { }
- void wcSuper(MyList<? super @B(value="m") String> l) { }
-
- MyList<? extends @B("m") String> returnWcExtends() { return null; }
- MyList<? super @B(value="m") String> returnWcSuper() { return null; }
- MyList<? extends @B("m") MyList<? super @B("m") String>> complex() { return null; }
-}
-
-class SelfTest {
- void wcExtends(MyList<@A ?> l) { }
- void wcSuper(MyList<@A ?> l) { }
-
- MyList<@A ?> returnWcExtends() { return null; }
- MyList<@A ?> returnWcSuper() { return null; }
- MyList<@A ? extends @A MyList<@B("m") ?>> complex() { return null; }
-}
-
-class SelfWithValue {
- void wcExtends(MyList<@B("m") ?> l) { }
- void wcSuper(MyList<@B(value="m") ?> l) { }
-
- MyList<@B("m") ?> returnWcExtends() { return null; }
- MyList<@B(value="m") ?> returnWcSuper() { return null; }
- MyList<@B("m") ? extends MyList<@B("m") ? super String>> complex() { return null; }
-}
-
-class MyList<K> { }
-
-@interface A { }
-@interface B { String value(); }
--- a/langtools/test/tools/javap/typeAnnotations/ArrayClassLiterals.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) 2009, 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.
- */
-
-import java.io.*;
-import com.sun.tools.classfile.*;
-
-/*
- * @test ArrayClassLiterals
- * @bug 6863814
- * @summary test that class literals array doesn't crash javap
- */
-
-public class ArrayClassLiterals {
- public static void main(String[] args) throws Exception {
- new ArrayClassLiterals().run();
- }
-
- public void run() throws Exception {
- File javaFile = writeTestFile();
- File classFile = compileTestFile(javaFile);
-
- ClassFile cf = ClassFile.read(classFile);
- test(cf);
- for (Field f : cf.fields) {
- test(cf, f);
- }
- for (Method m: cf.methods) {
- test(cf, m);
- }
-
- countAnnotations();
-
- if (errors > 0)
- throw new Exception(errors + " errors found");
- System.out.println("PASSED");
- }
-
- void test(ClassFile cf) {
- test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Method m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Field m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, String name, boolean visible) {
- int index = cf.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = cf.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
-
- for (ExtendedAnnotation anno : tAttr.annotations)
- anno.position.toString();
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Method m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
-
- for (ExtendedAnnotation anno : tAttr.annotations)
- anno.position.toString();
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Field m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
-
- for (ExtendedAnnotation anno : tAttr.annotations)
- anno.position.toString();
- }
- }
-
- File writeTestFile() throws IOException {
- File f = new File("Testa.java");
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
- out.println("import java.util.*;");
- out.println("class Testa { ");
- out.println(" @interface A { }");
-
- out.println(" void test() {");
- out.println(" Object a = @A String.class;");
- out.println(" Object b = @A String @A [] @A [].class;");
- out.println(" }");
- out.println("}");
-
- out.close();
- return f;
- }
-
- File compileTestFile(File f) {
- int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
- if (rc != 0)
- throw new Error("compilation failed. rc=" + rc);
- String path = f.getPath();
- return new File(path.substring(0, path.length() - 5) + ".class");
- }
-
- void countAnnotations() {
- int expected_visibles = 0, expected_invisibles = 4;
- int expected_all = expected_visibles + expected_invisibles;
-
- if (expected_all != all) {
- errors++;
- System.err.println("expected " + expected_all
- + " annotations but found " + all);
- }
-
- if (expected_visibles != visibles) {
- errors++;
- System.err.println("expected " + expected_visibles
- + " visibles annotations but found " + visibles);
- }
-
- if (expected_invisibles != invisibles) {
- errors++;
- System.err.println("expected " + expected_invisibles
- + " invisibles annotations but found " + invisibles);
- }
-
- }
-
- int errors;
- int all;
- int visibles;
- int invisibles;
-}
--- a/langtools/test/tools/javap/typeAnnotations/ArrayClassLiterals2.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2009, 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 6918625
- * @summary javap dumps type information of array class literals
- */
-
-import java.io.*;
-
-public class ArrayClassLiterals2 {
- public static void main(String[] args) throws Exception {
- new ArrayClassLiterals2().run();
- }
-
- public void run() throws IOException {
- File classFile = new File(System.getProperty("test.classes"), "ArrayClassLiterals2$Test.class");
-
- verify(classFile,
- "RuntimeInvisibleTypeAnnotations:",
- "CLASS_LITERAL_GENERIC_OR_ARRAY"
- );
-
- if (errors > 0)
- throw new Error(errors + " found.");
- }
-
- String javap(File f) {
- StringWriter sw = new StringWriter();
- PrintWriter out = new PrintWriter(sw);
- int rc = com.sun.tools.javap.Main.run(new String[] { "-v", f.getPath() }, out);
- if (rc != 0)
- throw new Error("javap failed. rc=" + rc);
- out.close();
- return sw.toString();
- }
-
- void verify(File classFile, String... expects) {
- String output = javap(classFile);
- for (String expect: expects) {
- if (output.indexOf(expect)< 0)
- error(expect + " not found");
- }
- }
-
- void error(String msg) {
- System.err.println(msg);
- errors++;
- }
-
- int errors;
-
-
- /*********************** Test class *************************/
- static class Test {
- @interface A { }
- void test() {
- Object a = @A String @A [] @A [].class;
- }
- }
-}
--- a/langtools/test/tools/javap/typeAnnotations/ClassLiterals.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-/*
- * Copyright (c) 2008, 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.
- */
-
-import java.io.*;
-import com.sun.tools.classfile.*;
-
-/*
- * @test ClassLiterals
- * @bug 6843077
- * @summary test that all type annotations are present in the classfile
- */
-
-public class ClassLiterals {
- public static void main(String[] args) throws Exception {
- new ClassLiterals().run();
- }
-
- public void run() throws Exception {
- File javaFile = writeTestFile();
- File classFile = compileTestFile(javaFile);
-
- ClassFile cf = ClassFile.read(classFile);
- test(cf);
- for (Field f : cf.fields) {
- test(cf, f);
- }
- for (Method m: cf.methods) {
- test(cf, m);
- }
-
- countAnnotations();
-
- if (errors > 0)
- throw new Exception(errors + " errors found");
- System.out.println("PASSED");
- }
-
- void test(ClassFile cf) {
- test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Method m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Field m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, String name, boolean visible) {
- int index = cf.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = cf.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Method m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Field m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- File writeTestFile() throws IOException {
- File f = new File("Testa.java");
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
- out.println("import java.util.*;");
- out.println("class Testa { ");
- out.println(" @interface A { }");
-
- out.println(" void test() {");
- out.println(" Object a = @A String.class;");
- out.println(" Object b = @A String @A [] @A [].class;");
- out.println(" }");
- out.println("}");
-
- out.close();
- return f;
- }
-
- File compileTestFile(File f) {
- int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
- if (rc != 0)
- throw new Error("compilation failed. rc=" + rc);
- String path = f.getPath();
- return new File(path.substring(0, path.length() - 5) + ".class");
- }
-
- void countAnnotations() {
- int expected_visibles = 0, expected_invisibles = 4;
- int expected_all = expected_visibles + expected_invisibles;
-
- if (expected_all != all) {
- errors++;
- System.err.println("expected " + expected_all
- + " annotations but found " + all);
- }
-
- if (expected_visibles != visibles) {
- errors++;
- System.err.println("expected " + expected_visibles
- + " visibles annotations but found " + visibles);
- }
-
- if (expected_invisibles != invisibles) {
- errors++;
- System.err.println("expected " + expected_invisibles
- + " invisibles annotations but found " + invisibles);
- }
-
- }
-
- int errors;
- int all;
- int visibles;
- int invisibles;
-}
--- a/langtools/test/tools/javap/typeAnnotations/JSR175Annotations.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2008, 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.
- */
-
-import java.io.*;
-import com.sun.tools.classfile.*;
-
-/*
- * @test JSR175Annotations
- * @bug 6843077
- * @summary test that only type annotations are recorded as such in classfile
- */
-
-public class JSR175Annotations {
- public static void main(String[] args) throws Exception {
- new JSR175Annotations().run();
- }
-
- public void run() throws Exception {
- File javaFile = writeTestFile();
- File classFile = compileTestFile(javaFile);
-
- ClassFile cf = ClassFile.read(classFile);
- for (Field f : cf.fields) {
- test(cf, f);
- }
- for (Method m: cf.methods) {
- test(cf, m);
- }
-
- countAnnotations();
-
- if (errors > 0)
- throw new Exception(errors + " errors found");
- System.out.println("PASSED");
- }
-
- void test(ClassFile cf, Method m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Field m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Method m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Field m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- File writeTestFile() throws IOException {
- File f = new File("Test.java");
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
- out.println("import java.lang.annotation.Retention;");
- out.println("import java.lang.annotation.RetentionPolicy;");
- out.println("abstract class Test { ");
- out.println(" @Retention(RetentionPolicy.RUNTIME)");
- out.println(" @interface A { }");
- out.println(" @A String m;");
- out.println(" @A String method(@A String a) {");
- out.println(" return a;");
- out.println(" }");
- out.println("}");
- out.close();
- return f;
- }
-
- File compileTestFile(File f) {
- int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
- if (rc != 0)
- throw new Error("compilation failed. rc=" + rc);
- String path = f.getPath();
- return new File(path.substring(0, path.length() - 5) + ".class");
- }
-
- void countAnnotations() {
- int expected_visibles = 0, expected_invisibles = 0;
- int expected_all = expected_visibles + expected_invisibles;
-
- if (expected_all != all) {
- errors++;
- System.err.println("expected " + expected_all
- + " annotations but found " + all);
- }
-
- if (expected_visibles != visibles) {
- errors++;
- System.err.println("expected " + expected_visibles
- + " visibles annotations but found " + visibles);
- }
-
- if (expected_invisibles != invisibles) {
- errors++;
- System.err.println("expected " + expected_invisibles
- + " invisibles annotations but found " + invisibles);
- }
-
- }
-
- int errors;
- int all;
- int visibles;
- int invisibles;
-}
--- a/langtools/test/tools/javap/typeAnnotations/NewArray.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2008, 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.
- */
-
-import java.io.*;
-import com.sun.tools.classfile.*;
-
-/*
- * @test NewArray
- * @bug 6843077
- * @summary test that all type annotations are present in the classfile
- */
-
-public class NewArray {
- public static void main(String[] args) throws Exception {
- new NewArray().run();
- }
-
- public void run() throws Exception {
- File javaFile = writeTestFile();
- File classFile = compileTestFile(javaFile);
-
- ClassFile cf = ClassFile.read(classFile);
- test(cf);
- for (Field f : cf.fields) {
- test(cf, f);
- }
- for (Method m: cf.methods) {
- test(cf, m);
- }
-
- countAnnotations();
-
- if (errors > 0)
- throw new Exception(errors + " errors found");
- System.out.println("PASSED");
- }
-
- void test(ClassFile cf) {
- test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Method m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Field m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, String name, boolean visible) {
- int index = cf.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = cf.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Method m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Field m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- File writeTestFile() throws IOException {
- File f = new File("Test.java");
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
- out.println("import java.util.*;");
- out.println("class Test { ");
- out.println(" @interface A { }");
-
- out.println(" void test() {");
- out.println(" Object a = new @A String @A [5] @A [];");
- out.println(" Object b = new @A String @A [5] @A [3];");
- out.println(" Object c = new @A String @A [] @A [] {};");
- out.println(" }");
- out.println("}");
-
- out.close();
- return f;
- }
-
- File compileTestFile(File f) {
- int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
- if (rc != 0)
- throw new Error("compilation failed. rc=" + rc);
- String path = f.getPath();
- return new File(path.substring(0, path.length() - 5) + ".class");
- }
-
- void countAnnotations() {
- int expected_visibles = 0, expected_invisibles = 9;
- int expected_all = expected_visibles + expected_invisibles;
-
- if (expected_all != all) {
- errors++;
- System.err.println("expected " + expected_all
- + " annotations but found " + all);
- }
-
- if (expected_visibles != visibles) {
- errors++;
- System.err.println("expected " + expected_visibles
- + " visibles annotations but found " + visibles);
- }
-
- if (expected_invisibles != invisibles) {
- errors++;
- System.err.println("expected " + expected_invisibles
- + " invisibles annotations but found " + invisibles);
- }
-
- }
-
- int errors;
- int all;
- int visibles;
- int invisibles;
-}
--- a/langtools/test/tools/javap/typeAnnotations/Presence.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2008, 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.
- */
-
-import java.io.*;
-import com.sun.tools.classfile.*;
-
-/*
- * @test Presence
- * @bug 6843077
- * @summary test that all type annotations are present in the classfile
- */
-
-public class Presence {
- public static void main(String[] args) throws Exception {
- new Presence().run();
- }
-
- public void run() throws Exception {
- File javaFile = writeTestFile();
- File classFile = compileTestFile(javaFile);
-
- ClassFile cf = ClassFile.read(classFile);
- test(cf);
- for (Field f : cf.fields) {
- test(cf, f);
- }
- for (Method m: cf.methods) {
- test(cf, m);
- }
-
- countAnnotations();
-
- if (errors > 0)
- throw new Exception(errors + " errors found");
- System.out.println("PASSED");
- }
-
- void test(ClassFile cf) {
- test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Method m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Field m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, String name, boolean visible) {
- int index = cf.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = cf.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Method m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Field m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- File writeTestFile() throws IOException {
- File f = new File("Test.java");
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
- out.println("import java.util.*;");
- out.println("class Test<@Test.A T extends @Test.A List<@Test.A String>> { ");
- out.println(" @interface A { }");
-
- out.println(" Map<@A String, Map<@A String, @A String>> f1;");
-
- out.println(" <@A T extends @A List<@A String>>");
- out.println(" Map<@A String, @A List<@A String>>");
- out.println(" method(List<@A String> @A [] param1, String @A [] @A ... param2) @A");
- out.println(" throws @A Exception {");
- out.println(" @A String lc1 = null;");
- out.println(" @A List<@A String> lc2 = null;");
- out.println(" @A String @A [] [] @A[] lc3 = null;");
- out.println(" List<? extends @A List<@A String>> lc4 = null;");
- out.println(" Object lc5 = (@A List<@A String>) null;");
- out.println(" boolean lc6 = lc1 instanceof @A String;");
- out.println(" boolean lc7 = lc5 instanceof @A String @A [] @A [];");
- out.println(" new @A ArrayList<@A String>();");
- out.println(" Object lc8 = new @A String @A [4];");
- out.println(" Object lc9 = @A String.class;");
- out.println(" Object lc10 = @A int.class;");
- out.println(" return null;");
- out.println(" }");
- out.println(" void vararg1(String @A ... t) { } ");
- out.println("}");
- out.close();
- return f;
- }
-
- File compileTestFile(File f) {
- int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
- if (rc != 0)
- throw new Error("compilation failed. rc=" + rc);
- String path = f.getPath();
- return new File(path.substring(0, path.length() - 5) + ".class");
- }
-
- void countAnnotations() {
- int expected_visibles = 0, expected_invisibles = 39;
- int expected_all = expected_visibles + expected_invisibles;
-
- if (expected_all != all) {
- errors++;
- System.err.println("expected " + expected_all
- + " annotations but found " + all);
- }
-
- if (expected_visibles != visibles) {
- errors++;
- System.err.println("expected " + expected_visibles
- + " visibles annotations but found " + visibles);
- }
-
- if (expected_invisibles != invisibles) {
- errors++;
- System.err.println("expected " + expected_invisibles
- + " invisibles annotations but found " + invisibles);
- }
-
- }
-
- int errors;
- int all;
- int visibles;
- int invisibles;
-}
--- a/langtools/test/tools/javap/typeAnnotations/PresenceInner.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2009, 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.
- */
-
-import java.io.*;
-import com.sun.tools.classfile.*;
-
-/*
- * @test PresenceInner
- * @bug 6843077
- * @summary test that annotations in inner types count only once
- */
-
-public class PresenceInner {
- public static void main(String[] args) throws Exception {
- new PresenceInner().run();
- }
-
- public void run() throws Exception {
- File javaFile = writeTestFile();
- File classFile = compileTestFile(javaFile);
-
- ClassFile cf = ClassFile.read(classFile);
- test(cf);
- for (Field f : cf.fields) {
- test(cf, f);
- }
- for (Method m: cf.methods) {
- test(cf, m);
- }
-
- // counts are zero when vising outer class
- countAnnotations(0);
-
- // visit inner class
- File innerFile = new File("Test$1Inner.class");
- ClassFile icf = ClassFile.read(innerFile);
- test(icf);
- for (Field f : icf.fields) {
- test(cf, f);
- }
- for (Method m: icf.methods) {
- test(cf, m);
- }
-
- countAnnotations(1);
- if (errors > 0)
- throw new Exception(errors + " errors found");
- System.out.println("PASSED");
- }
-
- void test(ClassFile cf) {
- test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Method m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- void test(ClassFile cf, Field m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, String name, boolean visible) {
- int index = cf.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = cf.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Method m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Field m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- File writeTestFile() throws IOException {
- File f = new File("Test.java");
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
-
- out.println("class Test {");
- out.println(" void method() {");
- out.println(" class Inner<T extends @A Object> { }");
- out.println(" }");
- out.println("}");
- out.println("@interface A { }");
- out.close();
- System.out.println(f.getAbsolutePath());
- return f;
- }
-
- File compileTestFile(File f) {
- int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
- if (rc != 0)
- throw new Error("compilation failed. rc=" + rc);
- String path = f.getPath();
- return new File(path.substring(0, path.length() - 5) + ".class");
- }
-
- void countAnnotations(int expected_invisibles) {
- int expected_visibles = 0;
- int expected_all = expected_visibles + expected_invisibles;
-
- if (expected_all != all) {
- errors++;
- System.err.println("expected " + expected_all
- + " annotations but found " + all);
- }
-
- if (expected_visibles != visibles) {
- errors++;
- System.err.println("expected " + expected_visibles
- + " visibles annotations but found " + visibles);
- }
-
- if (expected_invisibles != invisibles) {
- errors++;
- System.err.println("expected " + expected_invisibles
- + " invisibles annotations but found " + invisibles);
- }
-
- }
-
- int errors;
- int all;
- int visibles;
- int invisibles;
-}
--- a/langtools/test/tools/javap/typeAnnotations/T6855990.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, 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.
- */
-
-import java.io.*;
-
-/*
- * @test
- * @bug 6855990
- * @summary InstructionDetailWriter should support new 308 annotations attribute
- */
-
-public class T6855990 {
- public static void main(String[] args) throws Exception {
- new T6855990().run();
- }
-
- public void run() throws Exception {
- @Simple String[] args = { "-c", "-XDdetails:typeAnnotations", "T6855990" };
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- int rc = com.sun.tools.javap.Main.run(args, pw);
- pw.close();
- String out = sw.toString();
- System.out.println(out);
- if (out.indexOf("@Simple: LOCAL_VARIABLE") == -1)
- throw new Exception("expected output not found");
- }
-}
-
-@interface Simple { }
-
--- a/langtools/test/tools/javap/typeAnnotations/Visibility.java Tue Oct 19 11:47:17 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 2008, 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.
- */
-
-import java.io.*;
-import com.sun.tools.classfile.*;
-
-/*
- * @test Visibility
- * @bug 6843077
- * @summary test that type annotations are recorded in the classfile
- */
-
-public class Visibility {
- public static void main(String[] args) throws Exception {
- new Visibility().run();
- }
-
- public void run() throws Exception {
- File javaFile = writeTestFile();
- File classFile = compileTestFile(javaFile);
-
- ClassFile cf = ClassFile.read(classFile);
- for (Method m: cf.methods) {
- test(cf, m);
- }
-
- countAnnotations();
-
- if (errors > 0)
- throw new Exception(errors + " errors found");
- System.out.println("PASSED");
- }
-
- void test(ClassFile cf, Method m) {
- test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
- test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
- }
-
- // test the result of Attributes.getIndex according to expectations
- // encoded in the method's name
- void test(ClassFile cf, Method m, String name, boolean visible) {
- int index = m.attributes.getIndex(cf.constant_pool, name);
- if (index != -1) {
- Attribute attr = m.attributes.get(index);
- assert attr instanceof RuntimeTypeAnnotations_attribute;
- RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
- all += tAttr.annotations.length;
- if (visible)
- visibles += tAttr.annotations.length;
- else
- invisibles += tAttr.annotations.length;
- }
- }
-
- File writeTestFile() throws IOException {
- File f = new File("Test.java");
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
- out.println("import java.lang.annotation.Retention;");
- out.println("import java.lang.annotation.RetentionPolicy;");
- out.println("abstract class Test { ");
- // visible annotations: RUNTIME
- out.println(" @Retention(RetentionPolicy.RUNTIME)");
- out.println(" @interface A { }");
- out.println(" void visible() @A { }");
-
- // invisible annotations: CLASS
- out.println(" @Retention(RetentionPolicy.CLASS)");
- out.println(" @interface B { }");
- out.println(" void invisible() @B { }");
-
- // source annotations
- out.println(" @Retention(RetentionPolicy.SOURCE)");
- out.println(" @interface C { }");
- out.println(" void source() @C { }");
-
- // default visibility: CLASS
- out.println(" @interface D { }");
- out.println(" void def() @D { }");
- out.println("}");
- out.close();
- return f;
- }
-
- File compileTestFile(File f) {
- int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
- if (rc != 0)
- throw new Error("compilation failed. rc=" + rc);
- String path = f.getPath();
- return new File(path.substring(0, path.length() - 5) + ".class");
- }
-
- void countAnnotations() {
- int expected_all = 3, expected_visibles = 1, expected_invisibles = 2;
-
- if (expected_all != all) {
- errors++;
- System.err.println("expected " + expected_all
- + " annotations but found " + all);
- }
-
- if (expected_visibles != visibles) {
- errors++;
- System.err.println("expected " + expected_visibles
- + " visibles annotations but found " + visibles);
- }
-
- if (expected_invisibles != invisibles) {
- errors++;
- System.err.println("expected " + expected_invisibles
- + " invisibles annotations but found " + invisibles);
- }
-
- }
-
- int errors;
- int all;
- int visibles;
- int invisibles;
-}