Class LambdaProxyFactory


  • public final class LambdaProxyFactory
    extends Object
    Factory for heap proxy objects that stand in for invokedynamic lambda instances, storing captured arguments as capture$N fields.
    • Constructor Detail

      • LambdaProxyFactory

        public LambdaProxyFactory​(HeapManager heapManager)
        Creates a factory that allocates proxies on the given heap.
        Parameters:
        heapManager - the heap used to allocate proxy objects
    • Method Detail

      • createProxy

        public ObjectInstance createProxy​(InvokeDynamicInfo info,
                                          ConcreteValue[] capturedArgs)
        Allocates a fresh proxy object for a lambda call site and copies each captured argument into a capture$N field.
        Parameters:
        info - the invokedynamic call site information, naming the functional interface the proxy implements
        capturedArgs - the values captured at the call site
        Returns:
        the proxy instance
      • isLambdaFactory

        public boolean isLambdaFactory​(InvokeDynamicInfo info)
        Checks whether the call site's bootstrap method is the lambda metafactory.
        Parameters:
        info - the invokedynamic call site information, may be null
        Returns:
        true if the bootstrap is metafactory or altMetafactory
      • getCapturedArgCount

        public int getCapturedArgCount​(String descriptor)
        Counts the parameters in a call site descriptor, which equals the number of captured arguments.
        Parameters:
        descriptor - the call site method descriptor, may be null
        Returns:
        the parameter count, or 0 for a malformed descriptor
      • extractInterfaceType

        public String extractInterfaceType​(String descriptor)
        Extracts the functional interface internal name from a call site descriptor's return type.
        Parameters:
        descriptor - the call site method descriptor, may be null
        Returns:
        the interface internal name, or java/lang/Object if it cannot be determined
      • getTargetMethodName

        public String getTargetMethodName​(InvokeDynamicInfo info)
        Returns the interface method name the lambda implements.
        Parameters:
        info - the invokedynamic call site information
        Returns:
        the invoked method name