Skip to content

Commit 0bc19de

Browse files
committed
Look for BND annotation on classpath
The processor lives in the annotation processor path, so `Class.forName` does **not** check for the presence of the BND annotation on the classpath.
1 parent 372db59 commit 0bc19de

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

log4j-plugin-processor/src/main/java/org/apache/logging/log4j/plugin/processor/PluginProcessor.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,9 @@ private String commonPrefix(final String str1, final String str2) {
315315
return str1.substring(0, minLength);
316316
}
317317

318-
private static boolean isServiceConsumerClassPresent() {
319-
try {
320-
Class.forName("aQute.bnd.annotation.spi.ServiceConsumer");
321-
return true;
322-
} catch (ClassNotFoundException e) {
323-
return false;
324-
}
318+
private boolean isServiceConsumerClassPresent() {
319+
// Looks for the presence of the annotation on the classpath, not the annotation processor path.
320+
return processingEnv.getElementUtils().getTypeElement("aQute.bnd.annotation.spi.ServiceConsumer") != null;
325321
}
326322

327323
private void handleOptions(Map<String, String> options) {

0 commit comments

Comments
 (0)