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

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

Comments

Projects
None yet
3 participants
@singpolyma
Contributor

singpolyma commented Mar 3, 2014

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

This comment has been minimized.

Show comment
Hide comment
@singpolyma

singpolyma Mar 3, 2014

Contributor

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;
 }
Contributor

singpolyma commented Mar 3, 2014

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

This comment has been minimized.

Show comment
Hide comment
@waneck

waneck Mar 3, 2014

Member

This was recently fixed at 89de9b2

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