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() . 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
Source File: CallSiteDepContextTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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 File: BooleanType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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 3
Source File: BootstrapMethodErrorTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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 4
Source File: IntType.java    From jdk8u60 with 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 5
Source File: IntType.java    From jdk8u60 with 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 6
Source File: IntType.java    From hottub with 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 7
Source File: IntType.java    From hottub with 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 8
Source File: LongType.java    From TencentKona-8 with 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 9
Source File: BootstrapMethodErrorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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 10
Source File: IntType.java    From TencentKona-8 with 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 File: BooleanType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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 12
Source File: IntType.java    From openjdk-jdk8u with 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(IADD);
    } else {
        method.visitInvokeDynamicInsn("iadd", "(II)I", MATHBOOTSTRAP, programPoint);
    }
    return INT;
}
 
Example 13
Source File: LongType.java    From hottub with 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 14
Source File: InvokeDynamicInsnNode.java    From Bytecoder with 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 15
Source File: InvokeDynamicInsnNode.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(mv);
}
 
Example 16
Source File: InvokeDynamicInsnNode.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(mv);
}
 
Example 17
Source File: InvokeDynamicInsnNode.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(mv);
}
 
Example 18
Source File: InvokeDynamicInsnNode.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
}
 
Example 19
Source File: InvokeDynamicInsnNode.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(mv);
}
 
Example 20
Source File: InvokeDynamicInsnNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void accept(final MethodVisitor mv) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    acceptAnnotations(mv);
}