Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the name of the Long class in Kotlin JNI?

This Kotlin function

 @JvmStatic external fun registerNativeWindowFromSurface(): Integer;

is found by with return type java/lang/Integer but when I add a Long:

 @JvmStatic external fun registerNativeWindowFromSurface(id: Long): Integer;

I cannot find it with java/lang/Long in the argument.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is Kotlin’s Long a java long or a java/lang/Long? How can I get a Long class?

>Solution :

Integer is not the Kotlin-native integer type. Integer is an alias to java.lang.Integer. Int is the Kotlin integer type.

@JvmStatic external fun registerNativeWindowFromSurface(): Int
@JvmStatic external fun registerNativeWindowFromSurface(id: Long): Int

These will compile to functions with signatures

int registerNativeWindowFromSurface();
int registerNativeWindowFromSurface(long id);

And the class instance for the primitive type int is java.lang.Integer.TYPE. Likewise for long and java.lang.Long.TYPE.

If you actually intend to use Java boxed types, you can reference them with their fully qualified names.

@JvmStatic external fun registerNativeWindowFromSurface(): java.lang.Integer
@JvmStatic external fun registerNativeWindowFromSurface(id: java.lang.Long): java.lang.Integer
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading