Open lgemeinhardt opened 9 months ago
This sample code should find the "LO_APPENDED_STRING_IN_FORMAT_STRING" bug warning :
package sample; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class Sample { private static final Logger LOG = LogManager.getLogger(); public static void main(final String[] args) { LOG.error("main args " + args.length); // should raise LO_APPENDED_STRING_IN_FORMAT_STRING bug warning } }
And does it, if compiled with target 1.8, but not if compiled with target 11. Tested with JDK 11, 17 and 21.
The issue is the compiler is chosing
void error(Object message);
rather than
void error(String message);
so that check is bypassed. can be fixed.
This sample code should find the "LO_APPENDED_STRING_IN_FORMAT_STRING" bug warning :
And does it, if compiled with target 1.8, but not if compiled with target 11. Tested with JDK 11, 17 and 21.