Package java.lang.invoke

Examples of java.lang.invoke.MethodType$ConcurrentWeakInternSet


    return customClass;
  }

  private static Object createClassLoader(Class contextClass, Class generatedClassLoaderClass, Object contextObject, MethodHandle findVirtualHandle)
      throws Throwable {
    MethodType createClassLoaderType = MethodType.methodType(generatedClassLoaderClass, ClassLoader.class);
    MethodHandle createClassLoaderHandle = (MethodHandle) findVirtualHandle.invokeWithArguments(new Object[] { lookup, contextClass, "createClassLoader",
        createClassLoaderType });

    Object classLoader = createClassLoaderHandle.invokeWithArguments(new Object[] { contextObject, null });
    return classLoader;
View Full Code Here


    Object classLoader = createClassLoaderHandle.invokeWithArguments(new Object[] { contextObject, null });
    return classLoader;
  }

  private static Object createContextObject(Class contextClass, MethodHandles.Lookup lookup) throws NoSuchMethodException, IllegalAccessException, Throwable {
    MethodType findConstructorType = MethodType.methodType(MethodHandle.class, Class.class, new Class[] { MethodType.class });
    MethodHandle findConstructorHandle = lookup.findVirtual(MethodHandles.Lookup.class, "findConstructor", findConstructorType);

    MethodType constructorType = MethodType.methodType(Void.TYPE);
    MethodHandle constructorHandle = (MethodHandle) findConstructorHandle.invokeWithArguments(new Object[] { lookup, contextClass, constructorType });

    Object contextObject = constructorHandle.invokeWithArguments(new Object[0]);
    return contextObject;
  }
View Full Code Here

     */
    public Signature appendArg(String name, Class type) {
        String[] newArgNames = new String[argNames.length + 1];
        System.arraycopy(argNames, 0, newArgNames, 0, argNames.length);
        newArgNames[argNames.length] = name;
        MethodType newMethodType = methodType.appendParameterTypes(type);
        return new Signature(newMethodType, newArgNames);
    }
View Full Code Here

        assert names.length == types.length : "names and types must be of the same length";

        String[] newArgNames = new String[argNames.length + names.length];
        System.arraycopy(argNames, 0, newArgNames, 0, argNames.length);
        System.arraycopy(names, 0, newArgNames, argNames.length, names.length);
        MethodType newMethodType = methodType.appendParameterTypes(types);
        return new Signature(newMethodType, newArgNames);
    }
View Full Code Here

     */
    public Signature prependArg(String name, Class type) {
        String[] newArgNames = new String[argNames.length + 1];
        System.arraycopy(argNames, 0, newArgNames, 1, argNames.length);
        newArgNames[0] = name;
        MethodType newMethodType = methodType.insertParameterTypes(0, type);
        return new Signature(newMethodType, newArgNames);
    }
View Full Code Here

     */
    public Signature prependArgs(String[] names, Class... types) {
        String[] newArgNames = new String[argNames.length + names.length];
        System.arraycopy(argNames, 0, newArgNames, names.length, argNames.length);
        System.arraycopy(names, 0, newArgNames, 0, names.length);
        MethodType newMethodType = methodType.insertParameterTypes(0, types);
        return new Signature(newMethodType, newArgNames);
    }
View Full Code Here

        System.arraycopy(names, 0, newArgNames, index, names.length);
        if (index != 0) System.arraycopy(argNames, 0, newArgNames, 0, index);
        if (argNames.length - index != 0)
            System.arraycopy(argNames, index, newArgNames, index + names.length, argNames.length - index);

        MethodType newMethodType = methodType.insertParameterTypes(index, types);

        return new Signature(newMethodType, newArgNames);
    }
View Full Code Here

     * @param name the name of the argument to drop
     * @return a new signature
     */
    public Signature dropArg(String name) {
        String[] newArgNames = new String[argNames.length - 1];
        MethodType newType = methodType;

        for (int i = 0, j = 0; i < argNames.length; i++) {
            if (argNames[i].equals(name)) {
                newType = newType.dropParameterTypes(j, j + 1);
                continue;
            }
            newArgNames[j++] = argNames[i];
        }

View Full Code Here

        String[] newArgNames = new String[argNames.length - 1];
        if (index > 0) System.arraycopy(argNames, 0, newArgNames, 0, index);
        if (index < argNames.length - 1)
            System.arraycopy(argNames, index + 1, newArgNames, index, argNames.length - (index + 1));

        MethodType newType = methodType.dropParameterTypes(index, index + 1);

        return new Signature(newType, newArgNames);
    }
View Full Code Here

            newArgNames = Arrays.copyOf(argNames, argNames.length);
            newArgNames[offset] = newName;
        }

        Class oldType = methodType.parameterType(offset);
        MethodType newMethodType = methodType;

        if (!oldType.equals(newType)) newMethodType = methodType.changeParameterType(offset, newType);

        return new Signature(newMethodType, newArgNames);
    }
View Full Code Here

TOP

Related Classes of java.lang.invoke.MethodType$ConcurrentWeakInternSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.