src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java

Print this page




 164             returnClass = method.getReturnType();
 165             attr.accept(this);
 166             if (!(value instanceof ExceptionProxy) &&
 167                 !AnnotationType.invocationHandlerReturnType(returnClass)
 168                                                         .isInstance(value)) {
 169                 typeMismatch(method, attr);
 170             }
 171             return value;
 172         }
 173 
 174 
 175         public void visitConstant(Attribute.Constant c) {
 176             value = c.getValue();
 177         }
 178 
 179         public void visitClass(Attribute.Class c) {
 180             value = new MirroredTypeExceptionProxy(c.type);
 181         }
 182 
 183         public void visitArray(Attribute.Array a) {
 184             Name elemName = ((ArrayType) a.type).elemtype.tsym.name;
 185 
 186             if (elemName == elemName.table.names.java_lang_Class) {   // Class[]
 187                 // Construct a proxy for a MirroredTypesException
 188                 List<TypeMirror> elems = List.nil();
 189                 for (Attribute value : a.values) {
 190                     Type elem = ((Attribute.Class) value).type;
 191                     elems.add(elem);
 192                 }
 193                 value = new MirroredTypesExceptionProxy(elems);
 194 
 195             } else {
 196                 int len = a.values.length;
 197                 Class<?> returnClassSaved = returnClass;
 198                 returnClass = returnClass.getComponentType();
 199                 try {
 200                     Object res = Array.newInstance(returnClass, len);
 201                     for (int i = 0; i < len; i++) {
 202                         a.values[i].accept(this);
 203                         if (value == null || value instanceof ExceptionProxy) {
 204                             return;
 205                         }
 206                         try {
 207                             Array.set(res, i, value);
 208                         } catch (IllegalArgumentException e) {
 209                             value = null;       // indicates a type mismatch
 210                             return;
 211                         }
 212                     }
 213                     value = res;




 164             returnClass = method.getReturnType();
 165             attr.accept(this);
 166             if (!(value instanceof ExceptionProxy) &&
 167                 !AnnotationType.invocationHandlerReturnType(returnClass)
 168                                                         .isInstance(value)) {
 169                 typeMismatch(method, attr);
 170             }
 171             return value;
 172         }
 173 
 174 
 175         public void visitConstant(Attribute.Constant c) {
 176             value = c.getValue();
 177         }
 178 
 179         public void visitClass(Attribute.Class c) {
 180             value = new MirroredTypeExceptionProxy(c.type);
 181         }
 182 
 183         public void visitArray(Attribute.Array a) {
 184             Name elemName = ((ArrayType) a.type).elemtype.tsym.getQualifiedName();
 185 
 186             if (elemName.equals(elemName.table.names.java_lang_Class)) {   // Class[]
 187                 // Construct a proxy for a MirroredTypesException
 188                 ListBuffer<TypeMirror> elems = new ListBuffer<TypeMirror>();
 189                 for (Attribute value : a.values) {
 190                     Type elem = ((Attribute.Class) value).type;
 191                     elems.append(elem);
 192                 }
 193                 value = new MirroredTypesExceptionProxy(elems.toList());
 194 
 195             } else {
 196                 int len = a.values.length;
 197                 Class<?> returnClassSaved = returnClass;
 198                 returnClass = returnClass.getComponentType();
 199                 try {
 200                     Object res = Array.newInstance(returnClass, len);
 201                     for (int i = 0; i < len; i++) {
 202                         a.values[i].accept(this);
 203                         if (value == null || value instanceof ExceptionProxy) {
 204                             return;
 205                         }
 206                         try {
 207                             Array.set(res, i, value);
 208                         } catch (IllegalArgumentException e) {
 209                             value = null;       // indicates a type mismatch
 210                             return;
 211                         }
 212                     }
 213                     value = res;