當前位置: 首頁>>代碼示例>>Java>>正文


Java GeneratorAdapter.throwException方法代碼示例

本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.throwException方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.throwException方法的具體用法?Java GeneratorAdapter.throwException怎麽用?Java GeneratorAdapter.throwException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.objectweb.asm.commons.GeneratorAdapter的用法示例。


在下文中一共展示了GeneratorAdapter.throwException方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateFailedMethod

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Contract("null, null, null -> fail")
static void generateFailedMethod(ClassVisitor cv, Method interfaceMethod, String errorMessage) {
    String methodName = interfaceMethod.getName();
    String methodDescriptor = Type.getMethodDescriptor(interfaceMethod);
    MethodVisitor mv = cv.visitMethod(ACC_PUBLIC, methodName, methodDescriptor, null, null);
    GeneratorAdapter adapter = new GeneratorAdapter(mv, ACC_PUBLIC, methodName, methodDescriptor);
    adapter.visitCode();

    /* Throw exception */
    adapter.throwException(Type.getType(RuntimeException.class), errorMessage);

    /* End method generation */
    adapter.endMethod();
}
 
開發者ID:mikroskeem,項目名稱:Shuriken,代碼行數:15,代碼來源:MethodGenerator.java

示例2: writeMissingMessageWithHash

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
void writeMissingMessageWithHash(GeneratorAdapter mv, String visitedClassName) {
    mv.newInstance(INSTANT_RELOAD_EXCEPTION_TYPE);
    mv.dup();
    mv.push("int switch could not find %d in %s");
    mv.push(3);
    mv.newArray(OBJECT_TYPE);
    mv.dup();
    mv.push(0);
    visitInt();
    mv.visitMethodInsn(
            Opcodes.INVOKESTATIC,
            "java/lang/Integer",
            "valueOf",
            "(I)Ljava/lang/Integer;", false);
    mv.arrayStore(OBJECT_TYPE);
    mv.dup();
    mv.push(2);
    mv.push(visitedClassName);
    mv.arrayStore(OBJECT_TYPE);
    mv.visitMethodInsn(
            Opcodes.INVOKESTATIC,
            "java/lang/String",
            "format",
            "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", false);
    mv.invokeConstructor(INSTANT_RELOAD_EXCEPTION_TYPE,
            Method.getMethod("void <init> (String)"));
    mv.throwException();
}
 
開發者ID:meili,項目名稱:Aceso,代碼行數:29,代碼來源:IntSwitch.java

示例3: writeMissingMessageWithHash

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
 * Generates a standard error exception with message similar to:
 *
 *    String switch could not find 'equals.(Ljava/lang/Object;)Z' with hashcode 0
 *    in com/example/basic/GrandChild
 *
 * @param mv The generator adaptor used to emit the lookup switch code.
 * @param visitedClassName The abstract string trie structure.
 */
void writeMissingMessageWithHash(GeneratorAdapter mv, String visitedClassName) {
    mv.newInstance(INSTANT_RELOAD_EXCEPTION_TYPE);
    mv.dup();
    mv.push("String switch could not find '%s' with hashcode %s in %s");
    mv.push(3);
    mv.newArray(OBJECT_TYPE);
    mv.dup();
    mv.push(0);
    visitString();
    mv.arrayStore(OBJECT_TYPE);
    mv.dup();
    mv.push(1);
    visitString();
    visitHashMethod(mv);
    mv.visitMethodInsn(
            Opcodes.INVOKESTATIC,
            "java/lang/Integer",
            "valueOf",
            "(I)Ljava/lang/Integer;", false);
    mv.arrayStore(OBJECT_TYPE);
    mv.dup();
    mv.push(2);
    mv.push(visitedClassName);
    mv.arrayStore(OBJECT_TYPE);
    mv.visitMethodInsn(
            Opcodes.INVOKESTATIC,
            "java/lang/String",
            "format",
            "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", false);
    mv.invokeConstructor(INSTANT_RELOAD_EXCEPTION_TYPE,
            Method.getMethod("void <init> (String)"));
    mv.throwException();
}
 
開發者ID:dodola,項目名稱:AnoleFix,代碼行數:43,代碼來源:StringSwitch.java

示例4: emit

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
	excExpr.emit(C.EXPRESSION, objx, gen);
	gen.checkCast(THROWABLE_TYPE);
	gen.throwException();
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:6,代碼來源:Compiler.java


注:本文中的org.objectweb.asm.commons.GeneratorAdapter.throwException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。