Java Code Examples for jdk.internal.org.objectweb.asm.MethodVisitor#visitInvokeDynamicInsn()

The following examples show how to use jdk.internal.org.objectweb.asm.MethodVisitor#visitInvokeDynamicInsn() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
static byte[] getClassFile(String suffix) {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    MethodVisitor mv;
    cw.visit(52, ACC_PUBLIC | ACC_SUPER, CLASS_NAME + suffix, null, "java/lang/Object", null);
    {
        mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, METHOD_NAME, TYPE.toMethodDescriptorString(), null, null);
        mv.visitCode();
        Handle bsm = new Handle(H_INVOKESTATIC,
                CallSiteDepContextTest.class.getName().replace(".", "/"),
                "bootstrap",
                bsmMH.type().toMethodDescriptorString());
        mv.visitInvokeDynamicInsn("methodName", TYPE.toMethodDescriptorString(), bsm);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
}
 
Example 2
Source Project: hottub   File: IntType.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Type mul(final MethodVisitor method, final int programPoint) {
    if(programPoint == INVALID_PROGRAM_POINT) {
        method.visitInsn(IMUL);
    } else {
        method.visitInvokeDynamicInsn("imul", "(II)I", MATHBOOTSTRAP, programPoint);
    }
    return INT;
}
 
Example 3
Source Project: hottub   File: LongType.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Type add(final MethodVisitor method, final int programPoint) {
    if(programPoint == INVALID_PROGRAM_POINT) {
        method.visitInsn(LADD);
    } else {
        method.visitInvokeDynamicInsn("ladd", "(JJ)J", MATHBOOTSTRAP, programPoint);
    }
    return LONG;
}
 
Example 4
@Override
public Type add(final MethodVisitor method, final int programPoint) {
    if(programPoint == INVALID_PROGRAM_POINT) {
        method.visitInsn(IADD);
    } else {
        method.visitInvokeDynamicInsn("iadd", "(II)I", MATHBOOTSTRAP, programPoint);
    }
    return INT;
}
 
Example 5
@Override
public Type add(final MethodVisitor method, final int programPoint) {
    // Adding booleans in JavaScript is perfectly valid, they add as if false=0 and true=1
    if(programPoint == INVALID_PROGRAM_POINT) {
        method.visitInsn(IADD);
    } else {
        method.visitInvokeDynamicInsn("iadd", "(II)I", MATHBOOTSTRAP, programPoint);
    }
    return INT;
}
 
Example 6
@Override
public Type div(final MethodVisitor method, final int programPoint) {
    if (programPoint == INVALID_PROGRAM_POINT) {
        JSType.DIV_ZERO.invoke(method);
    } else {
        method.visitInvokeDynamicInsn("idiv", "(II)I", MATHBOOTSTRAP, programPoint);
    }
    return INT;
}
 
Example 7
void defineIndyCallingClass(ClassWriter cw) {
    cw.visit(52, ACC_SUPER | ACC_PUBLIC, INDY_CALLER_CLASS_NAME, null, "java/lang/Object", null);
    MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "invoke", "()V", null, null);
    mv.visitCode();
    Handle h = new Handle(H_INVOKESTATIC,
                          BOOTSTRAP_METHOD_CLASS_NAME, BOOTSTRAP_METHOD_NAME,
                          BOOTSTRAP_METHOD_DESC, false);
    mv.visitInvokeDynamicInsn(BOOTSTRAP_METHOD_CLASS_NAME, "()V", h);
    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    cw.visitEnd();
}
 
Example 8
@Override
public Type add(final MethodVisitor method, final int programPoint) {
    if(programPoint == INVALID_PROGRAM_POINT) {
        method.visitInsn(LADD);
    } else {
        method.visitInvokeDynamicInsn("ladd", "(JJ)J", MATHBOOTSTRAP, programPoint);
    }
    return LONG;
}
 
Example 9
@Override
public Type add(final MethodVisitor method, final int programPoint) {
    // Adding booleans in JavaScript is perfectly valid, they add as if false=0 and true=1
    if(programPoint == INVALID_PROGRAM_POINT) {
        method.visitInsn(IADD);
    } else {
        method.visitInvokeDynamicInsn("iadd", "(II)I", MATHBOOTSTRAP, programPoint);
    }
    return INT;
}
 
Example 10
Source Project: hottub   File: IntType.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Type div(final MethodVisitor method, final int programPoint) {
    if (programPoint == INVALID_PROGRAM_POINT) {
        JSType.DIV_ZERO.invoke(method);
    } else {
        method.visitInvokeDynamicInsn("idiv", "(II)I", MATHBOOTSTRAP, programPoint);
    }
    return INT;
}
 
Example 11
Source Project: jdk8u60   File: IntType.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Type sub(final MethodVisitor method, final int programPoint) {
    if(programPoint == INVALID_PROGRAM_POINT) {
        method.visitInsn(ISUB);
    } else {
        method.visitInvokeDynamicInsn("isub", "(II)I", MATHBOOTSTRAP, programPoint);
    }
    return INT;
}
 
Example 12
Source Project: jdk8u60   File: IntType.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Type neg(final MethodVisitor method, final int programPoint) {
    if(programPoint == INVALID_PROGRAM_POINT) {
        method.visitInsn(INEG);
    } else {
        method.visitInvokeDynamicInsn("ineg", "(I)I", MATHBOOTSTRAP, programPoint);
    }
    return INT;
}
 
Example 13
private byte[] loadClassData(String name) throws Exception {
  ClassWriter cw = new ClassWriter(0);
  MethodVisitor mv;

  if (name.equals("C")) {
    cw.visit(52, ACC_SUPER | ACC_PUBLIC, "C", null, "java/lang/Object", null);
    {
      mv = cw.visitMethod(ACC_PRIVATE | ACC_STATIC, "m", "()V", null, null);
      mv.visitCode();
      mv.visitInsn(RETURN);
      mv.visitMaxs(0, 1);
      mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
  } else if (name.equals("Exec")) {
    cw.visit(52, ACC_SUPER | ACC_PUBLIC, "Exec", null, "java/lang/Object", null);
    {
      mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "invokeRef", "()V", null, null);
      mv.visitCode();
      Handle h = new Handle(H_INVOKESTATIC, "C", "m", "()V");
      mv.visitInvokeDynamicInsn("C", "()V", h);
      mv.visitInsn(RETURN);
      mv.visitMaxs(0, 0);
      mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
  }
  return null;
}
 
Example 14
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(mv);
}
 
Example 15
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(mv);
}
 
Example 16
Source Project: Bytecoder   File: InvokeDynamicInsnNode.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void accept(final MethodVisitor methodVisitor) {
    methodVisitor.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(methodVisitor);
}
 
Example 17
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(mv);
}
 
Example 18
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(mv);
}
 
Example 19
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
}
 
Example 20
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(mv);
}