Skip to content

Commit

Permalink
Merge pull request #32784 from rsvoboda/remo.deprecated.classAnnotation
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi authored Apr 26, 2023
2 parents aa5b9b3 + 6d40f47 commit 2c39693
Show file tree
Hide file tree
Showing 50 changed files with 106 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static boolean isSameStructure(ClassInfo clazz, ClassInfo old) {
if (!clazz.interfaceNames().equals(old.interfaceNames())) {
return false;
}
if (!compareAnnotations(clazz.classAnnotations(), old.classAnnotations())) {
if (!compareAnnotations(clazz.declaredAnnotations(), old.declaredAnnotations())) {
return false;
}
if (old.fields().size() != clazz.fields().size()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ private DiscoveryResult discoverTestClasses() {
if (instance.target().kind() == AnnotationTarget.Kind.METHOD) {
ClassInfo classInfo = instance.target().asMethod().declaringClass();
allTestClasses.add(classInfo.name());
if (classInfo.classAnnotation(NESTED) != null) {
if (classInfo.declaredAnnotation(NESTED) != null) {
var enclosing = classInfo.enclosingClass();
if (enclosing != null) {
enclosingClasses.put(classInfo.name(), enclosing);
Expand All @@ -590,7 +590,7 @@ private DiscoveryResult discoverTestClasses() {
} else if (instance.target().kind() == AnnotationTarget.Kind.FIELD) {
ClassInfo classInfo = instance.target().asField().declaringClass();
allTestClasses.add(classInfo.name());
if (classInfo.classAnnotation(NESTED) != null) {
if (classInfo.declaredAnnotation(NESTED) != null) {
var enclosing = classInfo.enclosingClass();
if (enclosing != null) {
enclosingClasses.put(classInfo.name(), enclosing);
Expand Down Expand Up @@ -639,7 +639,7 @@ private DiscoveryResult discoverTestClasses() {
@Override
public String apply(Class<?> aClass) {
ClassInfo def = index.getClassByName(DotName.createSimple(aClass.getName()));
AnnotationInstance testProfile = def.classAnnotation(TEST_PROFILE);
AnnotationInstance testProfile = def.declaredAnnotation(TEST_PROFILE);
if (testProfile == null) {
return "$$" + aClass.getName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ List<AmazonLambdaBuildItem> discover(CombinedIndexBuildItem combinedIndexBuildIt
.produce(ReflectiveClassBuildItem.builder(lambda).methods().build());

String cdiName = null;
AnnotationInstance named = info.classAnnotation(NAMED);
AnnotationInstance named = info.declaredAnnotation(NAMED);
if (named != null) {
cdiName = named.value().asString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Collection<DotName> getCustomScopeNames() {
*/
public boolean isCustomScopeDeclaredOn(ClassInfo clazz) {
for (DotName scope : customScopeNames) {
if (clazz.classAnnotation(scope) != null) {
if (clazz.declaredAnnotation(scope) != null) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ List<AnnotationInstance> findAnnotations(AnnotationTarget target, DotName annota
AnnotationInstance container;
switch (target.kind()) {
case CLASS:
annotation = target.asClass().classAnnotation(annotationName);
container = target.asClass().classAnnotation(containingAnnotationName);
annotation = target.asClass().declaredAnnotation(annotationName);
container = target.asClass().declaredAnnotation(containingAnnotationName);
break;
case FIELD:
annotation = target.asField().annotation(annotationName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void implicitReflectiveBeanClasses(BuildProducer<ReflectiveBeanClassBuildItem> r

for (BeanInfo classBean : beanDiscoveryFinished.beanStream().classBeans()) {
ClassInfo beanClass = classBean.getTarget().get().asClass();
AnnotationInstance annotation = beanClass.classAnnotation(registerForReflection);
AnnotationInstance annotation = beanClass.declaredAnnotation(registerForReflection);
if (annotation != null) {
Type[] targets = annotation.value("targets") != null ? annotation.value("targets").asClassArray()
: new Type[] {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static UnremovableBeanBuildItem targetWithAnnotation(DotName annotationNa
@Override
public boolean test(BeanInfo bean) {
if (bean.isClassBean()) {
return Annotations.contains(bean.getTarget().get().asClass().classAnnotations(), annotationName);
return Annotations.contains(bean.getTarget().get().asClass().declaredAnnotations(), annotationName);
} else if (bean.isProducerMethod()) {
return !getAnnotations(Kind.METHOD, annotationName, bean.getTarget().get().asMethod().annotations())
.isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void validateCacheAnnotationsAndProduceCacheNames(CombinedIndexBuildItem combine
*/
if (container.target().kind() == METHOD) {
MethodInfo methodInfo = container.target().asMethod();
if (methodInfo.declaringClass().classAnnotation(REGISTER_REST_CLIENT) != null) {
if (methodInfo.declaringClass().declaredAnnotation(REGISTER_REST_CLIENT) != null) {
throwables.add(new UnsupportedRepeatedAnnotationException(methodInfo));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void transform(TransformationContext transformationContext) {
}
Transformation transformation = transformationContext.transform();
transformation.add(BuiltinScope.DEPENDENT.getName());
if (clazz.classAnnotation(DotNames.TYPED) == null) {
if (clazz.declaredAnnotation(DotNames.TYPED) == null) {
// Add @Typed(MySubresource.class)
transformation.add(createTypedAnnotationInstance(clazz));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static GrpcInterceptors gatherInterceptors(IndexView index, DotName interceptorI
|| Modifier.isInterface(interceptorImplClass.flags())) {
continue;
}
if (interceptorImplClass.classAnnotation(GLOBAL_INTERCEPTOR) == null) {
if (interceptorImplClass.declaredAnnotation(GLOBAL_INTERCEPTOR) == null) {
nonGlobalInterceptors.add(interceptorImplClass.name().toString());
} else {
globalInterceptors.add(interceptorImplClass.name().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void processGeneratedBeans(CombinedIndexBuildItem index, BuildProducer<Annotatio
ClassInfo userDefinedBean = null;
for (ClassInfo candidate : serviceCandidates) {
// The bean must be annotated with @GrpcService
if (candidate.classAnnotation(GrpcDotNames.GRPC_SERVICE) != null) {
if (candidate.declaredAnnotation(GrpcDotNames.GRPC_SERVICE) != null) {
userDefinedBean = candidate;
break;
}
Expand Down Expand Up @@ -312,7 +312,7 @@ private static boolean methodIsBlocking(List<ClassInfo> classes, String methodNa
BlockingMode methodMode = BlockingMode.UNDEFINED;
for (int i = 0; i < classes.size(); i++) {
ClassInfo ci = classes.get(i);
Predicate<DotName> annotationOnClass = annotationName -> ci.classAnnotation(annotationName) != null;
Predicate<DotName> annotationOnClass = annotationName -> ci.declaredAnnotation(annotationName) != null;
MethodInfo method = ci.method(methodName, methodArgs);

classModeInherited = inheritedBlockingMode(annotationOnClass, classModeInherited);
Expand All @@ -334,7 +334,7 @@ private static boolean methodIsBlocking(List<ClassInfo> classes, String methodNa
if (methodMode == BlockingMode.UNDEFINED) {
for (i++; i < classes.size(); i++) {
ClassInfo ci2 = classes.get(i);
annotationOnClass = annotationName -> ci2.classAnnotation(annotationName) != null;
annotationOnClass = annotationName -> ci2.declaredAnnotation(annotationName) != null;
classModeInherited = inheritedBlockingMode(annotationOnClass, classModeInherited);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1329,8 +1329,8 @@ public static Map<String, Set<String>> getModelClassesAndPackagesPerPersistenceU
Set<String> relatedModelClassNames = getRelatedModelClassNames(index, jpaModel.getAllModelClassNames(),
modelClassInfo);

if (modelClassInfo != null && (modelClassInfo.classAnnotation(ClassNames.QUARKUS_PERSISTENCE_UNIT) != null
|| modelClassInfo.classAnnotation(ClassNames.QUARKUS_PERSISTENCE_UNIT_REPEATABLE_CONTAINER) != null)) {
if (modelClassInfo != null && (modelClassInfo.declaredAnnotation(ClassNames.QUARKUS_PERSISTENCE_UNIT) != null
|| modelClassInfo.declaredAnnotation(ClassNames.QUARKUS_PERSISTENCE_UNIT_REPEATABLE_CONTAINER) != null)) {
modelClassesWithPersistenceUnitAnnotations.add(modelClassInfo.name().toString());
}

Expand Down Expand Up @@ -1390,8 +1390,8 @@ private static Set<String> getRelatedModelClassNames(IndexView index, Set<String
Set<String> relatedModelClassNames = new HashSet<>();

// for now we only deal with entities and mapped super classes
if (modelClassInfo.classAnnotation(ClassNames.JPA_ENTITY) == null &&
modelClassInfo.classAnnotation(ClassNames.MAPPED_SUPERCLASS) == null) {
if (modelClassInfo.declaredAnnotation(ClassNames.JPA_ENTITY) == null &&
modelClassInfo.declaredAnnotation(ClassNames.MAPPED_SUPERCLASS) == null) {
return Collections.emptySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ private static void collectPackage(Collector collector, ClassInfo classOrPackage
private static void collectModelType(Collector collector, ClassInfo modelClass) {
String name = modelClass.name().toString();
collector.modelTypes.add(name);
if (modelClass.classAnnotation(ClassNames.JPA_ENTITY) != null) {
if (modelClass.declaredAnnotation(ClassNames.JPA_ENTITY) != null) {
collector.entityTypes.add(name);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private Set<DotName> findClassesWithMethodsAnnotatedWith(Index index, DotName an
}

private boolean allowsTargetType(ClassInfo annotation, ElementType targetType) {
AnnotationInstance targetAnnotation = annotation.classAnnotation(TARGET);
AnnotationInstance targetAnnotation = annotation.declaredAnnotation(TARGET);
if (targetAnnotation == null) {
// Can target anything
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void transform(TransformationContext ctx) {
} else if (ctx.isClass()) {
classInfo = target.asClass();
// skip @Interceptor
if (target.asClass().classAnnotation(DotNames.INTERCEPTOR) != null) {
if (target.asClass().declaredAnnotation(DotNames.INTERCEPTOR) != null) {
return;
}
}
Expand Down Expand Up @@ -84,8 +84,8 @@ static boolean removeCountedWhenTimed(DotName sourceAnnotation, AnnotationTarget
MethodInfo methodInfo) {
if (MetricDotNames.COUNTED_ANNOTATION.equals(sourceAnnotation)) {
if (methodInfo == null) {
if (!Annotations.contains(classInfo.classAnnotations(), MetricDotNames.TIMED_ANNOTATION) &&
!Annotations.contains(classInfo.classAnnotations(), MetricDotNames.SIMPLY_TIMED_ANNOTATION)) {
if (!Annotations.contains(classInfo.declaredAnnotations(), MetricDotNames.TIMED_ANNOTATION) &&
!Annotations.contains(classInfo.declaredAnnotations(), MetricDotNames.SIMPLY_TIMED_ANNOTATION)) {
return false;
}
log.warnf("Bean %s is both counted and timed. The @Counted annotation " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private Collection<AnnotationInstance> collectAnnotationsToCopy(DotName classNam
return annotations;
}

for (AnnotationInstance annotation : classInfo.classAnnotations()) {
for (AnnotationInstance annotation : classInfo.declaredAnnotations()) {
if (ANNOTATIONS_TO_COPY.stream().anyMatch(annotation.name().toString()::startsWith)) {
annotations.add(annotation);
}
Expand All @@ -76,8 +76,8 @@ private AnnotationInstance findResourcePropertiesAnnotation(DotName className) {
if (classInfo == null) {
return null;
}
if (classInfo.classAnnotation(RESOURCE_PROPERTIES_ANNOTATION) != null) {
return classInfo.classAnnotation(RESOURCE_PROPERTIES_ANNOTATION);
if (classInfo.declaredAnnotation(RESOURCE_PROPERTIES_ANNOTATION) != null) {
return classInfo.declaredAnnotation(RESOURCE_PROPERTIES_ANNOTATION);
}
if (classInfo.superName() != null) {
return findResourcePropertiesAnnotation(classInfo.superName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void validateBeanDeployment(
// NOTE: inherited business methods are not taken into account
ClassInfo beanClass = bean.getTarget().get().asClass();
AnnotationInstance routeBaseAnnotation = beanClass
.classAnnotation(DotNames.ROUTE_BASE);
.declaredAnnotation(DotNames.ROUTE_BASE);
for (MethodInfo method : beanClass.methods()) {
if (method.isSynthetic() || Modifier.isStatic(method.flags()) || method.name().equals("<init>")) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private void warnAboutNotWorkingFeaturesInNative(PackageConfig packageConfig, Ma
}
Set<DotName> dotNames = new HashSet<>();
for (ClassInfo interfaze : interfaces.values()) {
if (interfaze.classAnnotation(CLIENT_HEADER_PARAM) != null) {
if (interfaze.declaredAnnotation(CLIENT_HEADER_PARAM) != null) {
boolean hasDefault = false;
for (MethodInfo method : interfaze.methods()) {
if (isDefault(method.flags())) {
Expand Down Expand Up @@ -448,7 +448,7 @@ private ScopeInfo computeDefaultScope(Capabilities capabilities, Config config,
}

private String getAnnotationParameter(ClassInfo classInfo, String parameterName) {
AnnotationInstance instance = classInfo.classAnnotation(REGISTER_REST_CLIENT);
AnnotationInstance instance = classInfo.declaredAnnotation(REGISTER_REST_CLIENT);
if (instance == null) {
return "";
}
Expand Down Expand Up @@ -566,7 +566,7 @@ void unremovableInterceptors(List<RestClientBuildItem> restClientInterfaces, Bea
ClassInfo restClientClass = index.getClassByName(DotName.createSimple(restClient.getInterfaceName()));
if (restClientClass != null) {
Set<AnnotationInstance> classLevelBindings = new HashSet<>();
for (AnnotationInstance annotationInstance : restClientClass.classAnnotations()) {
for (AnnotationInstance annotationInstance : restClientClass.declaredAnnotations()) {
if (interceptorBindings.contains(annotationInstance.name())) {
classLevelBindings.add(annotationInstance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ private static boolean collectDeclaredProvidersForMethodAndMediaTypeAnnotation(S
if (mediaTypeMethodAnnotationInstance == null) {
// no media types defined on the method, let's consider the class annotations
AnnotationInstance mediaTypeClassAnnotationInstance = methodTarget.declaringClass()
.classAnnotation(mediaTypeAnnotation);
.declaredAnnotation(mediaTypeAnnotation);
if (mediaTypeClassAnnotationInstance != null) {
AnnotationValue mediaTypeClassValue = mediaTypeClassAnnotationInstance.value();
if ((mediaTypeClassValue != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ public boolean appliesTo(Kind kind) {
@Override
public void transform(TransformationContext context) {
ClassInfo clazz = context.getTarget().asClass();
if (clazz.classAnnotation(ResteasyDotNames.PATH) != null) {
if (clazz.declaredAnnotation(ResteasyDotNames.PATH) != null) {
// Root resources - no need to add scope, @Path is a bean defining annotation
if (clazz.classAnnotation(DotNames.TYPED) == null) {
if (clazz.declaredAnnotation(DotNames.TYPED) == null) {
// Add @Typed(MyResource.class)
context.transform().add(createTypedAnnotationInstance(clazz)).done();
}
Expand All @@ -440,14 +440,14 @@ public void transform(TransformationContext context) {
// Skip classes annotated with built-in scope
return;
}
if (clazz.classAnnotation(ResteasyDotNames.PROVIDER) != null) {
if (clazz.declaredAnnotation(ResteasyDotNames.PROVIDER) != null) {
Transformation transformation = null;
if (clazz.annotationsMap().containsKey(DotNames.INJECT)
|| hasAutoInjectAnnotation(autoInjectAnnotationNames, clazz)) {
// A provider with an injection point but no built-in scope is @Singleton
transformation = context.transform().add(BuiltinScope.SINGLETON.getName());
}
if (clazz.classAnnotation(DotNames.TYPED) == null) {
if (clazz.declaredAnnotation(DotNames.TYPED) == null) {
// Add @Typed(MyProvider.class)
if (transformation == null) {
transformation = context.transform();
Expand All @@ -462,7 +462,7 @@ public void transform(TransformationContext context) {
Transformation transformation = context.transform()
.add(resteasyConfig.singletonResources ? BuiltinScope.SINGLETON.getName()
: BuiltinScope.DEPENDENT.getName());
if (clazz.classAnnotation(DotNames.TYPED) == null) {
if (clazz.declaredAnnotation(DotNames.TYPED) == null) {
// Add @Typed(MySubresource.class)
transformation.add(createTypedAnnotationInstance(clazz));
}
Expand Down Expand Up @@ -675,7 +675,7 @@ private static void generateDefaultConstructors(BuildProducer<BytecodeTransforme
}

boolean hasNonJaxRSAnnotations = false;
for (AnnotationInstance instance : classInfo.classAnnotations()) {
for (AnnotationInstance instance : classInfo.declaredAnnotations()) {
final String packageName = packageName(instance.name());
if (packageName == null || !isPackageAllowed(allowedAnnotationPrefixes, packageName)) {
hasNonJaxRSAnnotations = true;
Expand Down
Loading

0 comments on commit 2c39693

Please sign in to comment.