本文整理汇总了Java中alt.jiapi.reflect.InstructionList类的典型用法代码示例。如果您正苦于以下问题:Java InstructionList类的具体用法?Java InstructionList怎么用?Java InstructionList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InstructionList类属于alt.jiapi.reflect包,在下文中一共展示了InstructionList类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jiapiHelloWorld
import alt.jiapi.reflect.InstructionList; //导入依赖的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();
}
示例2: jiapiHelloWorld
import alt.jiapi.reflect.InstructionList; //导入依赖的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();
}
示例3: bcelHelloWorld
import alt.jiapi.reflect.InstructionList; //导入依赖的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();
}
示例4: aspectjBcelHelloWorld
import alt.jiapi.reflect.InstructionList; //导入依赖的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();
}
示例5: bcelHelloWorld
import alt.jiapi.reflect.InstructionList; //导入依赖的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();
}
示例6: aspectjBcelHelloWorld
import alt.jiapi.reflect.InstructionList; //导入依赖的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();
}