[fixes #2469] Support static reference as logger topic

This commit is contained in:
Rawi01 authored and Roel Spilker committed 2020-07-02 23:08:41 +02:00
1 parent e4ec9e6648
commit 9425e99b49
34 files changed
+279 -37

No files matched your search

@@ -411,6 +411,14 @@ public class AnnotationValues<A extends Annotation> {
List<Object> l = getActualExpressions(annotationMethodName);
return l.isEmpty() ? null : l.get(0);
}
/**
* Returns the guessed value for the provided {@code annotationMethodName}.
*/
public Object getValueGuess(String annotationMethodName) {
AnnotationValue v = values.get(annotationMethodName);
return v == null || v.valueGuesses.isEmpty() ? null : v.valueGuesses.get(0);
}
/** Generates an error message on the stated annotation value (you should only call this method if you know it's there!) */
public void setError(String annotationMethodName, String message) {
@@ -49,6 +49,7 @@ import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
import org.eclipse.jdt.internal.compiler.ast.AssertStatement;
import org.eclipse.jdt.internal.compiler.ast.BinaryExpression;
import org.eclipse.jdt.internal.compiler.ast.Block;
import org.eclipse.jdt.internal.compiler.ast.CastExpression;
import org.eclipse.jdt.internal.compiler.ast.CharLiteral;
@@ -380,7 +381,7 @@ public class EclipseHandlerUtil {
}
}
private static Expression copyAnnotationMemberValue(Expression in) {
public static Expression copyAnnotationMemberValue(Expression in) {
Expression out = copyAnnotationMemberValue0(in);
out.constant = in.constant;
return out;
@@ -421,12 +422,11 @@ public class EclipseHandlerUtil {
if (in instanceof SingleNameReference) {
SingleNameReference snr = (SingleNameReference) in;
long p = (long) s << 32 | e;
return new SingleNameReference(snr.token, p);
return new SingleNameReference(snr.token, pos(in));
}
if (in instanceof QualifiedNameReference) {
QualifiedNameReference qnr = (QualifiedNameReference) in;
return new QualifiedNameReference(qnr.tokens, qnr.sourcePositions, s, e);
return new QualifiedNameReference(qnr.tokens, poss(in, qnr.tokens.length), s, e);
}
// class refs
@@ -442,11 +442,22 @@ public class EclipseHandlerUtil {
out.sourceEnd = e;
out.bits = in.bits;
out.implicitConversion = in.implicitConversion;
out.statementEnd = in.statementEnd;
out.statementEnd = e;
out.expressions = copy;
return out;
}
if (in instanceof BinaryExpression) {
BinaryExpression be = (BinaryExpression) in;
BinaryExpression out = new BinaryExpression(be);
out.left = copyAnnotationMemberValue(be.left);
out.right = copyAnnotationMemberValue(be.right);
out.sourceStart = s;
out.sourceEnd = e;
out.statementEnd = e;
return out;
}
return in;
}
+20 -16
View File
@@ -51,6 +51,7 @@ import lombok.core.configuration.LogDeclaration.LogFactoryParameter;
import lombok.core.handlers.LoggingFramework;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult;
public class HandleLog {
private static final IdentifierName LOG = IdentifierName.valueOf("log");
@@ -59,7 +60,7 @@ public class HandleLog {
throw new UnsupportedOperationException();
}
public static void processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode, String loggerTopic) {
public static void processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode) {
EclipseNode owner = annotationNode.up();
switch (owner.getKind()) {
@@ -84,15 +85,18 @@ public class HandleLog {
annotationNode.addWarning("Field '" + logFieldName + "' already exists.");
return;
}
if (loggerTopic != null && loggerTopic.trim().isEmpty()) loggerTopic = null;
Object valueGuess = annotation.getValueGuess("topic");
Expression loggerTopic = (Expression) annotation.getActualExpression("topic");
if (valueGuess instanceof String && ((String) valueGuess).trim().isEmpty()) loggerTopic = null;
if (framework.getDeclaration().getParametersWithTopic() == null && loggerTopic != null) {
annotationNode.addError(framework.getAnnotationAsString() + " does not allow a topic.");
loggerTopic = null;
}
if (framework.getDeclaration().getParametersWithoutTopic() == null && loggerTopic == null) {
annotationNode.addError(framework.getAnnotationAsString() + " requires a topic.");
loggerTopic = "";
loggerTopic = new StringLiteral(new char[]{}, 0, 0, 0);
}
ClassLiteralAccess loggingType = selfType(owner, source);
@@ -122,7 +126,7 @@ public class HandleLog {
return result;
}
private static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType, String logFieldName, boolean useStatic, String loggerTopic) {
private static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType, String logFieldName, boolean useStatic, Expression loggerTopic) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long) pS << 32 | pE;
@@ -165,7 +169,7 @@ public class HandleLog {
return typeReference;
}
private static final Expression[] createFactoryParameters(ClassLiteralAccess loggingType, Annotation source, List<LogFactoryParameter> parameters, String loggerTopic) {
private static final Expression[] createFactoryParameters(ClassLiteralAccess loggingType, Annotation source, List<LogFactoryParameter> parameters, Expression loggerTopic) {
Expression[] expressions = new Expression[parameters.size()];
int pS = source.sourceStart, pE = source.sourceEnd;
@@ -192,7 +196,7 @@ public class HandleLog {
expressions[i] = factoryParameterCall;
break;
case TOPIC:
expressions[i] = new StringLiteral(loggerTopic.toCharArray(), pS, pE, 0);
expressions[i] = EclipseHandlerUtil.copyAnnotationMemberValue(loggerTopic);
break;
case NULL:
expressions[i] = new NullLiteral(pS, pE);
@@ -219,7 +223,7 @@ public class HandleLog {
public static class HandleCommonsLog extends EclipseAnnotationHandler<lombok.extern.apachecommons.CommonsLog> {
@Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_COMMONS_FLAG_USAGE, "@apachecommons.CommonsLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode);
}
}
@@ -230,7 +234,7 @@ public class HandleLog {
public static class HandleJulLog extends EclipseAnnotationHandler<lombok.extern.java.Log> {
@Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JUL_FLAG_USAGE, "@java.Log", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode);
}
}
@@ -241,7 +245,7 @@ public class HandleLog {
public static class HandleLog4jLog extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J_FLAG_USAGE, "@Log4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode);
}
}
@@ -252,7 +256,7 @@ public class HandleLog {
public static class HandleLog4j2Log extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j2> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J2_FLAG_USAGE, "@Log4j2", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode);
}
}
@@ -263,7 +267,7 @@ public class HandleLog {
public static class HandleSlf4jLog extends EclipseAnnotationHandler<lombok.extern.slf4j.Slf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_SLF4J_FLAG_USAGE, "@Slf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode);
}
}
@@ -274,7 +278,7 @@ public class HandleLog {
public static class HandleXSlf4jLog extends EclipseAnnotationHandler<lombok.extern.slf4j.XSlf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_XSLF4J_FLAG_USAGE, "@XSlf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode);
}
}
@@ -285,7 +289,7 @@ public class HandleLog {
public static class HandleJBossLog extends EclipseAnnotationHandler<lombok.extern.jbosslog.JBossLog> {
@Override public void handle(AnnotationValues<lombok.extern.jbosslog.JBossLog> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JBOSSLOG_FLAG_USAGE, "@JBossLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.JBOSSLOG, annotation, source, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.JBOSSLOG, annotation, source, annotationNode);
}
}
@@ -296,7 +300,7 @@ public class HandleLog {
public static class HandleFloggerLog extends EclipseAnnotationHandler<lombok.extern.flogger.Flogger> {
@Override public void handle(AnnotationValues<lombok.extern.flogger.Flogger> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_FLOGGER_FLAG_USAGE, "@Flogger", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.FLOGGER, annotation, source, annotationNode, "");
processAnnotation(LoggingFramework.FLOGGER, annotation, source, annotationNode);
}
}
@@ -313,7 +317,7 @@ public class HandleLog {
return;
}
LoggingFramework framework = new LoggingFramework(lombok.CustomLog.class, logDeclaration);
processAnnotation(framework, annotation, source, annotationNode, annotation.getInstance().topic());
processAnnotation(framework, annotation, source, annotationNode);
}
}
}
+18 -15
View File
@@ -56,7 +56,7 @@ public class HandleLog {
throw new UnsupportedOperationException();
}
public static void processAnnotation(LoggingFramework framework, AnnotationValues<?> annotation, JavacNode annotationNode, String loggerTopic) {
public static void processAnnotation(LoggingFramework framework, AnnotationValues<?> annotation, JavacNode annotationNode) {
deleteAnnotationIfNeccessary(annotationNode, framework.getAnnotationClass());
JavacNode typeNode = annotationNode.up();
@@ -76,14 +76,17 @@ public class HandleLog {
return;
}
if (loggerTopic != null && loggerTopic.trim().isEmpty()) loggerTopic = null;
Object valueGuess = annotation.getValueGuess("topic");
JCExpression loggerTopic = (JCExpression) annotation.getActualExpression("topic");
if (valueGuess instanceof String && ((String) valueGuess).trim().isEmpty()) loggerTopic = null;
if (framework.getDeclaration().getParametersWithTopic() == null && loggerTopic != null) {
annotationNode.addError(framework.getAnnotationAsString() + " does not allow a topic.");
loggerTopic = null;
}
if (framework.getDeclaration().getParametersWithoutTopic() == null && loggerTopic == null) {
annotationNode.addError(framework.getAnnotationAsString() + " requires a topic.");
loggerTopic = "";
loggerTopic = typeNode.getTreeMaker().Literal("");
}
JCFieldAccess loggingType = selfType(typeNode);
@@ -101,7 +104,7 @@ public class HandleLog {
return maker.Select(maker.Ident(name), typeNode.toName("class"));
}
private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String logFieldName, boolean useStatic, String loggerTopic) {
private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String logFieldName, boolean useStatic, JCExpression loggerTopic) {
JavacTreeMaker maker = typeNode.getTreeMaker();
LogDeclaration logDeclaration = framework.getDeclaration();
@@ -121,7 +124,7 @@ public class HandleLog {
return true;
}
private static JCExpression[] createFactoryParameters(JavacNode typeNode, JCFieldAccess loggingType, java.util.List<LogFactoryParameter> parameters, String loggerTopic) {
private static JCExpression[] createFactoryParameters(JavacNode typeNode, JCFieldAccess loggingType, java.util.List<LogFactoryParameter> parameters, JCExpression loggerTopic) {
JCExpression[] expressions = new JCExpression[parameters.size()];
JavacTreeMaker maker = typeNode.getTreeMaker();
@@ -136,7 +139,7 @@ public class HandleLog {
expressions[i] = maker.Apply(List.<JCExpression>nil(), method, List.<JCExpression>nil());
break;
case TOPIC:
expressions[i] = maker.Literal(loggerTopic);
expressions[i] = (JCExpression) loggerTopic.clone();
break;
case NULL:
expressions[i] = maker.Literal(CTC_BOT, null);
@@ -156,7 +159,7 @@ public class HandleLog {
public static class HandleCommonsLog extends JavacAnnotationHandler<lombok.extern.apachecommons.CommonsLog> {
@Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_COMMONS_FLAG_USAGE, "@apachecommons.CommonsLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode);
}
}
@@ -167,7 +170,7 @@ public class HandleLog {
public static class HandleJulLog extends JavacAnnotationHandler<lombok.extern.java.Log> {
@Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JUL_FLAG_USAGE, "@java.Log", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.JUL, annotation, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.JUL, annotation, annotationNode);
}
}
@@ -178,7 +181,7 @@ public class HandleLog {
public static class HandleLog4jLog extends JavacAnnotationHandler<lombok.extern.log4j.Log4j> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J_FLAG_USAGE, "@Log4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode);
}
}
@@ -189,7 +192,7 @@ public class HandleLog {
public static class HandleLog4j2Log extends JavacAnnotationHandler<lombok.extern.log4j.Log4j2> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J2_FLAG_USAGE, "@Log4j2", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode);
}
}
@@ -200,7 +203,7 @@ public class HandleLog {
public static class HandleSlf4jLog extends JavacAnnotationHandler<lombok.extern.slf4j.Slf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_SLF4J_FLAG_USAGE, "@Slf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode);
}
}
@@ -211,7 +214,7 @@ public class HandleLog {
public static class HandleXSlf4jLog extends JavacAnnotationHandler<lombok.extern.slf4j.XSlf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_XSLF4J_FLAG_USAGE, "@XSlf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode);
}
}
@@ -222,7 +225,7 @@ public class HandleLog {
public static class HandleJBossLog extends JavacAnnotationHandler<lombok.extern.jbosslog.JBossLog> {
@Override public void handle(AnnotationValues<lombok.extern.jbosslog.JBossLog> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JBOSSLOG_FLAG_USAGE, "@JBossLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.JBOSSLOG, annotation, annotationNode, annotation.getInstance().topic());
processAnnotation(LoggingFramework.JBOSSLOG, annotation, annotationNode);
}
}
@@ -233,7 +236,7 @@ public class HandleLog {
public static class HandleFloggerLog extends JavacAnnotationHandler<lombok.extern.flogger.Flogger> {
@Override public void handle(AnnotationValues<lombok.extern.flogger.Flogger> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_FLOGGER_FLAG_USAGE, "@Flogger", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
processAnnotation(LoggingFramework.FLOGGER, annotation, annotationNode, "");
processAnnotation(LoggingFramework.FLOGGER, annotation, annotationNode);
}
}
@@ -250,7 +253,7 @@ public class HandleLog {
return;
}
LoggingFramework framework = new LoggingFramework(lombok.CustomLog.class, logDeclaration);
processAnnotation(framework, annotation, annotationNode, annotation.getInstance().topic());
processAnnotation(framework, annotation, annotationNode);
}
}
}
@@ -10,3 +10,8 @@ class LoggerCommonsWithDifferentName {
@java.lang.SuppressWarnings("all")
private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("DifferentName");
}
class LoggerCommonsWithStaticField {
@java.lang.SuppressWarnings("all")
private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommonsWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
}
@@ -3,6 +3,12 @@ class LoggerCustomLog {
private static final MyLoggerFactory log = MyLoggerFactory.create(LoggerCustomLog.class.getName(), "t", null, LoggerCustomLog.class, "t");
}
class LoggerCustomLogWithStaticField {
@java.lang.SuppressWarnings("all")
private static final MyLoggerFactory log = MyLoggerFactory.create(LoggerCustomLogWithStaticField.class.getName(), LoggerCustomLogWithStaticField.TOPIC, null, LoggerCustomLogWithStaticField.class, LoggerCustomLogWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
}
class MyLoggerFactory {
static MyLoggerFactory create(String name, String t1, Object o, Class<?> clazz, String t2) {
return null;
@@ -17,3 +17,9 @@ class LoggerJBossLogWithDifferentLoggerName {
@java.lang.SuppressWarnings("all")
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger("DifferentLogger");
}
class LoggerJBossLogWithStaticField {
@java.lang.SuppressWarnings("all")
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LoggerJBossLogWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
}
@@ -10,3 +10,8 @@ class LoggerJulWithDifferentName {
@java.lang.SuppressWarnings("all")
private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("DifferentName");
}
class LoggerJulWithStaticField {
@java.lang.SuppressWarnings("all")
private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJulWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
}
@@ -10,3 +10,8 @@ class LoggerLog4jWithDifferentName {
@java.lang.SuppressWarnings("all")
private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("DifferentName");
}
class LoggerLog4jWithStaticField {
@java.lang.SuppressWarnings("all")
private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4jWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
}
@@ -10,3 +10,8 @@ class LoggerLog4j2WithDifferentName {
@java.lang.SuppressWarnings("all")
private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger("DifferentName");
}
class LoggerLog4j2WithStaticField {
@java.lang.SuppressWarnings("all")
private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2WithStaticField.TOPIC);
static final String TOPIC = "StaticField";
}
@@ -17,3 +17,20 @@ class LoggerSlf4jWithDifferentLoggerName {
@java.lang.SuppressWarnings("all")
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("DifferentLogger");
}
class LoggerSlf4jWithStaticField {
@java.lang.SuppressWarnings("all")
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
}
class LoggerSlf4jWithTwoStaticFields {
@java.lang.SuppressWarnings("all")
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jWithTwoStaticFields.TOPIC + LoggerSlf4jWithTwoStaticFields.TOPIC);
static final String TOPIC = "StaticField";
}
class LoggerSlf4jWithTwoLiterals {
@java.lang.SuppressWarnings("all")
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("A" + "B");
}
@@ -0,0 +1,5 @@
import lombok.extern.slf4j.Slf4j;
@Slf4j(topic = 42)
class LoggerSlf4jWithIntegerTopic {
}
@@ -10,3 +10,8 @@ class LoggerXSlf4jWithDifferentName {
@java.lang.SuppressWarnings("all")
private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger("DifferentName");
}
class LoggerXSlf4jWithStaticField {
@java.lang.SuppressWarnings("all")
private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger(LoggerXSlf4jWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
}
@@ -22,4 +22,13 @@ import lombok.extern.apachecommons.CommonsLog;
LoggerCommonsWithDifferentName() {
super();
}
}
@CommonsLog(topic = LoggerCommonsWithStaticField.TOPIC) class LoggerCommonsWithStaticField {
private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommonsWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
<clinit>() {
}
LoggerCommonsWithStaticField() {
super();
}
}
@@ -6,6 +6,15 @@
super();
}
}
@lombok.CustomLog(topic = LoggerCustomLogWithStaticField.TOPIC) class LoggerCustomLogWithStaticField {
private static final MyLoggerFactory log = MyLoggerFactory.create(LoggerCustomLogWithStaticField.class.getName(), LoggerCustomLogWithStaticField.TOPIC, null, LoggerCustomLogWithStaticField.class, LoggerCustomLogWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
<clinit>() {
}
LoggerCustomLogWithStaticField() {
super();
}
}
class MyLoggerFactory {
MyLoggerFactory() {
super();
@@ -35,4 +35,13 @@ class LoggerJBossLogOuter {
LoggerJBossLogWithDifferentLoggerName() {
super();
}
}
@JBossLog(topic = LoggerJBossLogWithStaticField.TOPIC) class LoggerJBossLogWithStaticField {
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LoggerJBossLogWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
<clinit>() {
}
LoggerJBossLogWithStaticField() {
super();
}
}
@@ -22,4 +22,13 @@ import lombok.extern.java.Log;
LoggerJulWithDifferentName() {
super();
}
}
@Log(topic = LoggerJulWithStaticField.TOPIC) class LoggerJulWithStaticField {
private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJulWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
<clinit>() {
}
LoggerJulWithStaticField() {
super();
}
}
@@ -22,4 +22,13 @@ import lombok.extern.log4j.Log4j;
LoggerLog4jWithDifferentName() {
super();
}
}
@Log4j(topic = LoggerLog4jWithStaticField.TOPIC) class LoggerLog4jWithStaticField {
private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4jWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
<clinit>() {
}
LoggerLog4jWithStaticField() {
super();
}
}
@@ -22,4 +22,13 @@ import lombok.extern.log4j.Log4j2;
LoggerLog4j2WithDifferentName() {
super();
}
}
@Log4j2(topic = LoggerLog4j2WithStaticField.TOPIC) class LoggerLog4j2WithStaticField {
private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2WithStaticField.TOPIC);
static final String TOPIC = "StaticField";
<clinit>() {
}
LoggerLog4j2WithStaticField() {
super();
}
}
@@ -36,4 +36,31 @@ class LoggerSlf4jOuter {
LoggerSlf4jWithDifferentLoggerName() {
super();
}
}
@Slf4j(topic = LoggerSlf4jWithStaticField.TOPIC) class LoggerSlf4jWithStaticField {
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
<clinit>() {
}
LoggerSlf4jWithStaticField() {
super();
}
}
@Slf4j(topic = (LoggerSlf4jWithTwoStaticFields.TOPIC + LoggerSlf4jWithTwoStaticFields.TOPIC)) class LoggerSlf4jWithTwoStaticFields {
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger((LoggerSlf4jWithTwoStaticFields.TOPIC + LoggerSlf4jWithTwoStaticFields.TOPIC));
static final String TOPIC = "StaticField";
<clinit>() {
}
LoggerSlf4jWithTwoStaticFields() {
super();
}
}
@Slf4j(topic = ExtendedStringLiteral{AB}) class LoggerSlf4jWithTwoLiterals {
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("AB");
<clinit>() {
}
LoggerSlf4jWithTwoLiterals() {
super();
}
}
@@ -0,0 +1,9 @@
import lombok.extern.slf4j.Slf4j;
@Slf4j(topic = 42) class LoggerSlf4jWithIntegerTopic {
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(42);
<clinit>() {
}
LoggerSlf4jWithIntegerTopic() {
super();
}
}
@@ -22,4 +22,13 @@ import lombok.extern.slf4j.XSlf4j;
LoggerXSlf4jWithDifferentName() {
super();
}
}
}
@XSlf4j(topic = LoggerXSlf4jWithStaticField.TOPIC) class LoggerXSlf4jWithStaticField {
private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger(LoggerXSlf4jWithStaticField.TOPIC);
static final String TOPIC = "StaticField";
<clinit>() {
}
LoggerXSlf4jWithStaticField() {
super();
}
}
@@ -11,3 +11,8 @@ class LoggerCommonsWithImport {
@CommonsLog(topic="DifferentName")
class LoggerCommonsWithDifferentName {
}
@CommonsLog(topic=LoggerCommonsWithStaticField.TOPIC)
class LoggerCommonsWithStaticField {
static final String TOPIC = "StaticField";
}
@@ -3,6 +3,11 @@
class LoggerCustomLog {
}
@lombok.CustomLog(topic=LoggerCustomLogWithStaticField.TOPIC)
class LoggerCustomLogWithStaticField {
static final String TOPIC = "StaticField";
}
class MyLoggerFactory {
static MyLoggerFactory create(String name, String t1, Object o, Class<?> clazz, String t2) {
return null;
@@ -17,4 +17,9 @@ class LoggerJBossLogOuter {
@JBossLog(topic="DifferentLogger")
class LoggerJBossLogWithDifferentLoggerName {
}
@JBossLog(topic=LoggerJBossLogWithStaticField.TOPIC)
class LoggerJBossLogWithStaticField {
static final String TOPIC = "StaticField";
}
@@ -10,4 +10,9 @@ class LoggerJulWithImport {
@Log(topic="DifferentName")
class LoggerJulWithDifferentName {
}
@Log(topic=LoggerJulWithStaticField.TOPIC)
class LoggerJulWithStaticField {
static final String TOPIC = "StaticField";
}
@@ -10,4 +10,9 @@ class LoggerLog4jWithImport {
@Log4j(topic="DifferentName")
class LoggerLog4jWithDifferentName {
}
@Log4j(topic=LoggerLog4jWithStaticField.TOPIC)
class LoggerLog4jWithStaticField {
static final String TOPIC = "StaticField";
}
@@ -10,4 +10,9 @@ class LoggerLog4j2WithImport {
@Log4j2(topic="DifferentName")
class LoggerLog4j2WithDifferentName {
}
@Log4j2(topic=LoggerLog4j2WithStaticField.TOPIC)
class LoggerLog4j2WithStaticField {
static final String TOPIC = "StaticField";
}
@@ -17,4 +17,18 @@ class LoggerSlf4jOuter {
@Slf4j(topic="DifferentLogger")
class LoggerSlf4jWithDifferentLoggerName {
}
@Slf4j(topic=LoggerSlf4jWithStaticField.TOPIC)
class LoggerSlf4jWithStaticField {
static final String TOPIC = "StaticField";
}
@Slf4j(topic=LoggerSlf4jWithTwoStaticFields.TOPIC + LoggerSlf4jWithTwoStaticFields.TOPIC)
class LoggerSlf4jWithTwoStaticFields {
static final String TOPIC = "StaticField";
}
@Slf4j(topic="A"+"B")
class LoggerSlf4jWithTwoLiterals {
}
@@ -0,0 +1,5 @@
import lombok.extern.slf4j.Slf4j;
@Slf4j(topic=42)
class LoggerSlf4jWithIntegerTopic {
}
@@ -10,4 +10,9 @@ class LoggerXSlf4jWithImport {
@XSlf4j(topic="DifferentName")
class LoggerXSlf4jWithDifferentName {
}
@XSlf4j(topic=LoggerXSlf4jWithStaticField.TOPIC)
class LoggerXSlf4jWithStaticField {
static final String TOPIC = "StaticField";
}
@@ -0,0 +1,2 @@
3 incompatible types: int cannot be converted to java.lang.String
-1 not flagged modified
@@ -0,0 +1 @@
3 Type mismatch: cannot convert from int to String
@@ -0,0 +1 @@
3 incompatible types: int cannot be converted to java.lang.String