From 70256754c2587361c9f70287f62c1e3fd2dede10 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 28 Aug 2012 09:14:41 +0200 Subject: If the JVM is started with -Dlombok.disable, lombok is disabled entirely for both eclipse/ecj and javac operations. --- src/core/lombok/eclipse/TransformEclipseAST.java | 38 ++++++++++++++---------- src/core/lombok/javac/apt/Processor.java | 7 +++++ 2 files changed, 29 insertions(+), 16 deletions(-) (limited to 'src/core/lombok') diff --git a/src/core/lombok/eclipse/TransformEclipseAST.java b/src/core/lombok/eclipse/TransformEclipseAST.java index 63783734..89d23fbd 100644 --- a/src/core/lombok/eclipse/TransformEclipseAST.java +++ b/src/core/lombok/eclipse/TransformEclipseAST.java @@ -62,25 +62,31 @@ public class TransformEclipseAST { Field f = null; HandlerLibrary h = null; - try { - h = HandlerLibrary.load(); - } catch (Throwable t) { + if (System.getProperty("lombok.disable") != null) { + disableLombok = true; + astCacheField = null; + handlers = null; + } else { try { - error(null, "Problem initializing lombok", t); - } catch (Throwable t2) { - System.err.println("Problem initializing lombok"); - t.printStackTrace(); + h = HandlerLibrary.load(); + } catch (Throwable t) { + try { + error(null, "Problem initializing lombok", t); + } catch (Throwable t2) { + System.err.println("Problem initializing lombok"); + t.printStackTrace(); + } + disableLombok = true; } - disableLombok = true; - } - try { - f = CompilationUnitDeclaration.class.getDeclaredField("$lombokAST"); - } catch (Throwable t) { - //I guess we're in an ecj environment; we'll just not cache stuff then. + try { + f = CompilationUnitDeclaration.class.getDeclaredField("$lombokAST"); + } catch (Throwable t) { + //I guess we're in an ecj environment; we'll just not cache stuff then. + } + + astCacheField = f; + handlers = h; } - - astCacheField = f; - handlers = h; } public static void transform_swapped(CompilationUnitDeclaration ast, Parser parser) { diff --git a/src/core/lombok/javac/apt/Processor.java b/src/core/lombok/javac/apt/Processor.java index 94e0e644..96150b06 100644 --- a/src/core/lombok/javac/apt/Processor.java +++ b/src/core/lombok/javac/apt/Processor.java @@ -75,10 +75,16 @@ public class Processor extends AbstractProcessor { private JavacProcessingEnvironment processingEnv; private JavacTransformer transformer; private Trees trees; + private boolean lombokDisabled = false; /** {@inheritDoc} */ @Override public void init(ProcessingEnvironment procEnv) { super.init(procEnv); + if (System.getProperty("lombok.disable") != null) { + lombokDisabled = true; + return; + } + this.processingEnv = (JavacProcessingEnvironment) procEnv; placePostCompileAndDontMakeForceRoundDummiesHook(); transformer = new JavacTransformer(procEnv.getMessager()); @@ -223,6 +229,7 @@ public class Processor extends AbstractProcessor { /** {@inheritDoc} */ @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (lombokDisabled) return false; if (roundEnv.processingOver()) return false; // We have: A sorted set of all priority levels: 'priorityLevels' -- cgit