本文整理汇总了Java中sun.reflect.annotation.AnnotationParser类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationParser类的具体用法?Java AnnotationParser怎么用?Java AnnotationParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationParser类属于sun.reflect.annotation包,在下文中一共展示了AnnotationParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: declaredAnnotations
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
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(),
SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
getDeclaringClass()
);
}
declaredAnnotations = declAnnos;
}
}
}
return declAnnos;
}
示例2: getDefaultValue
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
/**
* 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;
}
示例3: declaredAnnotations
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
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;
}
示例4: parseParameterAnnotations
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) {
return AnnotationParser.parseParameterAnnotations(
parameterAnnotations,
sun.misc.SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
getDeclaringClass());
}
示例5: declaredAnnotations
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
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;
}
示例6: getDefaultValue
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
/**
* 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;
}
示例7: declaredAnnotations
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
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;
}
示例8: parseParameterAnnotations
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) {
return AnnotationParser.parseParameterAnnotations(
parameterAnnotations,
SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
getDeclaringClass());
}
示例9: getDefaultValue
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
/**
* 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 sun.reflect.annotation.ExceptionProxy)
throw new AnnotationFormatError("Invalid default: " + this);
return result;
}
示例10: declaredAnnotations
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
private synchronized Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
if (declaredAnnotations == null) {
declaredAnnotations = AnnotationParser.parseAnnotations(
annotations, sun.misc.SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
getDeclaringClass());
}
return declaredAnnotations;
}
示例11: createAnnotationInstance
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
private static <A extends Annotation> A createAnnotationInstance(Map<String, Object> customValues,
Class<A> annotationType) {
Map<String, Object> values = new HashMap<>();
// Extract default values from annotation
for (Method method : annotationType.getDeclaredMethods()) {
values.put(method.getName(), method.getDefaultValue());
}
// Populate required values
values.putAll(customValues);
return (A) AnnotationParser.annotationForMap(annotationType, values);
}
示例12: declaredAnnotations
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
private synchronized Map<Class, Annotation> declaredAnnotations() {
if (declaredAnnotations == null) {
declaredAnnotations = AnnotationParser.parseAnnotations(
annotations, sun.misc.SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
getDeclaringClass());
}
return declaredAnnotations;
}
示例13: getParameterAnnotations
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
/**
* Returns an array of arrays that represent the annotations on the formal
* parameters, in declaration order, of the method represented by
* this <tt>Constructor</tt> 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;
}
示例14: getDefaultValue
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
/**
* Returns the default value for the annotation member represented by
* this <tt>Method</tt> 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 <tt>Method</tt> 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;
}
示例15: getParameterAnnotations
import sun.reflect.annotation.AnnotationParser; //导入依赖的package包/类
/**
* 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;
}