--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Aug 25 11:24:30 2010 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Aug 25 11:40:25 2010 -0700
@@ -34,6 +34,7 @@
import javax.tools.JavaFileObject;
import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Attribute.RetentionPolicy;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.file.BaseFileObject;
@@ -692,7 +693,7 @@
boolean hasInvisible = false;
if (m.params != null) for (VarSymbol s : m.params) {
for (Attribute.Compound a : s.getAnnotationMirrors()) {
- switch (getRetention(a.type.tsym)) {
+ switch (types.getRetention(a)) {
case SOURCE: break;
case CLASS: hasInvisible = true; break;
case RUNTIME: hasVisible = true; break;
@@ -708,7 +709,7 @@
for (VarSymbol s : m.params) {
ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>();
for (Attribute.Compound a : s.getAnnotationMirrors())
- if (getRetention(a.type.tsym) == RetentionPolicy.RUNTIME)
+ if (types.getRetention(a) == RetentionPolicy.RUNTIME)
buf.append(a);
databuf.appendChar(buf.length());
for (Attribute.Compound a : buf)
@@ -723,7 +724,7 @@
for (VarSymbol s : m.params) {
ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>();
for (Attribute.Compound a : s.getAnnotationMirrors())
- if (getRetention(a.type.tsym) == RetentionPolicy.CLASS)
+ if (types.getRetention(a) == RetentionPolicy.CLASS)
buf.append(a);
databuf.appendChar(buf.length());
for (Attribute.Compound a : buf)
@@ -747,7 +748,7 @@
ListBuffer<Attribute.Compound> visibles = new ListBuffer<Attribute.Compound>();
ListBuffer<Attribute.Compound> invisibles = new ListBuffer<Attribute.Compound>();
for (Attribute.Compound a : attrs) {
- switch (getRetention(a.type.tsym)) {
+ switch (types.getRetention(a)) {
case SOURCE: break;
case CLASS: invisibles.append(a); break;
case RUNTIME: visibles.append(a); break;
@@ -785,7 +786,7 @@
if (tc.position.type == TargetType.UNKNOWN
|| !tc.position.emitToClassfile())
continue;
- switch (getRetention(tc.type.tsym)) {
+ switch (types.getRetention(tc)) {
case SOURCE: break;
case CLASS: invisibles.append(tc); break;
case RUNTIME: visibles.append(tc); break;
@@ -815,29 +816,6 @@
return attrCount;
}
- /** A mirror of java.lang.annotation.RetentionPolicy. */
- enum RetentionPolicy {
- SOURCE,
- CLASS,
- RUNTIME
- }
-
- RetentionPolicy getRetention(TypeSymbol annotationType) {
- RetentionPolicy vis = RetentionPolicy.CLASS; // the default
- Attribute.Compound c = annotationType.attribute(syms.retentionType.tsym);
- if (c != null) {
- Attribute value = c.member(names.value);
- if (value != null && value instanceof Attribute.Enum) {
- Name levelName = ((Attribute.Enum)value).value.name;
- if (levelName == names.SOURCE) vis = RetentionPolicy.SOURCE;
- else if (levelName == names.CLASS) vis = RetentionPolicy.CLASS;
- else if (levelName == names.RUNTIME) vis = RetentionPolicy.RUNTIME;
- else ;// /* fail soft */ throw new AssertionError(levelName);
- }
- }
- return vis;
- }
-
/** A visitor to write an attribute including its leading
* single-character marker.
*/