diff --git a/.gitignore b/.gitignore index c6194f44..5eae78c0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ ivyCache google.properties debug LombokizedEclipse.launch -libertad-upload.key +escudo-upload.key findbugsReport.html lib .settings @@ -14,4 +14,4 @@ lib .factorypath lombok.iml .idea -*.markdown.html \ No newline at end of file +*.markdown.html diff --git a/build.xml b/build.xml index d1d4146e..676c34d7 100644 --- a/build.xml +++ b/build.xml @@ -164,12 +164,15 @@ the common tasks and can be called on to run the main aspects of all the sub-scr - + + + + @@ -177,7 +180,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr - + @@ -274,42 +277,60 @@ the common tasks and can be called on to run the main aspects of all the sub-scr All tests successful. - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - You don't have the libertad-upload.key; you'll need it to get write access to the server. + + You don't have the escudo-upload.key; you'll need it to get write access to the server. + keyfile="escudo-upload.key" passphrase="" + sftp="false" verbose="true" trust="true" /> + keyfile="escudo-upload.key" passphrase="" + trust="true" command="./publishToMavenCentral" /> + The artifact has been published to staging. Now go to http://oss.sonatype.org/ and log in as Reinier, then doublecheck if all is well and 'release' it. + diff --git a/buildScripts/ivy-repo/eclipse.org-ecj-3.6.0.xml b/buildScripts/ivy-repo/eclipse.org-ecj-3.6.0.xml deleted file mode 100644 index e3b8aceb..00000000 --- a/buildScripts/ivy-repo/eclipse.org-ecj-3.6.0.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/buildScripts/ivy-repo/jcraft.com-jsch-0.1.42.xml b/buildScripts/ivy-repo/jcraft.com-jsch-0.1.42.xml deleted file mode 100644 index 8c91c0cf..00000000 --- a/buildScripts/ivy-repo/jcraft.com-jsch-0.1.42.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/buildScripts/ivy-repo/eclipse.org-core.runtime-3.6.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.6.0.xml similarity index 71% rename from buildScripts/ivy-repo/eclipse.org-core.runtime-3.6.0.xml rename to buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.6.0.xml index d1232780..fe812bbc 100644 --- a/buildScripts/ivy-repo/eclipse.org-core.runtime-3.6.0.xml +++ b/buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.6.0.xml @@ -1,14 +1,14 @@ - + - + - + diff --git a/buildScripts/ivy-repo/org.eclipse.custom-ecj-3.6.2.xml b/buildScripts/ivy-repo/org.eclipse.custom-ecj-3.6.2.xml new file mode 100644 index 00000000..fc9fa661 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-ecj-3.6.2.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy-repo/eclipse.org-equinox.common-3.6.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.0.xml similarity index 69% rename from buildScripts/ivy-repo/eclipse.org-equinox.common-3.6.0.xml rename to buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.0.xml index acb748b0..889a2ceb 100644 --- a/buildScripts/ivy-repo/eclipse.org-equinox.common-3.6.0.xml +++ b/buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.0.xml @@ -1,14 +1,14 @@ - + - + - + - + \ No newline at end of file diff --git a/buildScripts/ivy-repo/eclipse.org-jdt.core-3.6.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.6.0.xml similarity index 71% rename from buildScripts/ivy-repo/eclipse.org-jdt.core-3.6.0.xml rename to buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.6.0.xml index 7a3225d8..f9a8f52d 100644 --- a/buildScripts/ivy-repo/eclipse.org-jdt.core-3.6.0.xml +++ b/buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.6.0.xml @@ -1,14 +1,14 @@ - + - + - + diff --git a/buildScripts/ivy-repo/eclipse.org-jdt.ui-3.6.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.6.0.xml similarity index 72% rename from buildScripts/ivy-repo/eclipse.org-jdt.ui-3.6.0.xml rename to buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.6.0.xml index 6244df5b..dbee2865 100644 --- a/buildScripts/ivy-repo/eclipse.org-jdt.ui-3.6.0.xml +++ b/buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.6.0.xml @@ -1,14 +1,14 @@ - + - + - + diff --git a/buildScripts/ivy-repo/eclipse.org-osgi-3.6.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-osgi-3.6.0.xml similarity index 72% rename from buildScripts/ivy-repo/eclipse.org-osgi-3.6.0.xml rename to buildScripts/ivy-repo/org.eclipse.custom-osgi-3.6.0.xml index 55bae381..93a7f381 100644 --- a/buildScripts/ivy-repo/eclipse.org-osgi-3.6.0.xml +++ b/buildScripts/ivy-repo/org.eclipse.custom-osgi-3.6.0.xml @@ -1,14 +1,14 @@ - + - + - + diff --git a/buildScripts/ivy-repo/projectlombok.org-junit-4.8.1.xml b/buildScripts/ivy-repo/projectlombok.org-junit-4.8.1.xml deleted file mode 100644 index aa31e5b0..00000000 --- a/buildScripts/ivy-repo/projectlombok.org-junit-4.8.1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/buildScripts/ivy.xml b/buildScripts/ivy.xml index 25f21928..7ff6bdc9 100644 --- a/buildScripts/ivy.xml +++ b/buildScripts/ivy.xml @@ -12,31 +12,32 @@ - - - - + + + + + - + - + - + - + - - - - - + + + + + diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml index aabc337c..68e20eae 100644 --- a/buildScripts/website.ant.xml +++ b/buildScripts/website.ant.xml @@ -144,6 +144,9 @@ such as converting the changelog into HTML, and creating javadoc. + + + diff --git a/doc/maven-pom.xml b/doc/maven-pom.xml index bf22ea5d..34955ab8 100644 --- a/doc/maven-pom.xml +++ b/doc/maven-pom.xml @@ -12,20 +12,37 @@ The MIT License - http://www.opensource.org/licenses/mit-license.php + http://projectlombok.org/LICENSE repo scm:git:git://github.com/rzwitserloot/lombok.git - scm:git:git://github.com/rzwitserloot/lombok.git + http://github.com/rzwitserloot/lombok - + + Google Code + http://code.google.com/p/projectlombok/issues + + + + rzwitserloot + Reinier Zwitserloot + reinier@projectlombok.org + http://zwitserloot.com + +1 + + + rspilker + Roel Spilker + roel@projectlombok.org + +1 + + + rgrootjans + Robbert Jan Grootjans + +1 + + diff --git a/doc/publishing.txt b/doc/publishing.txt index 01a2c294..85a13a9c 100644 --- a/doc/publishing.txt +++ b/doc/publishing.txt @@ -10,4 +10,6 @@ Step #4: git push && git push --tags Step #5: ant publish-all +Step #6: Follow the instructions that flew by when the maven-publish task ran, which involves going to http://oss.sonatype.org/ and logging in with the username/pass that are in your scroll log, to test and then 'release' the staged repo to maven central. Note that once you do this there's no turning back, and that version number is forever associated with this release. + Step #6: Change src/core/lombok/core/Version.java to "0.8.2-EDGE", and commit this. diff --git a/src/core/lombok/eclipse/Eclipse.java b/src/core/lombok/eclipse/Eclipse.java index ddba726a..8910bb3e 100644 --- a/src/core/lombok/eclipse/Eclipse.java +++ b/src/core/lombok/eclipse/Eclipse.java @@ -1,5 +1,5 @@ /* - * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -89,46 +89,85 @@ public class Eclipse { /** * Generates an error in the Eclipse error log. Note that most people never look at it! - */ - public static void error(CompilationUnitDeclaration cud, String message) { - error(cud, message, DEFAULT_BUNDLE, null); - } - - /** - * Generates an error in the Eclipse error log. Note that most people never look at it! + * + * @param cud The {@code CompilationUnitDeclaration} where the error occurred. + * An error will be generated on line 0 linking to the error log entry. Can be {@code null}. + * @param message Human readable description of the problem. + * @param error The associated exception. Can be {@code null}. */ public static void error(CompilationUnitDeclaration cud, String message, Throwable error) { - error(cud, message, DEFAULT_BUNDLE, error); - } - - /** - * Generates an error in the Eclipse error log. Note that most people never look at it! - */ - public static void error(CompilationUnitDeclaration cud, String message, String bundleName) { - error(cud, message, bundleName, null); + error(cud, message, null, error); } /** * Generates an error in the Eclipse error log. Note that most people never look at it! + * + * @param cud The {@code CompilationUnitDeclaration} where the error occurred. + * An error will be generated on line 0 linking to the error log entry. Can be {@code null}. + * @param message Human readable description of the problem. + * @param bundleName Can be {@code null} to default to {@code org.eclipse.jdt.core} which is usually right. + * @param error The associated exception. Can be {@code null}. */ public static void error(CompilationUnitDeclaration cud, String message, String bundleName, Throwable error) { + if (bundleName == null) bundleName = DEFAULT_BUNDLE; try { new EclipseWorkspaceLogger().error(message, bundleName, error); - } catch (NoClassDefFoundError e) { //standalone ecj does not jave Platform, ILog, IStatus, and friends. + } catch (NoClassDefFoundError e) { //standalone ecj does not jave Platform, ILog, IStatus, and friends. new TerminalLogger().error(message, bundleName, error); } if (cud != null) EclipseAST.addProblemToCompilationResult(cud, false, message + " - See error log.", 0, 0); } + /** + * Generates a warning in the Eclipse error log. Note that most people never look at it! + * + * @param cud The {@code CompilationUnitDeclaration} where the error occurred. + * An error will be generated on line 0 linking to the error log entry. Can be {@code null}. + * @param message Human readable description of the problem. + * @param error The associated exception. Can be {@code null}. + */ + public static void warning(String message, Throwable error) { + warning(message, null, error); + } + + /** + * Generates a warning in the Eclipse error log. Note that most people never look at it! + * + * @param message Human readable description of the problem. + * @param bundleName Can be {@code null} to default to {@code org.eclipse.jdt.core} which is usually right. + * @param error The associated exception. Can be {@code null}. + */ + public static void warning(String message, String bundleName, Throwable error) { + if (bundleName == null) bundleName = DEFAULT_BUNDLE; + try { + new EclipseWorkspaceLogger().warning(message, bundleName, error); + } catch (NoClassDefFoundError e) { //standalone ecj does not jave Platform, ILog, IStatus, and friends. + new TerminalLogger().warning(message, bundleName, error); + } + } + private static class TerminalLogger { void error(String message, String bundleName, Throwable error) { System.err.println(message); - error.printStackTrace(); + if (error != null) error.printStackTrace(); + } + + void warning(String message, String bundleName, Throwable error) { + System.err.println(message); + if (error != null) error.printStackTrace(); } } private static class EclipseWorkspaceLogger { void error(String message, String bundleName, Throwable error) { + msg(IStatus.ERROR, message, bundleName, error); + } + + void warning(String message, String bundleName, Throwable error) { + msg(IStatus.WARNING, message, bundleName, error); + } + + private void msg(int msgType, String message, String bundleName, Throwable error) { Bundle bundle = Platform.getBundle(bundleName); if (bundle == null) { System.err.printf("Can't find bundle %s while trying to report error:\n%s\n", bundleName, message); @@ -137,7 +176,7 @@ public class Eclipse { ILog log = Platform.getLog(bundle); - log.log(new Status(IStatus.ERROR, bundleName, message, error)); + log.log(new Status(msgType, bundleName, message, error)); } } diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java index df4681f0..ba7f891a 100644 --- a/src/core/lombok/eclipse/HandlerLibrary.java +++ b/src/core/lombok/eclipse/HandlerLibrary.java @@ -103,7 +103,7 @@ public class HandlerLibrary { SpiLoadUtil.findAnnotationClass(handler.getClass(), EclipseAnnotationHandler.class); AnnotationHandlerContainer container = new AnnotationHandlerContainer(handler, annotationClass); if (lib.annotationHandlers.put(container.annotationClass.getName(), container) != null) { - Eclipse.error(null, "Duplicate handlers for annotation type: " + container.annotationClass.getName()); + Eclipse.error(null, "Duplicate handlers for annotation type: " + container.annotationClass.getName(), null); } lib.typeLibrary.addType(container.annotationClass.getName()); } catch (Throwable t) { diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index a2867c39..4d397a3c 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -506,6 +506,27 @@ public class EclipseHandlerUtil { method.annotations = createSuppressWarningsAll(method, method.annotations); TypeDeclaration parent = (TypeDeclaration) type.get(); + if (parent.scope != null && method.scope == null) { + // We think this means heisenbug #164 is about to happen later in some other worker thread. + // To improve our ability to figure out what the heck is going on, let's generate a log so we can ask those who stumble on this about it, + // and thus see a far more useful stack trace. + boolean report = true; + for (StackTraceElement elem : Thread.currentThread().getStackTrace()) { + // We intentionally hook into the middle of ClassScope filling in BlockScopes for PatchDelegate, + // meaning that will trigger a false positive. Detect it and do not report the occurence of #164 if so. + if ("lombok.eclipse.agent.PatchDelegate".equals(elem.getClassName())) { + report = false; + break; + } + } + + if (report) { + Eclipse.warning("We believe you may have just stumbled on lombok issue #164. Please " + + "report the stack trace associated with this message at:\n" + + "http://code.google.com/p/projectlombok/issues/detail?id=164", new Throwable()); + } + } + if (parent.methods == null) { parent.methods = new AbstractMethodDeclaration[1]; parent.methods[0] = method; diff --git a/src/core/lombok/eclipse/handlers/HandleCleanup.java b/src/core/lombok/eclipse/handlers/HandleCleanup.java index 964653bc..9a63ce47 100644 --- a/src/core/lombok/eclipse/handlers/HandleCleanup.java +++ b/src/core/lombok/eclipse/handlers/HandleCleanup.java @@ -42,6 +42,7 @@ import org.eclipse.jdt.internal.compiler.ast.CastExpression; import org.eclipse.jdt.internal.compiler.ast.EqualExpression; import org.eclipse.jdt.internal.compiler.ast.Expression; import org.eclipse.jdt.internal.compiler.ast.IfStatement; +import org.eclipse.jdt.internal.compiler.ast.IntLiteral; import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; import org.eclipse.jdt.internal.compiler.ast.MemberValuePair; import org.eclipse.jdt.internal.compiler.ast.MessageSend; @@ -174,16 +175,7 @@ public class HandleCleanup implements EclipseAnnotationHandler { NullLiteral nullLiteral = new NullLiteral(pS, pE); Eclipse.setGeneratedBy(nullLiteral, ast); - MessageSend preventNullAnalysis = new MessageSend(); - Eclipse.setGeneratedBy(preventNullAnalysis, ast); - - preventNullAnalysis.receiver = createNameReference("lombok.Lombok", ast); - preventNullAnalysis.selector = "preventNullAnalysis".toCharArray(); - - preventNullAnalysis.arguments = new Expression[] { varName }; - preventNullAnalysis.nameSourcePosition = p; - preventNullAnalysis.sourceStart = pS; - preventNullAnalysis.sourceEnd = preventNullAnalysis.statementEnd = pE; + MessageSend preventNullAnalysis = preventNullAnalysis(ast, varName); EqualExpression equalExpression = new EqualExpression(preventNullAnalysis, nullLiteral, OperatorIds.NOT_EQUAL); equalExpression.sourceStart = pS; equalExpression.sourceEnd = pE; @@ -195,8 +187,6 @@ public class HandleCleanup implements EclipseAnnotationHandler { Eclipse.setGeneratedBy(closeBlock, ast); IfStatement ifStatement = new IfStatement(equalExpression, closeBlock, 0, 0); Eclipse.setGeneratedBy(ifStatement, ast); - - finallyBlock[0] = ifStatement; tryStatement.finallyBlock = new Block(0); @@ -219,6 +209,35 @@ public class HandleCleanup implements EclipseAnnotationHandler { return true; } + private MessageSend preventNullAnalysis(Annotation ast, Expression expr) { + MessageSend singletonList = new MessageSend(); + Eclipse.setGeneratedBy(singletonList, ast); + + int pS = ast.sourceStart, pE = ast.sourceEnd; + long p = (long)pS << 32 | pE; + + singletonList.receiver = createNameReference("java.util.Collections", ast); + singletonList.selector = "singletonList".toCharArray(); + + singletonList.arguments = new Expression[] { expr }; + singletonList.nameSourcePosition = p; + singletonList.sourceStart = pS; + singletonList.sourceEnd = singletonList.statementEnd = pE; + + MessageSend preventNullAnalysis = new MessageSend(); + Eclipse.setGeneratedBy(preventNullAnalysis, ast); + + preventNullAnalysis.receiver = singletonList; + preventNullAnalysis.selector = "get".toCharArray(); + + preventNullAnalysis.arguments = new Expression[] { new IntLiteral(new char[] { '0' }, pS, pE) }; + preventNullAnalysis.nameSourcePosition = p; + preventNullAnalysis.sourceStart = pS; + preventNullAnalysis.sourceEnd = singletonList.statementEnd = pE; + + return preventNullAnalysis; + } + private void doAssignmentCheck(EclipseNode node, Statement[] tryBlock, char[] varName) { for (Statement statement : tryBlock) doAssignmentCheck0(node, statement, varName); } diff --git a/src/core/lombok/javac/handlers/HandleCleanup.java b/src/core/lombok/javac/handlers/HandleCleanup.java index 9e2fddf6..b681ab28 100644 --- a/src/core/lombok/javac/handlers/HandleCleanup.java +++ b/src/core/lombok/javac/handlers/HandleCleanup.java @@ -117,7 +117,7 @@ public class HandleCleanup implements JavacAnnotationHandler { List cleanupCall = List.of(maker.Exec( maker.Apply(List.nil(), cleanupMethod, List.nil()))); - JCMethodInvocation preventNullAnalysis = maker.Apply(List.nil(), JavacHandlerUtil.chainDotsString(maker, annotationNode, "lombok.Lombok.preventNullAnalysis"), List.of(maker.Ident(decl.name))); + JCMethodInvocation preventNullAnalysis = preventNullAnalysis(maker, annotationNode, maker.Ident(decl.name)); JCBinary isNull = maker.Binary(Javac.getCTCint(JCTree.class, "NE"), preventNullAnalysis, maker.Literal(Javac.getCTCint(TypeTags.class, "BOT"), null)); JCIf ifNotNullCleanup = maker.If(isNull, maker.Block(0, cleanupCall), null); @@ -139,6 +139,12 @@ public class HandleCleanup implements JavacAnnotationHandler { return true; } + private JCMethodInvocation preventNullAnalysis(TreeMaker maker, JavacNode node, JCExpression expression) { + JCMethodInvocation singletonList = maker.Apply(List.nil(), JavacHandlerUtil.chainDotsString(maker, node, "java.util.Collections.singletonList"), List.of(expression)); + JCMethodInvocation cleanedExpr = maker.Apply(List.nil(), maker.Select(singletonList, node.toName("get")) , List.of(maker.Literal(TypeTags.INT, 0))); + return cleanedExpr; + } + private void doAssignmentCheck(JavacNode node, List statements, Name name) { for (JCStatement statement : statements) doAssignmentCheck0(node, statement, name); } diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java index 0aa47dba..846232f6 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java @@ -74,7 +74,6 @@ import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.Binding; import org.eclipse.jdt.internal.compiler.lookup.ClassScope; -import org.eclipse.jdt.internal.compiler.lookup.MemberTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; @@ -475,7 +474,7 @@ public class PatchDelegate { inner = binding; } - if (inner instanceof MemberTypeBinding) { + if (inner instanceof SourceTypeBinding) { ClassScope cs = ((SourceTypeBinding)inner).scope; if (cs != null) { try { @@ -527,6 +526,7 @@ public class PatchDelegate { private static final List METHODS_IN_OBJECT = Collections.unmodifiableList(Arrays.asList( "hashCode()", + "canEqual(java.lang.Object)", //Not in j.l.Object, but it goes with hashCode and equals so if we ignore those two, we should ignore this one. "equals(java.lang.Object)", "wait()", "wait(long)", diff --git a/test/transform/resource/after-delombok/CleanupName.java b/test/transform/resource/after-delombok/CleanupName.java index 37a8d117..a4ab8267 100644 --- a/test/transform/resource/after-delombok/CleanupName.java +++ b/test/transform/resource/after-delombok/CleanupName.java @@ -4,7 +4,7 @@ class CleanupName { try { System.out.println(o); } finally { - if (lombok.Lombok.preventNullAnalysis(o) != null) { + if (java.util.Collections.singletonList(o).get(0) != null) { o.toString(); } } @@ -14,7 +14,7 @@ class CleanupName { try { System.out.println(o); } finally { - if (lombok.Lombok.preventNullAnalysis(o) != null) { + if (java.util.Collections.singletonList(o).get(0) != null) { o.toString(); } } diff --git a/test/transform/resource/after-delombok/CleanupPlain.java b/test/transform/resource/after-delombok/CleanupPlain.java index 67c82f60..f91f35ee 100644 --- a/test/transform/resource/after-delombok/CleanupPlain.java +++ b/test/transform/resource/after-delombok/CleanupPlain.java @@ -9,12 +9,12 @@ class CleanupPlain { out.flush(); } } finally { - if (lombok.Lombok.preventNullAnalysis(out) != null) { + if (java.util.Collections.singletonList(out).get(0) != null) { out.close(); } } } finally { - if (lombok.Lombok.preventNullAnalysis(in) != null) { + if (java.util.Collections.singletonList(in).get(0) != null) { in.close(); } } diff --git a/test/transform/resource/after-ecj/CleanupName.java b/test/transform/resource/after-ecj/CleanupName.java index 8948e91d..f3f725f2 100644 --- a/test/transform/resource/after-ecj/CleanupName.java +++ b/test/transform/resource/after-ecj/CleanupName.java @@ -10,7 +10,7 @@ class CleanupName { } finally { - if ((lombok.Lombok.preventNullAnalysis(o) != null)) + if ((java.util.Collections.singletonList(o).get(0) != null)) { o.toString(); } @@ -24,7 +24,7 @@ class CleanupName { } finally { - if ((lombok.Lombok.preventNullAnalysis(o) != null)) + if ((java.util.Collections.singletonList(o).get(0) != null)) { o.toString(); } diff --git a/test/transform/resource/after-ecj/CleanupPlain.java b/test/transform/resource/after-ecj/CleanupPlain.java index 6eaa4377..a9b9eceb 100644 --- a/test/transform/resource/after-ecj/CleanupPlain.java +++ b/test/transform/resource/after-ecj/CleanupPlain.java @@ -18,7 +18,7 @@ class CleanupPlain { } finally { - if ((lombok.Lombok.preventNullAnalysis(out) != null)) + if ((java.util.Collections.singletonList(out).get(0) != null)) { out.close(); } @@ -26,7 +26,7 @@ class CleanupPlain { } finally { - if ((lombok.Lombok.preventNullAnalysis(in) != null)) + if ((java.util.Collections.singletonList(in).get(0) != null)) { in.close(); } diff --git a/usage_examples/onXExample_post.jpage b/usage_examples/onXExample_post.jpage new file mode 100644 index 00000000..85e3c58f --- /dev/null +++ b/usage_examples/onXExample_post.jpage @@ -0,0 +1,42 @@ +import com.google.inject.Inject; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import org.hibernate.validator.Min; + +public class OnMethodOnParamExample { + private int bananas; + private int radishes; + + @Deprecated + public int getBananas() { + return bananas; + } + + @Min(10) + public int setRadishes(int radishes) { + this.radishes = radishes; + } + + @Override public String toString() { + return String.format("I have %d bananas and %d beautiful radishes", bananas, radishes); + } +} + +class OnConstructorExample { + private final Fireman fireman; + private int fires = 10; + + @Inject + public OnConstructorExample(Fireman fireman) { + this.fireman = fireman; + } + + public void setFires(@SuppressWarnings("all") int fires) { + this.fires = fires; + } + + @Override public String toString() { + return String.format("Fireman: %s has %d fires", fireman, fires); + } +} \ No newline at end of file diff --git a/usage_examples/onXExample_pre.jpage b/usage_examples/onXExample_pre.jpage new file mode 100644 index 00000000..1bab3835 --- /dev/null +++ b/usage_examples/onXExample_pre.jpage @@ -0,0 +1,24 @@ +import com.google.inject.Inject; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import org.hibernate.validator.Min; + +public class OnMethodOnParamExample { + @Getter(onMethod=@Deprecated) private int bananas; + @Setter(onMethod=@Min(10)) private int radishes; + + @Override public String toString() { + return String.format("I have %d bananas and %d beautiful radishes", bananas, radishes); + } +} + +@RequiredArgsConstructor(onConstructor=@Inject) +class OnConstructorExample { + private final Fireman fireman; + @Setter(onParam=@SuppressWarnings("all")) private int fires = 10; + + @Override public String toString() { + return String.format("Fireman: %s has %d fires", fireman, fires); + } +} \ No newline at end of file diff --git a/website/features/Constructor.html b/website/features/Constructor.html index 072e46ed..c0ab9ef8 100644 --- a/website/features/Constructor.html +++ b/website/features/Constructor.html @@ -71,6 +71,10 @@

@XArgsConstructor can also be used on an enum definition. The generated constructor will always be private, because non-private constructors aren't legal in enums. You don't have to specify AccessLevel.PRIVATE. +

+ While suppressConstructorProperties has been marked deprecated in anticipation of a world where all java environments have the + @ConstructorProperties annotation available, first GWT 2.2 and Android 2.3.3, which do not (yet) have this annotation, will have + to be ancient history before this annotation parameter will be removed.

diff --git a/website/features/Delegate.html b/website/features/Delegate.html index bdb22c26..52b1035d 100644 --- a/website/features/Delegate.html +++ b/website/features/Delegate.html @@ -51,7 +51,7 @@
diff --git a/website/features/index.html b/website/features/index.html index 06b6763e..e9a2255b 100644 --- a/website/features/index.html +++ b/website/features/index.html @@ -38,6 +38,8 @@
Finally! hassle-free final local variables.
@Delegate
Don't lose your composition
+
onMethod=,onParam=,onConstructor=
+
Annotate this! Add you favorite annotation to methods generated by lombok.
diff --git a/website/features/onX.html b/website/features/onX.html new file mode 100644 index 00000000..b94dea4b --- /dev/null +++ b/website/features/onX.html @@ -0,0 +1,58 @@ + + + + + + + + onMethod=,onParam=,onConstructor= +
+
+
+ +

onMethod=,onParam=,onConstructor=

+ +
+

Overview

+

+ Lombok lets you add your favorite annotation to methods generated by @Getter and @Setter by using the attribute onMethod + on the lombok annotation. You can specify annotations to the parameters of the method on @Setter with the attribute onParameter. + You can add annotation to constructors generated by @NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructor by using the attribute + onConstructor +

+
+
+
+

With Lombok

+
@HTML_PRE@
+
+
+
+

Vanilla Java

+
@HTML_POST@
+
+
+
+
+

Small print

+ When the @Getter or @Setter annotation is placed on the type in stead of a field, using the attribute is not supported and it will result in a warning. +
+
+ +
+
+
+ + + diff --git a/website/mavenrepo/index.html b/website/mavenrepo/index.html index 6b8ea48d..aa7f4935 100644 --- a/website/mavenrepo/index.html +++ b/website/mavenrepo/index.html @@ -43,7 +43,7 @@
-

Use Lombok via Maven

+

Use Lombok via Maven or ivy

You can use lombok with maven by adding the following to your pom.xml:
<dependencies> @@ -53,25 +53,14 @@ <version>@VERSION@</version> <scope>provided</scope> </dependency> -</dependencies> -<repositories> - <repository> - <id>projectlombok.org</id> - <url>http://projectlombok.org/mavenrepo</url> - </repository> -</repositories>
+</dependencies>
+
- CAREFUL: lombok requires using the javac v1.6 compiler. If this is not your default compiler, you'll need to add the following to your - pom file to explicitly set the java compiler version to use: -
<plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <compilerVersion>1.6</compilerVersion> - <source>1.6</source> - <target>1.6</target> - </configuration> -</plugin>
+ You can use lombok with ivy by adding the following to your ivy.xml: +
<dependency org="projectlombok.org" name="lombok" rev="@VERSION@" conf="build" />
+
+
+ CAREFUL: lombok requires using the javac v1.6 compiler or higher.
That's all there is to it!
note: You'll still need to download lombok, or doubleclick on the lombok.jar file downloaded by maven, to install lombok into your eclipse installation.