mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
6987760: remove 308 support from JDK7
Reviewed-by: darcy, mcimadamore
This commit is contained in:
parent
564807c643
commit
bf00a77f2d
@ -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();
|
||||
}
|
||||
@ -53,7 +53,7 @@ public interface MethodTree extends Tree {
|
||||
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
|
||||
|
||||
@ -46,7 +46,7 @@ public interface Tree {
|
||||
*/
|
||||
public enum Kind {
|
||||
|
||||
ANNOTATED_TYPE(AnnotatedTypeTree.class),
|
||||
//308 ANNOTATED_TYPE(AnnotatedTypeTree.class),
|
||||
|
||||
/**
|
||||
* Used for instances of {@link AnnotationTree}.
|
||||
|
||||
@ -57,7 +57,7 @@ package com.sun.source.tree;
|
||||
* @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);
|
||||
|
||||
@ -47,5 +47,5 @@ import javax.lang.model.element.Name;
|
||||
public interface TypeParameterTree extends Tree {
|
||||
Name getName();
|
||||
List<? extends Tree> getBounds();
|
||||
List<? extends AnnotationTree> getAnnotations();
|
||||
//308 List<? extends AnnotationTree> getAnnotations();
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -248,9 +248,9 @@ public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
|
||||
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);
|
||||
|
||||
@ -138,7 +138,7 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
|
||||
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 class TreeScanner<R,P> implements TreeVisitor<R,P> {
|
||||
}
|
||||
|
||||
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 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
|
||||
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;
|
||||
|
||||
@ -55,8 +55,8 @@ public class TypeAnnotations {
|
||||
}
|
||||
|
||||
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 @@ public class TypeAnnotations {
|
||||
}
|
||||
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;
|
||||
|
||||
@ -75,42 +75,6 @@ public class JavacParser implements Parser {
|
||||
/** 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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
*/
|
||||
boolean allowAnnotations;
|
||||
|
||||
/** Switch: should we recognize type annotations?
|
||||
*/
|
||||
boolean allowTypeAnnotations;
|
||||
|
||||
/** Switch: should we recognize automatic resource management?
|
||||
*/
|
||||
boolean allowTWR;
|
||||
@ -620,33 +574,7 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
* | [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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
// 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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
typeArgs = null;
|
||||
}
|
||||
} else {
|
||||
if (!annos.isEmpty()) {
|
||||
if (permitTypeAnnotationsPushBack)
|
||||
typeAnnotationsPushedBack = annos;
|
||||
else
|
||||
return illegal(annos.head.pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1262,7 +1133,6 @@ public class JavacParser implements Parser {
|
||||
S.token() == PLUSPLUS ? JCTree.POSTINC : JCTree.POSTDEC, t));
|
||||
S.nextToken();
|
||||
}
|
||||
|
||||
return toP(t);
|
||||
}
|
||||
|
||||
@ -1400,26 +1270,24 @@ public class JavacParser implements Parser {
|
||||
}
|
||||
|
||||
/** 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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
}
|
||||
}
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
}
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
/** 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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
} 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 @@ public class JavacParser implements Parser {
|
||||
}
|
||||
|
||||
/** 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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
}
|
||||
}
|
||||
|
||||
/** 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 @@ public class JavacParser implements Parser {
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
*/
|
||||
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 @@ public class JavacParser implements Parser {
|
||||
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);
|
||||
|
||||
@ -49,11 +49,11 @@ import javax.tools.StandardJavaFileManager;
|
||||
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 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -1299,9 +1299,9 @@ compiler.err.annotations.not.supported.in.source=\
|
||||
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\
|
||||
|
||||
@ -2067,17 +2067,23 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
||||
}
|
||||
@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() {
|
||||
|
||||
@ -71,12 +71,12 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
|
||||
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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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> {}
|
||||
|
||||
@ -8,9 +8,4 @@ T6881115.java:17:8: compiler.err.annotation.missing.default.value: B, b1
|
||||
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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class TestAnonClassNames {
|
||||
@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 @@ public class TestAnonClassNames {
|
||||
|
||||
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 @@ class ClassNameProber extends JavacTestingAbstractProcessor {
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,7 +357,9 @@ public class TreePosTest {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
@ -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..., ?);
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
@ -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 { }
|
||||
}
|
||||
@ -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 { }
|
||||
@ -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 { }
|
||||
@ -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 { }
|
||||
@ -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(); }
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
AnnotationVersion.java:9:25: compiler.err.type.annotations.not.supported.in.source: 1.6
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
IncompleteArray.java:9:13: compiler.err.illegal.start.of.type
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
IncompleteVararg.java:10:19: compiler.err.illegal.start.of.type
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
IndexArray.java:10:15: compiler.err.illegal.start.of.expr
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -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
|
||||
@ -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 { }
|
||||
@ -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 { };
|
||||
}
|
||||
@ -1,2 +0,0 @@
|
||||
Scopes.java:8:25: compiler.err.cant.resolve: kindname.class, UniqueInner, ,
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
StaticFields.java:10:17: compiler.err.illegal.start.of.expr
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
StaticMethods.java:9:22: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateAnnotationValue.java:10:37: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateTypeAnnotation.java:11:26: compiler.err.duplicate.annotation
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
InvalidLocation.java:11:23: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
MissingAnnotationValue.java:10:23: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateAnnotationValue.java:10:26: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateTypeAnnotation.java:11:15: compiler.err.duplicate.annotation
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
InvalidLocation.java:11:12: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
MissingAnnotationValue.java:10:12: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateAnnotationValue.java:10:31: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateTypeAnnotation.java:10:20: compiler.err.duplicate.annotation
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
InvalidLocation.java:10:17: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
MissingAnnotationValue.java:10:17: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateAnnotationValue.java:10:43: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateTypeAnnotation.java:11:32: compiler.err.duplicate.annotation
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
InvalidLocation.java:11:29: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
MissingAnnotationValue.java:10:29: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateAnnotationValue.java:8:56: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateTypeAnnotation.java:9:38: compiler.err.duplicate.annotation
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
InvalidLocation.java:9:33: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
MissingAnnotationValue.java:8:40: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateAnnotationValue.java:9:29: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateTypeAnnotation.java:10:18: compiler.err.duplicate.annotation
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
InvalidLocation.java:10:15: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
MissingAnnotationValue.java:9:15: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
@ -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(); }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateAnnotationValue.java:10:9: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
||||
@ -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 { }
|
||||
@ -1,2 +0,0 @@
|
||||
DuplicateTypeAnnotation.java:11:12: compiler.err.duplicate.annotation
|
||||
1 error
|
||||
@ -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 { }
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user