@Test
 public void loadedBySystemClassLoaderDoesNotThrowNullPointerException() {
   AnnotationAccessor accessor =
       new AnnotationAccessor(
           TestSupportedAnnotations.values(), LoadedBySystemClassLoader.class, false);
   accessor.typeHas(null);
 }
  @Test
  public void dynamicClassWithSuppressedWarning() {
    Class<?> type = Instantiator.of(Point.class).instantiateAnonymousSubclass().getClass();
    AnnotationAccessor accessor =
        new AnnotationAccessor(TestSupportedAnnotations.values(), type, true);
    assertFalse(accessor.typeHas(TYPE_CLASS_RETENTION));

    // Checks if the short circuit works
    assertFalse(accessor.typeHas(TYPE_CLASS_RETENTION));
    assertFalse(accessor.fieldHas("x", FIELD_CLASS_RETENTION));
  }
  @Test
  public void dynamicClassThrowsException() {
    Class<?> type = Instantiator.of(Point.class).instantiateAnonymousSubclass().getClass();
    AnnotationAccessor accessor =
        new AnnotationAccessor(TestSupportedAnnotations.values(), type, false);

    thrown.expect(ReflectionException.class);
    thrown.expectMessage(containsString("Cannot read class file"));

    accessor.typeHas(TYPE_CLASS_RETENTION);
  }
  @Test
  public void annotationsArrayParametersAreFoundOnClass() {
    AnnotationWithClassValuesDescriptor annotation = new AnnotationWithClassValuesDescriptor();
    AnnotationAccessor accessor =
        new AnnotationAccessor(
            new Annotation[] {annotation}, AnnotationWithClassValuesContainer.class, false);

    boolean annotationPresent = accessor.typeHas(annotation);

    assertTrue(annotationPresent);
    Set<String> annotations = mapGetDescriptor(annotation);
    assertTrue(annotations.contains("Ljavax/annotation/Nonnull;"));
    assertTrue(annotations.contains("Lnl/jqno/equalsverifier/testhelpers/annotations/NotNull;"));
  }
 private boolean findFieldAnnotationFor(Class<?> type, String fieldName, Annotation annotation) {
   AnnotationAccessor accessor =
       new AnnotationAccessor(TestSupportedAnnotations.values(), type, false);
   return accessor.fieldHas(fieldName, annotation);
 }
 private boolean findTypeAnnotationFor(Class<?> type, Annotation annotation) {
   AnnotationAccessor accessor =
       new AnnotationAccessor(TestSupportedAnnotations.values(), type, false);
   return accessor.typeHas(annotation);
 }
 @Test
 public void regularClassWithSuppressedWarningStillProcessesAnnotation() {
   AnnotationAccessor accessor =
       new AnnotationAccessor(TestSupportedAnnotations.values(), AnnotatedWithClass.class, true);
   assertTrue(accessor.typeHas(TYPE_CLASS_RETENTION));
 }