aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.xml23
-rw-r--r--buildScripts/eclipse-run-tests.template41
-rw-r--r--src/core/lombok/javac/Javac6BasedLombokOptions.java27
-rw-r--r--src/core/lombok/javac/handlers/HandleVal.java2
-rw-r--r--src/delombok/lombok/delombok/PrettyCommentsPrinter.java46
-rw-r--r--test/core/src/lombok/CompilerMessageMatcher.java58
-rw-r--r--test/core/src/lombok/RunTestsViaEcj.java11
-rw-r--r--test/pretty/resource/after/DefaultMethod.java8
-rw-r--r--test/pretty/resource/after/MethodReference.java36
-rw-r--r--test/pretty/resource/before/DefaultMethod.java11
-rw-r--r--test/pretty/resource/before/MethodReference.java48
-rw-r--r--test/transform/resource/after-delombok/LoggerSlf4jOnNonType.java4
-rw-r--r--test/transform/resource/after-delombok/ValInTryWithResources.java1
-rw-r--r--test/transform/resource/before/LoggerSlf4jOnNonType.java1
-rw-r--r--test/transform/resource/before/ValInTryWithResources.java2
-rw-r--r--test/transform/resource/messages-delombok/LoggerSlf4jOnNonType.java.messages2
-rw-r--r--test/transform/resource/messages-ecj/LoggerSlf4jOnNonType.java.messages2
17 files changed, 259 insertions, 64 deletions
diff --git a/build.xml b/build.xml
index 12f19ccb..6b2a6f1b 100644
--- a/build.xml
+++ b/build.xml
@@ -431,12 +431,15 @@ ${sourceWarning}</echo>
overwrite="true">
<filterset>
<filter token="JAVAC_LOCATION" value="${test.location.javac}" />
+ <filter token="ECJ_LOCATION" value="${test.location.ecj}" />
<filter token="RT_LOCATION" value="${test.location.bootclasspath}" />
+ <filter token="JAVA_VERSION" value="${test.javaversion}" />
</filterset>
</copy>
+ <echo>WARNING: If you wish to test JDK8 features in eclipse, there must be a JDK8 installation configured in your eclipse, and it must be called 'JavaSE-1.8'.</echo>
</target>
- <target name="setupJavaOpenJDK6TestEnvironment" description="Sets up the test so that 'ant test' will test against OpenJDK6.">
+ <target name="setupJavaOpenJDK6TestEnvironment" depends="contrib" description="Sets up the test so that 'ant test' will test against OpenJDK6.">
<mkdir dir="lib/openJDK6Environment" />
<get src="http://projectlombok.org/ivyrepo/langtools/javac-1.6.0.18.jar" dest="lib/openJDK6Environment/javac6.jar" verbose="true" usetimestamp="true" />
<get src="http://projectlombok.org/ivyrepo/langtools/rt-openjdk6.jar" dest="lib/openJDK6Environment/rt-openjdk6.jar" verbose="true" usetimestamp="true" />
@@ -445,12 +448,13 @@ ${sourceWarning}</echo>
<entry key="test.location.ecj" value="lib/ecj7/org.eclipse.custom-ecj.jar" />
<entry key="test.location.bootclasspath" value="lib/openJDK6Environment/rt-openjdk6.jar" />
<entry key="test.location.name" value="OpenJDK6" />
+ <entry key="test.javaversion" value="6" />
</propertyfile>
<echo>Tests will now run against OpenJDK6</echo>
<antcall target="-createEclipseLaunchForTestEnvironmentIfEclipseProject" />
</target>
- <target name="setupJavaOpenJDK7TestEnvironment" description="Sets up the test so that 'ant test' will test against OpenJDK7.">
+ <target name="setupJavaOpenJDK7TestEnvironment" depends="contrib" description="Sets up the test so that 'ant test' will test against OpenJDK7.">
<mkdir dir="lib/openJDK7Environment" />
<get src="http://projectlombok.org/ivyrepo/langtools/javac-1.7.0.jar" dest="lib/openJDK7Environment/javac7.jar" verbose="true" usetimestamp="true" />
<get src="http://projectlombok.org/ivyrepo/langtools/rt-openjdk7.jar" dest="lib/openJDK7Environment/rt-openjdk7.jar" verbose="true" usetimestamp="true" />
@@ -459,12 +463,13 @@ ${sourceWarning}</echo>
<entry key="test.location.ecj" value="lib/ecj7/org.eclipse.custom-ecj.jar" />
<entry key="test.location.bootclasspath" value="lib/openJDK7Environment/rt-openjdk7.jar" />
<entry key="test.location.name" value="OpenJDK7" />
+ <entry key="test.javaversion" value="7" />
</propertyfile>
<echo>Tests will now run against OpenJDK7</echo>
<antcall target="-createEclipseLaunchForTestEnvironmentIfEclipseProject" />
</target>
- <target name="setupJavaOracle7TestEnvironment" description="Sets up the test so that 'ant test' will test against OpenJDK7.">
+ <target name="setupJavaOracle7TestEnvironment" depends="contrib" description="Sets up the test so that 'ant test' will test against OpenJDK7.">
<mkdir dir="lib/oracleJDK7Environment" />
<get src="http://projectlombok.org/ivyrepo/langtools/oracle-jdk7-tools.jar" dest="lib/oracleJDK7Environment/tools.jar" verbose="true" usetimestamp="true" />
<get src="http://projectlombok.org/ivyrepo/langtools/oracle-jdk7-rt.jar" dest="lib/oracleJDK7Environment/rt.jar" verbose="true" usetimestamp="true" />
@@ -473,26 +478,29 @@ ${sourceWarning}</echo>
<entry key="test.location.ecj" value="lib/ecj7/org.eclipse.custom-ecj.jar" />
<entry key="test.location.bootclasspath" value="lib/oracleJDK7Environment/rt.jar" />
<entry key="test.location.name" value="OracleJDK7" />
+ <entry key="test.javaversion" value="7" />
</propertyfile>
<echo>Tests will now run against Oracle JDK7</echo>
<antcall target="-createEclipseLaunchForTestEnvironmentIfEclipseProject" />
</target>
- <target name="setupJavaOracle8TestEnvironment" description="Sets up the test so that 'ant test' will test against OpenJDK8.">
+ <target name="setupJavaOracle8TestEnvironment" depends="contrib" description="Sets up the test so that 'ant test' will test against OpenJDK8.">
<mkdir dir="lib/oracleJDK8Environment" />
- <get src="http://projectlombok.org/ivyrepo/langtools/oracle-jdk8-tools.jar" dest="lib/oracleJDK8Environment/tools.jar" verbose="true" usetimestamp="true" />
+ <get src="http://projectlombok.org/ivyrepo/langtools/jdk8-javac.jar" dest="lib/oracleJDK8Environment/javac8.jar" verbose="true" usetimestamp="true" />
<get src="http://projectlombok.org/ivyrepo/langtools/oracle-jdk8-rt.jar" dest="lib/oracleJDK8Environment/rt.jar" verbose="true" usetimestamp="true" />
+ <get src="http://projectlombok.org/ivyrepo/langtools/jdk8-javac-sources.zip" dest="lib/oracleJDK8Environment/javac8-sources.zip" verbose="true" usetimestamp="true" />
<propertyfile file="testenvironment.properties">
- <entry key="test.location.javac" value="lib/oracleJDK8Environment/tools.jar" />
+ <entry key="test.location.javac" value="lib/oracleJDK8Environment/javac8.jar" />
<entry key="test.location.ecj" value="lib/ecj8/org.eclipse.custom-ecj.jar" />
<entry key="test.location.bootclasspath" value="lib/oracleJDK8Environment/rt.jar" />
<entry key="test.location.name" value="OracleJDK8" />
+ <entry key="test.javaversion" value="8" />
</propertyfile>
<echo>Tests will now run against Oracle JDK8</echo>
<antcall target="-createEclipseLaunchForTestEnvironmentIfEclipseProject" />
</target>
- <target name="-failIfNoTestEnvironmentProperties" unless="test.location.ecj">
+ <target name="-failIfNoTestEnvironmentProperties" unless="test.javaversion">
<fail>ERROR: No test environment set up.
You need to set up a test environment, which consists of a version of javac, and a JRE runtime classpath ('rt.jar').
@@ -513,6 +521,7 @@ You can also create your own by writing a 'testenvironment.properties' file. The
* test.location.ecj = /path/to/ecj6.jar
* test.location.bootclasspath = /path/to/rt.jar
* test.location.name = RandomUsefulNameToIdentifyThisSetup
+* test.javaversion = 6
</fail>
</target>
diff --git a/buildScripts/eclipse-run-tests.template b/buildScripts/eclipse-run-tests.template
index 1e23baa0..b7bc8b0d 100644
--- a/buildScripts/eclipse-run-tests.template
+++ b/buildScripts/eclipse-run-tests.template
@@ -1,19 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/lombok/test/core/src/lombok/RunAllTests.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
-<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="lombok.RunAllTests"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="lombok"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:dist/lombok.jar -Xbootclasspath/p:@JAVAC_LOCATION@ -Ddelombok.bootclasspath=@RT_LOCATION@"/>
+ <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+ <listEntry value="/lombok/test/core/src/lombok/RunAllTests.java"/>
+ </listAttribute>
+ <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+ <listEntry value="1"/>
+ </listAttribute>
+ <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+ <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+ </listAttribute>
+ <stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+ <booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+ <stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+ <stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+ <booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
+ <listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+ <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.@JAVA_VERSION@&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
+ <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lombok/@ECJ_LOCATION@&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
+ <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lombok/@JAVAC_LOCATION@&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
+ <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;lombok&quot;/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/>
+ </listAttribute>
+ <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
+ <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.@JAVA_VERSION@"/>
+ <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="lombok.RunAllTests"/>
+ <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="lombok"/>
+ <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:dist/lombok.jar -Ddelombok.bootclasspath=@RT_LOCATION@"/>
</launchConfiguration>
diff --git a/src/core/lombok/javac/Javac6BasedLombokOptions.java b/src/core/lombok/javac/Javac6BasedLombokOptions.java
index 871e41c4..cefb89ff 100644
--- a/src/core/lombok/javac/Javac6BasedLombokOptions.java
+++ b/src/core/lombok/javac/Javac6BasedLombokOptions.java
@@ -21,11 +21,28 @@
*/
package lombok.javac;
-import com.sun.tools.javac.main.OptionName;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import lombok.Lombok;
+
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Options;
public class Javac6BasedLombokOptions extends LombokOptions {
+ private static final Method optionName_valueOf;
+ private static final Method options_put;
+
+ static {
+ try {
+ Class<?> optionNameClass = Class.forName("com.sun.tools.javac.main.OptionName");
+ optionName_valueOf = optionNameClass.getMethod("valueOf", String.class);
+ options_put = Class.forName("com.sun.tools.javac.util.Options").getMethod("put", optionNameClass, String.class);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Can't initialize Javac6-based lombok options due to reflection issue.", e);
+ }
+ }
+
public static Javac6BasedLombokOptions replaceWithDelombokOptions(Context context) {
Options options = Options.instance(context);
context.put(optionsKey, (Options)null);
@@ -39,6 +56,12 @@ public class Javac6BasedLombokOptions extends LombokOptions {
}
@Override public void putJavacOption(String optionName, String value) {
- put(OptionName.valueOf(optionName), value);
+ try {
+ options_put.invoke(this, optionName_valueOf.invoke(null, optionName), value);
+ } catch (IllegalAccessException e) {
+ throw new IllegalArgumentException("Can't initialize Javac6-based lombok options due to reflection issue.", e);
+ } catch (InvocationTargetException e) {
+ throw Lombok.sneakyThrow(e.getCause());
+ }
}
}
diff --git a/src/core/lombok/javac/handlers/HandleVal.java b/src/core/lombok/javac/handlers/HandleVal.java
index 75464195..eb3a2f46 100644
--- a/src/core/lombok/javac/handlers/HandleVal.java
+++ b/src/core/lombok/javac/handlers/HandleVal.java
@@ -91,7 +91,7 @@ public class HandleVal extends JavacASTAdapter {
local.mods.annotations = local.mods.annotations == null ? List.of(valAnnotation) : local.mods.annotations.append(valAnnotation);
}
- local.vartype = JavacResolution.createJavaLangObject(localNode.getAst());
+ local.vartype = localNode.getAst().getTreeMaker().Ident(localNode.getAst().toName("___Lombok_VAL_Attrib__"));
Type type;
try {
diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
index a0a11d6c..9dd7e40e 100644
--- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
@@ -126,6 +126,9 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
private static final Map<TreeTag, String> OPERATORS;
+ // StandardFlags | DEFAULT
+ private static final long EXTENDED_STANDARD_FLAGS = 0x0fffL | 1L<<43;
+
static {
Map<TreeTag, String> map = new HashMap<TreeTag, String>();
@@ -493,7 +496,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
suppressFinalAndSemicolonsInTry = false;
}
print(TreeInfo.flagNames(flags));
- if ((flags & StandardFlags) != 0) print(" ");
+ if ((flags & EXTENDED_STANDARD_FLAGS) != 0) print(" ");
if ((flags & ANNOTATION) != 0) print("@");
}
@@ -1575,6 +1578,9 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
} else if ("JCLambda".equals(simpleName)) {
visitLambda0(tree);
return;
+ } else if ("JCMemberReference".equals(simpleName)) {
+ visitReference0(tree);
+ return;
} else {
print("(UNKNOWN[" + tree.getClass().getSimpleName() + "]: " + tree + ")");
println();
@@ -1587,6 +1593,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
private void visitLambda0(JCTree tree) {
try {
print("(");
+ @SuppressWarnings("unchecked")
List<JCVariableDecl> params = (List<JCVariableDecl>) readTreeList(tree, "params");
boolean explicit = true;
try {
@@ -1609,31 +1616,60 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
}
}
+
+ public void visitReference0(JCTree tree) {
+ try {
+ printExpr(readTree(tree, "expr"));
+ print("::");
+ List<JCExpression> typeArgs = readExpressionList(tree, "typeargs");
+ if (typeArgs != null) {
+ print("<");
+ printExprs(typeArgs);
+ print(">");
+ }
+ ;
+ print(readObject(tree, "mode").toString().equals("INVOKE") ? readObject(tree, "name") : "new");
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
private JCTree readTree(JCTree tree, String fieldName) {
try {
- return (JCTree) readObject(tree, fieldName);
+ return (JCTree) readObject0(tree, fieldName);
} catch (Exception e) {
return null;
}
}
+ @SuppressWarnings("unchecked")
private List<? extends JCTree> readTreeList(JCTree tree, String fieldName) throws IOException {
try {
- return (List<? extends JCTree>) readObject(tree, fieldName);
+ return (List<? extends JCTree>) readObject0(tree, fieldName);
} catch (Exception e) {
return List.nil();
}
}
+ @SuppressWarnings("unchecked")
private List<JCExpression> readExpressionList(JCTree tree, String fieldName) throws IOException {
try {
- return (List<JCExpression>) readObject(tree, fieldName);
+ return (List<JCExpression>) readObject0(tree, fieldName);
} catch (Exception e) {
return List.nil();
}
}
- private Object readObject(JCTree tree, String fieldName) throws Exception {
+ private Object readObject(JCTree tree, String fieldName) {
+ try {
+ return readObject0(tree, fieldName);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private Object readObject0(JCTree tree, String fieldName) throws Exception {
try {
return tree.getClass().getDeclaredField(fieldName).get(tree);
} catch (Exception e) {
diff --git a/test/core/src/lombok/CompilerMessageMatcher.java b/test/core/src/lombok/CompilerMessageMatcher.java
index db288749..cffad88a 100644
--- a/test/core/src/lombok/CompilerMessageMatcher.java
+++ b/test/core/src/lombok/CompilerMessageMatcher.java
@@ -27,7 +27,6 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -36,32 +35,41 @@ import lombok.javac.CapturingDiagnosticListener.CompilerMessage;
public class CompilerMessageMatcher {
/** Line Number (starting at 1) */
- private final long line;
+ private final List<Integer> lineNumbers = new ArrayList<Integer>();
+ private final List<List<String>> messages = new ArrayList<List<String>>();
- private final Collection<String> messageParts;
-
- public CompilerMessageMatcher(long line, String message) {
- this.line = line;
- this.messageParts = Arrays.asList(message.split("\\s+"));
- }
+ private CompilerMessageMatcher() {}
public static CompilerMessageMatcher asCompilerMessageMatcher(CompilerMessage message) {
- return new CompilerMessageMatcher(message.getLine(), message.getMessage());
+ CompilerMessageMatcher cmm = new CompilerMessageMatcher();
+ cmm.lineNumbers.add((int) message.getLine());
+ cmm.messages.add(Arrays.asList(message.getMessage().split("\\s+")));
+ return cmm;
}
@Override public String toString() {
- StringBuilder parts = new StringBuilder();
- for (String part : messageParts) parts.append(part).append(" ");
- if (parts.length() > 0) parts.setLength(parts.length() - 1);
- return String.format("%d %s", line, parts);
+ StringBuilder out = new StringBuilder();
+ for (int i = 0; i < lineNumbers.size(); i++) {
+ out.append(lineNumbers.get(i));
+ for (String part : messages.get(i)) out.append(part).append(" ");
+ if (out.length() > 0) out.setLength(out.length() - 1);
+ out.append(" |||| ");
+ }
+ if (out.length() > 0) out.setLength(out.length() - 6);
+ return out.toString();
}
public boolean matches(CompilerMessage message) {
- if (message.getLine() != this.line) return false;
- for (String token : messageParts) {
- if (!message.getMessage().contains(token)) return false;
+ outer:
+ for (int i = 0; i < lineNumbers.size(); i++) {
+ if (message.getLine() != lineNumbers.get(i)) continue;
+ for (String token : messages.get(i)) {
+ if (!message.getMessage().contains(token)) continue outer;
+ }
+ return true;
}
- return true;
+
+ return false;
}
public static List<CompilerMessageMatcher> readAll(InputStream rawIn) throws IOException {
@@ -75,11 +83,21 @@ public class CompilerMessageMatcher {
}
private static final Pattern PATTERN = Pattern.compile("^(\\d+) (.*)$");
+
private static CompilerMessageMatcher read(String line) {
line = line.trim();
if (line.isEmpty()) return null;
- Matcher m = PATTERN.matcher(line);
- if (!m.matches()) throw new IllegalArgumentException("Typo in test file: " + line);
- return new CompilerMessageMatcher(Integer.parseInt(m.group(1)), m.group(2));
+
+ String[] parts = line.split("\\s*\\|\\|\\|\\|\\s*");
+
+ CompilerMessageMatcher cmm = new CompilerMessageMatcher();
+ for (String part : parts) {
+ Matcher m = PATTERN.matcher(part);
+ if (!m.matches()) throw new IllegalArgumentException("Typo in test file: " + line);
+ cmm.lineNumbers.add(Integer.parseInt(m.group(1)));
+ cmm.messages.add(Arrays.asList(m.group(2).split("\\s+")));
+ }
+
+ return cmm;
}
}
diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java
index 8d1a8278..e23ebc4c 100644
--- a/test/core/src/lombok/RunTestsViaEcj.java
+++ b/test/core/src/lombok/RunTestsViaEcj.java
@@ -70,22 +70,22 @@ public class RunTestsViaEcj extends AbstractRunTests {
warnings.put(CompilerOptions.OPTION_ReportUnusedLabel, "ignore");
warnings.put(CompilerOptions.OPTION_ReportUnusedImport, "ignore");
warnings.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, "ignore");
- warnings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7);
+ warnings.put(CompilerOptions.OPTION_Source, "1." + Eclipse.getEcjCompilerVersion());
options.set(warnings);
return options;
}
protected IErrorHandlingPolicy ecjErrorHandlingPolicy() {
return new IErrorHandlingPolicy() {
- @Override public boolean stopOnFirstError() {
+ public boolean stopOnFirstError() {
return true;
}
- @Override public boolean proceedOnErrors() {
+ public boolean proceedOnErrors() {
return false;
}
- @Override public boolean ignoreAllErrors() {
+ public boolean ignoreAllErrors() {
return false;
}
};
@@ -124,7 +124,8 @@ public class RunTestsViaEcj extends AbstractRunTests {
CompilationUnitDeclaration cud = compilationUnit_.get();
- result.append(cud.toString());
+ if (cud == null) result.append("---- NO CompilationUnit provided by ecj ----");
+ else result.append(cud.toString());
}
private FileSystem createFileSystem(File file) {
diff --git a/test/pretty/resource/after/DefaultMethod.java b/test/pretty/resource/after/DefaultMethod.java
new file mode 100644
index 00000000..864ba60f
--- /dev/null
+++ b/test/pretty/resource/after/DefaultMethod.java
@@ -0,0 +1,8 @@
+interface DefaultMethod {
+ int size();
+ default boolean isEmpty() {
+ return size() == 0;
+ }
+ default strictfp void run() {
+ }
+} \ No newline at end of file
diff --git a/test/pretty/resource/after/MethodReference.java b/test/pretty/resource/after/MethodReference.java
new file mode 100644
index 00000000..115b7014
--- /dev/null
+++ b/test/pretty/resource/after/MethodReference.java
@@ -0,0 +1,36 @@
+class MethodReference {
+ public MethodReference() {
+ }
+ public <T> MethodReference(T in) {
+ }
+ public void simpleInstanceReference() {
+ Runnable r = this::foo;
+ }
+ public void simpleConstructorReference() {
+ Runnable r = MethodReference::new;
+ }
+ public void simpleStaticReference() {
+ Runnable r = MethodReference::staticFoo;
+ }
+ public void generifiedStaticReference() {
+ StringConverter sc = MethodReference::<String>generifiedStaticFoo;
+ }
+ public void generifiedConstructorReference() {
+ FooConverter<MethodReference> fc = MethodReference::<String>new;
+ }
+ public void foo() {
+ }
+ private static void staticFoo() {
+ }
+ public static <T> T generifiedStaticFoo(T foo) {
+ return foo;
+ }
+ @FunctionalInterface
+ public interface StringConverter {
+ String hello(String x);
+ }
+ @FunctionalInterface
+ public interface FooConverter<K> {
+ K hello(String x);
+ }
+} \ No newline at end of file
diff --git a/test/pretty/resource/before/DefaultMethod.java b/test/pretty/resource/before/DefaultMethod.java
new file mode 100644
index 00000000..e0358c7a
--- /dev/null
+++ b/test/pretty/resource/before/DefaultMethod.java
@@ -0,0 +1,11 @@
+// version 8:
+interface DefaultMethod {
+ int size();
+
+ default boolean isEmpty() {
+ return size() == 0;
+ }
+
+ default strictfp void run() {
+ }
+} \ No newline at end of file
diff --git a/test/pretty/resource/before/MethodReference.java b/test/pretty/resource/before/MethodReference.java
new file mode 100644
index 00000000..c7af9bf3
--- /dev/null
+++ b/test/pretty/resource/before/MethodReference.java
@@ -0,0 +1,48 @@
+// version 8:
+class MethodReference {
+ public MethodReference() {
+ }
+
+ public <T> MethodReference(T in) {
+ }
+
+ public void simpleInstanceReference() {
+ Runnable r = this::foo;
+ }
+
+ public void simpleConstructorReference() {
+ Runnable r = MethodReference::new;
+ }
+
+ public void simpleStaticReference() {
+ Runnable r = MethodReference::staticFoo;
+ }
+
+ public void generifiedStaticReference() {
+ StringConverter sc = MethodReference::<String>generifiedStaticFoo;
+ }
+
+ public void generifiedConstructorReference() {
+ FooConverter<MethodReference> fc = MethodReference::<String>new;
+ }
+
+ public void foo() {
+ }
+
+ private static void staticFoo() {
+ }
+
+ public static <T> T generifiedStaticFoo(T foo) {
+ return foo;
+ }
+
+ @FunctionalInterface
+ public interface StringConverter {
+ public String hello(String x);
+ }
+
+ @FunctionalInterface
+ public interface FooConverter<K> {
+ public K hello(String x);
+ }
+}
diff --git a/test/transform/resource/after-delombok/LoggerSlf4jOnNonType.java b/test/transform/resource/after-delombok/LoggerSlf4jOnNonType.java
deleted file mode 100644
index 4c944172..00000000
--- a/test/transform/resource/after-delombok/LoggerSlf4jOnNonType.java
+++ /dev/null
@@ -1,4 +0,0 @@
-class LoggerSlf4jOnNonType {
- void foo() {
- }
-} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/ValInTryWithResources.java b/test/transform/resource/after-delombok/ValInTryWithResources.java
index 9aae99a2..42bd3193 100644
--- a/test/transform/resource/after-delombok/ValInTryWithResources.java
+++ b/test/transform/resource/after-delombok/ValInTryWithResources.java
@@ -1,4 +1,3 @@
-//version 7
import java.io.IOException;
public class ValInTryWithResources {
public void whyTryInsteadOfCleanup() throws IOException {
diff --git a/test/transform/resource/before/LoggerSlf4jOnNonType.java b/test/transform/resource/before/LoggerSlf4jOnNonType.java
index fd557b25..495c67fc 100644
--- a/test/transform/resource/before/LoggerSlf4jOnNonType.java
+++ b/test/transform/resource/before/LoggerSlf4jOnNonType.java
@@ -1,3 +1,4 @@
+// skip-compare-content
class LoggerSlf4jOnNonType {
@lombok.extern.slf4j.Slf4j
void foo() {
diff --git a/test/transform/resource/before/ValInTryWithResources.java b/test/transform/resource/before/ValInTryWithResources.java
index 780e1c71..a7820062 100644
--- a/test/transform/resource/before/ValInTryWithResources.java
+++ b/test/transform/resource/before/ValInTryWithResources.java
@@ -1,4 +1,4 @@
-//version 7
+//version 7:
import lombok.val;
import java.io.IOException;
diff --git a/test/transform/resource/messages-delombok/LoggerSlf4jOnNonType.java.messages b/test/transform/resource/messages-delombok/LoggerSlf4jOnNonType.java.messages
index 262fbb27..ca4d607f 100644
--- a/test/transform/resource/messages-delombok/LoggerSlf4jOnNonType.java.messages
+++ b/test/transform/resource/messages-delombok/LoggerSlf4jOnNonType.java.messages
@@ -1 +1 @@
-2 @Log is legal only on types. \ No newline at end of file
+3 @Log is legal only on types. |||| 3 annotation type not applicable to this kind of declaration \ No newline at end of file
diff --git a/test/transform/resource/messages-ecj/LoggerSlf4jOnNonType.java.messages b/test/transform/resource/messages-ecj/LoggerSlf4jOnNonType.java.messages
index 81e9b718..3ef2aeb9 100644
--- a/test/transform/resource/messages-ecj/LoggerSlf4jOnNonType.java.messages
+++ b/test/transform/resource/messages-ecj/LoggerSlf4jOnNonType.java.messages
@@ -1 +1 @@
-2 The annotation @Slf4j is disallowed for this location
+3 The annotation @Slf4j is disallowed for this location