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

toString() exception when using generated functional interfaces #1149

Open
manikoske opened this issue Feb 6, 2025 · 1 comment
Open

toString() exception when using generated functional interfaces #1149

manikoske opened this issue Feb 6, 2025 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@manikoske
Copy link

manikoske commented Feb 6, 2025

Describe the bug

When toString() function is called on certain data class instances generated by Fixture Monkey an exception is thrown. I guess the problem might be located in FunctionalInterfaceArbitraryIntrospector.

Your environment

  • version of Fixture Monkey - 1.1.8
  • version of Java/Kotlin - 1.9.25

Steps to reproduce

    data class MyData2(
        val roll : () -> Int
    )

    @Test
    @Seed(30)
    fun test() {
        val sampled = FixtureMonkeyBuilder()
            .plugin(KotlinPlugin())
            .build()
            .giveMeKotlinBuilder<MyData2>()
            .sample()

        println("sampled: $sampled")
    }

Expected behaviour

I would expect a proper toString return value

Actual behaviour

java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String (java.lang.Integer and java.lang.String are in module java.base of loader 'bootstrap')

	at jdk.proxy2/jdk.proxy2.$Proxy13.toString(Unknown Source)
	at java.base/java.lang.StringConcatHelper.stringOf(StringConcatHelper.java:467)
	at com.manikoske.guild.encounter.CharacterStateTest$MyData2.toString(CharacterStateTest.kt)
	at java.base/java.lang.StringConcatHelper.stringOf(StringConcatHelper.java:467)
	at java.base/java.lang.StringConcatHelper.simpleConcat(StringConcatHelper.java:422)
	at com.manikoske.guild.encounter.CharacterStateTest.test(CharacterStateTest.kt:32)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

@manikoske manikoske added the bug Something isn't working label Feb 6, 2025
@seongahjo seongahjo added this to the 1.1.10 milestone Feb 8, 2025
@seongahjo
Copy link
Contributor

@manikoske
Hi, thank you for reporting an issue.

It'll be resolved in 1.1.10.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants