Java Code Examples for sun.reflect.annotation.AnnotationParser

The following examples show how to use sun.reflect.annotation.AnnotationParser. These examples are extracted from open source projects. 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 Project: TencentKona-8   Source File: Executable.java    License: 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 2
Source Project: TencentKona-8   Source File: Field.java    License: 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
private static Annotation ann(Class<? extends Annotation> annotationType,
                              Object value) {
    return AnnotationParser.annotationForMap(annotationType,
        Collections.singletonMap("value", value));
}
 
Example 4
Source Project: Bytecoder   Source File: Executable.java    License: 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 5
Source Project: Bytecoder   Source File: Method.java    License: 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 Project: Bytecoder   Source File: RecordComponent.java    License: 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 7
Source Project: openjdk-jdk9   Source File: Field.java    License: 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 8
Source Project: jdk8u_jdk   Source File: Executable.java    License: 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 9
private static Annotation ann(Class<? extends Annotation> annotationType,
                              Object value) {
    return AnnotationParser.annotationForMap(annotationType,
        Collections.singletonMap("value", value));
}
 
Example 10
Source Project: jdk1.8-source-analysis   Source File: Executable.java    License: Apache License 2.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 Project: jdk1.8-source-analysis   Source File: Method.java    License: Apache License 2.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 12
Source Project: jdk1.8-source-analysis   Source File: Field.java    License: Apache License 2.0 5 votes vote down vote up
private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    if (declaredAnnotations == null) {
        Field root = this.root;
        if (root != null) {
            declaredAnnotations = root.declaredAnnotations();
        } else {
            declaredAnnotations = AnnotationParser.parseAnnotations(
                    annotations,
                    sun.misc.SharedSecrets.getJavaLangAccess().getConstantPool(getDeclaringClass()),
                    getDeclaringClass());
        }
    }
    return declaredAnnotations;
}
 
Example 13
Source Project: dragonwell8_jdk   Source File: Executable.java    License: 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 Project: jdk8u-jdk   Source File: Method.java    License: 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 15
Source Project: dragonwell8_jdk   Source File: Method.java    License: 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 Project: jdk8u-jdk   Source File: Executable.java    License: 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 17
Source Project: TencentKona-8   Source File: Executable.java    License: 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 18
Source Project: openjdk-8   Source File: Executable.java    License: GNU General Public License v2.0 5 votes vote down vote up
private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    if (declaredAnnotations == null) {
        declaredAnnotations = AnnotationParser.parseAnnotations(
            getAnnotationBytes(),
            sun.misc.SharedSecrets.getJavaLangAccess().
            getConstantPool(getDeclaringClass()),
            getDeclaringClass());
    }
    return declaredAnnotations;
}
 
Example 19
Source Project: TencentKona-8   Source File: Method.java    License: 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 Project: hottub   Source File: Field.java    License: GNU General Public License v2.0 5 votes vote down vote up
private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    if (declaredAnnotations == null) {
        Field root = this.root;
        if (root != null) {
            declaredAnnotations = root.declaredAnnotations();
        } else {
            declaredAnnotations = AnnotationParser.parseAnnotations(
                    annotations,
                    sun.misc.SharedSecrets.getJavaLangAccess().getConstantPool(getDeclaringClass()),
                    getDeclaringClass());
        }
    }
    return declaredAnnotations;
}
 
Example 21
Source Project: jdk8u60   Source File: Executable.java    License: 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 22
Source Project: jdk8u60   Source File: Executable.java    License: 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 23
Source Project: jdk8u60   Source File: Method.java    License: 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 24
Source Project: jdk8u60   Source File: Field.java    License: GNU General Public License v2.0 5 votes vote down vote up
private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
    if (declaredAnnotations == null) {
        Field root = this.root;
        if (root != null) {
            declaredAnnotations = root.declaredAnnotations();
        } else {
            declaredAnnotations = AnnotationParser.parseAnnotations(
                    annotations,
                    sun.misc.SharedSecrets.getJavaLangAccess().getConstantPool(getDeclaringClass()),
                    getDeclaringClass());
        }
    }
    return declaredAnnotations;
}
 
Example 25
private static Annotation ann(Class<? extends Annotation> annotationType,
                              Object value) {
    return AnnotationParser.annotationForMap(annotationType,
        Collections.singletonMap("value", value));
}
 
Example 26
Source Project: JDKSourceCode1.8   Source File: Executable.java    License: MIT License 5 votes vote down vote up
Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) {
    return AnnotationParser.parseParameterAnnotations(
           parameterAnnotations,
           sun.misc.SharedSecrets.getJavaLangAccess().
           getConstantPool(getDeclaringClass()),
           getDeclaringClass());
}
 
Example 27
Source Project: openjdk-8   Source File: Executable.java    License: 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 28
Source Project: JDKSourceCode1.8   Source File: Method.java    License: MIT License 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 Project: jdk8u_jdk   Source File: Method.java    License: 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 30
Source Project: openjdk-jdk8u   Source File: Executable.java    License: 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());
}