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

java.lang.StackOverflowError due graph generation #255

Open
SergoSmyk opened this issue Oct 2, 2023 · 1 comment
Open

java.lang.StackOverflowError due graph generation #255

SergoSmyk opened this issue Oct 2, 2023 · 1 comment

Comments

@SergoSmyk
Copy link

The DI graph generation throws StackOverflowError when using specific generics combination.

Library version: 0.4.0-alpha05

Repro steps or stacktrace:

To repro we need to use @motif.Object inheritance functionality. The generic type should have bounds where specified generic type is the class itself.

The type which we want to provide

interface Foo<ItSelf> {
 fun foo(): IntSelf
}

Any class which implements Foo:

class SomeClass : Foo<SomeClass> {
   override fun foo(): SomeClass
}

The interface which will be implemented by @motif.Object (motif inheritance functionality)

interface ObjectComponent<T : Foo<T>> {
  fun create(): T
}

@motif.Object declaration

@motif.Object
abstract class Objects: ObjectComponent<SomeClass>

Stacktrace:

exception: java.lang.StackOverflowError
	at com.squareup.kotlinpoet.UtilKt.toImmutableList(Util.kt:31)
	at com.squareup.kotlinpoet.TypeName.<init>(TypeName.kt:70)
	at com.squareup.kotlinpoet.TypeName.<init>(TypeName.kt)
	at com.squareup.kotlinpoet.ClassName.<init>(ClassName.kt:34)
	at com.squareup.kotlinpoet.ClassName.<init>(ClassName.kt:29)
	at com.squareup.kotlinpoet.ClassName.<init>(ClassName.kt:55)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKClassName(j2kInterop.kt:66)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKParameterizedTypeName(j2kInterop.kt:76)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:103)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeVariableName(j2kInterop.kt:85)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:104)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKWildcardTypeName(j2kInterop.kt:95)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:105)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKParameterizedTypeName(j2kInterop.kt:77)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:103)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeVariableName(j2kInterop.kt:85)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:104)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKWildcardTypeName(j2kInterop.kt:95)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:105)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKParameterizedTypeName(j2kInterop.kt:77)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:103)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeVariableName(j2kInterop.kt:85)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:104)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKWildcardTypeName(j2kInterop.kt:95)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:105)
	...
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:105)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKParameterizedTypeName(j2kInterop.kt:77)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:103)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeVariableName(j2kInterop.kt:85)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:104)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKWildcardTypeName(j2kInterop.kt:95)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:105)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKParameterizedTypeName(j2kInterop.kt:77)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeName(j2kInterop.kt:103)
	at com.squareup.kotlinpoet.javapoet.J2kInteropKt.toKTypeVariableName(j2kInterop.kt:85)

    When running <kotlinc>.
davissuber added a commit to davissuber/motif that referenced this issue Oct 27, 2023
This avoids the infinite poetry in
uber#255
davissuber added a commit to davissuber/motif that referenced this issue Oct 27, 2023
This avoids the infinite poetry in
uber#255
muandrew pushed a commit that referenced this issue Nov 3, 2023
This avoids the infinite poetry in
#255
@psteiger
Copy link

Possibly related to #261 ?

crystalninja5 added a commit to crystalninja5/effective-octo-journey that referenced this issue Aug 11, 2024
This avoids the infinite poetry in
uber/motif#255
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