aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers/HandleCleanup.java
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2010-11-09 00:37:06 +0100
committerRoel Spilker <r.spilker@gmail.com>2010-11-09 00:37:06 +0100
commita94243e06202a274a9499d1c0e79aeccb1aef5cd (patch)
tree1dc46be3d32e92903f48f58c25823e99ca608e9d /src/core/lombok/javac/handlers/HandleCleanup.java
parent98d8a9f63b3183005174abb7691a1692347b9a2e (diff)
downloadlombok-a94243e06202a274a9499d1c0e79aeccb1aef5cd.tar.gz
lombok-a94243e06202a274a9499d1c0e79aeccb1aef5cd.tar.bz2
lombok-a94243e06202a274a9499d1c0e79aeccb1aef5cd.zip
Added lombok.Lombok.preventNullAnalysis to the null test in @Cleanup to suppress
warnings about variables that cannot be null
Diffstat (limited to 'src/core/lombok/javac/handlers/HandleCleanup.java')
-rw-r--r--src/core/lombok/javac/handlers/HandleCleanup.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/lombok/javac/handlers/HandleCleanup.java b/src/core/lombok/javac/handlers/HandleCleanup.java
index 779dd3ea..d72898b8 100644
--- a/src/core/lombok/javac/handlers/HandleCleanup.java
+++ b/src/core/lombok/javac/handlers/HandleCleanup.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -45,6 +45,7 @@ import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
import com.sun.tools.javac.tree.JCTree.JCIdent;
import com.sun.tools.javac.tree.JCTree.JCIf;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
+import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCTypeCast;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
@@ -115,7 +116,8 @@ public class HandleCleanup implements JavacAnnotationHandler<Cleanup> {
List<JCStatement> cleanupCall = List.<JCStatement>of(maker.Exec(
maker.Apply(List.<JCExpression>nil(), cleanupMethod, List.<JCExpression>nil())));
- JCBinary isNull = maker.Binary(JCTree.NE, maker.Ident(decl.name), maker.Literal(TypeTags.BOT, null));
+ JCMethodInvocation preventNullAnalysis = maker.Apply(List.<JCExpression>nil(), JavacHandlerUtil.chainDotsString(maker, annotationNode, "lombok.Lombok.preventNullAnalysis"), List.<JCExpression>of(maker.Ident(decl.name)));
+ JCBinary isNull = maker.Binary(JCTree.NE, preventNullAnalysis, maker.Literal(TypeTags.BOT, null));
JCIf ifNotNullCleanup = maker.If(isNull, maker.Block(0, cleanupCall), null);