Bck2Brwsr 0.10
From APIDesign
(Difference between revisions)
(New page: Using Object.defineProperty to make sure the JavaScript Object has all the methods of {{JDK|java/lang|Object}}, while those methods do not show up during iteration <source lang="java...) |
|||
Line 4: | Line 4: | ||
for (var p in anObject) { | for (var p in anObject) { | ||
console.log('A prop found ' + p); | console.log('A prop found ' + p); | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | The ''AOT'' mode has support for [[JDK]]8's [[Closure|Lambdas]]. Following methods properly return "XXXXXXXXXX" in [[Bck2Brwsr 0.10]]: | ||
+ | |||
+ | <source lang="java"> | ||
+ | private static void fewTimes(Runnable r, int cnt) { | ||
+ | while (cnt-- > 0) { | ||
+ | r.run(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | public static String compound() { | ||
+ | StringBuilder sb = new StringBuilder(); | ||
+ | fewTimes(() -> sb.append('X'), 10); | ||
+ | return sb.toString(); | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | Support for [[JDK]]8 defender and interface static methods. In the following example the method '''defaultValue''' properly returns ''42'' in [[Bck2Brwsr 0.10]]: | ||
+ | |||
+ | <source lang="java"> | ||
+ | public interface Value { | ||
+ | public static int staticValue(Value v) { | ||
+ | return v.value(); | ||
+ | } | ||
+ | |||
+ | public default int value() { | ||
+ | return 42; | ||
+ | } | ||
+ | |||
+ | public static int defaultValue() { | ||
+ | return staticValue(new Value() {}); | ||
+ | } | ||
} | } | ||
</source> | </source> |
Revision as of 16:51, 13 September 2014
Using Object.defineProperty to make sure the JavaScript Object has all the methods of Object, while those methods do not show up during iteration
for (var p in anObject) { console.log('A prop found ' + p); }
The AOT mode has support for JDK8's Lambdas. Following methods properly return "XXXXXXXXXX" in Bck2Brwsr 0.10:
private static void fewTimes(Runnable r, int cnt) { while (cnt-- > 0) { r.run(); } } public static String compound() { StringBuilder sb = new StringBuilder(); fewTimes(() -> sb.append('X'), 10); return sb.toString(); }
Support for JDK8 defender and interface static methods. In the following example the method defaultValue properly returns 42 in Bck2Brwsr 0.10:
public interface Value { public static int staticValue(Value v) { return v.value(); } public default int value() { return 42; } public static int defaultValue() { return staticValue(new Value() {}); } }