sun.reflect.annotation.ExceptionProxy Java Examples
The following examples show how to use
sun.reflect.annotation.ExceptionProxy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationProxyMaker.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
Object getValue(Attribute attr) { Method method; // runtime method of annotation element try { method = annoType.getMethod(meth.name.toString()); } catch (NoSuchMethodException e) { return null; } returnClass = method.getReturnType(); attr.accept(this); if (!(value instanceof ExceptionProxy) && !AnnotationType.invocationHandlerReturnType(returnClass) .isInstance(value)) { typeMismatch(method, attr); } return value; }
Example #2
Source File: AnnotationProxyMaker.java From javaide with GNU General Public License v3.0 | 6 votes |
Object getValue(Attribute attr) { Method method; // runtime method of annotation element try { method = annoType.getMethod(meth.name.toString()); } catch (NoSuchMethodException e) { return null; } returnClass = method.getReturnType(); attr.accept(this); if (!(value instanceof ExceptionProxy) && !AnnotationType.invocationHandlerReturnType(returnClass) .isInstance(value)) { typeMismatch(method, attr); } return value; }
Example #3
Source File: Method.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Returns the default value for the annotation member represented by * this {@code Method} instance. If the member is of a primitive type, * an instance of the corresponding wrapper type is returned. Returns * null if no default is associated with the member, or if the method * instance does not represent a declared member of an annotation type. * * @return the default value for the annotation member represented * by this {@code Method} instance. * @throws TypeNotPresentException if the annotation is of type * {@link Class} and no definition can be found for the * default class value. * @since 1.5 */ public Object getDefaultValue() { if (annotationDefault == null) return null; Class<?> memberType = AnnotationType.invocationHandlerReturnType( getReturnType()); Object result = AnnotationParser.parseMemberValue( memberType, ByteBuffer.wrap(annotationDefault), SharedSecrets.getJavaLangAccess(). getConstantPool(getDeclaringClass()), getDeclaringClass()); if (result instanceof ExceptionProxy) { if (result instanceof TypeNotPresentExceptionProxy) { TypeNotPresentExceptionProxy proxy = (TypeNotPresentExceptionProxy)result; throw new TypeNotPresentException(proxy.typeName(), proxy.getCause()); } throw new AnnotationFormatError("Invalid default: " + this); } return result; }
Example #4
Source File: Method.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns the default value for the annotation member represented by * this {@code Method} instance. If the member is of a primitive type, * an instance of the corresponding wrapper type is returned. Returns * null if no default is associated with the member, or if the method * instance does not represent a declared member of an annotation type. * * @return the default value for the annotation member represented * by this {@code Method} instance. * @throws TypeNotPresentException if the annotation is of type * {@link Class} and no definition can be found for the * default class value. * @since 1.5 */ public Object getDefaultValue() { if (annotationDefault == null) return null; Class<?> memberType = AnnotationType.invocationHandlerReturnType( getReturnType()); Object result = AnnotationParser.parseMemberValue( memberType, ByteBuffer.wrap(annotationDefault), SharedSecrets.getJavaLangAccess(). getConstantPool(getDeclaringClass()), getDeclaringClass()); if (result instanceof ExceptionProxy) { if (result instanceof TypeNotPresentExceptionProxy) { TypeNotPresentExceptionProxy proxy = (TypeNotPresentExceptionProxy)result; throw new TypeNotPresentException(proxy.typeName(), proxy.getCause()); } throw new AnnotationFormatError("Invalid default: " + this); } return result; }
Example #5
Source File: AnnotationProxyMaker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitArray(Attribute.Array a) { Name elemName = ((ArrayType) a.type).elemtype.tsym.getQualifiedName(); if (elemName.equals(elemName.table.names.java_lang_Class)) { // Class[] // Construct a proxy for a MirroredTypesException ListBuffer<TypeMirror> elems = new ListBuffer<TypeMirror>(); for (Attribute value : a.values) { Type elem = ((Attribute.Class) value).type; elems.append(elem); } value = new MirroredTypesExceptionProxy(elems.toList()); } else { int len = a.values.length; Class<?> returnClassSaved = returnClass; returnClass = returnClass.getComponentType(); try { Object res = Array.newInstance(returnClass, len); for (int i = 0; i < len; i++) { a.values[i].accept(this); if (value == null || value instanceof ExceptionProxy) { return; } try { Array.set(res, i, value); } catch (IllegalArgumentException e) { value = null; // indicates a type mismatch return; } } value = res; } finally { returnClass = returnClassSaved; } } }
Example #6
Source File: AnnotationProxyMaker.java From javaide with GNU General Public License v3.0 | 5 votes |
public void visitArray(Attribute.Array a) { Name elemName = ((ArrayType) a.type).elemtype.tsym.getQualifiedName(); if (elemName.equals(elemName.table.names.java_lang_Class)) { // Class[] // Construct a proxy for a MirroredTypesException ListBuffer<TypeMirror> elems = new ListBuffer<TypeMirror>(); for (Attribute value : a.values) { Type elem = ((Attribute.Class) value).type; elems.append(elem); } value = new MirroredTypesExceptionProxy(elems.toList()); } else { int len = a.values.length; Class<?> returnClassSaved = returnClass; returnClass = returnClass.getComponentType(); try { Object res = Array.newInstance(returnClass, len); for (int i = 0; i < len; i++) { a.values[i].accept(this); if (value == null || value instanceof ExceptionProxy) { return; } try { Array.set(res, i, value); } catch (IllegalArgumentException e) { value = null; // indicates a type mismatch return; } } value = res; } finally { returnClass = returnClassSaved; } } }