The OutOfSight#getCanonicalName method returns the canonical name of the given class. Specifically, Class#getCanonicalName is cached and returned. As per the javadoc, the result of Class#getCanonicalName may be null for local, anonymous, or hidden classes. This means that the result of OutOfSight#getCanonicalName will also be null for those cases.
Everywhere OutOfSight#getCanonicalName is called, String#startsWith is immediately called on its return value. This leads to an exception whenever the result of OutOfSight#getCanonicalName is null.
Currently, the only use case for OutOfSight#getCanonicalName is to check if a certain class is in the net.minecraft package. Since the cases mentioned above don't occur for any of Minecraft's classes anyways, I've opted to return an empty string whenever Class#getCanonicalName is null.
Relevant issues:
This seems to cause issues for nearly all my mods (#13, #12, https://github.com/SuperMartijn642/WirelessChargers/issues/21) and also for some other mods, such as ElementalCraft (#6).
I keep getting issue reports from this, so hopefully it can be solved either through this PR or through some other solution 🙂
The
OutOfSight#getCanonicalName
method returns the canonical name of the given class. Specifically,Class#getCanonicalName
is cached and returned. As per the javadoc, the result ofClass#getCanonicalName
may benull
for local, anonymous, or hidden classes. This means that the result ofOutOfSight#getCanonicalName
will also be null for those cases.Everywhere
OutOfSight#getCanonicalName
is called,String#startsWith
is immediately called on its return value. This leads to an exception whenever the result ofOutOfSight#getCanonicalName
is null.Currently, the only use case for
OutOfSight#getCanonicalName
is to check if a certain class is in thenet.minecraft
package. Since the cases mentioned above don't occur for any of Minecraft's classes anyways, I've opted to return an empty string wheneverClass#getCanonicalName
is null.Relevant issues: This seems to cause issues for nearly all my mods (#13, #12, https://github.com/SuperMartijn642/WirelessChargers/issues/21) and also for some other mods, such as ElementalCraft (#6). I keep getting issue reports from this, so hopefully it can be solved either through this PR or through some other solution 🙂