diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lombok/core/PostCompiler.java | 10 | ||||
-rw-r--r-- | src/core/lombok/javac/JavacAST.java | 9 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleBuilder.java | 2 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/core/lombok/core/PostCompiler.java b/src/core/lombok/core/PostCompiler.java index 72f4b3a2..122bb268 100644 --- a/src/core/lombok/core/PostCompiler.java +++ b/src/core/lombok/core/PostCompiler.java @@ -28,6 +28,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.util.Collections; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; public final class PostCompiler { private PostCompiler() {/* prevent instantiation*/}; @@ -67,8 +68,17 @@ public final class PostCompiler { public static OutputStream wrapOutputStream(final OutputStream originalStream, final String fileName, final DiagnosticsReceiver diagnostics) throws IOException { if (System.getProperty("lombok.disablePostCompiler", null) != null) return originalStream; + + // close() can be called more than once and should be idempotent, therefore, ensure we never transform more than once. + final AtomicBoolean closed = new AtomicBoolean(); + return new ByteArrayOutputStream() { @Override public void close() throws IOException { + if (closed.getAndSet(true)) { + originalStream.close(); + return; + } + // no need to call super byte[] original = toByteArray(); byte[] copy = null; diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java index b3e8930e..f58de60f 100644 --- a/src/core/lombok/javac/JavacAST.java +++ b/src/core/lombok/javac/JavacAST.java @@ -174,7 +174,14 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> { if (sbtMappedVirtualFileRootsField == null) return null; String encodedPath = (String) sbtMappedVirtualFilePathField.get(mappedVirtualFile); - if (!encodedPath.startsWith("${")) return null; + if (!encodedPath.startsWith("${")) { + File maybeAbsoluteFile = new File(encodedPath); + if (maybeAbsoluteFile.exists()) { + return maybeAbsoluteFile.toURI(); + } else { + return null; + } + } int idx = encodedPath.indexOf('}'); if (idx == -1) return null; String base = encodedPath.substring(2, idx); diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java index 1c74ce37..40b59183 100644 --- a/src/core/lombok/javac/handlers/HandleBuilder.java +++ b/src/core/lombok/javac/handlers/HandleBuilder.java @@ -371,7 +371,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> { } List<JCTypeParameter> tpOnMethod = jmd.typarams; - List<JCTypeParameter> tpOnType = ((JCClassDecl) job.builderType.get()).typarams; + List<JCTypeParameter> tpOnType = ((JCClassDecl) job.parentType.get()).typarams; typeArgsForToBuilder = new ArrayList<Name>(); for (JCTypeParameter tp : tpOnMethod) { |