Var parameters in JVM
Original Reporter info from Mantis: bozox
-
Reporter name: Seva Alekseyev
Original Reporter info from Mantis: bozox
- Reporter name: Seva Alekseyev
Description:
Passing uninitialized variables to functions/procedures as var-parameters is OK in Pascal. However, when compiling to JVM targeting Android, it's interpreted as reading an uninitialized variable, and causes the Android build process to error out, specifically on the stage of converting class files to Dalvik format.
The error message goes like this:
EXCEPTION FROM SIMULATION:
local 0000: invalid
...at bytecode offset 00000008
locals[0000]: &LtPos;invalid>
locals[0001]: [S
locals[0002]: &LtPos;invalid>
locals[0003]: &LtPos;invalid>
stack[0001]: [S
stack[top0]: int{0x00000000 / 0}
...while working on block 0003
...while working on method Hello:()V
...while processing Hello ()V
...while processing a.class
1 error; aborting
Investigation steps are here: http://stackoverflow.com/questions/12431691/conversion-to-dalvik-failed-uninitialized-variable-somewhere
Steps to reproduce:
Install FPC for Java from http://sourceforge.net/projects/freepascal/files/JVM/2.7.1-r19830-snapshot3/fpcjvmwin32-snapshot3.zip/download
Install Android SDK.
Compile the attached file to a .class:
ppcjvm -XP -Tandroid -FuC:\FPC\2.6.0\units\jvm-android\rtl a.pas
Try converting into Dalvik:
C:\android-sdk-windows\platform-tools\dx --dex --output=a.dex c:\Path
Where Path is the folder where the a.class file can be found.
The same error appears if you link the class in an Android project, and reference it at least once, and try to build an APK for that.
Mantis conversion info:
- Mantis ID: 22892
- OS: Java
- Platform: Java
- Version: 2.7.1