jacodb icon indicating copy to clipboard operation
jacodb copied to clipboard

Exception after taking parameters of <init> method of enum class

Open Damtev opened this issue 3 years ago • 0 comments

Consider the following simple enum:

public enum EnumExample {
    SUCCESS, ERROR
}

and the following code for analyzing the parameters of its <init> method:

class EnumTest : BaseTypesTest() {
    @Suppress("UNUSED_VARIABLE")
    @Test
    fun testEnumMethods() {
        runBlocking {
            val enumType = findType<EnumExample>()
            val parameters = enumType.findMethodOrNull("<init>", desc = null)!!.parameters
        }
    }
}

Expected behavior Successful extracting of parameters: String and int.

Actual behavior Throwing of the exception:

Index 0 out of bounds for length 0
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
	at java.base/java.util.Objects.checkIndex(Objects.java:359)
	at java.base/java.util.ArrayList.get(ArrayList.java:427)
	at org.jacodb.impl.types.JcTypedMethodImpl.getParameters(JcTypedMethodImpl.kt:98)
	at org.jacodb.testing.types.EnumTest$testEnumMethods$1.invokeSuspend(EnumTest.kt:13)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at org.jacodb.testing.types.EnumTest.testEnumMethods(EnumTest.kt:11)

Damtev avatar Jul 18 '23 14:07 Damtev