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


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.




I think the update to java.lang.invoke.MutableCallSite.java should be safe:

     public static void syncAll(MutableCallSite[] sites) {
         if (sites.length == 0)  return;
-        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.)




More information about the core-libs-dev mailing list