From fee0ad33abceb0219076dde05c9d5d9ba950000f Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 6 Feb 2018 05:42:03 +0100 Subject: [jdk9] add support for using lombok with JDK9 code when compiling using the new module syntax, and having module-info.java files in your source. --- src/core9/module-info.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/core9/module-info.java (limited to 'src/core9') diff --git a/src/core9/module-info.java b/src/core9/module-info.java new file mode 100644 index 00000000..a4c97a89 --- /dev/null +++ b/src/core9/module-info.java @@ -0,0 +1,18 @@ +module lombok { + requires java.compiler; + requires java.instrument; + requires jdk.unsupported; + + exports lombok; + exports lombok.experimental; + exports lombok.extern.apachecommons; + exports lombok.extern.java; + exports lombok.extern.jbosslog; + exports lombok.extern.log4j; + exports lombok.extern.slf4j; + + provides javax.annotation.processing.Processor with lombok.launch.AnnotationProcessorHider.AnnotationProcessor; +// provides javax.annotation.processing.Processor with lombok.launch.AnnotationProcessorHider.ClaimingProcessor; + provides org.mapstruct.ap.spi.AstModifyingAnnotationProcessor with lombok.launch.AnnotationProcessorHider.AstModificationNotifier; +} + -- cgit From b6f17ef81acdff9896a8e2b2eced40223491ed4e Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 6 Feb 2018 06:09:48 +0100 Subject: [jdk9] added a best-effort attempt to claim away lombok annotations when lombok is deployed in JDK9-module mode. Due to a bug or oversight in jigsaw it is no longer possible to supply 2 providers for the Processor service, which was the common and as far as I know only way to deal with the situation that you want to claim a subset of annotations but look at all of them (which is what lombok wants to do). --- src/core/lombok/core/AnnotationProcessor.java | 17 ++++++++++++++++- src/core9/module-info.java | 1 - 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/core9') diff --git a/src/core/lombok/core/AnnotationProcessor.java b/src/core/lombok/core/AnnotationProcessor.java index 5531ad8e..64b8de43 100644 --- a/src/core/lombok/core/AnnotationProcessor.java +++ b/src/core/lombok/core/AnnotationProcessor.java @@ -40,6 +40,7 @@ import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; import javax.lang.model.SourceVersion; import javax.lang.model.element.Element; +import javax.lang.model.element.Name; import javax.lang.model.element.TypeElement; import javax.tools.Diagnostic.Kind; @@ -163,7 +164,21 @@ public class AnnotationProcessor extends AbstractProcessor { for (ProcessorDescriptor proc : active) proc.process(annotations, roundEnv); - return false; + boolean onlyLombok = true; + boolean zeroElems = true; + for (TypeElement elem : annotations) { + zeroElems = false; + Name n = elem.getQualifiedName(); + if (n.length() > 7 && n.subSequence(0, 7).toString().equals("lombok.")) continue; + onlyLombok = false; + } + + // Normally we rely on the claiming processor to claim away all lombok annotations. + // One of the many Java9 oversights is that this 'process' API has not been fixed to address the point that 'files I want to look at' and 'annotations I want to claim' must be one and the same, + // and yet in java9 you can no longer have 2 providers for the same service, thus, if you go by module path, lombok no longer loads the ClaimingProcessor. + // This doesn't do as good a job, but it'll have to do. The only way to go from here, I think, is either 2 modules, or use reflection hackery to add ClaimingProcessor during our init. + + return onlyLombok && !zeroElems; } /** diff --git a/src/core9/module-info.java b/src/core9/module-info.java index a4c97a89..f11e2922 100644 --- a/src/core9/module-info.java +++ b/src/core9/module-info.java @@ -12,7 +12,6 @@ module lombok { exports lombok.extern.slf4j; provides javax.annotation.processing.Processor with lombok.launch.AnnotationProcessorHider.AnnotationProcessor; -// provides javax.annotation.processing.Processor with lombok.launch.AnnotationProcessorHider.ClaimingProcessor; provides org.mapstruct.ap.spi.AstModifyingAnnotationProcessor with lombok.launch.AnnotationProcessorHider.AstModificationNotifier; } -- cgit From 42961e8921cd98f688252eedc68cbe0baa0496ea Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 7 Feb 2018 00:49:08 +0100 Subject: [trivial] copyright header year bump to 2018 --- build.xml | 2 +- src/core/lombok/bytecode/ClassFileMetaData.java | 2 +- src/core/lombok/core/AnnotationProcessor.java | 2 +- src/core/lombok/core/LombokInternalAliasing.java | 2 +- src/core/lombok/core/handlers/HandlerUtil.java | 2 +- .../lombok/eclipse/handlers/EclipseHandlerUtil.java | 2 +- src/core/lombok/eclipse/handlers/HandleBuilder.java | 2 +- .../eclipse/handlers/HandleBuilderDefault.java | 21 +++++++++++++++++++++ .../javac/apt/InterceptingJavaFileManager.java | 2 +- .../lombok/javac/handlers/HandleBuilderDefault.java | 21 +++++++++++++++++++++ .../lombok/javac/handlers/JavacHandlerUtil.java | 2 +- src/core9/module-info.java | 21 +++++++++++++++++++++ .../lombok/delombok/DocCommentIntegrator.java | 2 +- src/eclipseAgent/lombok/eclipse/agent/PatchVal.java | 2 +- .../lombok/eclipse/agent/PatchValEclipse.java | 2 +- src/launch/lombok/launch/AnnotationProcessor.java | 2 +- src/utils/lombok/javac/Javac.java | 2 +- 17 files changed, 77 insertions(+), 14 deletions(-) (limited to 'src/core9') diff --git a/build.xml b/build.xml index 914b658b..3a8d6c14 100644 --- a/build.xml +++ b/build.xml @@ -1,5 +1,5 @@