jacodb
jacodb copied to clipboard
Wrong type for the first parameter of the <init> method in enum with field
Consider the following simple enum:
public enum EnumWithFieldExample {
OK(200), NOT_FOUND(404);
EnumWithFieldExample(int statusCode) {
this.statusCode = statusCode;
}
final int statusCode;
}
and the following code for analyzing the parameters of its <init> method:
val enumType = cp.findTypeOrNull<EnumWithFieldExample>() as JcClassType
val parameters = enumType.findMethodOrNull("<init>", desc = null)!!.parameters
assertEquals("java.lang.String", parameters.first().type.typeName)
Expected behavior
Successful extracting of the first parameter String.
Actual behavior Throwing of the exception:
expected: <java.lang.String> but was: <int>
Expected :java.lang.String
Actual :int
Additional context
All 3 extracted parameters have the same type int.