PersistenceUnitMetadata pu = PERSISTENCE_UNIT_METADATA_TLS.get();
if (pu == null) {
throw MESSAGES.missingPersistenceUnitMetadata();
}
if (pu.getAnnotationIndex() != null) {
Index index = getJarFileIndex(jartoScan, pu);
if (index == null) {
JPA_LOGGER.tracef("No classes to scan for annotations in jar '%s' (jars with classes '%s')",
jartoScan, pu.getAnnotationIndex().keySet());
return new HashSet<Class<?>>();
}
if (annotationsToLookFor == null) {
throw MESSAGES.nullVar("annotationsToLookFor");
}
if (annotationsToLookFor.size() == 0) {
throw MESSAGES.emptyParameter("annotationsToLookFor");
}
Set<Class<?>> result = new HashSet<Class<?>>();
for (Class<? extends Annotation> annClass : annotationsToLookFor) {
DotName annotation = DotName.createSimple(annClass.getName());
List<AnnotationInstance> classesWithAnnotation = index.getAnnotations(annotation);
Set<Class<?>> classesForAnnotation = new HashSet<Class<?>>();
for (AnnotationInstance annotationInstance : classesWithAnnotation) {
// verify that the annotation target is actually a class, since some frameworks
// may generate bytecode with annotations placed on methods (see AS7-2559)
if (annotationInstance.target() instanceof ClassInfo) {