Cube-Space / Yamler

21 stars 33 forks source link

StackOverflowError when a config class with an inner class initializes itself on startup #15

Closed bibo38 closed 8 years ago

bibo38 commented 9 years ago
import java.io.File;

import net.cubespace.Yamler.Config.Config;
import net.cubespace.Yamler.Config.InvalidConfigurationException;

public class TestConfig extends Config
{
    public class InnerConfig extends Config {}

    public InnerConfig inner = new InnerConfig();

    public TestConfig()
    {
        CONFIG_FILE = new File("test.yml");
        try
        {
            init();
        } catch (InvalidConfigurationException e)
        {
            e.printStackTrace();
        }
    }

    public static void main(String args[])
    {
        new TestConfig();
    }
}

This example produces a StackOverflowError with this repeating stacktrace:

    at TestConfig.<init>(TestConfig.java:17)
    at sun.reflect.GeneratedConstructorAccessor7.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:383)
    at net.cubespace.Yamler.Config.Converter.Config.newInstance(Config.java:44)
    at net.cubespace.Yamler.Config.Converter.Config.newInstance(Config.java:41)
    at net.cubespace.Yamler.Config.Converter.Config.fromConfig(Config.java:26)
    at net.cubespace.Yamler.Config.InternalConverter.fromConfig(InternalConverter.java:72)
    at net.cubespace.Yamler.Config.Config.internalLoad(Config.java:166)
    at net.cubespace.Yamler.Config.Config.load(Config.java:141)
    at net.cubespace.Yamler.Config.Config.init(Config.java:113)
    at TestConfig.<init>(TestConfig.java:17)
    at sun.reflect.GeneratedConstructorAccessor7.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:383)