Search in sources :

Example 6 with AnnotationFormatError

use of java.lang.annotation.AnnotationFormatError in project robovm by robovm.

the class AnnotationFormatErrorTest method test_constructorLjava_lang_String.

/**
     * @tests java.lang.annotation.AnnotationFormatError#AnnotationFormatError(String)
     */
@SuppressWarnings("nls")
public void test_constructorLjava_lang_String() {
    AnnotationFormatError e = new AnnotationFormatError("some message");
    assertEquals("some message", e.getMessage());
}
Also used : AnnotationFormatError(java.lang.annotation.AnnotationFormatError)

Example 7 with AnnotationFormatError

use of java.lang.annotation.AnnotationFormatError in project uPortal by Jasig.

the class RequestCacheAspect method createCacheKey.

protected CacheKey createCacheKey(ProceedingJoinPoint pjp, RequestCache requestCache) {
    final Signature signature = pjp.getSignature();
    final Class<?> declaringType = signature.getDeclaringType();
    final String signatureLongString = signature.toLongString();
    final boolean[] keyMask = requestCache.keyMask();
    final Object[] args = pjp.getArgs();
    final Object[] keyArgs;
    if (keyMask.length == 0) {
        keyArgs = args;
    } else if (keyMask.length != args.length) {
        throw new AnnotationFormatError("RequestCache.keyMask has an invalid length on: " + signature.toLongString());
    } else {
        keyArgs = new Object[args.length];
        for (int i = 0; i < args.length; i++) {
            if (keyMask[i]) {
                keyArgs[i] = args[i];
            }
        }
    }
    return CacheKey.build(signatureLongString, declaringType, keyArgs);
}
Also used : Signature(org.aspectj.lang.Signature) AnnotationFormatError(java.lang.annotation.AnnotationFormatError)

Example 8 with AnnotationFormatError

use of java.lang.annotation.AnnotationFormatError in project jdk8u_jdk by JetBrains.

the class Method method getDefaultValue.

/**
     * 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;
}
Also used : AnnotationFormatError(java.lang.annotation.AnnotationFormatError)

Aggregations

AnnotationFormatError (java.lang.annotation.AnnotationFormatError)8 Outputs (uk.gov.gchq.gaffer.function.annotation.Outputs)2 Signature (org.aspectj.lang.Signature)1 Inputs (uk.gov.gchq.gaffer.function.annotation.Inputs)1