1.1 --- a/emul/src/main/java/java/lang/Class.java Fri Dec 28 12:35:32 2012 +0100
1.2 +++ b/emul/src/main/java/java/lang/Class.java Sat Dec 29 19:46:09 2012 +0100
1.3 @@ -210,15 +210,32 @@
1.4 * </ul>
1.5 *
1.6 */
1.7 - @JavaScriptBody(args = "self", body =
1.8 - "var inst = self.cnstr();"
1.9 - + "inst.cons__V(inst);"
1.10 - + "return inst;"
1.11 + @JavaScriptBody(args = { "self", "illegal" }, body =
1.12 + "\nvar c = self.cnstr;"
1.13 + + "\nif (c['cons__V']) {"
1.14 + + "\n if ((c.cons__V.access & 0x1) != 0) {"
1.15 + + "\n var inst = c();"
1.16 + + "\n c.cons__V(inst);"
1.17 + + "\n return inst;"
1.18 + + "\n }"
1.19 + + "\n return illegal;"
1.20 + + "\n}"
1.21 + + "\nreturn null;"
1.22 )
1.23 + private static native Object newInstance0(Class<?> self, Object illegal);
1.24 +
1.25 public T newInstance()
1.26 throws InstantiationException, IllegalAccessException
1.27 {
1.28 - throw new UnsupportedOperationException();
1.29 + Object illegal = new Object();
1.30 + Object inst = newInstance0(this, illegal);
1.31 + if (inst == null) {
1.32 + throw new InstantiationException(getName());
1.33 + }
1.34 + if (inst == illegal) {
1.35 + throw new IllegalAccessException();
1.36 + }
1.37 + return (T)inst;
1.38 }
1.39
1.40 /**