mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 19:44:41 +02:00
6855544: add missing files
Co-authored-by: Mahmood Ali <mali@csail.mit.edu> Co-authored-by: Matt Papi <mpapi@csail.mit.edu> Reviewed-by: jjg, mcimadamore, darcy
This commit is contained in:
parent
5a1465b9de
commit
e03ee9130a
151 changed files with 6571 additions and 0 deletions
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2008-2009 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.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();
|
||||
}
|
|
@ -0,0 +1,245 @@
|
|||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,614 @@
|
|||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.classfile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.sun.tools.classfile.ExtendedAnnotation.TargetAttribute.*;
|
||||
|
||||
/**
|
||||
* See JSR 308 specification, section 4.1
|
||||
*
|
||||
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
|
||||
* you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class ExtendedAnnotation {
|
||||
ExtendedAnnotation(ClassReader cr) throws IOException, Annotation.InvalidAnnotation {
|
||||
annotation = new Annotation(cr);
|
||||
position = read_position(cr);
|
||||
}
|
||||
|
||||
public ExtendedAnnotation(ConstantPool constant_pool,
|
||||
Annotation annotation, Position position) {
|
||||
this.annotation = annotation;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public int length() {
|
||||
int n = annotation.length();
|
||||
n += position_length(position);
|
||||
return n;
|
||||
}
|
||||
|
||||
public final Annotation annotation;
|
||||
public final Position position;
|
||||
|
||||
private static Position read_position(ClassReader cr) throws IOException, Annotation.InvalidAnnotation {
|
||||
// Copied from ClassReader
|
||||
int tag = (byte)cr.readUnsignedByte(); // cast to introduce signedness
|
||||
if (!TargetType.isValidTargetTypeValue(tag))
|
||||
throw new Annotation.InvalidAnnotation("invalid type annotation target type value: " + tag);
|
||||
|
||||
TargetType type = TargetType.fromTargetTypeValue(tag);
|
||||
|
||||
Position position = new Position();
|
||||
position.type = type;
|
||||
|
||||
switch (type) {
|
||||
// type case
|
||||
case TYPECAST:
|
||||
case TYPECAST_GENERIC_OR_ARRAY:
|
||||
// object creation
|
||||
case INSTANCEOF:
|
||||
case INSTANCEOF_GENERIC_OR_ARRAY:
|
||||
// new expression
|
||||
case NEW:
|
||||
case NEW_GENERIC_OR_ARRAY:
|
||||
position.offset = cr.readUnsignedShort();
|
||||
break;
|
||||
// local variable
|
||||
case LOCAL_VARIABLE:
|
||||
case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
|
||||
int table_length = cr.readUnsignedShort();
|
||||
position.lvarOffset = new int[table_length];
|
||||
position.lvarLength = new int[table_length];
|
||||
position.lvarIndex = new int[table_length];
|
||||
for (int i = 0; i < table_length; ++i) {
|
||||
position.lvarOffset[i] = cr.readUnsignedShort();
|
||||
position.lvarLength[i] = cr.readUnsignedShort();
|
||||
position.lvarIndex[i] = cr.readUnsignedShort();
|
||||
}
|
||||
break;
|
||||
// method receiver
|
||||
case METHOD_RECEIVER:
|
||||
// Do nothing
|
||||
break;
|
||||
// type parameters
|
||||
case CLASS_TYPE_PARAMETER:
|
||||
case METHOD_TYPE_PARAMETER:
|
||||
position.parameter_index = cr.readUnsignedByte();
|
||||
break;
|
||||
// type parameter bounds
|
||||
case CLASS_TYPE_PARAMETER_BOUND:
|
||||
case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
|
||||
case METHOD_TYPE_PARAMETER_BOUND:
|
||||
case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
|
||||
position.parameter_index = cr.readUnsignedByte();
|
||||
position.bound_index = cr.readUnsignedByte();
|
||||
break;
|
||||
// wildcards
|
||||
case WILDCARD_BOUND:
|
||||
case WILDCARD_BOUND_GENERIC_OR_ARRAY:
|
||||
position.wildcard_position = read_position(cr);
|
||||
break;
|
||||
// Class extends and implements clauses
|
||||
case CLASS_EXTENDS:
|
||||
case CLASS_EXTENDS_GENERIC_OR_ARRAY:
|
||||
position.type_index = cr.readUnsignedByte();
|
||||
break;
|
||||
// throws
|
||||
case THROWS:
|
||||
position.type_index = cr.readUnsignedByte();
|
||||
break;
|
||||
case CLASS_LITERAL:
|
||||
case CLASS_LITERAL_GENERIC_OR_ARRAY:
|
||||
position.offset = cr.readUnsignedShort();
|
||||
break;
|
||||
// method parameter: not specified
|
||||
case METHOD_PARAMETER_GENERIC_OR_ARRAY:
|
||||
position.parameter_index = cr.readUnsignedByte();
|
||||
break;
|
||||
// method type argument: wasn't specified
|
||||
case NEW_TYPE_ARGUMENT:
|
||||
case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
|
||||
case METHOD_TYPE_ARGUMENT:
|
||||
case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
|
||||
position.offset = cr.readUnsignedShort();
|
||||
position.type_index = cr.readUnsignedByte();
|
||||
break;
|
||||
// We don't need to worry abut these
|
||||
case METHOD_RETURN_GENERIC_OR_ARRAY:
|
||||
case FIELD_GENERIC_OR_ARRAY:
|
||||
break;
|
||||
case UNKNOWN:
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("Cannot be here");
|
||||
}
|
||||
|
||||
if (type.hasLocation()) {
|
||||
int len = cr.readUnsignedShort();
|
||||
List<Integer> loc = new ArrayList<Integer>(len);
|
||||
for (int i = 0; i < len; i++)
|
||||
loc.add(cr.readUnsignedByte());
|
||||
position.location = loc;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
private static int position_length(Position pos) {
|
||||
int n = 0;
|
||||
n += 1; // target_type
|
||||
switch (pos.type) {
|
||||
// type case
|
||||
case TYPECAST:
|
||||
case TYPECAST_GENERIC_OR_ARRAY:
|
||||
// object creation
|
||||
case INSTANCEOF:
|
||||
case INSTANCEOF_GENERIC_OR_ARRAY:
|
||||
// new expression
|
||||
case NEW:
|
||||
case NEW_GENERIC_OR_ARRAY:
|
||||
n += 2;
|
||||
break;
|
||||
// local variable
|
||||
case LOCAL_VARIABLE:
|
||||
case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
|
||||
n += 2; // table_length;
|
||||
int table_length = pos.lvarOffset.length;
|
||||
n += 2 * table_length; // offset
|
||||
n += 2 * table_length; // length;
|
||||
n += 2 * table_length; // index
|
||||
break;
|
||||
// method receiver
|
||||
case METHOD_RECEIVER:
|
||||
// Do nothing
|
||||
break;
|
||||
// type parameters
|
||||
case CLASS_TYPE_PARAMETER:
|
||||
case METHOD_TYPE_PARAMETER:
|
||||
n += 1; // parameter_index;
|
||||
break;
|
||||
// type parameter bounds
|
||||
case CLASS_TYPE_PARAMETER_BOUND:
|
||||
case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
|
||||
case METHOD_TYPE_PARAMETER_BOUND:
|
||||
case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
|
||||
n += 1; // parameter_index
|
||||
n += 1; // bound_index
|
||||
break;
|
||||
case WILDCARD_BOUND:
|
||||
case WILDCARD_BOUND_GENERIC_OR_ARRAY:
|
||||
n += position_length(pos.wildcard_position);
|
||||
break;
|
||||
// Class extends and implements clauses
|
||||
case CLASS_EXTENDS:
|
||||
case CLASS_EXTENDS_GENERIC_OR_ARRAY:
|
||||
n += 1; // type_index
|
||||
break;
|
||||
// throws
|
||||
case THROWS:
|
||||
n += 1; // type_index
|
||||
break;
|
||||
case CLASS_LITERAL:
|
||||
case CLASS_LITERAL_GENERIC_OR_ARRAY:
|
||||
n += 1; // offset
|
||||
break;
|
||||
// method parameter: not specified
|
||||
case METHOD_PARAMETER_GENERIC_OR_ARRAY:
|
||||
n += 1; // parameter_index
|
||||
break;
|
||||
// method type argument: wasn't specified
|
||||
case NEW_TYPE_ARGUMENT:
|
||||
case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
|
||||
case METHOD_TYPE_ARGUMENT:
|
||||
case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
|
||||
n += 2; // offset
|
||||
n += 1; // type index
|
||||
break;
|
||||
// We don't need to worry abut these
|
||||
case METHOD_RETURN_GENERIC_OR_ARRAY:
|
||||
case FIELD_GENERIC_OR_ARRAY:
|
||||
break;
|
||||
case UNKNOWN:
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
if (pos.type.hasLocation()) {
|
||||
n += 2; // length
|
||||
n += 1 * pos.location.size(); // actual array size
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
// Code duplicated from com.sun.tools.javac.code.TypeAnnotations.Position
|
||||
public static class Position {
|
||||
|
||||
public TargetType type = TargetType.UNKNOWN;
|
||||
|
||||
// For generic/array types.
|
||||
public List<Integer> location = new ArrayList<Integer>();
|
||||
|
||||
// Tree position.
|
||||
public int pos = -1;
|
||||
|
||||
// For typecasts, type tests, new (and locals, as start_pc).
|
||||
public int offset = -1;
|
||||
|
||||
// For locals.
|
||||
public int[] lvarOffset = new int[] { -1 };
|
||||
public int[] lvarLength = new int[] { -1 };
|
||||
public int[] lvarIndex = new int[] { -1 };
|
||||
|
||||
// For type parameter bound
|
||||
public int bound_index = -1;
|
||||
|
||||
// For type parameter and method parameter
|
||||
public int parameter_index = -1;
|
||||
|
||||
// For class extends, implements, and throws classes
|
||||
public int type_index = -2;
|
||||
|
||||
// For wildcards
|
||||
public Position wildcard_position = null;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('[');
|
||||
sb.append(type);
|
||||
|
||||
switch (type) {
|
||||
// type case
|
||||
case TYPECAST:
|
||||
case TYPECAST_GENERIC_OR_ARRAY:
|
||||
// object creation
|
||||
case INSTANCEOF:
|
||||
case INSTANCEOF_GENERIC_OR_ARRAY:
|
||||
// new expression
|
||||
case NEW:
|
||||
case NEW_GENERIC_OR_ARRAY:
|
||||
case NEW_TYPE_ARGUMENT:
|
||||
case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
|
||||
sb.append(", offset = ");
|
||||
sb.append(offset);
|
||||
break;
|
||||
// local variable
|
||||
case LOCAL_VARIABLE:
|
||||
case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
|
||||
sb.append(", {");
|
||||
for (int i = 0; i < lvarOffset.length; ++i) {
|
||||
if (i != 0) sb.append("; ");
|
||||
sb.append(", start_pc = ");
|
||||
sb.append(lvarOffset[i]);
|
||||
sb.append(", length = ");
|
||||
sb.append(lvarLength[i]);
|
||||
sb.append(", index = ");
|
||||
sb.append(lvarIndex[i]);
|
||||
}
|
||||
sb.append("}");
|
||||
break;
|
||||
// method receiver
|
||||
case METHOD_RECEIVER:
|
||||
// Do nothing
|
||||
break;
|
||||
// type parameters
|
||||
case CLASS_TYPE_PARAMETER:
|
||||
case METHOD_TYPE_PARAMETER:
|
||||
sb.append(", param_index = ");
|
||||
sb.append(parameter_index);
|
||||
break;
|
||||
// type parameters bound
|
||||
case CLASS_TYPE_PARAMETER_BOUND:
|
||||
case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
|
||||
case METHOD_TYPE_PARAMETER_BOUND:
|
||||
case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
|
||||
sb.append(", param_index = ");
|
||||
sb.append(parameter_index);
|
||||
sb.append(", bound_index = ");
|
||||
sb.append(bound_index);
|
||||
break;
|
||||
// wildcard
|
||||
case WILDCARD_BOUND:
|
||||
case WILDCARD_BOUND_GENERIC_OR_ARRAY:
|
||||
sb.append(", wild_card = ");
|
||||
sb.append(wildcard_position);
|
||||
break;
|
||||
// Class extends and implements clauses
|
||||
case CLASS_EXTENDS:
|
||||
case CLASS_EXTENDS_GENERIC_OR_ARRAY:
|
||||
sb.append(", type_index = ");
|
||||
sb.append(type_index);
|
||||
break;
|
||||
// throws
|
||||
case THROWS:
|
||||
sb.append(", type_index = ");
|
||||
sb.append(type_index);
|
||||
break;
|
||||
case CLASS_LITERAL:
|
||||
sb.append(", offset = ");
|
||||
sb.append(offset);
|
||||
break;
|
||||
// method parameter: not specified
|
||||
case METHOD_PARAMETER_GENERIC_OR_ARRAY:
|
||||
sb.append(", param_index = ");
|
||||
sb.append(parameter_index);
|
||||
break;
|
||||
// method type argument: wasn't specified
|
||||
case METHOD_TYPE_ARGUMENT:
|
||||
case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
|
||||
sb.append(", offset = ");
|
||||
sb.append(offset);
|
||||
sb.append(", type_index = ");
|
||||
sb.append(type_index);
|
||||
break;
|
||||
// We don't need to worry abut these
|
||||
case METHOD_RETURN_GENERIC_OR_ARRAY:
|
||||
case FIELD_GENERIC_OR_ARRAY:
|
||||
break;
|
||||
case UNKNOWN:
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("unknown type: " + type);
|
||||
}
|
||||
|
||||
// Append location data for generics/arrays.
|
||||
if (type.hasLocation()) {
|
||||
sb.append(", location = (");
|
||||
sb.append(location);
|
||||
sb.append(")");
|
||||
}
|
||||
|
||||
sb.append(", pos = ");
|
||||
sb.append(pos);
|
||||
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
// Code duplicated from com.sun.tools.javac.comp.TargetType
|
||||
public enum TargetType {
|
||||
|
||||
/** For annotations on typecasts. */
|
||||
TYPECAST(0x00),
|
||||
|
||||
/** For annotations on a type argument or nested array of a typecast. */
|
||||
TYPECAST_GENERIC_OR_ARRAY(0x01, HasLocation),
|
||||
|
||||
/** For annotations on type tests. */
|
||||
INSTANCEOF(0x02),
|
||||
|
||||
/** For annotations on a type argument or nested array of a type test. */
|
||||
INSTANCEOF_GENERIC_OR_ARRAY(0x03, HasLocation),
|
||||
|
||||
/** For annotations on object creation expressions. */
|
||||
NEW(0x04),
|
||||
|
||||
/**
|
||||
* For annotations on a type argument or nested array of an object creation
|
||||
* expression.
|
||||
*/
|
||||
NEW_GENERIC_OR_ARRAY(0x05, HasLocation),
|
||||
|
||||
|
||||
/** For annotations on the method receiver. */
|
||||
METHOD_RECEIVER(0x06),
|
||||
|
||||
// invalid location
|
||||
// METHOD_RECEIVER_GENERIC_OR_ARRAY(0x07, HasLocation),
|
||||
|
||||
/** For annotations on local variables. */
|
||||
LOCAL_VARIABLE(0x08),
|
||||
|
||||
/** For annotations on a type argument or nested array of a local. */
|
||||
LOCAL_VARIABLE_GENERIC_OR_ARRAY(0x09, HasLocation),
|
||||
|
||||
// already handled by regular annotations
|
||||
// METHOD_RETURN(0x0A),
|
||||
|
||||
/**
|
||||
* For annotations on a type argument or nested array of a method return
|
||||
* type.
|
||||
*/
|
||||
METHOD_RETURN_GENERIC_OR_ARRAY(0x0B, HasLocation),
|
||||
|
||||
// already handled by regular annotations
|
||||
// METHOD_PARAMETER(0x0C),
|
||||
|
||||
/** For annotations on a type argument or nested array of a method parameter. */
|
||||
METHOD_PARAMETER_GENERIC_OR_ARRAY(0x0D, HasLocation),
|
||||
|
||||
// already handled by regular annotations
|
||||
// FIELD(0x0E),
|
||||
|
||||
/** For annotations on a type argument or nested array of a field. */
|
||||
FIELD_GENERIC_OR_ARRAY(0x0F, HasLocation),
|
||||
|
||||
/** For annotations on a bound of a type parameter of a class. */
|
||||
CLASS_TYPE_PARAMETER_BOUND(0x10, HasBound, HasParameter),
|
||||
|
||||
/**
|
||||
* For annotations on a type argument or nested array of a bound of a type
|
||||
* parameter of a class.
|
||||
*/
|
||||
CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x11, HasBound, HasLocation, HasParameter),
|
||||
|
||||
/** For annotations on a bound of a type parameter of a method. */
|
||||
METHOD_TYPE_PARAMETER_BOUND(0x12, HasBound, HasParameter),
|
||||
|
||||
/**
|
||||
* For annotations on a type argument or nested array of a bound of a type
|
||||
* parameter of a method.
|
||||
*/
|
||||
METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x13, HasBound, HasLocation, HasParameter),
|
||||
|
||||
/** For annotations on the type of an "extends" or "implements" clause. */
|
||||
CLASS_EXTENDS(0x14),
|
||||
|
||||
/** For annotations on the inner type of an "extends" or "implements" clause. */
|
||||
CLASS_EXTENDS_GENERIC_OR_ARRAY(0x15, HasLocation),
|
||||
|
||||
/** For annotations on a throws clause in a method declaration. */
|
||||
THROWS(0x16),
|
||||
|
||||
// invalid location
|
||||
// THROWS_GENERIC_OR_ARRAY(0x17, HasLocation),
|
||||
|
||||
/** For annotations in type arguments of object creation expressions. */
|
||||
NEW_TYPE_ARGUMENT(0x18),
|
||||
NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x19, HasLocation),
|
||||
|
||||
METHOD_TYPE_ARGUMENT(0x1A),
|
||||
METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x1B, HasLocation),
|
||||
|
||||
WILDCARD_BOUND(0x1C, HasBound),
|
||||
WILDCARD_BOUND_GENERIC_OR_ARRAY(0x1D, HasBound, HasLocation),
|
||||
|
||||
CLASS_LITERAL(0x1E),
|
||||
CLASS_LITERAL_GENERIC_OR_ARRAY(0x1F, HasLocation),
|
||||
|
||||
METHOD_TYPE_PARAMETER(0x20, HasParameter),
|
||||
|
||||
// invalid location
|
||||
// METHOD_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x21, HasLocation, HasParameter),
|
||||
|
||||
CLASS_TYPE_PARAMETER(0x22, HasParameter),
|
||||
|
||||
// invalid location
|
||||
// CLASS_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x23, HasLocation, HasParameter),
|
||||
|
||||
/** For annotations with an unknown target. */
|
||||
UNKNOWN(-1);
|
||||
|
||||
static final int MAXIMUM_TARGET_TYPE_VALUE = 0x22;
|
||||
|
||||
private final int targetTypeValue;
|
||||
private Set<TargetAttribute> flags;
|
||||
|
||||
TargetType(int targetTypeValue, TargetAttribute... attrs) {
|
||||
if (targetTypeValue < Byte.MIN_VALUE
|
||||
|| targetTypeValue > Byte.MAX_VALUE)
|
||||
throw new AssertionError("attribute type value needs to be a byte: " + targetTypeValue);
|
||||
this.targetTypeValue = (byte)targetTypeValue;
|
||||
this.flags = EnumSet.noneOf(TargetAttribute.class);
|
||||
for (TargetAttribute attr : attrs)
|
||||
this.flags.add(attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not this TargetType represents an annotation whose
|
||||
* target is an inner type of a generic or array type.
|
||||
*
|
||||
* @return true if this TargetType represents an annotation on an inner
|
||||
* type, false otherwise
|
||||
*/
|
||||
public boolean hasLocation() {
|
||||
return flags.contains(HasLocation);
|
||||
}
|
||||
|
||||
public TargetType getGenericComplement() {
|
||||
if (hasLocation())
|
||||
return this;
|
||||
else
|
||||
return fromTargetTypeValue(targetTypeValue() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not this TargetType represents an annotation whose
|
||||
* target has a parameter index.
|
||||
*
|
||||
* @return true if this TargetType has a parameter index,
|
||||
* false otherwise
|
||||
*/
|
||||
public boolean hasParameter() {
|
||||
return flags.contains(HasParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not this TargetType represents an annotation whose
|
||||
* target is a type parameter bound.
|
||||
*
|
||||
* @return true if this TargetType represents an type parameter bound
|
||||
* annotation, false otherwise
|
||||
*/
|
||||
public boolean hasBound() {
|
||||
return flags.contains(HasBound);
|
||||
}
|
||||
|
||||
public int targetTypeValue() {
|
||||
return this.targetTypeValue;
|
||||
}
|
||||
|
||||
private static TargetType[] targets = null;
|
||||
|
||||
private static TargetType[] buildTargets() {
|
||||
TargetType[] targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
|
||||
TargetType[] alltargets = values();
|
||||
for (TargetType target : alltargets)
|
||||
if (target.targetTypeValue >= 0)
|
||||
targets[target.targetTypeValue] = target;
|
||||
for (int i = 0; i <= MAXIMUM_TARGET_TYPE_VALUE; ++i)
|
||||
if (targets[i] == null)
|
||||
targets[i] = UNKNOWN;
|
||||
return targets;
|
||||
}
|
||||
|
||||
public static boolean isValidTargetTypeValue(int tag) {
|
||||
if (targets == null)
|
||||
targets = buildTargets();
|
||||
|
||||
if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
|
||||
return true;
|
||||
|
||||
return (tag >= 0 && tag < targets.length);
|
||||
}
|
||||
|
||||
public static TargetType fromTargetTypeValue(int tag) {
|
||||
if (targets == null)
|
||||
targets = buildTargets();
|
||||
|
||||
if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
|
||||
return UNKNOWN;
|
||||
|
||||
if (tag < 0 || tag >= targets.length)
|
||||
throw new IllegalArgumentException("Unknown TargetType: " + tag);
|
||||
return targets[tag];
|
||||
}
|
||||
}
|
||||
|
||||
static enum TargetAttribute {
|
||||
HasLocation, HasParameter, HasBound;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.classfile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* See JSR 308 specification, section 4.1
|
||||
*
|
||||
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
|
||||
* you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class RuntimeInvisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute {
|
||||
RuntimeInvisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length)
|
||||
throws IOException, Annotation.InvalidAnnotation {
|
||||
super(cr, name_index, length);
|
||||
}
|
||||
|
||||
public RuntimeInvisibleTypeAnnotations_attribute(ConstantPool cp, ExtendedAnnotation[] annotations)
|
||||
throws ConstantPoolException {
|
||||
this(cp.getUTF8Index(Attribute.RuntimeInvisibleTypeAnnotations), annotations);
|
||||
}
|
||||
|
||||
public RuntimeInvisibleTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) {
|
||||
super(name_index, annotations);
|
||||
}
|
||||
|
||||
public <R, P> R accept(Visitor<R, P> visitor, P p) {
|
||||
return visitor.visitRuntimeInvisibleTypeAnnotations(this, p);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.classfile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* See JSR 308 specification, section 4
|
||||
*
|
||||
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
|
||||
* you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public abstract class RuntimeTypeAnnotations_attribute extends Attribute {
|
||||
protected RuntimeTypeAnnotations_attribute(ClassReader cr, int name_index, int length)
|
||||
throws IOException, Annotation.InvalidAnnotation {
|
||||
super(name_index, length);
|
||||
int num_annotations = cr.readUnsignedShort();
|
||||
annotations = new ExtendedAnnotation[num_annotations];
|
||||
for (int i = 0; i < annotations.length; i++)
|
||||
annotations[i] = new ExtendedAnnotation(cr);
|
||||
}
|
||||
|
||||
protected RuntimeTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) {
|
||||
super(name_index, length(annotations));
|
||||
this.annotations = annotations;
|
||||
}
|
||||
|
||||
private static int length(ExtendedAnnotation[] annos) {
|
||||
int n = 2;
|
||||
for (ExtendedAnnotation anno: annos)
|
||||
n += anno.length();
|
||||
return n;
|
||||
}
|
||||
|
||||
public final ExtendedAnnotation[] annotations;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.classfile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* See JSR 308 specification, section 4.1
|
||||
*
|
||||
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
|
||||
* you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class RuntimeVisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute {
|
||||
RuntimeVisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length)
|
||||
throws IOException, Annotation.InvalidAnnotation {
|
||||
super(cr, name_index, length);
|
||||
}
|
||||
|
||||
public RuntimeVisibleTypeAnnotations_attribute(ConstantPool cp, ExtendedAnnotation[] annotations)
|
||||
throws ConstantPoolException {
|
||||
this(cp.getUTF8Index(Attribute.RuntimeVisibleTypeAnnotations), annotations);
|
||||
}
|
||||
|
||||
public RuntimeVisibleTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) {
|
||||
super(name_index, annotations);
|
||||
}
|
||||
|
||||
public <R, P> R accept(Visitor<R, P> visitor, P p) {
|
||||
return visitor.visitRuntimeVisibleTypeAnnotations(this, p);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,266 @@
|
|||
/*
|
||||
* Copyright 2008-2009 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.javac.code;
|
||||
|
||||
import static com.sun.tools.javac.code.TargetType.TargetAttribute.*;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Describes the type of program element an extended annotation (or extended
|
||||
* compound attribute) targets.
|
||||
*
|
||||
* By comparison, a Tree.Kind has enum values for all elements in the AST, and
|
||||
* it does not provide enough resolution for type arguments (i.e., whether an
|
||||
* annotation targets a type argument in a local variable, method return type,
|
||||
* or a typecast).
|
||||
*
|
||||
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
|
||||
* you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public enum TargetType {
|
||||
|
||||
//
|
||||
// Some target types are commented out, because Java doesn't permit such
|
||||
// targets. They are included here to confirm that their omission is
|
||||
// intentional omission not an accidental omission.
|
||||
//
|
||||
|
||||
/** For annotations on typecasts. */
|
||||
TYPECAST(0x00),
|
||||
|
||||
/** For annotations on a type argument or nested array of a typecast. */
|
||||
TYPECAST_GENERIC_OR_ARRAY(0x01, HasLocation),
|
||||
|
||||
/** For annotations on type tests. */
|
||||
INSTANCEOF(0x02),
|
||||
|
||||
/** For annotations on a type argument or nested array of a type test. */
|
||||
INSTANCEOF_GENERIC_OR_ARRAY(0x03, HasLocation),
|
||||
|
||||
/** For annotations on object creation expressions. */
|
||||
NEW(0x04),
|
||||
|
||||
/**
|
||||
* For annotations on a type argument or nested array of an object creation
|
||||
* expression.
|
||||
*/
|
||||
NEW_GENERIC_OR_ARRAY(0x05, HasLocation),
|
||||
|
||||
|
||||
/** For annotations on the method receiver. */
|
||||
METHOD_RECEIVER(0x06),
|
||||
|
||||
// invalid location
|
||||
//@Deprecated METHOD_RECEIVER_GENERIC_OR_ARRAY(0x07, HasLocation),
|
||||
|
||||
/** For annotations on local variables. */
|
||||
LOCAL_VARIABLE(0x08),
|
||||
|
||||
/** For annotations on a type argument or nested array of a local. */
|
||||
LOCAL_VARIABLE_GENERIC_OR_ARRAY(0x09, HasLocation),
|
||||
|
||||
// handled by regular annotations
|
||||
//@Deprecated METHOD_RETURN(0x0A),
|
||||
|
||||
/**
|
||||
* For annotations on a type argument or nested array of a method return
|
||||
* type.
|
||||
*/
|
||||
METHOD_RETURN_GENERIC_OR_ARRAY(0x0B, HasLocation),
|
||||
|
||||
// handled by regular annotations
|
||||
//@Deprecated METHOD_PARAMETER(0x0C),
|
||||
|
||||
/** For annotations on a type argument or nested array of a method parameter. */
|
||||
METHOD_PARAMETER_GENERIC_OR_ARRAY(0x0D, HasLocation),
|
||||
|
||||
// handled by regular annotations
|
||||
//@Deprecated FIELD(0x0E),
|
||||
|
||||
/** For annotations on a type argument or nested array of a field. */
|
||||
FIELD_GENERIC_OR_ARRAY(0x0F, HasLocation),
|
||||
|
||||
/** For annotations on a bound of a type parameter of a class. */
|
||||
CLASS_TYPE_PARAMETER_BOUND(0x10, HasBound, HasParameter),
|
||||
|
||||
/**
|
||||
* For annotations on a type argument or nested array of a bound of a type
|
||||
* parameter of a class.
|
||||
*/
|
||||
CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x11, HasBound, HasLocation, HasParameter),
|
||||
|
||||
/** For annotations on a bound of a type parameter of a method. */
|
||||
METHOD_TYPE_PARAMETER_BOUND(0x12, HasBound, HasParameter),
|
||||
|
||||
/**
|
||||
* For annotations on a type argument or nested array of a bound of a type
|
||||
* parameter of a method.
|
||||
*/
|
||||
METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x13, HasBound, HasLocation, HasParameter),
|
||||
|
||||
/** For annotations on the type of an "extends" or "implements" clause. */
|
||||
CLASS_EXTENDS(0x14),
|
||||
|
||||
/** For annotations on the inner type of an "extends" or "implements" clause. */
|
||||
CLASS_EXTENDS_GENERIC_OR_ARRAY(0x15, HasLocation),
|
||||
|
||||
/** For annotations on a throws clause in a method declaration. */
|
||||
THROWS(0x16),
|
||||
|
||||
// invalid location
|
||||
//@Deprecated THROWS_GENERIC_OR_ARRAY(0x17, HasLocation),
|
||||
|
||||
/** For annotations in type arguments of object creation expressions. */
|
||||
NEW_TYPE_ARGUMENT(0x18),
|
||||
NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x19, HasLocation),
|
||||
|
||||
METHOD_TYPE_ARGUMENT(0x1A),
|
||||
METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x1B, HasLocation),
|
||||
|
||||
WILDCARD_BOUND(0x1C, HasBound),
|
||||
WILDCARD_BOUND_GENERIC_OR_ARRAY(0x1D, HasBound, HasLocation),
|
||||
|
||||
CLASS_LITERAL(0x1E),
|
||||
CLASS_LITERAL_GENERIC_OR_ARRAY(0x1F, HasLocation),
|
||||
|
||||
METHOD_TYPE_PARAMETER(0x20, HasParameter),
|
||||
|
||||
// invalid location
|
||||
//@Deprecated METHOD_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x21, HasLocation, HasParameter),
|
||||
|
||||
CLASS_TYPE_PARAMETER(0x22, HasParameter),
|
||||
|
||||
// invalid location
|
||||
//@Deprecated CLASS_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x23, HasLocation, HasParameter),
|
||||
|
||||
/** For annotations with an unknown target. */
|
||||
UNKNOWN(-1);
|
||||
|
||||
static final int MAXIMUM_TARGET_TYPE_VALUE = 0x22;
|
||||
|
||||
private final int targetTypeValue;
|
||||
private Set<TargetAttribute> flags;
|
||||
|
||||
TargetType(int targetTypeValue, TargetAttribute... attributes) {
|
||||
if (targetTypeValue < Byte.MIN_VALUE
|
||||
|| targetTypeValue > Byte.MAX_VALUE)
|
||||
throw new AssertionError("attribute type value needs to be a byte: " + targetTypeValue);
|
||||
this.targetTypeValue = (byte)targetTypeValue;
|
||||
flags = EnumSet.noneOf(TargetAttribute.class);
|
||||
for (TargetAttribute attr : attributes)
|
||||
flags.add(attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not this TargetType represents an annotation whose
|
||||
* target is an inner type of a generic or array type.
|
||||
*
|
||||
* @return true if this TargetType represents an annotation on an inner
|
||||
* type, false otherwise
|
||||
*/
|
||||
public boolean hasLocation() {
|
||||
return flags.contains(HasLocation);
|
||||
}
|
||||
|
||||
public TargetType getGenericComplement() {
|
||||
if (hasLocation())
|
||||
return this;
|
||||
else
|
||||
return fromTargetTypeValue(targetTypeValue() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not this TargetType represents an annotation whose
|
||||
* target has a parameter index.
|
||||
*
|
||||
* @return true if this TargetType has a parameter index,
|
||||
* false otherwise
|
||||
*/
|
||||
public boolean hasParameter() {
|
||||
return flags.contains(HasParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not this TargetType represents an annotation whose
|
||||
* target is a type parameter bound.
|
||||
*
|
||||
* @return true if this TargetType represents an type parameter bound
|
||||
* annotation, false otherwise
|
||||
*/
|
||||
public boolean hasBound() {
|
||||
return flags.contains(HasBound);
|
||||
}
|
||||
|
||||
public int targetTypeValue() {
|
||||
return this.targetTypeValue;
|
||||
}
|
||||
|
||||
private static TargetType[] targets = null;
|
||||
|
||||
private static TargetType[] buildTargets() {
|
||||
TargetType[] targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
|
||||
TargetType[] alltargets = values();
|
||||
for (TargetType target : alltargets) {
|
||||
if (target.targetTypeValue >= 0)
|
||||
targets[target.targetTypeValue] = target;
|
||||
}
|
||||
for (int i = 0; i <= MAXIMUM_TARGET_TYPE_VALUE; ++i) {
|
||||
if (targets[i] == null)
|
||||
targets[i] = UNKNOWN;
|
||||
}
|
||||
return targets;
|
||||
}
|
||||
|
||||
public static boolean isValidTargetTypeValue(int tag) {
|
||||
if (targets == null)
|
||||
targets = buildTargets();
|
||||
|
||||
if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
|
||||
return true;
|
||||
|
||||
return (tag >= 0 && tag < targets.length);
|
||||
}
|
||||
|
||||
public static TargetType fromTargetTypeValue(int tag) {
|
||||
if (targets == null)
|
||||
targets = buildTargets();
|
||||
|
||||
if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
|
||||
return UNKNOWN;
|
||||
|
||||
if (tag < 0 || tag >= targets.length)
|
||||
throw new IllegalArgumentException("Unknown TargetType: " + tag);
|
||||
return targets[tag];
|
||||
}
|
||||
|
||||
static enum TargetAttribute {
|
||||
HasLocation, HasParameter, HasBound;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.javac.code;
|
||||
|
||||
import com.sun.tools.javac.util.*;
|
||||
|
||||
/** A type annotation position.
|
||||
*
|
||||
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
|
||||
* you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class TypeAnnotationPosition {
|
||||
|
||||
public TargetType type = TargetType.UNKNOWN;
|
||||
|
||||
// For generic/array types.
|
||||
public List<Integer> location = List.nil();
|
||||
|
||||
// Tree position.
|
||||
public int pos = -1;
|
||||
|
||||
// For typecasts, type tests, new (and locals, as start_pc).
|
||||
public int offset = -1;
|
||||
|
||||
// For locals. arrays same length
|
||||
public int[] lvarOffset = new int[] { -1 };
|
||||
public int[] lvarLength = new int[] { -1 };
|
||||
public int[] lvarIndex = new int[] { -1 };
|
||||
|
||||
// For type parameter bound
|
||||
public int bound_index = -1;
|
||||
|
||||
// For type parameter and method parameter
|
||||
public int parameter_index = -1;
|
||||
|
||||
// For class extends, implements, and throws classes
|
||||
public int type_index = -2;
|
||||
|
||||
// For wildcards
|
||||
public TypeAnnotationPosition wildcard_position = null;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('[');
|
||||
sb.append(type);
|
||||
|
||||
switch (type) {
|
||||
// type case
|
||||
case TYPECAST:
|
||||
case TYPECAST_GENERIC_OR_ARRAY:
|
||||
// object creation
|
||||
case INSTANCEOF:
|
||||
case INSTANCEOF_GENERIC_OR_ARRAY:
|
||||
// new expression
|
||||
case NEW:
|
||||
case NEW_GENERIC_OR_ARRAY:
|
||||
case NEW_TYPE_ARGUMENT:
|
||||
case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
|
||||
sb.append(", offset = ");
|
||||
sb.append(offset);
|
||||
break;
|
||||
// local variable
|
||||
case LOCAL_VARIABLE:
|
||||
case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
|
||||
sb.append(", {");
|
||||
for (int i = 0; i < lvarOffset.length; ++i) {
|
||||
if (i != 0) sb.append("; ");
|
||||
sb.append(", start_pc = ");
|
||||
sb.append(lvarOffset[i]);
|
||||
sb.append(", length = ");
|
||||
sb.append(lvarLength[i]);
|
||||
sb.append(", index = ");
|
||||
sb.append(lvarIndex[i]);
|
||||
}
|
||||
sb.append("}");
|
||||
break;
|
||||
// method receiver
|
||||
case METHOD_RECEIVER:
|
||||
// Do nothing
|
||||
break;
|
||||
// type parameters
|
||||
case CLASS_TYPE_PARAMETER:
|
||||
case METHOD_TYPE_PARAMETER:
|
||||
sb.append(", param_index = ");
|
||||
sb.append(parameter_index);
|
||||
break;
|
||||
// type parameters bound
|
||||
case CLASS_TYPE_PARAMETER_BOUND:
|
||||
case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
|
||||
case METHOD_TYPE_PARAMETER_BOUND:
|
||||
case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
|
||||
sb.append(", param_index = ");
|
||||
sb.append(parameter_index);
|
||||
sb.append(", bound_index = ");
|
||||
sb.append(bound_index);
|
||||
break;
|
||||
// wildcard
|
||||
case WILDCARD_BOUND:
|
||||
case WILDCARD_BOUND_GENERIC_OR_ARRAY:
|
||||
sb.append(", wild_card = ");
|
||||
sb.append(wildcard_position);
|
||||
break;
|
||||
// Class extends and implements clauses
|
||||
case CLASS_EXTENDS:
|
||||
case CLASS_EXTENDS_GENERIC_OR_ARRAY:
|
||||
sb.append(", type_index = ");
|
||||
sb.append(type_index);
|
||||
break;
|
||||
// throws
|
||||
case THROWS:
|
||||
sb.append(", type_index = ");
|
||||
sb.append(type_index);
|
||||
break;
|
||||
case CLASS_LITERAL:
|
||||
sb.append(", offset = ");
|
||||
sb.append(offset);
|
||||
break;
|
||||
// method parameter: not specified
|
||||
case METHOD_PARAMETER_GENERIC_OR_ARRAY:
|
||||
sb.append(", param_index = ");
|
||||
sb.append(parameter_index);
|
||||
break;
|
||||
// method type argument: wasn't specified
|
||||
case METHOD_TYPE_ARGUMENT:
|
||||
case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
|
||||
sb.append(", offset = ");
|
||||
sb.append(offset);
|
||||
sb.append(", type_index = ");
|
||||
sb.append(type_index);
|
||||
break;
|
||||
// We don't need to worry abut these
|
||||
case METHOD_RETURN_GENERIC_OR_ARRAY:
|
||||
case FIELD_GENERIC_OR_ARRAY:
|
||||
break;
|
||||
case UNKNOWN:
|
||||
break;
|
||||
default:
|
||||
// throw new AssertionError("unknown type: " + type);
|
||||
}
|
||||
|
||||
// Append location data for generics/arrays.
|
||||
if (type.hasLocation()) {
|
||||
sb.append(", location = (");
|
||||
sb.append(location);
|
||||
sb.append(")");
|
||||
}
|
||||
|
||||
sb.append(", pos = ");
|
||||
sb.append(pos);
|
||||
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
124
langtools/test/tools/javac/api/TestTreePath.java
Normal file
124
langtools/test/tools/javac/api/TestTreePath.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* Copyright 2006 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6473148
|
||||
* @summary TreePath.iterator() throws NPE
|
||||
*/
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.util.ElementFilter;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import com.sun.source.tree.Tree;
|
||||
import com.sun.source.util.*;
|
||||
|
||||
@SupportedAnnotationTypes("*")
|
||||
public class TestTreePath extends AbstractProcessor {
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnv) {
|
||||
final Trees trees = Trees.instance(this.processingEnv);
|
||||
for (Element element : ElementFilter.typesIn(roundEnv.getRootElements())) {
|
||||
checkTreePath(trees, element, 2);
|
||||
for (Element member : element.getEnclosedElements())
|
||||
checkTreePath(trees, member, 3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkTreePath(Trees trees, Element element, int expectedLength) {
|
||||
TreePath path = trees.getPath(element);
|
||||
assert path != null;
|
||||
|
||||
int enhancedLength = 0;
|
||||
for (Tree tree : path)
|
||||
++enhancedLength;
|
||||
|
||||
if (enhancedLength != expectedLength)
|
||||
throw new RuntimeException("found path length is wrong");
|
||||
|
||||
int normalLoopLength = 0;
|
||||
Iterator<Tree> iter = path.iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
++normalLoopLength;
|
||||
}
|
||||
if (normalLoopLength != expectedLength)
|
||||
throw new RuntimeException("found path length is wrong");
|
||||
|
||||
TreePath curr = path;
|
||||
// using getParent
|
||||
int whileLoopLength = 0;
|
||||
while (curr != null) {
|
||||
++whileLoopLength;
|
||||
curr = curr.getParentPath();
|
||||
}
|
||||
if (whileLoopLength != expectedLength)
|
||||
throw new RuntimeException("found path length is wrong");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceVersion getSupportedSourceVersion() {
|
||||
return SourceVersion.latest();
|
||||
}
|
||||
|
||||
File writeTestFile() throws IOException {
|
||||
File f = new File("Test.java");
|
||||
PrintWriter out = new PrintWriter(new FileWriter(f));
|
||||
out.println("class Test { void method() { } }");
|
||||
out.close();
|
||||
return f;
|
||||
}
|
||||
|
||||
public void run() throws IOException {
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fileManager
|
||||
= compiler.getStandardFileManager(null, null, null);
|
||||
Iterable<? extends JavaFileObject> tests
|
||||
= fileManager.getJavaFileObjects(writeTestFile());
|
||||
|
||||
JavaCompiler.CompilationTask task =
|
||||
ToolProvider.getSystemJavaCompiler().getTask(
|
||||
null, null, null,
|
||||
Arrays.asList("-processor", this.getClass().getName()), null,
|
||||
tests);
|
||||
task.call();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
new TestTreePath().run();
|
||||
}
|
||||
}
|
75
langtools/test/tools/javac/meth/InvokeMH_BAD68.java
Normal file
75
langtools/test/tools/javac/meth/InvokeMH_BAD68.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ##test
|
||||
* ##bug 6754038
|
||||
* ##summary Generate call sites for method handle
|
||||
* ##author jrose
|
||||
*
|
||||
* ##compile/fail -source 7 -target 7 InvokeMH_BAD68.java
|
||||
*/
|
||||
|
||||
/*
|
||||
* Standalone testing:
|
||||
* <code>
|
||||
* $ cd $MY_REPO_DIR/langtools
|
||||
* $ (cd make; make)
|
||||
* $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH_BAD68.java
|
||||
* $ javap -c -classpath dist meth.InvokeMH_BAD68
|
||||
* </code>
|
||||
*/
|
||||
|
||||
package meth;
|
||||
|
||||
import java.dyn.MethodHandle;
|
||||
|
||||
public class InvokeMH_BAD68 {
|
||||
void test(MethodHandle mh_SiO,
|
||||
MethodHandle mh_vS,
|
||||
MethodHandle mh_vi,
|
||||
MethodHandle mh_vv) {
|
||||
Object o; String s; int i; // for return type testing
|
||||
|
||||
// next five must have sig = (String,int)Object
|
||||
mh_SiO.invoke("world", 123);
|
||||
mh_SiO.invoke("mundus", 456);
|
||||
Object k = "kosmos";
|
||||
mh_SiO.invoke((String)k, 789);
|
||||
o = mh_SiO.invoke((String)null, 000);
|
||||
o = mh_SiO.<Object>invoke("arda", -123);
|
||||
|
||||
// sig = ()String
|
||||
s = mh_vS.<String>invoke();
|
||||
|
||||
// sig = ()int
|
||||
i = mh_vi.<int>invoke();
|
||||
o = mh_vi.<int>invoke();
|
||||
s = mh_vi.<int>invoke(); //BAD
|
||||
mh_vi.<int>invoke();
|
||||
|
||||
// sig = ()void
|
||||
//o = mh_vv.<void>invoke(); //BAD
|
||||
mh_vv.<void>invoke();
|
||||
}
|
||||
}
|
75
langtools/test/tools/javac/meth/InvokeMH_BAD72.java
Normal file
75
langtools/test/tools/javac/meth/InvokeMH_BAD72.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ##test
|
||||
* ##bug 6754038
|
||||
* ##summary Generate call sites for method handle
|
||||
* ##author jrose
|
||||
*
|
||||
* ##compile/fail -source 7 -target 7 InvokeMH_BAD72.java
|
||||
*/
|
||||
|
||||
/*
|
||||
* Standalone testing:
|
||||
* <code>
|
||||
* $ cd $MY_REPO_DIR/langtools
|
||||
* $ (cd make; make)
|
||||
* $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH_BAD72.java
|
||||
* $ javap -c -classpath dist meth.InvokeMH_BAD72
|
||||
* </code>
|
||||
*/
|
||||
|
||||
package meth;
|
||||
|
||||
import java.dyn.MethodHandle;
|
||||
|
||||
public class InvokeMH_BAD72 {
|
||||
void test(MethodHandle mh_SiO,
|
||||
MethodHandle mh_vS,
|
||||
MethodHandle mh_vi,
|
||||
MethodHandle mh_vv) {
|
||||
Object o; String s; int i; // for return type testing
|
||||
|
||||
// next five must have sig = (String,int)Object
|
||||
mh_SiO.invoke("world", 123);
|
||||
mh_SiO.invoke("mundus", 456);
|
||||
Object k = "kosmos";
|
||||
mh_SiO.invoke((String)k, 789);
|
||||
o = mh_SiO.invoke((String)null, 000);
|
||||
o = mh_SiO.<Object>invoke("arda", -123);
|
||||
|
||||
// sig = ()String
|
||||
s = mh_vS.<String>invoke();
|
||||
|
||||
// sig = ()int
|
||||
i = mh_vi.<int>invoke();
|
||||
o = mh_vi.<int>invoke();
|
||||
//s = mh_vi.<int>invoke(); //BAD
|
||||
mh_vi.<int>invoke();
|
||||
|
||||
// sig = ()void
|
||||
o = mh_vv.<void>invoke(); //BAD
|
||||
mh_vv.<void>invoke();
|
||||
}
|
||||
}
|
132
langtools/test/tools/javac/quid/QuotedIdent_BAD61.java
Normal file
132
langtools/test/tools/javac/quid/QuotedIdent_BAD61.java
Normal file
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ##test
|
||||
* ##bug 6746458
|
||||
* ##summary Verify correct lexing of quoted identifiers.
|
||||
* ##author jrose
|
||||
*
|
||||
* ##library ..
|
||||
* ##run main quid.QuotedIdent_BAD61
|
||||
*/
|
||||
|
||||
/*
|
||||
* Standalone testing:
|
||||
* <code>
|
||||
* $ cd $MY_REPO_DIR/langtools
|
||||
* $ (cd make; make)
|
||||
* $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD61.java
|
||||
* $ java -version # should print 1.6 or later
|
||||
* $ java -cp dist quid.QuotedIdent_BAD61
|
||||
* </code>
|
||||
*/
|
||||
|
||||
package quid;
|
||||
|
||||
public class QuotedIdent_BAD61 {
|
||||
static void check(int testid, String have, String expect)
|
||||
throws RuntimeException {
|
||||
if ((have == null && have != expect) ||
|
||||
(have != null && !have.equals(expect))) {
|
||||
String msg =
|
||||
"TEST " + testid + ": HAVE \"" +
|
||||
have + "\" EXPECT \"" + expect + "\"";
|
||||
System.out.println("StringConversion: " + msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// negative tests:
|
||||
static class #"" { } //BAD empty ident name
|
||||
//static class #"<foo>" { } //BAD bad char in ident name
|
||||
/*static class /*(//BAD ident name interrupted by newline) #"jump:
|
||||
" { } /* uncomment previous line to attempt class w/ bad name */
|
||||
|
||||
static class #"int" extends Number {
|
||||
final int #"int";
|
||||
#"int"(int #"int") {
|
||||
this.#"int" = #"int";
|
||||
}
|
||||
static #"int" valueOf(int #"int") {
|
||||
return new #"int"(#"int");
|
||||
}
|
||||
public int intValue() { return #"int"; }
|
||||
public long longValue() { return #"int"; }
|
||||
public float floatValue() { return #"int"; }
|
||||
public double doubleValue() { return #"int"; }
|
||||
public String toString() { return String.valueOf(#"int"); }
|
||||
}
|
||||
|
||||
class #"*86" {
|
||||
String #"555-1212"() { return "[*86.555-1212]"; }
|
||||
}
|
||||
static#"*86"#"MAKE-*86"() { // note close spacing
|
||||
return new QuotedIdent_BAD61().new#"*86"();
|
||||
}
|
||||
|
||||
static String bar() { return "[bar]"; }
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String s;
|
||||
|
||||
String #"sticky \' wicket" = "wicked ' stick";
|
||||
s = #"sticky ' wicket";
|
||||
check(11, s, "wicked \' stick");
|
||||
check(12, #"s", s);
|
||||
check(13, #"\163", s);
|
||||
|
||||
s = #"QuotedIdent_BAD61".bar();
|
||||
check(21, s, "[bar]");
|
||||
|
||||
s = #"int".valueOf(123).toString();
|
||||
check(22, s, "123");
|
||||
|
||||
s = #"MAKE-*86"().#"555-1212"();
|
||||
check(23, s, "[*86.555-1212]");
|
||||
|
||||
class#"{{{inmost}}}" { }
|
||||
s = new#"{{{inmost}}}"().getClass().getName();
|
||||
if (!s.endsWith("{{{inmost}}}"))
|
||||
check(24, s, "should end with \"{{{inmost}}}\"");
|
||||
|
||||
s = #"Yog-Shoggoth".#"(nameless ululation)";
|
||||
check(25, s, "Tekeli-li!");
|
||||
|
||||
s = #"int".class.getName();
|
||||
check(31, s, QuotedIdent_BAD61.class.getName()+"$int");
|
||||
|
||||
Class x86 = Class.forName(QuotedIdent_BAD61.class.getName()+"$*86");
|
||||
if (x86 != #"*86".class)
|
||||
check(32, "reflected "+x86, "static "+#"*86".class);
|
||||
|
||||
s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"());
|
||||
check(31, s, "[*86.555-1212]");
|
||||
|
||||
System.out.println("OK");
|
||||
}
|
||||
}
|
||||
|
||||
interface #"Yog-Shoggoth" {
|
||||
final String #"(nameless ululation)" = "Tekeli-li!";
|
||||
}
|
132
langtools/test/tools/javac/quid/QuotedIdent_BAD62.java
Normal file
132
langtools/test/tools/javac/quid/QuotedIdent_BAD62.java
Normal file
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ##test
|
||||
* ##bug 6746458
|
||||
* ##summary Verify correct lexing of quoted identifiers.
|
||||
* ##author jrose
|
||||
*
|
||||
* ##library ..
|
||||
* ##run main quid.QuotedIdent_BAD62
|
||||
*/
|
||||
|
||||
/*
|
||||
* Standalone testing:
|
||||
* <code>
|
||||
* $ cd $MY_REPO_DIR/langtools
|
||||
* $ (cd make; make)
|
||||
* $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD62.java
|
||||
* $ java -version # should print 1.6 or later
|
||||
* $ java -cp dist quid.QuotedIdent_BAD62
|
||||
* </code>
|
||||
*/
|
||||
|
||||
package quid;
|
||||
|
||||
public class QuotedIdent_BAD62 {
|
||||
static void check(int testid, String have, String expect)
|
||||
throws RuntimeException {
|
||||
if ((have == null && have != expect) ||
|
||||
(have != null && !have.equals(expect))) {
|
||||
String msg =
|
||||
"TEST " + testid + ": HAVE \"" +
|
||||
have + "\" EXPECT \"" + expect + "\"";
|
||||
System.out.println("StringConversion: " + msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// negative tests:
|
||||
//static class #"" { } //BAD empty ident name
|
||||
static class #"<foo>" { } //BAD bad char in ident name
|
||||
/*static class /*(//BAD ident name interrupted by newline) #"jump:
|
||||
" { } /* uncomment previous line to attempt class w/ bad name */
|
||||
|
||||
static class #"int" extends Number {
|
||||
final int #"int";
|
||||
#"int"(int #"int") {
|
||||
this.#"int" = #"int";
|
||||
}
|
||||
static #"int" valueOf(int #"int") {
|
||||
return new #"int"(#"int");
|
||||
}
|
||||
public int intValue() { return #"int"; }
|
||||
public long longValue() { return #"int"; }
|
||||
public float floatValue() { return #"int"; }
|
||||
public double doubleValue() { return #"int"; }
|
||||
public String toString() { return String.valueOf(#"int"); }
|
||||
}
|
||||
|
||||
class #"*86" {
|
||||
String #"555-1212"() { return "[*86.555-1212]"; }
|
||||
}
|
||||
static#"*86"#"MAKE-*86"() { // note close spacing
|
||||
return new QuotedIdent_BAD62().new#"*86"();
|
||||
}
|
||||
|
||||
static String bar() { return "[bar]"; }
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String s;
|
||||
|
||||
String #"sticky \' wicket" = "wicked ' stick";
|
||||
s = #"sticky ' wicket";
|
||||
check(11, s, "wicked \' stick");
|
||||
check(12, #"s", s);
|
||||
check(13, #"\163", s);
|
||||
|
||||
s = #"QuotedIdent_BAD62".bar();
|
||||
check(21, s, "[bar]");
|
||||
|
||||
s = #"int".valueOf(123).toString();
|
||||
check(22, s, "123");
|
||||
|
||||
s = #"MAKE-*86"().#"555-1212"();
|
||||
check(23, s, "[*86.555-1212]");
|
||||
|
||||
class#"{{{inmost}}}" { }
|
||||
s = new#"{{{inmost}}}"().getClass().getName();
|
||||
if (!s.endsWith("{{{inmost}}}"))
|
||||
check(24, s, "should end with \"{{{inmost}}}\"");
|
||||
|
||||
s = #"Yog-Shoggoth".#"(nameless ululation)";
|
||||
check(25, s, "Tekeli-li!");
|
||||
|
||||
s = #"int".class.getName();
|
||||
check(31, s, QuotedIdent_BAD62.class.getName()+"$int");
|
||||
|
||||
Class x86 = Class.forName(QuotedIdent_BAD62.class.getName()+"$*86");
|
||||
if (x86 != #"*86".class)
|
||||
check(32, "reflected "+x86, "static "+#"*86".class);
|
||||
|
||||
s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"());
|
||||
check(31, s, "[*86.555-1212]");
|
||||
|
||||
System.out.println("OK");
|
||||
}
|
||||
}
|
||||
|
||||
interface #"Yog-Shoggoth" {
|
||||
final String #"(nameless ululation)" = "Tekeli-li!";
|
||||
}
|
132
langtools/test/tools/javac/quid/QuotedIdent_BAD63.java
Normal file
132
langtools/test/tools/javac/quid/QuotedIdent_BAD63.java
Normal file
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ##test
|
||||
* ##bug 6746458
|
||||
* ##summary Verify correct lexing of quoted identifiers.
|
||||
* ##author jrose
|
||||
*
|
||||
* ##library ..
|
||||
* ##run main quid.QuotedIdent_BAD63
|
||||
*/
|
||||
|
||||
/*
|
||||
* Standalone testing:
|
||||
* <code>
|
||||
* $ cd $MY_REPO_DIR/langtools
|
||||
* $ (cd make; make)
|
||||
* $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD63.java
|
||||
* $ java -version # should print 1.6 or later
|
||||
* $ java -cp dist quid.QuotedIdent_BAD63
|
||||
* </code>
|
||||
*/
|
||||
|
||||
package quid;
|
||||
|
||||
public class QuotedIdent_BAD63 {
|
||||
static void check(int testid, String have, String expect)
|
||||
throws RuntimeException {
|
||||
if ((have == null && have != expect) ||
|
||||
(have != null && !have.equals(expect))) {
|
||||
String msg =
|
||||
"TEST " + testid + ": HAVE \"" +
|
||||
have + "\" EXPECT \"" + expect + "\"";
|
||||
System.out.println("StringConversion: " + msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// negative tests:
|
||||
//static class #"" { } //BAD empty ident name
|
||||
//static class #"<foo>" { } //BAD bad char in ident name
|
||||
static class /*(//BAD ident name interrupted by newline) #"jump:
|
||||
" { } /* uncomment previous line to attempt class w/ bad name */
|
||||
|
||||
static class #"int" extends Number {
|
||||
final int #"int";
|
||||
#"int"(int #"int") {
|
||||
this.#"int" = #"int";
|
||||
}
|
||||
static #"int" valueOf(int #"int") {
|
||||
return new #"int"(#"int");
|
||||
}
|
||||
public int intValue() { return #"int"; }
|
||||
public long longValue() { return #"int"; }
|
||||
public float floatValue() { return #"int"; }
|
||||
public double doubleValue() { return #"int"; }
|
||||
public String toString() { return String.valueOf(#"int"); }
|
||||
}
|
||||
|
||||
class #"*86" {
|
||||
String #"555-1212"() { return "[*86.555-1212]"; }
|
||||
}
|
||||
static#"*86"#"MAKE-*86"() { // note close spacing
|
||||
return new QuotedIdent_BAD63().new#"*86"();
|
||||
}
|
||||
|
||||
static String bar() { return "[bar]"; }
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String s;
|
||||
|
||||
String #"sticky \' wicket" = "wicked ' stick";
|
||||
s = #"sticky ' wicket";
|
||||
check(11, s, "wicked \' stick");
|
||||
check(12, #"s", s);
|
||||
check(13, #"\163", s);
|
||||
|
||||
s = #"QuotedIdent_BAD63".bar();
|
||||
check(21, s, "[bar]");
|
||||
|
||||
s = #"int".valueOf(123).toString();
|
||||
check(22, s, "123");
|
||||
|
||||
s = #"MAKE-*86"().#"555-1212"();
|
||||
check(23, s, "[*86.555-1212]");
|
||||
|
||||
class#"{{{inmost}}}" { }
|
||||
s = new#"{{{inmost}}}"().getClass().getName();
|
||||
if (!s.endsWith("{{{inmost}}}"))
|
||||
check(24, s, "should end with \"{{{inmost}}}\"");
|
||||
|
||||
s = #"Yog-Shoggoth".#"(nameless ululation)";
|
||||
check(25, s, "Tekeli-li!");
|
||||
|
||||
s = #"int".class.getName();
|
||||
check(31, s, QuotedIdent_BAD63.class.getName()+"$int");
|
||||
|
||||
Class x86 = Class.forName(QuotedIdent_BAD63.class.getName()+"$*86");
|
||||
if (x86 != #"*86".class)
|
||||
check(32, "reflected "+x86, "static "+#"*86".class);
|
||||
|
||||
s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"());
|
||||
check(31, s, "[*86.555-1212]");
|
||||
|
||||
System.out.println("OK");
|
||||
}
|
||||
}
|
||||
|
||||
interface #"Yog-Shoggoth" {
|
||||
final String #"(nameless ululation)" = "Tekeli-li!";
|
||||
}
|
38
langtools/test/tools/javac/typeAnnotations/InnerClass.java
Normal file
38
langtools/test/tools/javac/typeAnnotations/InnerClass.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.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 {
|
||||
private void a() {
|
||||
new Object() {
|
||||
public <R> void method() { }
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.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 { }
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.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 { }
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.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 { }
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.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(); }
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
AnnotationVersion.java:32:25: compiler.err.type.annotations.not.supported.in.source: 1.6
|
||||
1 error
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
IncompleteArray.java:32:13: compiler.err.illegal.start.of.type
|
||||
1 error
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
IncompleteVararg.java:33:19: compiler.err.illegal.start.of.type
|
||||
1 error
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
IndexArray.java:33:15: compiler.err.illegal.start.of.expr
|
||||
1 error
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,6 @@
|
|||
LintCast.java:36:21: compiler.warn.redundant.cast: java.lang.String
|
||||
LintCast.java:42:27: compiler.warn.redundant.cast: java.util.List<java.lang.String>
|
||||
LintCast.java:48:20: compiler.warn.redundant.cast: int[]
|
||||
LintCast.java:60:24: compiler.warn.redundant.cast: java.lang.String
|
||||
LintCast.java:61:26: compiler.warn.redundant.cast: java.lang.String
|
||||
5 warnings
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6843077
|
||||
* @summary test old array syntax
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=OldArray.out -XDrawDiagnostics -source 1.7 OldArray.java
|
||||
*/
|
||||
class OldArray {
|
||||
String [@A] s() { return null; }
|
||||
}
|
||||
|
||||
@interface A { }
|
|
@ -0,0 +1,2 @@
|
|||
OldArray.java:32:11: compiler.err.expected: ']'
|
||||
1 error
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { };
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Scopes.java:31:25: compiler.err.cant.resolve: kindname.class, UniqueInner, ,
|
||||
1 error
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
StaticFields.java:33:17: compiler.err.illegal.start.of.expr
|
||||
1 error
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
StaticMethods.java:32:22: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.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 { }
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6843077
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateAnnotationValue.java:33:45: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateTypeAnnotation.java:34:26: compiler.err.duplicate.annotation
|
||||
1 error
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
InvalidLocation.java:34:23: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
MissingAnnotationValue.java:33:23: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6843077
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateAnnotationValue.java:33:34: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateTypeAnnotation.java:34:15: compiler.err.duplicate.annotation
|
||||
1 error
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
InvalidLocation.java:34:12: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
MissingAnnotationValue.java:33:12: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6843077
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateAnnotationValue.java:33:39: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateTypeAnnotation.java:33:20: compiler.err.duplicate.annotation
|
||||
1 error
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
InvalidLocation.java:33:17: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
MissingAnnotationValue.java:33:17: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6843077
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateAnnotationValue.java:33:51: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateTypeAnnotation.java:34:32: compiler.err.duplicate.annotation
|
||||
1 error
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
InvalidLocation.java:34:29: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
MissingAnnotationValue.java:33:29: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6843077
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateAnnotationValue.java:31:64: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateTypeAnnotation.java:32:38: compiler.err.duplicate.annotation
|
||||
1 error
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
InvalidLocation.java:32:33: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
MissingAnnotationValue.java:31:40: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6843077
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateAnnotationValue.java:32:37: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateTypeAnnotation.java:33:18: compiler.err.duplicate.annotation
|
||||
1 error
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
InvalidLocation.java:33:15: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
MissingAnnotationValue.java:32:15: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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(); }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateAnnotationValue.java:33:9: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateTypeAnnotation.java:34:12: compiler.err.duplicate.annotation
|
||||
1 error
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @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 { }
|
|
@ -0,0 +1,2 @@
|
|||
InvalidLocation.java:34:9: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6843077
|
||||
* @summary check for missing annotation value
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
|
||||
*/
|
||||
class MissingAnnotationValue {
|
||||
void test() {
|
||||
new @A String();
|
||||
}
|
||||
}
|
||||
|
||||
@interface A { int field(); }
|
|
@ -0,0 +1,2 @@
|
|||
MissingAnnotationValue.java:33:9: compiler.err.annotation.missing.default.value: A, field
|
||||
1 error
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6843077
|
||||
* @summary check for duplicate annotation values for type parameter
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
|
||||
*/
|
||||
class DuplicateAnnotationValue<K> {
|
||||
DuplicateAnnotationValue<@A(value = 2, value = 1) String> l;
|
||||
}
|
||||
|
||||
@interface A { int value(); }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateAnnotationValue.java:32:50: compiler.err.duplicate.annotation.member.value: value, A
|
||||
1 error
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6843077
|
||||
* @summary check for duplicate annotations
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
|
||||
*/
|
||||
|
||||
class DuplicateTypeAnno<K> {
|
||||
DuplicateTypeAnno<@A @A String> l;
|
||||
}
|
||||
|
||||
@interface A { }
|
|
@ -0,0 +1,2 @@
|
|||
DuplicateTypeAnnotation.java:33:24: compiler.err.duplicate.annotation
|
||||
1 error
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6843077
|
||||
* @summary check for invalid annotatins given the target
|
||||
* @author Mahmood Ali
|
||||
* @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
|
||||
*/
|
||||
|
||||
class InvalidLocation<K> {
|
||||
InvalidLocation<@A String> l;
|
||||
}
|
||||
|
||||
@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
|
||||
@interface A { }
|
|
@ -0,0 +1,2 @@
|
|||
InvalidLocation.java:33:19: compiler.err.annotation.type.not.applicable
|
||||
1 error
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue