sun.reflect.annotation.AnnotationParser Java Examples

The following examples show how to use sun.reflect.annotation.AnnotationParser. 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: Executable.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    Map<Class<? extends Annotation>, Annotation> declAnnos;
    if ((declAnnos = declaredAnnotations) == null) {
        synchronized (this) {
            if ((declAnnos = declaredAnnotations) == null) {
                Executable root = (Executable)getRoot();
                if (root != null) {
                    declAnnos = root.declaredAnnotations();
                } else {
                    declAnnos = AnnotationParser.parseAnnotations(
                            getAnnotationBytes(),
                            SharedSecrets.getJavaLangAccess().
                                    getConstantPool(getDeclaringClass()),
                            getDeclaringClass()
                    );
                }
                declaredAnnotations = declAnnos;
            }
        }
    }
    return declAnnos;
}
 
Example #2
Source File: Field.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    Map<Class<? extends Annotation>, Annotation> declAnnos;
    if ((declAnnos = declaredAnnotations) == null) {
        synchronized (this) {
            if ((declAnnos = declaredAnnotations) == null) {
                Field root = this.root;
                if (root != null) {
                    declAnnos = root.declaredAnnotations();
                } else {
                    declAnnos = AnnotationParser.parseAnnotations(
                            annotations,
                            sun.misc.SharedSecrets.getJavaLangAccess()
                                    .getConstantPool(getDeclaringClass()),
                            getDeclaringClass());
                }
                declaredAnnotations = declAnnos;
            }
        }
    }
    return declAnnos;
}
 
Example #3
Source File: Executable.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    Map<Class<? extends Annotation>, Annotation> declAnnos;
    if ((declAnnos = declaredAnnotations) == null) {
        synchronized (this) {
            if ((declAnnos = declaredAnnotations) == null) {
                Executable root = getRoot();
                if (root != null) {
                    declAnnos = root.declaredAnnotations();
                } else {
                    declAnnos = AnnotationParser.parseAnnotations(
                            getAnnotationBytes(),
                            sun.misc.SharedSecrets.getJavaLangAccess().
                                    getConstantPool(getDeclaringClass()),
                            getDeclaringClass()
                    );
                }
                declaredAnnotations = declAnnos;
            }
        }
    }
    return declAnnos;
}
 
Example #4
Source File: Executable.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    Map<Class<? extends Annotation>, Annotation> declAnnos;
    if ((declAnnos = declaredAnnotations) == null) {
        synchronized (this) {
            if ((declAnnos = declaredAnnotations) == null) {
                Executable root = getRoot();
                if (root != null) {
                    declAnnos = root.declaredAnnotations();
                } else {
                    declAnnos = AnnotationParser.parseAnnotations(
                            getAnnotationBytes(),
                            sun.misc.SharedSecrets.getJavaLangAccess().
                                    getConstantPool(getDeclaringClass()),
                            getDeclaringClass()
                    );
                }
                declaredAnnotations = declAnnos;
            }
        }
    }
    return declAnnos;
}
 
Example #5
Source File: Method.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #6
Source File: Field.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    Map<Class<? extends Annotation>, Annotation> declAnnos;
    if ((declAnnos = declaredAnnotations) == null) {
        synchronized (this) {
            if ((declAnnos = declaredAnnotations) == null) {
                Field root = this.root;
                if (root != null) {
                    declAnnos = root.declaredAnnotations();
                } else {
                    declAnnos = AnnotationParser.parseAnnotations(
                            annotations,
                            SharedSecrets.getJavaLangAccess()
                                    .getConstantPool(getDeclaringClass()),
                            getDeclaringClass());
                }
                declaredAnnotations = declAnnos;
            }
        }
    }
    return declAnnos;
}
 
Example #7
Source File: RecordComponent.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    Map<Class<? extends Annotation>, Annotation> declAnnos;
    if ((declAnnos = declaredAnnotations) == null) {
        synchronized (this) {
            if ((declAnnos = declaredAnnotations) == null) {
                @SuppressWarnings("preview")
                RecordComponent root = this.root;
                if (root != null) {
                    declAnnos = root.declaredAnnotations();
                } else {
                    declAnnos = AnnotationParser.parseAnnotations(
                            annotations,
                            SharedSecrets.getJavaLangAccess()
                                    .getConstantPool(getDeclaringRecord()),
                            getDeclaringRecord());
                }
                declaredAnnotations = declAnnos;
            }
        }
    }
    return declAnnos;
}
 
Example #8
Source File: AnnotationsInheritanceOrderRedefinitionTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static Annotation ann(Class<? extends Annotation> annotationType,
                              Object value) {
    return AnnotationParser.annotationForMap(annotationType,
        Collections.singletonMap("value", value));
}
 
Example #9
Source File: Method.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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),
        sun.misc.SharedSecrets.getJavaLangAccess().
            getConstantPool(getDeclaringClass()),
        getDeclaringClass());
    if (result instanceof sun.reflect.annotation.ExceptionProxy)
        throw new AnnotationFormatError("Invalid default: " + this);
    return result;
}
 
Example #10
Source File: Executable.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    if (declaredAnnotations == null) {
        Executable root = getRoot();
        if (root != null) {
            declaredAnnotations = root.declaredAnnotations();
        } else {
            declaredAnnotations = AnnotationParser.parseAnnotations(
                getAnnotationBytes(),
                sun.misc.SharedSecrets.getJavaLangAccess().
                getConstantPool(getDeclaringClass()),
                getDeclaringClass());
        }
    }
    return declaredAnnotations;
}
 
Example #11
Source File: AnnotationProxyMaker.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a dynamic proxy for an annotation mirror.
 */
private Annotation generateAnnotation() {
    return AnnotationParser.annotationForMap(annoType,
                                             getAllReflectedValues());
}
 
Example #12
Source File: Executable.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    if (declaredAnnotations == null) {
        Executable root = getRoot();
        if (root != null) {
            declaredAnnotations = root.declaredAnnotations();
        } else {
            declaredAnnotations = AnnotationParser.parseAnnotations(
                getAnnotationBytes(),
                sun.misc.SharedSecrets.getJavaLangAccess().
                getConstantPool(getDeclaringClass()),
                getDeclaringClass());
        }
    }
    return declaredAnnotations;
}
 
Example #13
Source File: Executable.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) {
    return AnnotationParser.parseParameterAnnotations(
           parameterAnnotations,
           sun.misc.SharedSecrets.getJavaLangAccess().
           getConstantPool(getDeclaringClass()),
           getDeclaringClass());
}
 
Example #14
Source File: AnnotationsInheritanceOrderRedefinitionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static Annotation ann(Class<? extends Annotation> annotationType,
                              Object value) {
    return AnnotationParser.annotationForMap(annotationType,
        Collections.singletonMap("value", value));
}
 
Example #15
Source File: Method.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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),
        sun.misc.SharedSecrets.getJavaLangAccess().
            getConstantPool(getDeclaringClass()),
        getDeclaringClass());
    if (result instanceof sun.reflect.annotation.ExceptionProxy)
        throw new AnnotationFormatError("Invalid default: " + this);
    return result;
}
 
Example #16
Source File: Executable.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) {
    return AnnotationParser.parseParameterAnnotations(
           parameterAnnotations,
           SharedSecrets.getJavaLangAccess().
           getConstantPool(getDeclaringClass()),
           getDeclaringClass());
}
 
Example #17
Source File: AnnotationsInheritanceOrderRedefinitionTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static Annotation ann(Class<? extends Annotation> annotationType,
                              Object value) {
    return AnnotationParser.annotationForMap(annotationType,
        Collections.singletonMap("value", value));
}
 
Example #18
Source File: Constructor.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    if (declaredAnnotations == null) {
        declaredAnnotations = AnnotationParser.parseAnnotations(
            annotations, sun.misc.SharedSecrets.getJavaLangAccess().
            getConstantPool(getDeclaringClass()),
            getDeclaringClass());
    }
    return declaredAnnotations;
}
 
Example #19
Source File: Method.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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),
        sun.misc.SharedSecrets.getJavaLangAccess().
            getConstantPool(getDeclaringClass()),
        getDeclaringClass());
    if (result instanceof sun.reflect.annotation.ExceptionProxy)
        throw new AnnotationFormatError("Invalid default: " + this);
    return result;
}
 
Example #20
Source File: Executable.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) {
    return AnnotationParser.parseParameterAnnotations(
           parameterAnnotations,
           sun.misc.SharedSecrets.getJavaLangAccess().
           getConstantPool(getDeclaringClass()),
           getDeclaringClass());
}
 
Example #21
Source File: Constructor.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an array of arrays that represent the annotations on the formal
 * parameters, in declaration order, of the method represented by
 * this {@code Constructor} object. (Returns an array of length zero if the
 * underlying method is parameterless.  If the method has one or more
 * parameters, a nested array of length zero is returned for each parameter
 * with no annotations.) The annotation objects contained in the returned
 * arrays are serializable.  The caller of this method is free to modify
 * the returned arrays; it will have no effect on the arrays returned to
 * other callers.
 *
 * @return an array of arrays that represent the annotations on the formal
 *    parameters, in declaration order, of the method represented by this
 *    Constructor object
 * @since 1.5
 */
public Annotation[][] getParameterAnnotations() {
    int numParameters = parameterTypes.length;
    if (parameterAnnotations == null)
        return new Annotation[numParameters][0];

    Annotation[][] result = AnnotationParser.parseParameterAnnotations(
        parameterAnnotations,
        sun.misc.SharedSecrets.getJavaLangAccess().
            getConstantPool(getDeclaringClass()),
        getDeclaringClass());
    if (result.length != numParameters) {
        Class<?> declaringClass = getDeclaringClass();
        if (declaringClass.isEnum() ||
            declaringClass.isAnonymousClass() ||
            declaringClass.isLocalClass() )
            ; // Can't do reliable parameter counting
        else {
            if (!declaringClass.isMemberClass() || // top-level
                // Check for the enclosing instance parameter for
                // non-static member classes
                (declaringClass.isMemberClass() &&
                 ((declaringClass.getModifiers() & Modifier.STATIC) == 0)  &&
                 result.length + 1 != numParameters) ) {
                throw new AnnotationFormatError(
                          "Parameter annotations don't match number of parameters");
            }
        }
    }
    return result;
}
 
Example #22
Source File: Executable.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) {
    return AnnotationParser.parseParameterAnnotations(
           parameterAnnotations,
           sun.misc.SharedSecrets.getJavaLangAccess().
           getConstantPool(getDeclaringClass()),
           getDeclaringClass());
}
 
Example #23
Source File: AnnotationsInheritanceOrderRedefinitionTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static Annotation ann(Class<? extends Annotation> annotationType,
                              Object value) {
    return AnnotationParser.annotationForMap(annotationType,
        Collections.singletonMap("value", value));
}
 
Example #24
Source File: AnnotationsInheritanceOrderRedefinitionTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static Annotation ann(Class<? extends Annotation> annotationType,
                              Object value) {
    return AnnotationParser.annotationForMap(annotationType,
        Collections.singletonMap("value", value));
}
 
Example #25
Source File: Executable.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    if (declaredAnnotations == null) {
        Executable root = getRoot();
        if (root != null) {
            declaredAnnotations = root.declaredAnnotations();
        } else {
            declaredAnnotations = AnnotationParser.parseAnnotations(
                getAnnotationBytes(),
                sun.misc.SharedSecrets.getJavaLangAccess().
                getConstantPool(getDeclaringClass()),
                getDeclaringClass());
        }
    }
    return declaredAnnotations;
}
 
Example #26
Source File: AnnotationsInheritanceOrderRedefinitionTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Annotation ann(Class<? extends Annotation> annotationType,
                              Object value) {
    return AnnotationParser.annotationForMap(annotationType,
        Collections.singletonMap("value", value));
}
 
Example #27
Source File: Field.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    if (declaredAnnotations == null) {
        declaredAnnotations = AnnotationParser.parseAnnotations(
            annotations, sun.misc.SharedSecrets.getJavaLangAccess().
            getConstantPool(getDeclaringClass()),
            getDeclaringClass());
    }
    return declaredAnnotations;
}
 
Example #28
Source File: Method.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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),
        sun.misc.SharedSecrets.getJavaLangAccess().
            getConstantPool(getDeclaringClass()),
        getDeclaringClass());
    if (result instanceof sun.reflect.annotation.ExceptionProxy)
        throw new AnnotationFormatError("Invalid default: " + this);
    return result;
}
 
Example #29
Source File: Executable.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) {
    return AnnotationParser.parseParameterAnnotations(
           parameterAnnotations,
           sun.misc.SharedSecrets.getJavaLangAccess().
           getConstantPool(getDeclaringClass()),
           getDeclaringClass());
}
 
Example #30
Source File: Executable.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) {
    return AnnotationParser.parseParameterAnnotations(
           parameterAnnotations,
           sun.misc.SharedSecrets.getJavaLangAccess().
           getConstantPool(getDeclaringClass()),
           getDeclaringClass());
}