src/jdk/internal/dynalink/ChainedCallSite.java

changeset 488
9a3e3bb30db3
parent 101
f8221ce53c2e
child 524
badc919cd621
     1.1 --- a/src/jdk/internal/dynalink/ChainedCallSite.java	Thu Aug 01 12:23:38 2013 +0200
     1.2 +++ b/src/jdk/internal/dynalink/ChainedCallSite.java	Wed Aug 07 16:38:44 2013 +0200
     1.3 @@ -85,12 +85,12 @@
     1.4  
     1.5  import java.lang.invoke.MethodHandle;
     1.6  import java.lang.invoke.MethodHandles;
     1.7 -import java.lang.invoke.MethodType;
     1.8  import java.util.Iterator;
     1.9  import java.util.LinkedList;
    1.10  import java.util.concurrent.atomic.AtomicReference;
    1.11  import jdk.internal.dynalink.linker.GuardedInvocation;
    1.12  import jdk.internal.dynalink.support.AbstractRelinkableCallSite;
    1.13 +import jdk.internal.dynalink.support.Lookup;
    1.14  
    1.15  /**
    1.16   * A relinkable call site that maintains a chain of linked method handles. In the default implementation, up to 8 method
    1.17 @@ -103,6 +103,9 @@
    1.18   * handle is always at the start of the chain.
    1.19   */
    1.20  public class ChainedCallSite extends AbstractRelinkableCallSite {
    1.21 +    private static final MethodHandle PRUNE = Lookup.findOwnSpecial(MethodHandles.lookup(), "prune", MethodHandle.class,
    1.22 +            MethodHandle.class);
    1.23 +
    1.24      private final AtomicReference<LinkedList<GuardedInvocation>> invocations = new AtomicReference<>();
    1.25  
    1.26      /**
    1.27 @@ -194,18 +197,4 @@
    1.28      private MethodHandle prune(MethodHandle relink) {
    1.29          return relinkInternal(null, relink, false);
    1.30      }
    1.31 -
    1.32 -    private static final MethodHandle PRUNE;
    1.33 -    static {
    1.34 -        try {
    1.35 -            PRUNE = MethodHandles.lookup().findSpecial(ChainedCallSite.class, "prune", MethodType.methodType(
    1.36 -                    MethodHandle.class, MethodHandle.class), ChainedCallSite.class);
    1.37 -        // NOTE: using two catch blocks so we don't introduce a reference to 1.7 ReflectiveOperationException, allowing
    1.38 -        // Dynalink to be used on 1.6 JVMs with Remi's backport library.
    1.39 -        } catch(IllegalAccessException e) {
    1.40 -            throw new AssertionError(e.getMessage(), e); // Can not happen
    1.41 -        } catch(NoSuchMethodException e) {
    1.42 -            throw new AssertionError(e.getMessage(), e); // Can not happen
    1.43 -        }
    1.44 -    }
    1.45  }

mercurial