Package java.lang.invoke

Examples of java.lang.invoke.MethodHandle.invoke()


        case "toString":
          return "{{" + super_mh.invoke(aargs[0]) + "}}";
        case "varargs":
          return "{{" + super_mh.invoke(aargs[0],(Object[])aargs[1]) + "}}";
        case "varargs2":
          return "{{" + super_mh.invoke(aargs[0],aargs[1],(Object[])aargs[2]) + "}}";
        default:
          return super_mh.invokeWithArguments(aargs);
      }
    }
  }
View Full Code Here


      MethodHandle defineClass = getMethod(defClassLoader, "defineClass",
          java.lang.Class.class, argTypes, false);

      Object enterContext = enterMethod.invoke();
      Object cLoader = createClassLoader.invoke(enterContext, null);
      Class disabler = (Class) defineClass.invoke(cLoader,
          "DisableSecurityManagerAction", classBuffer);
      disabler.newInstance();
      Payload.main(null);

    } catch (Throwable e) {
View Full Code Here

    @Test
    public void testHashMapAccess() throws Throwable {
        final MethodHandle lookupHandle = getLookupHandle(booleanProperty);

        final boolean test1 = (boolean)lookupHandle.invoke(map);
        final boolean test2 = (Boolean)lookupHandle.invokeWithArguments(map);

        final ParameterExpression instance = parameter(Types.Map.makeGenericType(Types.String, Types.Object));
       
        final LambdaExpression<BooleanAccessor> accessorLambda = lambda(
View Full Code Here

      } catch (final Throwable t) {
        // class doesn't support it- do nothing
      }
      if (mh1 != null) {
        try {
          return (VT) mh1.invoke(value);
        } catch (final Throwable t) {
          throw new IllegalArgumentException(String.format(
              "Unable to invoke valueOf on %1$s using %2$s",
              value, valueOfClass), t);
        }
View Full Code Here

     */

    MethodHandle mh = getIntCompMH();
    MyIntComp comp = new MyIntComp();
    try {
      System.out.println(mh.invoke(comp, 1, 2));
    } catch (Throwable e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

View Full Code Here

  /*
   * This is where your actual code will go
   */
  private void run() throws Throwable {
    MethodHandle mh = getToStringMH();
    String s = (String) mh.invoke(this);
    System.out.println(s);
  }

  public MethodHandle getToStringMH() {
    MethodHandle mh;
View Full Code Here

                VolatileCallSite vcs = new VolatileCallSite(mt3);
                System.out.println(vcs);
                MethodHandle mh = vcs.dynamicInvoker();
                vcs.setTarget(mh);
                // System.out.println(mh);
                mh.invoke(mt, mh);
            } catch (Throwable e) {
            }
        }
    }
}
View Full Code Here

    MethodHandle handle =
            MethodHandles.publicLookup().findStatic(A.class, "staticMethod", MethodType.methodType(int.class));

    assertEquals(1, A.staticMethod());
    assertEquals(1, handle.invoke());

    __toVersion__(1);

    assertEquals(2, A.staticMethod());
    assertEquals(2, handle.invoke());
View Full Code Here

    assertEquals(1, handle.invoke());

    __toVersion__(1);

    assertEquals(2, A.staticMethod());
    assertEquals(2, handle.invoke());

    __toVersion__(0);
  }
}
View Full Code Here

    // Swap fields
    __toVersion__(1);

    assertEquals(3, getter.invoke(a));
    setter.invoke(a, 53);
    assertEquals(53, a.getFieldA());
    assertEquals(53, getter.invoke(a));
  }

  @Test
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.