Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-12

Problem with JVM and/or native types

9 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sven Barth

Hello together!

I'm currently experimenting with the JVM port and I have a problem when navigating a source file of mine (Lazarus revision 34392). The problematic locations are marked with "// (number)" of which the error is explained below.

=== source begin ===

unit TrainData;
{$namespace org.sven.trainlog}
{$mode objfpc}{$H+}
{$modeswitch unicodestrings}
interface
uses
   AndroidR14;
type
   ETrainLogData = class(JLException) // (1)
   end;
   TTrainLogHelper = class(ADSSqliteOpenHelper) // (1)
   private
     const
       DatabaseVersion = 1;
       DatabaseName = 'trainlog';
       CreateTableTrainFamily = 'create table TrainFamily (' +
                                '  _id integer primary key autoincrement,' +
                                '  name varchar not null' +
                                ')';
       CreateTableTrainType = 'create table TrainType (' +
                              '  _id integer primary key autoincrement,' +
                              '  name varchar not null,' +
                              '  family_id integer not null' +
                              ')';
       CreateTableTrain = 'create table Train (' +
                          '  _id integer primary key autoincrement,' +
                          '  name varchar not null,' +
                          '  cnt integer not null default 0,' +
                          '  type_id integer not null' +
                          ')';
   public
     const
       ColumnTrainFamilyName = 'name';
       ColumnTrainTypeName = 'name';
       ColumnTrainName = 'name';
       ColumnTrainCount = 'cnt';
       TableTrainFamily = 'TrainFamily';
       TableTrainType = 'TrainType';
       TableTrain = 'Train';
   public
     constructor Create(aContext: ACContext); // (2)
     procedure onCreate(aDatabase: ADSSqliteDatabase); override;
     procedure onUpgrade(aDatabase: ADSSqliteDatabase;
       aOldVersion, aNewVersion: jint); override;
     function GetAllTrainFamilies: ADCursor;
     function GetTrainTypesByFamily(aFamily: jlong): ADCursor;
     function GetTrainsByType(aType: jlong): ADCursor;
     procedure AddTrainFamily(aName: String);
     procedure AddTrainType(aName: String);
     procedure AddTrain(aName: String);
     function GetNameOfFamily(aID: jlong): String;
     procedure SetNameOfFamily(aID: jlong; aNewName: String);
     function GetNameOfType(aID: jlong): String;
     procedure SetNameOfType(aID: jlong; aNewName: String);
     function GetNameOfTrain(aID: jlong): String;
     procedure SetNameOfTrain(aID: jlong; aNewName: String);
     function GetCountOfTrain(aID: jlong): jint;
     procedure SetCountOfTrain(aID: jlong; aNewCount: jint);
     procedure DeleteTrainFamily(aID: jlong);
     procedure DeleteTrainType(aID: jlong);
     procedure DeleteTrain(aID: jlong);
   end;
implementation

...

end.

=== source end ===

(1) here the message in the stdout when doing Ctrl+Click is: ### TCodeToolManager.HandleException: ": erwartet aber 'java.lang' gefunden" at Line=11763 Col=35 in
"/mnt/data/source/fpc/fpc-jvm/rtl/android/jvm/androidr14.pas" (2) here the message in the stdout when doing Ctrl+Shift+Down is: ### TCodeToolManager.HandleException: "; erwartet aber const gefunden" at Line=37 Col=5 in "/home/sven/projects/android/trainlog/traindata.pas"

Regards,
Sven

Reply by email

Sven Barth
to Sven Barth
Sven Barth wrote 7 lines
Hello together! I'm currently experimenting with the JVM port and I have a problem when navigating a source file of mine (Lazarus revision 34392). The problematic locations are marked with "// (number)" of which the error is explained below.

The subject should read "Problem with JVM and/or nested types" -.-

Regards,
Sven

Reply by email

Mattias Gaertner
to Sven Barth: Hello together! I'm currently experimenting with the JVM port and I have a problem when…
Show quoted text 15 lines
Hello together! I'm currently experimenting with the JVM port and I have a problem when navigating a source file of mine (Lazarus revision 34392). The problematic locations are marked with "// (number)" of which the error is explained below. [...] (1) here the message in the stdout when doing Ctrl+Click is: ### TCodeToolManager.HandleException: ": erwartet aber 'java.lang' gefunden" at Line=11763 Col=35 in "/mnt/data/source/fpc/fpc-jvm/rtl/android/jvm/androidr14.pas" (2) here the message in the stdout when doing Ctrl+Shift+Down is: ### TCodeToolManager.HandleException: "; erwartet aber const gefunden" at Line=37 Col=5 in "/home/sven/projects/android/trainlog/traindata.pas"

