zoukankan      html  css  js  c++  java
  • (java)如何获得一个方法(method)的行数

     

    public class Widget {
        void x(){System.out.println("I'm x
    ");}
        //comment added to create space
        void y(){System.out.println("I'm y
    ");} 
    }
    // ----------------------------------
    import javassist.ClassPool; import javassist.CtClass; import javassist.CtMethod; import javassist.NotFoundException; public class App { public static void main(String[] args) throws NotFoundException { System.out.println("Get method line number with javassist "); ClassPool pool = ClassPool.getDefault(); CtClass cc = pool.get("com.quaternion.demo.Widget"); CtMethod methodX = cc.getDeclaredMethod("x"); int xlineNumber = methodX.getMethodInfo().getLineNumber(0); System.out.println("method x is on line " + xlineNumber + " "); } }

     参考:

    http://stackoverflow.com/questions/12834887/how-to-get-the-line-number-of-a-method

     

  • 相关阅读:
    距离某天还有多久
    U3D各键值说明
    一些比较重要的函数
    U3D功能脚本备忘
    沟边
    渲染排序
    字符串转整数备录
    沟边
    U3D优化
    Unity中的四个路径
  • 原文地址:https://www.cnblogs.com/yuankui/p/3792811.html
Copyright © 2011-2022 走看看