本文整理汇总了Java中org.mozilla.classfile.ClassFileWriter.addPush方法的典型用法代码示例。如果您正苦于以下问题:Java ClassFileWriter.addPush方法的具体用法?Java ClassFileWriter.addPush怎么用?Java ClassFileWriter.addPush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.classfile.ClassFileWriter
的用法示例。
在下文中一共展示了ClassFileWriter.addPush方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mozillaClassFileHelloWorld
import org.mozilla.classfile.ClassFileWriter; //导入方法依赖的package包/类
static byte[] mozillaClassFileHelloWorld() {
ClassFileWriter c = new ClassFileWriter("HelloWorld",
"java/lang/Object", "HelloWorld.java");
c.startMethod("<init>", "()V", ClassFileWriter.ACC_PUBLIC);
c.addLoadThis();
c.addInvoke(ByteCode.INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
c.add(ByteCode.RETURN);
c.stopMethod((short) 1);
c.startMethod(
"main",
"()V",
(short) (ClassFileWriter.ACC_PUBLIC | ClassFileWriter.ACC_STATIC));
c.add(ByteCode.GETSTATIC, "java/lang/System", "out",
"Ljava/io/PrintStream;");
c.addPush("Hello world!");
c.addInvoke(ByteCode.INVOKEVIRTUAL, "java/io/PrintStream", "println",
"(Ljava/lang/String;)V");
c.add(ByteCode.RETURN);
c.stopMethod((short) 1);
return c.toByteArray();
}
示例2: mozillaClassFileHelloWorld
import org.mozilla.classfile.ClassFileWriter; //导入方法依赖的package包/类
static byte[] mozillaClassFileHelloWorld() {
ClassFileWriter c = new ClassFileWriter("HelloWorld",
"java/lang/Object",
"HelloWorld.java");
c.startMethod("<init>", "()V", ClassFileWriter.ACC_PUBLIC);
c.addLoadThis();
c.addInvoke(ByteCode.INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
c.add(ByteCode.RETURN);
c.stopMethod((short) 1);
c.startMethod("main",
"()V",
(short) (ClassFileWriter.ACC_PUBLIC | ClassFileWriter.ACC_STATIC));
c.add(ByteCode.GETSTATIC,
"java/lang/System",
"out",
"Ljava/io/PrintStream;");
c.addPush("Hello world!");
c.addInvoke(ByteCode.INVOKEVIRTUAL,
"java/io/PrintStream",
"println",
"(Ljava/lang/String;)V");
c.add(ByteCode.RETURN);
c.stopMethod((short) 1);
return c.toByteArray();
}