Tabnine Logo
Binder.identity
Code IndexAdd Tabnine to your IDE (free)

How to use
identity
method
in
com.headius.invokebinder.Binder

Best Java code snippets using com.headius.invokebinder.Binder.identity (Showing top 5 results out of 315)

origin: com.headius/invokebinder

/**
 * Terminate this binder by returning its sole remaining argument. The
 * signature must take only one argument whose type matches the return
 * type.
 *
 * Invoking the resulting handle will (eventually) return the argument
 * passed in at this point.
 *
 * @return a new SmartHandle with this binder's starting signature that
 * simply returns its sole received argument
 */
public SmartHandle identity() {
  return new SmartHandle(start, binder.identity());
}
origin: com.headius/invokebinder

private MethodHandle nativeTryFinally(MethodHandle target, MethodHandle post) {
  MethodType targetType = target.type();
  boolean voidReturn = targetType.returnType() == Void.TYPE;
  MethodType finallyType = targetType.insertParameterTypes(0, Throwable.class);
  int dropCount = 1;
  if (!voidReturn) {
    finallyType = finallyType.insertParameterTypes(1, targetType.returnType());
    dropCount = 2;
  }
  MethodHandle wrapPost = Binder
      .from(finallyType)
      .drop(0, dropCount)
      .invoke(post);
  if (!voidReturn) {
    wrapPost = Binder.from(finallyType)
        .foldVoid(wrapPost)
        .permute(1)
        .identity();
  }
  try {
    return (MethodHandle) tryFinallyJava9.invokeExact(target, wrapPost);
  } catch (Throwable t) {
    throw new RuntimeException("Java 9 detected but MethodHandles.tryFinally missing", t);
  }
}
origin: com.ning.billing/killbill-osgi-bundles-jruby

public static IRubyObject attrAssign(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0) throws Throwable {
  RubyClass selfClass = self.getMetaClass();
  String methodName = site.name;
  SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData();
  CacheEntry entry = selfClass.searchWithCache(methodName);
  DynamicMethod method = entry.method;
  if (methodMissing(entry, CallType.NORMAL, methodName, self)) {
    return callMethodMissing(entry, CallType.NORMAL, context, self, methodName, arg0);
  }
  MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 1, false);
  mh = foldArguments(
      mh,
      Binder.from(site.type())
          .drop(0, 2)
          .identity());
  site.setTarget(mh);
  mh.invokeWithArguments(context, self, arg0);
  return arg0;
}
origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public static IRubyObject attrAssign(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0) throws Throwable {
  RubyClass selfClass = self.getMetaClass();
  String methodName = site.name;
  SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData();
  CacheEntry entry = selfClass.searchWithCache(methodName);
  DynamicMethod method = entry.method;
  if (methodMissing(entry, CallType.NORMAL, methodName, self)) {
    return callMethodMissing(entry, CallType.NORMAL, context, self, methodName, arg0);
  }
  MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 1, false);
  mh = foldArguments(
      mh,
      Binder.from(site.type())
          .drop(0, 2)
          .identity());
  site.setTarget(mh);
  mh.invokeWithArguments(context, self, arg0);
  return arg0;
}
origin: com.headius/invokebinder

public MethodHandle up(MethodHandle target) {
  if (Util.isJava9()) return nativeTryFinally(target, post);
  MethodHandle exceptionHandler = Binder
      .from(target.type().insertParameterTypes(0, Throwable.class).changeReturnType(void.class))
      .drop(0)
      .invoke(post);
  MethodHandle rethrow = Binder
      .from(target.type().insertParameterTypes(0, Throwable.class))
      .fold(exceptionHandler)
      .drop(1, target.type().parameterCount())
      .throwException();
  target = MethodHandles.catchException(target, Throwable.class, rethrow);
  // if target returns a value, we must return it regardless of post
  MethodHandle realPost = post;
  if (target.type().returnType() != void.class) {
    // modify post to ignore return value
    MethodHandle newPost = Binder
        .from(target.type().insertParameterTypes(0, target.type().returnType()).changeReturnType(void.class))
        .drop(0)
        .invoke(post);
    // fold post into an identity chain that only returns the value
    realPost = Binder
        .from(target.type().insertParameterTypes(0, target.type().returnType()))
        .fold(newPost)
        .drop(1, target.type().parameterCount())
        .identity();
  }
  return MethodHandles.foldArguments(realPost, target);
}
com.headius.invokebinderBinderidentity

Javadoc

Apply the tranforms, binding them to a handle that will simply return its sole argument as its return value. The endpoint signature must have a single argument of the same type as its return type.

Popular methods of Binder

  • from
    Construct a new Binder, starting from a given MethodType.
  • insert
    Insert at the given index the given argument value(s).
  • invoke
    Apply the chain of transforms and bind them to a static method specified using the end signature plu
  • collect
    Box all incoming arguments from the given position onward into the given array type.
  • constant
    Apply the tranforms, binding them to a constant value that will propagate back through the chain. Th
  • drop
    Drop from the given index a number of arguments.
  • filter
    Filter incoming arguments, from the given index, replacing each with the result of calling the assoc
  • fold
    Process the incoming arguments using the given handle, inserting the result as the first argument.
  • invokeVirtual
    Apply the chain of transforms and bind them to a virtual method specified using the end signature pl
  • permute
    Permute the incoming arguments to a new sequence specified by the given values. Arguments may be dup
  • cast
    Cast the incoming arguments to the given MethodType. The casts applied are equivalent to those in Me
  • filterReturn
    Filter return value, using a function that produces the current return type from another type. The n
  • cast,
  • filterReturn,
  • invokeStaticQuiet,
  • invokeVirtualQuiet,
  • tryFinally,
  • nop,
  • type,
  • append,
  • foldVoid

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • findViewById (Activity)
  • addToBackStack (FragmentTransaction)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • ImageIO (javax.imageio)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now