src/share/classes/com/sun/tools/javac/code/Types.java

changeset 657
70ebdef189c9
parent 640
995bcdb9a41d
child 665
d3ead6731a91
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Aug 25 11:24:30 2010 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Aug 25 11:40:25 2010 -0700
     1.3 @@ -32,6 +32,7 @@
     1.4  import com.sun.tools.javac.util.List;
     1.5  
     1.6  import com.sun.tools.javac.jvm.ClassReader;
     1.7 +import com.sun.tools.javac.code.Attribute.RetentionPolicy;
     1.8  import com.sun.tools.javac.comp.Check;
     1.9  
    1.10  import static com.sun.tools.javac.code.Type.*;
    1.11 @@ -3554,4 +3555,24 @@
    1.12          public Type visitType(Type t, S s) { return t; }
    1.13      }
    1.14      // </editor-fold>
    1.15 +
    1.16 +
    1.17 +    // <editor-fold defaultstate="collapsed" desc="Annotation support">
    1.18 +
    1.19 +    public RetentionPolicy getRetention(Attribute.Compound a) {
    1.20 +        RetentionPolicy vis = RetentionPolicy.CLASS; // the default
    1.21 +        Attribute.Compound c = a.type.tsym.attribute(syms.retentionType.tsym);
    1.22 +        if (c != null) {
    1.23 +            Attribute value = c.member(names.value);
    1.24 +            if (value != null && value instanceof Attribute.Enum) {
    1.25 +                Name levelName = ((Attribute.Enum)value).value.name;
    1.26 +                if (levelName == names.SOURCE) vis = RetentionPolicy.SOURCE;
    1.27 +                else if (levelName == names.CLASS) vis = RetentionPolicy.CLASS;
    1.28 +                else if (levelName == names.RUNTIME) vis = RetentionPolicy.RUNTIME;
    1.29 +                else ;// /* fail soft */ throw new AssertionError(levelName);
    1.30 +            }
    1.31 +        }
    1.32 +        return vis;
    1.33 +    }
    1.34 +    // </editor-fold>
    1.35  }

mercurial