HaxeFoundation / hxjava

Haxe Java support library. Build scripts and support code.
The Unlicense
46 stars 14 forks source link

NPE when using Type.createInstance and null constructor params #24

Closed ianharrigan closed 4 years ago

ianharrigan commented 6 years ago

Hi there,

So there is an issue currently in hxJava whereby if you try to pass a null value as a constructor param it causes an NPE and the whole app crashes. eg:

Type.createInstance(SomeClass, [1, null, 2]);

This is because the code in Type.java attempts to get the class from the params passed, one of which is null

Extract from Type.java:

Object o = args.__get(i);
objs[i]= o;
cls[i] = o.getClass(); // <--------------- this is the issue
boolean isNum = false;

I had a quick go at patching it and its a little more involved than i originally assumed (hence no PR).

Cheers, Ian

Gama11 commented 6 years ago

Considering Java's Type.createInstance implementation not here but in the Haxe repo, it's probably better to report it there?

ianharrigan commented 6 years ago

Right fair enough - makes sense.

RealyUniqueName commented 4 years ago

See https://github.com/HaxeFoundation/haxe/issues/7505

markknol commented 4 years ago

(Note sure if you are aware, but we can transfer issues across our GitHub organisation ) image

Gama11 commented 4 years ago

Not back when this issue was created, I think. :)

markknol commented 4 years ago

Oops, was only looking at date of latest comment 😛