<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body smarttemplateinserted="true" text="#000000" bgcolor="#FFFFFF">
<div id="smartTemplate4-template">Hi,<br>
<br>
when you use JNI functions you always need to repeat "env" a lot:<br>
<br>
var <br>
javaClass: jclass;<br>
javaObj: jobject;<br>
begin<br>
//javaClass := ...<br>
javaObj := env^^.NewObject(env, javaClass)<br>
env^^.DeleteLocalRef(env, javaObj);<br>
end;<br>
<br>
So I thought you could declare type helpers for jobject and
jclass, <br>
<br>
TjobjectHelper = type helper for jobject<br>
procedure DeleteLocalRef;<br>
end;<br>
TjclassHelper = type helper for jclass<br>
procedure NewObject;<br>
end;<br>
<br>
And then just write<br>
<br>
var <br>
javaClass: jclass;<br>
javaObj: jobject;<br>
begin<br>
//javaClass := ...<br>
javaObj := javaClass.NewObject()<br>
javaObj.DeleteLocalRef;<br>
end;<br>
<br>
<br>
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.<br>
<br>
Because it is declared as<br>
<br>
type<br>
jobject=pointer;<br>
jclass=jobject;<br>
<br>
<br>
What can we do about this?<br>
<br>
Bye,<br>
<p>Benito </p>
</div>
<br>
</body>
</html>