辅导:使用java的jvm指令写程序
来源:优易学  2011-9-29 11:29:24   【优易学:中国教育考试门户网】   资料下载   IT书店
  jasmin这个工具,用它写了一个HelloWorld程序,因为使用正常的javac编译得到的class文件确定是正确的,使用jasmin估计可以设计一些非法的class文件。
  HelloWorld的代码:
  .class  public  HelloWorld
  .super  java/lang/Object
  ;specify  the  constuctor  method  for  the  Example  class
  .method  public  <init>()V
  ;just  call  Object's  constructor
  aload_0
  invokespecial  java/lang/Object/<init>()V
  return
  .end  method
  ;specify  the  "main"  method  -this  prints  "Hello  World"
  .method  public  static  main([Ljava/lang/String;)V
  ;set  limmits  used  by  this  method
  .limit  stack  2
  ;push  the  output  stream  and  the  string  "Hello  World  "  onto  the  stack
  ;then  invoke  the  println  method
  getstatic  java/lang/System/out  Ljava/io/PrintStream;
  ldc  "Hello  World!"
  invokevirtual  java/io/PrintStream/println(Ljava/lang/String;)V
  return
  .end  method
  这样看太累了,希望不忙的时候能够开发个相关的插件。

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训