Fixed in trunk.

Mattias

Reply by email

Sven Barth
to Mattias Gaertner
Mattias Gaertner wrote 20 lines
On Sun, 25 Dec 2011 14:26:02 +0100 Sven Barth wrote: > Hello together! > > I'm currently experimenting with the JVM port and I have a problem when > navigating a source file of mine (Lazarus revision 34392). The > problematic locations are marked with "// (number)" of which the error > is explained below. > [...] > (1) here the message in the stdout when doing Ctrl+Click is: > ### TCodeToolManager.HandleException: ": erwartet aber 'java.lang' > gefunden" at Line=11763 Col=35 in > "/mnt/data/source/fpc/fpc-jvm/rtl/android/jvm/androidr14.pas" > (2) here the message in the stdout when doing Ctrl+Shift+Down is: > ### TCodeToolManager.HandleException: "; erwartet aber const gefunden" > at Line=37 Col=5 in "/home/sven/projects/android/trainlog/traindata.pas" Fixed in trunk.

It works indeed better (number (2) is solved and some Ctrl+Click into import units work), but I'm still getting errors.

1.) I have seen that you check for the define "JVM". Shouldn't this be "CPUJVM" instead? (just asking)

2.) If I e.g. click on the $include file at the bottom of the androidr14 unit (or any other converted unit that contains a "external" formal class declaration) I still get the error message mentioned at (1) in my old mail. The error location always appears at the first "external '...' name '...'" location. [Other actions cause this error as well, not only clicking on the include file name]

Regards,
Sven

Reply by email

Mattias Gaertner
to Sven Barth
Show quoted text 27 lines
On 28.12.2011 23:56, Mattias Gaertner wrote: > On Sun, 25 Dec 2011 14:26:02 +0100 > Sven Barth wrote: > >> Hello together! >> >> I'm currently experimenting with the JVM port and I have a problem when >> navigating a source file of mine (Lazarus revision 34392). The >> problematic locations are marked with "// (number)" of which the error >> is explained below. >> [...] > >> (1) here the message in the stdout when doing Ctrl+Click is: >> ### TCodeToolManager.HandleException: ": erwartet aber 'java.lang' >> gefunden" at Line=11763 Col=35 in >> "/mnt/data/source/fpc/fpc-jvm/rtl/android/jvm/androidr14.pas" >> (2) here the message in the stdout when doing Ctrl+Shift+Down is: >> ### TCodeToolManager.HandleException: "; erwartet aber const gefunden" >> at Line=37 Col=5 in "/home/sven/projects/android/trainlog/traindata.pas" > > Fixed in trunk. It works indeed better (number (2) is solved and some Ctrl+Click into import units work), but I'm still getting errors. 1.) I have seen that you check for the define "JVM". Shouldn't this be "CPUJVM" instead? (just asking)

I changed them to CPUJVM.

Show quoted text 6 lines
2.) If I e.g. click on the $include file at the bottom of the androidr14 unit (or any other converted unit that contains a "external" formal class declaration) I still get the error message mentioned at (1) in my old mail. The error location always appears at the first "external '...' name '...'" location. [Other actions cause this error as well, not only clicking on the include file name]

I didn't have a jvm fpc yet. I simply played in the IDE. The above change should be sufficient.

Mattias

Reply by email

Sven Barth
to Mattias Gaertner
Mattias Gaertner wrote 6 lines
On Thu, 29 Dec 2011 00:09:56 +0100 Sven Barth wrote: > 1.) I have seen that you check for the define "JVM". Shouldn't this be > "CPUJVM" instead? (just asking) I changed them to CPUJVM.

That made a big improvement, thanks :)

Show quoted text 9 lines
> 2.) If I e.g. click on the $include file at the bottom of the androidr14 > unit (or any other converted unit that contains a "external" formal > class declaration) I still get the error message mentioned at (1) in my > old mail. The error location always appears at the first "external '...' > name '...'" location. [Other actions cause this error as well, not only > clicking on the include file name] I didn't have a jvm fpc yet. I simply played in the IDE. The above change should be sufficient.

