RFR: Update code in java.lang to use new language features
Paul Sandoz
paul.sandoz at oracle.com
Fri Jan 24 14:45:58 UTC 2014
Hi,
Here are some patches that update code in java.lang to use newer language features. I will log a bug and fold into one patch once reviewed.
Locally run java.lang tests all pass, but i will also kick off a JPRT test.
Paul.
--
http://cr.openjdk.java.net/~psandoz/jdk9/java.lang-diamonds/
--
http://cr.openjdk.java.net/~psandoz/jdk9/java.lang-foreach/
I think the update to java.lang.invoke.MutableCallSite.java should be safe:
public static void syncAll(MutableCallSite[] sites) {
if (sites.length == 0) return;
STORE_BARRIER.lazySet(0);
- for (int i = 0; i < sites.length; i++) {
- sites[i].getClass(); // trigger NPE on first null
+ for (MutableCallSite site : sites) {
+ site.getClass(); // trigger NPE on first null
}
// FIXME: NYI
}
However, that got me wondering about that STORE_BARRIER. IIUC it is using a static AtomicInteger and a call to lazySet to in effect emulate a StoreStore (release) barrier or the equivalent of Unsafe.storeFence, so the AtomicInteger could be replaced with Unsafe. (When there is an update to the JMM it might be possible to update docs on syncAll.)
--
http://cr.openjdk.java.net/~psandoz/jdk9/java.lang-StringBuilder/
--
http://cr.openjdk.java.net/~psandoz/jdk9/java.lang-collapse-catches/
--
http://cr.openjdk.java.net/~psandoz/jdk9/java.lang-boxing/
More information about the core-libs-dev
mailing list