jtulach / bck2brwsr

Bck2Brwsr VM to transpile Java bytecode to JavaScript
http://bck2brwsr.apidesign.org
Other
114 stars 16 forks source link

Class.getMethod(String, Class[]) fails with null argument #34

Closed johanvos closed 3 years ago

johanvos commented 3 years ago

The following code snippet fails. When providing a (Class[])null, an error will be reported:

java.lang.NullPointerException:TypeError: Cannot read property 'length' of null When passing an empty Class array, it works.

  @Compare
    public boolean emptyArrayClass() {
        Class[] empty = new Class[0];
        Class klass = DummyClass.class;
        int a = 0;
        try {
            klass.getMethod("getInstance", (Class[])null);
         //   klass.getMethod("getInstance", empty); // uncomment to make it work
            a = 1;
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(JFXIssuesTest.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SecurityException ex) {
            Logger.getLogger(JFXIssuesTest.class.getName()).log(Level.SEVERE, null, ex);
        }
        return (a == 0);
    }
johanvos commented 3 years ago

(I'm not looking into this right now, as there is a workaround)

jtulach commented 3 years ago

Fixed by 802adfd