Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackOverflowError in the preprocessor when generating converters via @CompiledJson #242

Closed
vrasidas-at-b2c2 opened this issue Dec 1, 2022 · 5 comments

Comments

@vrasidas-at-b2c2
Copy link

Hi,

Thank you very much for creating and maintaining this fantastic library!

I am getting a stack overflow error in some cases when using the @CompiledJson annotation.

Error:

...
Caused by: java.lang.StackOverflowError
	at java.base/java.lang.String.valueOf(String.java:2951)
	at java.base/java.lang.StringBuilder.append(StringBuilder.java:168)
	at jdk.compiler/com.sun.tools.javac.util.List.toString(List.java:326)
	at jdk.compiler/com.sun.tools.javac.util.List.toString(List.java:339)
	at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.toString(Type.java:1027)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:179)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:203)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:188)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:203)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:188)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:203)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:188)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:203)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:188)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:203)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:188)
	at com.dslplatform.json.processor.AttributeInfo.createTypeSignature(AttributeInfo.java:203)
...

We are using Java 11 and the minimal repro for this is:

package foo;

import com.dslplatform.json.CompiledJson;

@CompiledJson
public class GenericClass<T> implements Comparable<GenericClass<T>> {

    final T genericField;

    public GenericClass(T genericField) {
        this.genericField = genericField;
    }

    public final T getGenericField() {
        return genericField;
    }

    @Override
    public int compareTo(GenericClass<T> other) {
        return 1;
    }
}

Any help with this would be appreciated!

@zapov
Copy link
Member

zapov commented Dec 2, 2022

Tnx for the report.
I managed to reproduce it.
Will look into how to resolve this.

@zapov
Copy link
Member

zapov commented Dec 28, 2022

I've pushed a fix on master. It seems only bound generics were supported more extensively.
I added basic support for unbounded ones so your case will now work, but there is significant more work to fully wrap the generics support.

@vrasidas-at-b2c2
Copy link
Author

Thank you very much @zapov for looking into this.

Are you planning to release the fix any time soon?

@zapov
Copy link
Member

zapov commented Jan 5, 2023

Yes. Probably this or next week

@zapov
Copy link
Member

zapov commented Jan 7, 2023

v1.10 released

@zapov zapov closed this as completed Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants