Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] NativeArray issue #5748

Closed
nadako opened this issue Oct 13, 2016 · 2 comments
Closed

[java] NativeArray issue #5748

nadako opened this issue Oct 13, 2016 · 2 comments
Assignees
Labels
bug platform-cs Everything related to c# platform-java Everything related to Java

Comments

@nadako
Copy link
Member

nadako commented Oct 13, 2016

As discussed in Slack...

class A<T> {
    var a:java.NativeArray<T>;
    public function new() {
        a = new java.NativeArray(10);
    }
    public inline function get(i:Int):T {
        return a[i];
    }
}


class Main {
    static function main() {
        var a = new A<Int>();
        Sys.println(a.get(0));
    }
}

Generated Java:

    public static void main()
    {
        //line 14 "d:\\Code\\playground\\src\\Main.hx"
        haxe.root.A<java.lang.Object> a = new haxe.root.A<java.lang.Object>();
        //line 15 "d:\\Code\\playground\\src\\Main.hx"
        java.lang.System.out.println(((java.lang.Object) (((int[]) (((java.lang.Object[]) (a.a) )) )[0]) ));
    }

This fails compiling with:

src\haxe\root\Main.java:39: error: incompatible types: Object[] cannot be converted to int[]
        java.lang.System.out.println(((java.lang.Object) (((int[]) (((java.lang.Object[]) (a.a) )) )[0]) ));
@nadako nadako added bug platform-java Everything related to Java labels Oct 13, 2016
nadako added a commit that referenced this issue Oct 21, 2016
@nadako nadako added the platform-cs Everything related to c# label Oct 21, 2016
@nadako
Copy link
Member Author

nadako commented Oct 21, 2016

It seems like it's not Java-specific, because I got pretty much the same issue with C# when -D erase-generics (see 3fe3fab).

@Simn Simn modified the milestone: 4.0 Jan 9, 2017
@Simn Simn modified the milestones: Release 4.0, Bugs Apr 17, 2018
@Simn
Copy link
Member

Simn commented Apr 10, 2019

This is also #3398.

@Simn Simn closed this as completed Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug platform-cs Everything related to c# platform-java Everything related to Java
Projects
None yet
Development

No branches or pull requests

3 participants