[fpc-pascal] ppcjvm issues

Jon Foster jon-lists at jfpossibilities.com
Sat Jan 7 03:12:33 CET 2017


I've been working on building an app for Android using the FPC's JVM 
target. I'm using fpc 3.0.0. I've run into a couple of things that I'm not 
sure if they're bugs or I just don't know what I'm doing. I was using fpc 
to avoid having to learn Java and have discovered that's not entirely 
possible. :-/

The first issue I ran into is this:

procedure Cppp1Activity.onResume;
begin
     inherited onResume;
     with AAAlertDialog.InnerBuilder(self) do begin
         setTitle(R.strings.app_name);
     end;
end;

Cppp1Activity is a descendant of AAActivity. I'm overriding the onResume 
method. The problem I ran into was with the AAAlertDialog.InnerBuilder 
class. I can create an object of that class without incident. However if I 
try to call any of the methods (tried several) I get a "Class Cast" 
exception reported in the Android log and the app goes *poof*. I also tried 
just chaining the call like 
"AAAlertDialog.InnerBuilder(self).setTitle(R.strings.app_name);", and I 
tried this in the "Activity.onCreate" method with the same result. And yes 
"R.strings.app_name" points to an actual resource and I generated a 
"resources.pas" with the "R" class fresh for this test.

The second issue I ran into:

function f(x, y: integer): float;
begin
     result:=float(dy)/float(dx)
end;

When attempting to compile this it tells me that "float" is undefined. I 
think I'm missing something here. "float" is the native Java name for their 
base floating point type and its a valid type for FPC. If I use "single" 
instead it will compile. Seems odd.

THX - Jon

-- 
Sent from my Debian Linux workstation -- http://www.debian.org/intro/about

Jon Foster
JF Possibilities, Inc.
jon at jfpossibilities.com
541-410-2760
Making computers work for you!




More information about the fpc-pascal mailing list