langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java
changeset 13689 4d519199a6aa
parent 8032 e1aa25ccdabb
child 14359 d4099818ab70
equal deleted inserted replaced
13636:bee2d435e11f 13689:4d519199a6aa
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   101 
   101 
   102     /** The value for an annotation element of type java.lang.Class,
   102     /** The value for an annotation element of type java.lang.Class,
   103      *  represented as a ClassSymbol.
   103      *  represented as a ClassSymbol.
   104      */
   104      */
   105     public static class Class extends Attribute {
   105     public static class Class extends Attribute {
   106         public final Type type;
   106         public final Type classType;
   107         public void accept(Visitor v) { v.visitClass(this); }
   107         public void accept(Visitor v) { v.visitClass(this); }
   108         public Class(Types types, Type type) {
   108         public Class(Types types, Type type) {
   109             super(makeClassType(types, type));
   109             super(makeClassType(types, type));
   110             this.type = type;
   110             this.classType = type;
   111         }
   111         }
   112         static Type makeClassType(Types types, Type type) {
   112         static Type makeClassType(Types types, Type type) {
   113             Type arg = type.isPrimitive()
   113             Type arg = type.isPrimitive()
   114                 ? types.boxedClass(type).type
   114                 ? types.boxedClass(type).type
   115                 : types.erasure(type);
   115                 : types.erasure(type);
   116             return new Type.ClassType(types.syms.classType.getEnclosingType(),
   116             return new Type.ClassType(types.syms.classType.getEnclosingType(),
   117                                       List.of(arg),
   117                                       List.of(arg),
   118                                       types.syms.classType.tsym);
   118                                       types.syms.classType.tsym);
   119         }
   119         }
   120         public String toString() {
   120         public String toString() {
   121             return type + ".class";
   121             return classType + ".class";
   122         }
   122         }
   123         public Type getValue() {
   123         public Type getValue() {
   124             return type;
   124             return classType;
   125         }
   125         }
   126         public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
   126         public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
   127             return v.visitType(type, p);
   127             return v.visitType(classType, p);
   128         }
   128         }
   129     }
   129     }
   130 
   130 
   131     /** A compound annotation element value, the type of which is an
   131     /** A compound annotation element value, the type of which is an
   132      *  attribute interface.
   132      *  attribute interface.
   210         public final Attribute[] values;
   210         public final Attribute[] values;
   211         public Array(Type type, Attribute[] values) {
   211         public Array(Type type, Attribute[] values) {
   212             super(type);
   212             super(type);
   213             this.values = values;
   213             this.values = values;
   214         }
   214         }
       
   215 
       
   216         public Array(Type type, List<Attribute> values) {
       
   217             super(type);
       
   218             this.values = values.toArray(new Attribute[values.size()]);
       
   219         }
       
   220 
   215         public void accept(Visitor v) { v.visitArray(this); }
   221         public void accept(Visitor v) { v.visitArray(this); }
   216         public String toString() {
   222         public String toString() {
   217             StringBuilder buf = new StringBuilder();
   223             StringBuilder buf = new StringBuilder();
   218             buf.append('{');
   224             buf.append('{');
   219             boolean first = true;
   225             boolean first = true;