NullPointerException log spam on startup in development environment
TheSilkMiner opened this issue ยท 1 comments
Issue Description:
When CraftTweaker is loading the default ZenScript symbols during Minecraft startup, the game identifies some duplicate classes (such as PlayerRespawnEvent
, IEntityItem
etc.).
While this is not an issue per se, because the duplicate entries are successfully logged in crafttweaker.log
, this causes a java.lang.NullPointerException
being logged in the console for every duplicate symbol identified. This does not impact gameplay, but it reduces the possibility of checking the console for possible (legitimate) error outputs.
What happens:
When the game loads up and reaches Pre-Initialization stage, CraftTweaker starts registering all the classes annotated with @ZenRegister
with a call to CraftTweakerAPI.registerClass
. The registration method then attempts to put in the root SymbolPackage
the given IZenSymbol
. When doing so, the package is checked for an already existing symbol and if so happens, an error is logged.
The default implementation used to log the error is given by the class CrtStoringErrorLogger
, which assumes that the given ZenPosition
is not null. In fact, it attempts to call various methods on the instance given.
The issue relies on the fact that, when registering a symbol provided by the system, the ZenPosition
given is null, which causes a NullPointerException
to be thrown. Note that this exception does not crash the game, but it simply gets caught and the stacktrace printed to STDERR
.
The superclass CrTErrorLogger
correctly handles this case.
What you expected to happen:
The game should have logged the error in the crafttweaker.log
file, maybe in the console, but not throw an exception.
Script used:
No script has been used: this occurs with an untouched "instance" of CraftTweaker in a development environment.
crafttweaker.log file:
Affected Versions:
- Minecraft: 1.12.2
- Forge: 1.12.2-14.23.5.2838
- CraftTweaker: 1.12-4.1.19.548, obtained through Gradle
- Using a server: No
Additional notes:
This issue has been observed in a development environment, with both the API and the mod itself being imported through Gradle. It has not been tested in a non-dev environment.
The relevant section of the build.gradle
is available on Gist.
Most recent log file where the issue was present:
your build.gradle is pulling in the api when it is already provided by the actual Jar file, so you have duplicate classes, just remove this line https://gist.github.com/TheSilkMiner/3077fe610817f8f1557eac4de4dd4fdf#file-build-gradle-L49