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

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


2758             throw new UnsupportedOperationException(); }
2759         @Override public boolean isCompletedExceptionally() {
2760             throw new UnsupportedOperationException(); }
2761         @Override public int getNumberOfDependents() {
2762             throw new UnsupportedOperationException(); }
2763         @Override public CompletableFuture<T> completeAsync
2764             (Supplier<? extends T> supplier, Executor executor) {
2765             throw new UnsupportedOperationException(); }
2766         @Override public CompletableFuture<T> completeAsync
2767             (Supplier<? extends T> supplier) {
2768             throw new UnsupportedOperationException(); }
2769         @Override public CompletableFuture<T> orTimeout
2770             (long timeout, TimeUnit unit) {
2771             throw new UnsupportedOperationException(); }
2772         @Override public CompletableFuture<T> completeOnTimeout
2773             (T value, long timeout, TimeUnit unit) {
2774             throw new UnsupportedOperationException(); }
2775     }
2776 
2777     // Unsafe mechanics
2778     private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
2779     private static final long RESULT;
2780     private static final long STACK;
2781     private static final long NEXT;
2782     static {
2783         try {
2784             RESULT = U.objectFieldOffset
2785                 (CompletableFuture.class.getDeclaredField("result"));
2786             STACK = U.objectFieldOffset
2787                 (CompletableFuture.class.getDeclaredField("stack"));
2788             NEXT = U.objectFieldOffset
2789                 (Completion.class.getDeclaredField("next"));
2790         } catch (ReflectiveOperationException e) {
2791             throw new Error(e);
2792         }
2793 
2794         // Reduce the risk of rare disastrous classloading in first call to
2795         // LockSupport.park: https://bugs.openjdk.java.net/browse/JDK-8074773
2796         Class<?> ensureLoaded = LockSupport.class;
2797     }
2798 }


2758             throw new UnsupportedOperationException(); }
2759         @Override public boolean isCompletedExceptionally() {
2760             throw new UnsupportedOperationException(); }
2761         @Override public int getNumberOfDependents() {
2762             throw new UnsupportedOperationException(); }
2763         @Override public CompletableFuture<T> completeAsync
2764             (Supplier<? extends T> supplier, Executor executor) {
2765             throw new UnsupportedOperationException(); }
2766         @Override public CompletableFuture<T> completeAsync
2767             (Supplier<? extends T> supplier) {
2768             throw new UnsupportedOperationException(); }
2769         @Override public CompletableFuture<T> orTimeout
2770             (long timeout, TimeUnit unit) {
2771             throw new UnsupportedOperationException(); }
2772         @Override public CompletableFuture<T> completeOnTimeout
2773             (T value, long timeout, TimeUnit unit) {
2774             throw new UnsupportedOperationException(); }
2775     }
2776 
2777     // Unsafe mechanics
2778     private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
2779     private static final long RESULT;
2780     private static final long STACK;
2781     private static final long NEXT;
2782     static {
2783         try {
2784             RESULT = U.objectFieldOffset
2785                 (CompletableFuture.class.getDeclaredField("result"));
2786             STACK = U.objectFieldOffset
2787                 (CompletableFuture.class.getDeclaredField("stack"));
2788             NEXT = U.objectFieldOffset
2789                 (Completion.class.getDeclaredField("next"));
2790         } catch (ReflectiveOperationException e) {
2791             throw new Error(e);
2792         }
2793 
2794         // Reduce the risk of rare disastrous classloading in first call to
2795         // LockSupport.park: https://bugs.openjdk.java.net/browse/JDK-8074773
2796         Class<?> ensureLoaded = LockSupport.class;
2797     }
2798 }