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


Java InstructionFactory類代碼示例

本文整理匯總了Java中alt.jiapi.reflect.InstructionFactory的典型用法代碼示例。如果您正苦於以下問題:Java InstructionFactory類的具體用法?Java InstructionFactory怎麽用?Java InstructionFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: jiapiHelloWorld

import alt.jiapi.reflect.InstructionFactory; //導入依賴的package包/類
static byte[] jiapiHelloWorld() throws MethodExistsException {
    JiapiClass c = JiapiClass.createClass("HelloWorld");

    // No API to set SourceFile!

    JiapiMethod method = c.addMethod(Modifier.PUBLIC, "<init>", emptySig);
    InstructionList il = method.getInstructionList();
    InstructionFactory iFactory = il.getInstructionFactory();
    il.add(iFactory.aload(0));
    il.add(iFactory.invoke(0, "java/lang/Object", "<init>", emptySig));
    il.add(iFactory.returnMethod(method));

    method = c
            .addMethod(Modifier.PUBLIC | Modifier.STATIC, "main", mainSig);
    il = method.getInstructionList();
    iFactory = il.getInstructionFactory();
    il.add(iFactory.getField(Modifier.STATIC, "java/lang/System", "out",
            "Ljava/io/PrintStream;"));
    il.add(iFactory.pushConstant("Hello world!"));
    il.add(iFactory.invoke(0, "java/io/PrintStream", "println", printlnSig));
    il.add(iFactory.returnMethod(method));

    return c.getByteCode();
}
 
開發者ID:lrytz,項目名稱:asm-legacy-svn-clone,代碼行數:25,代碼來源:GenPerfTest.java

示例2: jiapiHelloWorld

import alt.jiapi.reflect.InstructionFactory; //導入依賴的package包/類
static byte[] jiapiHelloWorld() throws MethodExistsException {
    JiapiClass c = JiapiClass.createClass("HelloWorld");

    // No API to set SourceFile!

    JiapiMethod method = c.addMethod(Modifier.PUBLIC, "<init>", emptySig);
    InstructionList il = method.getInstructionList();
    InstructionFactory iFactory = il.getInstructionFactory();
    il.add(iFactory.aload(0));
    il.add(iFactory.invoke(0, "java/lang/Object", "<init>", emptySig));
    il.add(iFactory.returnMethod(method));

    method = c.addMethod(Modifier.PUBLIC | Modifier.STATIC, "main", mainSig);
    il = method.getInstructionList();
    iFactory = il.getInstructionFactory();
    il.add(iFactory.getField(Modifier.STATIC,
            "java/lang/System",
            "out",
            "Ljava/io/PrintStream;"));
    il.add(iFactory.pushConstant("Hello world!"));
    il.add(iFactory.invoke(0, "java/io/PrintStream", "println", printlnSig));
    il.add(iFactory.returnMethod(method));

    return c.getByteCode();
}
 
開發者ID:nxmatic,項目名稱:objectweb-asm-4.0,代碼行數:26,代碼來源:GenPerfTest.java

示例3: bcelHelloWorld

import alt.jiapi.reflect.InstructionFactory; //導入依賴的package包/類
static byte[] bcelHelloWorld() {
    ClassGen cg = new ClassGen("HelloWorld", "java/lang/Object",
            "HelloWorld.java", Constants.ACC_PUBLIC, null);

    cg.addEmptyConstructor(Constants.ACC_PUBLIC);

    ConstantPoolGen cp = cg.getConstantPool();
    org.apache.bcel.generic.InstructionList il = new org.apache.bcel.generic.InstructionList();
    org.apache.bcel.generic.InstructionFactory factory = new org.apache.bcel.generic.InstructionFactory(
            cg);

    MethodGen mg = new MethodGen(Constants.ACC_STATIC
            | Constants.ACC_PUBLIC, org.apache.bcel.generic.Type.VOID,
            new org.apache.bcel.generic.Type[] { new ArrayType(
                    org.apache.bcel.generic.Type.STRING, 1) }, null,
            "main", "HelloWorld", il, cp);
    il.append(factory.createGetStatic("java/lang/System", "out",
            printStreamT));
    il.append(new PUSH(cp, "Hello world!"));
    il.append(factory
            .createInvoke(
                    "java.io.PrintStream",
                    "println",
                    org.apache.bcel.generic.Type.VOID,
                    new org.apache.bcel.generic.Type[] { org.apache.bcel.generic.Type.STRING },
                    Constants.INVOKESPECIAL));

    mg.setMaxStack();
    cg.addMethod(mg.getMethod());

    return cg.getJavaClass().getBytes();
}
 
開發者ID:lrytz,項目名稱:asm-legacy-svn-clone,代碼行數:33,代碼來源:GenPerfTest.java

示例4: aspectjBcelHelloWorld

