Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
charphi authored Aug 22, 2018
2 parents 35c7c6b + 769185e commit 3ffac66
Show file tree
Hide file tree
Showing 74 changed files with 987 additions and 453 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Rabea Gransberger <rgra@users.noreply.github.com>
Reinier Zwitserloot <reinier@zwitserloot.com>
Robbert Jan Grootjans <grootjans@gmail.com>
Roel Spilker <r.spilker@gmail.com>
Roland Praml <pram@gmx.de>
Sander Koning <askoning@gmail.com>
Szymon Pacanowski <spacanowski@gmail.com>
Taiki Sugawara <buzz.taiki@gmail.com>
Expand Down
22 changes: 9 additions & 13 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr
</target>

<target name="ensureBuildDeps" depends="config-ivy,ensureOpenJdk6Rt">
<ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="build, javac7" />
<ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="build, javac7, moduleBuild" />
<ivy:retrieve />
</target>

Expand Down Expand Up @@ -163,15 +163,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr

<target name="-ensureJdk9">
<condition property="java.version.insufficient">
<or>
<equals arg1="${ant.java.version}" arg2="1.2" />
<equals arg1="${ant.java.version}" arg2="1.3" />
<equals arg1="${ant.java.version}" arg2="1.4" />
<equals arg1="${ant.java.version}" arg2="1.5" />
<equals arg1="${ant.java.version}" arg2="1.6" />
<equals arg1="${ant.java.version}" arg2="1.7" />
<equals arg1="${ant.java.version}" arg2="1.8" />
</or>
<matches string="${java.version}" pattern="^1\.[2-8](\..*)?" />
</condition>
<fail if="java.version.insufficient">To compile lombok, you need JDK9 or higher; lombok requires this version because it's rather difficult to produce lombok builds that are compatible on JDK9 without at least building with JDK9. Sorry about that.</fail>
</target>
Expand Down Expand Up @@ -254,14 +246,18 @@ the common tasks and can be called on to run the main aspects of all the sub-scr
<classpath refid="build.path" />
</ivy:compile>

<ivy:compile destdir="build/lombok" source="1.9" target="1.9">
<javac includeAntRuntime="false" source="1.9" target="1.9" destdir="build/lombok" modulepath="lib/moduleBuild">
<compilerarg value="-Xlint:none" />
<!-- The above is because javac9 warns about 'service interface provided but not exported or used', probably because lombok uses SPI internally, and uses the 'old' classpath discovery system for it. We're fine with this, hence, ignore this warning. -->
<src path="src/core9" />
</javac>
<mkdir dir="build/lombokMapstruct" />
<javac includeAntRuntime="false" source="1.9" target="1.9" destdir="build/lombokMapstruct">
<src path="src/j9stubs" />
<!-- This includes org.mapstruct.ap.spi.AstModifyingAnnotationProcessor; putting this on the classpath doesn't work (needs to be internal or a module) so we just add it and then delete the class file for convenience. -->
</ivy:compile>
<delete file="build/lombok/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.class" />
</javac>
<mkdir dir="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi" />
<move file="build/lombokMapstruct/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.class" tofile="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.SCL.lombok" />

<ivy:compile destdir="build/lombok/Class50" source="1.5" target="1.6" ecj="true" nowarn="true" includeSystemBootclasspath="true">
<bootclasspath location="build/stubs" />
Expand Down
3 changes: 3 additions & 0 deletions buildScripts/ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<conf name="netbeansBuild" />
<conf name="buildBase" extends="netbeansBuild, javac6" />
<conf name="build" extends="buildBase, eclipseBuild" />
<conf name="moduleBuild" />
<conf name="buildWithoutEclipse" extends="buildBase" />
<conf name="runtime" />
<conf name="test" extends="runtime" />
Expand Down Expand Up @@ -64,5 +65,7 @@
<dependency org="com.jcraft" name="jsch" rev="0.1.54" conf="supporters->default" />
<dependency org="com.rimerosolutions.ant" name="ant-git-tasks" rev="1.3.2" conf="supporters->default" />
<dependency org="org.slf4j" name="slf4j-simple" rev="1.6.1" conf="supporters->default" />

<dependency org="org.mapstruct" name="mapstruct-processor" rev="1.3.0.Beta1" conf="moduleBuild->default" />
</dependencies>
</ivy-module>
10 changes: 9 additions & 1 deletion doc/changelog.markdown
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
Lombok Changelog
----------------

