aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/eclipse/handlers/HandleLog.java20
-rw-r--r--src/core/lombok/javac/handlers/HandleLog.java7
-rw-r--r--test/transform/resource/after-delombok/LoggerJul.java6
-rw-r--r--test/transform/resource/after-ecj/LoggerJul.java6
4 files changed, 26 insertions, 13 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java
index 08f3e6f2..dfb45a29 100644
--- a/src/core/lombok/eclipse/handlers/HandleLog.java
+++ b/src/core/lombok/eclipse/handlers/HandleLog.java
@@ -42,7 +42,6 @@ import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.NameReference;
import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -216,12 +215,23 @@ public class HandleLog {
// private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(TargetType.class);
COMMONS(lombok.jul.Log.class, "org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory", "getLog"),
- // private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("TargetType");
+ // private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(TargetType.class.getName());
JUL(lombok.jul.Log.class, "java.util.logging.Logger", "java.util.logging.Logger", "getLogger") {
@Override public Expression createFactoryParameter(String typeName, Annotation source) {
- Expression current = new StringLiteral(typeName.toCharArray(), source.sourceStart, source.sourceEnd, 0);
- Eclipse.setGeneratedBy(current, source);
- return current;
+ int pS = source.sourceStart, pE = source.sourceEnd;
+ long p = (long)pS << 32 | pE;
+
+ MessageSend factoryParameterCall = new MessageSend();
+ Eclipse.setGeneratedBy(factoryParameterCall, source);
+
+ factoryParameterCall.receiver = super.createFactoryParameter(typeName, source);
+ factoryParameterCall.selector = "getName".toCharArray();
+
+ factoryParameterCall.nameSourcePosition = p;
+ factoryParameterCall.sourceStart = pS;
+ factoryParameterCall.sourceEnd = factoryParameterCall.statementEnd = pE;
+
+ return factoryParameterCall;
}
},
diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java
index 52a308ab..014895a1 100644
--- a/src/core/lombok/javac/handlers/HandleLog.java
+++ b/src/core/lombok/javac/handlers/HandleLog.java
@@ -155,10 +155,13 @@ public class HandleLog {
// private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(TargetType.class);
COMMONS(lombok.jul.Log.class, "org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory.getLog"),
- // private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("TargetType");
+ // private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(TargetType.class.getName());
JUL(lombok.jul.Log.class, "java.util.logging.Logger", "java.util.logging.Logger.getLogger") {
@Override public JCExpression createFactoryParameter(JavacNode typeNode, String typeName) {
- return typeNode.getTreeMaker().Literal(typeName);
+ TreeMaker maker = typeNode.getTreeMaker();
+ JCExpression classAccess = super.createFactoryParameter(typeNode, typeName);
+ JCExpression method = maker.Select(classAccess, typeNode.toName("getName"));
+ return maker.Apply(List.<JCExpression>nil(), method, List.<JCExpression>nil());
}
},
diff --git a/test/transform/resource/after-delombok/LoggerJul.java b/test/transform/resource/after-delombok/LoggerJul.java
index a40bb2da..51f19926 100644
--- a/test/transform/resource/after-delombok/LoggerJul.java
+++ b/test/transform/resource/after-delombok/LoggerJul.java
@@ -1,9 +1,9 @@
class LoggerJul {
- private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("LoggerJul");
+ private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJul.class.getName());
}
class LoggerJulString {
- private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("String");
+ private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(String.class.getName());
}
class LoggerJulJavaLangString {
- private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("java.lang.String");
+ private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(java.lang.String.class.getName());
} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/LoggerJul.java b/test/transform/resource/after-ecj/LoggerJul.java
index 734d0dac..99c1000c 100644
--- a/test/transform/resource/after-ecj/LoggerJul.java
+++ b/test/transform/resource/after-ecj/LoggerJul.java
@@ -1,5 +1,5 @@
@lombok.jul.Log class LoggerJul {
- private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("LoggerJul");
+ private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJul.class.getName());
<clinit>() {
}
LoggerJul() {
@@ -7,7 +7,7 @@
}
}
@lombok.jul.Log(String.class) class LoggerJulString {
- private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("String");
+ private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(String.class.getName());
<clinit>() {
}
LoggerJulString() {
@@ -15,7 +15,7 @@
}
}
@lombok.jul.Log(java.lang.String.class) class LoggerJulJavaLangString {
- private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("java.lang.String");
+ private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(java.lang.String.class.getName());
<clinit>() {
}
LoggerJulJavaLangString() {