Skip to content

Commit

Permalink
Merge pull request #26442 from Ladicek/jandex-2.4.3
Browse files Browse the repository at this point in the history
Update to Jandex 2.4.3 and avoid deprecated methods
  • Loading branch information
gsmet committed Jul 4, 2022
2 parents 9421432 + fb4d23b commit b9d7536
Show file tree
Hide file tree
Showing 123 changed files with 362 additions and 351 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<bouncycastle.fips.version>1.0.2.3</bouncycastle.fips.version>
<bouncycastle.tls.fips.version>1.0.12.3</bouncycastle.tls.fips.version>
<findbugs.version>3.0.2</findbugs.version>
<jandex.version>2.4.2.Final</jandex.version>
<jandex.version>2.4.3.Final</jandex.version>
<resteasy.version>4.7.5.Final</resteasy.version>
<opentracing.version>0.33.0</opentracing.version>
<opentracing-jdbc.version>0.2.4</opentracing-jdbc.version>
Expand Down
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<failsafe-plugin.version>${version.surefire.plugin}</failsafe-plugin.version>

<!-- jandex maven plugin version -->
<jandex-maven-plugin.version>1.2.2</jandex-maven-plugin.version>
<jandex-maven-plugin.version>1.2.3</jandex-maven-plugin.version>

<!-- These properties are needed in order for them to be resolvable by the documentation -->
<!-- The Graal version we suggest using in documentation - as that's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public final class ReflectiveMethodBuildItem extends MultiBuildItem {
final String[] params;

