I'm creating a wrapper for a C++ library in Kotlin, using JNI. In order to have a property implemented in the C++ library, I need to mark a property's getter and setter as external to create getX and setX methods marked as native, as indicated in the Kotlin documentation.
While this works as expected, this also generates a backing field for the property, which is not useful in my case because the value is located only in the native side.
For instance, I have the following class, containing an external property:
class Something {
var name: String
external get
external set
}
The generated bytecode decompiled in Java (with @Metadata annotations stripped) by the "Kotlin Bytecode" tool in IntellIJ is as follows:
public final class Something {
@NotNull
private String name;
@NotNull
public final native String getName();
public final native void setName(@NotNull String var1);
}
As you can see, an unwanted name field is present. Is there a way to get rid of this?