From bf5831d12ae86cefb7f1bcc45f61285cd03834c9 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Thu, 29 Jan 2026 18:55:22 +0100 Subject: [PATCH] Avoid referring to PluginBuilderAttribute.class in PluginProcessor This makes it easier to build PluginProcessor by itself separately from the rest of log4j-core, and then include that processor when building the rest of core, instead of having to compile all of core twice. --- .../core/config/plugins/processor/PluginProcessor.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java index 6d07f91101f..59e933bf3f1 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java @@ -53,7 +53,6 @@ import javax.tools.StandardLocation; import org.apache.logging.log4j.core.config.plugins.Plugin; import org.apache.logging.log4j.core.config.plugins.PluginAliases; -import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; import org.apache.logging.log4j.util.Strings; /** @@ -84,9 +83,13 @@ public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } + private static final String PLUGIN_BUILDER_ATTRIBUTE_ANNOTATION = + "org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute"; + @Override public boolean process(final Set annotations, final RoundEnvironment roundEnv) { final Messager messager = processingEnv.getMessager(); + final Elements elementUtils = processingEnv.getElementUtils(); // Process the elements for this round if (!annotations.isEmpty()) { final Set elements = roundEnv.getElementsAnnotatedWith(Plugin.class); @@ -95,7 +98,8 @@ public boolean process(final Set annotations, final Round // process plugin builder Attributes final Set pluginAttributeBuilderElements = - roundEnv.getElementsAnnotatedWith(PluginBuilderAttribute.class); + roundEnv.getElementsAnnotatedWith( + elementUtils.getTypeElement(PLUGIN_BUILDER_ATTRIBUTE_ANNOTATION)); processBuilderAttribute(pluginAttributeBuilderElements); processedElements.addAll(pluginAttributeBuilderElements); }