changeset 308:664edca41e34

6855544: add missing files Reviewed-by: jjg, mcimadamore, darcy Contributed-by: mernst@cs.washington.edu, mali@csail.mit.edu, mpapi@csail.mit.edu
author jjg
date Fri, 26 Jun 2009 19:12:41 -0700
parents 03944ee4fac4
children 7c154fdc3547
files src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java src/share/classes/com/sun/source/util/AbstractTypeProcessor.java src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java src/share/classes/com/sun/tools/classfile/RuntimeInvisibleTypeAnnotations_attribute.java src/share/classes/com/sun/tools/classfile/RuntimeTypeAnnotations_attribute.java src/share/classes/com/sun/tools/classfile/RuntimeVisibleTypeAnnotations_attribute.java src/share/classes/com/sun/tools/javac/code/TargetType.java src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java test/tools/javac/api/TestTreePath.java test/tools/javac/meth/InvokeMH_BAD68.java test/tools/javac/meth/InvokeMH_BAD72.java test/tools/javac/quid/QuotedIdent_BAD61.java test/tools/javac/quid/QuotedIdent_BAD62.java test/tools/javac/quid/QuotedIdent_BAD63.java test/tools/javac/typeAnnotations/InnerClass.java test/tools/javac/typeAnnotations/MultipleTargets.java test/tools/javac/typeAnnotations/TypeParameterTarget.java test/tools/javac/typeAnnotations/TypeUseTarget.java test/tools/javac/typeAnnotations/attribution/Scopes.java test/tools/javac/typeAnnotations/failures/AnnotationVersion.java test/tools/javac/typeAnnotations/failures/AnnotationVersion.out test/tools/javac/typeAnnotations/failures/IncompleteArray.java test/tools/javac/typeAnnotations/failures/IncompleteArray.out test/tools/javac/typeAnnotations/failures/IncompleteVararg.java test/tools/javac/typeAnnotations/failures/IncompleteVararg.out test/tools/javac/typeAnnotations/failures/IndexArray.java test/tools/javac/typeAnnotations/failures/IndexArray.out test/tools/javac/typeAnnotations/failures/LintCast.java test/tools/javac/typeAnnotations/failures/LintCast.out test/tools/javac/typeAnnotations/failures/OldArray.java test/tools/javac/typeAnnotations/failures/OldArray.out test/tools/javac/typeAnnotations/failures/Scopes.java test/tools/javac/typeAnnotations/failures/Scopes.out test/tools/javac/typeAnnotations/failures/StaticFields.java test/tools/javac/typeAnnotations/failures/StaticFields.out test/tools/javac/typeAnnotations/failures/StaticMethods.java test/tools/javac/typeAnnotations/failures/StaticMethods.out test/tools/javac/typeAnnotations/failures/VoidGenericMethod.java test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.out test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.out test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.out test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.out test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.out test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.out test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.out test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.out test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.out test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.java test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.out test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out test/tools/javac/typeAnnotations/failures/target/Constructor.java test/tools/javac/typeAnnotations/failures/target/Constructor.out test/tools/javac/typeAnnotations/failures/target/IncompleteArray.java test/tools/javac/typeAnnotations/failures/target/IncompleteArray.out test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.java test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.out test/tools/javac/typeAnnotations/failures/target/NotTypeUse.java test/tools/javac/typeAnnotations/failures/target/NotTypeUse.out test/tools/javac/typeAnnotations/failures/target/VoidMethod.java test/tools/javac/typeAnnotations/failures/target/VoidMethod.out test/tools/javac/typeAnnotations/newlocations/BasicTest.java test/tools/javac/typeAnnotations/newlocations/ClassExtends.java test/tools/javac/typeAnnotations/newlocations/ClassLiterals.java test/tools/javac/typeAnnotations/newlocations/ClassParameters.java test/tools/javac/typeAnnotations/newlocations/ConstructorTypeArgs.java test/tools/javac/typeAnnotations/newlocations/Expressions.java test/tools/javac/typeAnnotations/newlocations/Fields.java test/tools/javac/typeAnnotations/newlocations/LocalVariables.java test/tools/javac/typeAnnotations/newlocations/MethodReturnType.java test/tools/javac/typeAnnotations/newlocations/MethodTypeArgs.java test/tools/javac/typeAnnotations/newlocations/MethodTypeParameters.java test/tools/javac/typeAnnotations/newlocations/Parameters.java test/tools/javac/typeAnnotations/newlocations/Receivers.java test/tools/javac/typeAnnotations/newlocations/Throws.java test/tools/javac/typeAnnotations/newlocations/TypeCasts.java test/tools/javac/typeAnnotations/newlocations/TypeParameters.java test/tools/javac/typeAnnotations/newlocations/Wildcards.java test/tools/javap/typeAnnotations/ClassLiterals.java test/tools/javap/typeAnnotations/JSR175Annotations.java test/tools/javap/typeAnnotations/NewArray.java test/tools/javap/typeAnnotations/Presence.java test/tools/javap/typeAnnotations/PresenceInner.java test/tools/javap/typeAnnotations/Visibility.java
diffstat 151 files changed, 6571 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/source/util/AbstractTypeProcessor.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/classfile/RuntimeInvisibleTypeAnnotations_attribute.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/classfile/RuntimeTypeAnnotations_attribute.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/classfile/RuntimeVisibleTypeAnnotations_attribute.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/code/TargetType.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/TestTreePath.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/meth/InvokeMH_BAD68.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/meth/InvokeMH_BAD72.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/quid/QuotedIdent_BAD61.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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!";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/quid/QuotedIdent_BAD62.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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!";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/quid/QuotedIdent_BAD63.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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!";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/InnerClass.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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() { }
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/MultipleTargets.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/TypeParameterTarget.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/TypeUseTarget.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/attribution/Scopes.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/AnnotationVersion.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/AnnotationVersion.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+AnnotationVersion.java:32:25: compiler.err.type.annotations.not.supported.in.source: 1.6
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/IncompleteArray.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/IncompleteArray.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+IncompleteArray.java:32:13: compiler.err.illegal.start.of.type
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/IncompleteVararg.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/IncompleteVararg.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+IncompleteVararg.java:33:19: compiler.err.illegal.start.of.type
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/IndexArray.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/IndexArray.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+IndexArray.java:33:15: compiler.err.illegal.start.of.expr
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/LintCast.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/LintCast.out	Fri Jun 26 19:12:41 2009 -0700
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/OldArray.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/OldArray.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+OldArray.java:32:11: compiler.err.expected: ']'
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/Scopes.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/Scopes.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+Scopes.java:31:25: compiler.err.cant.resolve: kindname.class, UniqueInner, , 
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/StaticFields.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/StaticFields.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+StaticFields.java:33:17: compiler.err.illegal.start.of.expr
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/StaticMethods.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/StaticMethods.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+StaticMethods.java:32:22: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/VoidGenericMethod.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:33:45: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:34:26: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:34:23: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:33:23: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:33:34: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:34:15: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:34:12: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:33:12: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:33:39: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:33:20: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:33:17: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:33:17: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:33:51: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:34:32: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:34:29: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:33:29: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:31:64: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:32:38: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:32:33: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:31:40: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:32:37: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:33:18: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:33:15: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:32:15: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:33:9: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:34:12: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:34:9: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:33:9: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:32:50: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:33:24: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:33:19: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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<K> {
+  MissingAnnotationValue<@A String> l;
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:32:26: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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<@A(value = 2, value = 1) K> {
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:31:54: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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<@A @A K> {
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:32:28: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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<@A K> {
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:32:23: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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<@A K> {
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:31:30: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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) ?> l;
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:32:50: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 ?> l;
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:33:24: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 ?> l;
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:33:19: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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<K> {
+  MissingAnnotationValue<@A ?> l;
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:32:26: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/Constructor.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,40 @@
+/*
+ * 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 invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail/ref=Constructor.out -XDrawDiagnostics -source 1.7 Constructor.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class Constructor {
+  @A Constructor() { }
+}
+
+@Target(ElementType.TYPE_USE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/Constructor.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+Constructor.java:36:3: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+IncompleteArray.java:32:13: compiler.err.illegal.start.of.type
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,40 @@
+/*
+ * 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 invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail/ref=NotTypeParameter.out -XDrawDiagnostics -source 1.7 NotTypeParameter.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class VoidMethod<@A K> {
+  @A void test() { }
+}
+
+@Target(ElementType.TYPE_USE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,3 @@
+NotTypeParameter.java:36:3: compiler.err.annotation.type.not.applicable
+NotTypeParameter.java:35:18: compiler.err.annotation.type.not.applicable
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,40 @@
+/*
+ * 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 invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail/ref=NotTypeUse.out -XDrawDiagnostics -source 1.7 NotTypeUse.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class VoidMethod {
+  @A void test() { }
+}
+
+@Target(ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+NotTypeUse.java:36:3: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/VoidMethod.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,40 @@
+/*
+ * 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 invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail/ref=VoidMethod.out -XDrawDiagnostics -source 1.7 VoidMethod.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class VoidMethod {
+  @A void test() { }
+}
+
+@Target(ElementType.TYPE_USE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/failures/target/VoidMethod.out	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,2 @@
+VoidMethod.java:36:3: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/BasicTest.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 6843077
+ * @summary random tests for new locations
+ * @author Matt Papi
+ * @compile -source 1.7 BasicTest.java
+ */
+
+import java.util.*;
+import java.io.*;
+
+@interface A {}
+@interface B {}
+@interface C {}
+@interface D {}
+
+/**
+ * Tests basic JSR 308 parser functionality. We don't really care about what
+ * the parse tree looks like, just that these annotations can be parsed.
+ */
+class BasicTest<T extends @A Object> extends @B LinkedList<T> implements @C List<T> {
+
+    void test() {
+
+        // Handle annotated class literals/cast types
+        Class<?> c = @A String.class;
+        Object o = (@A Object) "foo";
+
+        // Handle annotated "new" expressions (except arrays; see ArrayTest)
+        String s = new @A String("bar");
+
+        boolean b = o instanceof @A Object;
+
+
+        @A Map<@B List<@C String>, @D String> map =
+            new @A HashMap<@B List<@C String>, @D String>();
+
+        Class<? extends @A String> c2 = @A String.class;
+    }
+
+    // Handle receiver annotations
+    // Handle annotations on a qualified identifier list
+    void test2() @C @D throws @A IllegalArgumentException, @B IOException {
+
+    }
+
+    // Handle annotations on a varargs element type
+    void test3(Object @A... objs) {
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/ClassExtends.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,40 @@
+/*
+ * 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 new type annotation location: class extends/implements
+ * @author Mahmood Ali
+ * @compile -source 1.7 ClassExtends.java
+ */
+abstract class MyClass extends @A ParameterizedClass<@B String>
+  implements @B CharSequence, @A ParameterizedInterface<@B String> { }
+
+interface MyInterface extends @A ParameterizedInterface<@A String>,
+                              @B CharSequence { }
+
+class ParameterizedClass<K> {}
+interface ParameterizedInterface<K> {}
+@interface A {}
+@interface B {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/ClassLiterals.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,48 @@
+/*
+ * 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 new type annotation location: class literals
+ * @author Mahmood Ali
+ * @compile -source 1.7 ClassLiterals.java
+ */
+
+class ClassLiterals {
+
+  public static void main(String[] args) {
+    if (String.class != @A String.class) throw new Error();
+    if (@A int.class != int.class) throw new Error();
+    if (@A int.class != Integer.TYPE) throw new Error();
+    if (@A int @B(0) [].class != int[].class) throw new Error();
+
+    if (String[].class != @A String[].class) throw new Error();
+    if (String[].class != String @A [].class) throw new Error();
+    if (@A int[].class != int[].class) throw new Error();
+    if (@A int @B(0) [].class != int[].class) throw new Error();
+  }
+}
+
+@interface A {}
+@interface B { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/ClassParameters.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,56 @@
+/*
+ * 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 new type annotation location: class type parameter bounds
+ * @author Mahmood Ali
+ * @compile -source 1.7 ClassParameters.java
+ */
+class Unannotated<K> { }
+
+class ExtendsBound<K extends @A String> { }
+class ExtendsGeneric<K extends @A Unannotated<@B String>> { }
+class TwoBounds<K extends @A String, V extends @B String> { }
+
+class Complex1<K extends @A String&Runnable> { }
+class Complex2<K extends String & @B Runnable> { }
+class ComplexBoth<K extends @A String & @A Runnable> { }
+
+class Outer {
+  void inner() {
+    class Unannotated<K> { }
+
+    class ExtendsBound<K extends @A String> { }
+    class ExtendsGeneric<K extends @A Unannotated<@B String>> { }
+    class TwoBounds<K extends @A String, V extends @B String> { }
+
+    class Complex1<K extends @A String&Runnable> { }
+    class Complex2<K extends String & @B Runnable> { }
+    class ComplexBoth<K extends @A String & @A Runnable> { }
+  }
+}
+
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/ConstructorTypeArgs.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 new type annotation location: constructor type args
+ * @author Mahmood Ali
+ * @compile -source 1.7 ConstructorTypeArgs.java
+ */
+
+class ConstructorTypeArgs {
+  void oneArg() {
+    new @A MyList<@A String>();
+    new MyList<@A MyList<@B(0) String>>();
+  }
+
+  void twoArg() {
+    new MyMap<String, String>();
+    new MyMap<@A String, @B(0) MyList<@A String>>();
+  }
+
+  void withArraysIn() {
+    new MyList<String[]>();
+    new MyList<@A String @B(0) [] @A []>();
+
+    new MyMap<@A String[], @B(0) MyList<@A String> @A []>();
+  }
+}
+
+class MyList<E> { }
+class MyMap<K, V> { }
+
+@interface A { }
+@interface B { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/Expressions.java	Fri Jun 26 19:12:41 2009 -0700
@@ -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 6843077
+ * @summary new type annotation location: expressions
+ * @author Mahmood Ali
+ * @compile -source 1.7 Expressions.java
+ */
+class Expressions {
+  void instanceOf() {
+    Object o = null;
+    boolean a = o instanceof @A String;
+    boolean b = o instanceof @B(0) String;
+  }
+
+  void instanceOfArray() {
+    Object o = null;
+    boolean a1 = o instanceof @A String [];
+    boolean a2 = o instanceof @B(0) String [];
+
+    boolean b1 = o instanceof String @A [];
+    boolean b2 = o instanceof String @B(0) [];
+  }
+
+  void objectCreation() {
+    new @A String();
+    new @B(0) String();
+  }
+
+  void objectCreationArray() {
+    Object a1 = new @A String [] [] { };
+    Object a2 = new @A String [1] [];
+    Object a3 = new @A String [1] [2];
+
+    Object b1 = new @A String @B(0) [] [] { };
+    Object b2 = new @A String @B(0) [1] [];
+    Object b3 = new @A String @B(0) [1] [2];
+
+    Object c1 = new @A String []  @B(0) [] { };
+    Object c2 = new @A String [1] @B(0) [];
+    Object c3 = new @A String [1] @B(0) [2];
+
+    Object d1 = new @A String @B(0) []  @B(0) [] { };
+    Object d2 = new @A String @B(0) [1] @B(0) [];
+    Object d3 = new @A String @B(0) [1] @B(0) [2];
+
+    Object rand = new @A String @B(value = 0) [1] @B(value = 0) [2];
+
+  }
+}
+
+@interface A { }
+@interface B { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/Fields.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,69 @@
+/*
+ * 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 new type annotation location: field type array/generics
+ * @author Mahmood Ali
+ * @compile -source 1.7 Fields.java
+ */
+
+class DefaultScope {
+  Parameterized<String, String> unannotated;
+  Parameterized<@A String, String> firstTypeArg;
+  Parameterized<String, @A String> secondTypeArg;
+  Parameterized<@A String, @B String> bothTypeArgs;
+
+  Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized;
+
+  @A String [] array1;
+  @A String @B [] array1Deep;
+  @A String [] [] array2;
+  @A String @A [] @B [] array2Deep;
+  String @A [] [] array2First;
+  String [] @B [] array2Second;
+}
+
+class ModifiedScoped {
+  public final Parameterized<String, String> unannotated = null;
+  public final Parameterized<@A String, String> firstTypeArg = null;
+  public final Parameterized<String, @A String> secondTypeArg = null;
+  public final Parameterized<@A String, @B String> bothTypeArgs = null;
+
+  public final Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized = null;
+
+  public final @A String [] array1 = null;
+  public final @A String @B [] array1Deep = null;
+  public final @A String [] [] array2 = null;
+  public final @A String @A [] @B [] array2Deep = null;
+  public final String @A [] [] array2First = null;
+  public final String [] @B [] array2Second = null;
+}
+
+class Parameterized<K, V> { }
+
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/LocalVariables.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,77 @@
+/*
+ * 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 new type annotation location: local variables array/generics
+ * @author Mahmood Ali
+ * @compile -source 1.7 LocalVariables.java
+ */
+
+class DefaultScope {
+  void parameterized() {
+    Parameterized<String, String> unannotated;
+    Parameterized<@A String, String> firstTypeArg;
+    Parameterized<String, @A String> secondTypeArg;
+    Parameterized<@A String, @B String> bothTypeArgs;
+
+    Parameterized<@A Parameterized<@A String, @B String>, @B String>
+      nestedParameterized;
+  }
+
+  void arrays() {
+    @A String [] array1;
+    @A String @B [] array1Deep;
+    @A String [] [] array2;
+    @A String @A [] @B [] array2Deep;
+    String @A [] [] array2First;
+    String [] @B [] array2Second;
+  }
+}
+
+class ModifiedVars {
+  void parameterized() {
+    final Parameterized<String, String> unannotated = null;
+    final Parameterized<@A String, String> firstTypeArg = null;
+    final Parameterized<String, @A String> secondTypeArg = null;
+    final Parameterized<@A String, @B String> bothTypeArgs = null;
+
+    final Parameterized<@A Parameterized<@A String, @B String>, @B String>
+      nestedParameterized = null;
+  }
+
+  void arrays() {
+    final @A String [] array1 = null;
+    final @A String @B [] array1Deep = null;
+    final @A String [] [] array2 = null;
+    final @A String @A [] @B [] array2Deep = null;
+    final String @A [] [] array2First = null;
+    final String [] @B [] array2Second = null;
+  }
+}
+
+class Parameterized<K, V> { }
+
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/MethodReturnType.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,71 @@
+/*
+ * 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 new type annotation location: method return type array/generics
+ * @author Mahmood Ali
+ * @compile -source 1.7 MethodReturnType.java
+ */
+
+class DefaultScope {
+  Parameterized<String, String> unannotated() { return null; }
+  Parameterized<@A String, String> firstTypeArg() { return null; }
+  Parameterized<String, @A String> secondTypeArg() { return null; }
+  Parameterized<@A String, @B String> bothTypeArgs() { return null; }
+
+  Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized() { return null; }
+
+  public <T> @A String method() { return null; }
+
+  @A String [] array1() { return null; }
+  @A String @B [] array1Deep() { return null; }
+  @A String [] [] array2() { return null; }
+  @A String @A [] @B [] array2Deep() { return null; }
+  String @A [] [] array2First() { return null; }
+  String [] @B [] array2Second() { return null; }
+}
+
+class ModifiedScoped {
+  public final Parameterized<String, String> unannotated() { return null; }
+  public final Parameterized<@A String, String> firstTypeArg() { return null; }
+  public final Parameterized<String, @A String> secondTypeArg() { return null; }
+  public final Parameterized<@A String, @B String> bothTypeArgs() { return null; }
+
+  public final Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized() { return null; }
+
+  public final @A String [] array1() { return null; }
+  public final @A String @B [] array1Deep() { return null; }
+  public final @A String [] [] array2() { return null; }
+  public final @A String @A [] @B [] array2Deep() { return null; }
+  public final String @A [] [] array2First() { return null; }
+  public final String [] @B [] array2Second() { return null; }
+}
+
+class Parameterized<K, V> { }
+
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/MethodTypeArgs.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,62 @@
+/*
+ * 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 new type annotation location: method type args
+ * @author Mahmood Ali
+ * @compile -source 1.7 MethodTypeArgs.java
+ */
+
+class MethodTypeArgs {
+  void oneArg() {
+    this.<@A String>newList();
+    this.<@A MyList<@B(0) String>>newList();
+
+    MethodTypeArgs.<@A String>newList();
+    MethodTypeArgs.<@A MyList<@B(0) String>>newList();
+  }
+
+  void twoArg() {
+    this.<String, String>newMap();
+    this.<@A String, @B(0) MyList<@A String>>newMap();
+
+    MethodTypeArgs.<String, String>newMap();
+    MethodTypeArgs.<@A String, @B(0) MyList<@A String>>newMap();
+  }
+
+  void withArraysIn() {
+    this.<String[]>newList();
+    this.<@A String @B(0) [] @A []>newList();
+
+    this.<@A String[], @B(0) MyList<@A String> @A []>newMap();
+  }
+
+  static <E> void newList() { }
+  static <K, V> void newMap() { }
+}
+
+class MyList<E> { }
+@interface A { }
+@interface B { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/MethodTypeParameters.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,48 @@
+/*
+ * 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 new type annotation location: method type parameter bounds
+ * @author Mahmood Ali
+ * @compile -source 1.7 MethodTypeParameters.java
+ */
+
+class UnscopedUnmodified {
+  <K extends @A String> void methodExtends() {}
+  <K extends @A Parameterized<@B String>> void nestedExtends() {}
+  <K extends @A String, V extends @A Parameterized<@B String>> void dual() {}
+  <K extends String, V extends Parameterized<@B String>> void dualOneAnno() {}
+}
+
+class PublicModifiedMethods {
+  public final <K extends @A String> void methodExtends() {}
+  public final <K extends @A Parameterized<@B String>> void nestedExtends() {}
+  public final <K extends @A String, V extends @A Parameterized<@B String>> void dual() {}
+  public final <K extends String, V extends Parameterized<@B String>> void dualOneAnno() {}
+}
+
+class Parameterized<K> { }
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/Parameters.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,51 @@
+/*
+ * 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 new type annotation location: parameter type array/generics
+ * @author Mahmood Ali
+ * @compile -source 1.7 Parameters.java
+ */
+
+class Parameters {
+  void unannotated(Parameterized<String, String> a) {}
+  void firstTypeArg(Parameterized<@A String, String> a) {}
+  void secondTypeArg(Parameterized<String, @A String> a) {}
+  void bothTypeArgs(Parameterized<@A String, @B String> both) {}
+
+  void nestedParameterized(Parameterized<@A Parameterized<@A String, @B String>, @B String> a) {}
+
+  void array1(@A String [] a) {}
+  void array1Deep(@A String @B [] a) {}
+  void array2(@A String [] [] a) {}
+  void array2Deep(@A String @A [] @B [] a) {}
+  void array2First(String @A [] [] a) {}
+  void array2Second(String [] @B [] a) {}
+}
+
+class Parameterized<K, V> { }
+
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/Receivers.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,56 @@
+/*
+ * 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 new type annotation location: receivers
+ * @author Mahmood Ali
+ * @compile -source 1.7 Receivers.java
+ */
+class DefaultUnmodified {
+  void plain() @A { }
+  <T> void generic() @A { }
+  void withException() @A throws Exception { }
+  String nonVoid() @A { return null; }
+  <T extends Runnable> void accept(T r) @A throws Exception { }
+}
+
+class PublicModified {
+  public final void plain() @A { }
+  public final <T> void generic() @A { }
+  public final void withException() @A throws Exception { }
+  public final String nonVoid() @A { return null; }
+  public final <T extends Runnable> void accept(T r) @A throws Exception { }
+}
+
+class WithValue {
+  void plain() @B("m") { }
+  <T> void generic() @B("m") { }
+  void withException() @B("m") throws Exception { }
+  String nonVoid() @B("m") { return null; }
+  <T extends Runnable> void accept(T r) @B("m") throws Exception { }
+}
+
+@interface A {}
+@interface B { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/Throws.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,47 @@
+/*
+ * 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 new type annotation location: throw clauses
+ * @author Mahmood Ali
+ * @compile -source 1.7 Throws.java
+ */
+class DefaultUnmodified {
+  void oneException() throws @A Exception {}
+  void twoExceptions() throws @A RuntimeException, @A Exception {}
+}
+
+class PublicModified {
+  public final void oneException(String a) throws @A Exception {}
+  public final void twoExceptions(String a) throws @A RuntimeException, @A Exception {}
+}
+
+class WithValue {
+  void oneException() throws @B("m") Exception {}
+  void twoExceptions() throws @B(value="m") RuntimeException, @A Exception {}
+}
+
+@interface A {}
+@interface B { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/TypeCasts.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,44 @@
+/*
+ * 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 new type annotation location: type casts
+ * @author Mahmood Ali
+ * @compile -source 1.7 TypeCasts.java
+ */
+class TypeCasts {
+  void methodA() {
+    String s = (@A String) null;
+    Object o = (@A Class<@A String>) null;
+  }
+
+  void methodB() {
+    String s = (@B("m") String) null;
+    Object o = (@B("m") Class<@B("m") String>) null;
+  }
+}
+
+@interface A { }
+@interface B { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/TypeParameters.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,50 @@
+/*
+ * 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 new type annotation location: class and method type parameters
+ * @author Mahmood Ali
+ * @compile -source 1.7 TypeParameters.java
+ */
+
+class Unannotated<K> { }
+class OneAnnotated<@A K> { }
+class TwoAnnotated<@A K, @A V> { }
+class SecondAnnotated<K, @A V extends String> { }
+
+class TestMethods {
+  <K> void unannotated() { }
+  <@A K> void oneAnnotated() { }
+  <@A K, @B("m") V> void twoAnnotated() { }
+  <K, @A V extends @A String> void secondAnnotated() { }
+}
+
+class UnannotatedB<K> { }
+class OneAnnotatedB<@B("m") K> { }
+class TwoAnnotatedB<@B("m") K, @B("m") V> { }
+class SecondAnnotatedB<K, @B("m") V extends @B("m") String> { }
+
+@interface A { }
+@interface B { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/typeAnnotations/newlocations/Wildcards.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,70 @@
+/*
+ * 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 new type annotation location: wildcard bound
+ * @author Mahmood Ali
+ * @compile -source 1.7 Wildcards.java
+ */
+class BoundTest {
+  void wcExtends(MyList<? extends @A String> l) { }
+  void wcSuper(MyList<? super @A String> l) { }
+
+  MyList<? extends @A String> returnWcExtends() { return null; }
+  MyList<? super @A String> returnWcSuper() { return null; }
+  MyList<? extends @A MyList<? super @B("m") String>> complex() { return null; }
+}
+
+class BoundWithValue {
+  void wcExtends(MyList<? extends @B("m") String> l) { }
+  void wcSuper(MyList<? super @B(value="m") String> l) { }
+
+  MyList<? extends @B("m") String> returnWcExtends() { return null; }
+  MyList<? super @B(value="m") String> returnWcSuper() { return null; }
+  MyList<? extends @B("m") MyList<? super @B("m") String>> complex() { return null; }
+}
+
+class SelfTest {
+  void wcExtends(MyList<@A ?> l) { }
+  void wcSuper(MyList<@A ?> l) { }
+
+  MyList<@A ?> returnWcExtends() { return null; }
+  MyList<@A ?> returnWcSuper() { return null; }
+  MyList<@A ? extends @A MyList<@B("m") ?>> complex() { return null; }
+}
+
+class SelfWithValue {
+  void wcExtends(MyList<@B("m") ?> l) { }
+  void wcSuper(MyList<@B(value="m") ?> l) { }
+
+  MyList<@B("m") ?> returnWcExtends() { return null; }
+  MyList<@B(value="m") ?> returnWcSuper() { return null; }
+  MyList<@B("m") ? extends MyList<@B("m") ? super String>> complex() { return null; }
+}
+
+class MyList<K> { }
+
+@interface A { }
+@interface B { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/typeAnnotations/ClassLiterals.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,174 @@
+/*
+ * 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.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test ClassLiterals
+ * @bug 6843077
+ * @summary test that all type annotations are present in the classfile
+ */
+
+public class ClassLiterals {
+    public static void main(String[] args) throws Exception {
+        new ClassLiterals().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf) {
+        test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Field m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, String name, boolean visible) {
+        int index = cf.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = cf.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Field m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+      File f = new File("Testa.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.util.*;");
+        out.println("class Testa { ");
+        out.println("  @interface A { }");
+
+        out.println(" void test() {");
+        out.println("  Object a = @A String.class;");
+        out.println("  Object b = @A String @A [] @A [].class;");
+        out.println(" }");
+        out.println("}");
+
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+      int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 4;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/typeAnnotations/JSR175Annotations.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,152 @@
+/*
+ * 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.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test JSR175Annotations
+ * @bug 6843077
+ * @summary test that only type annotations are recorded as such in classfile
+ */
+
+public class JSR175Annotations {
+    public static void main(String[] args) throws Exception {
+        new JSR175Annotations().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Field m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Field m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.lang.annotation.Retention;");
+        out.println("import java.lang.annotation.RetentionPolicy;");
+        out.println("abstract class Test { ");
+        out.println("  @Retention(RetentionPolicy.RUNTIME)");
+        out.println("  @interface A { }");
+        out.println("  @A String m;");
+        out.println("  @A String method(@A String a) {");
+        out.println("    return a;");
+        out.println("  }");
+        out.println("}");
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 0;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/typeAnnotations/NewArray.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,175 @@
+/*
+ * 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.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test NewArray
+ * @bug 6843077
+ * @summary test that all type annotations are present in the classfile
+ */
+
+public class NewArray {
+    public static void main(String[] args) throws Exception {
+        new NewArray().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf) {
+        test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Field m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, String name, boolean visible) {
+        int index = cf.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = cf.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Field m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+      File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.util.*;");
+        out.println("class Test { ");
+        out.println("  @interface A { }");
+
+        out.println(" void test() {");
+        out.println("  Object a = new @A String @A [5] @A  [];");
+        out.println("  Object b = new @A String @A [5] @A [3];");
+        out.println("  Object c = new @A String @A [] @A [] {};");
+        out.println(" }");
+        out.println("}");
+
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 9;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/typeAnnotations/Presence.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,189 @@
+/*
+ * 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.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test Presence
+ * @bug 6843077
+ * @summary test that all type annotations are present in the classfile
+ */
+
+public class Presence {
+    public static void main(String[] args) throws Exception {
+        new Presence().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf) {
+        test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Field m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, String name, boolean visible) {
+        int index = cf.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = cf.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Field m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.util.*;");
+        out.println("class Test<@Test.A T extends @Test.A List<@Test.A String>> { ");
+        out.println("  @interface A { }");
+
+        out.println("  Map<@A String, Map<@A String, @A String>> f1;");
+
+        out.println("  <@A T extends @A List<@A String>>");
+        out.println("  Map<@A String, @A List<@A String>>");
+        out.println("  method(List<@A String> @A [] param1, String @A [] @A ... param2) @A");
+        out.println("  throws @A Exception {");
+        out.println("    @A String lc1 = null;");
+        out.println("    @A List<@A String> lc2 = null;");
+        out.println("    @A String @A [] [] @A[] lc3 = null;");
+        out.println("    List<? extends @A List<@A String>> lc4 = null;");
+        out.println("    Object lc5 = (@A List<@A String>) null;");
+        out.println("    boolean lc6 = lc1 instanceof @A String;");
+        out.println("    boolean lc7 = lc5 instanceof @A String @A [] @A [];");
+        out.println("    new @A ArrayList<@A String>();");
+        out.println("    Object lc8 = new @A String @A [4];");
+        out.println("    Object lc9 = @A String.class;");
+        out.println("    Object lc10 = @A int.class;");
+        out.println("    return null;");
+        out.println("  }");
+        out.println("  void vararg1(String @A ... t) { } ");
+        out.println("}");
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 39;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/typeAnnotations/PresenceInner.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,185 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test PresenceInner
+ * @bug 6843077
+ * @summary test that annotations in inner types count only once
+ */
+
+public class PresenceInner {
+    public static void main(String[] args) throws Exception {
+        new PresenceInner().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        // counts are zero when vising outer class
+        countAnnotations(0);
+
+        // visit inner class
+        File innerFile = new File("Test$1Inner.class");
+        ClassFile icf = ClassFile.read(innerFile);
+        test(icf);
+        for (Field f : icf.fields) {
+            test(cf, f);
+        }
+        for (Method m: icf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations(1);
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf) {
+        test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Field m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, String name, boolean visible) {
+        int index = cf.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = cf.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Field m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+
+        out.println("class Test {");
+        out.println("  void method() {");
+        out.println("    class Inner<T extends @A Object> { }");
+        out.println("  }");
+        out.println("}");
+        out.println("@interface A { }");
+        out.close();
+        System.out.println(f.getAbsolutePath());
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations(int expected_invisibles) {
+        int expected_visibles = 0;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/typeAnnotations/Visibility.java	Fri Jun 26 19:12:41 2009 -0700
@@ -0,0 +1,139 @@
+/*
+ * 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.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test Visibility
+ * @bug 6843077
+ * @summary test that type annotations are recorded in the classfile
+ */
+
+public class Visibility {
+    public static void main(String[] args) throws Exception {
+        new Visibility().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.lang.annotation.Retention;");
+        out.println("import java.lang.annotation.RetentionPolicy;");
+        out.println("abstract class Test { ");
+        // visible annotations: RUNTIME
+        out.println("  @Retention(RetentionPolicy.RUNTIME)");
+        out.println("  @interface A { }");
+        out.println("  void visible() @A { }");
+
+        // invisible annotations: CLASS
+        out.println("  @Retention(RetentionPolicy.CLASS)");
+        out.println("  @interface B { }");
+        out.println("  void invisible() @B { }");
+
+        // source annotations
+        out.println("  @Retention(RetentionPolicy.SOURCE)");
+        out.println("  @interface C { }");
+        out.println("  void source() @C { }");
+
+        // default visibility: CLASS
+        out.println("  @interface D { }");
+        out.println("  void def() @D { }");
+        out.println("}");
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+      int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_all = 3, expected_visibles = 1, expected_invisibles = 2;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}