fpc/tests/test/jvm/tbytearrres.pp
Jonas Maebe 71068ae7eb * made the tests Android-compatible (use the androidr14 unit instead
of the jdk15 unit in that case)
  * adjusted testall.sh script so it can also be used to test class
    files compiled for Android (still with the JVM though)

git-svn-id: branches/jvmbackend@19835 -
2011-12-12 20:34:02 +00:00

38 lines
732 B
ObjectPascal

program tbytearrres;
{$mode delphi}
uses
{$ifdef java}jdk15{$else}androidr14{$endif};
type
ByteArray = array of byte;
function GetUInt32(Src: array of byte; Offset : integer) : cardinal;
begin
result:=src[offset];
end;
function JByteArrayToByteArray(A : Arr1jbyte; Start: integer = 0; Count : integer = -1) : ByteArray;
var
i: longint;
begin
if count=-1 then
count:=length(a);
setlength(result,count);
for i:=start to start+count-1 do
result[i-start]:=a[i];
end;
function AddressToInt(X : JNInetAddress) : Cardinal;
begin
result := GetUInt32(JByteArrayToByteArray(X.getAddress()), 0);
end;
var
c: cardinal;
begin
c:=AddressToInt(JNInetAddress.getLocalHost);
JLSystem.fout.println(int64(c));
end.