Skip to content

[java] Cannot create a constant NativeArray of int #2701

Closed
singpolyma opened this Issue Mar 3, 2014 · 2 comments

3 participants

@singpolyma
var x = java.Lib.nativeArray([1], true);

This compiles with haxe, but produces java code that just blindly casts java.lang.Object[] to int[], which javac refuses to compile.

@singpolyma

The problem seems to stem from the way polymorphism is handled. The following works:

 public static function nativeIntArray(arr:Array<Int>):java.NativeArray<Int> {
    var native = new java.NativeArray(arr.length);
    for(i in 0...arr.length) {
       native[i] = arr[i];
    }
    return native;
 }
@waneck
Haxe Foundation member
waneck commented Mar 3, 2014

This was recently fixed at 89de9b2

@waneck waneck closed this Mar 3, 2014
@ncannasse ncannasse added this to the 3.2 milestone Mar 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.