public ReflectiveMethodBuildItem(MethodInfo methodInfo) {
String[] params = new String[methodInfo.parameters().size()];
String[] params = new String[methodInfo.parametersCount()];
for (int i = 0; i < params.length; ++i) {
params[i] = methodInfo.parameters().get(i).name().toString();
params[i] = methodInfo.parameterType(i).name().toString();
}
this.name = methodInfo.name();
this.params = params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static boolean isSameStructure(ClassInfo clazz, ClassInfo old) {
if (!i.returnType().equals(method.returnType())) {
continue;
}
if (i.parameters().size() != method.parameters().size()) {
if (i.parametersCount() != method.parametersCount()) {
continue;
}
if (i.flags() != method.flags()) {
Expand All @@ -76,9 +76,9 @@ static boolean isSameStructure(ClassInfo clazz, ClassInfo old) {
continue;
}
boolean paramEqual = true;
for (int j = 0; j < method.parameters().size(); ++j) {
Type a = method.parameters().get(j);
Type b = i.parameters().get(j);
for (int j = 0; j < method.parametersCount(); ++j) {
Type a = method.parameterType(j);
Type b = i.parameterType(j);
if (!a.equals(b)) {
paramEqual = false;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ private static Set<DotName> collectTestAnnotations(Index index) {
Set<DotName> processed = new HashSet<>();
processed.addAll(ret);
for (ClassInfo clazz : index.getKnownClasses()) {
for (DotName annotation : clazz.annotations().keySet()) {
for (DotName annotation : clazz.annotationsMap().keySet()) {
if (processed.contains(annotation)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public static void indexClass(String className, Indexer indexer, IndexView quark
// The class could be indexed by quarkus - we still need to distinguish framework classes
additionalIndex.add(classDotName);
}
for (DotName annotationName : classInfo.annotations().keySet()) {
for (DotName annotationName : classInfo.annotationsMap().keySet()) {
if (!additionalIndex.contains(annotationName) && quarkusIndex.getClassByName(annotationName) == null) {
try (InputStream annotationStream = IoUtil.readClass(classLoader, annotationName.toString())) {
if (annotationStream == null) {
Expand Down Expand Up @@ -187,7 +187,7 @@ public static void indexClass(String className, Indexer indexer,
// The class could be indexed by quarkus - we still need to distinguish framework classes
additionalIndex.add(classDotName);
}
for (DotName annotationName : classInfo.annotations().keySet()) {
for (DotName annotationName : classInfo.annotationsMap().keySet()) {
if (!additionalIndex.contains(annotationName) && quarkusIndex.getClassByName(annotationName) == null) {
try (InputStream annotationStream = IoUtil.readClass(classLoader, annotationName.toString())) {
log.debugf("Index annotation: %s", annotationName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private void addClassTypeHierarchy(CombinedIndexBuildItem combinedIndexBuildItem
for (MethodInfo method : info.methods()) {
if (reflectiveHierarchyBuildItem.getIgnoreMethodPredicate().test(method) ||
// we will only consider potential getters
method.parameters().size() > 0 ||
method.parametersCount() > 0 ||
Modifier.isStatic(method.flags()) ||
method.returnType().kind() == Kind.VOID) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private static boolean hasSignature(MethodInfo method) {
}
}

for (Type type : method.parameters()) {
for (Type type : method.parameterTypes()) {
if (type.kind() == Kind.TYPE_VARIABLE
|| type.kind() == Kind.UNRESOLVED_TYPE_VARIABLE
|| type.kind() == Kind.PARAMETERIZED_TYPE) {
Expand Down Expand Up @@ -196,7 +196,7 @@ public static String getSignature(MethodInfo method, Function<String, String> ty
}

signature.append('(');
for (Type type : method.parameters()) {
for (Type type : method.parameterTypes()) {
toSignature(signature, type, typeArgMapper, false);
}
signature.append(')');
Expand Down Expand Up @@ -259,7 +259,7 @@ private static boolean hasImplicitObjectBound(TypeVariable typeParameter) {
* @return a bytecode descriptor for that method.
*/
public static String getDescriptor(MethodInfo method, Function<String, String> typeArgMapper) {
List<Type> parameters = method.parameters();
List<Type> parameters = method.parameterTypes();

StringBuilder descriptor = new StringBuilder("(");
for (Type type : parameters) {
Expand Down Expand Up @@ -786,7 +786,7 @@ public static void printValueOnStderr(MethodVisitor mv, Runnable valuePusher) {
* @param method the method to copy from
*/
public static void copyParameterNames(MethodVisitor mv, MethodInfo method) {
int parameterSize = method.parameters().size();
int parameterSize = method.parametersCount();
if (parameterSize > 0) {
// perhaps we don't have parameter names
if (method.parameterName(0) == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ List<AmazonLambdaBuildItem> discover(CombinedIndexBuildItem combinedIndexBuildIt
while (current != null && !done) {
for (MethodInfo method : current.methods()) {
if (method.name().equals("handleRequest")) {
if (method.parameters().size() == 3) {
if (method.parametersCount() == 3) {
streamHandler = true;
done = true;
break;
} else if (method.parameters().size() == 2
&& !method.parameters().get(0).name().equals(DotName.createSimple(Object.class.getName()))) {
} else if (method.parametersCount() == 2
&& !method.parameterType(0).name().equals(DotName.createSimple(Object.class.getName()))) {
String source = getClass().getSimpleName() + " > " + method.declaringClass() + "[" + method + "]";

reflectiveHierarchy.produce(new ReflectiveHierarchyBuildItem.Builder()
.type(method.parameters().get(0))
.type(method.parameterType(0))
.source(source)
.build());
reflectiveHierarchy.produce(new ReflectiveHierarchyBuildItem.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void transform(TransformationContext transformationContext) {
if (defaultScope != null) {
transformationContext.transform().add(defaultScope).done();
} else {
if (!beanClass.annotations().containsKey(ADDITIONAL_BEAN)) {
if (!beanClass.annotationsMap().containsKey(ADDITIONAL_BEAN)) {
// Add special stereotype is added so that @Dependent is automatically used even if no scope is declared
// Otherwise the bean class would be ignored during bean discovery
transformationContext.transform().add(ADDITIONAL_BEAN).done();
Expand Down Expand Up @@ -745,7 +745,7 @@ public void transform(TransformationContext ctx) {
}
}
// Identifier is a hash of "type + method param annotations"
String id = HashUtil.sha1(method.parameters().get(position) + paramAnnotations.toString());
String id = HashUtil.sha1(method.parameterType(position) + paramAnnotations.toString());
toAdd.add(
AnnotationInstance.create(DotNames.IDENTIFIED,
MethodParameterInfo.create(method,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public Builder isAnnotatedWith(DotName annotationName) {
public Builder containsAnnotations(DotName... annotationNames) {
return and((clazz, annotations, index) -> {
for (DotName annotation : annotationNames) {
if (clazz.annotations().containsKey(annotation)) {
if (clazz.annotationsMap().containsKey(annotation)) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ private boolean requiresContainerServices(ClassInfo clazz, Set<DotName> containe
}

private boolean hasContainerAnnotation(ClassInfo clazz, Set<DotName> containerAnnotationNames) {
if (clazz.annotations().isEmpty() || containerAnnotationNames.isEmpty()) {
if (clazz.annotationsMap().isEmpty() || containerAnnotationNames.isEmpty()) {
return false;
}
return containsAny(clazz, containerAnnotationNames);
}

private boolean containsAny(ClassInfo clazz, Set<DotName> annotationNames) {
for (DotName annotation : clazz.annotations().keySet()) {
for (DotName annotation : clazz.annotationsMap().keySet()) {
if (annotationNames.contains(annotation)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void validateConfigMappingsInjectionPoints(
if (target.kind().equals(FIELD)) {
mapping = target.asField().annotation(CONFIG_MAPPING_NAME);
} else if (target.kind().equals(METHOD)) {
List<Type> parameters = target.asMethod().parameters();
List<Type> parameters = target.asMethod().parameterTypes();
for (int i = 0; i < parameters.size(); i++) {
Type parameter = parameters.get(i);
if (parameter.name().equals(type.name())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public boolean test(Index index) {
if (observesInstance.target().kind() == AnnotationTarget.Kind.METHOD_PARAMETER) {
MethodParameterInfo methodParameterInfo = observesInstance.target().asMethodParameter();
short paramPos = methodParameterInfo.position();
if (STARTUP_EVENT_NAME.equals(methodParameterInfo.method().parameters().get(paramPos).name())) {
if (STARTUP_EVENT_NAME.equals(methodParameterInfo.method().parameterType(paramPos).name())) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public BeanClassAnnotationExclusion(DotName name) {
@Override
public boolean test(BeanInfo bean) {
if (bean.isClassBean()) {
Map<DotName, List<AnnotationInstance>> annotations = bean.getTarget().get().asClass().annotations();
Map<DotName, List<AnnotationInstance>> annotations = bean.getTarget().get().asClass().annotationsMap();
if (name != null) {
return annotations.containsKey(name);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,20 @@ public String apply(AnnotationInstance annotationInstance) {
|| (NestingType.INNER == nestingType && !Modifier.isStatic(clazz.flags()))) {
// Annotations declared on the class, incl. the annotations added via transformers
Collection<AnnotationInstance> classAnnotations = transformedAnnotations.getAnnotations(clazz);
if (classAnnotations.isEmpty() && clazz.annotations().isEmpty()) {
if (classAnnotations.isEmpty() && clazz.annotationsMap().isEmpty()) {
continue;
}
if (scopeAnnotations.isScopeIn(classAnnotations)) {
validationErrors.produce(new ValidationErrorBuildItem(
new IllegalStateException(String.format(
"The %s class %s has a scope annotation but it must be ignored per the CDI rules",
clazz.nestingType().toString(), clazz.name().toString()))));
} else if (clazz.annotations().containsKey(DotNames.OBSERVES)) {
} else if (clazz.annotationsMap().containsKey(DotNames.OBSERVES)) {
validationErrors.produce(new ValidationErrorBuildItem(
new IllegalStateException(String.format(
"The %s class %s declares an observer method but it must be ignored per the CDI rules",
clazz.nestingType().toString(), clazz.name().toString()))));
} else if (clazz.annotations().containsKey(DotNames.PRODUCES)) {
} else if (clazz.annotationsMap().containsKey(DotNames.PRODUCES)) {
validationErrors.produce(new ValidationErrorBuildItem(
new IllegalStateException(String.format(
"The %s class %s declares a producer but it must be ignored per the CDI rules",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,10 @@ private ResultHandle populateConfigObject(ClassLoader classLoader, ClassInfo con
if (!method.name().equals("valueOf")) {
continue;
}
if (method.parameters().size() != 1) {
if (method.parametersCount() != 1) {
continue;
}
if (method.parameters().get(0).name().equals(DotNames.STRING)) {
if (method.parameterType(0).name().equals(DotNames.STRING)) {
reflectiveMethods.produce(new ReflectiveMethodBuildItem(method));
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void produceConfigPropertiesMetadata(CombinedIndexBuildItem combinedIndex, ArcCo
} else if (target.kind() == AnnotationTarget.Kind.METHOD_PARAMETER) {
final MethodParameterInfo parameter = target.asMethodParameter();
short position = parameter.position();
classInfo = index.getClassByName(parameter.method().parameters().get(position).name());
classInfo = index.getClassByName(parameter.method().parameterType(position).name());
} else {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private String generateImplementationForInterfaceConfigPropertiesRec(ClassInfo o
|| Modifier.isPrivate(methodModifiers)) {
continue;
}
if (!method.parameters().isEmpty()) {
if (!method.parameterTypes().isEmpty()) {
throw new IllegalArgumentException("Method " + method.name() + " of interface " + ifaceDotName
+ " is not a getter method since it defined parameters");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public ResultHandle handle(Member member, MethodCreator configPopulator, ResultH
getClazz.returnValue(getClazz.loadClassFromTCCL(wrapperClassName));

// generate the getFieldNameMap method by searching for fields annotated with @ConfigProperty
List<AnnotationInstance> configPropertyInstances = classInfo.annotations().get(DotNames.CONFIG_PROPERTY);
List<AnnotationInstance> configPropertyInstances = classInfo.annotationsMap().get(DotNames.CONFIG_PROPERTY);
Map<String, String> fieldNameMap = new HashMap<>();
if (configPropertyInstances != null) {
for (AnnotationInstance instance : configPropertyInstances) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void callInitializer(BeanContainerBuildItem beanContainer, List<InterceptedStati
private void implementForward(ClassCreator initializer,
InterceptedStaticMethodBuildItem interceptedStaticMethod) {
MethodInfo method = interceptedStaticMethod.getMethod();
List<Type> params = method.parameters();
List<Type> params = method.parameterTypes();
Object[] paramTypes = new String[params.size()];
for (int i = 0; i < paramTypes.length; ++i) {
paramTypes[i] = DescriptorUtils.typeToString(params.get(i));
Expand Down Expand Up @@ -295,9 +295,9 @@ private String implementInit(IndexView index, ClassCreator initializer,
ResultHandle[] paramsHandles = new ResultHandle[3];
paramsHandles[0] = init.loadClassFromTCCL(method.declaringClass().name().toString());
paramsHandles[1] = init.load(method.name());
if (!method.parameters().isEmpty()) {
ResultHandle paramsArray = init.newArray(Class.class, init.load(method.parameters().size()));
for (ListIterator<Type> iterator = method.parameters().listIterator(); iterator.hasNext();) {
if (!method.parameterTypes().isEmpty()) {
ResultHandle paramsArray = init.newArray(Class.class, init.load(method.parametersCount()));
for (ListIterator<Type> iterator = method.parameterTypes().listIterator(); iterator.hasNext();) {
init.writeArrayValue(paramsArray, iterator.nextIndex(),
init.loadClassFromTCCL(iterator.next().name().toString()));
}
Expand Down Expand Up @@ -379,7 +379,7 @@ private ResultHandle createForwardingFunction(MethodCreator init, ClassInfo targ
// Function<InvocationContext, Object> forward = ctx -> Foo.interceptMe_original((java.lang.String)ctx.getParameters()[0])
FunctionCreator func = init.createFunction(Function.class);
BytecodeCreator funcBytecode = func.getBytecode();
List<Type> paramTypes = method.parameters();
List<Type> paramTypes = method.parameterTypes();
ResultHandle[] paramHandles;
String[] params;
if (paramTypes.isEmpty()) {
Expand Down Expand Up @@ -491,7 +491,7 @@ public void visitEnd() {
// Invoke the initializer, i.e. Foo_InterceptorInitializer.hash("ping")
MethodDescriptor descriptor = MethodDescriptor.of(interceptedStaticMethod.getMethod());
int paramSlot = 0;
for (Type paramType : interceptedStaticMethod.getMethod().parameters()) {
for (Type paramType : interceptedStaticMethod.getMethod().parameterTypes()) {
superVisitor.visitIntInsn(AsmUtil.getLoadOpcode(paramType), paramSlot);
paramSlot += AsmUtil.getParameterSize(paramType);
}
Expand Down

0 comments on commit b9d7536

Please sign in to comment.