Fri, 26 Jun 2009 19:12:41 -0700
6855544: add missing files
Reviewed-by: jjg, mcimadamore, darcy
Contributed-by: mernst@cs.washington.edu, mali@csail.mit.edu, mpapi@csail.mit.edu
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java Fri Jun 26 19:12:41 2009 -0700 1.3 @@ -0,0 +1,47 @@ 1.4 +/* 1.5 + * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Sun designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Sun in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.26 + * have any questions. 1.27 + */ 1.28 + 1.29 +package com.sun.source.tree; 1.30 + 1.31 +import java.util.List; 1.32 + 1.33 +/** 1.34 + * A tree node for an annotated type 1.35 + * 1.36 + * For example: 1.37 + * <pre> 1.38 + * {@code @}<em>annotationType String</em> 1.39 + * {@code @}<em>annotationType</em> ( <em>arguments</em> ) <em>Date</em> 1.40 + * </pre> 1.41 + * 1.42 + * @see "JSR 308: Annotations on Java Types" 1.43 + * 1.44 + * @author Mahmood Ali 1.45 + * @since 1.7 1.46 + */ 1.47 +public interface AnnotatedTypeTree extends ExpressionTree { 1.48 + List<? extends AnnotationTree> getAnnotations(); 1.49 + ExpressionTree getUnderlyingType(); 1.50 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/src/share/classes/com/sun/source/util/AbstractTypeProcessor.java Fri Jun 26 19:12:41 2009 -0700 2.3 @@ -0,0 +1,245 @@ 2.4 +/* 2.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. Sun designates this 2.11 + * particular file as subject to the "Classpath" exception as provided 2.12 + * by Sun in the LICENSE file that accompanied this code. 2.13 + * 2.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.17 + * version 2 for more details (a copy is included in the LICENSE file that 2.18 + * accompanied this code). 2.19 + * 2.20 + * You should have received a copy of the GNU General Public License version 2.21 + * 2 along with this work; if not, write to the Free Software Foundation, 2.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.23 + * 2.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 2.26 + * have any questions. 2.27 + */ 2.28 + 2.29 +package com.sun.source.util; 2.30 + 2.31 +import java.util.ArrayList; 2.32 +import java.util.HashSet; 2.33 +import java.util.List; 2.34 +import java.util.Set; 2.35 + 2.36 +import javax.annotation.processing.*; 2.37 +import javax.lang.model.element.Name; 2.38 +import javax.lang.model.element.TypeElement; 2.39 +import javax.lang.model.util.ElementFilter; 2.40 + 2.41 +import com.sun.tools.javac.processing.JavacProcessingEnvironment; 2.42 +import com.sun.tools.javac.util.Context; 2.43 +import com.sun.tools.javac.util.Log; 2.44 + 2.45 +import com.sun.source.tree.ClassTree; 2.46 + 2.47 +/** 2.48 + * This class is an abstract annotation processor designed to be a 2.49 + * convenient superclass for concrete "type processors", processors that 2.50 + * require the type information in the processed source. 2.51 + * 2.52 + * <p>Type processing occurs in one round after the tool (e.g. java compiler) 2.53 + * analyzes the source (all sources taken as input to the tool and sources 2.54 + * generated by other annotation processors). 2.55 + * 2.56 + * <p>The tool infrastructure will interact with classes extending this abstract 2.57 + * class as follows: 2.58 + * 2.59 + * <ol> 2.60 + * [1-3: Identical to {@link Processor} life cycle] 2.61 + * 2.62 + * <li>If an existing {@code Processor} object is not being used, to 2.63 + * create an instance of a processor the tool calls the no-arg 2.64 + * constructor of the processor class. 2.65 + * 2.66 + * <li>Next, the tool calls the {@link #init init} method with 2.67 + * an appropriate {@code ProcessingEnvironment}. 2.68 + * 2.69 + * <li>Afterwards, the tool calls {@link #getSupportedAnnotationTypes 2.70 + * getSupportedAnnotationTypes}, {@link #getSupportedOptions 2.71 + * getSupportedOptions}, and {@link #getSupportedSourceVersion 2.72 + * getSupportedSourceVersion}. These methods are only called once per 2.73 + * run, not on each round. 2.74 + * 2.75 + * [4-5Unique to {@code AbstractTypeProcessor} subclasses] 2.76 + * 2.77 + * <li>For each class containing a supported annotation, the tool calls 2.78 + * {@link #typeProcess(TypeElement, TreePath) typeProcess} method on the 2.79 + * {@code Processor}. The class is guaranteed to be type-checked Java code 2.80 + * and all the tree type and symbol information is resolved. 2.81 + * 2.82 + * <li>Finally, the tools calls the 2.83 + * {@link #typeProcessingOver() typeProcessingOver} method 2.84 + * on the {@code Processor}. 2.85 + * 2.86 + * </ol> 2.87 + * 2.88 + * <p>The tool is permitted to ask type processors to process a class once 2.89 + * it is analyzed before the rest of classes are analyzed. The tool is also 2.90 + * permitted to stop type processing immediately if any errors are raised, 2.91 + * without invoking {@code typeProcessingOver} 2.92 + * 2.93 + * <p>A subclass may override any of the methods in this class, as long as the 2.94 + * general {@link javax.annotation.processing.Processor Processor} 2.95 + * contract is obeyed, with one notable exception. 2.96 + * {@link #process(Set, RoundEnvironment)} may not be overridden, as it 2.97 + * is called during the regular annotation phase before classes are analyzed. 2.98 + * 2.99 + * @author Mahmood Ali 2.100 + * @since 1.7 2.101 + */ 2.102 +public abstract class AbstractTypeProcessor extends AbstractProcessor { 2.103 + private final Set<Name> elements = new HashSet<Name>(); 2.104 + private boolean hasInvokedTypeProcessingOver = false; 2.105 + private JavacProcessingEnvironment env; 2.106 + private final AttributionTaskListener listener = new AttributionTaskListener(); 2.107 + 2.108 + /** 2.109 + * Constructor for subclasses to call. 2.110 + */ 2.111 + protected AbstractTypeProcessor() { } 2.112 + 2.113 + /** 2.114 + * {@inheritDoc} 2.115 + */ 2.116 + @Override 2.117 + public void init(ProcessingEnvironment env) { 2.118 + super.init(env); 2.119 + this.env = (JavacProcessingEnvironment)env; 2.120 + prepareContext(this.env.getContext()); 2.121 + } 2.122 + 2.123 + /** 2.124 + * The use of this method is obsolete in type processors. The method is 2.125 + * called during regular annotation processing phase only. 2.126 + */ 2.127 + @Override 2.128 + public final boolean process(Set<? extends TypeElement> annotations, 2.129 + RoundEnvironment roundEnv) { 2.130 + for (TypeElement elem : ElementFilter.typesIn(roundEnv.getRootElements())) { 2.131 + elements.add(elem.getQualifiedName()); 2.132 + } 2.133 + return false; 2.134 + } 2.135 + 2.136 + /** 2.137 + * Processes a fully analyzed class that contains a supported annotation 2.138 + * (look {@link #getSupportedAnnotationTypes()}). 2.139 + * 2.140 + * <p>The passed class is always a valid type-checked Java code. 2.141 + * 2.142 + * @param element element of the analyzed class 2.143 + * @param tree the tree path to the element, with the leaf being a 2.144 + * {@link ClassTree} 2.145 + */ 2.146 + public abstract void typeProcess(TypeElement element, TreePath tree); 2.147 + 2.148 + /** 2.149 + * A method to be called once all the classes are processed and no error 2.150 + * is reported. 2.151 + * 2.152 + * <p>Subclasses may override this method to do any aggregate analysis 2.153 + * (e.g. generate report, persistence) or resource deallocation. 2.154 + * 2.155 + * <p>If an error (a Java error or a processor error) is reported, this 2.156 + * method is not guaranteed to be invoked. 2.157 + */ 2.158 + public void typeProcessingOver() { } 2.159 + 2.160 + /** 2.161 + * adds a listener for attribution. 2.162 + */ 2.163 + private void prepareContext(Context context) { 2.164 + TaskListener otherListener = context.get(TaskListener.class); 2.165 + if (otherListener == null) { 2.166 + context.put(TaskListener.class, listener); 2.167 + } else { 2.168 + // handle cases of multiple listeners 2.169 + context.put(TaskListener.class, (TaskListener)null); 2.170 + TaskListeners listeners = new TaskListeners(); 2.171 + listeners.add(otherListener); 2.172 + listeners.add(listener); 2.173 + context.put(TaskListener.class, listeners); 2.174 + } 2.175 + } 2.176 + 2.177 + /** 2.178 + * A task listener that invokes the processor whenever a class is fully 2.179 + * analyzed. 2.180 + */ 2.181 + private final class AttributionTaskListener implements TaskListener { 2.182 + 2.183 + @Override 2.184 + public void finished(TaskEvent e) { 2.185 + Log log = Log.instance(env.getContext()); 2.186 + 2.187 + if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) { 2.188 + typeProcessingOver(); 2.189 + hasInvokedTypeProcessingOver = true; 2.190 + } 2.191 + 2.192 + if (e.getKind() != TaskEvent.Kind.ANALYZE) 2.193 + return; 2.194 + 2.195 + if (e.getTypeElement() == null) 2.196 + throw new AssertionError("event task without a type element"); 2.197 + if (e.getCompilationUnit() == null) 2.198 + throw new AssertionError("even task without compilation unit"); 2.199 + 2.200 + if (!elements.remove(e.getTypeElement().getQualifiedName())) 2.201 + return; 2.202 + 2.203 + if (log.nerrors != 0) 2.204 + return; 2.205 + 2.206 + TypeElement elem = e.getTypeElement(); 2.207 + TreePath p = Trees.instance(env).getPath(elem); 2.208 + 2.209 + typeProcess(elem, p); 2.210 + 2.211 + if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) { 2.212 + typeProcessingOver(); 2.213 + hasInvokedTypeProcessingOver = true; 2.214 + } 2.215 + } 2.216 + 2.217 + @Override 2.218 + public void started(TaskEvent e) { } 2.219 + 2.220 + } 2.221 + 2.222 + /** 2.223 + * A task listener multiplexer. 2.224 + */ 2.225 + private static class TaskListeners implements TaskListener { 2.226 + private final List<TaskListener> listeners = new ArrayList<TaskListener>(); 2.227 + 2.228 + public void add(TaskListener listener) { 2.229 + listeners.add(listener); 2.230 + } 2.231 + 2.232 + public void remove(TaskListener listener) { 2.233 + listeners.remove(listener); 2.234 + } 2.235 + 2.236 + @Override 2.237 + public void finished(TaskEvent e) { 2.238 + for (TaskListener listener : listeners) 2.239 + listener.finished(e); 2.240 + } 2.241 + 2.242 + @Override 2.243 + public void started(TaskEvent e) { 2.244 + for (TaskListener listener : listeners) 2.245 + listener.started(e); 2.246 + } 2.247 + } 2.248 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java Fri Jun 26 19:12:41 2009 -0700 3.3 @@ -0,0 +1,614 @@ 3.4 +/* 3.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. Sun designates this 3.11 + * particular file as subject to the "Classpath" exception as provided 3.12 + * by Sun in the LICENSE file that accompanied this code. 3.13 + * 3.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.17 + * version 2 for more details (a copy is included in the LICENSE file that 3.18 + * accompanied this code). 3.19 + * 3.20 + * You should have received a copy of the GNU General Public License version 3.21 + * 2 along with this work; if not, write to the Free Software Foundation, 3.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.23 + * 3.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 3.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 3.26 + * have any questions. 3.27 + */ 3.28 + 3.29 +package com.sun.tools.classfile; 3.30 + 3.31 +import java.io.IOException; 3.32 +import java.util.ArrayList; 3.33 +import java.util.EnumSet; 3.34 +import java.util.List; 3.35 +import java.util.Set; 3.36 + 3.37 +import static com.sun.tools.classfile.ExtendedAnnotation.TargetAttribute.*; 3.38 + 3.39 +/** 3.40 + * See JSR 308 specification, section 4.1 3.41 + * 3.42 + * <p><b>This is NOT part of any API supported by Sun Microsystems. If 3.43 + * you write code that depends on this, you do so at your own risk. 3.44 + * This code and its internal interfaces are subject to change or 3.45 + * deletion without notice.</b> 3.46 + */ 3.47 +public class ExtendedAnnotation { 3.48 + ExtendedAnnotation(ClassReader cr) throws IOException, Annotation.InvalidAnnotation { 3.49 + annotation = new Annotation(cr); 3.50 + position = read_position(cr); 3.51 + } 3.52 + 3.53 + public ExtendedAnnotation(ConstantPool constant_pool, 3.54 + Annotation annotation, Position position) { 3.55 + this.annotation = annotation; 3.56 + this.position = position; 3.57 + } 3.58 + 3.59 + public int length() { 3.60 + int n = annotation.length(); 3.61 + n += position_length(position); 3.62 + return n; 3.63 + } 3.64 + 3.65 + public final Annotation annotation; 3.66 + public final Position position; 3.67 + 3.68 + private static Position read_position(ClassReader cr) throws IOException, Annotation.InvalidAnnotation { 3.69 + // Copied from ClassReader 3.70 + int tag = (byte)cr.readUnsignedByte(); // cast to introduce signedness 3.71 + if (!TargetType.isValidTargetTypeValue(tag)) 3.72 + throw new Annotation.InvalidAnnotation("invalid type annotation target type value: " + tag); 3.73 + 3.74 + TargetType type = TargetType.fromTargetTypeValue(tag); 3.75 + 3.76 + Position position = new Position(); 3.77 + position.type = type; 3.78 + 3.79 + switch (type) { 3.80 + // type case 3.81 + case TYPECAST: 3.82 + case TYPECAST_GENERIC_OR_ARRAY: 3.83 + // object creation 3.84 + case INSTANCEOF: 3.85 + case INSTANCEOF_GENERIC_OR_ARRAY: 3.86 + // new expression 3.87 + case NEW: 3.88 + case NEW_GENERIC_OR_ARRAY: 3.89 + position.offset = cr.readUnsignedShort(); 3.90 + break; 3.91 + // local variable 3.92 + case LOCAL_VARIABLE: 3.93 + case LOCAL_VARIABLE_GENERIC_OR_ARRAY: 3.94 + int table_length = cr.readUnsignedShort(); 3.95 + position.lvarOffset = new int[table_length]; 3.96 + position.lvarLength = new int[table_length]; 3.97 + position.lvarIndex = new int[table_length]; 3.98 + for (int i = 0; i < table_length; ++i) { 3.99 + position.lvarOffset[i] = cr.readUnsignedShort(); 3.100 + position.lvarLength[i] = cr.readUnsignedShort(); 3.101 + position.lvarIndex[i] = cr.readUnsignedShort(); 3.102 + } 3.103 + break; 3.104 + // method receiver 3.105 + case METHOD_RECEIVER: 3.106 + // Do nothing 3.107 + break; 3.108 + // type parameters 3.109 + case CLASS_TYPE_PARAMETER: 3.110 + case METHOD_TYPE_PARAMETER: 3.111 + position.parameter_index = cr.readUnsignedByte(); 3.112 + break; 3.113 + // type parameter bounds 3.114 + case CLASS_TYPE_PARAMETER_BOUND: 3.115 + case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 3.116 + case METHOD_TYPE_PARAMETER_BOUND: 3.117 + case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 3.118 + position.parameter_index = cr.readUnsignedByte(); 3.119 + position.bound_index = cr.readUnsignedByte(); 3.120 + break; 3.121 + // wildcards 3.122 + case WILDCARD_BOUND: 3.123 + case WILDCARD_BOUND_GENERIC_OR_ARRAY: 3.124 + position.wildcard_position = read_position(cr); 3.125 + break; 3.126 + // Class extends and implements clauses 3.127 + case CLASS_EXTENDS: 3.128 + case CLASS_EXTENDS_GENERIC_OR_ARRAY: 3.129 + position.type_index = cr.readUnsignedByte(); 3.130 + break; 3.131 + // throws 3.132 + case THROWS: 3.133 + position.type_index = cr.readUnsignedByte(); 3.134 + break; 3.135 + case CLASS_LITERAL: 3.136 + case CLASS_LITERAL_GENERIC_OR_ARRAY: 3.137 + position.offset = cr.readUnsignedShort(); 3.138 + break; 3.139 + // method parameter: not specified 3.140 + case METHOD_PARAMETER_GENERIC_OR_ARRAY: 3.141 + position.parameter_index = cr.readUnsignedByte(); 3.142 + break; 3.143 + // method type argument: wasn't specified 3.144 + case NEW_TYPE_ARGUMENT: 3.145 + case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 3.146 + case METHOD_TYPE_ARGUMENT: 3.147 + case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 3.148 + position.offset = cr.readUnsignedShort(); 3.149 + position.type_index = cr.readUnsignedByte(); 3.150 + break; 3.151 + // We don't need to worry abut these 3.152 + case METHOD_RETURN_GENERIC_OR_ARRAY: 3.153 + case FIELD_GENERIC_OR_ARRAY: 3.154 + break; 3.155 + case UNKNOWN: 3.156 + break; 3.157 + default: 3.158 + throw new AssertionError("Cannot be here"); 3.159 + } 3.160 + 3.161 + if (type.hasLocation()) { 3.162 + int len = cr.readUnsignedShort(); 3.163 + List<Integer> loc = new ArrayList<Integer>(len); 3.164 + for (int i = 0; i < len; i++) 3.165 + loc.add(cr.readUnsignedByte()); 3.166 + position.location = loc; 3.167 + } 3.168 + return position; 3.169 + } 3.170 + 3.171 + private static int position_length(Position pos) { 3.172 + int n = 0; 3.173 + n += 1; // target_type 3.174 + switch (pos.type) { 3.175 + // type case 3.176 + case TYPECAST: 3.177 + case TYPECAST_GENERIC_OR_ARRAY: 3.178 + // object creation 3.179 + case INSTANCEOF: 3.180 + case INSTANCEOF_GENERIC_OR_ARRAY: 3.181 + // new expression 3.182 + case NEW: 3.183 + case NEW_GENERIC_OR_ARRAY: 3.184 + n += 2; 3.185 + break; 3.186 + // local variable 3.187 + case LOCAL_VARIABLE: 3.188 + case LOCAL_VARIABLE_GENERIC_OR_ARRAY: 3.189 + n += 2; // table_length; 3.190 + int table_length = pos.lvarOffset.length; 3.191 + n += 2 * table_length; // offset 3.192 + n += 2 * table_length; // length; 3.193 + n += 2 * table_length; // index 3.194 + break; 3.195 + // method receiver 3.196 + case METHOD_RECEIVER: 3.197 + // Do nothing 3.198 + break; 3.199 + // type parameters 3.200 + case CLASS_TYPE_PARAMETER: 3.201 + case METHOD_TYPE_PARAMETER: 3.202 + n += 1; // parameter_index; 3.203 + break; 3.204 + // type parameter bounds 3.205 + case CLASS_TYPE_PARAMETER_BOUND: 3.206 + case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 3.207 + case METHOD_TYPE_PARAMETER_BOUND: 3.208 + case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 3.209 + n += 1; // parameter_index 3.210 + n += 1; // bound_index 3.211 + break; 3.212 + case WILDCARD_BOUND: 3.213 + case WILDCARD_BOUND_GENERIC_OR_ARRAY: 3.214 + n += position_length(pos.wildcard_position); 3.215 + break; 3.216 + // Class extends and implements clauses 3.217 + case CLASS_EXTENDS: 3.218 + case CLASS_EXTENDS_GENERIC_OR_ARRAY: 3.219 + n += 1; // type_index 3.220 + break; 3.221 + // throws 3.222 + case THROWS: 3.223 + n += 1; // type_index 3.224 + break; 3.225 + case CLASS_LITERAL: 3.226 + case CLASS_LITERAL_GENERIC_OR_ARRAY: 3.227 + n += 1; // offset 3.228 + break; 3.229 + // method parameter: not specified 3.230 + case METHOD_PARAMETER_GENERIC_OR_ARRAY: 3.231 + n += 1; // parameter_index 3.232 + break; 3.233 + // method type argument: wasn't specified 3.234 + case NEW_TYPE_ARGUMENT: 3.235 + case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 3.236 + case METHOD_TYPE_ARGUMENT: 3.237 + case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 3.238 + n += 2; // offset 3.239 + n += 1; // type index 3.240 + break; 3.241 + // We don't need to worry abut these 3.242 + case METHOD_RETURN_GENERIC_OR_ARRAY: 3.243 + case FIELD_GENERIC_OR_ARRAY: 3.244 + break; 3.245 + case UNKNOWN: 3.246 + break; 3.247 + default: 3.248 + } 3.249 + 3.250 + if (pos.type.hasLocation()) { 3.251 + n += 2; // length 3.252 + n += 1 * pos.location.size(); // actual array size 3.253 + } 3.254 + 3.255 + return n; 3.256 + } 3.257 + 3.258 + // Code duplicated from com.sun.tools.javac.code.TypeAnnotations.Position 3.259 + public static class Position { 3.260 + 3.261 + public TargetType type = TargetType.UNKNOWN; 3.262 + 3.263 + // For generic/array types. 3.264 + public List<Integer> location = new ArrayList<Integer>(); 3.265 + 3.266 + // Tree position. 3.267 + public int pos = -1; 3.268 + 3.269 + // For typecasts, type tests, new (and locals, as start_pc). 3.270 + public int offset = -1; 3.271 + 3.272 + // For locals. 3.273 + public int[] lvarOffset = new int[] { -1 }; 3.274 + public int[] lvarLength = new int[] { -1 }; 3.275 + public int[] lvarIndex = new int[] { -1 }; 3.276 + 3.277 + // For type parameter bound 3.278 + public int bound_index = -1; 3.279 + 3.280 + // For type parameter and method parameter 3.281 + public int parameter_index = -1; 3.282 + 3.283 + // For class extends, implements, and throws classes 3.284 + public int type_index = -2; 3.285 + 3.286 + // For wildcards 3.287 + public Position wildcard_position = null; 3.288 + 3.289 + @Override 3.290 + public String toString() { 3.291 + StringBuilder sb = new StringBuilder(); 3.292 + sb.append('['); 3.293 + sb.append(type); 3.294 + 3.295 + switch (type) { 3.296 + // type case 3.297 + case TYPECAST: 3.298 + case TYPECAST_GENERIC_OR_ARRAY: 3.299 + // object creation 3.300 + case INSTANCEOF: 3.301 + case INSTANCEOF_GENERIC_OR_ARRAY: 3.302 + // new expression 3.303 + case NEW: 3.304 + case NEW_GENERIC_OR_ARRAY: 3.305 + case NEW_TYPE_ARGUMENT: 3.306 + case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 3.307 + sb.append(", offset = "); 3.308 + sb.append(offset); 3.309 + break; 3.310 + // local variable 3.311 + case LOCAL_VARIABLE: 3.312 + case LOCAL_VARIABLE_GENERIC_OR_ARRAY: 3.313 + sb.append(", {"); 3.314 + for (int i = 0; i < lvarOffset.length; ++i) { 3.315 + if (i != 0) sb.append("; "); 3.316 + sb.append(", start_pc = "); 3.317 + sb.append(lvarOffset[i]); 3.318 + sb.append(", length = "); 3.319 + sb.append(lvarLength[i]); 3.320 + sb.append(", index = "); 3.321 + sb.append(lvarIndex[i]); 3.322 + } 3.323 + sb.append("}"); 3.324 + break; 3.325 + // method receiver 3.326 + case METHOD_RECEIVER: 3.327 + // Do nothing 3.328 + break; 3.329 + // type parameters 3.330 + case CLASS_TYPE_PARAMETER: 3.331 + case METHOD_TYPE_PARAMETER: 3.332 + sb.append(", param_index = "); 3.333 + sb.append(parameter_index); 3.334 + break; 3.335 + // type parameters bound 3.336 + case CLASS_TYPE_PARAMETER_BOUND: 3.337 + case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 3.338 + case METHOD_TYPE_PARAMETER_BOUND: 3.339 + case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 3.340 + sb.append(", param_index = "); 3.341 + sb.append(parameter_index); 3.342 + sb.append(", bound_index = "); 3.343 + sb.append(bound_index); 3.344 + break; 3.345 + // wildcard 3.346 + case WILDCARD_BOUND: 3.347 + case WILDCARD_BOUND_GENERIC_OR_ARRAY: 3.348 + sb.append(", wild_card = "); 3.349 + sb.append(wildcard_position); 3.350 + break; 3.351 + // Class extends and implements clauses 3.352 + case CLASS_EXTENDS: 3.353 + case CLASS_EXTENDS_GENERIC_OR_ARRAY: 3.354 + sb.append(", type_index = "); 3.355 + sb.append(type_index); 3.356 + break; 3.357 + // throws 3.358 + case THROWS: 3.359 + sb.append(", type_index = "); 3.360 + sb.append(type_index); 3.361 + break; 3.362 + case CLASS_LITERAL: 3.363 + sb.append(", offset = "); 3.364 + sb.append(offset); 3.365 + break; 3.366 + // method parameter: not specified 3.367 + case METHOD_PARAMETER_GENERIC_OR_ARRAY: 3.368 + sb.append(", param_index = "); 3.369 + sb.append(parameter_index); 3.370 + break; 3.371 + // method type argument: wasn't specified 3.372 + case METHOD_TYPE_ARGUMENT: 3.373 + case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 3.374 + sb.append(", offset = "); 3.375 + sb.append(offset); 3.376 + sb.append(", type_index = "); 3.377 + sb.append(type_index); 3.378 + break; 3.379 + // We don't need to worry abut these 3.380 + case METHOD_RETURN_GENERIC_OR_ARRAY: 3.381 + case FIELD_GENERIC_OR_ARRAY: 3.382 + break; 3.383 + case UNKNOWN: 3.384 + break; 3.385 + default: 3.386 + throw new AssertionError("unknown type: " + type); 3.387 + } 3.388 + 3.389 + // Append location data for generics/arrays. 3.390 + if (type.hasLocation()) { 3.391 + sb.append(", location = ("); 3.392 + sb.append(location); 3.393 + sb.append(")"); 3.394 + } 3.395 + 3.396 + sb.append(", pos = "); 3.397 + sb.append(pos); 3.398 + 3.399 + sb.append(']'); 3.400 + return sb.toString(); 3.401 + } 3.402 + } 3.403 + 3.404 + // Code duplicated from com.sun.tools.javac.comp.TargetType 3.405 + public enum TargetType { 3.406 + 3.407 + /** For annotations on typecasts. */ 3.408 + TYPECAST(0x00), 3.409 + 3.410 + /** For annotations on a type argument or nested array of a typecast. */ 3.411 + TYPECAST_GENERIC_OR_ARRAY(0x01, HasLocation), 3.412 + 3.413 + /** For annotations on type tests. */ 3.414 + INSTANCEOF(0x02), 3.415 + 3.416 + /** For annotations on a type argument or nested array of a type test. */ 3.417 + INSTANCEOF_GENERIC_OR_ARRAY(0x03, HasLocation), 3.418 + 3.419 + /** For annotations on object creation expressions. */ 3.420 + NEW(0x04), 3.421 + 3.422 + /** 3.423 + * For annotations on a type argument or nested array of an object creation 3.424 + * expression. 3.425 + */ 3.426 + NEW_GENERIC_OR_ARRAY(0x05, HasLocation), 3.427 + 3.428 + 3.429 + /** For annotations on the method receiver. */ 3.430 + METHOD_RECEIVER(0x06), 3.431 + 3.432 + // invalid location 3.433 + // METHOD_RECEIVER_GENERIC_OR_ARRAY(0x07, HasLocation), 3.434 + 3.435 + /** For annotations on local variables. */ 3.436 + LOCAL_VARIABLE(0x08), 3.437 + 3.438 + /** For annotations on a type argument or nested array of a local. */ 3.439 + LOCAL_VARIABLE_GENERIC_OR_ARRAY(0x09, HasLocation), 3.440 + 3.441 + // already handled by regular annotations 3.442 + // METHOD_RETURN(0x0A), 3.443 + 3.444 + /** 3.445 + * For annotations on a type argument or nested array of a method return 3.446 + * type. 3.447 + */ 3.448 + METHOD_RETURN_GENERIC_OR_ARRAY(0x0B, HasLocation), 3.449 + 3.450 + // already handled by regular annotations 3.451 + // METHOD_PARAMETER(0x0C), 3.452 + 3.453 + /** For annotations on a type argument or nested array of a method parameter. */ 3.454 + METHOD_PARAMETER_GENERIC_OR_ARRAY(0x0D, HasLocation), 3.455 + 3.456 + // already handled by regular annotations 3.457 + // FIELD(0x0E), 3.458 + 3.459 + /** For annotations on a type argument or nested array of a field. */ 3.460 + FIELD_GENERIC_OR_ARRAY(0x0F, HasLocation), 3.461 + 3.462 + /** For annotations on a bound of a type parameter of a class. */ 3.463 + CLASS_TYPE_PARAMETER_BOUND(0x10, HasBound, HasParameter), 3.464 + 3.465 + /** 3.466 + * For annotations on a type argument or nested array of a bound of a type 3.467 + * parameter of a class. 3.468 + */ 3.469 + CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x11, HasBound, HasLocation, HasParameter), 3.470 + 3.471 + /** For annotations on a bound of a type parameter of a method. */ 3.472 + METHOD_TYPE_PARAMETER_BOUND(0x12, HasBound, HasParameter), 3.473 + 3.474 + /** 3.475 + * For annotations on a type argument or nested array of a bound of a type 3.476 + * parameter of a method. 3.477 + */ 3.478 + METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x13, HasBound, HasLocation, HasParameter), 3.479 + 3.480 + /** For annotations on the type of an "extends" or "implements" clause. */ 3.481 + CLASS_EXTENDS(0x14), 3.482 + 3.483 + /** For annotations on the inner type of an "extends" or "implements" clause. */ 3.484 + CLASS_EXTENDS_GENERIC_OR_ARRAY(0x15, HasLocation), 3.485 + 3.486 + /** For annotations on a throws clause in a method declaration. */ 3.487 + THROWS(0x16), 3.488 + 3.489 + // invalid location 3.490 + // THROWS_GENERIC_OR_ARRAY(0x17, HasLocation), 3.491 + 3.492 + /** For annotations in type arguments of object creation expressions. */ 3.493 + NEW_TYPE_ARGUMENT(0x18), 3.494 + NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x19, HasLocation), 3.495 + 3.496 + METHOD_TYPE_ARGUMENT(0x1A), 3.497 + METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x1B, HasLocation), 3.498 + 3.499 + WILDCARD_BOUND(0x1C, HasBound), 3.500 + WILDCARD_BOUND_GENERIC_OR_ARRAY(0x1D, HasBound, HasLocation), 3.501 + 3.502 + CLASS_LITERAL(0x1E), 3.503 + CLASS_LITERAL_GENERIC_OR_ARRAY(0x1F, HasLocation), 3.504 + 3.505 + METHOD_TYPE_PARAMETER(0x20, HasParameter), 3.506 + 3.507 + // invalid location 3.508 + // METHOD_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x21, HasLocation, HasParameter), 3.509 + 3.510 + CLASS_TYPE_PARAMETER(0x22, HasParameter), 3.511 + 3.512 + // invalid location 3.513 + // CLASS_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x23, HasLocation, HasParameter), 3.514 + 3.515 + /** For annotations with an unknown target. */ 3.516 + UNKNOWN(-1); 3.517 + 3.518 + static final int MAXIMUM_TARGET_TYPE_VALUE = 0x22; 3.519 + 3.520 + private final int targetTypeValue; 3.521 + private Set<TargetAttribute> flags; 3.522 + 3.523 + TargetType(int targetTypeValue, TargetAttribute... attrs) { 3.524 + if (targetTypeValue < Byte.MIN_VALUE 3.525 + || targetTypeValue > Byte.MAX_VALUE) 3.526 + throw new AssertionError("attribute type value needs to be a byte: " + targetTypeValue); 3.527 + this.targetTypeValue = (byte)targetTypeValue; 3.528 + this.flags = EnumSet.noneOf(TargetAttribute.class); 3.529 + for (TargetAttribute attr : attrs) 3.530 + this.flags.add(attr); 3.531 + } 3.532 + 3.533 + /** 3.534 + * Returns whether or not this TargetType represents an annotation whose 3.535 + * target is an inner type of a generic or array type. 3.536 + * 3.537 + * @return true if this TargetType represents an annotation on an inner 3.538 + * type, false otherwise 3.539 + */ 3.540 + public boolean hasLocation() { 3.541 + return flags.contains(HasLocation); 3.542 + } 3.543 + 3.544 + public TargetType getGenericComplement() { 3.545 + if (hasLocation()) 3.546 + return this; 3.547 + else 3.548 + return fromTargetTypeValue(targetTypeValue() + 1); 3.549 + } 3.550 + 3.551 + /** 3.552 + * Returns whether or not this TargetType represents an annotation whose 3.553 + * target has a parameter index. 3.554 + * 3.555 + * @return true if this TargetType has a parameter index, 3.556 + * false otherwise 3.557 + */ 3.558 + public boolean hasParameter() { 3.559 + return flags.contains(HasParameter); 3.560 + } 3.561 + 3.562 + /** 3.563 + * Returns whether or not this TargetType represents an annotation whose 3.564 + * target is a type parameter bound. 3.565 + * 3.566 + * @return true if this TargetType represents an type parameter bound 3.567 + * annotation, false otherwise 3.568 + */ 3.569 + public boolean hasBound() { 3.570 + return flags.contains(HasBound); 3.571 + } 3.572 + 3.573 + public int targetTypeValue() { 3.574 + return this.targetTypeValue; 3.575 + } 3.576 + 3.577 + private static TargetType[] targets = null; 3.578 + 3.579 + private static TargetType[] buildTargets() { 3.580 + TargetType[] targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1]; 3.581 + TargetType[] alltargets = values(); 3.582 + for (TargetType target : alltargets) 3.583 + if (target.targetTypeValue >= 0) 3.584 + targets[target.targetTypeValue] = target; 3.585 + for (int i = 0; i <= MAXIMUM_TARGET_TYPE_VALUE; ++i) 3.586 + if (targets[i] == null) 3.587 + targets[i] = UNKNOWN; 3.588 + return targets; 3.589 + } 3.590 + 3.591 + public static boolean isValidTargetTypeValue(int tag) { 3.592 + if (targets == null) 3.593 + targets = buildTargets(); 3.594 + 3.595 + if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue)) 3.596 + return true; 3.597 + 3.598 + return (tag >= 0 && tag < targets.length); 3.599 + } 3.600 + 3.601 + public static TargetType fromTargetTypeValue(int tag) { 3.602 + if (targets == null) 3.603 + targets = buildTargets(); 3.604 + 3.605 + if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue)) 3.606 + return UNKNOWN; 3.607 + 3.608 + if (tag < 0 || tag >= targets.length) 3.609 + throw new IllegalArgumentException("Unknown TargetType: " + tag); 3.610 + return targets[tag]; 3.611 + } 3.612 + } 3.613 + 3.614 + static enum TargetAttribute { 3.615 + HasLocation, HasParameter, HasBound; 3.616 + } 3.617 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/src/share/classes/com/sun/tools/classfile/RuntimeInvisibleTypeAnnotations_attribute.java Fri Jun 26 19:12:41 2009 -0700 4.3 @@ -0,0 +1,56 @@ 4.4 +/* 4.5 + * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. Sun designates this 4.11 + * particular file as subject to the "Classpath" exception as provided 4.12 + * by Sun in the LICENSE file that accompanied this code. 4.13 + * 4.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.17 + * version 2 for more details (a copy is included in the LICENSE file that 4.18 + * accompanied this code). 4.19 + * 4.20 + * You should have received a copy of the GNU General Public License version 4.21 + * 2 along with this work; if not, write to the Free Software Foundation, 4.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.23 + * 4.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 4.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 4.26 + * have any questions. 4.27 + */ 4.28 + 4.29 +package com.sun.tools.classfile; 4.30 + 4.31 +import java.io.IOException; 4.32 + 4.33 +/** 4.34 + * See JSR 308 specification, section 4.1 4.35 + * 4.36 + * <p><b>This is NOT part of any API supported by Sun Microsystems. If 4.37 + * you write code that depends on this, you do so at your own risk. 4.38 + * This code and its internal interfaces are subject to change or 4.39 + * deletion without notice.</b> 4.40 + */ 4.41 +public class RuntimeInvisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute { 4.42 + RuntimeInvisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length) 4.43 + throws IOException, Annotation.InvalidAnnotation { 4.44 + super(cr, name_index, length); 4.45 + } 4.46 + 4.47 + public RuntimeInvisibleTypeAnnotations_attribute(ConstantPool cp, ExtendedAnnotation[] annotations) 4.48 + throws ConstantPoolException { 4.49 + this(cp.getUTF8Index(Attribute.RuntimeInvisibleTypeAnnotations), annotations); 4.50 + } 4.51 + 4.52 + public RuntimeInvisibleTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) { 4.53 + super(name_index, annotations); 4.54 + } 4.55 + 4.56 + public <R, P> R accept(Visitor<R, P> visitor, P p) { 4.57 + return visitor.visitRuntimeInvisibleTypeAnnotations(this, p); 4.58 + } 4.59 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/src/share/classes/com/sun/tools/classfile/RuntimeTypeAnnotations_attribute.java Fri Jun 26 19:12:41 2009 -0700 5.3 @@ -0,0 +1,61 @@ 5.4 +/* 5.5 + * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. 5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 + * 5.8 + * This code is free software; you can redistribute it and/or modify it 5.9 + * under the terms of the GNU General Public License version 2 only, as 5.10 + * published by the Free Software Foundation. Sun designates this 5.11 + * particular file as subject to the "Classpath" exception as provided 5.12 + * by Sun in the LICENSE file that accompanied this code. 5.13 + * 5.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 5.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.17 + * version 2 for more details (a copy is included in the LICENSE file that 5.18 + * accompanied this code). 5.19 + * 5.20 + * You should have received a copy of the GNU General Public License version 5.21 + * 2 along with this work; if not, write to the Free Software Foundation, 5.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.23 + * 5.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 5.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 5.26 + * have any questions. 5.27 + */ 5.28 + 5.29 +package com.sun.tools.classfile; 5.30 + 5.31 +import java.io.IOException; 5.32 + 5.33 +/** 5.34 + * See JSR 308 specification, section 4 5.35 + * 5.36 + * <p><b>This is NOT part of any API supported by Sun Microsystems. If 5.37 + * you write code that depends on this, you do so at your own risk. 5.38 + * This code and its internal interfaces are subject to change or 5.39 + * deletion without notice.</b> 5.40 + */ 5.41 +public abstract class RuntimeTypeAnnotations_attribute extends Attribute { 5.42 + protected RuntimeTypeAnnotations_attribute(ClassReader cr, int name_index, int length) 5.43 + throws IOException, Annotation.InvalidAnnotation { 5.44 + super(name_index, length); 5.45 + int num_annotations = cr.readUnsignedShort(); 5.46 + annotations = new ExtendedAnnotation[num_annotations]; 5.47 + for (int i = 0; i < annotations.length; i++) 5.48 + annotations[i] = new ExtendedAnnotation(cr); 5.49 + } 5.50 + 5.51 + protected RuntimeTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) { 5.52 + super(name_index, length(annotations)); 5.53 + this.annotations = annotations; 5.54 + } 5.55 + 5.56 + private static int length(ExtendedAnnotation[] annos) { 5.57 + int n = 2; 5.58 + for (ExtendedAnnotation anno: annos) 5.59 + n += anno.length(); 5.60 + return n; 5.61 + } 5.62 + 5.63 + public final ExtendedAnnotation[] annotations; 5.64 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/src/share/classes/com/sun/tools/classfile/RuntimeVisibleTypeAnnotations_attribute.java Fri Jun 26 19:12:41 2009 -0700 6.3 @@ -0,0 +1,56 @@ 6.4 +/* 6.5 + * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. 6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.7 + * 6.8 + * This code is free software; you can redistribute it and/or modify it 6.9 + * under the terms of the GNU General Public License version 2 only, as 6.10 + * published by the Free Software Foundation. Sun designates this 6.11 + * particular file as subject to the "Classpath" exception as provided 6.12 + * by Sun in the LICENSE file that accompanied this code. 6.13 + * 6.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 6.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6.17 + * version 2 for more details (a copy is included in the LICENSE file that 6.18 + * accompanied this code). 6.19 + * 6.20 + * You should have received a copy of the GNU General Public License version 6.21 + * 2 along with this work; if not, write to the Free Software Foundation, 6.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6.23 + * 6.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 6.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 6.26 + * have any questions. 6.27 + */ 6.28 + 6.29 +package com.sun.tools.classfile; 6.30 + 6.31 +import java.io.IOException; 6.32 + 6.33 +/** 6.34 + * See JSR 308 specification, section 4.1 6.35 + * 6.36 + * <p><b>This is NOT part of any API supported by Sun Microsystems. If 6.37 + * you write code that depends on this, you do so at your own risk. 6.38 + * This code and its internal interfaces are subject to change or 6.39 + * deletion without notice.</b> 6.40 + */ 6.41 +public class RuntimeVisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute { 6.42 + RuntimeVisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length) 6.43 + throws IOException, Annotation.InvalidAnnotation { 6.44 + super(cr, name_index, length); 6.45 + } 6.46 + 6.47 + public RuntimeVisibleTypeAnnotations_attribute(ConstantPool cp, ExtendedAnnotation[] annotations) 6.48 + throws ConstantPoolException { 6.49 + this(cp.getUTF8Index(Attribute.RuntimeVisibleTypeAnnotations), annotations); 6.50 + } 6.51 + 6.52 + public RuntimeVisibleTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) { 6.53 + super(name_index, annotations); 6.54 + } 6.55 + 6.56 + public <R, P> R accept(Visitor<R, P> visitor, P p) { 6.57 + return visitor.visitRuntimeVisibleTypeAnnotations(this, p); 6.58 + } 6.59 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/src/share/classes/com/sun/tools/javac/code/TargetType.java Fri Jun 26 19:12:41 2009 -0700 7.3 @@ -0,0 +1,266 @@ 7.4 +/* 7.5 + * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved. 7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.7 + * 7.8 + * This code is free software; you can redistribute it and/or modify it 7.9 + * under the terms of the GNU General Public License version 2 only, as 7.10 + * published by the Free Software Foundation. Sun designates this 7.11 + * particular file as subject to the "Classpath" exception as provided 7.12 + * by Sun in the LICENSE file that accompanied this code. 7.13 + * 7.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 7.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7.17 + * version 2 for more details (a copy is included in the LICENSE file that 7.18 + * accompanied this code). 7.19 + * 7.20 + * You should have received a copy of the GNU General Public License version 7.21 + * 2 along with this work; if not, write to the Free Software Foundation, 7.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7.23 + * 7.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 7.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 7.26 + * have any questions. 7.27 + */ 7.28 + 7.29 +package com.sun.tools.javac.code; 7.30 + 7.31 +import static com.sun.tools.javac.code.TargetType.TargetAttribute.*; 7.32 + 7.33 +import java.util.EnumSet; 7.34 +import java.util.Set; 7.35 + 7.36 +/** 7.37 + * Describes the type of program element an extended annotation (or extended 7.38 + * compound attribute) targets. 7.39 + * 7.40 + * By comparison, a Tree.Kind has enum values for all elements in the AST, and 7.41 + * it does not provide enough resolution for type arguments (i.e., whether an 7.42 + * annotation targets a type argument in a local variable, method return type, 7.43 + * or a typecast). 7.44 + * 7.45 + * <p><b>This is NOT part of any API supported by Sun Microsystems. If 7.46 + * you write code that depends on this, you do so at your own risk. 7.47 + * This code and its internal interfaces are subject to change or 7.48 + * deletion without notice.</b> 7.49 + */ 7.50 +public enum TargetType { 7.51 + 7.52 + // 7.53 + // Some target types are commented out, because Java doesn't permit such 7.54 + // targets. They are included here to confirm that their omission is 7.55 + // intentional omission not an accidental omission. 7.56 + // 7.57 + 7.58 + /** For annotations on typecasts. */ 7.59 + TYPECAST(0x00), 7.60 + 7.61 + /** For annotations on a type argument or nested array of a typecast. */ 7.62 + TYPECAST_GENERIC_OR_ARRAY(0x01, HasLocation), 7.63 + 7.64 + /** For annotations on type tests. */ 7.65 + INSTANCEOF(0x02), 7.66 + 7.67 + /** For annotations on a type argument or nested array of a type test. */ 7.68 + INSTANCEOF_GENERIC_OR_ARRAY(0x03, HasLocation), 7.69 + 7.70 + /** For annotations on object creation expressions. */ 7.71 + NEW(0x04), 7.72 + 7.73 + /** 7.74 + * For annotations on a type argument or nested array of an object creation 7.75 + * expression. 7.76 + */ 7.77 + NEW_GENERIC_OR_ARRAY(0x05, HasLocation), 7.78 + 7.79 + 7.80 + /** For annotations on the method receiver. */ 7.81 + METHOD_RECEIVER(0x06), 7.82 + 7.83 + // invalid location 7.84 + //@Deprecated METHOD_RECEIVER_GENERIC_OR_ARRAY(0x07, HasLocation), 7.85 + 7.86 + /** For annotations on local variables. */ 7.87 + LOCAL_VARIABLE(0x08), 7.88 + 7.89 + /** For annotations on a type argument or nested array of a local. */ 7.90 + LOCAL_VARIABLE_GENERIC_OR_ARRAY(0x09, HasLocation), 7.91 + 7.92 + // handled by regular annotations 7.93 + //@Deprecated METHOD_RETURN(0x0A), 7.94 + 7.95 + /** 7.96 + * For annotations on a type argument or nested array of a method return 7.97 + * type. 7.98 + */ 7.99 + METHOD_RETURN_GENERIC_OR_ARRAY(0x0B, HasLocation), 7.100 + 7.101 + // handled by regular annotations 7.102 + //@Deprecated METHOD_PARAMETER(0x0C), 7.103 + 7.104 + /** For annotations on a type argument or nested array of a method parameter. */ 7.105 + METHOD_PARAMETER_GENERIC_OR_ARRAY(0x0D, HasLocation), 7.106 + 7.107 + // handled by regular annotations 7.108 + //@Deprecated FIELD(0x0E), 7.109 + 7.110 + /** For annotations on a type argument or nested array of a field. */ 7.111 + FIELD_GENERIC_OR_ARRAY(0x0F, HasLocation), 7.112 + 7.113 + /** For annotations on a bound of a type parameter of a class. */ 7.114 + CLASS_TYPE_PARAMETER_BOUND(0x10, HasBound, HasParameter), 7.115 + 7.116 + /** 7.117 + * For annotations on a type argument or nested array of a bound of a type 7.118 + * parameter of a class. 7.119 + */ 7.120 + CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x11, HasBound, HasLocation, HasParameter), 7.121 + 7.122 + /** For annotations on a bound of a type parameter of a method. */ 7.123 + METHOD_TYPE_PARAMETER_BOUND(0x12, HasBound, HasParameter), 7.124 + 7.125 + /** 7.126 + * For annotations on a type argument or nested array of a bound of a type 7.127 + * parameter of a method. 7.128 + */ 7.129 + METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x13, HasBound, HasLocation, HasParameter), 7.130 + 7.131 + /** For annotations on the type of an "extends" or "implements" clause. */ 7.132 + CLASS_EXTENDS(0x14), 7.133 + 7.134 + /** For annotations on the inner type of an "extends" or "implements" clause. */ 7.135 + CLASS_EXTENDS_GENERIC_OR_ARRAY(0x15, HasLocation), 7.136 + 7.137 + /** For annotations on a throws clause in a method declaration. */ 7.138 + THROWS(0x16), 7.139 + 7.140 + // invalid location 7.141 + //@Deprecated THROWS_GENERIC_OR_ARRAY(0x17, HasLocation), 7.142 + 7.143 + /** For annotations in type arguments of object creation expressions. */ 7.144 + NEW_TYPE_ARGUMENT(0x18), 7.145 + NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x19, HasLocation), 7.146 + 7.147 + METHOD_TYPE_ARGUMENT(0x1A), 7.148 + METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x1B, HasLocation), 7.149 + 7.150 + WILDCARD_BOUND(0x1C, HasBound), 7.151 + WILDCARD_BOUND_GENERIC_OR_ARRAY(0x1D, HasBound, HasLocation), 7.152 + 7.153 + CLASS_LITERAL(0x1E), 7.154 + CLASS_LITERAL_GENERIC_OR_ARRAY(0x1F, HasLocation), 7.155 + 7.156 + METHOD_TYPE_PARAMETER(0x20, HasParameter), 7.157 + 7.158 + // invalid location 7.159 + //@Deprecated METHOD_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x21, HasLocation, HasParameter), 7.160 + 7.161 + CLASS_TYPE_PARAMETER(0x22, HasParameter), 7.162 + 7.163 + // invalid location 7.164 + //@Deprecated CLASS_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x23, HasLocation, HasParameter), 7.165 + 7.166 + /** For annotations with an unknown target. */ 7.167 + UNKNOWN(-1); 7.168 + 7.169 + static final int MAXIMUM_TARGET_TYPE_VALUE = 0x22; 7.170 + 7.171 + private final int targetTypeValue; 7.172 + private Set<TargetAttribute> flags; 7.173 + 7.174 + TargetType(int targetTypeValue, TargetAttribute... attributes) { 7.175 + if (targetTypeValue < Byte.MIN_VALUE 7.176 + || targetTypeValue > Byte.MAX_VALUE) 7.177 + throw new AssertionError("attribute type value needs to be a byte: " + targetTypeValue); 7.178 + this.targetTypeValue = (byte)targetTypeValue; 7.179 + flags = EnumSet.noneOf(TargetAttribute.class); 7.180 + for (TargetAttribute attr : attributes) 7.181 + flags.add(attr); 7.182 + } 7.183 + 7.184 + /** 7.185 + * Returns whether or not this TargetType represents an annotation whose 7.186 + * target is an inner type of a generic or array type. 7.187 + * 7.188 + * @return true if this TargetType represents an annotation on an inner 7.189 + * type, false otherwise 7.190 + */ 7.191 + public boolean hasLocation() { 7.192 + return flags.contains(HasLocation); 7.193 + } 7.194 + 7.195 + public TargetType getGenericComplement() { 7.196 + if (hasLocation()) 7.197 + return this; 7.198 + else 7.199 + return fromTargetTypeValue(targetTypeValue() + 1); 7.200 + } 7.201 + 7.202 + /** 7.203 + * Returns whether or not this TargetType represents an annotation whose 7.204 + * target has a parameter index. 7.205 + * 7.206 + * @return true if this TargetType has a parameter index, 7.207 + * false otherwise 7.208 + */ 7.209 + public boolean hasParameter() { 7.210 + return flags.contains(HasParameter); 7.211 + } 7.212 + 7.213 + /** 7.214 + * Returns whether or not this TargetType represents an annotation whose 7.215 + * target is a type parameter bound. 7.216 + * 7.217 + * @return true if this TargetType represents an type parameter bound 7.218 + * annotation, false otherwise 7.219 + */ 7.220 + public boolean hasBound() { 7.221 + return flags.contains(HasBound); 7.222 + } 7.223 + 7.224 + public int targetTypeValue() { 7.225 + return this.targetTypeValue; 7.226 + } 7.227 + 7.228 + private static TargetType[] targets = null; 7.229 + 7.230 + private static TargetType[] buildTargets() { 7.231 + TargetType[] targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1]; 7.232 + TargetType[] alltargets = values(); 7.233 + for (TargetType target : alltargets) { 7.234 + if (target.targetTypeValue >= 0) 7.235 + targets[target.targetTypeValue] = target; 7.236 + } 7.237 + for (int i = 0; i <= MAXIMUM_TARGET_TYPE_VALUE; ++i) { 7.238 + if (targets[i] == null) 7.239 + targets[i] = UNKNOWN; 7.240 + } 7.241 + return targets; 7.242 + } 7.243 + 7.244 + public static boolean isValidTargetTypeValue(int tag) { 7.245 + if (targets == null) 7.246 + targets = buildTargets(); 7.247 + 7.248 + if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue)) 7.249 + return true; 7.250 + 7.251 + return (tag >= 0 && tag < targets.length); 7.252 + } 7.253 + 7.254 + public static TargetType fromTargetTypeValue(int tag) { 7.255 + if (targets == null) 7.256 + targets = buildTargets(); 7.257 + 7.258 + if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue)) 7.259 + return UNKNOWN; 7.260 + 7.261 + if (tag < 0 || tag >= targets.length) 7.262 + throw new IllegalArgumentException("Unknown TargetType: " + tag); 7.263 + return targets[tag]; 7.264 + } 7.265 + 7.266 + static enum TargetAttribute { 7.267 + HasLocation, HasParameter, HasBound; 7.268 + } 7.269 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java Fri Jun 26 19:12:41 2009 -0700 8.3 @@ -0,0 +1,180 @@ 8.4 +/* 8.5 + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. 8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 + * 8.8 + * This code is free software; you can redistribute it and/or modify it 8.9 + * under the terms of the GNU General Public License version 2 only, as 8.10 + * published by the Free Software Foundation. Sun designates this 8.11 + * particular file as subject to the "Classpath" exception as provided 8.12 + * by Sun in the LICENSE file that accompanied this code. 8.13 + * 8.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 8.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.17 + * version 2 for more details (a copy is included in the LICENSE file that 8.18 + * accompanied this code). 8.19 + * 8.20 + * You should have received a copy of the GNU General Public License version 8.21 + * 2 along with this work; if not, write to the Free Software Foundation, 8.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.23 + * 8.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 8.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 8.26 + * have any questions. 8.27 + */ 8.28 + 8.29 +package com.sun.tools.javac.code; 8.30 + 8.31 +import com.sun.tools.javac.util.*; 8.32 + 8.33 +/** A type annotation position. 8.34 +* 8.35 +* <p><b>This is NOT part of any API supported by Sun Microsystems. If 8.36 +* you write code that depends on this, you do so at your own risk. 8.37 +* This code and its internal interfaces are subject to change or 8.38 +* deletion without notice.</b> 8.39 +*/ 8.40 +public class TypeAnnotationPosition { 8.41 + 8.42 + public TargetType type = TargetType.UNKNOWN; 8.43 + 8.44 + // For generic/array types. 8.45 + public List<Integer> location = List.nil(); 8.46 + 8.47 + // Tree position. 8.48 + public int pos = -1; 8.49 + 8.50 + // For typecasts, type tests, new (and locals, as start_pc). 8.51 + public int offset = -1; 8.52 + 8.53 + // For locals. arrays same length 8.54 + public int[] lvarOffset = new int[] { -1 }; 8.55 + public int[] lvarLength = new int[] { -1 }; 8.56 + public int[] lvarIndex = new int[] { -1 }; 8.57 + 8.58 + // For type parameter bound 8.59 + public int bound_index = -1; 8.60 + 8.61 + // For type parameter and method parameter 8.62 + public int parameter_index = -1; 8.63 + 8.64 + // For class extends, implements, and throws classes 8.65 + public int type_index = -2; 8.66 + 8.67 + // For wildcards 8.68 + public TypeAnnotationPosition wildcard_position = null; 8.69 + 8.70 + @Override 8.71 + public String toString() { 8.72 + StringBuilder sb = new StringBuilder(); 8.73 + sb.append('['); 8.74 + sb.append(type); 8.75 + 8.76 + switch (type) { 8.77 + // type case 8.78 + case TYPECAST: 8.79 + case TYPECAST_GENERIC_OR_ARRAY: 8.80 + // object creation 8.81 + case INSTANCEOF: 8.82 + case INSTANCEOF_GENERIC_OR_ARRAY: 8.83 + // new expression 8.84 + case NEW: 8.85 + case NEW_GENERIC_OR_ARRAY: 8.86 + case NEW_TYPE_ARGUMENT: 8.87 + case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 8.88 + sb.append(", offset = "); 8.89 + sb.append(offset); 8.90 + break; 8.91 + // local variable 8.92 + case LOCAL_VARIABLE: 8.93 + case LOCAL_VARIABLE_GENERIC_OR_ARRAY: 8.94 + sb.append(", {"); 8.95 + for (int i = 0; i < lvarOffset.length; ++i) { 8.96 + if (i != 0) sb.append("; "); 8.97 + sb.append(", start_pc = "); 8.98 + sb.append(lvarOffset[i]); 8.99 + sb.append(", length = "); 8.100 + sb.append(lvarLength[i]); 8.101 + sb.append(", index = "); 8.102 + sb.append(lvarIndex[i]); 8.103 + } 8.104 + sb.append("}"); 8.105 + break; 8.106 + // method receiver 8.107 + case METHOD_RECEIVER: 8.108 + // Do nothing 8.109 + break; 8.110 + // type parameters 8.111 + case CLASS_TYPE_PARAMETER: 8.112 + case METHOD_TYPE_PARAMETER: 8.113 + sb.append(", param_index = "); 8.114 + sb.append(parameter_index); 8.115 + break; 8.116 + // type parameters bound 8.117 + case CLASS_TYPE_PARAMETER_BOUND: 8.118 + case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 8.119 + case METHOD_TYPE_PARAMETER_BOUND: 8.120 + case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 8.121 + sb.append(", param_index = "); 8.122 + sb.append(parameter_index); 8.123 + sb.append(", bound_index = "); 8.124 + sb.append(bound_index); 8.125 + break; 8.126 + // wildcard 8.127 + case WILDCARD_BOUND: 8.128 + case WILDCARD_BOUND_GENERIC_OR_ARRAY: 8.129 + sb.append(", wild_card = "); 8.130 + sb.append(wildcard_position); 8.131 + break; 8.132 + // Class extends and implements clauses 8.133 + case CLASS_EXTENDS: 8.134 + case CLASS_EXTENDS_GENERIC_OR_ARRAY: 8.135 + sb.append(", type_index = "); 8.136 + sb.append(type_index); 8.137 + break; 8.138 + // throws 8.139 + case THROWS: 8.140 + sb.append(", type_index = "); 8.141 + sb.append(type_index); 8.142 + break; 8.143 + case CLASS_LITERAL: 8.144 + sb.append(", offset = "); 8.145 + sb.append(offset); 8.146 + break; 8.147 + // method parameter: not specified 8.148 + case METHOD_PARAMETER_GENERIC_OR_ARRAY: 8.149 + sb.append(", param_index = "); 8.150 + sb.append(parameter_index); 8.151 + break; 8.152 + // method type argument: wasn't specified 8.153 + case METHOD_TYPE_ARGUMENT: 8.154 + case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 8.155 + sb.append(", offset = "); 8.156 + sb.append(offset); 8.157 + sb.append(", type_index = "); 8.158 + sb.append(type_index); 8.159 + break; 8.160 + // We don't need to worry abut these 8.161 + case METHOD_RETURN_GENERIC_OR_ARRAY: 8.162 + case FIELD_GENERIC_OR_ARRAY: 8.163 + break; 8.164 + case UNKNOWN: 8.165 + break; 8.166 + default: 8.167 + // throw new AssertionError("unknown type: " + type); 8.168 + } 8.169 + 8.170 + // Append location data for generics/arrays. 8.171 + if (type.hasLocation()) { 8.172 + sb.append(", location = ("); 8.173 + sb.append(location); 8.174 + sb.append(")"); 8.175 + } 8.176 + 8.177 + sb.append(", pos = "); 8.178 + sb.append(pos); 8.179 + 8.180 + sb.append(']'); 8.181 + return sb.toString(); 8.182 + } 8.183 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/tools/javac/api/TestTreePath.java Fri Jun 26 19:12:41 2009 -0700 9.3 @@ -0,0 +1,124 @@ 9.4 +/* 9.5 + * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. 9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 + * 9.8 + * This code is free software; you can redistribute it and/or modify it 9.9 + * under the terms of the GNU General Public License version 2 only, as 9.10 + * published by the Free Software Foundation. 9.11 + * 9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.15 + * version 2 for more details (a copy is included in the LICENSE file that 9.16 + * accompanied this code). 9.17 + * 9.18 + * You should have received a copy of the GNU General Public License version 9.19 + * 2 along with this work; if not, write to the Free Software Foundation, 9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.21 + * 9.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 9.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 9.24 + * have any questions. 9.25 + */ 9.26 + 9.27 +/* 9.28 + * @test 9.29 + * @bug 6473148 9.30 + * @summary TreePath.iterator() throws NPE 9.31 + */ 9.32 +import java.io.*; 9.33 +import java.util.Arrays; 9.34 +import java.util.Iterator; 9.35 +import java.util.Set; 9.36 + 9.37 +import javax.annotation.processing.*; 9.38 +import javax.lang.model.SourceVersion; 9.39 +import javax.lang.model.element.Element; 9.40 +import javax.lang.model.element.TypeElement; 9.41 +import javax.lang.model.util.ElementFilter; 9.42 +import javax.tools.JavaCompiler; 9.43 +import javax.tools.JavaFileObject; 9.44 +import javax.tools.StandardJavaFileManager; 9.45 +import javax.tools.ToolProvider; 9.46 + 9.47 +import com.sun.source.tree.Tree; 9.48 +import com.sun.source.util.*; 9.49 + 9.50 +@SupportedAnnotationTypes("*") 9.51 +public class TestTreePath extends AbstractProcessor { 9.52 + 9.53 + @Override 9.54 + public boolean process(Set<? extends TypeElement> annotations, 9.55 + RoundEnvironment roundEnv) { 9.56 + final Trees trees = Trees.instance(this.processingEnv); 9.57 + for (Element element : ElementFilter.typesIn(roundEnv.getRootElements())) { 9.58 + checkTreePath(trees, element, 2); 9.59 + for (Element member : element.getEnclosedElements()) 9.60 + checkTreePath(trees, member, 3); 9.61 + } 9.62 + return true; 9.63 + } 9.64 + 9.65 + private void checkTreePath(Trees trees, Element element, int expectedLength) { 9.66 + TreePath path = trees.getPath(element); 9.67 + assert path != null; 9.68 + 9.69 + int enhancedLength = 0; 9.70 + for (Tree tree : path) 9.71 + ++enhancedLength; 9.72 + 9.73 + if (enhancedLength != expectedLength) 9.74 + throw new RuntimeException("found path length is wrong"); 9.75 + 9.76 + int normalLoopLength = 0; 9.77 + Iterator<Tree> iter = path.iterator(); 9.78 + while (iter.hasNext()) { 9.79 + iter.next(); 9.80 + ++normalLoopLength; 9.81 + } 9.82 + if (normalLoopLength != expectedLength) 9.83 + throw new RuntimeException("found path length is wrong"); 9.84 + 9.85 + TreePath curr = path; 9.86 + // using getParent 9.87 + int whileLoopLength = 0; 9.88 + while (curr != null) { 9.89 + ++whileLoopLength; 9.90 + curr = curr.getParentPath(); 9.91 + } 9.92 + if (whileLoopLength != expectedLength) 9.93 + throw new RuntimeException("found path length is wrong"); 9.94 + } 9.95 + 9.96 + @Override 9.97 + public SourceVersion getSupportedSourceVersion() { 9.98 + return SourceVersion.latest(); 9.99 + } 9.100 + 9.101 + File writeTestFile() throws IOException { 9.102 + File f = new File("Test.java"); 9.103 + PrintWriter out = new PrintWriter(new FileWriter(f)); 9.104 + out.println("class Test { void method() { } }"); 9.105 + out.close(); 9.106 + return f; 9.107 + } 9.108 + 9.109 + public void run() throws IOException { 9.110 + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 9.111 + StandardJavaFileManager fileManager 9.112 + = compiler.getStandardFileManager(null, null, null); 9.113 + Iterable<? extends JavaFileObject> tests 9.114 + = fileManager.getJavaFileObjects(writeTestFile()); 9.115 + 9.116 + JavaCompiler.CompilationTask task = 9.117 + ToolProvider.getSystemJavaCompiler().getTask( 9.118 + null, null, null, 9.119 + Arrays.asList("-processor", this.getClass().getName()), null, 9.120 + tests); 9.121 + task.call(); 9.122 + } 9.123 + 9.124 + public static void main(String[] args) throws IOException { 9.125 + new TestTreePath().run(); 9.126 + } 9.127 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/tools/javac/meth/InvokeMH_BAD68.java Fri Jun 26 19:12:41 2009 -0700 10.3 @@ -0,0 +1,75 @@ 10.4 +/* 10.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 10.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 10.24 + * have any questions. 10.25 + */ 10.26 + 10.27 +/* 10.28 + * ##test 10.29 + * ##bug 6754038 10.30 + * ##summary Generate call sites for method handle 10.31 + * ##author jrose 10.32 + * 10.33 + * ##compile/fail -source 7 -target 7 InvokeMH_BAD68.java 10.34 + */ 10.35 + 10.36 +/* 10.37 + * Standalone testing: 10.38 + * <code> 10.39 + * $ cd $MY_REPO_DIR/langtools 10.40 + * $ (cd make; make) 10.41 + * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH_BAD68.java 10.42 + * $ javap -c -classpath dist meth.InvokeMH_BAD68 10.43 + * </code> 10.44 + */ 10.45 + 10.46 +package meth; 10.47 + 10.48 +import java.dyn.MethodHandle; 10.49 + 10.50 +public class InvokeMH_BAD68 { 10.51 + void test(MethodHandle mh_SiO, 10.52 + MethodHandle mh_vS, 10.53 + MethodHandle mh_vi, 10.54 + MethodHandle mh_vv) { 10.55 + Object o; String s; int i; // for return type testing 10.56 + 10.57 + // next five must have sig = (String,int)Object 10.58 + mh_SiO.invoke("world", 123); 10.59 + mh_SiO.invoke("mundus", 456); 10.60 + Object k = "kosmos"; 10.61 + mh_SiO.invoke((String)k, 789); 10.62 + o = mh_SiO.invoke((String)null, 000); 10.63 + o = mh_SiO.<Object>invoke("arda", -123); 10.64 + 10.65 + // sig = ()String 10.66 + s = mh_vS.<String>invoke(); 10.67 + 10.68 + // sig = ()int 10.69 + i = mh_vi.<int>invoke(); 10.70 + o = mh_vi.<int>invoke(); 10.71 + s = mh_vi.<int>invoke(); //BAD 10.72 + mh_vi.<int>invoke(); 10.73 + 10.74 + // sig = ()void 10.75 + //o = mh_vv.<void>invoke(); //BAD 10.76 + mh_vv.<void>invoke(); 10.77 + } 10.78 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/tools/javac/meth/InvokeMH_BAD72.java Fri Jun 26 19:12:41 2009 -0700 11.3 @@ -0,0 +1,75 @@ 11.4 +/* 11.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 + * 11.8 + * This code is free software; you can redistribute it and/or modify it 11.9 + * under the terms of the GNU General Public License version 2 only, as 11.10 + * published by the Free Software Foundation. 11.11 + * 11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.15 + * version 2 for more details (a copy is included in the LICENSE file that 11.16 + * accompanied this code). 11.17 + * 11.18 + * You should have received a copy of the GNU General Public License version 11.19 + * 2 along with this work; if not, write to the Free Software Foundation, 11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.21 + * 11.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 11.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 11.24 + * have any questions. 11.25 + */ 11.26 + 11.27 +/* 11.28 + * ##test 11.29 + * ##bug 6754038 11.30 + * ##summary Generate call sites for method handle 11.31 + * ##author jrose 11.32 + * 11.33 + * ##compile/fail -source 7 -target 7 InvokeMH_BAD72.java 11.34 + */ 11.35 + 11.36 +/* 11.37 + * Standalone testing: 11.38 + * <code> 11.39 + * $ cd $MY_REPO_DIR/langtools 11.40 + * $ (cd make; make) 11.41 + * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH_BAD72.java 11.42 + * $ javap -c -classpath dist meth.InvokeMH_BAD72 11.43 + * </code> 11.44 + */ 11.45 + 11.46 +package meth; 11.47 + 11.48 +import java.dyn.MethodHandle; 11.49 + 11.50 +public class InvokeMH_BAD72 { 11.51 + void test(MethodHandle mh_SiO, 11.52 + MethodHandle mh_vS, 11.53 + MethodHandle mh_vi, 11.54 + MethodHandle mh_vv) { 11.55 + Object o; String s; int i; // for return type testing 11.56 + 11.57 + // next five must have sig = (String,int)Object 11.58 + mh_SiO.invoke("world", 123); 11.59 + mh_SiO.invoke("mundus", 456); 11.60 + Object k = "kosmos"; 11.61 + mh_SiO.invoke((String)k, 789); 11.62 + o = mh_SiO.invoke((String)null, 000); 11.63 + o = mh_SiO.<Object>invoke("arda", -123); 11.64 + 11.65 + // sig = ()String 11.66 + s = mh_vS.<String>invoke(); 11.67 + 11.68 + // sig = ()int 11.69 + i = mh_vi.<int>invoke(); 11.70 + o = mh_vi.<int>invoke(); 11.71 + //s = mh_vi.<int>invoke(); //BAD 11.72 + mh_vi.<int>invoke(); 11.73 + 11.74 + // sig = ()void 11.75 + o = mh_vv.<void>invoke(); //BAD 11.76 + mh_vv.<void>invoke(); 11.77 + } 11.78 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/tools/javac/quid/QuotedIdent_BAD61.java Fri Jun 26 19:12:41 2009 -0700 12.3 @@ -0,0 +1,132 @@ 12.4 +/* 12.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 + * 12.8 + * This code is free software; you can redistribute it and/or modify it 12.9 + * under the terms of the GNU General Public License version 2 only, as 12.10 + * published by the Free Software Foundation. 12.11 + * 12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.15 + * version 2 for more details (a copy is included in the LICENSE file that 12.16 + * accompanied this code). 12.17 + * 12.18 + * You should have received a copy of the GNU General Public License version 12.19 + * 2 along with this work; if not, write to the Free Software Foundation, 12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.21 + * 12.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 12.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 12.24 + * have any questions. 12.25 + */ 12.26 + 12.27 +/* 12.28 + * ##test 12.29 + * ##bug 6746458 12.30 + * ##summary Verify correct lexing of quoted identifiers. 12.31 + * ##author jrose 12.32 + * 12.33 + * ##library .. 12.34 + * ##run main quid.QuotedIdent_BAD61 12.35 + */ 12.36 + 12.37 +/* 12.38 + * Standalone testing: 12.39 + * <code> 12.40 + * $ cd $MY_REPO_DIR/langtools 12.41 + * $ (cd make; make) 12.42 + * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD61.java 12.43 + * $ java -version # should print 1.6 or later 12.44 + * $ java -cp dist quid.QuotedIdent_BAD61 12.45 + * </code> 12.46 + */ 12.47 + 12.48 +package quid; 12.49 + 12.50 +public class QuotedIdent_BAD61 { 12.51 + static void check(int testid, String have, String expect) 12.52 + throws RuntimeException { 12.53 + if ((have == null && have != expect) || 12.54 + (have != null && !have.equals(expect))) { 12.55 + String msg = 12.56 + "TEST " + testid + ": HAVE \"" + 12.57 + have + "\" EXPECT \"" + expect + "\""; 12.58 + System.out.println("StringConversion: " + msg); 12.59 + throw new RuntimeException(msg); 12.60 + } 12.61 + } 12.62 + 12.63 + // negative tests: 12.64 + static class #"" { } //BAD empty ident name 12.65 + //static class #"<foo>" { } //BAD bad char in ident name 12.66 + /*static class /*(//BAD ident name interrupted by newline) #"jump: 12.67 + " { } /* uncomment previous line to attempt class w/ bad name */ 12.68 + 12.69 + static class #"int" extends Number { 12.70 + final int #"int"; 12.71 + #"int"(int #"int") { 12.72 + this.#"int" = #"int"; 12.73 + } 12.74 + static #"int" valueOf(int #"int") { 12.75 + return new #"int"(#"int"); 12.76 + } 12.77 + public int intValue() { return #"int"; } 12.78 + public long longValue() { return #"int"; } 12.79 + public float floatValue() { return #"int"; } 12.80 + public double doubleValue() { return #"int"; } 12.81 + public String toString() { return String.valueOf(#"int"); } 12.82 + } 12.83 + 12.84 + class #"*86" { 12.85 + String #"555-1212"() { return "[*86.555-1212]"; } 12.86 + } 12.87 + static#"*86"#"MAKE-*86"() { // note close spacing 12.88 + return new QuotedIdent_BAD61().new#"*86"(); 12.89 + } 12.90 + 12.91 + static String bar() { return "[bar]"; } 12.92 + 12.93 + public static void main(String[] args) throws Exception { 12.94 + String s; 12.95 + 12.96 + String #"sticky \' wicket" = "wicked ' stick"; 12.97 + s = #"sticky ' wicket"; 12.98 + check(11, s, "wicked \' stick"); 12.99 + check(12, #"s", s); 12.100 + check(13, #"\163", s); 12.101 + 12.102 + s = #"QuotedIdent_BAD61".bar(); 12.103 + check(21, s, "[bar]"); 12.104 + 12.105 + s = #"int".valueOf(123).toString(); 12.106 + check(22, s, "123"); 12.107 + 12.108 + s = #"MAKE-*86"().#"555-1212"(); 12.109 + check(23, s, "[*86.555-1212]"); 12.110 + 12.111 + class#"{{{inmost}}}" { } 12.112 + s = new#"{{{inmost}}}"().getClass().getName(); 12.113 + if (!s.endsWith("{{{inmost}}}")) 12.114 + check(24, s, "should end with \"{{{inmost}}}\""); 12.115 + 12.116 + s = #"Yog-Shoggoth".#"(nameless ululation)"; 12.117 + check(25, s, "Tekeli-li!"); 12.118 + 12.119 + s = #"int".class.getName(); 12.120 + check(31, s, QuotedIdent_BAD61.class.getName()+"$int"); 12.121 + 12.122 + Class x86 = Class.forName(QuotedIdent_BAD61.class.getName()+"$*86"); 12.123 + if (x86 != #"*86".class) 12.124 + check(32, "reflected "+x86, "static "+#"*86".class); 12.125 + 12.126 + s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"()); 12.127 + check(31, s, "[*86.555-1212]"); 12.128 + 12.129 + System.out.println("OK"); 12.130 + } 12.131 +} 12.132 + 12.133 +interface #"Yog-Shoggoth" { 12.134 + final String #"(nameless ululation)" = "Tekeli-li!"; 12.135 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/tools/javac/quid/QuotedIdent_BAD62.java Fri Jun 26 19:12:41 2009 -0700 13.3 @@ -0,0 +1,132 @@ 13.4 +/* 13.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.7 + * 13.8 + * This code is free software; you can redistribute it and/or modify it 13.9 + * under the terms of the GNU General Public License version 2 only, as 13.10 + * published by the Free Software Foundation. 13.11 + * 13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13.15 + * version 2 for more details (a copy is included in the LICENSE file that 13.16 + * accompanied this code). 13.17 + * 13.18 + * You should have received a copy of the GNU General Public License version 13.19 + * 2 along with this work; if not, write to the Free Software Foundation, 13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 13.21 + * 13.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 13.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 13.24 + * have any questions. 13.25 + */ 13.26 + 13.27 +/* 13.28 + * ##test 13.29 + * ##bug 6746458 13.30 + * ##summary Verify correct lexing of quoted identifiers. 13.31 + * ##author jrose 13.32 + * 13.33 + * ##library .. 13.34 + * ##run main quid.QuotedIdent_BAD62 13.35 + */ 13.36 + 13.37 +/* 13.38 + * Standalone testing: 13.39 + * <code> 13.40 + * $ cd $MY_REPO_DIR/langtools 13.41 + * $ (cd make; make) 13.42 + * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD62.java 13.43 + * $ java -version # should print 1.6 or later 13.44 + * $ java -cp dist quid.QuotedIdent_BAD62 13.45 + * </code> 13.46 + */ 13.47 + 13.48 +package quid; 13.49 + 13.50 +public class QuotedIdent_BAD62 { 13.51 + static void check(int testid, String have, String expect) 13.52 + throws RuntimeException { 13.53 + if ((have == null && have != expect) || 13.54 + (have != null && !have.equals(expect))) { 13.55 + String msg = 13.56 + "TEST " + testid + ": HAVE \"" + 13.57 + have + "\" EXPECT \"" + expect + "\""; 13.58 + System.out.println("StringConversion: " + msg); 13.59 + throw new RuntimeException(msg); 13.60 + } 13.61 + } 13.62 + 13.63 + // negative tests: 13.64 + //static class #"" { } //BAD empty ident name 13.65 + static class #"<foo>" { } //BAD bad char in ident name 13.66 + /*static class /*(//BAD ident name interrupted by newline) #"jump: 13.67 + " { } /* uncomment previous line to attempt class w/ bad name */ 13.68 + 13.69 + static class #"int" extends Number { 13.70 + final int #"int"; 13.71 + #"int"(int #"int") { 13.72 + this.#"int" = #"int"; 13.73 + } 13.74 + static #"int" valueOf(int #"int") { 13.75 + return new #"int"(#"int"); 13.76 + } 13.77 + public int intValue() { return #"int"; } 13.78 + public long longValue() { return #"int"; } 13.79 + public float floatValue() { return #"int"; } 13.80 + public double doubleValue() { return #"int"; } 13.81 + public String toString() { return String.valueOf(#"int"); } 13.82 + } 13.83 + 13.84 + class #"*86" { 13.85 + String #"555-1212"() { return "[*86.555-1212]"; } 13.86 + } 13.87 + static#"*86"#"MAKE-*86"() { // note close spacing 13.88 + return new QuotedIdent_BAD62().new#"*86"(); 13.89 + } 13.90 + 13.91 + static String bar() { return "[bar]"; } 13.92 + 13.93 + public static void main(String[] args) throws Exception { 13.94 + String s; 13.95 + 13.96 + String #"sticky \' wicket" = "wicked ' stick"; 13.97 + s = #"sticky ' wicket"; 13.98 + check(11, s, "wicked \' stick"); 13.99 + check(12, #"s", s); 13.100 + check(13, #"\163", s); 13.101 + 13.102 + s = #"QuotedIdent_BAD62".bar(); 13.103 + check(21, s, "[bar]"); 13.104 + 13.105 + s = #"int".valueOf(123).toString(); 13.106 + check(22, s, "123"); 13.107 + 13.108 + s = #"MAKE-*86"().#"555-1212"(); 13.109 + check(23, s, "[*86.555-1212]"); 13.110 + 13.111 + class#"{{{inmost}}}" { } 13.112 + s = new#"{{{inmost}}}"().getClass().getName(); 13.113 + if (!s.endsWith("{{{inmost}}}")) 13.114 + check(24, s, "should end with \"{{{inmost}}}\""); 13.115 + 13.116 + s = #"Yog-Shoggoth".#"(nameless ululation)"; 13.117 + check(25, s, "Tekeli-li!"); 13.118 + 13.119 + s = #"int".class.getName(); 13.120 + check(31, s, QuotedIdent_BAD62.class.getName()+"$int"); 13.121 + 13.122 + Class x86 = Class.forName(QuotedIdent_BAD62.class.getName()+"$*86"); 13.123 + if (x86 != #"*86".class) 13.124 + check(32, "reflected "+x86, "static "+#"*86".class); 13.125 + 13.126 + s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"()); 13.127 + check(31, s, "[*86.555-1212]"); 13.128 + 13.129 + System.out.println("OK"); 13.130 + } 13.131 +} 13.132 + 13.133 +interface #"Yog-Shoggoth" { 13.134 + final String #"(nameless ululation)" = "Tekeli-li!"; 13.135 +}
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/test/tools/javac/quid/QuotedIdent_BAD63.java Fri Jun 26 19:12:41 2009 -0700 14.3 @@ -0,0 +1,132 @@ 14.4 +/* 14.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.7 + * 14.8 + * This code is free software; you can redistribute it and/or modify it 14.9 + * under the terms of the GNU General Public License version 2 only, as 14.10 + * published by the Free Software Foundation. 14.11 + * 14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14.15 + * version 2 for more details (a copy is included in the LICENSE file that 14.16 + * accompanied this code). 14.17 + * 14.18 + * You should have received a copy of the GNU General Public License version 14.19 + * 2 along with this work; if not, write to the Free Software Foundation, 14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 14.21 + * 14.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 14.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 14.24 + * have any questions. 14.25 + */ 14.26 + 14.27 +/* 14.28 + * ##test 14.29 + * ##bug 6746458 14.30 + * ##summary Verify correct lexing of quoted identifiers. 14.31 + * ##author jrose 14.32 + * 14.33 + * ##library .. 14.34 + * ##run main quid.QuotedIdent_BAD63 14.35 + */ 14.36 + 14.37 +/* 14.38 + * Standalone testing: 14.39 + * <code> 14.40 + * $ cd $MY_REPO_DIR/langtools 14.41 + * $ (cd make; make) 14.42 + * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD63.java 14.43 + * $ java -version # should print 1.6 or later 14.44 + * $ java -cp dist quid.QuotedIdent_BAD63 14.45 + * </code> 14.46 + */ 14.47 + 14.48 +package quid; 14.49 + 14.50 +public class QuotedIdent_BAD63 { 14.51 + static void check(int testid, String have, String expect) 14.52 + throws RuntimeException { 14.53 + if ((have == null && have != expect) || 14.54 + (have != null && !have.equals(expect))) { 14.55 + String msg = 14.56 + "TEST " + testid + ": HAVE \"" + 14.57 + have + "\" EXPECT \"" + expect + "\""; 14.58 + System.out.println("StringConversion: " + msg); 14.59 + throw new RuntimeException(msg); 14.60 + } 14.61 + } 14.62 + 14.63 + // negative tests: 14.64 + //static class #"" { } //BAD empty ident name 14.65 + //static class #"<foo>" { } //BAD bad char in ident name 14.66 + static class /*(//BAD ident name interrupted by newline) #"jump: 14.67 + " { } /* uncomment previous line to attempt class w/ bad name */ 14.68 + 14.69 + static class #"int" extends Number { 14.70 + final int #"int"; 14.71 + #"int"(int #"int") { 14.72 + this.#"int" = #"int"; 14.73 + } 14.74 + static #"int" valueOf(int #"int") { 14.75 + return new #"int"(#"int"); 14.76 + } 14.77 + public int intValue() { return #"int"; } 14.78 + public long longValue() { return #"int"; } 14.79 + public float floatValue() { return #"int"; } 14.80 + public double doubleValue() { return #"int"; } 14.81 + public String toString() { return String.valueOf(#"int"); } 14.82 + } 14.83 + 14.84 + class #"*86" { 14.85 + String #"555-1212"() { return "[*86.555-1212]"; } 14.86 + } 14.87 + static#"*86"#"MAKE-*86"() { // note close spacing 14.88 + return new QuotedIdent_BAD63().new#"*86"(); 14.89 + } 14.90 + 14.91 + static String bar() { return "[bar]"; } 14.92 + 14.93 + public static void main(String[] args) throws Exception { 14.94 + String s; 14.95 + 14.96 + String #"sticky \' wicket" = "wicked ' stick"; 14.97 + s = #"sticky ' wicket"; 14.98 + check(11, s, "wicked \' stick"); 14.99 + check(12, #"s", s); 14.100 + check(13, #"\163", s); 14.101 + 14.102 + s = #"QuotedIdent_BAD63".bar(); 14.103 + check(21, s, "[bar]"); 14.104 + 14.105 + s = #"int".valueOf(123).toString(); 14.106 + check(22, s, "123"); 14.107 + 14.108 + s = #"MAKE-*86"().#"555-1212"(); 14.109 + check(23, s, "[*86.555-1212]"); 14.110 + 14.111 + class#"{{{inmost}}}" { } 14.112 + s = new#"{{{inmost}}}"().getClass().getName(); 14.113 + if (!s.endsWith("{{{inmost}}}")) 14.114 + check(24, s, "should end with \"{{{inmost}}}\""); 14.115 + 14.116 + s = #"Yog-Shoggoth".#"(nameless ululation)"; 14.117 + check(25, s, "Tekeli-li!"); 14.118 + 14.119 + s = #"int".class.getName(); 14.120 + check(31, s, QuotedIdent_BAD63.class.getName()+"$int"); 14.121 + 14.122 + Class x86 = Class.forName(QuotedIdent_BAD63.class.getName()+"$*86"); 14.123 + if (x86 != #"*86".class) 14.124 + check(32, "reflected "+x86, "static "+#"*86".class); 14.125 + 14.126 + s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"()); 14.127 + check(31, s, "[*86.555-1212]"); 14.128 + 14.129 + System.out.println("OK"); 14.130 + } 14.131 +} 14.132 + 14.133 +interface #"Yog-Shoggoth" { 14.134 + final String #"(nameless ululation)" = "Tekeli-li!"; 14.135 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/test/tools/javac/typeAnnotations/InnerClass.java Fri Jun 26 19:12:41 2009 -0700 15.3 @@ -0,0 +1,38 @@ 15.4 +/* 15.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.7 + * 15.8 + * This code is free software; you can redistribute it and/or modify it 15.9 + * under the terms of the GNU General Public License version 2 only, as 15.10 + * published by the Free Software Foundation. 15.11 + * 15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15.15 + * version 2 for more details (a copy is included in the LICENSE file that 15.16 + * accompanied this code). 15.17 + * 15.18 + * You should have received a copy of the GNU General Public License version 15.19 + * 2 along with this work; if not, write to the Free Software Foundation, 15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 15.21 + * 15.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 15.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 15.24 + * have any questions. 15.25 + */ 15.26 + 15.27 +/* 15.28 + * @test 15.29 + * @bug 6843077 15.30 + * @summary compiler crashes when visiting inner classes 15.31 + * @author Mahmood Ali 15.32 + * @compile -source 1.7 InnerClass.java 15.33 + */ 15.34 + 15.35 +class InnerClass { 15.36 + private void a() { 15.37 + new Object() { 15.38 + public <R> void method() { } 15.39 + }; 15.40 + } 15.41 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/test/tools/javac/typeAnnotations/MultipleTargets.java Fri Jun 26 19:12:41 2009 -0700 16.3 @@ -0,0 +1,41 @@ 16.4 +/* 16.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 16.7 + * 16.8 + * This code is free software; you can redistribute it and/or modify it 16.9 + * under the terms of the GNU General Public License version 2 only, as 16.10 + * published by the Free Software Foundation. 16.11 + * 16.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 16.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16.15 + * version 2 for more details (a copy is included in the LICENSE file that 16.16 + * accompanied this code). 16.17 + * 16.18 + * You should have received a copy of the GNU General Public License version 16.19 + * 2 along with this work; if not, write to the Free Software Foundation, 16.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 16.21 + * 16.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 16.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 16.24 + * have any questions. 16.25 + */ 16.26 + 16.27 +/* 16.28 + * @test 16.29 + * @bug 6843077 16.30 + * @summary check that type annotations may appear on void method if it is a 16.31 + * method annotation too. 16.32 + * @author Mahmood Ali 16.33 + * @compile -source 1.7 MultipleTargets.java 16.34 + */ 16.35 + 16.36 +import java.lang.annotation.Target; 16.37 +import java.lang.annotation.ElementType; 16.38 + 16.39 +class TypeUseTarget<K extends @A Object> { 16.40 + @A void voidMethod() { } 16.41 +} 16.42 + 16.43 +@Target({ElementType.TYPE_USE, ElementType.METHOD}) 16.44 +@interface A { }
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/test/tools/javac/typeAnnotations/TypeParameterTarget.java Fri Jun 26 19:12:41 2009 -0700 17.3 @@ -0,0 +1,46 @@ 17.4 +/* 17.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.7 + * 17.8 + * This code is free software; you can redistribute it and/or modify it 17.9 + * under the terms of the GNU General Public License version 2 only, as 17.10 + * published by the Free Software Foundation. 17.11 + * 17.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 17.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17.15 + * version 2 for more details (a copy is included in the LICENSE file that 17.16 + * accompanied this code). 17.17 + * 17.18 + * You should have received a copy of the GNU General Public License version 17.19 + * 2 along with this work; if not, write to the Free Software Foundation, 17.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17.21 + * 17.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 17.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 17.24 + * have any questions. 17.25 + */ 17.26 + 17.27 +/* 17.28 + * @test 17.29 + * @bug 6843077 17.30 + * @summary check that type annotations may appear on all type parameter 17.31 + * @author Mahmood Ali 17.32 + * @compile -source 1.7 TypeParameterTarget.java 17.33 + */ 17.34 + 17.35 +import java.lang.annotation.Target; 17.36 +import java.lang.annotation.ElementType; 17.37 + 17.38 +class TypeUseTarget<@A K extends Object> { 17.39 + String[] field; 17.40 + 17.41 + <@A K, @A V> String genericMethod(K k) { return null; } 17.42 +} 17.43 + 17.44 +interface MyInterface { } 17.45 + 17.46 +@interface MyAnnotation { } 17.47 + 17.48 +@Target(ElementType.TYPE_PARAMETER) 17.49 +@interface A { }
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/test/tools/javac/typeAnnotations/TypeUseTarget.java Fri Jun 26 19:12:41 2009 -0700 18.3 @@ -0,0 +1,55 @@ 18.4 +/* 18.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.7 + * 18.8 + * This code is free software; you can redistribute it and/or modify it 18.9 + * under the terms of the GNU General Public License version 2 only, as 18.10 + * published by the Free Software Foundation. 18.11 + * 18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18.15 + * version 2 for more details (a copy is included in the LICENSE file that 18.16 + * accompanied this code). 18.17 + * 18.18 + * You should have received a copy of the GNU General Public License version 18.19 + * 2 along with this work; if not, write to the Free Software Foundation, 18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18.21 + * 18.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 18.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 18.24 + * have any questions. 18.25 + */ 18.26 + 18.27 +/* 18.28 + * @test 18.29 + * @bug 6843077 18.30 + * @summary check that type annotations may appear on all type declarations 18.31 + * @author Mahmood Ali 18.32 + * @compile -source 1.7 TypeUseTarget.java 18.33 + */ 18.34 + 18.35 +import java.lang.annotation.Target; 18.36 +import java.lang.annotation.ElementType; 18.37 + 18.38 +@A 18.39 +class TypeUseTarget<K extends @A Object> { 18.40 + @A String @A [] field; 18.41 + 18.42 + @A String test(@A String param, @A String @A ... vararg) @A { 18.43 + @A Object o = new @A String @A [3]; 18.44 + TypeUseTarget<@A String> target; 18.45 + return (@A String) null; 18.46 + } 18.47 + 18.48 + <K> @A String genericMethod(K k) { return null; } 18.49 +} 18.50 + 18.51 +@A 18.52 +interface MyInterface { } 18.53 + 18.54 +@A 18.55 +@interface MyAnnotation { } 18.56 + 18.57 +@Target(ElementType.TYPE_USE) 18.58 +@interface A { }
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/test/tools/javac/typeAnnotations/attribution/Scopes.java Fri Jun 26 19:12:41 2009 -0700 19.3 @@ -0,0 +1,38 @@ 19.4 +/* 19.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.7 + * 19.8 + * This code is free software; you can redistribute it and/or modify it 19.9 + * under the terms of the GNU General Public License version 2 only, as 19.10 + * published by the Free Software Foundation. 19.11 + * 19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19.15 + * version 2 for more details (a copy is included in the LICENSE file that 19.16 + * accompanied this code). 19.17 + * 19.18 + * You should have received a copy of the GNU General Public License version 19.19 + * 2 along with this work; if not, write to the Free Software Foundation, 19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19.21 + * 19.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 19.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 19.24 + * have any questions. 19.25 + */ 19.26 + 19.27 +/* 19.28 + * @test 19.29 + * @bug 6843077 19.30 + * @summary test scopes of attribution 19.31 + * @author Mahmood Ali 19.32 + * @compile -source 1.7 Scopes.java 19.33 + */ 19.34 +class Scopes { 19.35 + 19.36 + void test() @A(VALUE) { } 19.37 + void test1() @A(value=VALUE) { } 19.38 + 19.39 + private static final int VALUE = 1; 19.40 + @interface A { int value(); } 19.41 +}
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/test/tools/javac/typeAnnotations/failures/AnnotationVersion.java Fri Jun 26 19:12:41 2009 -0700 20.3 @@ -0,0 +1,35 @@ 20.4 +/* 20.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.7 + * 20.8 + * This code is free software; you can redistribute it and/or modify it 20.9 + * under the terms of the GNU General Public License version 2 only, as 20.10 + * published by the Free Software Foundation. 20.11 + * 20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20.15 + * version 2 for more details (a copy is included in the LICENSE file that 20.16 + * accompanied this code). 20.17 + * 20.18 + * You should have received a copy of the GNU General Public License version 20.19 + * 2 along with this work; if not, write to the Free Software Foundation, 20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20.21 + * 20.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 20.24 + * have any questions. 20.25 + */ 20.26 + 20.27 +/* 20.28 + * @test 20.29 + * @bug 6843077 20.30 + * @summary test that only java 7 allows type annotations 20.31 + * @author Mahmood Ali 20.32 + * @compile/fail/ref=AnnotationVersion.out -XDrawDiagnostics -source 1.6 AnnotationVersion.java 20.33 + */ 20.34 +class AnnotationVersion { 20.35 + public void method() @A { } 20.36 +} 20.37 + 20.38 +@interface A { }
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/test/tools/javac/typeAnnotations/failures/AnnotationVersion.out Fri Jun 26 19:12:41 2009 -0700 21.3 @@ -0,0 +1,2 @@ 21.4 +AnnotationVersion.java:32:25: compiler.err.type.annotations.not.supported.in.source: 1.6 21.5 +1 error
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/test/tools/javac/typeAnnotations/failures/IncompleteArray.java Fri Jun 26 19:12:41 2009 -0700 22.3 @@ -0,0 +1,35 @@ 22.4 +/* 22.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.7 + * 22.8 + * This code is free software; you can redistribute it and/or modify it 22.9 + * under the terms of the GNU General Public License version 2 only, as 22.10 + * published by the Free Software Foundation. 22.11 + * 22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 22.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22.15 + * version 2 for more details (a copy is included in the LICENSE file that 22.16 + * accompanied this code). 22.17 + * 22.18 + * You should have received a copy of the GNU General Public License version 22.19 + * 2 along with this work; if not, write to the Free Software Foundation, 22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22.21 + * 22.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 22.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 22.24 + * have any questions. 22.25 + */ 22.26 + 22.27 +/* 22.28 + * @test 22.29 + * @bug 6843077 22.30 + * @summary test incomplete array declaration 22.31 + * @author Mahmood Ali 22.32 + * @compile/fail/ref=IncompleteArray.out -XDrawDiagnostics -source 1.7 IncompleteArray.java 22.33 + */ 22.34 +class IncompleteArray { 22.35 + int @A [] @A var; 22.36 +} 22.37 + 22.38 +@interface A { }
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 23.2 +++ b/test/tools/javac/typeAnnotations/failures/IncompleteArray.out Fri Jun 26 19:12:41 2009 -0700 23.3 @@ -0,0 +1,2 @@ 23.4 +IncompleteArray.java:32:13: compiler.err.illegal.start.of.type 23.5 +1 error
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 24.2 +++ b/test/tools/javac/typeAnnotations/failures/IncompleteVararg.java Fri Jun 26 19:12:41 2009 -0700 24.3 @@ -0,0 +1,36 @@ 24.4 +/* 24.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 24.7 + * 24.8 + * This code is free software; you can redistribute it and/or modify it 24.9 + * under the terms of the GNU General Public License version 2 only, as 24.10 + * published by the Free Software Foundation. 24.11 + * 24.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 24.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 24.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 24.15 + * version 2 for more details (a copy is included in the LICENSE file that 24.16 + * accompanied this code). 24.17 + * 24.18 + * You should have received a copy of the GNU General Public License version 24.19 + * 2 along with this work; if not, write to the Free Software Foundation, 24.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 24.21 + * 24.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 24.24 + * have any questions. 24.25 + */ 24.26 + 24.27 +/* 24.28 + * @test 24.29 + * @bug 6843077 24.30 + * @summary test incomplete vararg declaration 24.31 + * @author Mahmood Ali 24.32 + * @compile/fail/ref=IncompleteVararg.out -XDrawDiagnostics -source 1.7 IncompleteVararg.java 24.33 + */ 24.34 +class IncompleteArray { 24.35 + // the last variable may be vararg 24.36 + void method(int @A test) { } 24.37 +} 24.38 + 24.39 +@interface A { }
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/test/tools/javac/typeAnnotations/failures/IncompleteVararg.out Fri Jun 26 19:12:41 2009 -0700 25.3 @@ -0,0 +1,2 @@ 25.4 +IncompleteVararg.java:33:19: compiler.err.illegal.start.of.type 25.5 +1 error
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 26.2 +++ b/test/tools/javac/typeAnnotations/failures/IndexArray.java Fri Jun 26 19:12:41 2009 -0700 26.3 @@ -0,0 +1,36 @@ 26.4 +/* 26.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 26.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 26.7 + * 26.8 + * This code is free software; you can redistribute it and/or modify it 26.9 + * under the terms of the GNU General Public License version 2 only, as 26.10 + * published by the Free Software Foundation. 26.11 + * 26.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 26.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 26.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 26.15 + * version 2 for more details (a copy is included in the LICENSE file that 26.16 + * accompanied this code). 26.17 + * 26.18 + * You should have received a copy of the GNU General Public License version 26.19 + * 2 along with this work; if not, write to the Free Software Foundation, 26.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 26.21 + * 26.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 26.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 26.24 + * have any questions. 26.25 + */ 26.26 + 26.27 +/* 26.28 + * @test 26.29 + * @bug 6843077 26.30 + * @summary test indexing of an array 26.31 + * @author Mahmood Ali 26.32 + * @compile/fail/ref=IndexArray.out -XDrawDiagnostics -source 1.7 IndexArray.java 26.33 + */ 26.34 +class IndexArray { 26.35 + int[] var; 26.36 + int a = var @A [1]; 26.37 +} 26.38 + 26.39 +@interface A { }
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 27.2 +++ b/test/tools/javac/typeAnnotations/failures/IndexArray.out Fri Jun 26 19:12:41 2009 -0700 27.3 @@ -0,0 +1,2 @@ 27.4 +IndexArray.java:33:15: compiler.err.illegal.start.of.expr 27.5 +1 error
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/test/tools/javac/typeAnnotations/failures/LintCast.java Fri Jun 26 19:12:41 2009 -0700 28.3 @@ -0,0 +1,65 @@ 28.4 +/* 28.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 28.7 + * 28.8 + * This code is free software; you can redistribute it and/or modify it 28.9 + * under the terms of the GNU General Public License version 2 only, as 28.10 + * published by the Free Software Foundation. 28.11 + * 28.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 28.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 28.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 28.15 + * version 2 for more details (a copy is included in the LICENSE file that 28.16 + * accompanied this code). 28.17 + * 28.18 + * You should have received a copy of the GNU General Public License version 28.19 + * 2 along with this work; if not, write to the Free Software Foundation, 28.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 28.21 + * 28.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 28.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 28.24 + * have any questions. 28.25 + */ 28.26 + 28.27 +import java.util.List; 28.28 + 28.29 +/* 28.30 + * @test 28.31 + * @bug 6843077 28.32 + * @summary test that compiler doesn't warn about annotated redundant casts 28.33 + * @author Mahmood Ali 28.34 + * @compile/ref=LintCast.out -Xlint:cast -XDrawDiagnostics -source 1.7 LintCast.java 28.35 + */ 28.36 +class LintCast { 28.37 + void unparameterized() { 28.38 + String s = "m"; 28.39 + String s1 = (String)s; 28.40 + String s2 = (@A String)s; 28.41 + } 28.42 + 28.43 + void parameterized() { 28.44 + List<String> l = null; 28.45 + List<String> l1 = (List<String>)l; 28.46 + List<String> l2 = (List<@A String>)l; 28.47 + } 28.48 + 28.49 + void array() { 28.50 + int @A [] a = null; 28.51 + int[] a1 = (int[])a; 28.52 + int[] a2 = (int @A [])a; 28.53 + } 28.54 + 28.55 + void sameAnnotations() { 28.56 + @A String annotated = null; 28.57 + String unannotated = null; 28.58 + 28.59 + // compiler ignore annotated casts even if redundant 28.60 + @A String anno1 = (@A String)annotated; 28.61 + 28.62 + // warn if redundant without an annotation 28.63 + String anno2 = (String)annotated; 28.64 + String unanno2 = (String)unannotated; 28.65 + } 28.66 +} 28.67 + 28.68 +@interface A { }
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/test/tools/javac/typeAnnotations/failures/LintCast.out Fri Jun 26 19:12:41 2009 -0700 29.3 @@ -0,0 +1,6 @@ 29.4 +LintCast.java:36:21: compiler.warn.redundant.cast: java.lang.String 29.5 +LintCast.java:42:27: compiler.warn.redundant.cast: java.util.List<java.lang.String> 29.6 +LintCast.java:48:20: compiler.warn.redundant.cast: int[] 29.7 +LintCast.java:60:24: compiler.warn.redundant.cast: java.lang.String 29.8 +LintCast.java:61:26: compiler.warn.redundant.cast: java.lang.String 29.9 +5 warnings
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 30.2 +++ b/test/tools/javac/typeAnnotations/failures/OldArray.java Fri Jun 26 19:12:41 2009 -0700 30.3 @@ -0,0 +1,35 @@ 30.4 +/* 30.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 30.7 + * 30.8 + * This code is free software; you can redistribute it and/or modify it 30.9 + * under the terms of the GNU General Public License version 2 only, as 30.10 + * published by the Free Software Foundation. 30.11 + * 30.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 30.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 30.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 30.15 + * version 2 for more details (a copy is included in the LICENSE file that 30.16 + * accompanied this code). 30.17 + * 30.18 + * You should have received a copy of the GNU General Public License version 30.19 + * 2 along with this work; if not, write to the Free Software Foundation, 30.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 30.21 + * 30.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 30.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 30.24 + * have any questions. 30.25 + */ 30.26 + 30.27 +/* 30.28 + * @test 30.29 + * @bug 6843077 30.30 + * @summary test old array syntax 30.31 + * @author Mahmood Ali 30.32 + * @compile/fail/ref=OldArray.out -XDrawDiagnostics -source 1.7 OldArray.java 30.33 + */ 30.34 +class OldArray { 30.35 + String [@A] s() { return null; } 30.36 +} 30.37 + 30.38 +@interface A { }
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/test/tools/javac/typeAnnotations/failures/OldArray.out Fri Jun 26 19:12:41 2009 -0700 31.3 @@ -0,0 +1,2 @@ 31.4 +OldArray.java:32:11: compiler.err.expected: ']' 31.5 +1 error
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 32.2 +++ b/test/tools/javac/typeAnnotations/failures/Scopes.java Fri Jun 26 19:12:41 2009 -0700 32.3 @@ -0,0 +1,33 @@ 32.4 +/* 32.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 32.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 32.7 + * 32.8 + * This code is free software; you can redistribute it and/or modify it 32.9 + * under the terms of the GNU General Public License version 2 only, as 32.10 + * published by the Free Software Foundation. 32.11 + * 32.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 32.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 32.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 32.15 + * version 2 for more details (a copy is included in the LICENSE file that 32.16 + * accompanied this code). 32.17 + * 32.18 + * You should have received a copy of the GNU General Public License version 32.19 + * 2 along with this work; if not, write to the Free Software Foundation, 32.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 32.21 + * 32.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 32.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 32.24 + * have any questions. 32.25 + */ 32.26 + 32.27 +/* 32.28 + * @test 32.29 + * @bug 6843077 32.30 + * @summary check that A is accessible in the class type parameters 32.31 + * @author Mahmood Ali 32.32 + * @compile/fail/ref=Scopes.out -XDrawDiagnostics -source 1.7 Scopes.java 32.33 + */ 32.34 +class Scopes<T extends @UniqueInner Object> { 32.35 + @interface UniqueInner { }; 32.36 +}
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 33.2 +++ b/test/tools/javac/typeAnnotations/failures/Scopes.out Fri Jun 26 19:12:41 2009 -0700 33.3 @@ -0,0 +1,2 @@ 33.4 +Scopes.java:31:25: compiler.err.cant.resolve: kindname.class, UniqueInner, , 33.5 +1 error
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 34.2 +++ b/test/tools/javac/typeAnnotations/failures/StaticFields.java Fri Jun 26 19:12:41 2009 -0700 34.3 @@ -0,0 +1,36 @@ 34.4 +/* 34.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 34.7 + * 34.8 + * This code is free software; you can redistribute it and/or modify it 34.9 + * under the terms of the GNU General Public License version 2 only, as 34.10 + * published by the Free Software Foundation. 34.11 + * 34.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 34.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 34.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 34.15 + * version 2 for more details (a copy is included in the LICENSE file that 34.16 + * accompanied this code). 34.17 + * 34.18 + * You should have received a copy of the GNU General Public License version 34.19 + * 2 along with this work; if not, write to the Free Software Foundation, 34.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 34.21 + * 34.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 34.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 34.24 + * have any questions. 34.25 + */ 34.26 + 34.27 +/* 34.28 + * @test 34.29 + * @bug 6843077 34.30 + * @summary static field access isn't a valid location 34.31 + * @author Mahmood Ali 34.32 + * @compile/fail/ref=StaticFields.out -XDrawDiagnostics -source 1.7 StaticFields.java 34.33 + */ 34.34 +class C { 34.35 + int f; 34.36 + int a = @A C.f; 34.37 +} 34.38 + 34.39 +@interface A { }
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 35.2 +++ b/test/tools/javac/typeAnnotations/failures/StaticFields.out Fri Jun 26 19:12:41 2009 -0700 35.3 @@ -0,0 +1,2 @@ 35.4 +StaticFields.java:33:17: compiler.err.illegal.start.of.expr 35.5 +1 error
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 36.2 +++ b/test/tools/javac/typeAnnotations/failures/StaticMethods.java Fri Jun 26 19:12:41 2009 -0700 36.3 @@ -0,0 +1,35 @@ 36.4 +/* 36.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 36.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 36.7 + * 36.8 + * This code is free software; you can redistribute it and/or modify it 36.9 + * under the terms of the GNU General Public License version 2 only, as 36.10 + * published by the Free Software Foundation. 36.11 + * 36.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 36.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 36.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 36.15 + * version 2 for more details (a copy is included in the LICENSE file that 36.16 + * accompanied this code). 36.17 + * 36.18 + * You should have received a copy of the GNU General Public License version 36.19 + * 2 along with this work; if not, write to the Free Software Foundation, 36.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 36.21 + * 36.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 36.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 36.24 + * have any questions. 36.25 + */ 36.26 + 36.27 +/* 36.28 + * @test 36.29 + * @bug 6843077 36.30 + * @summary static methods don't have receivers 36.31 + * @author Mahmood Ali 36.32 + * @compile/fail/ref=StaticMethods.out -XDrawDiagnostics -source 1.7 StaticMethods.java 36.33 + */ 36.34 +class StaticMethods { 36.35 + static void main() @A { } 36.36 +} 36.37 + 36.38 +@interface A { }
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 37.2 +++ b/test/tools/javac/typeAnnotations/failures/StaticMethods.out Fri Jun 26 19:12:41 2009 -0700 37.3 @@ -0,0 +1,2 @@ 37.4 +StaticMethods.java:32:22: compiler.err.annotation.type.not.applicable 37.5 +1 error
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 38.2 +++ b/test/tools/javac/typeAnnotations/failures/VoidGenericMethod.java Fri Jun 26 19:12:41 2009 -0700 38.3 @@ -0,0 +1,35 @@ 38.4 +/* 38.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 38.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 38.7 + * 38.8 + * This code is free software; you can redistribute it and/or modify it 38.9 + * under the terms of the GNU General Public License version 2 only, as 38.10 + * published by the Free Software Foundation. 38.11 + * 38.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 38.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 38.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 38.15 + * version 2 for more details (a copy is included in the LICENSE file that 38.16 + * accompanied this code). 38.17 + * 38.18 + * You should have received a copy of the GNU General Public License version 38.19 + * 2 along with this work; if not, write to the Free Software Foundation, 38.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 38.21 + * 38.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 38.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 38.24 + * have any questions. 38.25 + */ 38.26 + 38.27 +/* 38.28 + * @test 38.29 + * @bug 6843077 38.30 + * @summary test type annotation on void generic methods 38.31 + * @author Mahmood Ali 38.32 + * @compile/fail -source 1.7 VoidGenericMethod.java 38.33 + */ 38.34 +class VoidGenericMethod { 38.35 + public <T> @A void method() { } 38.36 +} 38.37 + 38.38 +@interface A { }
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 39.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 39.3 @@ -0,0 +1,37 @@ 39.4 +/* 39.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 39.7 + * 39.8 + * This code is free software; you can redistribute it and/or modify it 39.9 + * under the terms of the GNU General Public License version 2 only, as 39.10 + * published by the Free Software Foundation. 39.11 + * 39.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 39.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 39.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 39.15 + * version 2 for more details (a copy is included in the LICENSE file that 39.16 + * accompanied this code). 39.17 + * 39.18 + * You should have received a copy of the GNU General Public License version 39.19 + * 2 along with this work; if not, write to the Free Software Foundation, 39.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 39.21 + * 39.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 39.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 39.24 + * have any questions. 39.25 + */ 39.26 + 39.27 +/* 39.28 + * @test 39.29 + * @bug 6843077 39.30 + * @summary check for duplicate annotation values 39.31 + * @author Mahmood Ali 39.32 + * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java 39.33 + */ 39.34 +class DuplicateAnnotationValue { 39.35 + void test() { 39.36 + Object a = String @A(value = 2, value = 1) [].class; 39.37 + } 39.38 +} 39.39 + 39.40 +@interface A { int value(); }
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 40.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 40.3 @@ -0,0 +1,2 @@ 40.4 +DuplicateAnnotationValue.java:33:45: compiler.err.duplicate.annotation.member.value: value, A 40.5 +1 error
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 41.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.java Fri Jun 26 19:12:41 2009 -0700 41.3 @@ -0,0 +1,38 @@ 41.4 +/* 41.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41.7 + * 41.8 + * This code is free software; you can redistribute it and/or modify it 41.9 + * under the terms of the GNU General Public License version 2 only, as 41.10 + * published by the Free Software Foundation. 41.11 + * 41.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 41.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 41.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41.15 + * version 2 for more details (a copy is included in the LICENSE file that 41.16 + * accompanied this code). 41.17 + * 41.18 + * You should have received a copy of the GNU General Public License version 41.19 + * 2 along with this work; if not, write to the Free Software Foundation, 41.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 41.21 + * 41.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 41.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 41.24 + * have any questions. 41.25 + */ 41.26 + 41.27 +/* 41.28 + * @test 41.29 + * @bug 6843077 41.30 + * @summary check for duplicate annotations 41.31 + * @author Mahmood Ali 41.32 + * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java 41.33 + */ 41.34 + 41.35 +class DuplicateTypeAnnotation { 41.36 + void test() { 41.37 + Object a = String @A @A [].class; 41.38 + } 41.39 +} 41.40 + 41.41 +@interface A { }
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 42.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.out Fri Jun 26 19:12:41 2009 -0700 42.3 @@ -0,0 +1,2 @@ 42.4 +DuplicateTypeAnnotation.java:34:26: compiler.err.duplicate.annotation 42.5 +1 error
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 43.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.java Fri Jun 26 19:12:41 2009 -0700 43.3 @@ -0,0 +1,39 @@ 43.4 +/* 43.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 43.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 43.7 + * 43.8 + * This code is free software; you can redistribute it and/or modify it 43.9 + * under the terms of the GNU General Public License version 2 only, as 43.10 + * published by the Free Software Foundation. 43.11 + * 43.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 43.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 43.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 43.15 + * version 2 for more details (a copy is included in the LICENSE file that 43.16 + * accompanied this code). 43.17 + * 43.18 + * You should have received a copy of the GNU General Public License version 43.19 + * 2 along with this work; if not, write to the Free Software Foundation, 43.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 43.21 + * 43.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 43.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 43.24 + * have any questions. 43.25 + */ 43.26 + 43.27 +/* 43.28 + * @test 43.29 + * @bug 6843077 43.30 + * @summary check for invalid annotatins given the target 43.31 + * @author Mahmood Ali 43.32 + * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java 43.33 + */ 43.34 + 43.35 +class InvalidLocation { 43.36 + void test() { 43.37 + Object a = String @A [].class; 43.38 + } 43.39 +} 43.40 + 43.41 +@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) 43.42 +@interface A { }
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 44.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.out Fri Jun 26 19:12:41 2009 -0700 44.3 @@ -0,0 +1,2 @@ 44.4 +InvalidLocation.java:34:23: compiler.err.annotation.type.not.applicable 44.5 +1 error
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 45.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 45.3 @@ -0,0 +1,37 @@ 45.4 +/* 45.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 45.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 45.7 + * 45.8 + * This code is free software; you can redistribute it and/or modify it 45.9 + * under the terms of the GNU General Public License version 2 only, as 45.10 + * published by the Free Software Foundation. 45.11 + * 45.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 45.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 45.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 45.15 + * version 2 for more details (a copy is included in the LICENSE file that 45.16 + * accompanied this code). 45.17 + * 45.18 + * You should have received a copy of the GNU General Public License version 45.19 + * 2 along with this work; if not, write to the Free Software Foundation, 45.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 45.21 + * 45.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 45.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 45.24 + * have any questions. 45.25 + */ 45.26 + 45.27 +/* 45.28 + * @test 45.29 + * @bug 6843077 45.30 + * @summary check for missing annotation value 45.31 + * @author Mahmood Ali 45.32 + * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java 45.33 + */ 45.34 +class MissingAnnotationValue { 45.35 + void test() { 45.36 + Object a = String @A [].class; 45.37 + } 45.38 +} 45.39 + 45.40 +@interface A { int field(); }
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 46.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 46.3 @@ -0,0 +1,2 @@ 46.4 +MissingAnnotationValue.java:33:23: compiler.err.annotation.missing.default.value: A, field 46.5 +1 error
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 47.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 47.3 @@ -0,0 +1,37 @@ 47.4 +/* 47.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 47.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 47.7 + * 47.8 + * This code is free software; you can redistribute it and/or modify it 47.9 + * under the terms of the GNU General Public License version 2 only, as 47.10 + * published by the Free Software Foundation. 47.11 + * 47.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 47.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 47.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 47.15 + * version 2 for more details (a copy is included in the LICENSE file that 47.16 + * accompanied this code). 47.17 + * 47.18 + * You should have received a copy of the GNU General Public License version 47.19 + * 2 along with this work; if not, write to the Free Software Foundation, 47.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 47.21 + * 47.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 47.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 47.24 + * have any questions. 47.25 + */ 47.26 + 47.27 +/* 47.28 + * @test 47.29 + * @bug 6843077 47.30 + * @summary check for duplicate annotation values 47.31 + * @author Mahmood Ali 47.32 + * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java 47.33 + */ 47.34 +class DuplicateAnnotationValue { 47.35 + void test() { 47.36 + String @A(value = 2, value = 1) [] s; 47.37 + } 47.38 +} 47.39 + 47.40 +@interface A { int value(); }
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 48.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 48.3 @@ -0,0 +1,2 @@ 48.4 +DuplicateAnnotationValue.java:33:34: compiler.err.duplicate.annotation.member.value: value, A 48.5 +1 error
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 49.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java Fri Jun 26 19:12:41 2009 -0700 49.3 @@ -0,0 +1,38 @@ 49.4 +/* 49.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 49.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 49.7 + * 49.8 + * This code is free software; you can redistribute it and/or modify it 49.9 + * under the terms of the GNU General Public License version 2 only, as 49.10 + * published by the Free Software Foundation. 49.11 + * 49.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 49.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 49.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 49.15 + * version 2 for more details (a copy is included in the LICENSE file that 49.16 + * accompanied this code). 49.17 + * 49.18 + * You should have received a copy of the GNU General Public License version 49.19 + * 2 along with this work; if not, write to the Free Software Foundation, 49.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 49.21 + * 49.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 49.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 49.24 + * have any questions. 49.25 + */ 49.26 + 49.27 +/* 49.28 + * @test 49.29 + * @bug 6843077 49.30 + * @summary check for duplicate annotations 49.31 + * @author Mahmood Ali 49.32 + * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java 49.33 + */ 49.34 + 49.35 +class DuplicateTypeAnnotation { 49.36 + void test() { 49.37 + String @A @A [] s; 49.38 + } 49.39 +} 49.40 + 49.41 +@interface A { }
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out Fri Jun 26 19:12:41 2009 -0700 50.3 @@ -0,0 +1,2 @@ 50.4 +DuplicateTypeAnnotation.java:34:15: compiler.err.duplicate.annotation 50.5 +1 error
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.java Fri Jun 26 19:12:41 2009 -0700 51.3 @@ -0,0 +1,39 @@ 51.4 +/* 51.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 51.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 51.7 + * 51.8 + * This code is free software; you can redistribute it and/or modify it 51.9 + * under the terms of the GNU General Public License version 2 only, as 51.10 + * published by the Free Software Foundation. 51.11 + * 51.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 51.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 51.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 51.15 + * version 2 for more details (a copy is included in the LICENSE file that 51.16 + * accompanied this code). 51.17 + * 51.18 + * You should have received a copy of the GNU General Public License version 51.19 + * 2 along with this work; if not, write to the Free Software Foundation, 51.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 51.21 + * 51.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 51.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 51.24 + * have any questions. 51.25 + */ 51.26 + 51.27 +/* 51.28 + * @test 51.29 + * @bug 6843077 51.30 + * @summary check for invalid annotatins given the target 51.31 + * @author Mahmood Ali 51.32 + * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java 51.33 + */ 51.34 + 51.35 +class InvalidLocation { 51.36 + void test() { 51.37 + String @A [] s; 51.38 + } 51.39 +} 51.40 + 51.41 +@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) 51.42 +@interface A { }
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 52.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.out Fri Jun 26 19:12:41 2009 -0700 52.3 @@ -0,0 +1,2 @@ 52.4 +InvalidLocation.java:34:12: compiler.err.annotation.type.not.applicable 52.5 +1 error
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 53.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 53.3 @@ -0,0 +1,37 @@ 53.4 +/* 53.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 53.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 53.7 + * 53.8 + * This code is free software; you can redistribute it and/or modify it 53.9 + * under the terms of the GNU General Public License version 2 only, as 53.10 + * published by the Free Software Foundation. 53.11 + * 53.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 53.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 53.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 53.15 + * version 2 for more details (a copy is included in the LICENSE file that 53.16 + * accompanied this code). 53.17 + * 53.18 + * You should have received a copy of the GNU General Public License version 53.19 + * 2 along with this work; if not, write to the Free Software Foundation, 53.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 53.21 + * 53.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 53.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 53.24 + * have any questions. 53.25 + */ 53.26 + 53.27 +/* 53.28 + * @test 53.29 + * @bug 6843077 53.30 + * @summary check for missing annotation value 53.31 + * @author Mahmood Ali 53.32 + * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java 53.33 + */ 53.34 +class MissingAnnotationValue { 53.35 + void test() { 53.36 + String @A [] s; 53.37 + } 53.38 +} 53.39 + 53.40 +@interface A { int field(); }
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 54.2 +++ b/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 54.3 @@ -0,0 +1,2 @@ 54.4 +MissingAnnotationValue.java:33:12: compiler.err.annotation.missing.default.value: A, field 54.5 +1 error
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 55.2 +++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 55.3 @@ -0,0 +1,37 @@ 55.4 +/* 55.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 55.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 55.7 + * 55.8 + * This code is free software; you can redistribute it and/or modify it 55.9 + * under the terms of the GNU General Public License version 2 only, as 55.10 + * published by the Free Software Foundation. 55.11 + * 55.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 55.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 55.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 55.15 + * version 2 for more details (a copy is included in the LICENSE file that 55.16 + * accompanied this code). 55.17 + * 55.18 + * You should have received a copy of the GNU General Public License version 55.19 + * 2 along with this work; if not, write to the Free Software Foundation, 55.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 55.21 + * 55.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 55.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 55.24 + * have any questions. 55.25 + */ 55.26 + 55.27 +/* 55.28 + * @test 55.29 + * @bug 6843077 55.30 + * @summary check for duplicate annotation values for type parameter 55.31 + * @author Mahmood Ali 55.32 + * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java 55.33 + */ 55.34 +class DuplicateAnnotationValue { 55.35 + void method() { 55.36 + class Inner<@A(value = 2, value = 1) K> {} 55.37 + } 55.38 +} 55.39 + 55.40 +@interface A { int value(); }
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 56.2 +++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 56.3 @@ -0,0 +1,2 @@ 56.4 +DuplicateAnnotationValue.java:33:39: compiler.err.duplicate.annotation.member.value: value, A 56.5 +1 error
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 57.2 +++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java Fri Jun 26 19:12:41 2009 -0700 57.3 @@ -0,0 +1,37 @@ 57.4 +/* 57.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 57.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 57.7 + * 57.8 + * This code is free software; you can redistribute it and/or modify it 57.9 + * under the terms of the GNU General Public License version 2 only, as 57.10 + * published by the Free Software Foundation. 57.11 + * 57.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 57.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 57.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 57.15 + * version 2 for more details (a copy is included in the LICENSE file that 57.16 + * accompanied this code). 57.17 + * 57.18 + * You should have received a copy of the GNU General Public License version 57.19 + * 2 along with this work; if not, write to the Free Software Foundation, 57.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 57.21 + * 57.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 57.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 57.24 + * have any questions. 57.25 + */ 57.26 + 57.27 +/* 57.28 + * @test 57.29 + * @bug 6843077 57.30 + * @summary check for duplicate annotations 57.31 + * @author Mahmood Ali 57.32 + * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java 57.33 + */ 57.34 +class DuplicateTypeAnno { 57.35 + void innermethod() { 57.36 + class Inner<@A @A K> { } 57.37 + } 57.38 +} 57.39 + 57.40 +@interface A { }
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 58.2 +++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out Fri Jun 26 19:12:41 2009 -0700 58.3 @@ -0,0 +1,2 @@ 58.4 +DuplicateTypeAnnotation.java:33:20: compiler.err.duplicate.annotation 58.5 +1 error
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 59.2 +++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java Fri Jun 26 19:12:41 2009 -0700 59.3 @@ -0,0 +1,38 @@ 59.4 +/* 59.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 59.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 59.7 + * 59.8 + * This code is free software; you can redistribute it and/or modify it 59.9 + * under the terms of the GNU General Public License version 2 only, as 59.10 + * published by the Free Software Foundation. 59.11 + * 59.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 59.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 59.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 59.15 + * version 2 for more details (a copy is included in the LICENSE file that 59.16 + * accompanied this code). 59.17 + * 59.18 + * You should have received a copy of the GNU General Public License version 59.19 + * 2 along with this work; if not, write to the Free Software Foundation, 59.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 59.21 + * 59.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 59.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 59.24 + * have any questions. 59.25 + */ 59.26 + 59.27 +/* 59.28 + * @test 59.29 + * @bug 6843077 59.30 + * @summary check for invalid annotatins given the target 59.31 + * @author Mahmood Ali 59.32 + * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java 59.33 + */ 59.34 +class InvalidLocation { 59.35 + void innermethod() { 59.36 + class Inner<@A K> {} 59.37 + } 59.38 +} 59.39 + 59.40 +@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) 59.41 +@interface A { }
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 60.2 +++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out Fri Jun 26 19:12:41 2009 -0700 60.3 @@ -0,0 +1,2 @@ 60.4 +InvalidLocation.java:33:17: compiler.err.annotation.type.not.applicable 60.5 +1 error
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 61.2 +++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 61.3 @@ -0,0 +1,37 @@ 61.4 +/* 61.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 61.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 61.7 + * 61.8 + * This code is free software; you can redistribute it and/or modify it 61.9 + * under the terms of the GNU General Public License version 2 only, as 61.10 + * published by the Free Software Foundation. 61.11 + * 61.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 61.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 61.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 61.15 + * version 2 for more details (a copy is included in the LICENSE file that 61.16 + * accompanied this code). 61.17 + * 61.18 + * You should have received a copy of the GNU General Public License version 61.19 + * 2 along with this work; if not, write to the Free Software Foundation, 61.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 61.21 + * 61.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 61.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 61.24 + * have any questions. 61.25 + */ 61.26 + 61.27 +/* 61.28 + * @test 61.29 + * @bug 6843077 61.30 + * @summary check for missing annotation value 61.31 + * @author Mahmood Ali 61.32 + * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java 61.33 + */ 61.34 +class MissingAnnotationValue { 61.35 + void innermethod() { 61.36 + class Inner<@A K> { } 61.37 + } 61.38 +} 61.39 + 61.40 +@interface A { int field(); }
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 62.2 +++ b/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 62.3 @@ -0,0 +1,2 @@ 62.4 +MissingAnnotationValue.java:33:17: compiler.err.annotation.missing.default.value: A, field 62.5 +1 error
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 63.2 +++ b/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 63.3 @@ -0,0 +1,37 @@ 63.4 +/* 63.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 63.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 63.7 + * 63.8 + * This code is free software; you can redistribute it and/or modify it 63.9 + * under the terms of the GNU General Public License version 2 only, as 63.10 + * published by the Free Software Foundation. 63.11 + * 63.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 63.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 63.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 63.15 + * version 2 for more details (a copy is included in the LICENSE file that 63.16 + * accompanied this code). 63.17 + * 63.18 + * You should have received a copy of the GNU General Public License version 63.19 + * 2 along with this work; if not, write to the Free Software Foundation, 63.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 63.21 + * 63.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 63.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 63.24 + * have any questions. 63.25 + */ 63.26 + 63.27 +/* 63.28 + * @test 63.29 + * @bug 6843077 63.30 + * @summary check for duplicate annotation values 63.31 + * @author Mahmood Ali 63.32 + * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java 63.33 + */ 63.34 +class DuplicateAnnotationValue { 63.35 + void test() { 63.36 + String[] a = new String @A(value = 2, value = 1) [5] ; 63.37 + } 63.38 +} 63.39 + 63.40 +@interface A { int value(); }
64.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 64.2 +++ b/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 64.3 @@ -0,0 +1,2 @@ 64.4 +DuplicateAnnotationValue.java:33:51: compiler.err.duplicate.annotation.member.value: value, A 64.5 +1 error
65.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 65.2 +++ b/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java Fri Jun 26 19:12:41 2009 -0700 65.3 @@ -0,0 +1,38 @@ 65.4 +/* 65.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 65.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 65.7 + * 65.8 + * This code is free software; you can redistribute it and/or modify it 65.9 + * under the terms of the GNU General Public License version 2 only, as 65.10 + * published by the Free Software Foundation. 65.11 + * 65.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 65.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 65.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 65.15 + * version 2 for more details (a copy is included in the LICENSE file that 65.16 + * accompanied this code). 65.17 + * 65.18 + * You should have received a copy of the GNU General Public License version 65.19 + * 2 along with this work; if not, write to the Free Software Foundation, 65.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 65.21 + * 65.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 65.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 65.24 + * have any questions. 65.25 + */ 65.26 + 65.27 +/* 65.28 + * @test 65.29 + * @bug 6843077 65.30 + * @summary check for duplicate annotations 65.31 + * @author Mahmood Ali 65.32 + * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java 65.33 + */ 65.34 + 65.35 +class DuplicateTypeAnnotation { 65.36 + void test() { 65.37 + String[] a = new String @A @A [5] ; 65.38 + } 65.39 +} 65.40 + 65.41 +@interface A { }
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 66.2 +++ b/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out Fri Jun 26 19:12:41 2009 -0700 66.3 @@ -0,0 +1,2 @@ 66.4 +DuplicateTypeAnnotation.java:34:32: compiler.err.duplicate.annotation 66.5 +1 error
67.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 67.2 +++ b/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.java Fri Jun 26 19:12:41 2009 -0700 67.3 @@ -0,0 +1,39 @@ 67.4 +/* 67.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 67.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 67.7 + * 67.8 + * This code is free software; you can redistribute it and/or modify it 67.9 + * under the terms of the GNU General Public License version 2 only, as 67.10 + * published by the Free Software Foundation. 67.11 + * 67.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 67.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 67.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 67.15 + * version 2 for more details (a copy is included in the LICENSE file that 67.16 + * accompanied this code). 67.17 + * 67.18 + * You should have received a copy of the GNU General Public License version 67.19 + * 2 along with this work; if not, write to the Free Software Foundation, 67.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 67.21 + * 67.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 67.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 67.24 + * have any questions. 67.25 + */ 67.26 + 67.27 +/* 67.28 + * @test 67.29 + * @bug 6843077 67.30 + * @summary check for invalid annotatins given the target 67.31 + * @author Mahmood Ali 67.32 + * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java 67.33 + */ 67.34 + 67.35 +class InvalidLocation { 67.36 + void test() { 67.37 + String[] s = new String @A [5] ; 67.38 + } 67.39 +} 67.40 + 67.41 +@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) 67.42 +@interface A { }
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 68.2 +++ b/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.out Fri Jun 26 19:12:41 2009 -0700 68.3 @@ -0,0 +1,2 @@ 68.4 +InvalidLocation.java:34:29: compiler.err.annotation.type.not.applicable 68.5 +1 error
69.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 69.2 +++ b/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 69.3 @@ -0,0 +1,37 @@ 69.4 +/* 69.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 69.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 69.7 + * 69.8 + * This code is free software; you can redistribute it and/or modify it 69.9 + * under the terms of the GNU General Public License version 2 only, as 69.10 + * published by the Free Software Foundation. 69.11 + * 69.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 69.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 69.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 69.15 + * version 2 for more details (a copy is included in the LICENSE file that 69.16 + * accompanied this code). 69.17 + * 69.18 + * You should have received a copy of the GNU General Public License version 69.19 + * 2 along with this work; if not, write to the Free Software Foundation, 69.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 69.21 + * 69.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 69.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 69.24 + * have any questions. 69.25 + */ 69.26 + 69.27 +/* 69.28 + * @test 69.29 + * @bug 6843077 69.30 + * @summary check for missing annotation value 69.31 + * @author Mahmood Ali 69.32 + * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java 69.33 + */ 69.34 +class MissingAnnotationValue { 69.35 + void test() { 69.36 + String[] a = new String @A [5]; 69.37 + } 69.38 +} 69.39 + 69.40 +@interface A { int field(); }
70.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 70.2 +++ b/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 70.3 @@ -0,0 +1,2 @@ 70.4 +MissingAnnotationValue.java:33:29: compiler.err.annotation.missing.default.value: A, field 70.5 +1 error
71.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 71.2 +++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 71.3 @@ -0,0 +1,34 @@ 71.4 +/* 71.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 71.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 71.7 + * 71.8 + * This code is free software; you can redistribute it and/or modify it 71.9 + * under the terms of the GNU General Public License version 2 only, as 71.10 + * published by the Free Software Foundation. 71.11 + * 71.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 71.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 71.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 71.15 + * version 2 for more details (a copy is included in the LICENSE file that 71.16 + * accompanied this code). 71.17 + * 71.18 + * You should have received a copy of the GNU General Public License version 71.19 + * 2 along with this work; if not, write to the Free Software Foundation, 71.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 71.21 + * 71.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 71.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 71.24 + * have any questions. 71.25 + */ 71.26 + 71.27 +/* 71.28 + * @test 71.29 + * @bug 6843077 71.30 + * @summary check for duplicate annotation values for type parameter 71.31 + * @author Mahmood Ali 71.32 + * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java 71.33 + */ 71.34 +class DuplicateAnnotationValue<K extends @A(value = 2, value = 1) Object> { 71.35 +} 71.36 + 71.37 +@interface A { int value(); }
72.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 72.2 +++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 72.3 @@ -0,0 +1,2 @@ 72.4 +DuplicateAnnotationValue.java:31:64: compiler.err.duplicate.annotation.member.value: value, A 72.5 +1 error
73.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 73.2 +++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java Fri Jun 26 19:12:41 2009 -0700 73.3 @@ -0,0 +1,35 @@ 73.4 +/* 73.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 73.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 73.7 + * 73.8 + * This code is free software; you can redistribute it and/or modify it 73.9 + * under the terms of the GNU General Public License version 2 only, as 73.10 + * published by the Free Software Foundation. 73.11 + * 73.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 73.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 73.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 73.15 + * version 2 for more details (a copy is included in the LICENSE file that 73.16 + * accompanied this code). 73.17 + * 73.18 + * You should have received a copy of the GNU General Public License version 73.19 + * 2 along with this work; if not, write to the Free Software Foundation, 73.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 73.21 + * 73.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 73.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 73.24 + * have any questions. 73.25 + */ 73.26 + 73.27 +/* 73.28 + * @test 73.29 + * @bug 6843077 73.30 + * @summary check for duplicate annotations 73.31 + * @author Mahmood Ali 73.32 + * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java 73.33 + */ 73.34 + 73.35 +class DuplicateTypeAnno<K extends @A @A Object> { 73.36 +} 73.37 + 73.38 +@interface A { }
74.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 74.2 +++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out Fri Jun 26 19:12:41 2009 -0700 74.3 @@ -0,0 +1,2 @@ 74.4 +DuplicateTypeAnnotation.java:32:38: compiler.err.duplicate.annotation 74.5 +1 error
75.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 75.2 +++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.java Fri Jun 26 19:12:41 2009 -0700 75.3 @@ -0,0 +1,36 @@ 75.4 +/* 75.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 75.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 75.7 + * 75.8 + * This code is free software; you can redistribute it and/or modify it 75.9 + * under the terms of the GNU General Public License version 2 only, as 75.10 + * published by the Free Software Foundation. 75.11 + * 75.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 75.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 75.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 75.15 + * version 2 for more details (a copy is included in the LICENSE file that 75.16 + * accompanied this code). 75.17 + * 75.18 + * You should have received a copy of the GNU General Public License version 75.19 + * 2 along with this work; if not, write to the Free Software Foundation, 75.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 75.21 + * 75.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 75.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 75.24 + * have any questions. 75.25 + */ 75.26 + 75.27 +/* 75.28 + * @test 75.29 + * @bug 6843077 75.30 + * @summary check for invalid annotatins given the target 75.31 + * @author Mahmood Ali 75.32 + * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java 75.33 + */ 75.34 + 75.35 +class InvalidLocation<K extends @A Object> { 75.36 +} 75.37 + 75.38 +@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) 75.39 +@interface A { }
76.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 76.2 +++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.out Fri Jun 26 19:12:41 2009 -0700 76.3 @@ -0,0 +1,2 @@ 76.4 +InvalidLocation.java:32:33: compiler.err.annotation.type.not.applicable 76.5 +1 error
77.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 77.2 +++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 77.3 @@ -0,0 +1,34 @@ 77.4 +/* 77.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 77.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 77.7 + * 77.8 + * This code is free software; you can redistribute it and/or modify it 77.9 + * under the terms of the GNU General Public License version 2 only, as 77.10 + * published by the Free Software Foundation. 77.11 + * 77.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 77.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 77.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 77.15 + * version 2 for more details (a copy is included in the LICENSE file that 77.16 + * accompanied this code). 77.17 + * 77.18 + * You should have received a copy of the GNU General Public License version 77.19 + * 2 along with this work; if not, write to the Free Software Foundation, 77.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 77.21 + * 77.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 77.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 77.24 + * have any questions. 77.25 + */ 77.26 + 77.27 +/* 77.28 + * @test 77.29 + * @bug 6843077 77.30 + * @summary check for missing annotation value 77.31 + * @author Mahmood Ali 77.32 + * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java 77.33 + */ 77.34 +class MissingAnnotationValue<K extends @A Object> { 77.35 +} 77.36 + 77.37 +@interface A { int field(); }
78.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 78.2 +++ b/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 78.3 @@ -0,0 +1,2 @@ 78.4 +MissingAnnotationValue.java:31:40: compiler.err.annotation.missing.default.value: A, field 78.5 +1 error
79.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 79.2 +++ b/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 79.3 @@ -0,0 +1,35 @@ 79.4 +/* 79.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 79.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 79.7 + * 79.8 + * This code is free software; you can redistribute it and/or modify it 79.9 + * under the terms of the GNU General Public License version 2 only, as 79.10 + * published by the Free Software Foundation. 79.11 + * 79.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 79.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 79.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 79.15 + * version 2 for more details (a copy is included in the LICENSE file that 79.16 + * accompanied this code). 79.17 + * 79.18 + * You should have received a copy of the GNU General Public License version 79.19 + * 2 along with this work; if not, write to the Free Software Foundation, 79.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 79.21 + * 79.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 79.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 79.24 + * have any questions. 79.25 + */ 79.26 + 79.27 +/* 79.28 + * @test 79.29 + * @bug 6843077 79.30 + * @summary check for duplicate annotation values in receiver 79.31 + * @author Mahmood Ali 79.32 + * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java 79.33 + */ 79.34 +class DuplicateAnnotationValue { 79.35 + void test() @A(value = 2, value = 1) { } 79.36 +} 79.37 + 79.38 +@interface A { int value(); }
80.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 80.2 +++ b/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 80.3 @@ -0,0 +1,2 @@ 80.4 +DuplicateAnnotationValue.java:32:37: compiler.err.duplicate.annotation.member.value: value, A 80.5 +1 error
81.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 81.2 +++ b/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java Fri Jun 26 19:12:41 2009 -0700 81.3 @@ -0,0 +1,36 @@ 81.4 +/* 81.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 81.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 81.7 + * 81.8 + * This code is free software; you can redistribute it and/or modify it 81.9 + * under the terms of the GNU General Public License version 2 only, as 81.10 + * published by the Free Software Foundation. 81.11 + * 81.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 81.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 81.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 81.15 + * version 2 for more details (a copy is included in the LICENSE file that 81.16 + * accompanied this code). 81.17 + * 81.18 + * You should have received a copy of the GNU General Public License version 81.19 + * 2 along with this work; if not, write to the Free Software Foundation, 81.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 81.21 + * 81.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 81.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 81.24 + * have any questions. 81.25 + */ 81.26 + 81.27 +/* 81.28 + * @test 81.29 + * @bug 6843077 81.30 + * @summary check for duplicate annotations in receiver 81.31 + * @author Mahmood Ali 81.32 + * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java 81.33 + */ 81.34 + 81.35 +class DuplicateTypeAnnotation { 81.36 + void test() @A @A { } 81.37 +} 81.38 + 81.39 +@interface A { }
82.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 82.2 +++ b/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out Fri Jun 26 19:12:41 2009 -0700 82.3 @@ -0,0 +1,2 @@ 82.4 +DuplicateTypeAnnotation.java:33:18: compiler.err.duplicate.annotation 82.5 +1 error
83.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 83.2 +++ b/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.java Fri Jun 26 19:12:41 2009 -0700 83.3 @@ -0,0 +1,38 @@ 83.4 +/* 83.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 83.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 83.7 + * 83.8 + * This code is free software; you can redistribute it and/or modify it 83.9 + * under the terms of the GNU General Public License version 2 only, as 83.10 + * published by the Free Software Foundation. 83.11 + * 83.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 83.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 83.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 83.15 + * version 2 for more details (a copy is included in the LICENSE file that 83.16 + * accompanied this code). 83.17 + * 83.18 + * You should have received a copy of the GNU General Public License version 83.19 + * 2 along with this work; if not, write to the Free Software Foundation, 83.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 83.21 + * 83.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 83.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 83.24 + * have any questions. 83.25 + */ 83.26 + 83.27 +/* 83.28 + * @test 83.29 + * @bug 6843077 83.30 + * @summary check for invalid annotatins given the target 83.31 + * @author Mahmood Ali 83.32 + * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java 83.33 + */ 83.34 + 83.35 +class InvalidLocation { 83.36 + void test() @A { 83.37 + } 83.38 +} 83.39 + 83.40 +@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) 83.41 +@interface A { }
84.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 84.2 +++ b/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.out Fri Jun 26 19:12:41 2009 -0700 84.3 @@ -0,0 +1,2 @@ 84.4 +InvalidLocation.java:33:15: compiler.err.annotation.type.not.applicable 84.5 +1 error
85.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 85.2 +++ b/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 85.3 @@ -0,0 +1,35 @@ 85.4 +/* 85.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 85.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 85.7 + * 85.8 + * This code is free software; you can redistribute it and/or modify it 85.9 + * under the terms of the GNU General Public License version 2 only, as 85.10 + * published by the Free Software Foundation. 85.11 + * 85.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 85.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 85.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 85.15 + * version 2 for more details (a copy is included in the LICENSE file that 85.16 + * accompanied this code). 85.17 + * 85.18 + * You should have received a copy of the GNU General Public License version 85.19 + * 2 along with this work; if not, write to the Free Software Foundation, 85.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 85.21 + * 85.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 85.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 85.24 + * have any questions. 85.25 + */ 85.26 + 85.27 +/* 85.28 + * @test 85.29 + * @bug 6843077 85.30 + * @summary check for missing annotation value 85.31 + * @author Mahmood Ali 85.32 + * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java 85.33 + */ 85.34 +class MissingAnnotationValue { 85.35 + void test() @A { } 85.36 +} 85.37 + 85.38 +@interface A { int field(); }
86.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 86.2 +++ b/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 86.3 @@ -0,0 +1,2 @@ 86.4 +MissingAnnotationValue.java:32:15: compiler.err.annotation.missing.default.value: A, field 86.5 +1 error
87.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 87.2 +++ b/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 87.3 @@ -0,0 +1,37 @@ 87.4 +/* 87.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 87.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 87.7 + * 87.8 + * This code is free software; you can redistribute it and/or modify it 87.9 + * under the terms of the GNU General Public License version 2 only, as 87.10 + * published by the Free Software Foundation. 87.11 + * 87.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 87.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 87.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 87.15 + * version 2 for more details (a copy is included in the LICENSE file that 87.16 + * accompanied this code). 87.17 + * 87.18 + * You should have received a copy of the GNU General Public License version 87.19 + * 2 along with this work; if not, write to the Free Software Foundation, 87.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 87.21 + * 87.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 87.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 87.24 + * have any questions. 87.25 + */ 87.26 + 87.27 +/* 87.28 + * @test 87.29 + * @bug 6843077 87.30 + * @summary check for Duplicate annotation value 87.31 + * @author Mahmood Ali 87.32 + * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java 87.33 + */ 87.34 +class DuplicateAnnotationValue { 87.35 + void test() { 87.36 + new @A String(); 87.37 + } 87.38 +} 87.39 + 87.40 +@interface A { int field(); }
88.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 88.2 +++ b/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 88.3 @@ -0,0 +1,2 @@ 88.4 +DuplicateAnnotationValue.java:33:9: compiler.err.annotation.missing.default.value: A, field 88.5 +1 error
89.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 89.2 +++ b/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java Fri Jun 26 19:12:41 2009 -0700 89.3 @@ -0,0 +1,38 @@ 89.4 +/* 89.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 89.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 89.7 + * 89.8 + * This code is free software; you can redistribute it and/or modify it 89.9 + * under the terms of the GNU General Public License version 2 only, as 89.10 + * published by the Free Software Foundation. 89.11 + * 89.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 89.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 89.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 89.15 + * version 2 for more details (a copy is included in the LICENSE file that 89.16 + * accompanied this code). 89.17 + * 89.18 + * You should have received a copy of the GNU General Public License version 89.19 + * 2 along with this work; if not, write to the Free Software Foundation, 89.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 89.21 + * 89.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 89.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 89.24 + * have any questions. 89.25 + */ 89.26 + 89.27 +/* 89.28 + * @test 89.29 + * @bug 6843077 89.30 + * @summary check for duplicate annotations 89.31 + * @author Mahmood Ali 89.32 + * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java 89.33 + */ 89.34 + 89.35 +class DuplicateTypeAnnotation { 89.36 + void test() { 89.37 + new @A @A String(); 89.38 + } 89.39 +} 89.40 + 89.41 +@interface A { }
90.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 90.2 +++ b/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out Fri Jun 26 19:12:41 2009 -0700 90.3 @@ -0,0 +1,2 @@ 90.4 +DuplicateTypeAnnotation.java:34:12: compiler.err.duplicate.annotation 90.5 +1 error
91.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 91.2 +++ b/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.java Fri Jun 26 19:12:41 2009 -0700 91.3 @@ -0,0 +1,39 @@ 91.4 +/* 91.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 91.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 91.7 + * 91.8 + * This code is free software; you can redistribute it and/or modify it 91.9 + * under the terms of the GNU General Public License version 2 only, as 91.10 + * published by the Free Software Foundation. 91.11 + * 91.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 91.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 91.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 91.15 + * version 2 for more details (a copy is included in the LICENSE file that 91.16 + * accompanied this code). 91.17 + * 91.18 + * You should have received a copy of the GNU General Public License version 91.19 + * 2 along with this work; if not, write to the Free Software Foundation, 91.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 91.21 + * 91.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 91.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 91.24 + * have any questions. 91.25 + */ 91.26 + 91.27 +/* 91.28 + * @test 91.29 + * @bug 6843077 91.30 + * @summary check for invalid annotatins given the target 91.31 + * @author Mahmood Ali 91.32 + * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java 91.33 + */ 91.34 + 91.35 +class InvalidLocation { 91.36 + void test() { 91.37 + new @A String(); 91.38 + } 91.39 +} 91.40 + 91.41 +@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) 91.42 +@interface A { }
92.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 92.2 +++ b/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.out Fri Jun 26 19:12:41 2009 -0700 92.3 @@ -0,0 +1,2 @@ 92.4 +InvalidLocation.java:34:9: compiler.err.annotation.type.not.applicable 92.5 +1 error
93.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 93.2 +++ b/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 93.3 @@ -0,0 +1,37 @@ 93.4 +/* 93.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 93.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 93.7 + * 93.8 + * This code is free software; you can redistribute it and/or modify it 93.9 + * under the terms of the GNU General Public License version 2 only, as 93.10 + * published by the Free Software Foundation. 93.11 + * 93.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 93.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 93.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 93.15 + * version 2 for more details (a copy is included in the LICENSE file that 93.16 + * accompanied this code). 93.17 + * 93.18 + * You should have received a copy of the GNU General Public License version 93.19 + * 2 along with this work; if not, write to the Free Software Foundation, 93.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 93.21 + * 93.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 93.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 93.24 + * have any questions. 93.25 + */ 93.26 + 93.27 +/* 93.28 + * @test 93.29 + * @bug 6843077 93.30 + * @summary check for missing annotation value 93.31 + * @author Mahmood Ali 93.32 + * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java 93.33 + */ 93.34 +class MissingAnnotationValue { 93.35 + void test() { 93.36 + new @A String(); 93.37 + } 93.38 +} 93.39 + 93.40 +@interface A { int field(); }
94.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 94.2 +++ b/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 94.3 @@ -0,0 +1,2 @@ 94.4 +MissingAnnotationValue.java:33:9: compiler.err.annotation.missing.default.value: A, field 94.5 +1 error
95.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 95.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 95.3 @@ -0,0 +1,35 @@ 95.4 +/* 95.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 95.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 95.7 + * 95.8 + * This code is free software; you can redistribute it and/or modify it 95.9 + * under the terms of the GNU General Public License version 2 only, as 95.10 + * published by the Free Software Foundation. 95.11 + * 95.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 95.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 95.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 95.15 + * version 2 for more details (a copy is included in the LICENSE file that 95.16 + * accompanied this code). 95.17 + * 95.18 + * You should have received a copy of the GNU General Public License version 95.19 + * 2 along with this work; if not, write to the Free Software Foundation, 95.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 95.21 + * 95.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 95.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 95.24 + * have any questions. 95.25 + */ 95.26 + 95.27 +/* 95.28 + * @test 95.29 + * @bug 6843077 95.30 + * @summary check for duplicate annotation values for type parameter 95.31 + * @author Mahmood Ali 95.32 + * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java 95.33 + */ 95.34 +class DuplicateAnnotationValue<K> { 95.35 + DuplicateAnnotationValue<@A(value = 2, value = 1) String> l; 95.36 +} 95.37 + 95.38 +@interface A { int value(); }
96.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 96.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 96.3 @@ -0,0 +1,2 @@ 96.4 +DuplicateAnnotationValue.java:32:50: compiler.err.duplicate.annotation.member.value: value, A 96.5 +1 error
97.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 97.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java Fri Jun 26 19:12:41 2009 -0700 97.3 @@ -0,0 +1,36 @@ 97.4 +/* 97.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 97.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 97.7 + * 97.8 + * This code is free software; you can redistribute it and/or modify it 97.9 + * under the terms of the GNU General Public License version 2 only, as 97.10 + * published by the Free Software Foundation. 97.11 + * 97.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 97.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 97.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 97.15 + * version 2 for more details (a copy is included in the LICENSE file that 97.16 + * accompanied this code). 97.17 + * 97.18 + * You should have received a copy of the GNU General Public License version 97.19 + * 2 along with this work; if not, write to the Free Software Foundation, 97.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 97.21 + * 97.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 97.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 97.24 + * have any questions. 97.25 + */ 97.26 + 97.27 +/* 97.28 + * @test 97.29 + * @bug 6843077 97.30 + * @summary check for duplicate annotations 97.31 + * @author Mahmood Ali 97.32 + * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java 97.33 + */ 97.34 + 97.35 +class DuplicateTypeAnno<K> { 97.36 + DuplicateTypeAnno<@A @A String> l; 97.37 +} 97.38 + 97.39 +@interface A { }
98.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 98.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out Fri Jun 26 19:12:41 2009 -0700 98.3 @@ -0,0 +1,2 @@ 98.4 +DuplicateTypeAnnotation.java:33:24: compiler.err.duplicate.annotation 98.5 +1 error
99.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 99.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.java Fri Jun 26 19:12:41 2009 -0700 99.3 @@ -0,0 +1,37 @@ 99.4 +/* 99.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 99.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 99.7 + * 99.8 + * This code is free software; you can redistribute it and/or modify it 99.9 + * under the terms of the GNU General Public License version 2 only, as 99.10 + * published by the Free Software Foundation. 99.11 + * 99.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 99.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 99.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 99.15 + * version 2 for more details (a copy is included in the LICENSE file that 99.16 + * accompanied this code). 99.17 + * 99.18 + * You should have received a copy of the GNU General Public License version 99.19 + * 2 along with this work; if not, write to the Free Software Foundation, 99.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 99.21 + * 99.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 99.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 99.24 + * have any questions. 99.25 + */ 99.26 + 99.27 +/* 99.28 + * @test 99.29 + * @bug 6843077 99.30 + * @summary check for invalid annotatins given the target 99.31 + * @author Mahmood Ali 99.32 + * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java 99.33 + */ 99.34 + 99.35 +class InvalidLocation<K> { 99.36 + InvalidLocation<@A String> l; 99.37 +} 99.38 + 99.39 +@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) 99.40 +@interface A { }
100.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 100.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.out Fri Jun 26 19:12:41 2009 -0700 100.3 @@ -0,0 +1,2 @@ 100.4 +InvalidLocation.java:33:19: compiler.err.annotation.type.not.applicable 100.5 +1 error
101.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 101.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 101.3 @@ -0,0 +1,35 @@ 101.4 +/* 101.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 101.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 101.7 + * 101.8 + * This code is free software; you can redistribute it and/or modify it 101.9 + * under the terms of the GNU General Public License version 2 only, as 101.10 + * published by the Free Software Foundation. 101.11 + * 101.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 101.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 101.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 101.15 + * version 2 for more details (a copy is included in the LICENSE file that 101.16 + * accompanied this code). 101.17 + * 101.18 + * You should have received a copy of the GNU General Public License version 101.19 + * 2 along with this work; if not, write to the Free Software Foundation, 101.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 101.21 + * 101.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 101.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 101.24 + * have any questions. 101.25 + */ 101.26 + 101.27 +/* 101.28 + * @test 101.29 + * @bug 6843077 101.30 + * @summary check for missing annotation value 101.31 + * @author Mahmood Ali 101.32 + * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java 101.33 + */ 101.34 +class MissingAnnotationValue<K> { 101.35 + MissingAnnotationValue<@A String> l; 101.36 +} 101.37 + 101.38 +@interface A { int field(); }
102.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 102.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 102.3 @@ -0,0 +1,2 @@ 102.4 +MissingAnnotationValue.java:32:26: compiler.err.annotation.missing.default.value: A, field 102.5 +1 error
103.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 103.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 103.3 @@ -0,0 +1,34 @@ 103.4 +/* 103.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 103.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 103.7 + * 103.8 + * This code is free software; you can redistribute it and/or modify it 103.9 + * under the terms of the GNU General Public License version 2 only, as 103.10 + * published by the Free Software Foundation. 103.11 + * 103.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 103.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 103.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 103.15 + * version 2 for more details (a copy is included in the LICENSE file that 103.16 + * accompanied this code). 103.17 + * 103.18 + * You should have received a copy of the GNU General Public License version 103.19 + * 2 along with this work; if not, write to the Free Software Foundation, 103.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 103.21 + * 103.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 103.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 103.24 + * have any questions. 103.25 + */ 103.26 + 103.27 +/* 103.28 + * @test 103.29 + * @bug 6843077 103.30 + * @summary check for duplicate annotation values for type parameter 103.31 + * @author Mahmood Ali 103.32 + * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java 103.33 + */ 103.34 +class DuplicateAnnotationValue<@A(value = 2, value = 1) K> { 103.35 +} 103.36 + 103.37 +@interface A { int value(); }
104.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 104.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 104.3 @@ -0,0 +1,2 @@ 104.4 +DuplicateAnnotationValue.java:31:54: compiler.err.duplicate.annotation.member.value: value, A 104.5 +1 error
105.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 105.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java Fri Jun 26 19:12:41 2009 -0700 105.3 @@ -0,0 +1,35 @@ 105.4 +/* 105.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 105.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 105.7 + * 105.8 + * This code is free software; you can redistribute it and/or modify it 105.9 + * under the terms of the GNU General Public License version 2 only, as 105.10 + * published by the Free Software Foundation. 105.11 + * 105.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 105.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 105.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 105.15 + * version 2 for more details (a copy is included in the LICENSE file that 105.16 + * accompanied this code). 105.17 + * 105.18 + * You should have received a copy of the GNU General Public License version 105.19 + * 2 along with this work; if not, write to the Free Software Foundation, 105.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 105.21 + * 105.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 105.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 105.24 + * have any questions. 105.25 + */ 105.26 + 105.27 +/* 105.28 + * @test 105.29 + * @bug 6843077 105.30 + * @summary check for duplicate annotations 105.31 + * @author Mahmood Ali 105.32 + * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java 105.33 + */ 105.34 + 105.35 +class DuplicateTypeAnno<@A @A K> { 105.36 +} 105.37 + 105.38 +@interface A { }
106.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 106.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out Fri Jun 26 19:12:41 2009 -0700 106.3 @@ -0,0 +1,2 @@ 106.4 +DuplicateTypeAnnotation.java:32:28: compiler.err.duplicate.annotation 106.5 +1 error
107.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 107.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.java Fri Jun 26 19:12:41 2009 -0700 107.3 @@ -0,0 +1,36 @@ 107.4 +/* 107.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 107.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 107.7 + * 107.8 + * This code is free software; you can redistribute it and/or modify it 107.9 + * under the terms of the GNU General Public License version 2 only, as 107.10 + * published by the Free Software Foundation. 107.11 + * 107.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 107.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 107.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 107.15 + * version 2 for more details (a copy is included in the LICENSE file that 107.16 + * accompanied this code). 107.17 + * 107.18 + * You should have received a copy of the GNU General Public License version 107.19 + * 2 along with this work; if not, write to the Free Software Foundation, 107.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 107.21 + * 107.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 107.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 107.24 + * have any questions. 107.25 + */ 107.26 + 107.27 +/* 107.28 + * @test 107.29 + * @bug 6843077 107.30 + * @summary check for invalid annotatins given the target 107.31 + * @author Mahmood Ali 107.32 + * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java 107.33 + */ 107.34 + 107.35 +class InvalidLocation<@A K> { 107.36 +} 107.37 + 107.38 +@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) 107.39 +@interface A { }
108.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 108.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.out Fri Jun 26 19:12:41 2009 -0700 108.3 @@ -0,0 +1,2 @@ 108.4 +InvalidLocation.java:32:23: compiler.err.annotation.type.not.applicable 108.5 +1 error
109.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 109.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 109.3 @@ -0,0 +1,34 @@ 109.4 +/* 109.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 109.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 109.7 + * 109.8 + * This code is free software; you can redistribute it and/or modify it 109.9 + * under the terms of the GNU General Public License version 2 only, as 109.10 + * published by the Free Software Foundation. 109.11 + * 109.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 109.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 109.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 109.15 + * version 2 for more details (a copy is included in the LICENSE file that 109.16 + * accompanied this code). 109.17 + * 109.18 + * You should have received a copy of the GNU General Public License version 109.19 + * 2 along with this work; if not, write to the Free Software Foundation, 109.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 109.21 + * 109.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 109.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 109.24 + * have any questions. 109.25 + */ 109.26 + 109.27 +/* 109.28 + * @test 109.29 + * @bug 6843077 109.30 + * @summary check for missing annotation value 109.31 + * @author Mahmood Ali 109.32 + * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java 109.33 + */ 109.34 +class MissingAnnotationValue<@A K> { 109.35 +} 109.36 + 109.37 +@interface A { int field(); }
110.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 110.2 +++ b/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 110.3 @@ -0,0 +1,2 @@ 110.4 +MissingAnnotationValue.java:31:30: compiler.err.annotation.missing.default.value: A, field 110.5 +1 error
111.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 111.2 +++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 111.3 @@ -0,0 +1,35 @@ 111.4 +/* 111.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 111.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 111.7 + * 111.8 + * This code is free software; you can redistribute it and/or modify it 111.9 + * under the terms of the GNU General Public License version 2 only, as 111.10 + * published by the Free Software Foundation. 111.11 + * 111.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 111.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 111.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 111.15 + * version 2 for more details (a copy is included in the LICENSE file that 111.16 + * accompanied this code). 111.17 + * 111.18 + * You should have received a copy of the GNU General Public License version 111.19 + * 2 along with this work; if not, write to the Free Software Foundation, 111.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 111.21 + * 111.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 111.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 111.24 + * have any questions. 111.25 + */ 111.26 + 111.27 +/* 111.28 + * @test 111.29 + * @bug 6843077 111.30 + * @summary check for duplicate annotation values for type parameter 111.31 + * @author Mahmood Ali 111.32 + * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java 111.33 + */ 111.34 +class DuplicateAnnotationValue<K> { 111.35 + DuplicateAnnotationValue<@A(value = 2, value = 1) ?> l; 111.36 +} 111.37 + 111.38 +@interface A { int value(); }
112.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 112.2 +++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 112.3 @@ -0,0 +1,2 @@ 112.4 +DuplicateAnnotationValue.java:32:50: compiler.err.duplicate.annotation.member.value: value, A 112.5 +1 error
113.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 113.2 +++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java Fri Jun 26 19:12:41 2009 -0700 113.3 @@ -0,0 +1,36 @@ 113.4 +/* 113.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 113.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 113.7 + * 113.8 + * This code is free software; you can redistribute it and/or modify it 113.9 + * under the terms of the GNU General Public License version 2 only, as 113.10 + * published by the Free Software Foundation. 113.11 + * 113.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 113.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 113.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 113.15 + * version 2 for more details (a copy is included in the LICENSE file that 113.16 + * accompanied this code). 113.17 + * 113.18 + * You should have received a copy of the GNU General Public License version 113.19 + * 2 along with this work; if not, write to the Free Software Foundation, 113.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 113.21 + * 113.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 113.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 113.24 + * have any questions. 113.25 + */ 113.26 + 113.27 +/* 113.28 + * @test 113.29 + * @bug 6843077 113.30 + * @summary check for duplicate annotations 113.31 + * @author Mahmood Ali 113.32 + * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java 113.33 + */ 113.34 + 113.35 +class DuplicateTypeAnno<K> { 113.36 + DuplicateTypeAnno<@A @A ?> l; 113.37 +} 113.38 + 113.39 +@interface A { }
114.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 114.2 +++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out Fri Jun 26 19:12:41 2009 -0700 114.3 @@ -0,0 +1,2 @@ 114.4 +DuplicateTypeAnnotation.java:33:24: compiler.err.duplicate.annotation 114.5 +1 error
115.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 115.2 +++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.java Fri Jun 26 19:12:41 2009 -0700 115.3 @@ -0,0 +1,37 @@ 115.4 +/* 115.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 115.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 115.7 + * 115.8 + * This code is free software; you can redistribute it and/or modify it 115.9 + * under the terms of the GNU General Public License version 2 only, as 115.10 + * published by the Free Software Foundation. 115.11 + * 115.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 115.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 115.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 115.15 + * version 2 for more details (a copy is included in the LICENSE file that 115.16 + * accompanied this code). 115.17 + * 115.18 + * You should have received a copy of the GNU General Public License version 115.19 + * 2 along with this work; if not, write to the Free Software Foundation, 115.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 115.21 + * 115.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 115.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 115.24 + * have any questions. 115.25 + */ 115.26 + 115.27 +/* 115.28 + * @test 115.29 + * @bug 6843077 115.30 + * @summary check for invalid annotatins given the target 115.31 + * @author Mahmood Ali 115.32 + * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java 115.33 + */ 115.34 + 115.35 +class InvalidLocation<K> { 115.36 + InvalidLocation<@A ?> l; 115.37 +} 115.38 + 115.39 +@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) 115.40 +@interface A { }
116.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 116.2 +++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.out Fri Jun 26 19:12:41 2009 -0700 116.3 @@ -0,0 +1,2 @@ 116.4 +InvalidLocation.java:33:19: compiler.err.annotation.type.not.applicable 116.5 +1 error
117.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 117.2 +++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java Fri Jun 26 19:12:41 2009 -0700 117.3 @@ -0,0 +1,35 @@ 117.4 +/* 117.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 117.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 117.7 + * 117.8 + * This code is free software; you can redistribute it and/or modify it 117.9 + * under the terms of the GNU General Public License version 2 only, as 117.10 + * published by the Free Software Foundation. 117.11 + * 117.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 117.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 117.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 117.15 + * version 2 for more details (a copy is included in the LICENSE file that 117.16 + * accompanied this code). 117.17 + * 117.18 + * You should have received a copy of the GNU General Public License version 117.19 + * 2 along with this work; if not, write to the Free Software Foundation, 117.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 117.21 + * 117.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 117.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 117.24 + * have any questions. 117.25 + */ 117.26 + 117.27 +/* 117.28 + * @test 117.29 + * @bug 6843077 117.30 + * @summary check for missing annotation value 117.31 + * @author Mahmood Ali 117.32 + * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java 117.33 + */ 117.34 +class MissingAnnotationValue<K> { 117.35 + MissingAnnotationValue<@A ?> l; 117.36 +} 117.37 + 117.38 +@interface A { int field(); }
118.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 118.2 +++ b/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out Fri Jun 26 19:12:41 2009 -0700 118.3 @@ -0,0 +1,2 @@ 118.4 +MissingAnnotationValue.java:32:26: compiler.err.annotation.missing.default.value: A, field 118.5 +1 error
119.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 119.2 +++ b/test/tools/javac/typeAnnotations/failures/target/Constructor.java Fri Jun 26 19:12:41 2009 -0700 119.3 @@ -0,0 +1,40 @@ 119.4 +/* 119.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 119.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 119.7 + * 119.8 + * This code is free software; you can redistribute it and/or modify it 119.9 + * under the terms of the GNU General Public License version 2 only, as 119.10 + * published by the Free Software Foundation. 119.11 + * 119.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 119.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 119.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 119.15 + * version 2 for more details (a copy is included in the LICENSE file that 119.16 + * accompanied this code). 119.17 + * 119.18 + * You should have received a copy of the GNU General Public License version 119.19 + * 2 along with this work; if not, write to the Free Software Foundation, 119.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 119.21 + * 119.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 119.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 119.24 + * have any questions. 119.25 + */ 119.26 + 119.27 +/* 119.28 + * @test 119.29 + * @bug 6843077 119.30 + * @summary test invalid location of TypeUse 119.31 + * @author Mahmood Ali 119.32 + * @compile/fail/ref=Constructor.out -XDrawDiagnostics -source 1.7 Constructor.java 119.33 + */ 119.34 + 119.35 +import java.lang.annotation.Target; 119.36 +import java.lang.annotation.ElementType; 119.37 + 119.38 +class Constructor { 119.39 + @A Constructor() { } 119.40 +} 119.41 + 119.42 +@Target(ElementType.TYPE_USE) 119.43 +@interface A { }
120.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 120.2 +++ b/test/tools/javac/typeAnnotations/failures/target/Constructor.out Fri Jun 26 19:12:41 2009 -0700 120.3 @@ -0,0 +1,2 @@ 120.4 +Constructor.java:36:3: compiler.err.annotation.type.not.applicable 120.5 +1 error
121.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 121.2 +++ b/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.java Fri Jun 26 19:12:41 2009 -0700 121.3 @@ -0,0 +1,35 @@ 121.4 +/* 121.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 121.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 121.7 + * 121.8 + * This code is free software; you can redistribute it and/or modify it 121.9 + * under the terms of the GNU General Public License version 2 only, as 121.10 + * published by the Free Software Foundation. 121.11 + * 121.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 121.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 121.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 121.15 + * version 2 for more details (a copy is included in the LICENSE file that 121.16 + * accompanied this code). 121.17 + * 121.18 + * You should have received a copy of the GNU General Public License version 121.19 + * 2 along with this work; if not, write to the Free Software Foundation, 121.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 121.21 + * 121.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 121.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 121.24 + * have any questions. 121.25 + */ 121.26 + 121.27 +/* 121.28 + * @test 121.29 + * @bug 6843077 121.30 + * @summary test incomplete array declaration 121.31 + * @author Mahmood Ali 121.32 + * @compile/fail/ref=IncompleteArray.out -XDrawDiagnostics -source 1.7 IncompleteArray.java 121.33 + */ 121.34 +class IncompleteArray { 121.35 + int @A [] @A var; 121.36 +} 121.37 + 121.38 +@interface A { }
122.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 122.2 +++ b/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.out Fri Jun 26 19:12:41 2009 -0700 122.3 @@ -0,0 +1,2 @@ 122.4 +IncompleteArray.java:32:13: compiler.err.illegal.start.of.type 122.5 +1 error
123.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 123.2 +++ b/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.java Fri Jun 26 19:12:41 2009 -0700 123.3 @@ -0,0 +1,40 @@ 123.4 +/* 123.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 123.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 123.7 + * 123.8 + * This code is free software; you can redistribute it and/or modify it 123.9 + * under the terms of the GNU General Public License version 2 only, as 123.10 + * published by the Free Software Foundation. 123.11 + * 123.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 123.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 123.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 123.15 + * version 2 for more details (a copy is included in the LICENSE file that 123.16 + * accompanied this code). 123.17 + * 123.18 + * You should have received a copy of the GNU General Public License version 123.19 + * 2 along with this work; if not, write to the Free Software Foundation, 123.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 123.21 + * 123.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 123.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 123.24 + * have any questions. 123.25 + */ 123.26 + 123.27 +/* 123.28 + * @test 123.29 + * @bug 6843077 123.30 + * @summary test invalid location of TypeUse 123.31 + * @author Mahmood Ali 123.32 + * @compile/fail/ref=NotTypeParameter.out -XDrawDiagnostics -source 1.7 NotTypeParameter.java 123.33 + */ 123.34 + 123.35 +import java.lang.annotation.Target; 123.36 +import java.lang.annotation.ElementType; 123.37 + 123.38 +class VoidMethod<@A K> { 123.39 + @A void test() { } 123.40 +} 123.41 + 123.42 +@Target(ElementType.TYPE_USE) 123.43 +@interface A { }
124.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 124.2 +++ b/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.out Fri Jun 26 19:12:41 2009 -0700 124.3 @@ -0,0 +1,3 @@ 124.4 +NotTypeParameter.java:36:3: compiler.err.annotation.type.not.applicable 124.5 +NotTypeParameter.java:35:18: compiler.err.annotation.type.not.applicable 124.6 +2 errors
125.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 125.2 +++ b/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.java Fri Jun 26 19:12:41 2009 -0700 125.3 @@ -0,0 +1,40 @@ 125.4 +/* 125.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 125.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 125.7 + * 125.8 + * This code is free software; you can redistribute it and/or modify it 125.9 + * under the terms of the GNU General Public License version 2 only, as 125.10 + * published by the Free Software Foundation. 125.11 + * 125.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 125.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 125.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 125.15 + * version 2 for more details (a copy is included in the LICENSE file that 125.16 + * accompanied this code). 125.17 + * 125.18 + * You should have received a copy of the GNU General Public License version 125.19 + * 2 along with this work; if not, write to the Free Software Foundation, 125.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 125.21 + * 125.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 125.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 125.24 + * have any questions. 125.25 + */ 125.26 + 125.27 +/* 125.28 + * @test 125.29 + * @bug 6843077 125.30 + * @summary test invalid location of TypeUse 125.31 + * @author Mahmood Ali 125.32 + * @compile/fail/ref=NotTypeUse.out -XDrawDiagnostics -source 1.7 NotTypeUse.java 125.33 + */ 125.34 + 125.35 +import java.lang.annotation.Target; 125.36 +import java.lang.annotation.ElementType; 125.37 + 125.38 +class VoidMethod { 125.39 + @A void test() { } 125.40 +} 125.41 + 125.42 +@Target(ElementType.TYPE) 125.43 +@interface A { }
126.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 126.2 +++ b/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.out Fri Jun 26 19:12:41 2009 -0700 126.3 @@ -0,0 +1,2 @@ 126.4 +NotTypeUse.java:36:3: compiler.err.annotation.type.not.applicable 126.5 +1 error
127.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 127.2 +++ b/test/tools/javac/typeAnnotations/failures/target/VoidMethod.java Fri Jun 26 19:12:41 2009 -0700 127.3 @@ -0,0 +1,40 @@ 127.4 +/* 127.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 127.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 127.7 + * 127.8 + * This code is free software; you can redistribute it and/or modify it 127.9 + * under the terms of the GNU General Public License version 2 only, as 127.10 + * published by the Free Software Foundation. 127.11 + * 127.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 127.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 127.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 127.15 + * version 2 for more details (a copy is included in the LICENSE file that 127.16 + * accompanied this code). 127.17 + * 127.18 + * You should have received a copy of the GNU General Public License version 127.19 + * 2 along with this work; if not, write to the Free Software Foundation, 127.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 127.21 + * 127.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 127.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 127.24 + * have any questions. 127.25 + */ 127.26 + 127.27 +/* 127.28 + * @test 127.29 + * @bug 6843077 127.30 + * @summary test invalid location of TypeUse 127.31 + * @author Mahmood Ali 127.32 + * @compile/fail/ref=VoidMethod.out -XDrawDiagnostics -source 1.7 VoidMethod.java 127.33 + */ 127.34 + 127.35 +import java.lang.annotation.Target; 127.36 +import java.lang.annotation.ElementType; 127.37 + 127.38 +class VoidMethod { 127.39 + @A void test() { } 127.40 +} 127.41 + 127.42 +@Target(ElementType.TYPE_USE) 127.43 +@interface A { }
128.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 128.2 +++ b/test/tools/javac/typeAnnotations/failures/target/VoidMethod.out Fri Jun 26 19:12:41 2009 -0700 128.3 @@ -0,0 +1,2 @@ 128.4 +VoidMethod.java:36:3: compiler.err.annotation.type.not.applicable 128.5 +1 error
129.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 129.2 +++ b/test/tools/javac/typeAnnotations/newlocations/BasicTest.java Fri Jun 26 19:12:41 2009 -0700 129.3 @@ -0,0 +1,75 @@ 129.4 + 129.5 +/* 129.6 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 129.7 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 129.8 + * 129.9 + * This code is free software; you can redistribute it and/or modify it 129.10 + * under the terms of the GNU General Public License version 2 only, as 129.11 + * published by the Free Software Foundation. 129.12 + * 129.13 + * This code is distributed in the hope that it will be useful, but WITHOUT 129.14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 129.15 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 129.16 + * version 2 for more details (a copy is included in the LICENSE file that 129.17 + * accompanied this code). 129.18 + * 129.19 + * You should have received a copy of the GNU General Public License version 129.20 + * 2 along with this work; if not, write to the Free Software Foundation, 129.21 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 129.22 + * 129.23 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 129.24 + * CA 95054 USA or visit www.sun.com if you need additional information or 129.25 + * have any questions. 129.26 + */ 129.27 + 129.28 +/* 129.29 + * @test 129.30 + * @bug 6843077 129.31 + * @summary random tests for new locations 129.32 + * @author Matt Papi 129.33 + * @compile -source 1.7 BasicTest.java 129.34 + */ 129.35 + 129.36 +import java.util.*; 129.37 +import java.io.*; 129.38 + 129.39 +@interface A {} 129.40 +@interface B {} 129.41 +@interface C {} 129.42 +@interface D {} 129.43 + 129.44 +/** 129.45 + * Tests basic JSR 308 parser functionality. We don't really care about what 129.46 + * the parse tree looks like, just that these annotations can be parsed. 129.47 + */ 129.48 +class BasicTest<T extends @A Object> extends @B LinkedList<T> implements @C List<T> { 129.49 + 129.50 + void test() { 129.51 + 129.52 + // Handle annotated class literals/cast types 129.53 + Class<?> c = @A String.class; 129.54 + Object o = (@A Object) "foo"; 129.55 + 129.56 + // Handle annotated "new" expressions (except arrays; see ArrayTest) 129.57 + String s = new @A String("bar"); 129.58 + 129.59 + boolean b = o instanceof @A Object; 129.60 + 129.61 + 129.62 + @A Map<@B List<@C String>, @D String> map = 129.63 + new @A HashMap<@B List<@C String>, @D String>(); 129.64 + 129.65 + Class<? extends @A String> c2 = @A String.class; 129.66 + } 129.67 + 129.68 + // Handle receiver annotations 129.69 + // Handle annotations on a qualified identifier list 129.70 + void test2() @C @D throws @A IllegalArgumentException, @B IOException { 129.71 + 129.72 + } 129.73 + 129.74 + // Handle annotations on a varargs element type 129.75 + void test3(Object @A... objs) { 129.76 + 129.77 + } 129.78 +}
130.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 130.2 +++ b/test/tools/javac/typeAnnotations/newlocations/ClassExtends.java Fri Jun 26 19:12:41 2009 -0700 130.3 @@ -0,0 +1,40 @@ 130.4 +/* 130.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 130.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 130.7 + * 130.8 + * This code is free software; you can redistribute it and/or modify it 130.9 + * under the terms of the GNU General Public License version 2 only, as 130.10 + * published by the Free Software Foundation. 130.11 + * 130.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 130.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 130.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 130.15 + * version 2 for more details (a copy is included in the LICENSE file that 130.16 + * accompanied this code). 130.17 + * 130.18 + * You should have received a copy of the GNU General Public License version 130.19 + * 2 along with this work; if not, write to the Free Software Foundation, 130.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 130.21 + * 130.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 130.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 130.24 + * have any questions. 130.25 + */ 130.26 + 130.27 +/* 130.28 + * @test 130.29 + * @bug 6843077 130.30 + * @summary new type annotation location: class extends/implements 130.31 + * @author Mahmood Ali 130.32 + * @compile -source 1.7 ClassExtends.java 130.33 + */ 130.34 +abstract class MyClass extends @A ParameterizedClass<@B String> 130.35 + implements @B CharSequence, @A ParameterizedInterface<@B String> { } 130.36 + 130.37 +interface MyInterface extends @A ParameterizedInterface<@A String>, 130.38 + @B CharSequence { } 130.39 + 130.40 +class ParameterizedClass<K> {} 130.41 +interface ParameterizedInterface<K> {} 130.42 +@interface A {} 130.43 +@interface B {}
131.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 131.2 +++ b/test/tools/javac/typeAnnotations/newlocations/ClassLiterals.java Fri Jun 26 19:12:41 2009 -0700 131.3 @@ -0,0 +1,48 @@ 131.4 +/* 131.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 131.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 131.7 + * 131.8 + * This code is free software; you can redistribute it and/or modify it 131.9 + * under the terms of the GNU General Public License version 2 only, as 131.10 + * published by the Free Software Foundation. 131.11 + * 131.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 131.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 131.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 131.15 + * version 2 for more details (a copy is included in the LICENSE file that 131.16 + * accompanied this code). 131.17 + * 131.18 + * You should have received a copy of the GNU General Public License version 131.19 + * 2 along with this work; if not, write to the Free Software Foundation, 131.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 131.21 + * 131.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 131.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 131.24 + * have any questions. 131.25 + */ 131.26 + 131.27 +/* 131.28 + * @test 131.29 + * @bug 6843077 131.30 + * @summary new type annotation location: class literals 131.31 + * @author Mahmood Ali 131.32 + * @compile -source 1.7 ClassLiterals.java 131.33 + */ 131.34 + 131.35 +class ClassLiterals { 131.36 + 131.37 + public static void main(String[] args) { 131.38 + if (String.class != @A String.class) throw new Error(); 131.39 + if (@A int.class != int.class) throw new Error(); 131.40 + if (@A int.class != Integer.TYPE) throw new Error(); 131.41 + if (@A int @B(0) [].class != int[].class) throw new Error(); 131.42 + 131.43 + if (String[].class != @A String[].class) throw new Error(); 131.44 + if (String[].class != String @A [].class) throw new Error(); 131.45 + if (@A int[].class != int[].class) throw new Error(); 131.46 + if (@A int @B(0) [].class != int[].class) throw new Error(); 131.47 + } 131.48 +} 131.49 + 131.50 +@interface A {} 131.51 +@interface B { int value(); }
132.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 132.2 +++ b/test/tools/javac/typeAnnotations/newlocations/ClassParameters.java Fri Jun 26 19:12:41 2009 -0700 132.3 @@ -0,0 +1,56 @@ 132.4 +/* 132.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 132.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 132.7 + * 132.8 + * This code is free software; you can redistribute it and/or modify it 132.9 + * under the terms of the GNU General Public License version 2 only, as 132.10 + * published by the Free Software Foundation. 132.11 + * 132.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 132.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 132.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 132.15 + * version 2 for more details (a copy is included in the LICENSE file that 132.16 + * accompanied this code). 132.17 + * 132.18 + * You should have received a copy of the GNU General Public License version 132.19 + * 2 along with this work; if not, write to the Free Software Foundation, 132.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 132.21 + * 132.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 132.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 132.24 + * have any questions. 132.25 + */ 132.26 + 132.27 +/* 132.28 + * @test 132.29 + * @bug 6843077 132.30 + * @summary new type annotation location: class type parameter bounds 132.31 + * @author Mahmood Ali 132.32 + * @compile -source 1.7 ClassParameters.java 132.33 + */ 132.34 +class Unannotated<K> { } 132.35 + 132.36 +class ExtendsBound<K extends @A String> { } 132.37 +class ExtendsGeneric<K extends @A Unannotated<@B String>> { } 132.38 +class TwoBounds<K extends @A String, V extends @B String> { } 132.39 + 132.40 +class Complex1<K extends @A String&Runnable> { } 132.41 +class Complex2<K extends String & @B Runnable> { } 132.42 +class ComplexBoth<K extends @A String & @A Runnable> { } 132.43 + 132.44 +class Outer { 132.45 + void inner() { 132.46 + class Unannotated<K> { } 132.47 + 132.48 + class ExtendsBound<K extends @A String> { } 132.49 + class ExtendsGeneric<K extends @A Unannotated<@B String>> { } 132.50 + class TwoBounds<K extends @A String, V extends @B String> { } 132.51 + 132.52 + class Complex1<K extends @A String&Runnable> { } 132.53 + class Complex2<K extends String & @B Runnable> { } 132.54 + class ComplexBoth<K extends @A String & @A Runnable> { } 132.55 + } 132.56 +} 132.57 + 132.58 +@interface A { } 132.59 +@interface B { }
133.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 133.2 +++ b/test/tools/javac/typeAnnotations/newlocations/ConstructorTypeArgs.java Fri Jun 26 19:12:41 2009 -0700 133.3 @@ -0,0 +1,55 @@ 133.4 +/* 133.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 133.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 133.7 + * 133.8 + * This code is free software; you can redistribute it and/or modify it 133.9 + * under the terms of the GNU General Public License version 2 only, as 133.10 + * published by the Free Software Foundation. 133.11 + * 133.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 133.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 133.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 133.15 + * version 2 for more details (a copy is included in the LICENSE file that 133.16 + * accompanied this code). 133.17 + * 133.18 + * You should have received a copy of the GNU General Public License version 133.19 + * 2 along with this work; if not, write to the Free Software Foundation, 133.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 133.21 + * 133.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 133.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 133.24 + * have any questions. 133.25 + */ 133.26 + 133.27 +/* 133.28 + * @test 133.29 + * @bug 6843077 133.30 + * @summary new type annotation location: constructor type args 133.31 + * @author Mahmood Ali 133.32 + * @compile -source 1.7 ConstructorTypeArgs.java 133.33 + */ 133.34 + 133.35 +class ConstructorTypeArgs { 133.36 + void oneArg() { 133.37 + new @A MyList<@A String>(); 133.38 + new MyList<@A MyList<@B(0) String>>(); 133.39 + } 133.40 + 133.41 + void twoArg() { 133.42 + new MyMap<String, String>(); 133.43 + new MyMap<@A String, @B(0) MyList<@A String>>(); 133.44 + } 133.45 + 133.46 + void withArraysIn() { 133.47 + new MyList<String[]>(); 133.48 + new MyList<@A String @B(0) [] @A []>(); 133.49 + 133.50 + new MyMap<@A String[], @B(0) MyList<@A String> @A []>(); 133.51 + } 133.52 +} 133.53 + 133.54 +class MyList<E> { } 133.55 +class MyMap<K, V> { } 133.56 + 133.57 +@interface A { } 133.58 +@interface B { int value(); }
134.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 134.2 +++ b/test/tools/javac/typeAnnotations/newlocations/Expressions.java Fri Jun 26 19:12:41 2009 -0700 134.3 @@ -0,0 +1,75 @@ 134.4 +/* 134.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 134.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 134.7 + * 134.8 + * This code is free software; you can redistribute it and/or modify it 134.9 + * under the terms of the GNU General Public License version 2 only, as 134.10 + * published by the Free Software Foundation. 134.11 + * 134.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 134.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 134.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 134.15 + * version 2 for more details (a copy is included in the LICENSE file that 134.16 + * accompanied this code). 134.17 + * 134.18 + * You should have received a copy of the GNU General Public License version 134.19 + * 2 along with this work; if not, write to the Free Software Foundation, 134.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 134.21 + * 134.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 134.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 134.24 + * have any questions. 134.25 + */ 134.26 + 134.27 +/* 134.28 + * @test 134.29 + * @bug 6843077 134.30 + * @summary new type annotation location: expressions 134.31 + * @author Mahmood Ali 134.32 + * @compile -source 1.7 Expressions.java 134.33 + */ 134.34 +class Expressions { 134.35 + void instanceOf() { 134.36 + Object o = null; 134.37 + boolean a = o instanceof @A String; 134.38 + boolean b = o instanceof @B(0) String; 134.39 + } 134.40 + 134.41 + void instanceOfArray() { 134.42 + Object o = null; 134.43 + boolean a1 = o instanceof @A String []; 134.44 + boolean a2 = o instanceof @B(0) String []; 134.45 + 134.46 + boolean b1 = o instanceof String @A []; 134.47 + boolean b2 = o instanceof String @B(0) []; 134.48 + } 134.49 + 134.50 + void objectCreation() { 134.51 + new @A String(); 134.52 + new @B(0) String(); 134.53 + } 134.54 + 134.55 + void objectCreationArray() { 134.56 + Object a1 = new @A String [] [] { }; 134.57 + Object a2 = new @A String [1] []; 134.58 + Object a3 = new @A String [1] [2]; 134.59 + 134.60 + Object b1 = new @A String @B(0) [] [] { }; 134.61 + Object b2 = new @A String @B(0) [1] []; 134.62 + Object b3 = new @A String @B(0) [1] [2]; 134.63 + 134.64 + Object c1 = new @A String [] @B(0) [] { }; 134.65 + Object c2 = new @A String [1] @B(0) []; 134.66 + Object c3 = new @A String [1] @B(0) [2]; 134.67 + 134.68 + Object d1 = new @A String @B(0) [] @B(0) [] { }; 134.69 + Object d2 = new @A String @B(0) [1] @B(0) []; 134.70 + Object d3 = new @A String @B(0) [1] @B(0) [2]; 134.71 + 134.72 + Object rand = new @A String @B(value = 0) [1] @B(value = 0) [2]; 134.73 + 134.74 + } 134.75 +} 134.76 + 134.77 +@interface A { } 134.78 +@interface B { int value(); }
135.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 135.2 +++ b/test/tools/javac/typeAnnotations/newlocations/Fields.java Fri Jun 26 19:12:41 2009 -0700 135.3 @@ -0,0 +1,69 @@ 135.4 +/* 135.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 135.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 135.7 + * 135.8 + * This code is free software; you can redistribute it and/or modify it 135.9 + * under the terms of the GNU General Public License version 2 only, as 135.10 + * published by the Free Software Foundation. 135.11 + * 135.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 135.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 135.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 135.15 + * version 2 for more details (a copy is included in the LICENSE file that 135.16 + * accompanied this code). 135.17 + * 135.18 + * You should have received a copy of the GNU General Public License version 135.19 + * 2 along with this work; if not, write to the Free Software Foundation, 135.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 135.21 + * 135.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 135.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 135.24 + * have any questions. 135.25 + */ 135.26 + 135.27 +/* 135.28 + * @test 135.29 + * @bug 6843077 135.30 + * @summary new type annotation location: field type array/generics 135.31 + * @author Mahmood Ali 135.32 + * @compile -source 1.7 Fields.java 135.33 + */ 135.34 + 135.35 +class DefaultScope { 135.36 + Parameterized<String, String> unannotated; 135.37 + Parameterized<@A String, String> firstTypeArg; 135.38 + Parameterized<String, @A String> secondTypeArg; 135.39 + Parameterized<@A String, @B String> bothTypeArgs; 135.40 + 135.41 + Parameterized<@A Parameterized<@A String, @B String>, @B String> 135.42 + nestedParameterized; 135.43 + 135.44 + @A String [] array1; 135.45 + @A String @B [] array1Deep; 135.46 + @A String [] [] array2; 135.47 + @A String @A [] @B [] array2Deep; 135.48 + String @A [] [] array2First; 135.49 + String [] @B [] array2Second; 135.50 +} 135.51 + 135.52 +class ModifiedScoped { 135.53 + public final Parameterized<String, String> unannotated = null; 135.54 + public final Parameterized<@A String, String> firstTypeArg = null; 135.55 + public final Parameterized<String, @A String> secondTypeArg = null; 135.56 + public final Parameterized<@A String, @B String> bothTypeArgs = null; 135.57 + 135.58 + public final Parameterized<@A Parameterized<@A String, @B String>, @B String> 135.59 + nestedParameterized = null; 135.60 + 135.61 + public final @A String [] array1 = null; 135.62 + public final @A String @B [] array1Deep = null; 135.63 + public final @A String [] [] array2 = null; 135.64 + public final @A String @A [] @B [] array2Deep = null; 135.65 + public final String @A [] [] array2First = null; 135.66 + public final String [] @B [] array2Second = null; 135.67 +} 135.68 + 135.69 +class Parameterized<K, V> { } 135.70 + 135.71 +@interface A { } 135.72 +@interface B { }
136.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 136.2 +++ b/test/tools/javac/typeAnnotations/newlocations/LocalVariables.java Fri Jun 26 19:12:41 2009 -0700 136.3 @@ -0,0 +1,77 @@ 136.4 +/* 136.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 136.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 136.7 + * 136.8 + * This code is free software; you can redistribute it and/or modify it 136.9 + * under the terms of the GNU General Public License version 2 only, as 136.10 + * published by the Free Software Foundation. 136.11 + * 136.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 136.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 136.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 136.15 + * version 2 for more details (a copy is included in the LICENSE file that 136.16 + * accompanied this code). 136.17 + * 136.18 + * You should have received a copy of the GNU General Public License version 136.19 + * 2 along with this work; if not, write to the Free Software Foundation, 136.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 136.21 + * 136.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 136.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 136.24 + * have any questions. 136.25 + */ 136.26 + 136.27 +/* 136.28 + * @test 136.29 + * @bug 6843077 136.30 + * @summary new type annotation location: local variables array/generics 136.31 + * @author Mahmood Ali 136.32 + * @compile -source 1.7 LocalVariables.java 136.33 + */ 136.34 + 136.35 +class DefaultScope { 136.36 + void parameterized() { 136.37 + Parameterized<String, String> unannotated; 136.38 + Parameterized<@A String, String> firstTypeArg; 136.39 + Parameterized<String, @A String> secondTypeArg; 136.40 + Parameterized<@A String, @B String> bothTypeArgs; 136.41 + 136.42 + Parameterized<@A Parameterized<@A String, @B String>, @B String> 136.43 + nestedParameterized; 136.44 + } 136.45 + 136.46 + void arrays() { 136.47 + @A String [] array1; 136.48 + @A String @B [] array1Deep; 136.49 + @A String [] [] array2; 136.50 + @A String @A [] @B [] array2Deep; 136.51 + String @A [] [] array2First; 136.52 + String [] @B [] array2Second; 136.53 + } 136.54 +} 136.55 + 136.56 +class ModifiedVars { 136.57 + void parameterized() { 136.58 + final Parameterized<String, String> unannotated = null; 136.59 + final Parameterized<@A String, String> firstTypeArg = null; 136.60 + final Parameterized<String, @A String> secondTypeArg = null; 136.61 + final Parameterized<@A String, @B String> bothTypeArgs = null; 136.62 + 136.63 + final Parameterized<@A Parameterized<@A String, @B String>, @B String> 136.64 + nestedParameterized = null; 136.65 + } 136.66 + 136.67 + void arrays() { 136.68 + final @A String [] array1 = null; 136.69 + final @A String @B [] array1Deep = null; 136.70 + final @A String [] [] array2 = null; 136.71 + final @A String @A [] @B [] array2Deep = null; 136.72 + final String @A [] [] array2First = null; 136.73 + final String [] @B [] array2Second = null; 136.74 + } 136.75 +} 136.76 + 136.77 +class Parameterized<K, V> { } 136.78 + 136.79 +@interface A { } 136.80 +@interface B { }
137.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 137.2 +++ b/test/tools/javac/typeAnnotations/newlocations/MethodReturnType.java Fri Jun 26 19:12:41 2009 -0700 137.3 @@ -0,0 +1,71 @@ 137.4 +/* 137.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 137.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 137.7 + * 137.8 + * This code is free software; you can redistribute it and/or modify it 137.9 + * under the terms of the GNU General Public License version 2 only, as 137.10 + * published by the Free Software Foundation. 137.11 + * 137.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 137.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 137.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 137.15 + * version 2 for more details (a copy is included in the LICENSE file that 137.16 + * accompanied this code). 137.17 + * 137.18 + * You should have received a copy of the GNU General Public License version 137.19 + * 2 along with this work; if not, write to the Free Software Foundation, 137.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 137.21 + * 137.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 137.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 137.24 + * have any questions. 137.25 + */ 137.26 + 137.27 +/* 137.28 + * @test 137.29 + * @bug 6843077 137.30 + * @summary new type annotation location: method return type array/generics 137.31 + * @author Mahmood Ali 137.32 + * @compile -source 1.7 MethodReturnType.java 137.33 + */ 137.34 + 137.35 +class DefaultScope { 137.36 + Parameterized<String, String> unannotated() { return null; } 137.37 + Parameterized<@A String, String> firstTypeArg() { return null; } 137.38 + Parameterized<String, @A String> secondTypeArg() { return null; } 137.39 + Parameterized<@A String, @B String> bothTypeArgs() { return null; } 137.40 + 137.41 + Parameterized<@A Parameterized<@A String, @B String>, @B String> 137.42 + nestedParameterized() { return null; } 137.43 + 137.44 + public <T> @A String method() { return null; } 137.45 + 137.46 + @A String [] array1() { return null; } 137.47 + @A String @B [] array1Deep() { return null; } 137.48 + @A String [] [] array2() { return null; } 137.49 + @A String @A [] @B [] array2Deep() { return null; } 137.50 + String @A [] [] array2First() { return null; } 137.51 + String [] @B [] array2Second() { return null; } 137.52 +} 137.53 + 137.54 +class ModifiedScoped { 137.55 + public final Parameterized<String, String> unannotated() { return null; } 137.56 + public final Parameterized<@A String, String> firstTypeArg() { return null; } 137.57 + public final Parameterized<String, @A String> secondTypeArg() { return null; } 137.58 + public final Parameterized<@A String, @B String> bothTypeArgs() { return null; } 137.59 + 137.60 + public final Parameterized<@A Parameterized<@A String, @B String>, @B String> 137.61 + nestedParameterized() { return null; } 137.62 + 137.63 + public final @A String [] array1() { return null; } 137.64 + public final @A String @B [] array1Deep() { return null; } 137.65 + public final @A String [] [] array2() { return null; } 137.66 + public final @A String @A [] @B [] array2Deep() { return null; } 137.67 + public final String @A [] [] array2First() { return null; } 137.68 + public final String [] @B [] array2Second() { return null; } 137.69 +} 137.70 + 137.71 +class Parameterized<K, V> { } 137.72 + 137.73 +@interface A { } 137.74 +@interface B { }
138.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 138.2 +++ b/test/tools/javac/typeAnnotations/newlocations/MethodTypeArgs.java Fri Jun 26 19:12:41 2009 -0700 138.3 @@ -0,0 +1,62 @@ 138.4 +/* 138.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 138.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 138.7 + * 138.8 + * This code is free software; you can redistribute it and/or modify it 138.9 + * under the terms of the GNU General Public License version 2 only, as 138.10 + * published by the Free Software Foundation. 138.11 + * 138.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 138.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 138.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 138.15 + * version 2 for more details (a copy is included in the LICENSE file that 138.16 + * accompanied this code). 138.17 + * 138.18 + * You should have received a copy of the GNU General Public License version 138.19 + * 2 along with this work; if not, write to the Free Software Foundation, 138.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 138.21 + * 138.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 138.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 138.24 + * have any questions. 138.25 + */ 138.26 + 138.27 +/* 138.28 + * @test 138.29 + * @bug 6843077 138.30 + * @summary new type annotation location: method type args 138.31 + * @author Mahmood Ali 138.32 + * @compile -source 1.7 MethodTypeArgs.java 138.33 + */ 138.34 + 138.35 +class MethodTypeArgs { 138.36 + void oneArg() { 138.37 + this.<@A String>newList(); 138.38 + this.<@A MyList<@B(0) String>>newList(); 138.39 + 138.40 + MethodTypeArgs.<@A String>newList(); 138.41 + MethodTypeArgs.<@A MyList<@B(0) String>>newList(); 138.42 + } 138.43 + 138.44 + void twoArg() { 138.45 + this.<String, String>newMap(); 138.46 + this.<@A String, @B(0) MyList<@A String>>newMap(); 138.47 + 138.48 + MethodTypeArgs.<String, String>newMap(); 138.49 + MethodTypeArgs.<@A String, @B(0) MyList<@A String>>newMap(); 138.50 + } 138.51 + 138.52 + void withArraysIn() { 138.53 + this.<String[]>newList(); 138.54 + this.<@A String @B(0) [] @A []>newList(); 138.55 + 138.56 + this.<@A String[], @B(0) MyList<@A String> @A []>newMap(); 138.57 + } 138.58 + 138.59 + static <E> void newList() { } 138.60 + static <K, V> void newMap() { } 138.61 +} 138.62 + 138.63 +class MyList<E> { } 138.64 +@interface A { } 138.65 +@interface B { int value(); }
139.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 139.2 +++ b/test/tools/javac/typeAnnotations/newlocations/MethodTypeParameters.java Fri Jun 26 19:12:41 2009 -0700 139.3 @@ -0,0 +1,48 @@ 139.4 +/* 139.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 139.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 139.7 + * 139.8 + * This code is free software; you can redistribute it and/or modify it 139.9 + * under the terms of the GNU General Public License version 2 only, as 139.10 + * published by the Free Software Foundation. 139.11 + * 139.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 139.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 139.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 139.15 + * version 2 for more details (a copy is included in the LICENSE file that 139.16 + * accompanied this code). 139.17 + * 139.18 + * You should have received a copy of the GNU General Public License version 139.19 + * 2 along with this work; if not, write to the Free Software Foundation, 139.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 139.21 + * 139.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 139.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 139.24 + * have any questions. 139.25 + */ 139.26 + 139.27 +/* 139.28 + * @test 139.29 + * @bug 6843077 139.30 + * @summary new type annotation location: method type parameter bounds 139.31 + * @author Mahmood Ali 139.32 + * @compile -source 1.7 MethodTypeParameters.java 139.33 + */ 139.34 + 139.35 +class UnscopedUnmodified { 139.36 + <K extends @A String> void methodExtends() {} 139.37 + <K extends @A Parameterized<@B String>> void nestedExtends() {} 139.38 + <K extends @A String, V extends @A Parameterized<@B String>> void dual() {} 139.39 + <K extends String, V extends Parameterized<@B String>> void dualOneAnno() {} 139.40 +} 139.41 + 139.42 +class PublicModifiedMethods { 139.43 + public final <K extends @A String> void methodExtends() {} 139.44 + public final <K extends @A Parameterized<@B String>> void nestedExtends() {} 139.45 + public final <K extends @A String, V extends @A Parameterized<@B String>> void dual() {} 139.46 + public final <K extends String, V extends Parameterized<@B String>> void dualOneAnno() {} 139.47 +} 139.48 + 139.49 +class Parameterized<K> { } 139.50 +@interface A { } 139.51 +@interface B { }
140.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 140.2 +++ b/test/tools/javac/typeAnnotations/newlocations/Parameters.java Fri Jun 26 19:12:41 2009 -0700 140.3 @@ -0,0 +1,51 @@ 140.4 +/* 140.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 140.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 140.7 + * 140.8 + * This code is free software; you can redistribute it and/or modify it 140.9 + * under the terms of the GNU General Public License version 2 only, as 140.10 + * published by the Free Software Foundation. 140.11 + * 140.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 140.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 140.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 140.15 + * version 2 for more details (a copy is included in the LICENSE file that 140.16 + * accompanied this code). 140.17 + * 140.18 + * You should have received a copy of the GNU General Public License version 140.19 + * 2 along with this work; if not, write to the Free Software Foundation, 140.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 140.21 + * 140.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 140.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 140.24 + * have any questions. 140.25 + */ 140.26 + 140.27 +/* 140.28 + * @test 140.29 + * @bug 6843077 140.30 + * @summary new type annotation location: parameter type array/generics 140.31 + * @author Mahmood Ali 140.32 + * @compile -source 1.7 Parameters.java 140.33 + */ 140.34 + 140.35 +class Parameters { 140.36 + void unannotated(Parameterized<String, String> a) {} 140.37 + void firstTypeArg(Parameterized<@A String, String> a) {} 140.38 + void secondTypeArg(Parameterized<String, @A String> a) {} 140.39 + void bothTypeArgs(Parameterized<@A String, @B String> both) {} 140.40 + 140.41 + void nestedParameterized(Parameterized<@A Parameterized<@A String, @B String>, @B String> a) {} 140.42 + 140.43 + void array1(@A String [] a) {} 140.44 + void array1Deep(@A String @B [] a) {} 140.45 + void array2(@A String [] [] a) {} 140.46 + void array2Deep(@A String @A [] @B [] a) {} 140.47 + void array2First(String @A [] [] a) {} 140.48 + void array2Second(String [] @B [] a) {} 140.49 +} 140.50 + 140.51 +class Parameterized<K, V> { } 140.52 + 140.53 +@interface A { } 140.54 +@interface B { }
141.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 141.2 +++ b/test/tools/javac/typeAnnotations/newlocations/Receivers.java Fri Jun 26 19:12:41 2009 -0700 141.3 @@ -0,0 +1,56 @@ 141.4 +/* 141.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 141.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 141.7 + * 141.8 + * This code is free software; you can redistribute it and/or modify it 141.9 + * under the terms of the GNU General Public License version 2 only, as 141.10 + * published by the Free Software Foundation. 141.11 + * 141.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 141.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 141.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 141.15 + * version 2 for more details (a copy is included in the LICENSE file that 141.16 + * accompanied this code). 141.17 + * 141.18 + * You should have received a copy of the GNU General Public License version 141.19 + * 2 along with this work; if not, write to the Free Software Foundation, 141.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 141.21 + * 141.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 141.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 141.24 + * have any questions. 141.25 + */ 141.26 + 141.27 +/* 141.28 + * @test 141.29 + * @bug 6843077 141.30 + * @summary new type annotation location: receivers 141.31 + * @author Mahmood Ali 141.32 + * @compile -source 1.7 Receivers.java 141.33 + */ 141.34 +class DefaultUnmodified { 141.35 + void plain() @A { } 141.36 + <T> void generic() @A { } 141.37 + void withException() @A throws Exception { } 141.38 + String nonVoid() @A { return null; } 141.39 + <T extends Runnable> void accept(T r) @A throws Exception { } 141.40 +} 141.41 + 141.42 +class PublicModified { 141.43 + public final void plain() @A { } 141.44 + public final <T> void generic() @A { } 141.45 + public final void withException() @A throws Exception { } 141.46 + public final String nonVoid() @A { return null; } 141.47 + public final <T extends Runnable> void accept(T r) @A throws Exception { } 141.48 +} 141.49 + 141.50 +class WithValue { 141.51 + void plain() @B("m") { } 141.52 + <T> void generic() @B("m") { } 141.53 + void withException() @B("m") throws Exception { } 141.54 + String nonVoid() @B("m") { return null; } 141.55 + <T extends Runnable> void accept(T r) @B("m") throws Exception { } 141.56 +} 141.57 + 141.58 +@interface A {} 141.59 +@interface B { String value(); }
142.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 142.2 +++ b/test/tools/javac/typeAnnotations/newlocations/Throws.java Fri Jun 26 19:12:41 2009 -0700 142.3 @@ -0,0 +1,47 @@ 142.4 +/* 142.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 142.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 142.7 + * 142.8 + * This code is free software; you can redistribute it and/or modify it 142.9 + * under the terms of the GNU General Public License version 2 only, as 142.10 + * published by the Free Software Foundation. 142.11 + * 142.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 142.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 142.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 142.15 + * version 2 for more details (a copy is included in the LICENSE file that 142.16 + * accompanied this code). 142.17 + * 142.18 + * You should have received a copy of the GNU General Public License version 142.19 + * 2 along with this work; if not, write to the Free Software Foundation, 142.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 142.21 + * 142.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 142.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 142.24 + * have any questions. 142.25 + */ 142.26 + 142.27 +/* 142.28 + * @test 142.29 + * @bug 6843077 142.30 + * @summary new type annotation location: throw clauses 142.31 + * @author Mahmood Ali 142.32 + * @compile -source 1.7 Throws.java 142.33 + */ 142.34 +class DefaultUnmodified { 142.35 + void oneException() throws @A Exception {} 142.36 + void twoExceptions() throws @A RuntimeException, @A Exception {} 142.37 +} 142.38 + 142.39 +class PublicModified { 142.40 + public final void oneException(String a) throws @A Exception {} 142.41 + public final void twoExceptions(String a) throws @A RuntimeException, @A Exception {} 142.42 +} 142.43 + 142.44 +class WithValue { 142.45 + void oneException() throws @B("m") Exception {} 142.46 + void twoExceptions() throws @B(value="m") RuntimeException, @A Exception {} 142.47 +} 142.48 + 142.49 +@interface A {} 142.50 +@interface B { String value(); }
143.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 143.2 +++ b/test/tools/javac/typeAnnotations/newlocations/TypeCasts.java Fri Jun 26 19:12:41 2009 -0700 143.3 @@ -0,0 +1,44 @@ 143.4 +/* 143.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 143.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 143.7 + * 143.8 + * This code is free software; you can redistribute it and/or modify it 143.9 + * under the terms of the GNU General Public License version 2 only, as 143.10 + * published by the Free Software Foundation. 143.11 + * 143.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 143.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 143.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 143.15 + * version 2 for more details (a copy is included in the LICENSE file that 143.16 + * accompanied this code). 143.17 + * 143.18 + * You should have received a copy of the GNU General Public License version 143.19 + * 2 along with this work; if not, write to the Free Software Foundation, 143.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 143.21 + * 143.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 143.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 143.24 + * have any questions. 143.25 + */ 143.26 + 143.27 +/* 143.28 + * @test 143.29 + * @bug 6843077 143.30 + * @summary new type annotation location: type casts 143.31 + * @author Mahmood Ali 143.32 + * @compile -source 1.7 TypeCasts.java 143.33 + */ 143.34 +class TypeCasts { 143.35 + void methodA() { 143.36 + String s = (@A String) null; 143.37 + Object o = (@A Class<@A String>) null; 143.38 + } 143.39 + 143.40 + void methodB() { 143.41 + String s = (@B("m") String) null; 143.42 + Object o = (@B("m") Class<@B("m") String>) null; 143.43 + } 143.44 +} 143.45 + 143.46 +@interface A { } 143.47 +@interface B { String value(); }
144.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 144.2 +++ b/test/tools/javac/typeAnnotations/newlocations/TypeParameters.java Fri Jun 26 19:12:41 2009 -0700 144.3 @@ -0,0 +1,50 @@ 144.4 +/* 144.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 144.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 144.7 + * 144.8 + * This code is free software; you can redistribute it and/or modify it 144.9 + * under the terms of the GNU General Public License version 2 only, as 144.10 + * published by the Free Software Foundation. 144.11 + * 144.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 144.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 144.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 144.15 + * version 2 for more details (a copy is included in the LICENSE file that 144.16 + * accompanied this code). 144.17 + * 144.18 + * You should have received a copy of the GNU General Public License version 144.19 + * 2 along with this work; if not, write to the Free Software Foundation, 144.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 144.21 + * 144.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 144.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 144.24 + * have any questions. 144.25 + */ 144.26 + 144.27 +/* 144.28 + * @test 144.29 + * @bug 6843077 144.30 + * @summary new type annotation location: class and method type parameters 144.31 + * @author Mahmood Ali 144.32 + * @compile -source 1.7 TypeParameters.java 144.33 + */ 144.34 + 144.35 +class Unannotated<K> { } 144.36 +class OneAnnotated<@A K> { } 144.37 +class TwoAnnotated<@A K, @A V> { } 144.38 +class SecondAnnotated<K, @A V extends String> { } 144.39 + 144.40 +class TestMethods { 144.41 + <K> void unannotated() { } 144.42 + <@A K> void oneAnnotated() { } 144.43 + <@A K, @B("m") V> void twoAnnotated() { } 144.44 + <K, @A V extends @A String> void secondAnnotated() { } 144.45 +} 144.46 + 144.47 +class UnannotatedB<K> { } 144.48 +class OneAnnotatedB<@B("m") K> { } 144.49 +class TwoAnnotatedB<@B("m") K, @B("m") V> { } 144.50 +class SecondAnnotatedB<K, @B("m") V extends @B("m") String> { } 144.51 + 144.52 +@interface A { } 144.53 +@interface B { String value(); }
145.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 145.2 +++ b/test/tools/javac/typeAnnotations/newlocations/Wildcards.java Fri Jun 26 19:12:41 2009 -0700 145.3 @@ -0,0 +1,70 @@ 145.4 +/* 145.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 145.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 145.7 + * 145.8 + * This code is free software; you can redistribute it and/or modify it 145.9 + * under the terms of the GNU General Public License version 2 only, as 145.10 + * published by the Free Software Foundation. 145.11 + * 145.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 145.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 145.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 145.15 + * version 2 for more details (a copy is included in the LICENSE file that 145.16 + * accompanied this code). 145.17 + * 145.18 + * You should have received a copy of the GNU General Public License version 145.19 + * 2 along with this work; if not, write to the Free Software Foundation, 145.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 145.21 + * 145.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 145.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 145.24 + * have any questions. 145.25 + */ 145.26 + 145.27 +/* 145.28 + * @test 145.29 + * @bug 6843077 145.30 + * @summary new type annotation location: wildcard bound 145.31 + * @author Mahmood Ali 145.32 + * @compile -source 1.7 Wildcards.java 145.33 + */ 145.34 +class BoundTest { 145.35 + void wcExtends(MyList<? extends @A String> l) { } 145.36 + void wcSuper(MyList<? super @A String> l) { } 145.37 + 145.38 + MyList<? extends @A String> returnWcExtends() { return null; } 145.39 + MyList<? super @A String> returnWcSuper() { return null; } 145.40 + MyList<? extends @A MyList<? super @B("m") String>> complex() { return null; } 145.41 +} 145.42 + 145.43 +class BoundWithValue { 145.44 + void wcExtends(MyList<? extends @B("m") String> l) { } 145.45 + void wcSuper(MyList<? super @B(value="m") String> l) { } 145.46 + 145.47 + MyList<? extends @B("m") String> returnWcExtends() { return null; } 145.48 + MyList<? super @B(value="m") String> returnWcSuper() { return null; } 145.49 + MyList<? extends @B("m") MyList<? super @B("m") String>> complex() { return null; } 145.50 +} 145.51 + 145.52 +class SelfTest { 145.53 + void wcExtends(MyList<@A ?> l) { } 145.54 + void wcSuper(MyList<@A ?> l) { } 145.55 + 145.56 + MyList<@A ?> returnWcExtends() { return null; } 145.57 + MyList<@A ?> returnWcSuper() { return null; } 145.58 + MyList<@A ? extends @A MyList<@B("m") ?>> complex() { return null; } 145.59 +} 145.60 + 145.61 +class SelfWithValue { 145.62 + void wcExtends(MyList<@B("m") ?> l) { } 145.63 + void wcSuper(MyList<@B(value="m") ?> l) { } 145.64 + 145.65 + MyList<@B("m") ?> returnWcExtends() { return null; } 145.66 + MyList<@B(value="m") ?> returnWcSuper() { return null; } 145.67 + MyList<@B("m") ? extends MyList<@B("m") ? super String>> complex() { return null; } 145.68 +} 145.69 + 145.70 +class MyList<K> { } 145.71 + 145.72 +@interface A { } 145.73 +@interface B { String value(); }
146.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 146.2 +++ b/test/tools/javap/typeAnnotations/ClassLiterals.java Fri Jun 26 19:12:41 2009 -0700 146.3 @@ -0,0 +1,174 @@ 146.4 +/* 146.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 146.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 146.7 + * 146.8 + * This code is free software; you can redistribute it and/or modify it 146.9 + * under the terms of the GNU General Public License version 2 only, as 146.10 + * published by the Free Software Foundation. 146.11 + * 146.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 146.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 146.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 146.15 + * version 2 for more details (a copy is included in the LICENSE file that 146.16 + * accompanied this code). 146.17 + * 146.18 + * You should have received a copy of the GNU General Public License version 146.19 + * 2 along with this work; if not, write to the Free Software Foundation, 146.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 146.21 + * 146.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 146.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 146.24 + * have any questions. 146.25 + */ 146.26 + 146.27 +import java.io.*; 146.28 +import com.sun.tools.classfile.*; 146.29 + 146.30 +/* 146.31 + * @test ClassLiterals 146.32 + * @bug 6843077 146.33 + * @summary test that all type annotations are present in the classfile 146.34 + */ 146.35 + 146.36 +public class ClassLiterals { 146.37 + public static void main(String[] args) throws Exception { 146.38 + new ClassLiterals().run(); 146.39 + } 146.40 + 146.41 + public void run() throws Exception { 146.42 + File javaFile = writeTestFile(); 146.43 + File classFile = compileTestFile(javaFile); 146.44 + 146.45 + ClassFile cf = ClassFile.read(classFile); 146.46 + test(cf); 146.47 + for (Field f : cf.fields) { 146.48 + test(cf, f); 146.49 + } 146.50 + for (Method m: cf.methods) { 146.51 + test(cf, m); 146.52 + } 146.53 + 146.54 + countAnnotations(); 146.55 + 146.56 + if (errors > 0) 146.57 + throw new Exception(errors + " errors found"); 146.58 + System.out.println("PASSED"); 146.59 + } 146.60 + 146.61 + void test(ClassFile cf) { 146.62 + test(cf, Attribute.RuntimeVisibleTypeAnnotations, true); 146.63 + test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false); 146.64 + } 146.65 + 146.66 + void test(ClassFile cf, Method m) { 146.67 + test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); 146.68 + test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); 146.69 + } 146.70 + 146.71 + void test(ClassFile cf, Field m) { 146.72 + test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); 146.73 + test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); 146.74 + } 146.75 + 146.76 + // test the result of Attributes.getIndex according to expectations 146.77 + // encoded in the method's name 146.78 + void test(ClassFile cf, String name, boolean visible) { 146.79 + int index = cf.attributes.getIndex(cf.constant_pool, name); 146.80 + if (index != -1) { 146.81 + Attribute attr = cf.attributes.get(index); 146.82 + assert attr instanceof RuntimeTypeAnnotations_attribute; 146.83 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 146.84 + all += tAttr.annotations.length; 146.85 + if (visible) 146.86 + visibles += tAttr.annotations.length; 146.87 + else 146.88 + invisibles += tAttr.annotations.length; 146.89 + } 146.90 + } 146.91 + 146.92 + // test the result of Attributes.getIndex according to expectations 146.93 + // encoded in the method's name 146.94 + void test(ClassFile cf, Method m, String name, boolean visible) { 146.95 + int index = m.attributes.getIndex(cf.constant_pool, name); 146.96 + if (index != -1) { 146.97 + Attribute attr = m.attributes.get(index); 146.98 + assert attr instanceof RuntimeTypeAnnotations_attribute; 146.99 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 146.100 + all += tAttr.annotations.length; 146.101 + if (visible) 146.102 + visibles += tAttr.annotations.length; 146.103 + else 146.104 + invisibles += tAttr.annotations.length; 146.105 + } 146.106 + } 146.107 + 146.108 + // test the result of Attributes.getIndex according to expectations 146.109 + // encoded in the method's name 146.110 + void test(ClassFile cf, Field m, String name, boolean visible) { 146.111 + int index = m.attributes.getIndex(cf.constant_pool, name); 146.112 + if (index != -1) { 146.113 + Attribute attr = m.attributes.get(index); 146.114 + assert attr instanceof RuntimeTypeAnnotations_attribute; 146.115 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 146.116 + all += tAttr.annotations.length; 146.117 + if (visible) 146.118 + visibles += tAttr.annotations.length; 146.119 + else 146.120 + invisibles += tAttr.annotations.length; 146.121 + } 146.122 + } 146.123 + 146.124 + File writeTestFile() throws IOException { 146.125 + File f = new File("Testa.java"); 146.126 + PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); 146.127 + out.println("import java.util.*;"); 146.128 + out.println("class Testa { "); 146.129 + out.println(" @interface A { }"); 146.130 + 146.131 + out.println(" void test() {"); 146.132 + out.println(" Object a = @A String.class;"); 146.133 + out.println(" Object b = @A String @A [] @A [].class;"); 146.134 + out.println(" }"); 146.135 + out.println("}"); 146.136 + 146.137 + out.close(); 146.138 + return f; 146.139 + } 146.140 + 146.141 + File compileTestFile(File f) { 146.142 + int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); 146.143 + if (rc != 0) 146.144 + throw new Error("compilation failed. rc=" + rc); 146.145 + String path = f.getPath(); 146.146 + return new File(path.substring(0, path.length() - 5) + ".class"); 146.147 + } 146.148 + 146.149 + void countAnnotations() { 146.150 + int expected_visibles = 0, expected_invisibles = 4; 146.151 + int expected_all = expected_visibles + expected_invisibles; 146.152 + 146.153 + if (expected_all != all) { 146.154 + errors++; 146.155 + System.err.println("expected " + expected_all 146.156 + + " annotations but found " + all); 146.157 + } 146.158 + 146.159 + if (expected_visibles != visibles) { 146.160 + errors++; 146.161 + System.err.println("expected " + expected_visibles 146.162 + + " visibles annotations but found " + visibles); 146.163 + } 146.164 + 146.165 + if (expected_invisibles != invisibles) { 146.166 + errors++; 146.167 + System.err.println("expected " + expected_invisibles 146.168 + + " invisibles annotations but found " + invisibles); 146.169 + } 146.170 + 146.171 + } 146.172 + 146.173 + int errors; 146.174 + int all; 146.175 + int visibles; 146.176 + int invisibles; 146.177 +}
147.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 147.2 +++ b/test/tools/javap/typeAnnotations/JSR175Annotations.java Fri Jun 26 19:12:41 2009 -0700 147.3 @@ -0,0 +1,152 @@ 147.4 +/* 147.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 147.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 147.7 + * 147.8 + * This code is free software; you can redistribute it and/or modify it 147.9 + * under the terms of the GNU General Public License version 2 only, as 147.10 + * published by the Free Software Foundation. 147.11 + * 147.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 147.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 147.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 147.15 + * version 2 for more details (a copy is included in the LICENSE file that 147.16 + * accompanied this code). 147.17 + * 147.18 + * You should have received a copy of the GNU General Public License version 147.19 + * 2 along with this work; if not, write to the Free Software Foundation, 147.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 147.21 + * 147.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 147.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 147.24 + * have any questions. 147.25 + */ 147.26 + 147.27 +import java.io.*; 147.28 +import com.sun.tools.classfile.*; 147.29 + 147.30 +/* 147.31 + * @test JSR175Annotations 147.32 + * @bug 6843077 147.33 + * @summary test that only type annotations are recorded as such in classfile 147.34 + */ 147.35 + 147.36 +public class JSR175Annotations { 147.37 + public static void main(String[] args) throws Exception { 147.38 + new JSR175Annotations().run(); 147.39 + } 147.40 + 147.41 + public void run() throws Exception { 147.42 + File javaFile = writeTestFile(); 147.43 + File classFile = compileTestFile(javaFile); 147.44 + 147.45 + ClassFile cf = ClassFile.read(classFile); 147.46 + for (Field f : cf.fields) { 147.47 + test(cf, f); 147.48 + } 147.49 + for (Method m: cf.methods) { 147.50 + test(cf, m); 147.51 + } 147.52 + 147.53 + countAnnotations(); 147.54 + 147.55 + if (errors > 0) 147.56 + throw new Exception(errors + " errors found"); 147.57 + System.out.println("PASSED"); 147.58 + } 147.59 + 147.60 + void test(ClassFile cf, Method m) { 147.61 + test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); 147.62 + test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); 147.63 + } 147.64 + 147.65 + void test(ClassFile cf, Field m) { 147.66 + test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); 147.67 + test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); 147.68 + } 147.69 + 147.70 + // test the result of Attributes.getIndex according to expectations 147.71 + // encoded in the method's name 147.72 + void test(ClassFile cf, Method m, String name, boolean visible) { 147.73 + int index = m.attributes.getIndex(cf.constant_pool, name); 147.74 + if (index != -1) { 147.75 + Attribute attr = m.attributes.get(index); 147.76 + assert attr instanceof RuntimeTypeAnnotations_attribute; 147.77 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 147.78 + all += tAttr.annotations.length; 147.79 + if (visible) 147.80 + visibles += tAttr.annotations.length; 147.81 + else 147.82 + invisibles += tAttr.annotations.length; 147.83 + } 147.84 + } 147.85 + 147.86 + // test the result of Attributes.getIndex according to expectations 147.87 + // encoded in the method's name 147.88 + void test(ClassFile cf, Field m, String name, boolean visible) { 147.89 + int index = m.attributes.getIndex(cf.constant_pool, name); 147.90 + if (index != -1) { 147.91 + Attribute attr = m.attributes.get(index); 147.92 + assert attr instanceof RuntimeTypeAnnotations_attribute; 147.93 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 147.94 + all += tAttr.annotations.length; 147.95 + if (visible) 147.96 + visibles += tAttr.annotations.length; 147.97 + else 147.98 + invisibles += tAttr.annotations.length; 147.99 + } 147.100 + } 147.101 + 147.102 + File writeTestFile() throws IOException { 147.103 + File f = new File("Test.java"); 147.104 + PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); 147.105 + out.println("import java.lang.annotation.Retention;"); 147.106 + out.println("import java.lang.annotation.RetentionPolicy;"); 147.107 + out.println("abstract class Test { "); 147.108 + out.println(" @Retention(RetentionPolicy.RUNTIME)"); 147.109 + out.println(" @interface A { }"); 147.110 + out.println(" @A String m;"); 147.111 + out.println(" @A String method(@A String a) {"); 147.112 + out.println(" return a;"); 147.113 + out.println(" }"); 147.114 + out.println("}"); 147.115 + out.close(); 147.116 + return f; 147.117 + } 147.118 + 147.119 + File compileTestFile(File f) { 147.120 + int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); 147.121 + if (rc != 0) 147.122 + throw new Error("compilation failed. rc=" + rc); 147.123 + String path = f.getPath(); 147.124 + return new File(path.substring(0, path.length() - 5) + ".class"); 147.125 + } 147.126 + 147.127 + void countAnnotations() { 147.128 + int expected_visibles = 0, expected_invisibles = 0; 147.129 + int expected_all = expected_visibles + expected_invisibles; 147.130 + 147.131 + if (expected_all != all) { 147.132 + errors++; 147.133 + System.err.println("expected " + expected_all 147.134 + + " annotations but found " + all); 147.135 + } 147.136 + 147.137 + if (expected_visibles != visibles) { 147.138 + errors++; 147.139 + System.err.println("expected " + expected_visibles 147.140 + + " visibles annotations but found " + visibles); 147.141 + } 147.142 + 147.143 + if (expected_invisibles != invisibles) { 147.144 + errors++; 147.145 + System.err.println("expected " + expected_invisibles 147.146 + + " invisibles annotations but found " + invisibles); 147.147 + } 147.148 + 147.149 + } 147.150 + 147.151 + int errors; 147.152 + int all; 147.153 + int visibles; 147.154 + int invisibles; 147.155 +}
148.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 148.2 +++ b/test/tools/javap/typeAnnotations/NewArray.java Fri Jun 26 19:12:41 2009 -0700 148.3 @@ -0,0 +1,175 @@ 148.4 +/* 148.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 148.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 148.7 + * 148.8 + * This code is free software; you can redistribute it and/or modify it 148.9 + * under the terms of the GNU General Public License version 2 only, as 148.10 + * published by the Free Software Foundation. 148.11 + * 148.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 148.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 148.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 148.15 + * version 2 for more details (a copy is included in the LICENSE file that 148.16 + * accompanied this code). 148.17 + * 148.18 + * You should have received a copy of the GNU General Public License version 148.19 + * 2 along with this work; if not, write to the Free Software Foundation, 148.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 148.21 + * 148.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 148.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 148.24 + * have any questions. 148.25 + */ 148.26 + 148.27 +import java.io.*; 148.28 +import com.sun.tools.classfile.*; 148.29 + 148.30 +/* 148.31 + * @test NewArray 148.32 + * @bug 6843077 148.33 + * @summary test that all type annotations are present in the classfile 148.34 + */ 148.35 + 148.36 +public class NewArray { 148.37 + public static void main(String[] args) throws Exception { 148.38 + new NewArray().run(); 148.39 + } 148.40 + 148.41 + public void run() throws Exception { 148.42 + File javaFile = writeTestFile(); 148.43 + File classFile = compileTestFile(javaFile); 148.44 + 148.45 + ClassFile cf = ClassFile.read(classFile); 148.46 + test(cf); 148.47 + for (Field f : cf.fields) { 148.48 + test(cf, f); 148.49 + } 148.50 + for (Method m: cf.methods) { 148.51 + test(cf, m); 148.52 + } 148.53 + 148.54 + countAnnotations(); 148.55 + 148.56 + if (errors > 0) 148.57 + throw new Exception(errors + " errors found"); 148.58 + System.out.println("PASSED"); 148.59 + } 148.60 + 148.61 + void test(ClassFile cf) { 148.62 + test(cf, Attribute.RuntimeVisibleTypeAnnotations, true); 148.63 + test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false); 148.64 + } 148.65 + 148.66 + void test(ClassFile cf, Method m) { 148.67 + test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); 148.68 + test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); 148.69 + } 148.70 + 148.71 + void test(ClassFile cf, Field m) { 148.72 + test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); 148.73 + test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); 148.74 + } 148.75 + 148.76 + // test the result of Attributes.getIndex according to expectations 148.77 + // encoded in the method's name 148.78 + void test(ClassFile cf, String name, boolean visible) { 148.79 + int index = cf.attributes.getIndex(cf.constant_pool, name); 148.80 + if (index != -1) { 148.81 + Attribute attr = cf.attributes.get(index); 148.82 + assert attr instanceof RuntimeTypeAnnotations_attribute; 148.83 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 148.84 + all += tAttr.annotations.length; 148.85 + if (visible) 148.86 + visibles += tAttr.annotations.length; 148.87 + else 148.88 + invisibles += tAttr.annotations.length; 148.89 + } 148.90 + } 148.91 + 148.92 + // test the result of Attributes.getIndex according to expectations 148.93 + // encoded in the method's name 148.94 + void test(ClassFile cf, Method m, String name, boolean visible) { 148.95 + int index = m.attributes.getIndex(cf.constant_pool, name); 148.96 + if (index != -1) { 148.97 + Attribute attr = m.attributes.get(index); 148.98 + assert attr instanceof RuntimeTypeAnnotations_attribute; 148.99 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 148.100 + all += tAttr.annotations.length; 148.101 + if (visible) 148.102 + visibles += tAttr.annotations.length; 148.103 + else 148.104 + invisibles += tAttr.annotations.length; 148.105 + } 148.106 + } 148.107 + 148.108 + // test the result of Attributes.getIndex according to expectations 148.109 + // encoded in the method's name 148.110 + void test(ClassFile cf, Field m, String name, boolean visible) { 148.111 + int index = m.attributes.getIndex(cf.constant_pool, name); 148.112 + if (index != -1) { 148.113 + Attribute attr = m.attributes.get(index); 148.114 + assert attr instanceof RuntimeTypeAnnotations_attribute; 148.115 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 148.116 + all += tAttr.annotations.length; 148.117 + if (visible) 148.118 + visibles += tAttr.annotations.length; 148.119 + else 148.120 + invisibles += tAttr.annotations.length; 148.121 + } 148.122 + } 148.123 + 148.124 + File writeTestFile() throws IOException { 148.125 + File f = new File("Test.java"); 148.126 + PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); 148.127 + out.println("import java.util.*;"); 148.128 + out.println("class Test { "); 148.129 + out.println(" @interface A { }"); 148.130 + 148.131 + out.println(" void test() {"); 148.132 + out.println(" Object a = new @A String @A [5] @A [];"); 148.133 + out.println(" Object b = new @A String @A [5] @A [3];"); 148.134 + out.println(" Object c = new @A String @A [] @A [] {};"); 148.135 + out.println(" }"); 148.136 + out.println("}"); 148.137 + 148.138 + out.close(); 148.139 + return f; 148.140 + } 148.141 + 148.142 + File compileTestFile(File f) { 148.143 + int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); 148.144 + if (rc != 0) 148.145 + throw new Error("compilation failed. rc=" + rc); 148.146 + String path = f.getPath(); 148.147 + return new File(path.substring(0, path.length() - 5) + ".class"); 148.148 + } 148.149 + 148.150 + void countAnnotations() { 148.151 + int expected_visibles = 0, expected_invisibles = 9; 148.152 + int expected_all = expected_visibles + expected_invisibles; 148.153 + 148.154 + if (expected_all != all) { 148.155 + errors++; 148.156 + System.err.println("expected " + expected_all 148.157 + + " annotations but found " + all); 148.158 + } 148.159 + 148.160 + if (expected_visibles != visibles) { 148.161 + errors++; 148.162 + System.err.println("expected " + expected_visibles 148.163 + + " visibles annotations but found " + visibles); 148.164 + } 148.165 + 148.166 + if (expected_invisibles != invisibles) { 148.167 + errors++; 148.168 + System.err.println("expected " + expected_invisibles 148.169 + + " invisibles annotations but found " + invisibles); 148.170 + } 148.171 + 148.172 + } 148.173 + 148.174 + int errors; 148.175 + int all; 148.176 + int visibles; 148.177 + int invisibles; 148.178 +}
149.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 149.2 +++ b/test/tools/javap/typeAnnotations/Presence.java Fri Jun 26 19:12:41 2009 -0700 149.3 @@ -0,0 +1,189 @@ 149.4 +/* 149.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 149.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 149.7 + * 149.8 + * This code is free software; you can redistribute it and/or modify it 149.9 + * under the terms of the GNU General Public License version 2 only, as 149.10 + * published by the Free Software Foundation. 149.11 + * 149.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 149.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 149.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 149.15 + * version 2 for more details (a copy is included in the LICENSE file that 149.16 + * accompanied this code). 149.17 + * 149.18 + * You should have received a copy of the GNU General Public License version 149.19 + * 2 along with this work; if not, write to the Free Software Foundation, 149.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 149.21 + * 149.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 149.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 149.24 + * have any questions. 149.25 + */ 149.26 + 149.27 +import java.io.*; 149.28 +import com.sun.tools.classfile.*; 149.29 + 149.30 +/* 149.31 + * @test Presence 149.32 + * @bug 6843077 149.33 + * @summary test that all type annotations are present in the classfile 149.34 + */ 149.35 + 149.36 +public class Presence { 149.37 + public static void main(String[] args) throws Exception { 149.38 + new Presence().run(); 149.39 + } 149.40 + 149.41 + public void run() throws Exception { 149.42 + File javaFile = writeTestFile(); 149.43 + File classFile = compileTestFile(javaFile); 149.44 + 149.45 + ClassFile cf = ClassFile.read(classFile); 149.46 + test(cf); 149.47 + for (Field f : cf.fields) { 149.48 + test(cf, f); 149.49 + } 149.50 + for (Method m: cf.methods) { 149.51 + test(cf, m); 149.52 + } 149.53 + 149.54 + countAnnotations(); 149.55 + 149.56 + if (errors > 0) 149.57 + throw new Exception(errors + " errors found"); 149.58 + System.out.println("PASSED"); 149.59 + } 149.60 + 149.61 + void test(ClassFile cf) { 149.62 + test(cf, Attribute.RuntimeVisibleTypeAnnotations, true); 149.63 + test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false); 149.64 + } 149.65 + 149.66 + void test(ClassFile cf, Method m) { 149.67 + test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); 149.68 + test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); 149.69 + } 149.70 + 149.71 + void test(ClassFile cf, Field m) { 149.72 + test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); 149.73 + test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); 149.74 + } 149.75 + 149.76 + // test the result of Attributes.getIndex according to expectations 149.77 + // encoded in the method's name 149.78 + void test(ClassFile cf, String name, boolean visible) { 149.79 + int index = cf.attributes.getIndex(cf.constant_pool, name); 149.80 + if (index != -1) { 149.81 + Attribute attr = cf.attributes.get(index); 149.82 + assert attr instanceof RuntimeTypeAnnotations_attribute; 149.83 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 149.84 + all += tAttr.annotations.length; 149.85 + if (visible) 149.86 + visibles += tAttr.annotations.length; 149.87 + else 149.88 + invisibles += tAttr.annotations.length; 149.89 + } 149.90 + } 149.91 + 149.92 + // test the result of Attributes.getIndex according to expectations 149.93 + // encoded in the method's name 149.94 + void test(ClassFile cf, Method m, String name, boolean visible) { 149.95 + int index = m.attributes.getIndex(cf.constant_pool, name); 149.96 + if (index != -1) { 149.97 + Attribute attr = m.attributes.get(index); 149.98 + assert attr instanceof RuntimeTypeAnnotations_attribute; 149.99 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 149.100 + all += tAttr.annotations.length; 149.101 + if (visible) 149.102 + visibles += tAttr.annotations.length; 149.103 + else 149.104 + invisibles += tAttr.annotations.length; 149.105 + } 149.106 + } 149.107 + 149.108 + // test the result of Attributes.getIndex according to expectations 149.109 + // encoded in the method's name 149.110 + void test(ClassFile cf, Field m, String name, boolean visible) { 149.111 + int index = m.attributes.getIndex(cf.constant_pool, name); 149.112 + if (index != -1) { 149.113 + Attribute attr = m.attributes.get(index); 149.114 + assert attr instanceof RuntimeTypeAnnotations_attribute; 149.115 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 149.116 + all += tAttr.annotations.length; 149.117 + if (visible) 149.118 + visibles += tAttr.annotations.length; 149.119 + else 149.120 + invisibles += tAttr.annotations.length; 149.121 + } 149.122 + } 149.123 + 149.124 + File writeTestFile() throws IOException { 149.125 + File f = new File("Test.java"); 149.126 + PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); 149.127 + out.println("import java.util.*;"); 149.128 + out.println("class Test<@Test.A T extends @Test.A List<@Test.A String>> { "); 149.129 + out.println(" @interface A { }"); 149.130 + 149.131 + out.println(" Map<@A String, Map<@A String, @A String>> f1;"); 149.132 + 149.133 + out.println(" <@A T extends @A List<@A String>>"); 149.134 + out.println(" Map<@A String, @A List<@A String>>"); 149.135 + out.println(" method(List<@A String> @A [] param1, String @A [] @A ... param2) @A"); 149.136 + out.println(" throws @A Exception {"); 149.137 + out.println(" @A String lc1 = null;"); 149.138 + out.println(" @A List<@A String> lc2 = null;"); 149.139 + out.println(" @A String @A [] [] @A[] lc3 = null;"); 149.140 + out.println(" List<? extends @A List<@A String>> lc4 = null;"); 149.141 + out.println(" Object lc5 = (@A List<@A String>) null;"); 149.142 + out.println(" boolean lc6 = lc1 instanceof @A String;"); 149.143 + out.println(" boolean lc7 = lc5 instanceof @A String @A [] @A [];"); 149.144 + out.println(" new @A ArrayList<@A String>();"); 149.145 + out.println(" Object lc8 = new @A String @A [4];"); 149.146 + out.println(" Object lc9 = @A String.class;"); 149.147 + out.println(" Object lc10 = @A int.class;"); 149.148 + out.println(" return null;"); 149.149 + out.println(" }"); 149.150 + out.println(" void vararg1(String @A ... t) { } "); 149.151 + out.println("}"); 149.152 + out.close(); 149.153 + return f; 149.154 + } 149.155 + 149.156 + File compileTestFile(File f) { 149.157 + int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); 149.158 + if (rc != 0) 149.159 + throw new Error("compilation failed. rc=" + rc); 149.160 + String path = f.getPath(); 149.161 + return new File(path.substring(0, path.length() - 5) + ".class"); 149.162 + } 149.163 + 149.164 + void countAnnotations() { 149.165 + int expected_visibles = 0, expected_invisibles = 39; 149.166 + int expected_all = expected_visibles + expected_invisibles; 149.167 + 149.168 + if (expected_all != all) { 149.169 + errors++; 149.170 + System.err.println("expected " + expected_all 149.171 + + " annotations but found " + all); 149.172 + } 149.173 + 149.174 + if (expected_visibles != visibles) { 149.175 + errors++; 149.176 + System.err.println("expected " + expected_visibles 149.177 + + " visibles annotations but found " + visibles); 149.178 + } 149.179 + 149.180 + if (expected_invisibles != invisibles) { 149.181 + errors++; 149.182 + System.err.println("expected " + expected_invisibles 149.183 + + " invisibles annotations but found " + invisibles); 149.184 + } 149.185 + 149.186 + } 149.187 + 149.188 + int errors; 149.189 + int all; 149.190 + int visibles; 149.191 + int invisibles; 149.192 +}
150.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 150.2 +++ b/test/tools/javap/typeAnnotations/PresenceInner.java Fri Jun 26 19:12:41 2009 -0700 150.3 @@ -0,0 +1,185 @@ 150.4 +/* 150.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 150.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 150.7 + * 150.8 + * This code is free software; you can redistribute it and/or modify it 150.9 + * under the terms of the GNU General Public License version 2 only, as 150.10 + * published by the Free Software Foundation. 150.11 + * 150.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 150.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 150.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 150.15 + * version 2 for more details (a copy is included in the LICENSE file that 150.16 + * accompanied this code). 150.17 + * 150.18 + * You should have received a copy of the GNU General Public License version 150.19 + * 2 along with this work; if not, write to the Free Software Foundation, 150.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 150.21 + * 150.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 150.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 150.24 + * have any questions. 150.25 + */ 150.26 + 150.27 +import java.io.*; 150.28 +import com.sun.tools.classfile.*; 150.29 + 150.30 +/* 150.31 + * @test PresenceInner 150.32 + * @bug 6843077 150.33 + * @summary test that annotations in inner types count only once 150.34 + */ 150.35 + 150.36 +public class PresenceInner { 150.37 + public static void main(String[] args) throws Exception { 150.38 + new PresenceInner().run(); 150.39 + } 150.40 + 150.41 + public void run() throws Exception { 150.42 + File javaFile = writeTestFile(); 150.43 + File classFile = compileTestFile(javaFile); 150.44 + 150.45 + ClassFile cf = ClassFile.read(classFile); 150.46 + test(cf); 150.47 + for (Field f : cf.fields) { 150.48 + test(cf, f); 150.49 + } 150.50 + for (Method m: cf.methods) { 150.51 + test(cf, m); 150.52 + } 150.53 + 150.54 + // counts are zero when vising outer class 150.55 + countAnnotations(0); 150.56 + 150.57 + // visit inner class 150.58 + File innerFile = new File("Test$1Inner.class"); 150.59 + ClassFile icf = ClassFile.read(innerFile); 150.60 + test(icf); 150.61 + for (Field f : icf.fields) { 150.62 + test(cf, f); 150.63 + } 150.64 + for (Method m: icf.methods) { 150.65 + test(cf, m); 150.66 + } 150.67 + 150.68 + countAnnotations(1); 150.69 + if (errors > 0) 150.70 + throw new Exception(errors + " errors found"); 150.71 + System.out.println("PASSED"); 150.72 + } 150.73 + 150.74 + void test(ClassFile cf) { 150.75 + test(cf, Attribute.RuntimeVisibleTypeAnnotations, true); 150.76 + test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false); 150.77 + } 150.78 + 150.79 + void test(ClassFile cf, Method m) { 150.80 + test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); 150.81 + test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); 150.82 + } 150.83 + 150.84 + void test(ClassFile cf, Field m) { 150.85 + test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); 150.86 + test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); 150.87 + } 150.88 + 150.89 + // test the result of Attributes.getIndex according to expectations 150.90 + // encoded in the method's name 150.91 + void test(ClassFile cf, String name, boolean visible) { 150.92 + int index = cf.attributes.getIndex(cf.constant_pool, name); 150.93 + if (index != -1) { 150.94 + Attribute attr = cf.attributes.get(index); 150.95 + assert attr instanceof RuntimeTypeAnnotations_attribute; 150.96 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 150.97 + all += tAttr.annotations.length; 150.98 + if (visible) 150.99 + visibles += tAttr.annotations.length; 150.100 + else 150.101 + invisibles += tAttr.annotations.length; 150.102 + } 150.103 + } 150.104 + 150.105 + // test the result of Attributes.getIndex according to expectations 150.106 + // encoded in the method's name 150.107 + void test(ClassFile cf, Method m, String name, boolean visible) { 150.108 + int index = m.attributes.getIndex(cf.constant_pool, name); 150.109 + if (index != -1) { 150.110 + Attribute attr = m.attributes.get(index); 150.111 + assert attr instanceof RuntimeTypeAnnotations_attribute; 150.112 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 150.113 + all += tAttr.annotations.length; 150.114 + if (visible) 150.115 + visibles += tAttr.annotations.length; 150.116 + else 150.117 + invisibles += tAttr.annotations.length; 150.118 + } 150.119 + } 150.120 + 150.121 + // test the result of Attributes.getIndex according to expectations 150.122 + // encoded in the method's name 150.123 + void test(ClassFile cf, Field m, String name, boolean visible) { 150.124 + int index = m.attributes.getIndex(cf.constant_pool, name); 150.125 + if (index != -1) { 150.126 + Attribute attr = m.attributes.get(index); 150.127 + assert attr instanceof RuntimeTypeAnnotations_attribute; 150.128 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 150.129 + all += tAttr.annotations.length; 150.130 + if (visible) 150.131 + visibles += tAttr.annotations.length; 150.132 + else 150.133 + invisibles += tAttr.annotations.length; 150.134 + } 150.135 + } 150.136 + 150.137 + File writeTestFile() throws IOException { 150.138 + File f = new File("Test.java"); 150.139 + PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); 150.140 + 150.141 + out.println("class Test {"); 150.142 + out.println(" void method() {"); 150.143 + out.println(" class Inner<T extends @A Object> { }"); 150.144 + out.println(" }"); 150.145 + out.println("}"); 150.146 + out.println("@interface A { }"); 150.147 + out.close(); 150.148 + System.out.println(f.getAbsolutePath()); 150.149 + return f; 150.150 + } 150.151 + 150.152 + File compileTestFile(File f) { 150.153 + int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); 150.154 + if (rc != 0) 150.155 + throw new Error("compilation failed. rc=" + rc); 150.156 + String path = f.getPath(); 150.157 + return new File(path.substring(0, path.length() - 5) + ".class"); 150.158 + } 150.159 + 150.160 + void countAnnotations(int expected_invisibles) { 150.161 + int expected_visibles = 0; 150.162 + int expected_all = expected_visibles + expected_invisibles; 150.163 + 150.164 + if (expected_all != all) { 150.165 + errors++; 150.166 + System.err.println("expected " + expected_all 150.167 + + " annotations but found " + all); 150.168 + } 150.169 + 150.170 + if (expected_visibles != visibles) { 150.171 + errors++; 150.172 + System.err.println("expected " + expected_visibles 150.173 + + " visibles annotations but found " + visibles); 150.174 + } 150.175 + 150.176 + if (expected_invisibles != invisibles) { 150.177 + errors++; 150.178 + System.err.println("expected " + expected_invisibles 150.179 + + " invisibles annotations but found " + invisibles); 150.180 + } 150.181 + 150.182 + } 150.183 + 150.184 + int errors; 150.185 + int all; 150.186 + int visibles; 150.187 + int invisibles; 150.188 +}
151.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 151.2 +++ b/test/tools/javap/typeAnnotations/Visibility.java Fri Jun 26 19:12:41 2009 -0700 151.3 @@ -0,0 +1,139 @@ 151.4 +/* 151.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 151.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 151.7 + * 151.8 + * This code is free software; you can redistribute it and/or modify it 151.9 + * under the terms of the GNU General Public License version 2 only, as 151.10 + * published by the Free Software Foundation. 151.11 + * 151.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 151.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 151.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 151.15 + * version 2 for more details (a copy is included in the LICENSE file that 151.16 + * accompanied this code). 151.17 + * 151.18 + * You should have received a copy of the GNU General Public License version 151.19 + * 2 along with this work; if not, write to the Free Software Foundation, 151.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 151.21 + * 151.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 151.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 151.24 + * have any questions. 151.25 + */ 151.26 + 151.27 +import java.io.*; 151.28 +import com.sun.tools.classfile.*; 151.29 + 151.30 +/* 151.31 + * @test Visibility 151.32 + * @bug 6843077 151.33 + * @summary test that type annotations are recorded in the classfile 151.34 + */ 151.35 + 151.36 +public class Visibility { 151.37 + public static void main(String[] args) throws Exception { 151.38 + new Visibility().run(); 151.39 + } 151.40 + 151.41 + public void run() throws Exception { 151.42 + File javaFile = writeTestFile(); 151.43 + File classFile = compileTestFile(javaFile); 151.44 + 151.45 + ClassFile cf = ClassFile.read(classFile); 151.46 + for (Method m: cf.methods) { 151.47 + test(cf, m); 151.48 + } 151.49 + 151.50 + countAnnotations(); 151.51 + 151.52 + if (errors > 0) 151.53 + throw new Exception(errors + " errors found"); 151.54 + System.out.println("PASSED"); 151.55 + } 151.56 + 151.57 + void test(ClassFile cf, Method m) { 151.58 + test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true); 151.59 + test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false); 151.60 + } 151.61 + 151.62 + // test the result of Attributes.getIndex according to expectations 151.63 + // encoded in the method's name 151.64 + void test(ClassFile cf, Method m, String name, boolean visible) { 151.65 + int index = m.attributes.getIndex(cf.constant_pool, name); 151.66 + if (index != -1) { 151.67 + Attribute attr = m.attributes.get(index); 151.68 + assert attr instanceof RuntimeTypeAnnotations_attribute; 151.69 + RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; 151.70 + all += tAttr.annotations.length; 151.71 + if (visible) 151.72 + visibles += tAttr.annotations.length; 151.73 + else 151.74 + invisibles += tAttr.annotations.length; 151.75 + } 151.76 + } 151.77 + 151.78 + File writeTestFile() throws IOException { 151.79 + File f = new File("Test.java"); 151.80 + PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); 151.81 + out.println("import java.lang.annotation.Retention;"); 151.82 + out.println("import java.lang.annotation.RetentionPolicy;"); 151.83 + out.println("abstract class Test { "); 151.84 + // visible annotations: RUNTIME 151.85 + out.println(" @Retention(RetentionPolicy.RUNTIME)"); 151.86 + out.println(" @interface A { }"); 151.87 + out.println(" void visible() @A { }"); 151.88 + 151.89 + // invisible annotations: CLASS 151.90 + out.println(" @Retention(RetentionPolicy.CLASS)"); 151.91 + out.println(" @interface B { }"); 151.92 + out.println(" void invisible() @B { }"); 151.93 + 151.94 + // source annotations 151.95 + out.println(" @Retention(RetentionPolicy.SOURCE)"); 151.96 + out.println(" @interface C { }"); 151.97 + out.println(" void source() @C { }"); 151.98 + 151.99 + // default visibility: CLASS 151.100 + out.println(" @interface D { }"); 151.101 + out.println(" void def() @D { }"); 151.102 + out.println("}"); 151.103 + out.close(); 151.104 + return f; 151.105 + } 151.106 + 151.107 + File compileTestFile(File f) { 151.108 + int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() }); 151.109 + if (rc != 0) 151.110 + throw new Error("compilation failed. rc=" + rc); 151.111 + String path = f.getPath(); 151.112 + return new File(path.substring(0, path.length() - 5) + ".class"); 151.113 + } 151.114 + 151.115 + void countAnnotations() { 151.116 + int expected_all = 3, expected_visibles = 1, expected_invisibles = 2; 151.117 + 151.118 + if (expected_all != all) { 151.119 + errors++; 151.120 + System.err.println("expected " + expected_all 151.121 + + " annotations but found " + all); 151.122 + } 151.123 + 151.124 + if (expected_visibles != visibles) { 151.125 + errors++; 151.126 + System.err.println("expected " + expected_visibles 151.127 + + " visibles annotations but found " + visibles); 151.128 + } 151.129 + 151.130 + if (expected_invisibles != invisibles) { 151.131 + errors++; 151.132 + System.err.println("expected " + expected_invisibles 151.133 + + " invisibles annotations but found " + invisibles); 151.134 + } 151.135 + 151.136 + } 151.137 + 151.138 + int errors; 151.139 + int all; 151.140 + int visibles; 151.141 + int invisibles; 151.142 +}