1.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Aug 25 11:24:30 2010 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Aug 25 11:40:25 2010 -0700 1.3 @@ -34,6 +34,7 @@ 1.4 import javax.tools.JavaFileObject; 1.5 1.6 import com.sun.tools.javac.code.*; 1.7 +import com.sun.tools.javac.code.Attribute.RetentionPolicy; 1.8 import com.sun.tools.javac.code.Symbol.*; 1.9 import com.sun.tools.javac.code.Type.*; 1.10 import com.sun.tools.javac.file.BaseFileObject; 1.11 @@ -692,7 +693,7 @@ 1.12 boolean hasInvisible = false; 1.13 if (m.params != null) for (VarSymbol s : m.params) { 1.14 for (Attribute.Compound a : s.getAnnotationMirrors()) { 1.15 - switch (getRetention(a.type.tsym)) { 1.16 + switch (types.getRetention(a)) { 1.17 case SOURCE: break; 1.18 case CLASS: hasInvisible = true; break; 1.19 case RUNTIME: hasVisible = true; break; 1.20 @@ -708,7 +709,7 @@ 1.21 for (VarSymbol s : m.params) { 1.22 ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>(); 1.23 for (Attribute.Compound a : s.getAnnotationMirrors()) 1.24 - if (getRetention(a.type.tsym) == RetentionPolicy.RUNTIME) 1.25 + if (types.getRetention(a) == RetentionPolicy.RUNTIME) 1.26 buf.append(a); 1.27 databuf.appendChar(buf.length()); 1.28 for (Attribute.Compound a : buf) 1.29 @@ -723,7 +724,7 @@ 1.30 for (VarSymbol s : m.params) { 1.31 ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>(); 1.32 for (Attribute.Compound a : s.getAnnotationMirrors()) 1.33 - if (getRetention(a.type.tsym) == RetentionPolicy.CLASS) 1.34 + if (types.getRetention(a) == RetentionPolicy.CLASS) 1.35 buf.append(a); 1.36 databuf.appendChar(buf.length()); 1.37 for (Attribute.Compound a : buf) 1.38 @@ -747,7 +748,7 @@ 1.39 ListBuffer<Attribute.Compound> visibles = new ListBuffer<Attribute.Compound>(); 1.40 ListBuffer<Attribute.Compound> invisibles = new ListBuffer<Attribute.Compound>(); 1.41 for (Attribute.Compound a : attrs) { 1.42 - switch (getRetention(a.type.tsym)) { 1.43 + switch (types.getRetention(a)) { 1.44 case SOURCE: break; 1.45 case CLASS: invisibles.append(a); break; 1.46 case RUNTIME: visibles.append(a); break; 1.47 @@ -785,7 +786,7 @@ 1.48 if (tc.position.type == TargetType.UNKNOWN 1.49 || !tc.position.emitToClassfile()) 1.50 continue; 1.51 - switch (getRetention(tc.type.tsym)) { 1.52 + switch (types.getRetention(tc)) { 1.53 case SOURCE: break; 1.54 case CLASS: invisibles.append(tc); break; 1.55 case RUNTIME: visibles.append(tc); break; 1.56 @@ -815,29 +816,6 @@ 1.57 return attrCount; 1.58 } 1.59 1.60 - /** A mirror of java.lang.annotation.RetentionPolicy. */ 1.61 - enum RetentionPolicy { 1.62 - SOURCE, 1.63 - CLASS, 1.64 - RUNTIME 1.65 - } 1.66 - 1.67 - RetentionPolicy getRetention(TypeSymbol annotationType) { 1.68 - RetentionPolicy vis = RetentionPolicy.CLASS; // the default 1.69 - Attribute.Compound c = annotationType.attribute(syms.retentionType.tsym); 1.70 - if (c != null) { 1.71 - Attribute value = c.member(names.value); 1.72 - if (value != null && value instanceof Attribute.Enum) { 1.73 - Name levelName = ((Attribute.Enum)value).value.name; 1.74 - if (levelName == names.SOURCE) vis = RetentionPolicy.SOURCE; 1.75 - else if (levelName == names.CLASS) vis = RetentionPolicy.CLASS; 1.76 - else if (levelName == names.RUNTIME) vis = RetentionPolicy.RUNTIME; 1.77 - else ;// /* fail soft */ throw new AssertionError(levelName); 1.78 - } 1.79 - } 1.80 - return vis; 1.81 - } 1.82 - 1.83 /** A visitor to write an attribute including its leading 1.84 * single-character marker. 1.85 */