apache / apache/logging-log4j-transform

Logger.getName() cause exception

Open
#220 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
6
Forks
8
PR merge metrics
No merged PRs in 30d

Description

When trying to convert the following sample class:
```
public class Main {
private static final Logger logger = LogManager.getLogger();

static public void main(String[] args) {
logger.debug(logger.getName());
}
}
```

A ConversionException is thrown:
`org.apache.logging.log4j.weaver.ConversionException: Unsupported method 'org.apache.logging.log4j.Logger#getName'.`

Based on the stack trace a located the bug to be in the `LoggerConversionHandler` in the `handleMethodInstruction` method.
It seems the default operation to an unplanned function is to throw exception instead of keeping the call as is. There is already a section in the switch for this kind of calls, so creating the NOP as the default will also remove a bit of bloat and support more functions. My suggestion is simple:
```
default:
// These are NOPs
mv.invokeInterface(LOGGER_TYPE, new Method(name, descriptor));
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.