src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java

Print this page
rev 12972 : 8140606: Update library code to use internal Unsafe
Reviewed-by: duke


1500         s.defaultWriteObject();
1501         s.writeObject(getException());
1502     }
1503 
1504     /**
1505      * Reconstitutes this task from a stream (that is, deserializes it).
1506      * @param s the stream
1507      * @throws ClassNotFoundException if the class of a serialized object
1508      *         could not be found
1509      * @throws java.io.IOException if an I/O error occurs
1510      */
1511     private void readObject(java.io.ObjectInputStream s)
1512         throws java.io.IOException, ClassNotFoundException {
1513         s.defaultReadObject();
1514         Object ex = s.readObject();
1515         if (ex != null)
1516             setExceptionalCompletion((Throwable)ex);
1517     }
1518 
1519     // Unsafe mechanics
1520     private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
1521     private static final long STATUS;
1522 
1523     static {
1524         exceptionTableLock = new ReentrantLock();
1525         exceptionTableRefQueue = new ReferenceQueue<Object>();
1526         exceptionTable = new ExceptionNode[EXCEPTION_MAP_CAPACITY];
1527         try {
1528             STATUS = U.objectFieldOffset
1529                 (ForkJoinTask.class.getDeclaredField("status"));
1530         } catch (ReflectiveOperationException e) {
1531             throw new Error(e);
1532         }
1533     }
1534 
1535 }


1500         s.defaultWriteObject();
1501         s.writeObject(getException());
1502     }
1503 
1504     /**
1505      * Reconstitutes this task from a stream (that is, deserializes it).
1506      * @param s the stream
1507      * @throws ClassNotFoundException if the class of a serialized object
1508      *         could not be found
1509      * @throws java.io.IOException if an I/O error occurs
1510      */
1511     private void readObject(java.io.ObjectInputStream s)
1512         throws java.io.IOException, ClassNotFoundException {
1513         s.defaultReadObject();
1514         Object ex = s.readObject();
1515         if (ex != null)
1516             setExceptionalCompletion((Throwable)ex);
1517     }
1518 
1519     // Unsafe mechanics
1520     private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
1521     private static final long STATUS;
1522 
1523     static {
1524         exceptionTableLock = new ReentrantLock();
1525         exceptionTableRefQueue = new ReferenceQueue<Object>();
1526         exceptionTable = new ExceptionNode[EXCEPTION_MAP_CAPACITY];
1527         try {
1528             STATUS = U.objectFieldOffset
1529                 (ForkJoinTask.class.getDeclaredField("status"));
1530         } catch (ReflectiveOperationException e) {
1531             throw new Error(e);
1532         }
1533     }
1534 
1535 }