Mon, 10 Jan 2011 14:57:59 -0800
6992999: fully remove JSR 308 from langtools
Reviewed-by: mcimadamore
1.1 --- a/src/share/classes/com/sun/source/tree/MethodTree.java Wed Jan 05 09:59:01 2011 +0000 1.2 +++ b/src/share/classes/com/sun/source/tree/MethodTree.java Mon Jan 10 14:57:59 2011 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -53,7 +53,6 @@ 1.11 Tree getReturnType(); 1.12 List<? extends TypeParameterTree> getTypeParameters(); 1.13 List<? extends VariableTree> getParameters(); 1.14 -//308 List<? extends AnnotationTree> getReceiverAnnotations(); 1.15 List<? extends ExpressionTree> getThrows(); 1.16 BlockTree getBody(); 1.17 Tree getDefaultValue(); // for annotation types
2.1 --- a/src/share/classes/com/sun/source/tree/Tree.java Wed Jan 05 09:59:01 2011 +0000 2.2 +++ b/src/share/classes/com/sun/source/tree/Tree.java Mon Jan 10 14:57:59 2011 -0800 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -46,8 +46,6 @@ 2.11 */ 2.12 public enum Kind { 2.13 2.14 -//308 ANNOTATED_TYPE(AnnotatedTypeTree.class), 2.15 - 2.16 /** 2.17 * Used for instances of {@link AnnotationTree}. 2.18 */
3.1 --- a/src/share/classes/com/sun/source/tree/TreeVisitor.java Wed Jan 05 09:59:01 2011 +0000 3.2 +++ b/src/share/classes/com/sun/source/tree/TreeVisitor.java Mon Jan 10 14:57:59 2011 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -57,7 +57,6 @@ 3.11 * @since 1.6 3.12 */ 3.13 public interface TreeVisitor<R,P> { 3.14 -//308 R visitAnnotatedType(AnnotatedTypeTree node, P p); 3.15 R visitAnnotation(AnnotationTree node, P p); 3.16 R visitMethodInvocation(MethodInvocationTree node, P p); 3.17 R visitAssert(AssertTree node, P p);
4.1 --- a/src/share/classes/com/sun/source/tree/TypeParameterTree.java Wed Jan 05 09:59:01 2011 +0000 4.2 +++ b/src/share/classes/com/sun/source/tree/TypeParameterTree.java Mon Jan 10 14:57:59 2011 -0800 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -47,5 +47,4 @@ 4.11 public interface TypeParameterTree extends Tree { 4.12 Name getName(); 4.13 List<? extends Tree> getBounds(); 4.14 -//308 List<? extends AnnotationTree> getAnnotations(); 4.15 }
5.1 --- a/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Wed Jan 05 09:59:01 2011 +0000 5.2 +++ b/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Mon Jan 10 14:57:59 2011 -0800 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -248,10 +248,6 @@ 5.11 return defaultAction(node, p); 5.12 } 5.13 5.14 -//308 public R visitAnnotatedType(AnnotatedTypeTree node, P p) { 5.15 -//308 return defaultAction(node, p); 5.16 -//308 } 5.17 - 5.18 public R visitErroneous(ErroneousTree node, P p) { 5.19 return defaultAction(node, p); 5.20 }
6.1 --- a/src/share/classes/com/sun/source/util/TreeScanner.java Wed Jan 05 09:59:01 2011 +0000 6.2 +++ b/src/share/classes/com/sun/source/util/TreeScanner.java Mon Jan 10 14:57:59 2011 -0800 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -138,7 +138,6 @@ 6.11 r = scanAndReduce(node.getReturnType(), p, r); 6.12 r = scanAndReduce(node.getTypeParameters(), p, r); 6.13 r = scanAndReduce(node.getParameters(), p, r); 6.14 -//308 r = scanAndReduce(node.getReceiverAnnotations(), p, r); 6.15 r = scanAndReduce(node.getThrows(), p, r); 6.16 r = scanAndReduce(node.getBody(), p, r); 6.17 r = scanAndReduce(node.getDefaultValue(), p, r); 6.18 @@ -362,7 +361,6 @@ 6.19 6.20 public R visitTypeParameter(TypeParameterTree node, P p) { 6.21 R r = scan(node.getBounds(), p); 6.22 -//308 R r = scanAndReduce(node.getAnnotations(), p, r); 6.23 return r; 6.24 } 6.25 6.26 @@ -380,12 +378,6 @@ 6.27 return r; 6.28 } 6.29 6.30 -//308 public R visitAnnotatedType(AnnotatedTypeTree node, P p) { 6.31 -//308 R r = scan(node.getAnnotations(), p); 6.32 -//308 r = scanAndReduce(node.getUnderlyingType(), p, r); 6.33 -//308 return r; 6.34 -//308 } 6.35 - 6.36 public R visitOther(Tree node, P p) { 6.37 return null; 6.38 }
7.1 --- a/src/share/classes/com/sun/tools/classfile/Attribute.java Wed Jan 05 09:59:01 2011 +0000 7.2 +++ b/src/share/classes/com/sun/tools/classfile/Attribute.java Mon Jan 10 14:57:59 2011 -0800 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -54,8 +54,6 @@ 7.11 public static final String RuntimeInvisibleAnnotations = "RuntimeInvisibleAnnotations"; 7.12 public static final String RuntimeVisibleParameterAnnotations = "RuntimeVisibleParameterAnnotations"; 7.13 public static final String RuntimeInvisibleParameterAnnotations = "RuntimeInvisibleParameterAnnotations"; 7.14 - public static final String RuntimeVisibleTypeAnnotations = "RuntimeVisibleTypeAnnotations"; 7.15 - public static final String RuntimeInvisibleTypeAnnotations = "RuntimeInvisibleTypeAnnotations"; 7.16 public static final String Signature = "Signature"; 7.17 public static final String SourceDebugExtension = "SourceDebugExtension"; 7.18 public static final String SourceFile = "SourceFile"; 7.19 @@ -118,8 +116,6 @@ 7.20 standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class); 7.21 standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class); 7.22 standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class); 7.23 - standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class); 7.24 - standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class); 7.25 standardAttributes.put(Signature, Signature_attribute.class); 7.26 standardAttributes.put(SourceID, SourceID_attribute.class); 7.27 } 7.28 @@ -176,8 +172,6 @@ 7.29 R visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, P p); 7.30 R visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, P p); 7.31 R visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, P p); 7.32 - R visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, P p); 7.33 - R visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, P p); 7.34 R visitSignature(Signature_attribute attr, P p); 7.35 R visitSourceDebugExtension(SourceDebugExtension_attribute attr, P p); 7.36 R visitSourceFile(SourceFile_attribute attr, P p);
8.1 --- a/src/share/classes/com/sun/tools/classfile/ClassWriter.java Wed Jan 05 09:59:01 2011 +0000 8.2 +++ b/src/share/classes/com/sun/tools/classfile/ClassWriter.java Mon Jan 10 14:57:59 2011 -0800 8.3 @@ -1,6 +1,6 @@ 8.4 8.5 /* 8.6 - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 8.7 + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 8.8 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.9 * 8.10 * This code is free software; you can redistribute it and/or modify it 8.11 @@ -459,16 +459,6 @@ 8.12 return null; 8.13 } 8.14 8.15 - public Void visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, ClassOutputStream out) { 8.16 - annotationWriter.write(attr.annotations, out); 8.17 - return null; 8.18 - } 8.19 - 8.20 - public Void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, ClassOutputStream out) { 8.21 - annotationWriter.write(attr.annotations, out); 8.22 - return null; 8.23 - } 8.24 - 8.25 public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, ClassOutputStream out) { 8.26 out.writeByte(attr.parameter_annotations.length); 8.27 for (Annotation[] annos: attr.parameter_annotations) 8.28 @@ -628,12 +618,6 @@ 8.29 write(anno, out); 8.30 } 8.31 8.32 - public void write(ExtendedAnnotation[] annos, ClassOutputStream out) { 8.33 - out.writeShort(annos.length); 8.34 - for (ExtendedAnnotation anno: annos) 8.35 - write(anno, out); 8.36 - } 8.37 - 8.38 public void write(Annotation anno, ClassOutputStream out) { 8.39 out.writeShort(anno.type_index); 8.40 out.writeShort(anno.element_value_pairs.length); 8.41 @@ -641,11 +625,6 @@ 8.42 write(p, out); 8.43 } 8.44 8.45 - public void write(ExtendedAnnotation anno, ClassOutputStream out) { 8.46 - write(anno.annotation, out); 8.47 - write(anno.position, out); 8.48 - } 8.49 - 8.50 public void write(element_value_pair pair, ClassOutputStream out) { 8.51 out.writeShort(pair.element_name_index); 8.52 write(pair.value, out); 8.53 @@ -684,95 +663,5 @@ 8.54 return null; 8.55 } 8.56 8.57 - private void write(ExtendedAnnotation.Position p, ClassOutputStream out) { 8.58 - out.writeByte(p.type.targetTypeValue()); 8.59 - switch (p.type) { 8.60 - // type case 8.61 - case TYPECAST: 8.62 - case TYPECAST_GENERIC_OR_ARRAY: 8.63 - // object creation 8.64 - case INSTANCEOF: 8.65 - case INSTANCEOF_GENERIC_OR_ARRAY: 8.66 - // new expression 8.67 - case NEW: 8.68 - case NEW_GENERIC_OR_ARRAY: 8.69 - case NEW_TYPE_ARGUMENT: 8.70 - case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 8.71 - out.writeShort(p.offset); 8.72 - break; 8.73 - // local variable 8.74 - case LOCAL_VARIABLE: 8.75 - case LOCAL_VARIABLE_GENERIC_OR_ARRAY: 8.76 - int table_length = p.lvarOffset.length; 8.77 - out.writeShort(table_length); 8.78 - for (int i = 0; i < table_length; ++i) { 8.79 - out.writeShort(1); // for table length 8.80 - out.writeShort(p.lvarOffset[i]); 8.81 - out.writeShort(p.lvarLength[i]); 8.82 - out.writeShort(p.lvarIndex[i]); 8.83 - } 8.84 - break; 8.85 - // method receiver 8.86 - case METHOD_RECEIVER: 8.87 - // Do nothing 8.88 - break; 8.89 - // type parameters 8.90 - case CLASS_TYPE_PARAMETER: 8.91 - case METHOD_TYPE_PARAMETER: 8.92 - out.writeByte(p.parameter_index); 8.93 - break; 8.94 - // type parameters bounds 8.95 - case CLASS_TYPE_PARAMETER_BOUND: 8.96 - case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 8.97 - case METHOD_TYPE_PARAMETER_BOUND: 8.98 - case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 8.99 - out.writeByte(p.parameter_index); 8.100 - out.writeByte(p.bound_index); 8.101 - break; 8.102 - // wildcards 8.103 - case WILDCARD_BOUND: 8.104 - case WILDCARD_BOUND_GENERIC_OR_ARRAY: 8.105 - write(p.wildcard_position, out); 8.106 - break; 8.107 - // Class extends and implements clauses 8.108 - case CLASS_EXTENDS: 8.109 - case CLASS_EXTENDS_GENERIC_OR_ARRAY: 8.110 - out.writeByte(p.type_index); 8.111 - break; 8.112 - // throws 8.113 - case THROWS: 8.114 - out.writeByte(p.type_index); 8.115 - break; 8.116 - case CLASS_LITERAL: 8.117 - case CLASS_LITERAL_GENERIC_OR_ARRAY: 8.118 - out.writeShort(p.offset); 8.119 - break; 8.120 - // method parameter: not specified 8.121 - case METHOD_PARAMETER_GENERIC_OR_ARRAY: 8.122 - out.writeByte(p.parameter_index); 8.123 - break; 8.124 - // method type argument: wasn't specified 8.125 - case METHOD_TYPE_ARGUMENT: 8.126 - case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 8.127 - out.writeShort(p.offset); 8.128 - out.writeByte(p.type_index); 8.129 - break; 8.130 - // We don't need to worry abut these 8.131 - case METHOD_RETURN_GENERIC_OR_ARRAY: 8.132 - case FIELD_GENERIC_OR_ARRAY: 8.133 - break; 8.134 - case UNKNOWN: 8.135 - break; 8.136 - default: 8.137 - throw new AssertionError("unknown type: " + p); 8.138 - } 8.139 - 8.140 - // Append location data for generics/arrays. 8.141 - if (p.type.hasLocation()) { 8.142 - out.writeShort(p.location.size()); 8.143 - for (int i : p.location) 8.144 - out.writeByte((byte)i); 8.145 - } 8.146 - } 8.147 } 8.148 }
9.1 --- a/src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java Wed Jan 05 09:59:01 2011 +0000 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,612 +0,0 @@ 9.4 -/* 9.5 - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. 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. Oracle designates this 9.11 - * particular file as subject to the "Classpath" exception as provided 9.12 - * by Oracle in the LICENSE file that accompanied this code. 9.13 - * 9.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 9.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.17 - * version 2 for more details (a copy is included in the LICENSE file that 9.18 - * accompanied this code). 9.19 - * 9.20 - * You should have received a copy of the GNU General Public License version 9.21 - * 2 along with this work; if not, write to the Free Software Foundation, 9.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.23 - * 9.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 9.25 - * or visit www.oracle.com if you need additional information or have any 9.26 - * questions. 9.27 - */ 9.28 - 9.29 -package com.sun.tools.classfile; 9.30 - 9.31 -import java.io.IOException; 9.32 -import java.util.ArrayList; 9.33 -import java.util.EnumSet; 9.34 -import java.util.List; 9.35 -import java.util.Set; 9.36 - 9.37 -import static com.sun.tools.classfile.ExtendedAnnotation.TargetAttribute.*; 9.38 - 9.39 -/** 9.40 - * See JSR 308 specification, section 4.1 9.41 - * 9.42 - * <p><b>This is NOT part of any supported API. 9.43 - * If you write code that depends on this, you do so at your own risk. 9.44 - * This code and its internal interfaces are subject to change or 9.45 - * deletion without notice.</b> 9.46 - */ 9.47 -public class ExtendedAnnotation { 9.48 - ExtendedAnnotation(ClassReader cr) throws IOException, Annotation.InvalidAnnotation { 9.49 - annotation = new Annotation(cr); 9.50 - position = read_position(cr); 9.51 - } 9.52 - 9.53 - public ExtendedAnnotation(ConstantPool constant_pool, 9.54 - Annotation annotation, Position position) { 9.55 - this.annotation = annotation; 9.56 - this.position = position; 9.57 - } 9.58 - 9.59 - public int length() { 9.60 - int n = annotation.length(); 9.61 - n += position_length(position); 9.62 - return n; 9.63 - } 9.64 - 9.65 - public final Annotation annotation; 9.66 - public final Position position; 9.67 - 9.68 - private static Position read_position(ClassReader cr) throws IOException, Annotation.InvalidAnnotation { 9.69 - // Copied from ClassReader 9.70 - int tag = (byte)cr.readUnsignedByte(); // cast to introduce signedness 9.71 - if (!TargetType.isValidTargetTypeValue(tag)) 9.72 - throw new Annotation.InvalidAnnotation("invalid type annotation target type value: " + tag); 9.73 - 9.74 - TargetType type = TargetType.fromTargetTypeValue(tag); 9.75 - 9.76 - Position position = new Position(); 9.77 - position.type = type; 9.78 - 9.79 - switch (type) { 9.80 - // type case 9.81 - case TYPECAST: 9.82 - case TYPECAST_GENERIC_OR_ARRAY: 9.83 - // object creation 9.84 - case INSTANCEOF: 9.85 - case INSTANCEOF_GENERIC_OR_ARRAY: 9.86 - // new expression 9.87 - case NEW: 9.88 - case NEW_GENERIC_OR_ARRAY: 9.89 - position.offset = cr.readUnsignedShort(); 9.90 - break; 9.91 - // local variable 9.92 - case LOCAL_VARIABLE: 9.93 - case LOCAL_VARIABLE_GENERIC_OR_ARRAY: 9.94 - int table_length = cr.readUnsignedShort(); 9.95 - position.lvarOffset = new int[table_length]; 9.96 - position.lvarLength = new int[table_length]; 9.97 - position.lvarIndex = new int[table_length]; 9.98 - for (int i = 0; i < table_length; ++i) { 9.99 - position.lvarOffset[i] = cr.readUnsignedShort(); 9.100 - position.lvarLength[i] = cr.readUnsignedShort(); 9.101 - position.lvarIndex[i] = cr.readUnsignedShort(); 9.102 - } 9.103 - break; 9.104 - // method receiver 9.105 - case METHOD_RECEIVER: 9.106 - // Do nothing 9.107 - break; 9.108 - // type parameters 9.109 - case CLASS_TYPE_PARAMETER: 9.110 - case METHOD_TYPE_PARAMETER: 9.111 - position.parameter_index = cr.readUnsignedByte(); 9.112 - break; 9.113 - // type parameter bounds 9.114 - case CLASS_TYPE_PARAMETER_BOUND: 9.115 - case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 9.116 - case METHOD_TYPE_PARAMETER_BOUND: 9.117 - case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 9.118 - position.parameter_index = cr.readUnsignedByte(); 9.119 - position.bound_index = cr.readUnsignedByte(); 9.120 - break; 9.121 - // wildcards 9.122 - case WILDCARD_BOUND: 9.123 - case WILDCARD_BOUND_GENERIC_OR_ARRAY: 9.124 - position.wildcard_position = read_position(cr); 9.125 - break; 9.126 - // Class extends and implements clauses 9.127 - case CLASS_EXTENDS: 9.128 - case CLASS_EXTENDS_GENERIC_OR_ARRAY: 9.129 - int in = cr.readUnsignedShort(); 9.130 - if (in == 0xFFFF) 9.131 - in = -1; 9.132 - position.type_index = in; 9.133 - break; 9.134 - // throws 9.135 - case THROWS: 9.136 - position.type_index = cr.readUnsignedShort(); 9.137 - break; 9.138 - case CLASS_LITERAL: 9.139 - case CLASS_LITERAL_GENERIC_OR_ARRAY: 9.140 - position.offset = cr.readUnsignedShort(); 9.141 - break; 9.142 - // method parameter: not specified 9.143 - case METHOD_PARAMETER_GENERIC_OR_ARRAY: 9.144 - position.parameter_index = cr.readUnsignedByte(); 9.145 - break; 9.146 - // method type argument: wasn't specified 9.147 - case NEW_TYPE_ARGUMENT: 9.148 - case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 9.149 - case METHOD_TYPE_ARGUMENT: 9.150 - case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 9.151 - position.offset = cr.readUnsignedShort(); 9.152 - position.type_index = cr.readUnsignedByte(); 9.153 - break; 9.154 - // We don't need to worry abut these 9.155 - case METHOD_RETURN_GENERIC_OR_ARRAY: 9.156 - case FIELD_GENERIC_OR_ARRAY: 9.157 - break; 9.158 - case UNKNOWN: 9.159 - break; 9.160 - default: 9.161 - throw new AssertionError("Cannot be here"); 9.162 - } 9.163 - 9.164 - if (type.hasLocation()) { 9.165 - int len = cr.readUnsignedShort(); 9.166 - List<Integer> loc = new ArrayList<Integer>(len); 9.167 - for (int i = 0; i < len; i++) 9.168 - loc.add(cr.readUnsignedByte()); 9.169 - position.location = loc; 9.170 - } 9.171 - return position; 9.172 - } 9.173 - 9.174 - private static int position_length(Position pos) { 9.175 - int n = 0; 9.176 - n += 1; // target_type 9.177 - switch (pos.type) { 9.178 - // type case 9.179 - case TYPECAST: 9.180 - case TYPECAST_GENERIC_OR_ARRAY: 9.181 - // object creation 9.182 - case INSTANCEOF: 9.183 - case INSTANCEOF_GENERIC_OR_ARRAY: 9.184 - // new expression 9.185 - case NEW: 9.186 - case NEW_GENERIC_OR_ARRAY: 9.187 - n += 2; 9.188 - break; 9.189 - // local variable 9.190 - case LOCAL_VARIABLE: 9.191 - case LOCAL_VARIABLE_GENERIC_OR_ARRAY: 9.192 - n += 2; // table_length; 9.193 - int table_length = pos.lvarOffset.length; 9.194 - n += 2 * table_length; // offset 9.195 - n += 2 * table_length; // length; 9.196 - n += 2 * table_length; // index 9.197 - break; 9.198 - // method receiver 9.199 - case METHOD_RECEIVER: 9.200 - // Do nothing 9.201 - break; 9.202 - // type parameters 9.203 - case CLASS_TYPE_PARAMETER: 9.204 - case METHOD_TYPE_PARAMETER: 9.205 - n += 1; // parameter_index; 9.206 - break; 9.207 - // type parameter bounds 9.208 - case CLASS_TYPE_PARAMETER_BOUND: 9.209 - case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 9.210 - case METHOD_TYPE_PARAMETER_BOUND: 9.211 - case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 9.212 - n += 1; // parameter_index 9.213 - n += 1; // bound_index 9.214 - break; 9.215 - case WILDCARD_BOUND: 9.216 - case WILDCARD_BOUND_GENERIC_OR_ARRAY: 9.217 - n += position_length(pos.wildcard_position); 9.218 - break; 9.219 - // Class extends and implements clauses 9.220 - case CLASS_EXTENDS: 9.221 - case CLASS_EXTENDS_GENERIC_OR_ARRAY: 9.222 - n += 2; // type_index 9.223 - break; 9.224 - // throws 9.225 - case THROWS: 9.226 - n += 2; // type_index 9.227 - break; 9.228 - case CLASS_LITERAL: 9.229 - case CLASS_LITERAL_GENERIC_OR_ARRAY: 9.230 - n += 1; // offset 9.231 - break; 9.232 - // method parameter: not specified 9.233 - case METHOD_PARAMETER_GENERIC_OR_ARRAY: 9.234 - n += 1; // parameter_index 9.235 - break; 9.236 - // method type argument: wasn't specified 9.237 - case NEW_TYPE_ARGUMENT: 9.238 - case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 9.239 - case METHOD_TYPE_ARGUMENT: 9.240 - case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 9.241 - n += 2; // offset 9.242 - n += 1; // type index 9.243 - break; 9.244 - // We don't need to worry abut these 9.245 - case METHOD_RETURN_GENERIC_OR_ARRAY: 9.246 - case FIELD_GENERIC_OR_ARRAY: 9.247 - break; 9.248 - case UNKNOWN: 9.249 - break; 9.250 - default: 9.251 - } 9.252 - 9.253 - if (pos.type.hasLocation()) { 9.254 - n += 2; // length 9.255 - n += 1 * pos.location.size(); // actual array size 9.256 - } 9.257 - 9.258 - return n; 9.259 - } 9.260 - 9.261 - // Code duplicated from com.sun.tools.javac.code.TypeAnnotations.Position 9.262 - public static class Position { 9.263 - 9.264 - public TargetType type = TargetType.UNKNOWN; 9.265 - 9.266 - // For generic/array types. 9.267 - public List<Integer> location = new ArrayList<Integer>(); 9.268 - 9.269 - // For typecasts, type tests, new (and locals, as start_pc). 9.270 - public int offset = -1; 9.271 - 9.272 - // For locals. 9.273 - public int[] lvarOffset = null; 9.274 - public int[] lvarLength = null; 9.275 - public int[] lvarIndex = null; 9.276 - 9.277 - // For type parameter bound 9.278 - public int bound_index = Integer.MIN_VALUE; 9.279 - 9.280 - // For type parameter and method parameter 9.281 - public int parameter_index = Integer.MIN_VALUE; 9.282 - 9.283 - // For class extends, implements, and throws classes 9.284 - public int type_index = Integer.MIN_VALUE; 9.285 - 9.286 - // For wildcards 9.287 - public Position wildcard_position = null; 9.288 - 9.289 - @Override 9.290 - public String toString() { 9.291 - StringBuilder sb = new StringBuilder(); 9.292 - sb.append('['); 9.293 - sb.append(type); 9.294 - 9.295 - switch (type) { 9.296 - // type case 9.297 - case TYPECAST: 9.298 - case TYPECAST_GENERIC_OR_ARRAY: 9.299 - // object creation 9.300 - case INSTANCEOF: 9.301 - case INSTANCEOF_GENERIC_OR_ARRAY: 9.302 - // new expression 9.303 - case NEW: 9.304 - case NEW_GENERIC_OR_ARRAY: 9.305 - case NEW_TYPE_ARGUMENT: 9.306 - case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 9.307 - sb.append(", offset = "); 9.308 - sb.append(offset); 9.309 - break; 9.310 - // local variable 9.311 - case LOCAL_VARIABLE: 9.312 - case LOCAL_VARIABLE_GENERIC_OR_ARRAY: 9.313 - sb.append(", {"); 9.314 - for (int i = 0; i < lvarOffset.length; ++i) { 9.315 - if (i != 0) sb.append("; "); 9.316 - sb.append(", start_pc = "); 9.317 - sb.append(lvarOffset[i]); 9.318 - sb.append(", length = "); 9.319 - sb.append(lvarLength[i]); 9.320 - sb.append(", index = "); 9.321 - sb.append(lvarIndex[i]); 9.322 - } 9.323 - sb.append("}"); 9.324 - break; 9.325 - // method receiver 9.326 - case METHOD_RECEIVER: 9.327 - // Do nothing 9.328 - break; 9.329 - // type parameters 9.330 - case CLASS_TYPE_PARAMETER: 9.331 - case METHOD_TYPE_PARAMETER: 9.332 - sb.append(", param_index = "); 9.333 - sb.append(parameter_index); 9.334 - break; 9.335 - // type parameters bound 9.336 - case CLASS_TYPE_PARAMETER_BOUND: 9.337 - case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 9.338 - case METHOD_TYPE_PARAMETER_BOUND: 9.339 - case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 9.340 - sb.append(", param_index = "); 9.341 - sb.append(parameter_index); 9.342 - sb.append(", bound_index = "); 9.343 - sb.append(bound_index); 9.344 - break; 9.345 - // wildcard 9.346 - case WILDCARD_BOUND: 9.347 - case WILDCARD_BOUND_GENERIC_OR_ARRAY: 9.348 - sb.append(", wild_card = "); 9.349 - sb.append(wildcard_position); 9.350 - break; 9.351 - // Class extends and implements clauses 9.352 - case CLASS_EXTENDS: 9.353 - case CLASS_EXTENDS_GENERIC_OR_ARRAY: 9.354 - sb.append(", type_index = "); 9.355 - sb.append(type_index); 9.356 - break; 9.357 - // throws 9.358 - case THROWS: 9.359 - sb.append(", type_index = "); 9.360 - sb.append(type_index); 9.361 - break; 9.362 - case CLASS_LITERAL: 9.363 - case CLASS_LITERAL_GENERIC_OR_ARRAY: 9.364 - sb.append(", offset = "); 9.365 - sb.append(offset); 9.366 - break; 9.367 - // method parameter: not specified 9.368 - case METHOD_PARAMETER_GENERIC_OR_ARRAY: 9.369 - sb.append(", param_index = "); 9.370 - sb.append(parameter_index); 9.371 - break; 9.372 - // method type argument: wasn't specified 9.373 - case METHOD_TYPE_ARGUMENT: 9.374 - case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 9.375 - sb.append(", offset = "); 9.376 - sb.append(offset); 9.377 - sb.append(", type_index = "); 9.378 - sb.append(type_index); 9.379 - break; 9.380 - // We don't need to worry abut these 9.381 - case METHOD_RETURN_GENERIC_OR_ARRAY: 9.382 - case FIELD_GENERIC_OR_ARRAY: 9.383 - break; 9.384 - case UNKNOWN: 9.385 - break; 9.386 - default: 9.387 - throw new AssertionError("unknown type: " + type); 9.388 - } 9.389 - 9.390 - // Append location data for generics/arrays. 9.391 - if (type.hasLocation()) { 9.392 - sb.append(", location = ("); 9.393 - sb.append(location); 9.394 - sb.append(")"); 9.395 - } 9.396 - 9.397 - sb.append(']'); 9.398 - return sb.toString(); 9.399 - } 9.400 - } 9.401 - 9.402 - // Code duplicated from com.sun.tools.javac.comp.TargetType 9.403 - public enum TargetType { 9.404 - 9.405 - /** For annotations on typecasts. */ 9.406 - TYPECAST(0x00), 9.407 - 9.408 - /** For annotations on a type argument or nested array of a typecast. */ 9.409 - TYPECAST_GENERIC_OR_ARRAY(0x01, HasLocation), 9.410 - 9.411 - /** For annotations on type tests. */ 9.412 - INSTANCEOF(0x02), 9.413 - 9.414 - /** For annotations on a type argument or nested array of a type test. */ 9.415 - INSTANCEOF_GENERIC_OR_ARRAY(0x03, HasLocation), 9.416 - 9.417 - /** For annotations on object creation expressions. */ 9.418 - NEW(0x04), 9.419 - 9.420 - /** 9.421 - * For annotations on a type argument or nested array of an object creation 9.422 - * expression. 9.423 - */ 9.424 - NEW_GENERIC_OR_ARRAY(0x05, HasLocation), 9.425 - 9.426 - 9.427 - /** For annotations on the method receiver. */ 9.428 - METHOD_RECEIVER(0x06), 9.429 - 9.430 - // invalid location 9.431 - // METHOD_RECEIVER_GENERIC_OR_ARRAY(0x07, HasLocation), 9.432 - 9.433 - /** For annotations on local variables. */ 9.434 - LOCAL_VARIABLE(0x08), 9.435 - 9.436 - /** For annotations on a type argument or nested array of a local. */ 9.437 - LOCAL_VARIABLE_GENERIC_OR_ARRAY(0x09, HasLocation), 9.438 - 9.439 - // already handled by regular annotations 9.440 - // METHOD_RETURN(0x0A), 9.441 - 9.442 - /** 9.443 - * For annotations on a type argument or nested array of a method return 9.444 - * type. 9.445 - */ 9.446 - METHOD_RETURN_GENERIC_OR_ARRAY(0x0B, HasLocation), 9.447 - 9.448 - // already handled by regular annotations 9.449 - // METHOD_PARAMETER(0x0C), 9.450 - 9.451 - /** For annotations on a type argument or nested array of a method parameter. */ 9.452 - METHOD_PARAMETER_GENERIC_OR_ARRAY(0x0D, HasLocation), 9.453 - 9.454 - // already handled by regular annotations 9.455 - // FIELD(0x0E), 9.456 - 9.457 - /** For annotations on a type argument or nested array of a field. */ 9.458 - FIELD_GENERIC_OR_ARRAY(0x0F, HasLocation), 9.459 - 9.460 - /** For annotations on a bound of a type parameter of a class. */ 9.461 - CLASS_TYPE_PARAMETER_BOUND(0x10, HasBound, HasParameter), 9.462 - 9.463 - /** 9.464 - * For annotations on a type argument or nested array of a bound of a type 9.465 - * parameter of a class. 9.466 - */ 9.467 - CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x11, HasBound, HasLocation, HasParameter), 9.468 - 9.469 - /** For annotations on a bound of a type parameter of a method. */ 9.470 - METHOD_TYPE_PARAMETER_BOUND(0x12, HasBound, HasParameter), 9.471 - 9.472 - /** 9.473 - * For annotations on a type argument or nested array of a bound of a type 9.474 - * parameter of a method. 9.475 - */ 9.476 - METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x13, HasBound, HasLocation, HasParameter), 9.477 - 9.478 - /** For annotations on the type of an "extends" or "implements" clause. */ 9.479 - CLASS_EXTENDS(0x14), 9.480 - 9.481 - /** For annotations on the inner type of an "extends" or "implements" clause. */ 9.482 - CLASS_EXTENDS_GENERIC_OR_ARRAY(0x15, HasLocation), 9.483 - 9.484 - /** For annotations on a throws clause in a method declaration. */ 9.485 - THROWS(0x16), 9.486 - 9.487 - // invalid location 9.488 - // THROWS_GENERIC_OR_ARRAY(0x17, HasLocation), 9.489 - 9.490 - /** For annotations in type arguments of object creation expressions. */ 9.491 - NEW_TYPE_ARGUMENT(0x18), 9.492 - NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x19, HasLocation), 9.493 - 9.494 - METHOD_TYPE_ARGUMENT(0x1A), 9.495 - METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x1B, HasLocation), 9.496 - 9.497 - WILDCARD_BOUND(0x1C, HasBound), 9.498 - WILDCARD_BOUND_GENERIC_OR_ARRAY(0x1D, HasBound, HasLocation), 9.499 - 9.500 - CLASS_LITERAL(0x1E), 9.501 - CLASS_LITERAL_GENERIC_OR_ARRAY(0x1F, HasLocation), 9.502 - 9.503 - METHOD_TYPE_PARAMETER(0x20, HasParameter), 9.504 - 9.505 - // invalid location 9.506 - // METHOD_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x21, HasLocation, HasParameter), 9.507 - 9.508 - CLASS_TYPE_PARAMETER(0x22, HasParameter), 9.509 - 9.510 - // invalid location 9.511 - // CLASS_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x23, HasLocation, HasParameter), 9.512 - 9.513 - /** For annotations with an unknown target. */ 9.514 - UNKNOWN(-1); 9.515 - 9.516 - static final int MAXIMUM_TARGET_TYPE_VALUE = 0x22; 9.517 - 9.518 - private final int targetTypeValue; 9.519 - private Set<TargetAttribute> flags; 9.520 - 9.521 - TargetType(int targetTypeValue, TargetAttribute... attrs) { 9.522 - if (targetTypeValue < Byte.MIN_VALUE 9.523 - || targetTypeValue > Byte.MAX_VALUE) 9.524 - throw new AssertionError("attribute type value needs to be a byte: " + targetTypeValue); 9.525 - this.targetTypeValue = (byte)targetTypeValue; 9.526 - this.flags = EnumSet.noneOf(TargetAttribute.class); 9.527 - for (TargetAttribute attr : attrs) 9.528 - this.flags.add(attr); 9.529 - } 9.530 - 9.531 - /** 9.532 - * Returns whether or not this TargetType represents an annotation whose 9.533 - * target is an inner type of a generic or array type. 9.534 - * 9.535 - * @return true if this TargetType represents an annotation on an inner 9.536 - * type, false otherwise 9.537 - */ 9.538 - public boolean hasLocation() { 9.539 - return flags.contains(HasLocation); 9.540 - } 9.541 - 9.542 - public TargetType getGenericComplement() { 9.543 - if (hasLocation()) 9.544 - return this; 9.545 - else 9.546 - return fromTargetTypeValue(targetTypeValue() + 1); 9.547 - } 9.548 - 9.549 - /** 9.550 - * Returns whether or not this TargetType represents an annotation whose 9.551 - * target has a parameter index. 9.552 - * 9.553 - * @return true if this TargetType has a parameter index, 9.554 - * false otherwise 9.555 - */ 9.556 - public boolean hasParameter() { 9.557 - return flags.contains(HasParameter); 9.558 - } 9.559 - 9.560 - /** 9.561 - * Returns whether or not this TargetType represents an annotation whose 9.562 - * target is a type parameter bound. 9.563 - * 9.564 - * @return true if this TargetType represents an type parameter bound 9.565 - * annotation, false otherwise 9.566 - */ 9.567 - public boolean hasBound() { 9.568 - return flags.contains(HasBound); 9.569 - } 9.570 - 9.571 - public int targetTypeValue() { 9.572 - return this.targetTypeValue; 9.573 - } 9.574 - 9.575 - private static TargetType[] targets = null; 9.576 - 9.577 - private static TargetType[] buildTargets() { 9.578 - TargetType[] targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1]; 9.579 - TargetType[] alltargets = values(); 9.580 - for (TargetType target : alltargets) 9.581 - if (target.targetTypeValue >= 0) 9.582 - targets[target.targetTypeValue] = target; 9.583 - for (int i = 0; i <= MAXIMUM_TARGET_TYPE_VALUE; ++i) 9.584 - if (targets[i] == null) 9.585 - targets[i] = UNKNOWN; 9.586 - return targets; 9.587 - } 9.588 - 9.589 - public static boolean isValidTargetTypeValue(int tag) { 9.590 - if (targets == null) 9.591 - targets = buildTargets(); 9.592 - 9.593 - if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue)) 9.594 - return true; 9.595 - 9.596 - return (tag >= 0 && tag < targets.length); 9.597 - } 9.598 - 9.599 - public static TargetType fromTargetTypeValue(int tag) { 9.600 - if (targets == null) 9.601 - targets = buildTargets(); 9.602 - 9.603 - if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue)) 9.604 - return UNKNOWN; 9.605 - 9.606 - if (tag < 0 || tag >= targets.length) 9.607 - throw new IllegalArgumentException("Unknown TargetType: " + tag); 9.608 - return targets[tag]; 9.609 - } 9.610 - } 9.611 - 9.612 - static enum TargetAttribute { 9.613 - HasLocation, HasParameter, HasBound; 9.614 - } 9.615 -}
10.1 --- a/src/share/classes/com/sun/tools/classfile/RuntimeInvisibleTypeAnnotations_attribute.java Wed Jan 05 09:59:01 2011 +0000 10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 10.3 @@ -1,56 +0,0 @@ 10.4 -/* 10.5 - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. 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. Oracle designates this 10.11 - * particular file as subject to the "Classpath" exception as provided 10.12 - * by Oracle in the LICENSE file that accompanied this code. 10.13 - * 10.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 10.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.17 - * version 2 for more details (a copy is included in the LICENSE file that 10.18 - * accompanied this code). 10.19 - * 10.20 - * You should have received a copy of the GNU General Public License version 10.21 - * 2 along with this work; if not, write to the Free Software Foundation, 10.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.23 - * 10.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.25 - * or visit www.oracle.com if you need additional information or have any 10.26 - * questions. 10.27 - */ 10.28 - 10.29 -package com.sun.tools.classfile; 10.30 - 10.31 -import java.io.IOException; 10.32 - 10.33 -/** 10.34 - * See JSR 308 specification, section 4.1 10.35 - * 10.36 - * <p><b>This is NOT part of any supported API. 10.37 - * If you write code that depends on this, you do so at your own risk. 10.38 - * This code and its internal interfaces are subject to change or 10.39 - * deletion without notice.</b> 10.40 - */ 10.41 -public class RuntimeInvisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute { 10.42 - RuntimeInvisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length) 10.43 - throws IOException, Annotation.InvalidAnnotation { 10.44 - super(cr, name_index, length); 10.45 - } 10.46 - 10.47 - public RuntimeInvisibleTypeAnnotations_attribute(ConstantPool cp, ExtendedAnnotation[] annotations) 10.48 - throws ConstantPoolException { 10.49 - this(cp.getUTF8Index(Attribute.RuntimeInvisibleTypeAnnotations), annotations); 10.50 - } 10.51 - 10.52 - public RuntimeInvisibleTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) { 10.53 - super(name_index, annotations); 10.54 - } 10.55 - 10.56 - public <R, P> R accept(Visitor<R, P> visitor, P p) { 10.57 - return visitor.visitRuntimeInvisibleTypeAnnotations(this, p); 10.58 - } 10.59 -}
11.1 --- a/src/share/classes/com/sun/tools/classfile/RuntimeTypeAnnotations_attribute.java Wed Jan 05 09:59:01 2011 +0000 11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 11.3 @@ -1,61 +0,0 @@ 11.4 -/* 11.5 - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. 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. Oracle designates this 11.11 - * particular file as subject to the "Classpath" exception as provided 11.12 - * by Oracle in the LICENSE file that accompanied this code. 11.13 - * 11.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 11.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.17 - * version 2 for more details (a copy is included in the LICENSE file that 11.18 - * accompanied this code). 11.19 - * 11.20 - * You should have received a copy of the GNU General Public License version 11.21 - * 2 along with this work; if not, write to the Free Software Foundation, 11.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.23 - * 11.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.25 - * or visit www.oracle.com if you need additional information or have any 11.26 - * questions. 11.27 - */ 11.28 - 11.29 -package com.sun.tools.classfile; 11.30 - 11.31 -import java.io.IOException; 11.32 - 11.33 -/** 11.34 - * See JSR 308 specification, section 4 11.35 - * 11.36 - * <p><b>This is NOT part of any supported API. 11.37 - * If you write code that depends on this, you do so at your own risk. 11.38 - * This code and its internal interfaces are subject to change or 11.39 - * deletion without notice.</b> 11.40 - */ 11.41 -public abstract class RuntimeTypeAnnotations_attribute extends Attribute { 11.42 - protected RuntimeTypeAnnotations_attribute(ClassReader cr, int name_index, int length) 11.43 - throws IOException, Annotation.InvalidAnnotation { 11.44 - super(name_index, length); 11.45 - int num_annotations = cr.readUnsignedShort(); 11.46 - annotations = new ExtendedAnnotation[num_annotations]; 11.47 - for (int i = 0; i < annotations.length; i++) 11.48 - annotations[i] = new ExtendedAnnotation(cr); 11.49 - } 11.50 - 11.51 - protected RuntimeTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) { 11.52 - super(name_index, length(annotations)); 11.53 - this.annotations = annotations; 11.54 - } 11.55 - 11.56 - private static int length(ExtendedAnnotation[] annos) { 11.57 - int n = 2; 11.58 - for (ExtendedAnnotation anno: annos) 11.59 - n += anno.length(); 11.60 - return n; 11.61 - } 11.62 - 11.63 - public final ExtendedAnnotation[] annotations; 11.64 -}
12.1 --- a/src/share/classes/com/sun/tools/classfile/RuntimeVisibleTypeAnnotations_attribute.java Wed Jan 05 09:59:01 2011 +0000 12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 12.3 @@ -1,56 +0,0 @@ 12.4 -/* 12.5 - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. 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. Oracle designates this 12.11 - * particular file as subject to the "Classpath" exception as provided 12.12 - * by Oracle in the LICENSE file that accompanied this code. 12.13 - * 12.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 12.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.17 - * version 2 for more details (a copy is included in the LICENSE file that 12.18 - * accompanied this code). 12.19 - * 12.20 - * You should have received a copy of the GNU General Public License version 12.21 - * 2 along with this work; if not, write to the Free Software Foundation, 12.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.23 - * 12.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.25 - * or visit www.oracle.com if you need additional information or have any 12.26 - * questions. 12.27 - */ 12.28 - 12.29 -package com.sun.tools.classfile; 12.30 - 12.31 -import java.io.IOException; 12.32 - 12.33 -/** 12.34 - * See JSR 308 specification, section 4.1 12.35 - * 12.36 - * <p><b>This is NOT part of any supported API. 12.37 - * If you write code that depends on this, you do so at your own risk. 12.38 - * This code and its internal interfaces are subject to change or 12.39 - * deletion without notice.</b> 12.40 - */ 12.41 -public class RuntimeVisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute { 12.42 - RuntimeVisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length) 12.43 - throws IOException, Annotation.InvalidAnnotation { 12.44 - super(cr, name_index, length); 12.45 - } 12.46 - 12.47 - public RuntimeVisibleTypeAnnotations_attribute(ConstantPool cp, ExtendedAnnotation[] annotations) 12.48 - throws ConstantPoolException { 12.49 - this(cp.getUTF8Index(Attribute.RuntimeVisibleTypeAnnotations), annotations); 12.50 - } 12.51 - 12.52 - public RuntimeVisibleTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) { 12.53 - super(name_index, annotations); 12.54 - } 12.55 - 12.56 - public <R, P> R accept(Visitor<R, P> visitor, P p) { 12.57 - return visitor.visitRuntimeVisibleTypeAnnotations(this, p); 12.58 - } 12.59 -}
13.1 --- a/src/share/classes/com/sun/tools/javac/code/Attribute.java Wed Jan 05 09:59:01 2011 +0000 13.2 +++ b/src/share/classes/com/sun/tools/javac/code/Attribute.java Mon Jan 10 14:57:59 2011 -0800 13.3 @@ -1,5 +1,5 @@ 13.4 /* 13.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 13.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 13.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.8 * 13.9 * This code is free software; you can redistribute it and/or modify it 13.10 @@ -204,21 +204,6 @@ 13.11 } 13.12 } 13.13 13.14 - public static class TypeCompound extends Compound { 13.15 - public TypeAnnotationPosition position; 13.16 - public TypeCompound(Compound compound, 13.17 - TypeAnnotationPosition position) { 13.18 - this(compound.type, compound.values, position); 13.19 - } 13.20 - public TypeCompound(Type type, 13.21 - List<Pair<MethodSymbol, Attribute>> values, 13.22 - TypeAnnotationPosition position) { 13.23 - super(type, values); 13.24 - this.position = position; 13.25 - } 13.26 - 13.27 - } 13.28 - 13.29 /** The value for an annotation element of an array type. 13.30 */ 13.31 public static class Array extends Attribute {
14.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Jan 05 09:59:01 2011 +0000 14.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Mon Jan 10 14:57:59 2011 -0800 14.3 @@ -1,5 +1,5 @@ 14.4 /* 14.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 14.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 14.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.8 * 14.9 * This code is free software; you can redistribute it and/or modify it 14.10 @@ -100,17 +100,6 @@ 14.11 */ 14.12 public Type type; 14.13 14.14 - /** The type annotations targeted to a tree directly owned by this symbol 14.15 - */ 14.16 - // type annotations are stored here for two purposes: 14.17 - // - convenient location to store annotations for generation after erasure 14.18 - // - a private interface for accessing type annotations parsed from 14.19 - // classfiles 14.20 - // the field is populated for the following declaration only 14.21 - // class, field, variable and type parameters 14.22 - // 14.23 - public List<Attribute.TypeCompound> typeAnnotations; 14.24 - 14.25 /** The owner of this symbol. 14.26 */ 14.27 public Symbol owner; 14.28 @@ -133,7 +122,6 @@ 14.29 this.completer = null; 14.30 this.erasure_field = null; 14.31 this.attributes_field = List.nil(); 14.32 - this.typeAnnotations = List.nil(); 14.33 this.name = name; 14.34 } 14.35
15.1 --- a/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Wed Jan 05 09:59:01 2011 +0000 15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 15.3 @@ -1,403 +0,0 @@ 15.4 -/* 15.5 - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. 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. Oracle designates this 15.11 - * particular file as subject to the "Classpath" exception as provided 15.12 - * by Oracle in the LICENSE file that accompanied this code. 15.13 - * 15.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 15.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15.17 - * version 2 for more details (a copy is included in the LICENSE file that 15.18 - * accompanied this code). 15.19 - * 15.20 - * You should have received a copy of the GNU General Public License version 15.21 - * 2 along with this work; if not, write to the Free Software Foundation, 15.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 15.23 - * 15.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 15.25 - * or visit www.oracle.com if you need additional information or have any 15.26 - * questions. 15.27 - */ 15.28 - 15.29 -package com.sun.tools.javac.code; 15.30 - 15.31 -import javax.lang.model.element.ElementKind; 15.32 - 15.33 -import com.sun.tools.javac.code.Symbol.VarSymbol; 15.34 -import com.sun.tools.javac.tree.JCTree; 15.35 -import com.sun.tools.javac.tree.TreeInfo; 15.36 -import com.sun.tools.javac.tree.TreeScanner; 15.37 -import com.sun.tools.javac.tree.JCTree.*; 15.38 -import com.sun.tools.javac.util.Context; 15.39 -import com.sun.tools.javac.util.List; 15.40 -import com.sun.tools.javac.util.ListBuffer; 15.41 - 15.42 -/** 15.43 - * Contains operations specific to processing type annotations 15.44 - */ 15.45 -public class TypeAnnotations { 15.46 - private static final Context.Key<TypeAnnotations> key 15.47 - = new Context.Key<TypeAnnotations>(); 15.48 - 15.49 - public static TypeAnnotations instance(Context context) { 15.50 - TypeAnnotations instance = context.get(key); 15.51 - if (instance == null) 15.52 - instance = new TypeAnnotations(context); 15.53 - return instance; 15.54 - } 15.55 - 15.56 - protected TypeAnnotations(Context context) { 15.57 - context.put(key, this); 15.58 - } 15.59 - 15.60 - public void taFillAndLift(JCClassDecl tree, boolean visitBodies) { 15.61 -//308 new TypeAnnotationPositions().scan(tree); 15.62 -//308 new TypeAnnotationLift().scan(tree); 15.63 - } 15.64 - 15.65 - private static class TypeAnnotationPositions extends TreeScanner { 15.66 - 15.67 - private ListBuffer<JCTree> frames = ListBuffer.lb(); 15.68 - private void push(JCTree t) { frames = frames.prepend(t); } 15.69 - private JCTree pop() { return frames.next(); } 15.70 - private JCTree peek2() { return frames.toList().tail.head; } 15.71 - 15.72 - @Override 15.73 - public void scan(JCTree tree) { 15.74 - push(tree); 15.75 - super.scan(tree); 15.76 - pop(); 15.77 - } 15.78 - 15.79 - private boolean inClass = false; 15.80 - 15.81 - @Override 15.82 - public void visitClassDef(JCClassDecl tree) { 15.83 - if (!inClass) { 15.84 - // Do not recurse into nested and inner classes since 15.85 - // TransTypes.visitClassDef makes an invocation for each class 15.86 - // separately. 15.87 - inClass = true; 15.88 - try { 15.89 - super.visitClassDef(tree); 15.90 - } finally { 15.91 - inClass = false; 15.92 - } 15.93 - } 15.94 - } 15.95 - 15.96 - private TypeAnnotationPosition resolveFrame(JCTree tree, JCTree frame, 15.97 - List<JCTree> path, TypeAnnotationPosition p) { 15.98 - switch (frame.getKind()) { 15.99 - case TYPE_CAST: 15.100 - p.type = TargetType.TYPECAST; 15.101 - p.pos = frame.pos; 15.102 - return p; 15.103 - 15.104 - case INSTANCE_OF: 15.105 - p.type = TargetType.INSTANCEOF; 15.106 - p.pos = frame.pos; 15.107 - return p; 15.108 - 15.109 - case NEW_CLASS: 15.110 - p.type = TargetType.NEW; 15.111 - p.pos = frame.pos; 15.112 - return p; 15.113 - 15.114 - case NEW_ARRAY: 15.115 - p.type = TargetType.NEW; 15.116 - p.pos = frame.pos; 15.117 - return p; 15.118 - 15.119 - case ANNOTATION_TYPE: 15.120 - case CLASS: 15.121 - case ENUM: 15.122 - case INTERFACE: 15.123 - p.pos = frame.pos; 15.124 - if (((JCClassDecl)frame).extending == tree) { 15.125 - p.type = TargetType.CLASS_EXTENDS; 15.126 - p.type_index = -1; 15.127 - } else if (((JCClassDecl)frame).implementing.contains(tree)) { 15.128 - p.type = TargetType.CLASS_EXTENDS; 15.129 - p.type_index = ((JCClassDecl)frame).implementing.indexOf(tree); 15.130 - } else if (((JCClassDecl)frame).typarams.contains(tree)) { 15.131 - p.type = TargetType.CLASS_TYPE_PARAMETER; 15.132 - p.parameter_index = ((JCClassDecl)frame).typarams.indexOf(tree); 15.133 - } else 15.134 - throw new AssertionError(); 15.135 - return p; 15.136 - 15.137 - case METHOD: { 15.138 - JCMethodDecl frameMethod = (JCMethodDecl)frame; 15.139 - p.pos = frame.pos; 15.140 - if (frameMethod.receiverAnnotations.contains(tree)) 15.141 - p.type = TargetType.METHOD_RECEIVER; 15.142 - else if (frameMethod.thrown.contains(tree)) { 15.143 - p.type = TargetType.THROWS; 15.144 - p.type_index = frameMethod.thrown.indexOf(tree); 15.145 - } else if (((JCMethodDecl)frame).restype == tree) { 15.146 - p.type = TargetType.METHOD_RETURN_GENERIC_OR_ARRAY; 15.147 - } else if (frameMethod.typarams.contains(tree)) { 15.148 - p.type = TargetType.METHOD_TYPE_PARAMETER; 15.149 - p.parameter_index = frameMethod.typarams.indexOf(tree); 15.150 - } else 15.151 - throw new AssertionError(); 15.152 - return p; 15.153 - } 15.154 - case MEMBER_SELECT: { 15.155 - JCFieldAccess fieldFrame = (JCFieldAccess)frame; 15.156 - if ("class".contentEquals(fieldFrame.name)) { 15.157 - p.type = TargetType.CLASS_LITERAL; 15.158 - p.pos = TreeInfo.innermostType(fieldFrame.selected).pos; 15.159 - } else 15.160 - throw new AssertionError(); 15.161 - return p; 15.162 - } 15.163 - case PARAMETERIZED_TYPE: { 15.164 - TypeAnnotationPosition nextP; 15.165 - if (((JCTypeApply)frame).clazz == tree) 15.166 - nextP = p; // generic: RAW; noop 15.167 - else if (((JCTypeApply)frame).arguments.contains(tree)) 15.168 - p.location = p.location.prepend( 15.169 - ((JCTypeApply)frame).arguments.indexOf(tree)); 15.170 - else 15.171 - throw new AssertionError(); 15.172 - 15.173 - List<JCTree> newPath = path.tail; 15.174 - return resolveFrame(newPath.head, newPath.tail.head, newPath, p); 15.175 - } 15.176 - 15.177 - case ARRAY_TYPE: { 15.178 - p.location = p.location.prepend(0); 15.179 - List<JCTree> newPath = path.tail; 15.180 - return resolveFrame(newPath.head, newPath.tail.head, newPath, p); 15.181 - } 15.182 - 15.183 - case TYPE_PARAMETER: 15.184 - if (path.tail.tail.head.getTag() == JCTree.CLASSDEF) { 15.185 - JCClassDecl clazz = (JCClassDecl)path.tail.tail.head; 15.186 - p.type = TargetType.CLASS_TYPE_PARAMETER_BOUND; 15.187 - p.parameter_index = clazz.typarams.indexOf(path.tail.head); 15.188 - p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree); 15.189 - } else if (path.tail.tail.head.getTag() == JCTree.METHODDEF) { 15.190 - JCMethodDecl method = (JCMethodDecl)path.tail.tail.head; 15.191 - p.type = TargetType.METHOD_TYPE_PARAMETER_BOUND; 15.192 - p.parameter_index = method.typarams.indexOf(path.tail.head); 15.193 - p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree); 15.194 - } else 15.195 - throw new AssertionError(); 15.196 - p.pos = frame.pos; 15.197 - return p; 15.198 - 15.199 - case VARIABLE: 15.200 - VarSymbol v = ((JCVariableDecl)frame).sym; 15.201 - p.pos = frame.pos; 15.202 - switch (v.getKind()) { 15.203 - case LOCAL_VARIABLE: 15.204 - p.type = TargetType.LOCAL_VARIABLE; break; 15.205 - case FIELD: 15.206 - p.type = TargetType.FIELD_GENERIC_OR_ARRAY; break; 15.207 - case PARAMETER: 15.208 - p.type = TargetType.METHOD_PARAMETER_GENERIC_OR_ARRAY; 15.209 - p.parameter_index = methodParamIndex(path, frame); 15.210 - break; 15.211 - default: throw new AssertionError(); 15.212 - } 15.213 - return p; 15.214 - 15.215 -//308 case ANNOTATED_TYPE: { 15.216 -//308 List<JCTree> newPath = path.tail; 15.217 -//308 return resolveFrame(newPath.head, newPath.tail.head, 15.218 -//308 newPath, p); 15.219 -//308 } 15.220 - 15.221 - case METHOD_INVOCATION: { 15.222 - JCMethodInvocation invocation = (JCMethodInvocation)frame; 15.223 - if (!invocation.typeargs.contains(tree)) 15.224 - throw new AssertionError("{" + tree + "} is not an argument in the invocation: " + invocation); 15.225 - p.type = TargetType.METHOD_TYPE_ARGUMENT; 15.226 - p.pos = invocation.pos; 15.227 - p.type_index = invocation.typeargs.indexOf(tree); 15.228 - return p; 15.229 - } 15.230 - 15.231 - case EXTENDS_WILDCARD: 15.232 - case SUPER_WILDCARD: { 15.233 - p.type = TargetType.WILDCARD_BOUND; 15.234 - List<JCTree> newPath = path.tail; 15.235 - 15.236 - TypeAnnotationPosition wildcard = 15.237 - resolveFrame(newPath.head, newPath.tail.head, newPath, 15.238 - new TypeAnnotationPosition()); 15.239 - if (!wildcard.location.isEmpty()) 15.240 - wildcard.type = wildcard.type.getGenericComplement(); 15.241 - p.wildcard_position = wildcard; 15.242 - p.pos = frame.pos; 15.243 - return p; 15.244 - } 15.245 - } 15.246 - return p; 15.247 - } 15.248 - 15.249 - private void setTypeAnnotationPos(List<JCTypeAnnotation> annotations, TypeAnnotationPosition position) { 15.250 - for (JCTypeAnnotation anno : annotations) { 15.251 - anno.annotation_position = position; 15.252 - anno.attribute_field.position = position; 15.253 - } 15.254 - } 15.255 - 15.256 - @Override 15.257 - public void visitNewArray(JCNewArray tree) { 15.258 - findPosition(tree, tree, tree.annotations); 15.259 - int dimAnnosCount = tree.dimAnnotations.size(); 15.260 - 15.261 - // handle annotations associated with dimentions 15.262 - for (int i = 0; i < dimAnnosCount; ++i) { 15.263 - TypeAnnotationPosition p = new TypeAnnotationPosition(); 15.264 - p.type = TargetType.NEW_GENERIC_OR_ARRAY; 15.265 - p.pos = tree.pos; 15.266 - p.location = p.location.append(i); 15.267 - setTypeAnnotationPos(tree.dimAnnotations.get(i), p); 15.268 - } 15.269 - 15.270 - // handle "free" annotations 15.271 - int i = dimAnnosCount == 0 ? 0 : dimAnnosCount - 1; 15.272 - JCExpression elemType = tree.elemtype; 15.273 - while (elemType != null) { 15.274 - if (elemType.getTag() == JCTree.ANNOTATED_TYPE) { 15.275 - JCAnnotatedType at = (JCAnnotatedType)elemType; 15.276 - TypeAnnotationPosition p = new TypeAnnotationPosition(); 15.277 - p.type = TargetType.NEW_GENERIC_OR_ARRAY; 15.278 - p.pos = tree.pos; 15.279 - p.location = p.location.append(i); 15.280 - setTypeAnnotationPos(at.annotations, p); 15.281 - elemType = at.underlyingType; 15.282 - } else if (elemType.getTag() == JCTree.TYPEARRAY) { 15.283 - ++i; 15.284 - elemType = ((JCArrayTypeTree)elemType).elemtype; 15.285 - } else 15.286 - break; 15.287 - } 15.288 - 15.289 - // find annotations locations of initializer elements 15.290 - scan(tree.elems); 15.291 - } 15.292 - 15.293 - @Override 15.294 - public void visitAnnotatedType(JCAnnotatedType tree) { 15.295 - findPosition(tree, peek2(), tree.annotations); 15.296 - super.visitAnnotatedType(tree); 15.297 - } 15.298 - 15.299 - @Override 15.300 - public void visitMethodDef(JCMethodDecl tree) { 15.301 - TypeAnnotationPosition p = new TypeAnnotationPosition(); 15.302 - p.type = TargetType.METHOD_RECEIVER; 15.303 - setTypeAnnotationPos(tree.receiverAnnotations, p); 15.304 - super.visitMethodDef(tree); 15.305 - } 15.306 - @Override 15.307 - public void visitTypeParameter(JCTypeParameter tree) { 15.308 - findPosition(tree, peek2(), tree.annotations); 15.309 - super.visitTypeParameter(tree); 15.310 - } 15.311 - 15.312 - void findPosition(JCTree tree, JCTree frame, List<JCTypeAnnotation> annotations) { 15.313 - if (!annotations.isEmpty()) { 15.314 - TypeAnnotationPosition p = 15.315 - resolveFrame(tree, frame, frames.toList(), 15.316 - new TypeAnnotationPosition()); 15.317 - if (!p.location.isEmpty()) 15.318 - p.type = p.type.getGenericComplement(); 15.319 - setTypeAnnotationPos(annotations, p); 15.320 - } 15.321 - } 15.322 - 15.323 - private int methodParamIndex(List<JCTree> path, JCTree param) { 15.324 - List<JCTree> curr = path; 15.325 - if (curr.head != param) 15.326 - curr = path.tail; 15.327 - JCMethodDecl method = (JCMethodDecl)curr.tail.head; 15.328 - return method.params.indexOf(param); 15.329 - } 15.330 - } 15.331 - 15.332 - private static class TypeAnnotationLift extends TreeScanner { 15.333 - List<Attribute.TypeCompound> recordedTypeAnnotations = List.nil(); 15.334 - 15.335 - boolean isInner = false; 15.336 - @Override 15.337 - public void visitClassDef(JCClassDecl tree) { 15.338 - if (isInner) { 15.339 - // tree is an inner class tree. stop now. 15.340 - // TransTypes.visitClassDef makes an invocation for each class 15.341 - // separately. 15.342 - return; 15.343 - } 15.344 - isInner = true; 15.345 - List<Attribute.TypeCompound> prevTAs = recordedTypeAnnotations; 15.346 - recordedTypeAnnotations = List.nil(); 15.347 - try { 15.348 - super.visitClassDef(tree); 15.349 - } finally { 15.350 - tree.sym.typeAnnotations = tree.sym.typeAnnotations.appendList(recordedTypeAnnotations); 15.351 - recordedTypeAnnotations = prevTAs; 15.352 - } 15.353 - } 15.354 - 15.355 - @Override 15.356 - public void visitMethodDef(JCMethodDecl tree) { 15.357 - List<Attribute.TypeCompound> prevTAs = recordedTypeAnnotations; 15.358 - recordedTypeAnnotations = List.nil(); 15.359 - try { 15.360 - super.visitMethodDef(tree); 15.361 - } finally { 15.362 - tree.sym.typeAnnotations = tree.sym.typeAnnotations.appendList(recordedTypeAnnotations); 15.363 - recordedTypeAnnotations = prevTAs; 15.364 - } 15.365 - } 15.366 - 15.367 - @Override 15.368 - public void visitVarDef(JCVariableDecl tree) { 15.369 - List<Attribute.TypeCompound> prevTAs = recordedTypeAnnotations; 15.370 - recordedTypeAnnotations = List.nil(); 15.371 - ElementKind kind = tree.sym.getKind(); 15.372 - if (kind == ElementKind.LOCAL_VARIABLE && tree.mods.annotations.nonEmpty()) { 15.373 - // need to lift the annotations 15.374 - TypeAnnotationPosition position = new TypeAnnotationPosition(); 15.375 - position.pos = tree.pos; 15.376 - position.type = TargetType.LOCAL_VARIABLE; 15.377 - for (Attribute.Compound attribute : tree.sym.attributes_field) { 15.378 - Attribute.TypeCompound tc = 15.379 - new Attribute.TypeCompound(attribute.type, attribute.values, position); 15.380 - recordedTypeAnnotations = recordedTypeAnnotations.append(tc); 15.381 - } 15.382 - } 15.383 - try { 15.384 - super.visitVarDef(tree); 15.385 - } finally { 15.386 - if (kind.isField() || kind == ElementKind.LOCAL_VARIABLE) 15.387 - tree.sym.typeAnnotations = tree.sym.typeAnnotations.appendList(recordedTypeAnnotations); 15.388 - recordedTypeAnnotations = kind.isField() ? prevTAs : prevTAs.appendList(recordedTypeAnnotations); 15.389 - } 15.390 - } 15.391 - 15.392 - @Override 15.393 - public void visitApply(JCMethodInvocation tree) { 15.394 - scan(tree.meth); 15.395 - scan(tree.typeargs); 15.396 - scan(tree.args); 15.397 - } 15.398 - 15.399 - public void visitAnnotation(JCAnnotation tree) { 15.400 - if (tree instanceof JCTypeAnnotation) 15.401 - recordedTypeAnnotations = recordedTypeAnnotations.append(((JCTypeAnnotation)tree).attribute_field); 15.402 - super.visitAnnotation(tree); 15.403 - } 15.404 - } 15.405 - 15.406 -}
16.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Jan 05 09:59:01 2011 +0000 16.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jan 10 14:57:59 2011 -0800 16.3 @@ -1,5 +1,5 @@ 16.4 /* 16.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 16.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 16.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 16.8 * 16.9 * This code is free software; you can redistribute it and/or modify it 16.10 @@ -2989,10 +2989,6 @@ 16.11 result = tree.type = syms.errType; 16.12 } 16.13 16.14 - public void visitAnnotatedType(JCAnnotatedType tree) { 16.15 - result = tree.type = attribType(tree.getUnderlyingType(), env); 16.16 - } 16.17 - 16.18 public void visitErroneous(JCErroneous tree) { 16.19 if (tree.errs != null) 16.20 for (JCTree err : tree.errs) 16.21 @@ -3184,9 +3180,6 @@ 16.22 (c.flags() & ABSTRACT) == 0) { 16.23 checkSerialVersionUID(tree, c); 16.24 } 16.25 - 16.26 - // Check type annotations applicability rules 16.27 - validateTypeAnnotations(tree); 16.28 } 16.29 // where 16.30 /** check if a class is a subtype of Serializable, if that is available. */ 16.31 @@ -3234,35 +3227,6 @@ 16.32 return types.capture(type); 16.33 } 16.34 16.35 - private void validateTypeAnnotations(JCTree tree) { 16.36 - tree.accept(typeAnnotationsValidator); 16.37 - } 16.38 - //where 16.39 - private final JCTree.Visitor typeAnnotationsValidator = 16.40 - new TreeScanner() { 16.41 - public void visitAnnotation(JCAnnotation tree) { 16.42 - if (tree instanceof JCTypeAnnotation) { 16.43 - chk.validateTypeAnnotation((JCTypeAnnotation)tree, false); 16.44 - } 16.45 - super.visitAnnotation(tree); 16.46 - } 16.47 - public void visitTypeParameter(JCTypeParameter tree) { 16.48 - chk.validateTypeAnnotations(tree.annotations, true); 16.49 - // don't call super. skip type annotations 16.50 - scan(tree.bounds); 16.51 - } 16.52 - public void visitMethodDef(JCMethodDecl tree) { 16.53 - // need to check static methods 16.54 - if ((tree.sym.flags() & Flags.STATIC) != 0) { 16.55 - for (JCTypeAnnotation a : tree.receiverAnnotations) { 16.56 - if (chk.isTypeAnnotation(a, false)) 16.57 - log.error(a.pos(), "annotation.type.not.applicable"); 16.58 - } 16.59 - } 16.60 - super.visitMethodDef(tree); 16.61 - } 16.62 - }; 16.63 - 16.64 // <editor-fold desc="post-attribution visitor"> 16.65 16.66 /**
17.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Jan 05 09:59:01 2011 +0000 17.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Jan 10 14:57:59 2011 -0800 17.3 @@ -1,5 +1,5 @@ 17.4 /* 17.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 17.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 17.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.8 * 17.9 * This code is free software; you can redistribute it and/or modify it 17.10 @@ -1086,11 +1086,6 @@ 17.11 } 17.12 } 17.13 17.14 - @Override 17.15 - public void visitAnnotatedType(JCAnnotatedType tree) { 17.16 - tree.underlyingType.accept(this); 17.17 - } 17.18 - 17.19 /** Default visitor method: do nothing. 17.20 */ 17.21 @Override 17.22 @@ -2239,14 +2234,6 @@ 17.23 validateAnnotation(a, s); 17.24 } 17.25 17.26 - /** Check the type annotations 17.27 - */ 17.28 - public void validateTypeAnnotations(List<JCTypeAnnotation> annotations, boolean isTypeParameter) { 17.29 - if (skipAnnotations) return; 17.30 - for (JCTypeAnnotation a : annotations) 17.31 - validateTypeAnnotation(a, isTypeParameter); 17.32 - } 17.33 - 17.34 /** Check an annotation of a symbol. 17.35 */ 17.36 public void validateAnnotation(JCAnnotation a, Symbol s) { 17.37 @@ -2261,15 +2248,6 @@ 17.38 } 17.39 } 17.40 17.41 - public void validateTypeAnnotation(JCTypeAnnotation a, boolean isTypeParameter) { 17.42 - if (a.type == null) 17.43 - throw new AssertionError("annotation tree hasn't been attributed yet: " + a); 17.44 - validateAnnotationTree(a); 17.45 - 17.46 - if (!isTypeAnnotation(a, isTypeParameter)) 17.47 - log.error(a.pos(), "annotation.type.not.applicable"); 17.48 - } 17.49 - 17.50 /** Is s a method symbol that overrides a method in a superclass? */ 17.51 boolean isOverrider(Symbol s) { 17.52 if (s.kind != MTH || s.isStatic()) 17.53 @@ -2288,25 +2266,6 @@ 17.54 return false; 17.55 } 17.56 17.57 - /** Is the annotation applicable to type annotations */ 17.58 - boolean isTypeAnnotation(JCTypeAnnotation a, boolean isTypeParameter) { 17.59 - Attribute.Compound atTarget = 17.60 - a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym); 17.61 - if (atTarget == null) return true; 17.62 - Attribute atValue = atTarget.member(names.value); 17.63 - if (!(atValue instanceof Attribute.Array)) return true; // error recovery 17.64 - Attribute.Array arr = (Attribute.Array) atValue; 17.65 - for (Attribute app : arr.values) { 17.66 - if (!(app instanceof Attribute.Enum)) return true; // recovery 17.67 - Attribute.Enum e = (Attribute.Enum) app; 17.68 - if (!isTypeParameter && e.value.name == names.TYPE_USE) 17.69 - return true; 17.70 - else if (isTypeParameter && e.value.name == names.TYPE_PARAMETER) 17.71 - return true; 17.72 - } 17.73 - return false; 17.74 - } 17.75 - 17.76 /** Is the annotation applicable to the symbol? */ 17.77 boolean annotationApplicable(JCAnnotation a, Symbol s) { 17.78 Attribute.Compound atTarget =
18.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Wed Jan 05 09:59:01 2011 +0000 18.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Mon Jan 10 14:57:59 2011 -0800 18.3 @@ -1,5 +1,5 @@ 18.4 /* 18.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 18.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 18.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.8 * 18.9 * This code is free software; you can redistribute it and/or modify it 18.10 @@ -37,7 +37,6 @@ 18.11 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 18.12 18.13 import com.sun.tools.javac.code.Symbol.*; 18.14 -import com.sun.tools.javac.comp.Resolve; 18.15 import com.sun.tools.javac.tree.JCTree.*; 18.16 18.17 import static com.sun.tools.javac.code.Flags.*; 18.18 @@ -1350,11 +1349,6 @@ 18.19 } 18.20 } 18.21 18.22 - public void visitAnnotatedType(JCAnnotatedType tree) { 18.23 - // annotations don't get scanned 18.24 - tree.underlyingType.accept(this); 18.25 - } 18.26 - 18.27 public void visitIdent(JCIdent tree) { 18.28 if (tree.sym.kind == VAR) { 18.29 checkInit(tree.pos(), (VarSymbol)tree.sym); 18.30 @@ -1373,7 +1367,6 @@ 18.31 if (!tree.type.isErroneous() 18.32 && lint.isEnabled(Lint.LintCategory.CAST) 18.33 && types.isSameType(tree.expr.type, tree.clazz.type) 18.34 - && !(ignoreAnnotatedCasts && containsTypeAnnotation(tree.clazz)) 18.35 && !is292targetTypeCast(tree)) { 18.36 log.warning(Lint.LintCategory.CAST, 18.37 tree.pos(), "redundant.cast", tree.expr.type); 18.38 @@ -1397,23 +1390,6 @@ 18.39 } 18.40 18.41 /************************************************************************** 18.42 - * utility methods for ignoring type-annotated casts lint checking 18.43 - *************************************************************************/ 18.44 - private static final boolean ignoreAnnotatedCasts = true; 18.45 - private static class AnnotationFinder extends TreeScanner { 18.46 - public boolean foundTypeAnno = false; 18.47 - public void visitAnnotation(JCAnnotation tree) { 18.48 - foundTypeAnno = foundTypeAnno || (tree instanceof JCTypeAnnotation); 18.49 - } 18.50 - } 18.51 - 18.52 - private boolean containsTypeAnnotation(JCTree e) { 18.53 - AnnotationFinder finder = new AnnotationFinder(); 18.54 - finder.scan(e); 18.55 - return finder.foundTypeAnno; 18.56 - } 18.57 - 18.58 -/************************************************************************** 18.59 * main method 18.60 *************************************************************************/ 18.61
19.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Wed Jan 05 09:59:01 2011 +0000 19.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon Jan 10 14:57:59 2011 -0800 19.3 @@ -1,5 +1,5 @@ 19.4 /* 19.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 19.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 19.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.8 * 19.9 * This code is free software; you can redistribute it and/or modify it 19.10 @@ -2585,11 +2585,6 @@ 19.11 result = tree; 19.12 } 19.13 19.14 - public void visitAnnotatedType(JCAnnotatedType tree) { 19.15 - tree.underlyingType = translate(tree.underlyingType); 19.16 - result = tree.underlyingType; 19.17 - } 19.18 - 19.19 public void visitTypeCast(JCTypeCast tree) { 19.20 tree.clazz = translate(tree.clazz); 19.21 if (tree.type.isPrimitive() != tree.expr.type.isPrimitive())
20.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Wed Jan 05 09:59:01 2011 +0000 20.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Mon Jan 10 14:57:59 2011 -0800 20.3 @@ -1,5 +1,5 @@ 20.4 /* 20.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 20.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 20.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.8 * 20.9 * This code is free software; you can redistribute it and/or modify it 20.10 @@ -928,10 +928,6 @@ 20.11 if (hasDeprecatedAnnotation(tree.mods.annotations)) 20.12 c.flags_field |= DEPRECATED; 20.13 annotateLater(tree.mods.annotations, baseEnv, c); 20.14 - // class type parameters use baseEnv but everything uses env 20.15 - for (JCTypeParameter tp : tree.typarams) 20.16 - tp.accept(new TypeAnnotate(baseEnv)); 20.17 - tree.accept(new TypeAnnotate(env)); 20.18 20.19 chk.checkNonCyclicDecl(tree); 20.20 20.21 @@ -1014,86 +1010,6 @@ 20.22 } 20.23 } 20.24 20.25 - // A sub-phase that "compiles" annotations in annotated types. 20.26 - private class TypeAnnotate extends TreeScanner { 20.27 - private Env<AttrContext> env; 20.28 - public TypeAnnotate(Env<AttrContext> env) { this.env = env; } 20.29 - 20.30 - private void enterTypeAnnotations(List<JCTypeAnnotation> annotations) { 20.31 - Set<TypeSymbol> annotated = new HashSet<TypeSymbol>(); 20.32 - if (!skipAnnotations) 20.33 - for (List<JCTypeAnnotation> al = annotations; al.nonEmpty(); al = al.tail) { 20.34 - JCTypeAnnotation a = al.head; 20.35 - Attribute.Compound c = annotate.enterAnnotation(a, 20.36 - syms.annotationType, 20.37 - env); 20.38 - if (c == null) continue; 20.39 - Attribute.TypeCompound tc = new Attribute.TypeCompound(c.type, c.values, a.annotation_position); 20.40 - a.attribute_field = tc; 20.41 - // Note: @Deprecated has no effect on local variables and parameters 20.42 - if (!annotated.add(a.type.tsym)) 20.43 - log.error(a.pos, "duplicate.annotation"); 20.44 - } 20.45 - } 20.46 - 20.47 - // each class (including enclosed inner classes) should be visited 20.48 - // separately through MemberEnter.complete(Symbol) 20.49 - // this flag is used to prevent from visiting inner classes. 20.50 - private boolean isEnclosingClass = false; 20.51 - @Override 20.52 - public void visitClassDef(final JCClassDecl tree) { 20.53 - if (isEnclosingClass) 20.54 - return; 20.55 - isEnclosingClass = true; 20.56 - scan(tree.mods); 20.57 - // type parameter need to be visited with a separate env 20.58 - // scan(tree.typarams); 20.59 - scan(tree.extending); 20.60 - scan(tree.implementing); 20.61 - scan(tree.defs); 20.62 - } 20.63 - 20.64 - private void annotate(final JCTree tree, final List<JCTypeAnnotation> annotations) { 20.65 - annotate.later(new Annotate.Annotator() { 20.66 - public String toString() { 20.67 - return "annotate " + annotations + " onto " + tree; 20.68 - } 20.69 - public void enterAnnotation() { 20.70 - JavaFileObject prev = log.useSource(env.toplevel.sourcefile); 20.71 - try { 20.72 - enterTypeAnnotations(annotations); 20.73 - } finally { 20.74 - log.useSource(prev); 20.75 - } 20.76 - } 20.77 - }); 20.78 - } 20.79 - 20.80 - @Override 20.81 - public void visitAnnotatedType(final JCAnnotatedType tree) { 20.82 - annotate(tree, tree.annotations); 20.83 - super.visitAnnotatedType(tree); 20.84 - } 20.85 - @Override 20.86 - public void visitTypeParameter(final JCTypeParameter tree) { 20.87 - annotate(tree, tree.annotations); 20.88 - super.visitTypeParameter(tree); 20.89 - } 20.90 - @Override 20.91 - public void visitNewArray(final JCNewArray tree) { 20.92 - annotate(tree, tree.annotations); 20.93 - for (List<JCTypeAnnotation> dimAnnos : tree.dimAnnotations) 20.94 - annotate(tree, dimAnnos); 20.95 - super.visitNewArray(tree); 20.96 - } 20.97 - @Override 20.98 - public void visitMethodDef(JCMethodDecl tree) { 20.99 - annotate(tree, tree.receiverAnnotations); 20.100 - super.visitMethodDef(tree); 20.101 - } 20.102 - } 20.103 - 20.104 - 20.105 private Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) { 20.106 Scope baseScope = new Scope.ClassScope(tree.sym, scopeCounter); 20.107 //import already entered local classes into base scope
21.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Wed Jan 05 09:59:01 2011 +0000 21.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Mon Jan 10 14:57:59 2011 -0800 21.3 @@ -1,5 +1,5 @@ 21.4 /* 21.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 21.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 21.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.8 * 21.9 * This code is free software; you can redistribute it and/or modify it 21.10 @@ -69,7 +69,6 @@ 21.11 private boolean allowEnums; 21.12 private Types types; 21.13 private final Resolve resolve; 21.14 - private final TypeAnnotations typeAnnotations; 21.15 21.16 /** 21.17 * Flag to indicate whether or not to generate bridge methods. 21.18 @@ -91,7 +90,6 @@ 21.19 types = Types.instance(context); 21.20 make = TreeMaker.instance(context); 21.21 resolve = Resolve.instance(context); 21.22 - typeAnnotations = TypeAnnotations.instance(context); 21.23 } 21.24 21.25 /** A hashtable mapping bridge methods to the methods they override after 21.26 @@ -445,14 +443,12 @@ 21.27 } 21.28 21.29 public void visitClassDef(JCClassDecl tree) { 21.30 - typeAnnotations.taFillAndLift(tree, true); 21.31 translateClass(tree.sym); 21.32 result = tree; 21.33 } 21.34 21.35 JCMethodDecl currentMethod = null; 21.36 public void visitMethodDef(JCMethodDecl tree) { 21.37 - tree.sym.typeAnnotations = tree.sym.typeAnnotations; 21.38 JCMethodDecl previousMethod = currentMethod; 21.39 try { 21.40 currentMethod = tree;
22.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Wed Jan 05 09:59:01 2011 +0000 22.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Jan 10 14:57:59 2011 -0800 22.3 @@ -1,5 +1,5 @@ 22.4 /* 22.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 22.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 22.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.8 * 22.9 * This code is free software; you can redistribute it and/or modify it 22.10 @@ -207,10 +207,6 @@ 22.11 /** The minor version number of the class file being read. */ 22.12 int minorVersion; 22.13 22.14 - /** Switch: debug output for JSR 308-related operations. 22.15 - */ 22.16 - boolean debugJSR308; 22.17 - 22.18 /** A table to hold the constant pool indices for method parameter 22.19 * names, as given in LocalVariableTable attributes. 22.20 */ 22.21 @@ -297,7 +293,6 @@ 22.22 : null; 22.23 22.24 typevars = new Scope(syms.noSymbol); 22.25 - debugJSR308 = options.isSet("TA:reader"); 22.26 22.27 lintClassfile = Lint.instance(context).isEnabled(LintCategory.CLASSFILE); 22.28 22.29 @@ -1128,20 +1123,6 @@ 22.30 } 22.31 }, 22.32 22.33 - // v51 attributes 22.34 - new AttributeReader(names.RuntimeVisibleTypeAnnotations, V51, CLASS_OR_MEMBER_ATTRIBUTE) { 22.35 - void read(Symbol sym, int attrLen) { 22.36 - attachTypeAnnotations(sym); 22.37 - } 22.38 - }, 22.39 - 22.40 - new AttributeReader(names.RuntimeInvisibleTypeAnnotations, V51, CLASS_OR_MEMBER_ATTRIBUTE) { 22.41 - void read(Symbol sym, int attrLen) { 22.42 - attachTypeAnnotations(sym); 22.43 - } 22.44 - }, 22.45 - 22.46 - 22.47 // The following attributes for a Code attribute are not currently handled 22.48 // StackMapTable 22.49 // SourceDebugExtension 22.50 @@ -1351,17 +1332,6 @@ 22.51 } 22.52 } 22.53 22.54 - void attachTypeAnnotations(final Symbol sym) { 22.55 - int numAttributes = nextChar(); 22.56 - if (numAttributes != 0) { 22.57 - ListBuffer<TypeAnnotationProxy> proxies = 22.58 - ListBuffer.lb(); 22.59 - for (int i = 0; i < numAttributes; i++) 22.60 - proxies.append(readTypeAnnotation()); 22.61 - annotate.later(new TypeAnnotationCompleter(sym, proxies.toList())); 22.62 - } 22.63 - } 22.64 - 22.65 /** Attach the default value for an annotation element. 22.66 */ 22.67 void attachAnnotationDefault(final Symbol sym) { 22.68 @@ -1398,121 +1368,6 @@ 22.69 return new CompoundAnnotationProxy(t, pairs.toList()); 22.70 } 22.71 22.72 - TypeAnnotationProxy readTypeAnnotation() { 22.73 - CompoundAnnotationProxy proxy = readCompoundAnnotation(); 22.74 - TypeAnnotationPosition position = readPosition(); 22.75 - 22.76 - if (debugJSR308) 22.77 - System.out.println("TA: reading: " + proxy + " @ " + position 22.78 - + " in " + log.currentSourceFile()); 22.79 - 22.80 - return new TypeAnnotationProxy(proxy, position); 22.81 - } 22.82 - 22.83 - TypeAnnotationPosition readPosition() { 22.84 - byte tag = nextByte(); 22.85 - 22.86 - if (!TargetType.isValidTargetTypeValue(tag)) 22.87 - throw this.badClassFile("bad.type.annotation.value", tag); 22.88 - 22.89 - TypeAnnotationPosition position = new TypeAnnotationPosition(); 22.90 - TargetType type = TargetType.fromTargetTypeValue(tag); 22.91 - 22.92 - position.type = type; 22.93 - 22.94 - switch (type) { 22.95 - // type case 22.96 - case TYPECAST: 22.97 - case TYPECAST_GENERIC_OR_ARRAY: 22.98 - // object creation 22.99 - case INSTANCEOF: 22.100 - case INSTANCEOF_GENERIC_OR_ARRAY: 22.101 - // new expression 22.102 - case NEW: 22.103 - case NEW_GENERIC_OR_ARRAY: 22.104 - position.offset = nextChar(); 22.105 - break; 22.106 - // local variable 22.107 - case LOCAL_VARIABLE: 22.108 - case LOCAL_VARIABLE_GENERIC_OR_ARRAY: 22.109 - int table_length = nextChar(); 22.110 - position.lvarOffset = new int[table_length]; 22.111 - position.lvarLength = new int[table_length]; 22.112 - position.lvarIndex = new int[table_length]; 22.113 - 22.114 - for (int i = 0; i < table_length; ++i) { 22.115 - position.lvarOffset[i] = nextChar(); 22.116 - position.lvarLength[i] = nextChar(); 22.117 - position.lvarIndex[i] = nextChar(); 22.118 - } 22.119 - break; 22.120 - // method receiver 22.121 - case METHOD_RECEIVER: 22.122 - // Do nothing 22.123 - break; 22.124 - // type parameters 22.125 - case CLASS_TYPE_PARAMETER: 22.126 - case METHOD_TYPE_PARAMETER: 22.127 - position.parameter_index = nextByte(); 22.128 - break; 22.129 - // type parameter bounds 22.130 - case CLASS_TYPE_PARAMETER_BOUND: 22.131 - case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 22.132 - case METHOD_TYPE_PARAMETER_BOUND: 22.133 - case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 22.134 - position.parameter_index = nextByte(); 22.135 - position.bound_index = nextByte(); 22.136 - break; 22.137 - // wildcard 22.138 - case WILDCARD_BOUND: 22.139 - case WILDCARD_BOUND_GENERIC_OR_ARRAY: 22.140 - position.wildcard_position = readPosition(); 22.141 - break; 22.142 - // Class extends and implements clauses 22.143 - case CLASS_EXTENDS: 22.144 - case CLASS_EXTENDS_GENERIC_OR_ARRAY: 22.145 - position.type_index = nextChar(); 22.146 - break; 22.147 - // throws 22.148 - case THROWS: 22.149 - position.type_index = nextChar(); 22.150 - break; 22.151 - case CLASS_LITERAL: 22.152 - case CLASS_LITERAL_GENERIC_OR_ARRAY: 22.153 - position.offset = nextChar(); 22.154 - break; 22.155 - // method parameter: not specified 22.156 - case METHOD_PARAMETER_GENERIC_OR_ARRAY: 22.157 - position.parameter_index = nextByte(); 22.158 - break; 22.159 - // method type argument: wasn't specified 22.160 - case NEW_TYPE_ARGUMENT: 22.161 - case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 22.162 - case METHOD_TYPE_ARGUMENT: 22.163 - case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 22.164 - position.offset = nextChar(); 22.165 - position.type_index = nextByte(); 22.166 - break; 22.167 - // We don't need to worry abut these 22.168 - case METHOD_RETURN_GENERIC_OR_ARRAY: 22.169 - case FIELD_GENERIC_OR_ARRAY: 22.170 - break; 22.171 - case UNKNOWN: 22.172 - break; 22.173 - default: 22.174 - throw new AssertionError("unknown type: " + position); 22.175 - } 22.176 - 22.177 - if (type.hasLocation()) { 22.178 - int len = nextChar(); 22.179 - ListBuffer<Integer> loc = ListBuffer.lb(); 22.180 - for (int i = 0; i < len; i++) 22.181 - loc = loc.append((int)nextByte()); 22.182 - position.location = loc.toList(); 22.183 - } 22.184 - 22.185 - return position; 22.186 - } 22.187 Attribute readAttributeValue() { 22.188 char c = (char) buf[bp++]; 22.189 switch (c) { 22.190 @@ -1825,45 +1680,6 @@ 22.191 } 22.192 } 22.193 22.194 - class TypeAnnotationCompleter extends AnnotationCompleter { 22.195 - 22.196 - List<TypeAnnotationProxy> proxies; 22.197 - 22.198 - TypeAnnotationCompleter(Symbol sym, 22.199 - List<TypeAnnotationProxy> proxies) { 22.200 - super(sym, List.<CompoundAnnotationProxy>nil()); 22.201 - this.proxies = proxies; 22.202 - } 22.203 - 22.204 - List<Attribute.TypeCompound> deproxyTypeCompoundList(List<TypeAnnotationProxy> proxies) { 22.205 - ListBuffer<Attribute.TypeCompound> buf = ListBuffer.lb(); 22.206 - for (TypeAnnotationProxy proxy: proxies) { 22.207 - Attribute.Compound compound = deproxyCompound(proxy.compound); 22.208 - Attribute.TypeCompound typeCompound = new Attribute.TypeCompound(compound, proxy.position); 22.209 - buf.add(typeCompound); 22.210 - } 22.211 - return buf.toList(); 22.212 - } 22.213 - 22.214 - @Override 22.215 - public void enterAnnotation() { 22.216 - JavaFileObject previousClassFile = currentClassFile; 22.217 - try { 22.218 - currentClassFile = classFile; 22.219 - List<Attribute.TypeCompound> newList = deproxyTypeCompoundList(proxies); 22.220 - if (debugJSR308) 22.221 - System.out.println("TA: reading: adding " + newList 22.222 - + " to symbol " + sym + " in " + log.currentSourceFile()); 22.223 - sym.typeAnnotations = ((sym.typeAnnotations == null) 22.224 - ? newList 22.225 - : newList.prependList(sym.typeAnnotations)); 22.226 - 22.227 - } finally { 22.228 - currentClassFile = previousClassFile; 22.229 - } 22.230 - } 22.231 - } 22.232 - 22.233 22.234 /************************************************************************ 22.235 * Reading Symbols
23.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Jan 05 09:59:01 2011 +0000 23.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Mon Jan 10 14:57:59 2011 -0800 23.3 @@ -1,5 +1,5 @@ 23.4 /* 23.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 23.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 23.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 23.8 * 23.9 * This code is free software; you can redistribute it and/or modify it 23.10 @@ -65,10 +65,6 @@ 23.11 23.12 private final Options options; 23.13 23.14 - /** Switch: debugging output for JSR 308-related operations. 23.15 - */ 23.16 - private boolean debugJSR308; 23.17 - 23.18 /** Switch: verbose output. 23.19 */ 23.20 private boolean verbose; 23.21 @@ -180,7 +176,6 @@ 23.22 types = Types.instance(context); 23.23 fileManager = context.get(JavaFileManager.class); 23.24 23.25 - debugJSR308 = options.isSet("TA:writer"); 23.26 verbose = options.isSet(VERBOSE); 23.27 scramble = options.isSet("-scramble"); 23.28 scrambleAll = options.isSet("-scrambleAll"); 23.29 @@ -677,7 +672,6 @@ 23.30 acount++; 23.31 } 23.32 acount += writeJavaAnnotations(sym.getAnnotationMirrors()); 23.33 - acount += writeTypeAnnotations(sym.typeAnnotations); 23.34 return acount; 23.35 } 23.36 23.37 @@ -772,46 +766,6 @@ 23.38 return attrCount; 23.39 } 23.40 23.41 - int writeTypeAnnotations(List<Attribute.TypeCompound> typeAnnos) { 23.42 - if (typeAnnos.isEmpty()) return 0; 23.43 - 23.44 - ListBuffer<Attribute.TypeCompound> visibles = ListBuffer.lb(); 23.45 - ListBuffer<Attribute.TypeCompound> invisibles = ListBuffer.lb(); 23.46 - 23.47 - for (Attribute.TypeCompound tc : typeAnnos) { 23.48 - if (tc.position.type == TargetType.UNKNOWN 23.49 - || !tc.position.emitToClassfile()) 23.50 - continue; 23.51 - switch (types.getRetention(tc)) { 23.52 - case SOURCE: break; 23.53 - case CLASS: invisibles.append(tc); break; 23.54 - case RUNTIME: visibles.append(tc); break; 23.55 - default: ;// /* fail soft */ throw new AssertionError(vis); 23.56 - } 23.57 - } 23.58 - 23.59 - int attrCount = 0; 23.60 - if (visibles.length() != 0) { 23.61 - int attrIndex = writeAttr(names.RuntimeVisibleTypeAnnotations); 23.62 - databuf.appendChar(visibles.length()); 23.63 - for (Attribute.TypeCompound p : visibles) 23.64 - writeTypeAnnotation(p); 23.65 - endAttr(attrIndex); 23.66 - attrCount++; 23.67 - } 23.68 - 23.69 - if (invisibles.length() != 0) { 23.70 - int attrIndex = writeAttr(names.RuntimeInvisibleTypeAnnotations); 23.71 - databuf.appendChar(invisibles.length()); 23.72 - for (Attribute.TypeCompound p : invisibles) 23.73 - writeTypeAnnotation(p); 23.74 - endAttr(attrIndex); 23.75 - attrCount++; 23.76 - } 23.77 - 23.78 - return attrCount; 23.79 - } 23.80 - 23.81 /** A visitor to write an attribute including its leading 23.82 * single-character marker. 23.83 */ 23.84 @@ -888,104 +842,6 @@ 23.85 p.snd.accept(awriter); 23.86 } 23.87 } 23.88 - 23.89 - void writeTypeAnnotation(Attribute.TypeCompound c) { 23.90 - if (debugJSR308) 23.91 - System.out.println("TA: writing " + c + " at " + c.position 23.92 - + " in " + log.currentSourceFile()); 23.93 - writeCompoundAttribute(c); 23.94 - writePosition(c.position); 23.95 - } 23.96 - 23.97 - void writePosition(TypeAnnotationPosition p) { 23.98 - databuf.appendByte(p.type.targetTypeValue()); 23.99 - switch (p.type) { 23.100 - // type case 23.101 - case TYPECAST: 23.102 - case TYPECAST_GENERIC_OR_ARRAY: 23.103 - // object creation 23.104 - case INSTANCEOF: 23.105 - case INSTANCEOF_GENERIC_OR_ARRAY: 23.106 - // new expression 23.107 - case NEW: 23.108 - case NEW_GENERIC_OR_ARRAY: 23.109 - databuf.appendChar(p.offset); 23.110 - break; 23.111 - // local variable 23.112 - case LOCAL_VARIABLE: 23.113 - case LOCAL_VARIABLE_GENERIC_OR_ARRAY: 23.114 - databuf.appendChar(p.lvarOffset.length); // for table length 23.115 - for (int i = 0; i < p.lvarOffset.length; ++i) { 23.116 - databuf.appendChar(p.lvarOffset[i]); 23.117 - databuf.appendChar(p.lvarLength[i]); 23.118 - databuf.appendChar(p.lvarIndex[i]); 23.119 - } 23.120 - break; 23.121 - // method receiver 23.122 - case METHOD_RECEIVER: 23.123 - // Do nothing 23.124 - break; 23.125 - // type parameters 23.126 - case CLASS_TYPE_PARAMETER: 23.127 - case METHOD_TYPE_PARAMETER: 23.128 - databuf.appendByte(p.parameter_index); 23.129 - break; 23.130 - // type parameters bounds 23.131 - case CLASS_TYPE_PARAMETER_BOUND: 23.132 - case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 23.133 - case METHOD_TYPE_PARAMETER_BOUND: 23.134 - case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 23.135 - databuf.appendByte(p.parameter_index); 23.136 - databuf.appendByte(p.bound_index); 23.137 - break; 23.138 - // wildcards 23.139 - case WILDCARD_BOUND: 23.140 - case WILDCARD_BOUND_GENERIC_OR_ARRAY: 23.141 - writePosition(p.wildcard_position); 23.142 - break; 23.143 - // Class extends and implements clauses 23.144 - case CLASS_EXTENDS: 23.145 - case CLASS_EXTENDS_GENERIC_OR_ARRAY: 23.146 - databuf.appendChar(p.type_index); 23.147 - break; 23.148 - // throws 23.149 - case THROWS: 23.150 - databuf.appendChar(p.type_index); 23.151 - break; 23.152 - case CLASS_LITERAL: 23.153 - case CLASS_LITERAL_GENERIC_OR_ARRAY: 23.154 - databuf.appendChar(p.offset); 23.155 - break; 23.156 - // method parameter: not specified 23.157 - case METHOD_PARAMETER_GENERIC_OR_ARRAY: 23.158 - databuf.appendByte(p.parameter_index); 23.159 - break; 23.160 - // method type argument: wasn't specified 23.161 - case NEW_TYPE_ARGUMENT: 23.162 - case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 23.163 - case METHOD_TYPE_ARGUMENT: 23.164 - case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 23.165 - databuf.appendChar(p.offset); 23.166 - databuf.appendByte(p.type_index); 23.167 - break; 23.168 - // We don't need to worry abut these 23.169 - case METHOD_RETURN_GENERIC_OR_ARRAY: 23.170 - case FIELD_GENERIC_OR_ARRAY: 23.171 - break; 23.172 - case UNKNOWN: 23.173 - break; 23.174 - default: 23.175 - throw new AssertionError("unknown position: " + p); 23.176 - } 23.177 - 23.178 - // Append location data for generics/arrays. 23.179 - if (p.type.hasLocation()) { 23.180 - databuf.appendChar(p.location.size()); 23.181 - for (int i : p.location) 23.182 - databuf.appendByte((byte)i); 23.183 - } 23.184 - } 23.185 - 23.186 /********************************************************************** 23.187 * Writing Objects 23.188 **********************************************************************/ 23.189 @@ -1698,7 +1554,6 @@ 23.190 23.191 acount += writeFlagAttrs(c.flags()); 23.192 acount += writeJavaAnnotations(c.getAnnotationMirrors()); 23.193 - acount += writeTypeAnnotations(c.typeAnnotations); 23.194 acount += writeEnclosingMethodAttribute(c); 23.195 23.196 poolbuf.appendInt(JAVA_MAGIC);
24.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Wed Jan 05 09:59:01 2011 +0000 24.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Mon Jan 10 14:57:59 2011 -0800 24.3 @@ -1,5 +1,5 @@ 24.4 /* 24.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 24.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 24.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 24.8 * 24.9 * This code is free software; you can redistribute it and/or modify it 24.10 @@ -1912,29 +1912,12 @@ 24.11 if (length < Character.MAX_VALUE) { 24.12 v.length = length; 24.13 putVar(v); 24.14 - fillLocalVarPosition(v); 24.15 } 24.16 } 24.17 } 24.18 state.defined.excl(adr); 24.19 } 24.20 24.21 - private void fillLocalVarPosition(LocalVar lv) { 24.22 - if (lv == null || lv.sym == null 24.23 - || lv.sym.typeAnnotations == null) 24.24 - return; 24.25 - for (Attribute.TypeCompound ta : lv.sym.typeAnnotations) { 24.26 - TypeAnnotationPosition p = ta.position; 24.27 - while (p != null) { 24.28 - p.lvarOffset = new int[] { (int)lv.start_pc }; 24.29 - p.lvarLength = new int[] { (int)lv.length }; 24.30 - p.lvarIndex = new int[] { (int)lv.reg }; 24.31 - p.isValidOffset = true; 24.32 - p = p.wildcard_position; 24.33 - } 24.34 - } 24.35 - } 24.36 - 24.37 /** Put a live variable range into the buffer to be output to the 24.38 * class file. 24.39 */
25.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Jan 05 09:59:01 2011 +0000 25.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Mon Jan 10 14:57:59 2011 -0800 25.3 @@ -1,5 +1,5 @@ 25.4 /* 25.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 25.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 25.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.8 * 25.9 * This code is free software; you can redistribute it and/or modify it 25.10 @@ -1682,7 +1682,6 @@ 25.11 *************************************************************************/ 25.12 25.13 public void visitApply(JCMethodInvocation tree) { 25.14 - setTypeAnnotationPositions(tree.pos); 25.15 // Generate code for method. 25.16 Item m = genExpr(tree.meth, methodType); 25.17 // Generate code for all arguments, where the expected types are 25.18 @@ -1718,48 +1717,10 @@ 25.19 result = items.makeStackItem(pt); 25.20 } 25.21 25.22 - private void setTypeAnnotationPositions(int treePos) { 25.23 - MethodSymbol meth = code.meth; 25.24 - 25.25 - for (Attribute.TypeCompound ta : meth.typeAnnotations) { 25.26 - if (ta.position.pos == treePos) { 25.27 - ta.position.offset = code.cp; 25.28 - ta.position.lvarOffset = new int[] { code.cp }; 25.29 - ta.position.isValidOffset = true; 25.30 - } 25.31 - } 25.32 - 25.33 - if (code.meth.getKind() != ElementKind.CONSTRUCTOR 25.34 - && code.meth.getKind() != ElementKind.STATIC_INIT) 25.35 - return; 25.36 - 25.37 - for (Attribute.TypeCompound ta : meth.owner.typeAnnotations) { 25.38 - if (ta.position.pos == treePos) { 25.39 - ta.position.offset = code.cp; 25.40 - ta.position.lvarOffset = new int[] { code.cp }; 25.41 - ta.position.isValidOffset = true; 25.42 - } 25.43 - } 25.44 - 25.45 - ClassSymbol clazz = meth.enclClass(); 25.46 - for (Symbol s : new com.sun.tools.javac.model.FilteredMemberList(clazz.members())) { 25.47 - if (!s.getKind().isField()) 25.48 - continue; 25.49 - for (Attribute.TypeCompound ta : s.typeAnnotations) { 25.50 - if (ta.position.pos == treePos) { 25.51 - ta.position.offset = code.cp; 25.52 - ta.position.lvarOffset = new int[] { code.cp }; 25.53 - ta.position.isValidOffset = true; 25.54 - } 25.55 - } 25.56 - } 25.57 - } 25.58 - 25.59 public void visitNewClass(JCNewClass tree) { 25.60 // Enclosing instances or anonymous classes should have been eliminated 25.61 // by now. 25.62 assert tree.encl == null && tree.def == null; 25.63 - setTypeAnnotationPositions(tree.pos); 25.64 25.65 code.emitop2(new_, makeRef(tree.pos(), tree.type)); 25.66 code.emitop0(dup); 25.67 @@ -1774,7 +1735,6 @@ 25.68 } 25.69 25.70 public void visitNewArray(JCNewArray tree) { 25.71 - setTypeAnnotationPositions(tree.pos); 25.72 25.73 if (tree.elems != null) { 25.74 Type elemtype = types.elemtype(tree.type); 25.75 @@ -2104,7 +2064,6 @@ 25.76 } 25.77 25.78 public void visitTypeCast(JCTypeCast tree) { 25.79 - setTypeAnnotationPositions(tree.pos); 25.80 result = genExpr(tree.expr, tree.clazz.type).load(); 25.81 // Additional code is only needed if we cast to a reference type 25.82 // which is not statically a supertype of the expression's type. 25.83 @@ -2121,8 +2080,6 @@ 25.84 } 25.85 25.86 public void visitTypeTest(JCInstanceOf tree) { 25.87 - setTypeAnnotationPositions(tree.pos); 25.88 - 25.89 genExpr(tree.expr, tree.expr.type).load(); 25.90 code.emitop2(instanceof_, makeRef(tree.pos(), tree.clazz.type)); 25.91 result = items.makeStackItem(syms.booleanType); 25.92 @@ -2164,15 +2121,9 @@ 25.93 25.94 if (tree.name == names._class) { 25.95 assert target.hasClassLiterals(); 25.96 - setTypeAnnotationPositions(tree.pos); 25.97 code.emitop2(ldc2, makeRef(tree.pos(), tree.selected.type)); 25.98 result = items.makeStackItem(pt); 25.99 return; 25.100 - } else if (tree.name == names.TYPE) { 25.101 - // Set the annotation positions for primitive class literals 25.102 - // (e.g. int.class) which have been converted to TYPE field 25.103 - // access on the corresponding boxed type (e.g. Integer.TYPE). 25.104 - setTypeAnnotationPositions(tree.pos); 25.105 } 25.106 25.107 Symbol ssym = TreeInfo.symbol(tree.selected);
26.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Wed Jan 05 09:59:01 2011 +0000 26.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Mon Jan 10 14:57:59 2011 -0800 26.3 @@ -1,5 +1,5 @@ 26.4 /* 26.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 26.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 26.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 26.8 * 26.9 * This code is free software; you can redistribute it and/or modify it 26.10 @@ -49,7 +49,6 @@ 26.11 import javax.tools.JavaFileObject; 26.12 import javax.tools.DiagnosticListener; 26.13 26.14 -//308 import com.sun.source.util.AbstractTypeProcessor; 26.15 import com.sun.source.util.TaskEvent; 26.16 import com.sun.source.util.TaskListener; 26.17 import com.sun.tools.javac.api.JavacTaskImpl; 26.18 @@ -712,7 +711,6 @@ 26.19 } 26.20 26.21 if (matchedNames.size() > 0 || ps.contributed) { 26.22 -//308 foundTypeProcessors = foundTypeProcessors || (ps.processor instanceof AbstractTypeProcessor); 26.23 boolean processingResult = callProcessor(ps.processor, typeElements, renv); 26.24 ps.contributed = true; 26.25 ps.removeSupportedOptions(unmatchedProcessorOptions);
27.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jan 05 09:59:01 2011 +0000 27.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Jan 10 14:57:59 2011 -0800 27.3 @@ -1,5 +1,5 @@ 27.4 # 27.5 -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 27.6 +# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 27.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 27.8 # 27.9 # This code is free software; you can redistribute it and/or modify it 27.10 @@ -971,8 +971,6 @@ 27.11 bad constant pool tag: {0} at {1} 27.12 compiler.misc.bad.signature=\ 27.13 bad signature: {0} 27.14 -compiler.misc.bad.type.annotation.value=\ 27.15 - bad type annotation target type value: {0} 27.16 compiler.misc.class.file.wrong.class=\ 27.17 class file contains wrong class: {0} 27.18 compiler.misc.class.file.not.found=\
28.1 --- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java Wed Jan 05 09:59:01 2011 +0000 28.2 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java Mon Jan 10 14:57:59 2011 -0800 28.3 @@ -1,5 +1,5 @@ 28.4 /* 28.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 28.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 28.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 28.8 * 28.9 * This code is free software; you can redistribute it and/or modify it 28.10 @@ -640,7 +640,6 @@ 28.11 public JCExpression restype; 28.12 public List<JCTypeParameter> typarams; 28.13 public List<JCVariableDecl> params; 28.14 - public List<JCTypeAnnotation> receiverAnnotations; 28.15 public List<JCExpression> thrown; 28.16 public JCBlock body; 28.17 public JCExpression defaultValue; // for annotation types 28.18 @@ -650,7 +649,6 @@ 28.19 JCExpression restype, 28.20 List<JCTypeParameter> typarams, 28.21 List<JCVariableDecl> params, 28.22 - List<JCTypeAnnotation> receiver, 28.23 List<JCExpression> thrown, 28.24 JCBlock body, 28.25 JCExpression defaultValue, 28.26 @@ -661,7 +659,6 @@ 28.27 this.restype = restype; 28.28 this.typarams = typarams; 28.29 this.params = params; 28.30 - this.receiverAnnotations = (receiver != null ? receiver : List.<JCTypeAnnotation>nil()); 28.31 this.thrown = thrown; 28.32 this.body = body; 28.33 this.defaultValue = defaultValue; 28.34 @@ -680,7 +677,6 @@ 28.35 public List<JCVariableDecl> getParameters() { 28.36 return params; 28.37 } 28.38 - public List<JCTypeAnnotation> getReceiverAnnotations() { return receiverAnnotations; } 28.39 public List<JCExpression> getThrows() { 28.40 return thrown; 28.41 } 28.42 @@ -1402,8 +1398,6 @@ 28.43 public static class JCNewArray extends JCExpression implements NewArrayTree { 28.44 public JCExpression elemtype; 28.45 public List<JCExpression> dims; 28.46 - public List<JCTypeAnnotation> annotations; 28.47 - public List<List<JCTypeAnnotation>> dimAnnotations; 28.48 public List<JCExpression> elems; 28.49 protected JCNewArray(JCExpression elemtype, 28.50 List<JCExpression> dims, 28.51 @@ -1411,8 +1405,6 @@ 28.52 { 28.53 this.elemtype = elemtype; 28.54 this.dims = dims; 28.55 - this.annotations = List.nil(); 28.56 - this.dimAnnotations = List.nil(); 28.57 this.elems = elems; 28.58 } 28.59 @Override 28.60 @@ -1923,11 +1915,9 @@ 28.61 public static class JCTypeParameter extends JCTree implements TypeParameterTree { 28.62 public Name name; 28.63 public List<JCExpression> bounds; 28.64 - public List<JCTypeAnnotation> annotations; 28.65 - protected JCTypeParameter(Name name, List<JCExpression> bounds, List<JCTypeAnnotation> annotations) { 28.66 + protected JCTypeParameter(Name name, List<JCExpression> bounds) { 28.67 this.name = name; 28.68 this.bounds = bounds; 28.69 - this.annotations = annotations; 28.70 } 28.71 @Override 28.72 public void accept(Visitor v) { v.visitTypeParameter(this); } 28.73 @@ -1937,9 +1927,6 @@ 28.74 public List<JCExpression> getBounds() { 28.75 return bounds; 28.76 } 28.77 - public List<JCTypeAnnotation> getAnnotations() { 28.78 - return annotations; 28.79 - } 28.80 @Override 28.81 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 28.82 return v.visitTypeParameter(this, d); 28.83 @@ -2030,16 +2017,6 @@ 28.84 } 28.85 } 28.86 28.87 - public static class JCTypeAnnotation extends JCAnnotation { 28.88 - public TypeAnnotationPosition annotation_position; 28.89 - public Attribute.TypeCompound attribute_field; 28.90 - 28.91 - protected JCTypeAnnotation(JCTree annotationType, List<JCExpression> args) { 28.92 - super(annotationType, args); 28.93 - this.annotation_position = new TypeAnnotationPosition(); 28.94 - } 28.95 - } 28.96 - 28.97 public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree { 28.98 public long flags; 28.99 public List<JCAnnotation> annotations; 28.100 @@ -2067,40 +2044,6 @@ 28.101 } 28.102 } 28.103 28.104 - public static class JCAnnotatedType extends JCExpression 28.105 -//308 implements com.sun.source.tree.AnnotatedTypeTree 28.106 - { 28.107 - public List<JCTypeAnnotation> annotations; 28.108 - public JCExpression underlyingType; 28.109 - protected JCAnnotatedType(List<JCTypeAnnotation> annotations, JCExpression underlyingType) { 28.110 - throw new UnsupportedOperationException(); 28.111 -//308 this.annotations = annotations; 28.112 -//308 this.underlyingType = underlyingType; 28.113 - } 28.114 - @Override 28.115 - public void accept(Visitor v) { v.visitAnnotatedType(this); } 28.116 - 28.117 - public Kind getKind() { 28.118 - throw new UnsupportedOperationException(); 28.119 -//308 return Kind.ANNOTATED_TYPE; 28.120 - } 28.121 - public List<JCTypeAnnotation> getAnnotations() { 28.122 - return annotations; 28.123 - } 28.124 - public JCExpression getUnderlyingType() { 28.125 - return underlyingType; 28.126 - } 28.127 - @Override 28.128 - public <R,D> R accept(TreeVisitor<R,D> v, D d) { 28.129 - throw new UnsupportedOperationException(); 28.130 -//308 return v.visitAnnotatedType(this, d); 28.131 - } 28.132 - @Override 28.133 - public int getTag() { 28.134 - return ANNOTATED_TYPE; 28.135 - } 28.136 - } 28.137 - 28.138 public static class JCErroneous extends JCExpression 28.139 implements com.sun.source.tree.ErroneousTree { 28.140 public List<? extends JCTree> errs; 28.141 @@ -2168,7 +2111,6 @@ 28.142 JCExpression restype, 28.143 List<JCTypeParameter> typarams, 28.144 List<JCVariableDecl> params, 28.145 - List<JCTypeAnnotation> receiver, 28.146 List<JCExpression> thrown, 28.147 JCBlock body, 28.148 JCExpression defaultValue); 28.149 @@ -2290,7 +2232,6 @@ 28.150 public void visitTypeBoundKind(TypeBoundKind that) { visitTree(that); } 28.151 public void visitAnnotation(JCAnnotation that) { visitTree(that); } 28.152 public void visitModifiers(JCModifiers that) { visitTree(that); } 28.153 - public void visitAnnotatedType(JCAnnotatedType that) { visitTree(that); } 28.154 public void visitErroneous(JCErroneous that) { visitTree(that); } 28.155 public void visitLetExpr(LetExpr that) { visitTree(that); } 28.156
29.1 --- a/src/share/classes/com/sun/tools/javac/tree/Pretty.java Wed Jan 05 09:59:01 2011 +0000 29.2 +++ b/src/share/classes/com/sun/tools/javac/tree/Pretty.java Mon Jan 10 14:57:59 2011 -0800 29.3 @@ -1,5 +1,5 @@ 29.4 /* 29.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 29.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 29.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.8 * 29.9 * This code is free software; you can redistribute it and/or modify it 29.10 @@ -224,15 +224,6 @@ 29.11 } 29.12 } 29.13 29.14 - public void printTypeAnnotations(List<JCTypeAnnotation> trees) throws IOException { 29.15 - if (trees.nonEmpty()) 29.16 - print(" "); 29.17 - for (List<JCTypeAnnotation> l = trees; l.nonEmpty(); l = l.tail) { 29.18 - printExpr(l.head); 29.19 - print(" "); 29.20 - } 29.21 - } 29.22 - 29.23 /** Print documentation comment, if it exists 29.24 * @param tree The tree for which a documentation comment should be printed. 29.25 */ 29.26 @@ -890,33 +881,21 @@ 29.27 try { 29.28 if (tree.elemtype != null) { 29.29 print("new "); 29.30 - printTypeAnnotations(tree.annotations); 29.31 JCTree elem = tree.elemtype; 29.32 - printBaseElementType(elem); 29.33 - boolean isElemAnnoType = elem instanceof JCAnnotatedType; 29.34 - int i = 0; 29.35 - List<List<JCTypeAnnotation>> da = tree.dimAnnotations; 29.36 + if (elem.getTag() == JCTree.TYPEARRAY) 29.37 + printBaseElementType((JCArrayTypeTree) elem); 29.38 + else 29.39 + printExpr(elem); 29.40 for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) { 29.41 - if (da.size() > i) { 29.42 - printTypeAnnotations(da.get(i)); 29.43 - } 29.44 print("["); 29.45 - i++; 29.46 printExpr(l.head); 29.47 print("]"); 29.48 } 29.49 - if (tree.elems != null) { 29.50 - if (isElemAnnoType) { 29.51 - printTypeAnnotations(((JCAnnotatedType)tree.elemtype).annotations); 29.52 - } 29.53 - print("[]"); 29.54 - } 29.55 - if (isElemAnnoType) 29.56 - elem = ((JCAnnotatedType)elem).underlyingType; 29.57 if (elem instanceof JCArrayTypeTree) 29.58 printBrackets((JCArrayTypeTree) elem); 29.59 } 29.60 if (tree.elems != null) { 29.61 + if (tree.elemtype != null) print("[]"); 29.62 print("{"); 29.63 printExprs(tree.elems); 29.64 print("}"); 29.65 @@ -1173,11 +1152,6 @@ 29.66 JCTree elem; 29.67 while (true) { 29.68 elem = tree.elemtype; 29.69 - if (elem.getTag() == JCTree.ANNOTATED_TYPE) { 29.70 - JCAnnotatedType atype = (JCAnnotatedType) elem; 29.71 - printTypeAnnotations(atype.annotations); 29.72 - elem = atype.underlyingType; 29.73 - } 29.74 print("[]"); 29.75 if (elem.getTag() != JCTree.TYPEARRAY) break; 29.76 tree = (JCArrayTypeTree) elem; 29.77 @@ -1272,15 +1246,6 @@ 29.78 } 29.79 } 29.80 29.81 - public void visitAnnotatedType(JCAnnotatedType tree) { 29.82 - try { 29.83 - printTypeAnnotations(tree.annotations); 29.84 - printExpr(tree.underlyingType); 29.85 - } catch (IOException e) { 29.86 - throw new UncheckedIOException(e); 29.87 - } 29.88 - } 29.89 - 29.90 public void visitTree(JCTree tree) { 29.91 try { 29.92 print("(UNKNOWN: " + tree + ")");
30.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Wed Jan 05 09:59:01 2011 +0000 30.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Mon Jan 10 14:57:59 2011 -0800 30.3 @@ -1,5 +1,5 @@ 30.4 /* 30.5 - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 30.6 + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 30.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 30.8 * 30.9 * This code is free software; you can redistribute it and/or modify it 30.10 @@ -71,13 +71,6 @@ 30.11 return lb.toList(); 30.12 } 30.13 30.14 -//308 public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) { 30.15 -//308 JCAnnotatedType t = (JCAnnotatedType) node; 30.16 -//308 List<JCTypeAnnotation> annotations = copy(t.annotations, p); 30.17 -//308 JCExpression underlyingType = copy(t.underlyingType, p); 30.18 -//308 return M.at(t.pos).AnnotatedType(annotations, underlyingType); 30.19 -//308 } 30.20 - 30.21 public JCTree visitAnnotation(AnnotationTree node, P p) { 30.22 JCAnnotation t = (JCAnnotation) node; 30.23 JCTree annotationType = copy(t.annotationType, p); 30.24 @@ -240,11 +233,10 @@ 30.25 JCExpression restype = copy(t.restype, p); 30.26 List<JCTypeParameter> typarams = copy(t.typarams, p); 30.27 List<JCVariableDecl> params = copy(t.params, p); 30.28 - List<JCTypeAnnotation> receiver = copy(t.receiverAnnotations, p); 30.29 List<JCExpression> thrown = copy(t.thrown, p); 30.30 JCBlock body = copy(t.body, p); 30.31 JCExpression defaultValue = copy(t.defaultValue, p); 30.32 - return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, params, receiver, thrown, body, defaultValue); 30.33 + return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, params, thrown, body, defaultValue); 30.34 } 30.35 30.36 public JCTree visitMethodInvocation(MethodInvocationTree node, P p) { 30.37 @@ -372,9 +364,8 @@ 30.38 30.39 public JCTree visitTypeParameter(TypeParameterTree node, P p) { 30.40 JCTypeParameter t = (JCTypeParameter) node; 30.41 - List<JCTypeAnnotation> annos = copy(t.annotations, p); 30.42 List<JCExpression> bounds = copy(t.bounds, p); 30.43 - return M.at(t.pos).TypeParameter(t.name, bounds, annos); 30.44 + return M.at(t.pos).TypeParameter(t.name, bounds); 30.45 } 30.46 30.47 public JCTree visitInstanceOf(InstanceOfTree node, P p) {
31.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Jan 05 09:59:01 2011 +0000 31.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Mon Jan 10 14:57:59 2011 -0800 31.3 @@ -1,5 +1,5 @@ 31.4 /* 31.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 31.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 31.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.8 * 31.9 * This code is free software; you can redistribute it and/or modify it 31.10 @@ -311,12 +311,6 @@ 31.11 case(JCTree.POSTINC): 31.12 case(JCTree.POSTDEC): 31.13 return getStartPos(((JCUnary) tree).arg); 31.14 - case(JCTree.ANNOTATED_TYPE): { 31.15 - JCAnnotatedType node = (JCAnnotatedType) tree; 31.16 - if (node.annotations.nonEmpty()) 31.17 - return getStartPos(node.annotations.head); 31.18 - return getStartPos(node.underlyingType); 31.19 - } 31.20 case(JCTree.NEWCLASS): { 31.21 JCNewClass node = (JCNewClass)tree; 31.22 if (node.encl != null) 31.23 @@ -420,8 +414,6 @@ 31.24 return getEndPos(((JCUnary) tree).arg, endPositions); 31.25 case(JCTree.WHILELOOP): 31.26 return getEndPos(((JCWhileLoop) tree).body, endPositions); 31.27 - case(JCTree.ANNOTATED_TYPE): 31.28 - return getEndPos(((JCAnnotatedType) tree).underlyingType, endPositions); 31.29 case(JCTree.ERRONEOUS): { 31.30 JCErroneous node = (JCErroneous)tree; 31.31 if (node.errs != null && node.errs.nonEmpty()) 31.32 @@ -909,8 +901,6 @@ 31.33 */ 31.34 public static JCExpression typeIn(JCExpression tree) { 31.35 switch (tree.getTag()) { 31.36 - case JCTree.ANNOTATED_TYPE: 31.37 - return ((JCAnnotatedType)tree).underlyingType; 31.38 case JCTree.IDENT: /* simple names */ 31.39 case JCTree.TYPEIDENT: /* primitive name */ 31.40 case JCTree.SELECT: /* qualified name */ 31.41 @@ -930,8 +920,6 @@ 31.42 return innermostType(((JCArrayTypeTree)type).elemtype); 31.43 case JCTree.WILDCARD: 31.44 return innermostType(((JCWildcard)type).inner); 31.45 - case JCTree.ANNOTATED_TYPE: 31.46 - return innermostType(((JCAnnotatedType)type).underlyingType); 31.47 default: 31.48 return type; 31.49 }
32.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Wed Jan 05 09:59:01 2011 +0000 32.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Mon Jan 10 14:57:59 2011 -0800 32.3 @@ -1,5 +1,5 @@ 32.4 /* 32.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 32.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 32.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 32.8 * 32.9 * This code is free software; you can redistribute it and/or modify it 32.10 @@ -169,27 +169,11 @@ 32.11 List<JCExpression> thrown, 32.12 JCBlock body, 32.13 JCExpression defaultValue) { 32.14 - return MethodDef( 32.15 - mods, name, restype, typarams, params, 32.16 - null, thrown, body, defaultValue); 32.17 - } 32.18 - 32.19 - public JCMethodDecl MethodDef(JCModifiers mods, 32.20 - Name name, 32.21 - JCExpression restype, 32.22 - List<JCTypeParameter> typarams, 32.23 - List<JCVariableDecl> params, 32.24 - List<JCTypeAnnotation> receiver, 32.25 - List<JCExpression> thrown, 32.26 - JCBlock body, 32.27 - JCExpression defaultValue) 32.28 - { 32.29 JCMethodDecl tree = new JCMethodDecl(mods, 32.30 name, 32.31 restype, 32.32 typarams, 32.33 params, 32.34 - receiver, 32.35 thrown, 32.36 body, 32.37 defaultValue, 32.38 @@ -458,11 +442,7 @@ 32.39 } 32.40 32.41 public JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds) { 32.42 - return TypeParameter(name, bounds, List.<JCTypeAnnotation>nil()); 32.43 - } 32.44 - 32.45 - public JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds, List<JCTypeAnnotation> annos) { 32.46 - JCTypeParameter tree = new JCTypeParameter(name, bounds, annos); 32.47 + JCTypeParameter tree = new JCTypeParameter(name, bounds); 32.48 tree.pos = pos; 32.49 return tree; 32.50 } 32.51 @@ -485,12 +465,6 @@ 32.52 return tree; 32.53 } 32.54 32.55 - public JCTypeAnnotation TypeAnnotation(JCTree annotationType, List<JCExpression> args) { 32.56 - JCTypeAnnotation tree = new JCTypeAnnotation(annotationType, args); 32.57 - tree.pos = pos; 32.58 - return tree; 32.59 - } 32.60 - 32.61 public JCModifiers Modifiers(long flags, List<JCAnnotation> annotations) { 32.62 JCModifiers tree = new JCModifiers(flags, annotations); 32.63 boolean noFlags = (flags & (Flags.ModifierFlags | Flags.ANNOTATION)) == 0; 32.64 @@ -502,12 +476,6 @@ 32.65 return Modifiers(flags, List.<JCAnnotation>nil()); 32.66 } 32.67 32.68 - public JCAnnotatedType AnnotatedType(List<JCTypeAnnotation> annotations, JCExpression underlyingType) { 32.69 - JCAnnotatedType tree = new JCAnnotatedType(annotations, underlyingType); 32.70 - tree.pos = pos; 32.71 - return tree; 32.72 - } 32.73 - 32.74 public JCErroneous Erroneous() { 32.75 return Erroneous(List.<JCTree>nil()); 32.76 } 32.77 @@ -821,7 +789,6 @@ 32.78 Type(mtype.getReturnType()), 32.79 TypeParams(mtype.getTypeArguments()), 32.80 Params(mtype.getParameterTypes(), m), 32.81 - null, 32.82 Types(mtype.getThrownTypes()), 32.83 body, 32.84 null,
33.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java Wed Jan 05 09:59:01 2011 +0000 33.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java Mon Jan 10 14:57:59 2011 -0800 33.3 @@ -1,5 +1,5 @@ 33.4 /* 33.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 33.6 + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 33.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 33.8 * 33.9 * This code is free software; you can redistribute it and/or modify it 33.10 @@ -85,7 +85,6 @@ 33.11 scan(tree.restype); 33.12 scan(tree.typarams); 33.13 scan(tree.params); 33.14 - scan(tree.receiverAnnotations); 33.15 scan(tree.thrown); 33.16 scan(tree.defaultValue); 33.17 scan(tree.body); 33.18 @@ -208,11 +207,8 @@ 33.19 } 33.20 33.21 public void visitNewArray(JCNewArray tree) { 33.22 - scan(tree.annotations); 33.23 scan(tree.elemtype); 33.24 scan(tree.dims); 33.25 - for (List<JCTypeAnnotation> annos : tree.dimAnnotations) 33.26 - scan(annos); 33.27 scan(tree.elems); 33.28 } 33.29 33.30 @@ -281,7 +277,6 @@ 33.31 } 33.32 33.33 public void visitTypeParameter(JCTypeParameter tree) { 33.34 - scan(tree.annotations); 33.35 scan(tree.bounds); 33.36 } 33.37 33.38 @@ -305,11 +300,6 @@ 33.39 scan(tree.args); 33.40 } 33.41 33.42 - public void visitAnnotatedType(JCAnnotatedType tree) { 33.43 - scan(tree.annotations); 33.44 - scan(tree.underlyingType); 33.45 - } 33.46 - 33.47 public void visitErroneous(JCErroneous tree) { 33.48 } 33.49
34.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Wed Jan 05 09:59:01 2011 +0000 34.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Mon Jan 10 14:57:59 2011 -0800 34.3 @@ -1,5 +1,5 @@ 34.4 /* 34.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 34.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 34.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 34.8 * 34.9 * This code is free software; you can redistribute it and/or modify it 34.10 @@ -283,11 +283,6 @@ 34.11 } 34.12 34.13 public void visitNewArray(JCNewArray tree) { 34.14 - tree.annotations = translate(tree.annotations); 34.15 - List<List<JCTypeAnnotation>> dimAnnos = List.nil(); 34.16 - for (List<JCTypeAnnotation> origDimAnnos : tree.dimAnnotations) 34.17 - dimAnnos = dimAnnos.append(translate(origDimAnnos)); 34.18 - tree.dimAnnotations = dimAnnos; 34.19 tree.elemtype = translate(tree.elemtype); 34.20 tree.dims = translate(tree.dims); 34.21 tree.elems = translate(tree.elems); 34.22 @@ -374,7 +369,6 @@ 34.23 } 34.24 34.25 public void visitTypeParameter(JCTypeParameter tree) { 34.26 - tree.annotations = translate(tree.annotations); 34.27 tree.bounds = translate(tree.bounds); 34.28 result = tree; 34.29 } 34.30 @@ -412,12 +406,6 @@ 34.31 result = tree; 34.32 } 34.33 34.34 - public void visitAnnotatedType(JCAnnotatedType tree) { 34.35 - tree.annotations = translate(tree.annotations); 34.36 - tree.underlyingType = translate(tree.underlyingType); 34.37 - result = tree; 34.38 - } 34.39 - 34.40 public void visitTree(JCTree tree) { 34.41 throw new AssertionError(tree); 34.42 }
35.1 --- a/src/share/classes/com/sun/tools/javap/AnnotationWriter.java Wed Jan 05 09:59:01 2011 +0000 35.2 +++ b/src/share/classes/com/sun/tools/javap/AnnotationWriter.java Mon Jan 10 14:57:59 2011 -0800 35.3 @@ -1,5 +1,5 @@ 35.4 /* 35.5 - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 35.6 + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 35.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 35.8 * 35.9 * This code is free software; you can redistribute it and/or modify it 35.10 @@ -26,7 +26,6 @@ 35.11 package com.sun.tools.javap; 35.12 35.13 import com.sun.tools.classfile.Annotation; 35.14 -import com.sun.tools.classfile.ExtendedAnnotation; 35.15 import com.sun.tools.classfile.Annotation.Annotation_element_value; 35.16 import com.sun.tools.classfile.Annotation.Array_element_value; 35.17 import com.sun.tools.classfile.Annotation.Class_element_value; 35.18 @@ -77,129 +76,6 @@ 35.19 print(")"); 35.20 } 35.21 35.22 - public void write(ExtendedAnnotation annot) { 35.23 - write(annot, true, false); 35.24 - } 35.25 - 35.26 - public void write(ExtendedAnnotation annot, boolean showOffsets, boolean resolveIndices) { 35.27 - write(annot.annotation, resolveIndices); 35.28 - print(": "); 35.29 - write(annot.position, showOffsets); 35.30 - } 35.31 - 35.32 - public void write(ExtendedAnnotation.Position pos, boolean showOffsets) { 35.33 - print(pos.type); 35.34 - 35.35 - switch (pos.type) { 35.36 - // type case 35.37 - case TYPECAST: 35.38 - case TYPECAST_GENERIC_OR_ARRAY: 35.39 - // object creation 35.40 - case INSTANCEOF: 35.41 - case INSTANCEOF_GENERIC_OR_ARRAY: 35.42 - // new expression 35.43 - case NEW: 35.44 - case NEW_GENERIC_OR_ARRAY: 35.45 - case NEW_TYPE_ARGUMENT: 35.46 - case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 35.47 - if (showOffsets) { 35.48 - print(", offset="); 35.49 - print(pos.offset); 35.50 - } 35.51 - break; 35.52 - // local variable 35.53 - case LOCAL_VARIABLE: 35.54 - case LOCAL_VARIABLE_GENERIC_OR_ARRAY: 35.55 - print(", {"); 35.56 - for (int i = 0; i < pos.lvarOffset.length; ++i) { 35.57 - if (i != 0) print("; "); 35.58 - if (showOffsets) { 35.59 - print(", start_pc="); 35.60 - print(pos.lvarOffset[i]); 35.61 - } 35.62 - print(", length="); 35.63 - print(pos.lvarLength[i]); 35.64 - print(", index="); 35.65 - print(pos.lvarIndex[i]); 35.66 - } 35.67 - print("}"); 35.68 - break; 35.69 - // method receiver 35.70 - case METHOD_RECEIVER: 35.71 - // Do nothing 35.72 - break; 35.73 - // type parameters 35.74 - case CLASS_TYPE_PARAMETER: 35.75 - case METHOD_TYPE_PARAMETER: 35.76 - print(", param_index="); 35.77 - print(pos.parameter_index); 35.78 - break; 35.79 - // type parameters bound 35.80 - case CLASS_TYPE_PARAMETER_BOUND: 35.81 - case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 35.82 - case METHOD_TYPE_PARAMETER_BOUND: 35.83 - case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: 35.84 - print(", param_index="); 35.85 - print(pos.parameter_index); 35.86 - print(", bound_index="); 35.87 - print(pos.bound_index); 35.88 - break; 35.89 - // wildcard 35.90 - case WILDCARD_BOUND: 35.91 - case WILDCARD_BOUND_GENERIC_OR_ARRAY: 35.92 - print(", wild_card="); 35.93 - print(pos.wildcard_position); 35.94 - break; 35.95 - // Class extends and implements clauses 35.96 - case CLASS_EXTENDS: 35.97 - case CLASS_EXTENDS_GENERIC_OR_ARRAY: 35.98 - print(", type_index="); 35.99 - print(pos.type_index); 35.100 - break; 35.101 - // throws 35.102 - case THROWS: 35.103 - print(", type_index="); 35.104 - print(pos.type_index); 35.105 - break; 35.106 - case CLASS_LITERAL: 35.107 - case CLASS_LITERAL_GENERIC_OR_ARRAY: 35.108 - if (showOffsets) { 35.109 - print(", offset="); 35.110 - print(pos.offset); 35.111 - } 35.112 - break; 35.113 - // method parameter: not specified 35.114 - case METHOD_PARAMETER_GENERIC_OR_ARRAY: 35.115 - print(", param_index="); 35.116 - print(pos.parameter_index); 35.117 - break; 35.118 - // method type argument: wasn't specified 35.119 - case METHOD_TYPE_ARGUMENT: 35.120 - case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: 35.121 - if (showOffsets) { 35.122 - print(", offset="); 35.123 - print(pos.offset); 35.124 - } 35.125 - print(", type_index="); 35.126 - print(pos.type_index); 35.127 - break; 35.128 - // We don't need to worry abut these 35.129 - case METHOD_RETURN_GENERIC_OR_ARRAY: 35.130 - case FIELD_GENERIC_OR_ARRAY: 35.131 - break; 35.132 - case UNKNOWN: 35.133 - break; 35.134 - default: 35.135 - throw new AssertionError("unknown type: " + pos.type); 35.136 - } 35.137 - 35.138 - // Append location data for generics/arrays. 35.139 - if (pos.type.hasLocation()) { 35.140 - print(", location="); 35.141 - print(pos.location); 35.142 - } 35.143 - } 35.144 - 35.145 public void write(Annotation.element_value_pair pair) { 35.146 write(pair, false); 35.147 }
36.1 --- a/src/share/classes/com/sun/tools/javap/AttributeWriter.java Wed Jan 05 09:59:01 2011 +0000 36.2 +++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java Mon Jan 10 14:57:59 2011 -0800 36.3 @@ -1,5 +1,5 @@ 36.4 /* 36.5 - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 36.6 + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 36.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 36.8 * 36.9 * This code is free software; you can redistribute it and/or modify it 36.10 @@ -47,10 +47,8 @@ 36.11 import com.sun.tools.classfile.LocalVariableTypeTable_attribute; 36.12 import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute; 36.13 import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute; 36.14 -import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute; 36.15 import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute; 36.16 import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute; 36.17 -import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute; 36.18 import com.sun.tools.classfile.Signature_attribute; 36.19 import com.sun.tools.classfile.SourceDebugExtension_attribute; 36.20 import com.sun.tools.classfile.SourceFile_attribute; 36.21 @@ -392,30 +390,6 @@ 36.22 return null; 36.23 } 36.24 36.25 - public Void visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, Void ignore) { 36.26 - println("RuntimeVisibleTypeAnnotations:"); 36.27 - indent(+1); 36.28 - for (int i = 0; i < attr.annotations.length; i++) { 36.29 - print(i + ": "); 36.30 - annotationWriter.write(attr.annotations[i]); 36.31 - println(); 36.32 - } 36.33 - indent(-1); 36.34 - return null; 36.35 - } 36.36 - 36.37 - public Void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, Void ignore) { 36.38 - println("RuntimeInvisibleTypeAnnotations:"); 36.39 - indent(+1); 36.40 - for (int i = 0; i < attr.annotations.length; i++) { 36.41 - print(i + ": "); 36.42 - annotationWriter.write(attr.annotations[i]); 36.43 - println(); 36.44 - } 36.45 - indent(-1); 36.46 - return null; 36.47 - } 36.48 - 36.49 public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, Void ignore) { 36.50 println("RuntimeVisibleParameterAnnotations:"); 36.51 indent(+1);
37.1 --- a/src/share/classes/com/sun/tools/javap/CodeWriter.java Wed Jan 05 09:59:01 2011 +0000 37.2 +++ b/src/share/classes/com/sun/tools/javap/CodeWriter.java Mon Jan 10 14:57:59 2011 -0800 37.3 @@ -1,5 +1,5 @@ 37.4 /* 37.5 - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 37.6 + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 37.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 37.8 * 37.9 * This code is free software; you can redistribute it and/or modify it 37.10 @@ -64,7 +64,6 @@ 37.11 stackMapWriter = StackMapWriter.instance(context); 37.12 localVariableTableWriter = LocalVariableTableWriter.instance(context); 37.13 localVariableTypeTableWriter = LocalVariableTypeTableWriter.instance(context); 37.14 - typeAnnotationWriter = TypeAnnotationWriter.instance(context); 37.15 options = Options.instance(context); 37.16 } 37.17 37.18 @@ -266,11 +265,6 @@ 37.19 detailWriters.add(tryBlockWriter); 37.20 } 37.21 37.22 - if (options.details.contains(InstructionDetailWriter.Kind.TYPE_ANNOS)) { 37.23 - typeAnnotationWriter.reset(attr); 37.24 - detailWriters.add(typeAnnotationWriter); 37.25 - } 37.26 - 37.27 return detailWriters; 37.28 } 37.29 37.30 @@ -279,7 +273,6 @@ 37.31 private ConstantWriter constantWriter; 37.32 private LocalVariableTableWriter localVariableTableWriter; 37.33 private LocalVariableTypeTableWriter localVariableTypeTableWriter; 37.34 - private TypeAnnotationWriter typeAnnotationWriter; 37.35 private SourceWriter sourceWriter; 37.36 private StackMapWriter stackMapWriter; 37.37 private TryBlockWriter tryBlockWriter;
38.1 --- a/src/share/classes/com/sun/tools/javap/InstructionDetailWriter.java Wed Jan 05 09:59:01 2011 +0000 38.2 +++ b/src/share/classes/com/sun/tools/javap/InstructionDetailWriter.java Mon Jan 10 14:57:59 2011 -0800 38.3 @@ -1,5 +1,5 @@ 38.4 /* 38.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 38.6 + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 38.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 38.8 * 38.9 * This code is free software; you can redistribute it and/or modify it 38.10 @@ -42,13 +42,13 @@ 38.11 LOCAL_VAR_TYPES("localVariableTypes"), 38.12 SOURCE("source"), 38.13 STACKMAPS("stackMaps"), 38.14 - TRY_BLOCKS("tryBlocks"), 38.15 - TYPE_ANNOS("typeAnnotations"); 38.16 + TRY_BLOCKS("tryBlocks"); 38.17 Kind(String option) { 38.18 this.option = option; 38.19 } 38.20 final String option; 38.21 } 38.22 + 38.23 InstructionDetailWriter(Context context) { 38.24 super(context); 38.25 }
39.1 --- a/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java Wed Jan 05 09:59:01 2011 +0000 39.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 39.3 @@ -1,126 +0,0 @@ 39.4 -/* 39.5 - * Copyright (c) 2009, Oracle and/or its affiliates. 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. Oracle designates this 39.11 - * particular file as subject to the "Classpath" exception as provided 39.12 - * by Oracle in the LICENSE file that accompanied this code. 39.13 - * 39.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 39.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 39.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 39.17 - * version 2 for more details (a copy is included in the LICENSE file that 39.18 - * accompanied this code). 39.19 - * 39.20 - * You should have received a copy of the GNU General Public License version 39.21 - * 2 along with this work; if not, write to the Free Software Foundation, 39.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 39.23 - * 39.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 39.25 - * or visit www.oracle.com if you need additional information or have any 39.26 - * questions. 39.27 - */ 39.28 -package com.sun.tools.javap; 39.29 - 39.30 -import com.sun.tools.classfile.Attribute; 39.31 -import com.sun.tools.classfile.Code_attribute; 39.32 -import com.sun.tools.classfile.ExtendedAnnotation; 39.33 -import com.sun.tools.classfile.ExtendedAnnotation.Position; 39.34 -import com.sun.tools.classfile.Instruction; 39.35 -import com.sun.tools.classfile.Method; 39.36 -import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute; 39.37 -import com.sun.tools.classfile.RuntimeTypeAnnotations_attribute; 39.38 -import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute; 39.39 -import java.util.ArrayList; 39.40 -import java.util.HashMap; 39.41 -import java.util.List; 39.42 -import java.util.Map; 39.43 - 39.44 -/** 39.45 - * Annotate instructions with details about type annotations. 39.46 - * 39.47 - * <p><b>This is NOT part of any supported API. 39.48 - * If you write code that depends on this, you do so at your own risk. 39.49 - * This code and its internal interfaces are subject to change or 39.50 - * deletion without notice.</b> 39.51 - */ 39.52 -public class TypeAnnotationWriter extends InstructionDetailWriter { 39.53 - public enum NoteKind { VISIBLE, INVISIBLE }; 39.54 - public static class Note { 39.55 - Note(NoteKind kind, ExtendedAnnotation anno) { 39.56 - this.kind = kind; 39.57 - this.anno = anno; 39.58 - } 39.59 - public final NoteKind kind; 39.60 - public final ExtendedAnnotation anno; 39.61 - } 39.62 - 39.63 - static TypeAnnotationWriter instance(Context context) { 39.64 - TypeAnnotationWriter instance = context.get(TypeAnnotationWriter.class); 39.65 - if (instance == null) 39.66 - instance = new TypeAnnotationWriter(context); 39.67 - return instance; 39.68 - } 39.69 - 39.70 - protected TypeAnnotationWriter(Context context) { 39.71 - super(context); 39.72 - context.put(TypeAnnotationWriter.class, this); 39.73 - annotationWriter = AnnotationWriter.instance(context); 39.74 - classWriter = ClassWriter.instance(context); 39.75 - } 39.76 - 39.77 - public void reset(Code_attribute attr) { 39.78 - Method m = classWriter.getMethod(); 39.79 - pcMap = new HashMap<Integer, List<Note>>(); 39.80 - check(NoteKind.VISIBLE, (RuntimeVisibleTypeAnnotations_attribute) m.attributes.get(Attribute.RuntimeVisibleTypeAnnotations)); 39.81 - check(NoteKind.INVISIBLE, (RuntimeInvisibleTypeAnnotations_attribute) m.attributes.get(Attribute.RuntimeInvisibleTypeAnnotations)); 39.82 - } 39.83 - 39.84 - private void check(NoteKind kind, RuntimeTypeAnnotations_attribute attr) { 39.85 - if (attr == null) 39.86 - return; 39.87 - 39.88 - for (ExtendedAnnotation anno: attr.annotations) { 39.89 - Position p = anno.position; 39.90 - Note note = null; 39.91 - if (p.offset != -1) 39.92 - addNote(p.offset, note = new Note(kind, anno)); 39.93 - if (p.lvarOffset != null) { 39.94 - for (int i = 0; i < p.lvarOffset.length; i++) { 39.95 - if (note == null) 39.96 - note = new Note(kind, anno); 39.97 - addNote(p.lvarOffset[i], note); 39.98 - } 39.99 - } 39.100 - } 39.101 - } 39.102 - 39.103 - private void addNote(int pc, Note note) { 39.104 - List<Note> list = pcMap.get(pc); 39.105 - if (list == null) 39.106 - pcMap.put(pc, list = new ArrayList<Note>()); 39.107 - list.add(note); 39.108 - } 39.109 - 39.110 - @Override 39.111 - void writeDetails(Instruction instr) { 39.112 - String indent = space(2); // get from Options? 39.113 - int pc = instr.getPC(); 39.114 - List<Note> notes = pcMap.get(pc); 39.115 - if (notes != null) { 39.116 - for (Note n: notes) { 39.117 - print(indent); 39.118 - print("@"); 39.119 - annotationWriter.write(n.anno, false, true); 39.120 - print(", "); 39.121 - println(n.kind.toString().toLowerCase()); 39.122 - } 39.123 - } 39.124 - } 39.125 - 39.126 - private AnnotationWriter annotationWriter; 39.127 - private ClassWriter classWriter; 39.128 - private Map<Integer, List<Note>> pcMap; 39.129 -}
40.1 --- a/test/tools/javac/diags/examples.not-yet.txt Wed Jan 05 09:59:01 2011 +0000 40.2 +++ b/test/tools/javac/diags/examples.not-yet.txt Mon Jan 10 14:57:59 2011 -0800 40.3 @@ -52,7 +52,6 @@ 40.4 compiler.misc.bad.enclosing.method # bad class file 40.5 compiler.misc.bad.runtime.invisible.param.annotations # bad class file 40.6 compiler.misc.bad.signature # bad class file 40.7 -compiler.misc.bad.type.annotation.value 40.8 compiler.misc.base.membership # UNUSED 40.9 compiler.misc.ccf.found.later.version 40.10 compiler.misc.ccf.unrecognized.attribute