[fpc-devel] FPC-JVM: Status report on Android
Sven Barth
pascaldragon at googlemail.com
Sat Aug 27 17:43:03 CEST 2011
Hello together!
As you might have noticed I'm currently trying to get Pascal code
working on Android using the new JVM backend.
So far I've converted the Android API in the android namespace to Pascal
and managed to compile, convert (to DEX) and package a full Pascal
HelloWorld application, but when started on the emulator I get the
message that the application stopped working (log will be shown further
down).
After some non successful tries I decided to use the Java HelloWorld
application outlined on
http://developer.android.com/resources/tutorials/hello-world.html#ui (I
used this as an example for the full FPC one as well) and replace the
string constant by a call to a FPC class.
So I added a TTestClass derived from TObject with a method getText that
returns a UnicodeString. After providing the RTL class files to the
build system I invoked "ant debug" and were greeted with error messages
when it tried to convert TObject.class and tmethod.class to Dalvik code
(log will be posted below).
To be sure I decided to replace TObject by JLObject, I built
successfully and sent the package to the emulator. And look at the
screenshot, I got presented by my choosen text :D
So it is definitely possible to run FPC JVM code on Dalvik, it's just
not working perfectly currently...
Here are the logs:
When running the full FPC application (or "activity"):
=== begin run log ===
I/ActivityManager( 59): Start proc org.freepascal.helloworld for
activity org.freepascal.helloworld/.THelloWorld: pid=601 uid=10035
gids={1015}
D/dalvikvm( 601): newInstance failed: p0 i0 [0 a1
D/AndroidRuntime( 601): Shutting down VM
W/dalvikvm( 601): threadid=1: thread exiting with uncaught exception
(group=0x40015560)
E/AndroidRuntime( 601): FATAL EXCEPTION: main
E/AndroidRuntime( 601): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{org.freepascal.helloworld/org.freepascal.helloworld.THelloWorld}:
java.lang.InstantiationException: org.freepascal.helloworld.THelloWorld
E/AndroidRuntime( 601): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
E/AndroidRuntime( 601): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime( 601): at
android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 601): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 601): at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 601): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 601): at
android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 601): at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 601): at
java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 601): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 601): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 601): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 601): Caused by: java.lang.InstantiationException:
org.freepascal.helloworld.THelloWorld
E/AndroidRuntime( 601): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime( 601): at java.lang.Class.newInstance(Class.java:1409)
E/AndroidRuntime( 601): at
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 601): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
E/AndroidRuntime( 601): ... 11 more
W/ActivityManager( 59): Force finishing activity
org.freepascal.helloworld/.THelloWorld
W/ActivityManager( 59): Activity pause timeout for
HistoryRecord{406869e8 org.freepascal.helloworld/.THelloWorld}
=== end run log ===
And here the log entry when building the Java based example with a class
that derives from TObject:
=== begin build log ===
[echo] Converting compiled files and external libraries into
/home/sven/projects/android/helloandroid/bin/classes.dex...
[apply]
[apply] UNEXPECTED TOP-LEVEL EXCEPTION:
[apply] com.android.dx.cf.code.SimException: local variable type
mismatch: attempt to set or access a value of type java.lang.Object
using a local variable of type boolean. This is symptomatic of .class
transformation tools that ignore local variable information.
[apply] at
com.android.dx.cf.code.BaseMachine.throwLocalMismatch(BaseMachine.java:550)
[apply] at
com.android.dx.cf.code.Simulator$SimVisitor.visitLocal(Simulator.java:570)
[apply] at
com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:481)
[apply] at
com.android.dx.cf.code.Simulator.simulate(Simulator.java:99)
[apply] at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:684)
[apply] at com.android.dx.cf.code.Ropper.doit(Ropper.java:639)
[apply] at com.android.dx.cf.code.Ropper.convert(Ropper.java:252)
[apply] at
com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:252)
[apply] at
com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:131)
[apply] at
com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:85)
[apply] at
com.android.dx.command.dexer.Main.processClass(Main.java:369)
[apply] at
com.android.dx.command.dexer.Main.processFileBytes(Main.java:346)
[apply] at com.android.dx.command.dexer.Main.access$400(Main.java:59)
[apply] at
com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:294)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:134)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[apply] at com.android.dx.command.dexer.Main.processOne(Main.java:313)
[apply] at
com.android.dx.command.dexer.Main.processAllFiles(Main.java:233)
[apply] at com.android.dx.command.dexer.Main.run(Main.java:185)
[apply] at com.android.dx.command.dexer.Main.main(Main.java:166)
[apply] at com.android.dx.command.Main.main(Main.java:90)
[apply] ...at bytecode offset 00000005
[apply] locals[0000]: Lorg/freepascal/rtl/FpcBitSet;
[apply] locals[0001]: Lorg/freepascal/rtl/FpcBitSet;
[apply] locals[0002]: <invalid>
[apply] locals[0003]: <invalid>
[apply] locals[0004]: <invalid>
[apply] locals[0005]: <invalid>
[apply] locals[0006]: <invalid>
[apply] locals[0007]: <invalid>
[apply] stack[top0]: Ljava/lang/Object;
[apply] ...while working on block 0005
[apply] ...while working on method
containsAll:(Lorg/freepascal/rtl/FpcBitSet;)Z
[apply] ...while processing containsAll
(Lorg/freepascal/rtl/FpcBitSet;)Z
[apply] ...while processing org/freepascal/rtl/FpcBitSet.class
[apply]
[apply]
[apply] trouble processing:
[apply] class name (org/freepascal/rtl/TMethod) does not match path
(org/freepascal/rtl/tmethod.class)
[apply] ...while parsing org/freepascal/rtl/tmethod.class
[apply] ...while processing org/freepascal/rtl/tmethod.class
[apply]
[apply] UNEXPECTED TOP-LEVEL EXCEPTION:
[apply] com.android.dx.cf.code.SimException: local variable type
mismatch: attempt to set or access a value of type java.lang.Object
using a local variable of type boolean. This is symptomatic of .class
transformation tools that ignore local variable information.
[apply] at
com.android.dx.cf.code.BaseMachine.throwLocalMismatch(BaseMachine.java:550)
[apply] at
com.android.dx.cf.code.Simulator$SimVisitor.visitLocal(Simulator.java:570)
[apply] at
com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:481)
[apply] at
com.android.dx.cf.code.Simulator.simulate(Simulator.java:99)
[apply] at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:684)
[apply] at com.android.dx.cf.code.Ropper.doit(Ropper.java:639)
[apply] at com.android.dx.cf.code.Ropper.convert(Ropper.java:252)
[apply] at
com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:252)
[apply] at
com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:131)
[apply] at
com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:85)
[apply] at
com.android.dx.command.dexer.Main.processClass(Main.java:369)
[apply] at
com.android.dx.command.dexer.Main.processFileBytes(Main.java:346)
[apply] at com.android.dx.command.dexer.Main.access$400(Main.java:59)
[apply] at
com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:294)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:134)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[apply] at com.android.dx.command.dexer.Main.processOne(Main.java:313)
[apply] at
com.android.dx.command.dexer.Main.processAllFiles(Main.java:233)
[apply] at com.android.dx.command.dexer.Main.run(Main.java:185)
[apply] at com.android.dx.command.dexer.Main.main(Main.java:166)
[apply] at com.android.dx.command.Main.main(Main.java:90)
[apply] ...at bytecode offset 00000009
[apply] locals[0000]: Lorg/freepascal/rtl/FpcBaseNestedProcVarType;
[apply] locals[0001]: [Ljava/lang/Object;
[apply] locals[0002]: <invalid>
[apply] locals[0003]: <invalid>
[apply] locals[0004]: <invalid>
[apply] locals[0005]: <invalid>
[apply] locals[0006]: <invalid>
[apply] locals[0007]: <invalid>
[apply] stack[0001]: Lorg/freepascal/rtl/FpcBaseNestedProcVarType;
[apply] stack[top0]: [Ljava/lang/Object;
[apply] ...while working on block 0009
[apply] ...while working on method
invokeBooleanFunc:([Ljava/lang/Object;)Z
[apply] ...while processing invokeBooleanFunc ([Ljava/lang/Object;)Z
[apply] ...while processing
org/freepascal/rtl/FpcBaseNestedProcVarType.class
[apply]
[apply]
[apply] UNEXPECTED TOP-LEVEL EXCEPTION:
[apply] com.android.dx.cf.code.SimException: local variable type
mismatch: attempt to set or access a value of type java.lang.Object
using a local variable of type int. This is symptomatic of .class
transformation tools that ignore local variable information.
[apply] at
com.android.dx.cf.code.BaseMachine.throwLocalMismatch(BaseMachine.java:550)
[apply] at
com.android.dx.cf.code.Simulator$SimVisitor.visitLocal(Simulator.java:570)
[apply] at
com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:481)
[apply] at
com.android.dx.cf.code.Simulator.simulate(Simulator.java:99)
[apply] at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:684)
[apply] at com.android.dx.cf.code.Ropper.doit(Ropper.java:639)
[apply] at com.android.dx.cf.code.Ropper.convert(Ropper.java:252)
[apply] at
com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:252)
[apply] at
com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:131)
[apply] at
com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:85)
[apply] at
com.android.dx.command.dexer.Main.processClass(Main.java:369)
[apply] at
com.android.dx.command.dexer.Main.processFileBytes(Main.java:346)
[apply] at com.android.dx.command.dexer.Main.access$400(Main.java:59)
[apply] at
com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:294)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:134)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[apply] at
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[apply] at com.android.dx.command.dexer.Main.processOne(Main.java:313)
[apply] at
com.android.dx.command.dexer.Main.processAllFiles(Main.java:233)
[apply] at com.android.dx.command.dexer.Main.run(Main.java:185)
[apply] at com.android.dx.command.dexer.Main.main(Main.java:166)
[apply] at com.android.dx.command.Main.main(Main.java:90)
[apply] ...at bytecode offset 00000010
[apply] locals[0000]: [Ljava/lang/Object;
[apply] locals[0001]: [Ljava/lang/Object;
[apply] locals[0002]: I
[apply] locals[0003]: I
[apply] locals[0004]: I
[apply] locals[0005]: [Ljava/lang/Object;
[apply] locals[0006]: <invalid>
[apply] locals[0007]: <invalid>
[apply] locals[0008]: <invalid>
[apply] locals[0009]: <invalid>
[apply] locals[000a]: <invalid>
[apply] locals[000b]: <invalid>
[apply] locals[000c]: <invalid>
[apply] locals[000d]: <invalid>
[apply] locals[000e]: <invalid>
[apply] locals[000f]: <invalid>
[apply] stack[top0]: Ljava/lang/Object;
[apply] ...while working on block 0010
[apply] ...while working on method
fpc_setlength_dynarr_multidim:([Ljava/lang/Object;[Ljava/lang/Object;ZIC)[Ljava/lang/Object;
[apply] ...while processing fpc_setlength_dynarr_multidim
([Ljava/lang/Object;[Ljava/lang/Object;ZIC)[Ljava/lang/Object;
[apply] ...while processing org/freepascal/rtl/system.class
[apply]
[apply] 1 warning
[apply] 3 errors; aborting
=== end build log ===
Regards,
Sven
-------------- next part --------------
A non-text attachment was scrubbed...
Name: first-fpc-dalvik.png
Type: image/png
Size: 6009 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20110827/466f4146/attachment.png>
More information about the fpc-devel
mailing list