I'm currently working on an implementation of a jar file in delphi via the JNI. Here's my problem: I'm unable to create an object via the java implemented builder.
Here's the java code:
public class MyObject {
// .. code
public static class Builder {
protected MyObject instance;
public Builder() {
this.instance = new MyObject
}
public Builder withString(String s) {
instance.string = s;
return this;
}
public MyObject Build() {
// check object values
return instance;
}
}
}
As you can see, the builder class is a subclass of the object.
In delphi, I use this code to access the builder:
jClass := JNIEnv.FindClass('package/MyObject$Builder');
jMid := JNIEnv.GetMethodID(jClass, '<init>', '()V');
jObj := JNIEnv.NewObjectV(jClass, jMid, '');
_jMid := JNIEnv.GetMethodID(jClass, 'withString', '(Ljava/lang/String;)package/MyObject$Builder;');
_jObj := JNIEnv.CallObjectMethodV(jObj, _jMid, 'string');
But I can't seem to get this working, I always get an access violation.
Thanks in advance!