Hi,

when you use JNI functions you always need to repeat "env" a lot:

var
  javaClass: jclass;
  javaObj: jobject;
begin
  //javaClass := ...
  javaObj := env^^.NewObject(env, javaClass)
  env^^.DeleteLocalRef(env, javaObj);
end;

So I thought you could declare type helpers for jobject and jclass,

  TjobjectHelper = type helper for jobject
     procedure DeleteLocalRef;
  end;
  TjclassHelper = type helper for jclass
     procedure NewObject;
  end;

And then just write

var
  javaClass: jclass;
  javaObj: jobject;
begin
  //javaClass := ...
  javaObj := javaClass.NewObject()
  javaObj.DeleteLocalRef;
end;


But this does not work, because fpc thinks jclass and jobject are the same type, so there is only one type helper for both of the types allowed.

Because it is declared as

type
     jobject=pointer;
     jclass=jobject;


What can we do about this?

Bye,

Benito


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to