plasma-umass / doppio

Breaks the browser language barrier (includes a plugin-free JVM).
http://plasma-umass.github.io/doppio-demo
MIT License
2.16k stars 175 forks source link

Reflection API not working for primitive integer #427

Closed jimfb closed 8 years ago

jimfb commented 8 years ago

Invoking the constructor with the integer 42 should result in it printing 42, but actually prints -0.

// Test.java
import java.lang.reflect.Constructor;

public class Test {
  public Test(int a) {
    System.out.println("Number: " + a);
  }
  public static void main(String[] args) {
    try {
      Constructor<?> constructor = Test.class.getConstructors()[0];
      constructor.newInstance(new Object[] { 42 });
      new Test(43);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
$ javac Test.java
$ doppio Test
Number: -0
Number: 43
jvilk commented 8 years ago

Good catch. Looks like an unboxing bug.