fpc/tests/test/jvm/tnestdynarr.pp
Jonas Maebe 21e6401921 * no longer encode all pointers to other pointer types (such as
classes, interfaces, dynamic arrays, ...) as "array of JLObject",
    but instead as an array of the actual pointed-to type. The reason
    for the previous behaviour was mainly that the JVM threadvar
    implementation internally stores all threadvars that are
    such double pointer types into an "array of JLObject". Type casting
    this array to e.g. an "array of array of byte" causes an exception
    even if it only contains "array of byte" instances (since the outer
    array type is different). This is now solved by first taking the
    element of the array and then typecasting it to the destination
    type (so dynarrbyte(arr[0]) instead of pdynarrbyte(arr)^[0]).

    The reason for the new (more accurate) behaviour is because the
    old one caused type errors in case a double pointer field was
    internally created for the nestedfpstruct support (see added
    test)

git-svn-id: branches/jvmbackend@19821 -
2011-12-11 17:25:09 +00:00

25 lines
259 B
ObjectPascal

program tnestdynarr;
type
tbytearray = array of byte;
procedure test(var a: tbytearray);
procedure nest;
begin
a[0]:=2;
end;
begin
nest;
end;
var
a: tbytearray;
begin
setlength(a,1);
test(a);
if a[0]<>2 then
halt(1);
end.