From 24adea185f297fb804acef310bcf94c01af9a498 Mon Sep 17 00:00:00 2001 From: Juan Manuel Leflet Estrada Date: Tue, 10 Dec 2024 17:12:33 +0100 Subject: [PATCH] Fix annotations when coming from java.lang (like @Override) Signed-off-by: Juan Manuel Leflet Estrada --- .../konveyor/tackle/core/internal/query/AnnotationQuery.java | 4 ++++ .../tackle/core/internal/symbol/WithAnnotationQuery.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/query/AnnotationQuery.java b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/query/AnnotationQuery.java index 356a95b..6be7564 100644 --- a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/query/AnnotationQuery.java +++ b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/query/AnnotationQuery.java @@ -50,6 +50,10 @@ public boolean matchesAnnotation(String annotation) { // If the annotation query is happening on an annotation, the annotation field in the annotation query can be null if (isOnAnnotation() && getType() == null) { return true; + // Classes in the "java.lang" package are never imported, so there is a chance these annotations don't come + // as FQNs from the LS. Therefore lets check if the annotation is in "java.lang" + } else if (getType().startsWith("java.lang.") && !annotation.contains(".")) { + return Pattern.matches(getType().replace("java.lang.", ""), annotation); } else { return Pattern.matches(getType(), annotation); } diff --git a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/WithAnnotationQuery.java b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/WithAnnotationQuery.java index 5b54b05..7d5995a 100644 --- a/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/WithAnnotationQuery.java +++ b/java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/symbol/WithAnnotationQuery.java @@ -191,7 +191,7 @@ private String getFQN(IAnnotation annotation) { .filter(i -> i.getElementName().endsWith(name)) .findFirst() .map(IImportDeclaration::getElementName) - .orElse(""); + .orElse(name); } }