import alt.jiapi.reflect.InstructionFactory; //導入依賴的package包/類
static byte[] aspectjBcelHelloWorld() {
    org.aspectj.apache.bcel.generic.ClassGen cg = new org.aspectj.apache.bcel.generic.ClassGen(
            "HelloWorld", "java/lang/Object", "HelloWorld.java",
            Constants.ACC_PUBLIC, null);

    cg.addEmptyConstructor(Constants.ACC_PUBLIC);

    org.aspectj.apache.bcel.generic.ConstantPoolGen cp = cg
            .getConstantPool();
    org.aspectj.apache.bcel.generic.InstructionList il = new org.aspectj.apache.bcel.generic.InstructionList();
    org.aspectj.apache.bcel.generic.InstructionFactory factory = new org.aspectj.apache.bcel.generic.InstructionFactory(
            cg);

    org.aspectj.apache.bcel.generic.MethodGen mg = new org.aspectj.apache.bcel.generic.MethodGen(
            Constants.ACC_STATIC | Constants.ACC_PUBLIC,
            org.aspectj.apache.bcel.generic.Type.VOID,
            new org.aspectj.apache.bcel.generic.Type[] { new org.aspectj.apache.bcel.generic.ArrayType(
                    org.aspectj.apache.bcel.generic.Type.STRING, 1) },
            null, "main", "HelloWorld", il, cp);
    il.append(factory.createGetStatic("java/lang/System", "out",
            printStreamAT));
    il.append(new org.aspectj.apache.bcel.generic.PUSH(cp, "Hello world!"));
    il.append(factory
            .createInvoke(
                    "java.io.PrintStream",
                    "println",
                    org.aspectj.apache.bcel.generic.Type.VOID,
                    new org.aspectj.apache.bcel.generic.Type[] { org.aspectj.apache.bcel.generic.Type.STRING },
                    Constants.INVOKESPECIAL));

    mg.setMaxStack();
    cg.addMethod(mg.getMethod());

    return cg.getJavaClass().getBytes();
}
 
開發者ID:lrytz,項目名稱:asm-legacy-svn-clone,代碼行數:36,代碼來源:GenPerfTest.java

示例5: bcelHelloWorld

import alt.jiapi.reflect.InstructionFactory; //導入依賴的package包/類
static byte[] bcelHelloWorld() {
    ClassGen cg = new ClassGen("HelloWorld",
            "java/lang/Object",
            "HelloWorld.java",
            Constants.ACC_PUBLIC,
            null);

    cg.addEmptyConstructor(Constants.ACC_PUBLIC);

    ConstantPoolGen cp = cg.getConstantPool();
    org.apache.bcel.generic.InstructionList il = new org.apache.bcel.generic.InstructionList();
    org.apache.bcel.generic.InstructionFactory factory = new org.apache.bcel.generic.InstructionFactory(cg);

    MethodGen mg = new MethodGen(Constants.ACC_STATIC
            | Constants.ACC_PUBLIC,
            org.apache.bcel.generic.Type.VOID,
            new org.apache.bcel.generic.Type[] { new ArrayType(org.apache.bcel.generic.Type.STRING,
                    1) },
            null,
            "main",
            "HelloWorld",
            il,
            cp);
    il.append(factory.createGetStatic("java/lang/System",
            "out",
            printStreamT));
    il.append(new PUSH(cp, "Hello world!"));
    il.append(factory.createInvoke("java.io.PrintStream",
            "println",
            org.apache.bcel.generic.Type.VOID,
            new org.apache.bcel.generic.Type[] { org.apache.bcel.generic.Type.STRING },
            Constants.INVOKESPECIAL));

    mg.setMaxStack();
    cg.addMethod(mg.getMethod());

    return cg.getJavaClass().getBytes();
}
 
開發者ID:nxmatic,項目名稱:objectweb-asm-4.0,代碼行數:39,代碼來源:GenPerfTest.java

示例6: aspectjBcelHelloWorld

import alt.jiapi.reflect.InstructionFactory; //導入依賴的package包/類
static byte[] aspectjBcelHelloWorld() {
    org.aspectj.apache.bcel.generic.ClassGen cg = new org.aspectj.apache.bcel.generic.ClassGen("HelloWorld",
            "java/lang/Object",
            "HelloWorld.java",
            Constants.ACC_PUBLIC,
            null);

    cg.addEmptyConstructor(Constants.ACC_PUBLIC);

    org.aspectj.apache.bcel.generic.ConstantPoolGen cp = cg.getConstantPool();
    org.aspectj.apache.bcel.generic.InstructionList il = new org.aspectj.apache.bcel.generic.InstructionList();
    org.aspectj.apache.bcel.generic.InstructionFactory factory = new org.aspectj.apache.bcel.generic.InstructionFactory(cg);

    org.aspectj.apache.bcel.generic.MethodGen mg = new org.aspectj.apache.bcel.generic.MethodGen(Constants.ACC_STATIC
            | Constants.ACC_PUBLIC,
            org.aspectj.apache.bcel.generic.Type.VOID,
            new org.aspectj.apache.bcel.generic.Type[] { new org.aspectj.apache.bcel.generic.ArrayType(org.aspectj.apache.bcel.generic.Type.STRING,
                    1) },
            null,
            "main",
            "HelloWorld",
            il,
            cp);
    il.append(factory.createGetStatic("java/lang/System",
            "out",
            printStreamAT));
    il.append(new org.aspectj.apache.bcel.generic.PUSH(cp, "Hello world!"));
    il.append(factory.createInvoke("java.io.PrintStream",
            "println",
            org.aspectj.apache.bcel.generic.Type.VOID,
            new org.aspectj.apache.bcel.generic.Type[] { org.aspectj.apache.bcel.generic.Type.STRING },
            Constants.INVOKESPECIAL));

    mg.setMaxStack();
    cg.addMethod(mg.getMethod());

    return cg.getJavaClass().getBytes();
}
 
開發者ID:nxmatic,項目名稱:objectweb-asm-4.0,代碼行數:39,代碼來源:GenPerfTest.java


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