Minecraftforge: Intelij support too hard

Created on 10 Dec 2016  路  10Comments  路  Source: MinecraftForge/MinecraftForge

Intelij configuration too hard. Newer, 2016.3 can't run despite of true configurations.

Error when run Forge Client

Exception in thread "Client thread" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [Forge_main/:?]
    at GradleStart.main(GradleStart.java:26) [Forge_main/:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112]
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:?]
Caused by: java.lang.IllegalStateException: @Nonnull method net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.getObject must not return null
    at net.minecraft.util.registry.RegistryNamespacedDefaultedByKey.$$$reportNull$$$0(RegistryNamespacedDefaultedByKey.java) ~[RegistryNamespacedDefaultedByKey.class:?]
    at net.minecraft.util.registry.RegistryNamespacedDefaultedByKey.getObject(RegistryNamespacedDefaultedByKey.java:50) ~[RegistryNamespacedDefaultedByKey.class:?]
    at net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry.getRaw(FMLControlledNamespacedRegistry.java:319) ~[FMLControlledNamespacedRegistry.class:?]
    at net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry.add(FMLControlledNamespacedRegistry.java:451) ~[FMLControlledNamespacedRegistry.class:?]
    at net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry.register(FMLControlledNamespacedRegistry.java:215) ~[FMLControlledNamespacedRegistry.class:?]
    at net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry.register(FMLControlledNamespacedRegistry.java:49) ~[FMLControlledNamespacedRegistry.class:?]
    at net.minecraft.util.SoundEvent.registerSound(SoundEvent.java:524) ~[SoundEvent.class:?]
    at net.minecraft.util.SoundEvent.registerSounds(SoundEvent.java:26) ~[SoundEvent.class:?]
    at net.minecraft.init.Bootstrap.register(Bootstrap.java:490) ~[Bootstrap.class:?]
    at net.minecraft.client.Minecraft.<init>(Minecraft.java:340) ~[Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) ~[Main.class:?]
    ... 17 more
[18:00:58] [Client thread/INFO]: [STDERR]: java.lang.reflect.InvocationTargetException
[18:00:58] [Client thread/INFO]: [STDERR]:  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[18:00:58] [Client thread/INFO]: [STDERR]:  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[18:00:58] [Client thread/INFO]: [STDERR]:  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[18:00:58] [Client thread/INFO]: [STDERR]:  at java.lang.reflect.Method.invoke(Method.java:498)
[18:00:58] [Client thread/INFO]: [STDERR]:  at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
[18:00:58] [Client thread/INFO]: [STDERR]:  at GradleStart.main(GradleStart.java:26)
[18:00:58] [Client thread/INFO]: [STDERR]:  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[18:00:58] [Client thread/INFO]: [STDERR]:  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[18:00:58] [Client thread/INFO]: [STDERR]:  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[18:00:58] [Client thread/INFO]: [STDERR]:  at java.lang.reflect.Method.invoke(Method.java:498)
[18:00:58] [Client thread/INFO]: [STDERR]:  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
[18:00:58] [Client thread/INFO]: [STDERR]: Caused by: net.minecraftforge.fml.relauncher.FMLSecurityManager$ExitTrappedException
[18:00:58] [Client thread/INFO]: [STDERR]:  at net.minecraftforge.fml.relauncher.FMLSecurityManager.checkPermission(FMLSecurityManager.java:49)
[18:00:58] [Client thread/INFO]: [STDERR]:  at java.lang.SecurityManager.checkExit(SecurityManager.java:761)
[18:00:58] [Client thread/INFO]: [STDERR]:  at java.lang.Runtime.exit(Runtime.java:107)
[18:00:58] [Client thread/INFO]: [STDERR]:  at java.lang.System.exit(System.java:971)
[18:00:58] [Client thread/INFO]: [STDERR]:  at net.minecraft.launchwrapper.Launch.launch(Launch.java:138)
[18:00:58] [Client thread/INFO]: [STDERR]:  at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
[18:00:58] [Client thread/INFO]: [STDERR]:  ... 11 more

Process finished with exit code 1

Most helpful comment

This is an issue in 1.11 due to nonnull annotation checks added by IntelliJ. The correct fix is to prevent nulls returned from a Nonnull method, but meanwhile you can work around this issue by going to Settings -> Build -> Compiler -> "Add runtime assertions for not-null[...]" and turning it off for the forge environment.

All 10 comments

I noticed this behavior with 2016.3 too. Use 2016.2 if you do forge things.

so it works with an older version? might be worth examining the function it mentions (net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.getObject) it is possible that it is picking up on a 'return null' in the function while it's notnull and thus crashing cause it violoates its contract (even if it wouldn't return null normally but there still is one present)

i know there have been quite some improvements to intellij recently to aimed at making finding null bugs and such easier, this might be one of them

Okay, I test it again...

This is an issue in 1.11 due to nonnull annotation checks added by IntelliJ. The correct fix is to prevent nulls returned from a Nonnull method, but meanwhile you can work around this issue by going to Settings -> Build -> Compiler -> "Add runtime assertions for not-null[...]" and turning it off for the forge environment.

Problem fixed with this option. Also, I tested both versions of Intelij and
reconfigured Forge.
Need search Optifine source code. After, I can implement nVidia OptiX to Minecraft.

The problem isn't fixed. Don't be mistaken: the problem is returning null from a nonnull method. The option just makes IntelliJ not care that there's a problem.

This is not fixed. Why closing? @mezz

The only way to fix this is to fix every @Nonnull annotation in Minecraft. This is not something Forge is in a good position to do, it would require too many patches.
We can and should fix the annotations in Forge classes, but that's not where this specific error is coming from.
Turning the strict check off, like gigaherz showed, is the only solution as long as Minecraft has imperfect annotations.

@gigaherz as you seem to know more about it: do you know if it's possible to only dissable it for the minecraft code? if that's possible that would be extremely usefull as then someone with that intellij version could easely go through the entirety of forge with it to find the broken annotations

Not as far as I can see, It's just a project-wide toggle.

Was this page helpful?
0 / 5 - 0 ratings