The error with the first "external" class or interface declaration now has gone away, but I have found a new problem:

Ctrl+Clicking on an identifier that is declared in the AndroidR14 unit gives the following error:

### TCodeToolManager.HandleException: "Bezeichner nicht gefunden: TObject" at Line=2 Col=6 in
"/mnt/data/source/fpc/fpc-jvm/rtl/android/jvm/androidr14.pas"

But there is no "TObject" at that position.

Also if I do this in a Java project instead of an Android one with an identifier that is declared in jdk15.pp then I get the following error:

### TCodeToolManager.HandleException: "Bezeichner nicht gefunden: TObject" at Line=17 Col=6 in
"/mnt/data/source/fpc/fpc-jvm/rtl/java/system.pp"

Using an identifier that is declared in the system unit (JLObject) results in the same error.

Also a strange behavior: consider the following code:

=== example begin ===

   THelloWorld = class(OBPJJavaPlugin)
   private
     fLog: JULLogger;
     fFoo: OBPJJavaPlugin;
   public
     constructor Create;
     procedure onEnable;
     procedure onDisable;
     procedure onLoad; override;
   end;

=== example end ===

I can successfully Ctrl+Click the identifier inside the "class(...)", but I can not do that for the type of fFoo (see above mentioned error). I can also successfully do code completion in the class parent, but not for fFoo (if I do that for the type of fFoo then the code completion jumps to the above mentioned error location in system.pp, which is the "unit system;" line)

Nevertheless working with the JVM port is much easier now. Thank you very much :)

Regards,
Sven

Reply by email

Mattias Gaertner
to Sven Barth
Show quoted text 12 lines
[...] The error with the first "external" class or interface declaration now has gone away, but I have found a new problem: Ctrl+Clicking on an identifier that is declared in the AndroidR14 unit gives the following error: ### TCodeToolManager.HandleException: "Bezeichner nicht gefunden: TObject" at Line=2 Col=6 in "/mnt/data/source/fpc/fpc-jvm/rtl/android/jvm/androidr14.pas" But there is no "TObject" at that position.

"TObject" is the default ancestor of a class. It does not need to be written in code.
It works here.
Clicking on what identifier?

Show quoted text 9 lines
Also if I do this in a Java project instead of an Android one with an identifier that is declared in jdk15.pp then I get the following error: ### TCodeToolManager.HandleException: "Bezeichner nicht gefunden: TObject" at Line=17 Col=6 in "/mnt/data/source/fpc/fpc-jvm/rtl/java/system.pp" Using an identifier that is declared in the system unit (JLObject) results in the same error.

It works here. But I don't have a working jvm compiler, so maybe it has some special defines.

Show quoted text 5 lines
Also a strange behavior: consider the following code: === example begin === THelloWorld = class(OBPJJavaPlugin)

Where is OBPJJavaPlugin defined?

Show quoted text 21 lines
private fLog: JULLogger; fFoo: OBPJJavaPlugin; public constructor Create; procedure onEnable; procedure onDisable; procedure onLoad; override; end; === example end === I can successfully Ctrl+Click the identifier inside the "class(...)", but I can not do that for the type of fFoo (see above mentioned error). I can also successfully do code completion in the class parent, but not for fFoo (if I do that for the type of fFoo then the code completion jumps to the above mentioned error location in system.pp, which is the "unit system;" line) Nevertheless working with the JVM port is much easier now. Thank you very much :)

Mattias

Reply by email

Sven Barth
to Mattias Gaertner
Mattias Gaertner wrote 12 lines
On Thu, 29 Dec 2011 13:23:08 +0100 Sven Barth wrote: > [...] > ### TCodeToolManager.HandleException: "Bezeichner nicht gefunden: > TObject" at Line=2 Col=6 in > "/mnt/data/source/fpc/fpc-jvm/rtl/android/jvm/androidr14.pas" > > But there is no "TObject" at that position. It seems JLObject is the base class for target jvm. I added that information to codetools.

And that seems to have solved all remaining problems. Now Lazarus is usable for FPC JVM development. Thank you very much Matthias :)

Regards,
Sven

Reply by email