oωo (owo-lib)

oωo (owo-lib)

17M Downloads

[owo-config] [bug] Infinite InvocationTargetExceptions

skyeredwood opened this issue · 6 comments

commented

When trying to instantiate my config class I get an infinite chain of InvocationTargetExceptions. This means that the client tries to load for around 20-30 minutes then eventually crashes and produces a crash report with around 1.9 million lines. I can't send it all here considering the crash report file is around 120MB but I'll send a sample:

java.lang.RuntimeException: Could not execute entrypoint stage 'client' due to errors, provided by 'hideawayplus'!
	at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.lambda$invoke0$0(EntrypointUtils.java:51)
	at net.fabricmc.loader.impl.util.ExceptionUtil.gatherExceptions(ExceptionUtil.java:33)
	at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:49)
	at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke(EntrypointUtils.java:35)
	at net.fabricmc.loader.impl.game.minecraft.Hooks.startClient(Hooks.java:53)
	at net.minecraft.class_310.<init>(class_310.java:468)
	at net.minecraft.client.main.Main.main(Main.java:198)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:468)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
Caused by: java.lang.ExceptionInInitializerError
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:467)
	at net.fabricmc.loader.impl.util.DefaultLanguageAdapter.create(DefaultLanguageAdapter.java:50)
	at net.fabricmc.loader.impl.entrypoint.EntrypointStorage$NewEntry.getOrCreate(EntrypointStorage.java:117)
	at net.fabricmc.loader.impl.entrypoint.EntrypointContainerImpl.getEntrypoint(EntrypointContainerImpl.java:53)
	at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47)
	... 7 more
Caused by: java.lang.RuntimeException: Could not instantiate class class plus.hideaway.mod.feat.config.HideawayPlusConfigModel
	at io.wispforest.owo.util.ReflectionUtils.tryInstantiateWithNoArgs(ReflectionUtils.java:30)
	at io.wispforest.owo.config.ConfigWrapper.<init>(ConfigWrapper.java:65)
	at io.wispforest.owo.config.ConfigWrapper.<init>(ConfigWrapper.java:60)
	at plus.hideaway.mod.feat.config.HideawayPlusConfig.<init>(HideawayPlusConfig.java:24)
	at plus.hideaway.mod.feat.config.HideawayPlusConfig.createAndLoad(HideawayPlusConfig.java:32)
	at plus.hideaway.mod.HideawayPlus.<clinit>(HideawayPlus.java:32)
	... 13 more
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at io.wispforest.owo.util.ReflectionUtils.tryInstantiateWithNoArgs(ReflectionUtils.java:28)
	... 18 more
Caused by: java.lang.RuntimeException: Could not instantiate class class plus.hideaway.mod.feat.config.HideawayPlusConfigModel
	at io.wispforest.owo.util.ReflectionUtils.tryInstantiateWithNoArgs(ReflectionUtils.java:30)
	at io.wispforest.owo.config.ConfigWrapper.<init>(ConfigWrapper.java:65)
	at io.wispforest.owo.config.ConfigWrapper.<init>(ConfigWrapper.java:60)
	at plus.hideaway.mod.feat.config.HideawayPlusConfigModel.<init>(HideawayPlusConfigModel.java:15)
	... 24 more

... for 20-30 or so times [the "x more" numbers increase but not at a constant rate]; it then tails off into this for the rest of the file:

Caused by: java.lang.RuntimeException: Could not instantiate class class plus.hideaway.mod.feat.config.HideawayPlusConfigModel
	at io.wispforest.owo.util.ReflectionUtils.tryInstantiateWithNoArgs(ReflectionUtils.java:30)
	at io.wispforest.owo.config.ConfigWrapper.<init>(ConfigWrapper.java:65)
	at io.wispforest.owo.config.ConfigWrapper.<init>(ConfigWrapper.java:60)
	at plus.hideaway.mod.feat.config.HideawayPlusConfigModel.<init>(HideawayPlusConfigModel.java:15)
	at jdk.internal.reflect.GeneratedConstructorAccessor72.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at io.wispforest.owo.util.ReflectionUtils.tryInstantiateWithNoArgs(ReflectionUtils.java:28)
	at io.wispforest.owo.config.ConfigWrapper.<init>(ConfigWrapper.java:65)
	at io.wispforest.owo.config.ConfigWrapper.<init>(ConfigWrapper.java:60)
	at plus.hideaway.mod.feat.config.HideawayPlusConfigModel.<init>(HideawayPlusConfigModel.java:15)
	at jdk.internal.reflect.GeneratedConstructorAccessor72.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

etc. etc. etc.

My config class:

@Sync(Option.SyncMode.NONE)
@Config(name = "hplus-config", wrapperName = "HideawayPlusConfig")
public class HideawayPlusConfigModel extends ConfigWrapper<HideawayPlusConfigModel> {

    public HideawayPlusConfigModel() {
        super(HideawayPlusConfigModel.class);
    }

    public GeneralConfig general = new GeneralConfig();
    public RoomsConfig rooms = new RoomsConfig();
    public SoundConfig sound = new SoundConfig();

    public static class GeneralConfig {
        public boolean pipNav = true;
        public boolean hideCosmetics = true;
        public boolean discordRPC = true;
    }

    public static class RoomsConfig {
        public boolean autoEnableEditor = true;
    }

    public static class SoundConfig {
        public boolean jukebox = true;
        public boolean noAmbientSounds = true;
    }
}

... and it is registered in my mod class as follows:

private static final HideawayPlusConfig CONFIG = HideawayPlusConfig.createAndLoad();

Is this a known issue? I have presumably made a stupid mistake, so apologies if it's a simple issue I've missed.

commented

You do not need to create a constructor for the config class. I think this might be why you are experiencing recursion. Calling the method from the generated wrapper is enough

commented

At one point, I got an error that the constructor wasn't declared. I'll try again though.

Update: yep, same error:
image

commented

Hang on, I may have found the issue. It could be because the constructor I declared was public, not protected. Compiling now to check.

Update: Well, it changed the error. I'm now getting yelled at for not having a zero-args constructor. Despite having a zero-args constructor.

commented

If I try to compile with the constructor removed, I get this error:

error: no suitable constructor found for ConfigWrapper(no arguments)
public class HideawayPlusConfigModel extends ConfigWrapper<HideawayPlusConfigModel> {
       ^
    constructor ConfigWrapper.ConfigWrapper(Class<HideawayPlusConfigModel>) is not applicable
      (actual and formal argument lists differ in length)
    constructor ConfigWrapper.ConfigWrapper(Class<HideawayPlusConfigModel>,Consumer<Builder>) is not applicable
      (actual and formal argument lists differ in length)

Looking back at my build.gradle, this issue could be because I'm using a down-graded version of the library as the latest does not support 1.19.4, however I can't see any significant config-related changes between them. Running the plugin with the latest version (made for 1.20) crashes the game without a crash report.

commented

Well, your general issue is that you config model shouldn't extend ConfigWrapper. That's as the name implies, the job of the wrapper generated by the annotation processor

Why did you even do this in the first place? There's nothing in the docs implying this should be done 🤔
Either way, removing that should resolve your woes
Cheers

commented

Oh my god I'm such an idiot. Buying new glasses tomorrow morning.