Class GraalVmProcessor

  • All Implemented Interfaces:
    javax.annotation.processing.Processor

    @SupportedAnnotationTypes({"org.apache.logging.log4j.core.config.plugins.validation.Constraint","org.apache.logging.log4j.core.config.plugins.Plugin","org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute","org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory","org.apache.logging.log4j.core.config.plugins.PluginConfiguration","org.apache.logging.log4j.core.config.plugins.PluginElement","org.apache.logging.log4j.core.config.plugins.PluginFactory","org.apache.logging.log4j.core.config.plugins.PluginLoggerContext","org.apache.logging.log4j.core.config.plugins.PluginNode","org.apache.logging.log4j.core.config.plugins.PluginValue","org.apache.logging.log4j.core.config.plugins.PluginVisitorStrategy"})
    @SupportedOptions({"log4j.graalvm.groupId","log4j.graalvm.artifactId"})
    public class GraalVmProcessor
    extends javax.annotation.processing.AbstractProcessor
    Java annotation processor that generates GraalVM metadata.

    Note: The annotations listed here must also be classified by the Annotations helper.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void addField​(javax.lang.model.element.TypeElement parent, javax.lang.model.element.VariableElement element)  
      private void addMethod​(javax.lang.model.element.TypeElement parent, javax.lang.model.element.ExecutableElement element)  
      (package private) java.lang.String getReachabilityMetadataPath​(@Nullable java.lang.String groupId, @Nullable java.lang.String artifactId, java.lang.String fallbackFolderName)
      Returns the path to the reachability metadata file.
      javax.lang.model.SourceVersion getSupportedSourceVersion()  
      void init​(javax.annotation.processing.ProcessingEnvironment processingEnv)  
      boolean process​(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations, javax.annotation.processing.RoundEnvironment roundEnv)  
      private void processConstraintOrVisitor​(javax.lang.model.element.Element element, javax.lang.model.element.TypeElement annotation)  
      private void processFactory​(javax.lang.model.element.Element element)  
      private void processParameter​(javax.lang.model.element.Element element)  
      private void processPlugin​(javax.lang.model.element.Element element)  
      private <T extends javax.lang.model.element.Element>
      T
      safeCast​(javax.lang.model.element.Element element, java.lang.Class<T> type)  
      private java.lang.String toString​(javax.lang.model.element.TypeElement element)
      Returns the fully qualified name of the element corresponding to a DeclaredType.
      private java.lang.String toString​(javax.lang.model.type.TypeMirror type)
      Returns the fully qualified name of a type.
      private void writeReachabilityMetadata()  
      • Methods inherited from class javax.annotation.processing.AbstractProcessor

        getCompletions, getSupportedAnnotationTypes, getSupportedOptions, isInitialized
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PROCESSOR_NAME

        private static final java.lang.String PROCESSOR_NAME
      • processedElements

        private final java.util.List<javax.lang.model.element.Element> processedElements
    • Constructor Detail

      • GraalVmProcessor

        public GraalVmProcessor()
    • Method Detail

      • init

        public void init​(javax.annotation.processing.ProcessingEnvironment processingEnv)
        Specified by:
        init in interface javax.annotation.processing.Processor
        Overrides:
        init in class javax.annotation.processing.AbstractProcessor
      • getSupportedSourceVersion

        public javax.lang.model.SourceVersion getSupportedSourceVersion()
        Specified by:
        getSupportedSourceVersion in interface javax.annotation.processing.Processor
        Overrides:
        getSupportedSourceVersion in class javax.annotation.processing.AbstractProcessor
      • process

        public boolean process​(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations,
                               javax.annotation.processing.RoundEnvironment roundEnv)
        Specified by:
        process in interface javax.annotation.processing.Processor
        Specified by:
        process in class javax.annotation.processing.AbstractProcessor
      • processPlugin

        private void processPlugin​(javax.lang.model.element.Element element)
      • processConstraintOrVisitor

        private void processConstraintOrVisitor​(javax.lang.model.element.Element element,
                                                javax.lang.model.element.TypeElement annotation)
      • processParameter

        private void processParameter​(javax.lang.model.element.Element element)
      • processFactory

        private void processFactory​(javax.lang.model.element.Element element)
      • writeReachabilityMetadata

        private void writeReachabilityMetadata()
      • getReachabilityMetadataPath

        java.lang.String getReachabilityMetadataPath​(@Nullable java.lang.String groupId,
                                                     @Nullable java.lang.String artifactId,
                                                     java.lang.String fallbackFolderName)
        Returns the path to the reachability metadata file.

        If the groupId or artifactId is not specified, a warning is printed and a fallback folder name is used. The fallback folder name should be reproducible, but unique enough to avoid conflicts.

        Parameters:
        groupId - The group ID of the plugin.
        artifactId - The artifact ID of the plugin.
        fallbackFolderName - The fallback folder name to use if groupId or artifactId is not specified.
      • addField

        private void addField​(javax.lang.model.element.TypeElement parent,
                              javax.lang.model.element.VariableElement element)
      • addMethod

        private void addMethod​(javax.lang.model.element.TypeElement parent,
                               javax.lang.model.element.ExecutableElement element)
      • safeCast

        private <T extends javax.lang.model.element.Element> T safeCast​(javax.lang.model.element.Element element,
                                                                        java.lang.Class<T> type)
      • toString

        private java.lang.String toString​(javax.lang.model.type.TypeMirror type)
        Returns the fully qualified name of a type.
        Parameters:
        type - A Java type.
      • toString

        private java.lang.String toString​(javax.lang.model.element.TypeElement element)
        Returns the fully qualified name of the element corresponding to a DeclaredType.
        Parameters:
        element - A Java language element.