### v1.18.1 "Edgy Guinea Pig"
### v1.18.3 "Edgy Guinea Pig"
* FEATURE: The `@FieldNameConstants` feature has been completely redesigned. [Issue #1774](https://github.com/rzwitserloot/lombok/issues/1774) [FieldNameConstants documentation](https://projectlombok.org/features/experimental/FieldNameConstants)
* BUGFIX: When using lombok to compile modularized (`module-info.java`-style) code, if the module name has dots in it, it wouldn't work. [Issue #1808](https://github.com/rzwitserloot/lombok/issues/1808)
* BUGFIX: Errors about lombok not reading a module providing `org.mapstruct.ap.spi` when trying to use lombok in jigsaw-mode on JDK 11. [Issue #1806](https://github.com/rzwitserloot/lombok/issues/1806)

### v1.18.2 (July 26th, 2018)
* BUGFIX: mapstruct + lombok in eclipse should hopefully work again. [Issue #1359](https://github.com/rzwitserloot/lombok/issues/1359) and [mapstruct issue #1159](https://github.com/mapstruct/mapstruct/issues/1159)
* BUGFIX: Equals and hashCode again exclude transient fields by default. [Issue #1724](https://github.com/rzwitserloot/lombok/issues/1724)
* BUGFIX: Eclipse 'organize imports' feature (either explicitly, or if automatically triggered on saving via 'save actions') would remove the import for `lombok.var`. [Issue #1783](https://github.com/rzwitserloot/lombok/issues/1783)
* BUGFIX: Lombok and gradle v4.9 didn't work together; that's been fixed. [Issue #1716](https://github.com/rzwitserloot/lombok/issues/1716) and [gradle-apt-plugin issue #87](https://github.com/tbroyer/gradle-apt-plugin/issues/87)
* FEATURE: You can now make builders for type hierarchies, using the new (experimental) `@SuperBuilder` annotation. Thanks for the contribution, Jan Rieke. [`@SuperBuilder` documentation](https://projectlombok.org/features/experimental/SuperBuilder)
* FEATURE: `@NoArgsConstructor`, including forcing one with `lombok.config: lombok.noArgsConstructor.extraPrivate=true` now take any defaults set with `@Builder.Default` into account. [Issue #1347](https://github.com/rzwitserloot/lombok/issues/1347)

Expand Down
4 changes: 4 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jdk:
- openjdk9
before_install:
- export JAVA_HOME=/usr/lib/jvm/java-9-oracle
20 changes: 10 additions & 10 deletions src/core/lombok/ConfigurationKeys.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -38,6 +38,13 @@ private ConfigurationKeys() {}

// ----- global -----

/**
* lombok configuration: {@code dangerousconfig.lombok.disable} = {@code true} | {@code false}.
*
* If {@code true}, lombok is disabled entirely.
*/
public static final ConfigurationKey<Boolean> LOMBOK_DISABLE = new ConfigurationKey<Boolean>("dangerousconfig.lombok.disable", "Disables lombok transformers. It does not flag any lombok mentions (so, @Cleanup silently does nothing), and does not disable patched operations in eclipse either. Don't use this unless you know what you're doing. (default: false).", true) {};

/**
* lombok configuration: {@code lombok.addGeneratedAnnotation} = {@code true} | {@code false}.
*
Expand Down Expand Up @@ -522,18 +529,11 @@ private ConfigurationKeys() {}
public static final ConfigurationKey<FlagUsageType> FIELD_NAME_CONSTANTS_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.fieldNameConstants.flagUsage", "Emit a warning or error if @FieldNameConstants is used.") {};

/**
* lombok configuration: {@code lombok.fieldNameConstants.prefix} = &lt;String: aJavaIdentifierPrefix&gt; (Default: {@code PREFIX_}).
* lombok configuration: {@code lombok.fieldNameConstants.innerTypeName} = &lt;String: AValidJavaTypeName&gt; (Default: {@code Fields}).
*
* The names of the constants generated by {@code @FieldNameConstants} will be prefixed with this value.
*/
public static final ConfigurationKey<String> FIELD_NAME_CONSTANTS_PREFIX = new ConfigurationKey<String>("lombok.fieldNameConstants.prefix", "names of constants generated by @FieldNameConstants will be prefixed with this value. (default: 'PREFIX_').") {};

/**
* lombok configuration: {@code lombok.fieldNameConstants.suffix} = &lt;String: aJavaIdentifierPrefix&gt; (Default: nothing).
*
* The names of the constants generated by {@code @FieldNameConstants} will be suffixed with this value.
*/
public static final ConfigurationKey<String> FIELD_NAME_CONSTANTS_SUFFIX = new ConfigurationKey<String>("lombok.fieldNameConstants.suffix", "names of constants generated by @FieldNameConstants will be suffixed with this value. (default: nothing).") {};
public static final ConfigurationKey<String> FIELD_NAME_CONSTANTS_INNER_TYPE_NAME = new ConfigurationKey<String>("lombok.fieldNameConstants.innerTypeName", "The default name of the inner type generated by @FieldNameConstants. (default: 'Fields').") {};

// ----- Wither -----

Expand Down
11 changes: 6 additions & 5 deletions src/core/lombok/bytecode/ClassFileMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,24 @@ private String decodeString(int pos, int size) {
int end = pos + size;

// the resulting string might be smaller
StringBuilder result = new StringBuilder(size);
char[] result = new char[size];
int length = 0;
while (pos < end) {
int first = (byteCode[pos++] & 0xFF);
if (first < 0x80) {
result.append((char)first);
result[length++] = (char)first;
} else if ((first & 0xE0) == 0xC0) {
int x = (first & 0x1F) << 6;
int y = (byteCode[pos++] & 0x3F);
result.append((char)(x | y));
result[length++] = (char)(x | y);
} else {
int x = (first & 0x0F) << 12;
int y = (byteCode[pos++] & 0x3F) << 6;
int z = (byteCode[pos++] & 0x3F);
result.append((char)(x | y | z));
result[length++] = (char)(x | y | z);
}
}
return result.toString();
return new String(result, 0, length);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/core/lombok/core/AST.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,19 @@ protected static class FieldAccess {
}
}

private static final ConcurrentMap<Class<?>, Collection<FieldAccess>> fieldsOfASTClasses = new ConcurrentHashMap<Class<?>, Collection<FieldAccess>>();
private static final ConcurrentMap<Class<?>, FieldAccess[]> fieldsOfASTClasses = new ConcurrentHashMap<Class<?>, FieldAccess[]>();

/** Returns FieldAccess objects for the stated class. Each field that contains objects of the kind returned by
* {@link #getStatementTypes()}, either directly or inside of an array or java.util.collection (or array-of-arrays,
* or collection-of-collections, et cetera), is returned.
*/
protected Collection<FieldAccess> fieldsOf(Class<?> c) {
Collection<FieldAccess> fields = fieldsOfASTClasses.get(c);
protected FieldAccess[] fieldsOf(Class<?> c) {
FieldAccess[] fields = fieldsOfASTClasses.get(c);
if (fields != null) return fields;

fields = new ArrayList<FieldAccess>();
getFields(c, fields);
fieldsOfASTClasses.putIfAbsent(c, fields);
List<FieldAccess> fieldList = new ArrayList<FieldAccess>();
getFields(c, fieldList);
fieldsOfASTClasses.putIfAbsent(c, fieldList.toArray(new FieldAccess[fieldList.size()]));
return fieldsOfASTClasses.get(c);
}

Expand Down
30 changes: 13 additions & 17 deletions src/core/lombok/core/AnnotationProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

@SupportedAnnotationTypes("*")
public class AnnotationProcessor extends AbstractProcessor {

private static String trace(Throwable t) {
StringWriter w = new StringWriter();
t.printStackTrace(new PrintWriter(w, true));
Expand All @@ -65,42 +65,35 @@ static abstract class ProcessorDescriptor {
private final List<ProcessorDescriptor> registered = Arrays.asList(new JavacDescriptor(), new EcjDescriptor());
private final List<ProcessorDescriptor> active = new ArrayList<ProcessorDescriptor>();
private final List<String> delayedWarnings = new ArrayList<String>();

/**
* This method is a simplified version of {@link lombok.javac.apt.LombokProcessor.getJavacProcessingEnvironment}
* It simply returns the processing environment, but in case of gradle incremental compilation,
* the delegate ProcessingEnvironment of the gradle wrapper is returned.
*/
public static ProcessingEnvironment getJavacProcessingEnvironment(ProcessingEnvironment procEnv, List<String> delayedWarnings) {
ProcessingEnvironment javacProcEnv = tryRecursivelyObtainJavacProcessingEnvironment(procEnv);

if (javacProcEnv == null) {
delayedWarnings.add("Can't get the delegate of the gradle IncrementalProcessingEnvironment.");
}

return javacProcEnv;
return tryRecursivelyObtainJavacProcessingEnvironment(procEnv);
}

private static ProcessingEnvironment tryRecursivelyObtainJavacProcessingEnvironment(ProcessingEnvironment procEnv) {
if (procEnv.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) {
return procEnv;
}

for (Class<?> procEnvClass = procEnv.getClass(); procEnvClass != null; procEnvClass = procEnvClass.getSuperclass()) {
try {
Field field = procEnvClass.getDeclaredField("delegate");
field.setAccessible(true);
Object delegate = field.get(procEnv);

return tryRecursivelyObtainJavacProcessingEnvironment((ProcessingEnvironment) delegate);
} catch (final Exception e) {
// no valid delegate, try superclass
}
}

return null;
}


static class JavacDescriptor extends ProcessorDescriptor {
private Processor processor;
Expand All @@ -110,10 +103,13 @@ static class JavacDescriptor extends ProcessorDescriptor {
}

@Override boolean want(ProcessingEnvironment procEnv, List<String> delayedWarnings) {
// do not run on ECJ as it may print warnings
if (procEnv.getClass().getName().startsWith("org.eclipse.jdt.")) return false;

ProcessingEnvironment javacProcEnv = getJavacProcessingEnvironment(procEnv, delayedWarnings);

if (javacProcEnv == null) return false;

try {
ClassLoader classLoader = findAndPatchClassLoader(javacProcEnv);
processor = (Processor) Class.forName("lombok.javac.apt.LombokProcessor", false, classLoader).newInstance();
Expand Down Expand Up @@ -209,7 +205,7 @@ static class EcjDescriptor extends ProcessorDescriptor {
for (TypeElement elem : annotations) {
zeroElems = false;
Name n = elem.getQualifiedName();
if (n.length() > 7 && n.subSequence(0, 7).toString().equals("lombok.")) continue;
if (n.toString().startsWith("lombok.")) continue;
onlyLombok = false;
}

Expand Down
15 changes: 10 additions & 5 deletions src/core/lombok/core/LombokConfiguration.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2014 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
Expand All @@ -21,6 +21,7 @@
*/
package lombok.core;

import java.net.URI;
import java.util.Collections;

import lombok.core.configuration.BubblingConfigurationResolver;
Expand All @@ -44,7 +45,7 @@ public class LombokConfiguration {
static {
if (System.getProperty("lombok.disableConfig") != null) {
configurationResolverFactory = new ConfigurationResolverFactory() {
@Override public ConfigurationResolver createResolver(AST<?, ?, ?> ast) {
@Override public ConfigurationResolver createResolver(URI sourceLocation) {
return NULL_RESOLVER;
}
};
Expand All @@ -63,13 +64,17 @@ public static void overrideConfigurationResolverFactory(ConfigurationResolverFac
}

static <T> T read(ConfigurationKey<T> key, AST<?, ?, ?> ast) {
return configurationResolverFactory.createResolver(ast).resolve(key);
return configurationResolverFactory.createResolver(ast.getAbsoluteFileLocation()).resolve(key);
}

public static <T> T read(ConfigurationKey<T> key, URI sourceLocation) {
return configurationResolverFactory.createResolver(sourceLocation).resolve(key);
}

private static ConfigurationResolverFactory createFileSystemBubblingResolverFactory() {
return new ConfigurationResolverFactory() {
@Override public ConfigurationResolver createResolver(AST<?, ?, ?> ast) {
return new BubblingConfigurationResolver(cache.sourcesForJavaFile(ast.getAbsoluteFileLocation(), ConfigurationProblemReporter.CONSOLE));
@Override public ConfigurationResolver createResolver(URI sourceLocation) {
return new BubblingConfigurationResolver(cache.sourcesForJavaFile(sourceLocation, ConfigurationProblemReporter.CONSOLE));
}
};
}
Expand Down
6 changes: 2 additions & 4 deletions src/core/lombok/core/LombokInternalAliasing.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ public class LombokInternalAliasing {
*/
public static String processAliases(String in) {
if (in == null) return null;
for (Map.Entry<String, String> e : ALIASES.entrySet()) {
if (in.equals(e.getKey())) return e.getValue();
}
return in;
String ret = ALIASES.get(in);
return ret == null ? in : ret;
}

static {
Expand Down
Loading

0 comments on commit 3ffac66

Please sign in to comment.