java.lang.VerifyError with a nillable enum


(Jon Nermut) #1

Came across this in passing:
consoleapplication222.zip (200.3 KB)

The following code in a Cooper command line project:

print("The magic happens here.")

enum MyStringEnum: String
{
    case case1
    case case2
}

class MySimpleJsonClassWithStringEnum
{
    var theEnum: MyStringEnum? = nil
}

let o1 = MySimpleJsonClassWithStringEnum()
o1.theEnum = .case2
print(o1)

Produces this at runtime:
!> Fatal exception of type java.lang.VerifyError on thread 0001 ()
!> Message: java.lang.VerifyError: (class: consoleapplication222/__Global, method: main$ signature: ([Ljava/lang/String;)I) Incompatible argument to function
Error: A JNI error has occurred, please check your installation and try again
Exception in thread “main” java.lang.VerifyError: (class: consoleapplication222/__Global, method: main$ signature: ([Ljava/lang/String;)I) Incompatible argument to function
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)

I got to this trying to reproduce a test case project for the following in my Android project with similar classes, they must be related:

    java.lang.NullPointerException: Attempt to write to field 'int interoputil.MyStringEnum.fValue' on a null object reference
    at interoputil.MyStringEnum.case2(Unknown Source:3)

(RemObjects) #2

Thanks, logged as bugs://80899


(RemObjects) #3

bugs://80899 got closed with status fixed.