aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcnuessgens <christian@nuessgens.com>2018-01-18 21:18:14 +0100
committercnuessgens <christian@nuessgens.com>2018-01-18 21:18:14 +0100
commit1b6de01bf187def687cb0e757da4295b0790f0ac (patch)
treef86c0951a8669fb67689a92fd9059df7589d17da
parentcdee2996514723dfbcf6ac177d82446acef260f3 (diff)
parent01754d914056b3baa0a6bfe3b20bf5c40f6a5199 (diff)
downloadlombok-1b6de01bf187def687cb0e757da4295b0790f0ac.tar.gz
lombok-1b6de01bf187def687cb0e757da4295b0790f0ac.tar.bz2
lombok-1b6de01bf187def687cb0e757da4295b0790f0ac.zip
Merge remote-tracking branch 'remotes/upstream/master'
-rw-r--r--buildScripts/website.ant.xml2
-rw-r--r--doc/changelog.markdown9
-rw-r--r--src/core/lombok/Cleanup.java4
-rw-r--r--src/core/lombok/Lombok.java5
-rw-r--r--src/core/lombok/core/Version.java2
-rw-r--r--src/core/lombok/javac/JavacResolution.java20
-rw-r--r--src/core/lombok/javac/apt/LombokFileObjects.java10
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java9
-rw-r--r--src/core/lombok/javac/handlers/HandleVal.java25
-rw-r--r--test/transform/resource/after-delombok/BuilderDefaults.java6
-rw-r--r--test/transform/resource/after-delombok/BuilderDefaultsGenerics.java8
11 files changed, 61 insertions, 39 deletions
diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml
index 13b97231..36b3a193 100644
--- a/buildScripts/website.ant.xml
+++ b/buildScripts/website.ant.xml
@@ -223,7 +223,7 @@ such as applying the templates to produce the website, converting the changelog
<classpath refid="build.path" />
<classpath location="build/lombok" />
<header><![CDATA[<a href='https://projectlombok.org/' target='_blank'>Lombok</a> - ]]>v${lombok.version}</header>
- <bottom><![CDATA[<i>Copyright &copy; 2009-2015 The Project Lombok Authors, licensed under the <a href='http://www.opensource.org/licenses/mit-license.php' target='_blank'>MIT licence</a>.]]></bottom>
+ <bottom><![CDATA[<i>Copyright &copy; 2009-2018 The Project Lombok Authors, licensed under the <a href='http://www.opensource.org/licenses/mit-license.php' target='_blank'>MIT licence</a>.]]></bottom>
</javadoc>
<!-- bugfix for boneheaded javadoc bug where ?is-external=true is inserted before an anchor ref, breaking the anchor ref.
is-external=true doesn't actually do anything, so, we'll just get rid of it. -->
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 9e025c24..7172b166 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -1,9 +1,12 @@
Lombok Changelog
----------------
-### v1.16.19 "Edgy Guinea Pig"
-* v1.16.18 is the latest stable release of Project Lombok.
-* PLATFORM: Possible support for jdk9 in the new IntelliJ, Netbeans and for Gradle.
+### v1.16.21 "Edgy Guinea Pig"
+* v1.16.20 is the latest stable release of Project Lombok.
+* Potential fix for Netbeans < 9. [Issue #1555](https://github.com/rzwitserloot/lombok/issues/1555)
+
+### v1.16.20 (January 9th, 2018)
+* PLATFORM: Better support for jdk9 in the new IntelliJ, Netbeans and for Gradle.
* BREAKING CHANGE: _lombok config_ key `lombok.addJavaxGeneratedAnnotation` now defaults to `false` instead of true. Oracle broke this annotation with the release of JDK9, necessitating this breaking change.
* BREAKING CHANGE: _lombok config_ key `lombok.anyConstructor.suppressConstructorProperties` is now deprecated and defaults to `true`, that is, by default lombok no longer automatically generates `@ConstructorProperties` annotations. New config key `lombok.anyConstructor.addConstructorProperties` now exists; set it to `true` if you want the old behavior. Oracle more or less broke this annotation with the release of JDK9, necessitating this breaking change.
* DEVELOPMENT: Compiling lombok on JDK1.9 is now possible.
diff --git a/src/core/lombok/Cleanup.java b/src/core/lombok/Cleanup.java
index 528855cd..a3a1c198 100644
--- a/src/core/lombok/Cleanup.java
+++ b/src/core/lombok/Cleanup.java
@@ -61,10 +61,10 @@ import java.lang.annotation.Target;
* outStream.write(b, 0, r);
* }
* } finally {
- * if (out != null) out.close();
+ * if (outStream != null) outStream.close();
* }
* } finally {
- * if (in != null) in.close();
+ * if (inStream != null) inStream.close();
* }
* }
* </pre>
diff --git a/src/core/lombok/Lombok.java b/src/core/lombok/Lombok.java
index 310b57e3..d86b6d1c 100644
--- a/src/core/lombok/Lombok.java
+++ b/src/core/lombok/Lombok.java
@@ -48,12 +48,11 @@ public class Lombok {
*/
public static RuntimeException sneakyThrow(Throwable t) {
if (t == null) throw new NullPointerException("t");
- Lombok.<RuntimeException>sneakyThrow0(t);
- return null;
+ return Lombok.<RuntimeException>sneakyThrow0(t);
}
@SuppressWarnings("unchecked")
- private static <T extends Throwable> void sneakyThrow0(Throwable t) throws T {
+ private static <T extends Throwable> T sneakyThrow0(Throwable t) throws T {
throw (T)t;
}
diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java
index 18c78b04..98f1e575 100644
--- a/src/core/lombok/core/Version.java
+++ b/src/core/lombok/core/Version.java
@@ -30,7 +30,7 @@ public class Version {
// ** CAREFUL ** - this class must always compile with 0 dependencies (it must not refer to any other sources or libraries).
// Note: In 'X.Y.Z', if Z is odd, its a snapshot build built from the repository, so many different 0.10.3 versions can exist, for example.
// Official builds always end in an even number. (Since 0.10.2).
- private static final String VERSION = "1.16.19";
+ private static final String VERSION = "1.16.21";
private static final String RELEASE_NAME = "Edgy Guinea Pig";
// private static final String RELEASE_NAME = "Dancing Elephant";
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java
index ded6284b..8cc239e1 100644
--- a/src/core/lombok/javac/JavacResolution.java
+++ b/src/core/lombok/javac/JavacResolution.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2015 The Project Lombok Authors.
+ * Copyright (C) 2011-2018 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -31,6 +31,7 @@ import java.util.ArrayDeque;
import java.util.Map;
import javax.lang.model.type.TypeKind;
+import javax.tools.JavaFileObject;
import lombok.Lombok;
import lombok.core.debug.AssertionLogger;
@@ -59,6 +60,7 @@ import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Log;
public class JavacResolution {
private final Attr attr;
@@ -142,9 +144,14 @@ public class JavacResolution {
TreeMirrorMaker mirrorMaker = new TreeMirrorMaker(node.getTreeMaker(), node.getContext());
JCTree copy = mirrorMaker.copy(finder.copyAt());
-
- memberEnterAndAttribute(copy, finder.get(), node.getContext());
- return mirrorMaker.getOriginalToCopyMap();
+ Log log = Log.instance(node.getContext());
+ JavaFileObject oldFileObject = log.useSource(((JCCompilationUnit) node.top().get()).getSourceFile());
+ try {
+ memberEnterAndAttribute(copy, finder.get(), node.getContext());
+ return mirrorMaker.getOriginalToCopyMap();
+ } finally {
+ log.useSource(oldFileObject);
+ }
} finally {
messageSuppressor.enableLoggers();
}
@@ -222,6 +229,11 @@ public class JavacResolution {
}
private void attrib(JCTree tree, Env<AttrContext> env) {
+ if (env.enclClass.type == null) try {
+ env.enclClass.type = Type.noType;
+ } catch (Throwable ignore) {
+ // This addresses issue #1553 which involves JDK9; if it doesn't exist, we probably don't need to set it.
+ }
if (tree instanceof JCBlock) attr.attribStat(tree, env);
else if (tree instanceof JCMethodDecl) attr.attribStat(((JCMethodDecl) tree).body, env);
else if (tree instanceof JCVariableDecl) attr.attribStat(tree, env);
diff --git a/src/core/lombok/javac/apt/LombokFileObjects.java b/src/core/lombok/javac/apt/LombokFileObjects.java
index 37a0b366..7184629f 100644
--- a/src/core/lombok/javac/apt/LombokFileObjects.java
+++ b/src/core/lombok/javac/apt/LombokFileObjects.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2017 The Project Lombok Authors.
+ * Copyright (C) 2010-2018 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -120,23 +120,23 @@ final class LombokFileObjects {
return new Java9Compiler(jfm);
}
}
- catch (Exception e) {}
+ catch (Throwable e) {}
return Compiler.JAVAC7;
}
if (KNOWN_JAVA9_FILE_MANAGERS.contains(jfmClassName)) {
try {
return new Java9Compiler(jfm);
}
- catch (Exception e) {}
+ catch (Throwable e) {}
}
try {
if (Class.forName("com.sun.tools.javac.file.BaseFileObject") == null) throw new NullPointerException();
return Compiler.JAVAC7;
- } catch (Exception e) {}
+ } catch (Throwable e) {}
try {
if (Class.forName("com.sun.tools.javac.util.BaseFileObject") == null) throw new NullPointerException();
return Compiler.JAVAC6;
- } catch (Exception e) {}
+ } catch (Throwable e) {}
StringBuilder sb = new StringBuilder(jfmClassName);
if (jfm != null) {
diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java
index 420d4b72..d5a342e4 100644
--- a/src/core/lombok/javac/handlers/HandleBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2017 The Project Lombok Authors.
+ * Copyright (C) 2013-2018 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -554,11 +554,10 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
for (BuilderFieldData bfd : builderFields) {
if (bfd.nameOfSetFlag != null) {
- args.append(maker.Conditional(maker.Ident(bfd.nameOfSetFlag), maker.Ident(bfd.name),
- maker.Apply(typeParameterNames(maker, ((JCClassDecl) tdParent.get()).typarams), maker.Select(maker.Ident(((JCClassDecl) tdParent.get()).name), bfd.nameOfDefaultProvider), List.<JCExpression>nil())));
- } else {
- args.append(maker.Ident(bfd.name));
+ statements.append(maker.VarDef(maker.Modifiers(0L), bfd.name, cloneType(maker, bfd.type, source, tdParent.getContext()), maker.Select(maker.Ident(type.toName("this")), bfd.name)));
+ statements.append(maker.If(maker.Unary(CTC_NOT, maker.Ident(bfd.nameOfSetFlag)), maker.Exec(maker.Assign(maker.Ident(bfd.name),maker.Apply(typeParameterNames(maker, ((JCClassDecl) tdParent.get()).typarams), maker.Select(maker.Ident(((JCClassDecl) tdParent.get()).name), bfd.nameOfDefaultProvider), List.<JCExpression>nil()))), null));
}
+ args.append(maker.Ident(bfd.name));
}
if (addCleaning) {
diff --git a/src/core/lombok/javac/handlers/HandleVal.java b/src/core/lombok/javac/handlers/HandleVal.java
index 2976eabe..f0f6eb2a 100644
--- a/src/core/lombok/javac/handlers/HandleVal.java
+++ b/src/core/lombok/javac/handlers/HandleVal.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2016 The Project Lombok Authors.
+ * Copyright (C) 2010-2018 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -62,21 +62,21 @@ public class HandleVal extends JavacASTAdapter {
JCTree typeTree = local.vartype;
if (typeTree == null) return;
String typeTreeToString = typeTree.toString();
-
+
if (!(eq(typeTreeToString, "val") || eq(typeTreeToString, "var"))) return;
boolean isVal = typeMatches(val.class, localNode, typeTree);
boolean isVar = typeMatches(var.class, localNode, typeTree);
if (!(isVal || isVar)) return;
-
+
if (isVal) handleFlagUsage(localNode, ConfigurationKeys.VAL_FLAG_USAGE, "val");
if (isVar) handleFlagUsage(localNode, ConfigurationKeys.VAR_FLAG_USAGE, "var");
-
+
JCTree parentRaw = localNode.directUp().get();
if (isVal && parentRaw instanceof JCForLoop) {
localNode.addError("'val' is not allowed in old-style for loops");
return;
}
-
+
JCExpression rhsOfEnhancedForLoop = null;
if (local.init == null) {
if (parentRaw instanceof JCEnhancedForLoop) {
@@ -84,26 +84,25 @@ public class HandleVal extends JavacASTAdapter {
if (efl.var == local) rhsOfEnhancedForLoop = efl.expr;
}
}
-
+
final String annotation = typeTreeToString;
if (rhsOfEnhancedForLoop == null && local.init == null) {
localNode.addError("'" + annotation + "' on a local variable requires an initializer expression");
return;
-
}
-
+
if (local.init instanceof JCNewArray && ((JCNewArray)local.init).elemtype == null) {
localNode.addError("'" + annotation + "' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... })");
return;
}
-
+
if (localNode.shouldDeleteLombokAnnotations()) {
JavacHandlerUtil.deleteImportFromCompilationUnit(localNode, val.class.getName());
JavacHandlerUtil.deleteImportFromCompilationUnit(localNode, var.class.getName());
}
-
+
if (isVal) local.mods.flags |= Flags.FINAL;
-
+
if (!localNode.shouldDeleteLombokAnnotations()) {
JCAnnotation valAnnotation = recursiveSetGeneratedBy(localNode.getTreeMaker().Annotation(local.vartype, List.<JCExpression>nil()), typeTree, localNode.getContext());
local.mods.annotations = local.mods.annotations == null ? List.of(valAnnotation) : local.mods.annotations.append(valAnnotation);
@@ -126,7 +125,7 @@ public class HandleVal extends JavacASTAdapter {
try {
type = ((JCExpression) resolver.resolveMethodMember(localNode).get(local.init)).type;
} catch (RuntimeException e) {
- System.err.println("Exception while resolving: " + localNode);
+ System.err.println("Exception while resolving: " + localNode + "(" + localNode.getFileName() + ")");
throw e;
}
} else {
@@ -137,7 +136,7 @@ public class HandleVal extends JavacASTAdapter {
local.type = Symtab.instance(localNode.getContext()).unknownType;
type = ((JCExpression) resolver.resolveMethodMember(localNode).get(local.init)).type;
} catch (RuntimeException e) {
- System.err.println("Exception while resolving: " + localNode);
+ System.err.println("Exception while resolving: " + localNode + "(" + localNode.getFileName() + ")");
throw e;
}
}
diff --git a/test/transform/resource/after-delombok/BuilderDefaults.java b/test/transform/resource/after-delombok/BuilderDefaults.java
index 02fb9727..b916b725 100644
--- a/test/transform/resource/after-delombok/BuilderDefaults.java
+++ b/test/transform/resource/after-delombok/BuilderDefaults.java
@@ -50,7 +50,11 @@ public final class BuilderDefaults {
}
@java.lang.SuppressWarnings("all")
public BuilderDefaults build() {
- return new BuilderDefaults(x$set ? x : BuilderDefaults.$default$x(), name, z$set ? z : BuilderDefaults.$default$z());
+ int x = this.x;
+ if (!x$set) x = BuilderDefaults.$default$x();
+ long z = this.z;
+ if (!z$set) z = BuilderDefaults.$default$z();
+ return new BuilderDefaults(x, name, z);
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
diff --git a/test/transform/resource/after-delombok/BuilderDefaultsGenerics.java b/test/transform/resource/after-delombok/BuilderDefaultsGenerics.java
index 18dd375e..b88a61be 100644
--- a/test/transform/resource/after-delombok/BuilderDefaultsGenerics.java
+++ b/test/transform/resource/after-delombok/BuilderDefaultsGenerics.java
@@ -58,7 +58,13 @@ public class BuilderDefaultsGenerics<N extends Number, T, R extends List<T>> {
}
@java.lang.SuppressWarnings("all")
public BuilderDefaultsGenerics<N, T, R> build() {
- return new BuilderDefaultsGenerics<N, T, R>(callable$set ? callable : BuilderDefaultsGenerics.<N, T, R>$default$callable(), tee$set ? tee : BuilderDefaultsGenerics.<N, T, R>$default$tee(), arrr$set ? arrr : BuilderDefaultsGenerics.<N, T, R>$default$arrr());
+ java.util.concurrent.Callable<N> callable = this.callable;
+ if (!callable$set) callable = BuilderDefaultsGenerics.<N, T, R>$default$callable();
+ T tee = this.tee;
+ if (!tee$set) tee = BuilderDefaultsGenerics.<N, T, R>$default$tee();
+ R arrr = this.arrr;
+ if (!arrr$set) arrr = BuilderDefaultsGenerics.<N, T, R>$default$arrr();
+ return new BuilderDefaultsGenerics<N, T, R>(callable, tee, arrr);
}
@java.lang.Override
@java.lang.SuppressWarnings("all")