BTW:不要忘記將後面download的jar導過來
結果會打在Console裡象這樣
Loading netblogjavaxmpCVSClass
Loaded netblogjavaxmpCVSClass
Found java source file in C:\Documents and Settings\hut\workspace\AccountMethodLocation / net / blogjava / xmp / CVSClassjava
Parsing netblogjavaxmpCVSClass
Parsed a common class and brackets can matched the methods correctly
MethodParseEngine have searched methods(Including constructors)
Completed :Spend seconds to parse this file
[ public CVSClass(String) locate between and
public CVSMethod[] getCvsMethodArray() locate between and
public CVSConstructor[] getCvsConstructorArray() locate between and
public Set getMethodSet() locate between and
public Set getConstructorSet() locate between and
public String getClasspath() locate between and
public List getMethodList() locate between and
public String getClassName() locate between and
public boolean equals(Object) locate between and
public int hashCode() locate between and
]
我是怎麼做的
用java反射拿出所有的的類的構造函數和方法
讀java源文件通過匹配左右括號來匹配方法並記錄出合適的位置
存在的問題
到目前為止這個小程序至少不能分析它自己的主類CVSParseMethod(很多Exceptions) 因為這個類裡面定義的一些String中含用 { }而導致匹配的時候出錯呵呵但是我保證它應該在>%的概率下正常工作
[] []
From:http://tw.wingwit.com/Article/program/Java/ky/201311/29238.html