diff -r 44a5802816be -r 2adac52f955e emul/src/main/java/java/lang/Class.java --- a/emul/src/main/java/java/lang/Class.java Fri Dec 28 12:35:32 2012 +0100 +++ b/emul/src/main/java/java/lang/Class.java Sat Dec 29 19:46:09 2012 +0100 @@ -210,15 +210,32 @@ * * */ - @JavaScriptBody(args = "self", body = - "var inst = self.cnstr();" - + "inst.cons__V(inst);" - + "return inst;" + @JavaScriptBody(args = { "self", "illegal" }, body = + "\nvar c = self.cnstr;" + + "\nif (c['cons__V']) {" + + "\n if ((c.cons__V.access & 0x1) != 0) {" + + "\n var inst = c();" + + "\n c.cons__V(inst);" + + "\n return inst;" + + "\n }" + + "\n return illegal;" + + "\n}" + + "\nreturn null;" ) + private static native Object newInstance0(Class self, Object illegal); + public T newInstance() throws InstantiationException, IllegalAccessException { - throw new UnsupportedOperationException(); + Object illegal = new Object(); + Object inst = newInstance0(this, illegal); + if (inst == null) { + throw new InstantiationException(getName()); + } + if (inst == illegal) { + throw new IllegalAccessException(); + } + return (T)inst; } /**