forked from onlyliuxin/coding2017
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gongxun
committed
Apr 21, 2017
1 parent
fa6590f
commit ca83f60
Showing
8 changed files
with
117 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package print; | ||
|
||
import clz.ClassFile; | ||
import jvm_1.ClassFileLoader; | ||
|
||
/** | ||
* Created by gongxun on 2017/4/21. | ||
*/ | ||
public class ClassFilePrinter { | ||
ClassFile clzFile = null; | ||
public ClassFilePrinter(ClassFile clzFile){ | ||
this.clzFile = clzFile; | ||
} | ||
|
||
public void print(){ | ||
|
||
if(clzFile.getAccessFlag().isPublicClass()){ | ||
System.out.println("Access flag : public "); | ||
} | ||
System.out.println("Class Name:"+ clzFile.getClassName()); | ||
|
||
System.out.println("Super Class Name:"+ clzFile.getSuperClassName()); | ||
|
||
System.out.println("minor version:" + clzFile.getMinorVersion()); | ||
|
||
System.out.println("major version:" + clzFile.getMinorVersion()); | ||
|
||
ConstantPoolPrinter cnstPoolPrinter = new ConstantPoolPrinter(clzFile.getConstantPool()); | ||
cnstPoolPrinter.print(); | ||
|
||
|
||
|
||
|
||
} | ||
|
||
public static void main(String[] args){ | ||
String path = "C:\\Users\\liuxin\\git\\coding2017\\liuxin\\mini-jvm\\bin"; | ||
ClassFileLoader loader = new ClassFileLoader(); | ||
loader.addClassPath(path); | ||
String className = "com.coderising.jvm.test.EmployeeV1"; | ||
|
||
ClassFile clzFile = loader.loadClass(className); | ||
|
||
ClassFilePrinter printer = new ClassFilePrinter(clzFile); | ||
|
||
printer.print(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package print; | ||
|
||
import constant.*; | ||
|
||
/** | ||
* Created by gongxun on 2017/4/21. | ||
*/ | ||
public class ConstantPoolPrinter { | ||
ConstantPool pool; | ||
ConstantPoolPrinter(ConstantPool pool){ | ||
this.pool = pool; | ||
} | ||
public void print(){ | ||
System.out.println("Constant Pool:"); | ||
|
||
ConstantInfo.Visitor visitor = new ConstantInfo.Visitor() { | ||
@Override | ||
public void visitClassInfo(ClassInfo info) { | ||
|
||
} | ||
|
||
@Override | ||
public void visitFieldRef(FieldRefInfo info) { | ||
|
||
} | ||
|
||
@Override | ||
public void visitMethodRef(MethodRefInfo info) { | ||
|
||
} | ||
|
||
@Override | ||
public void visitNameAndType(NameAndTypeInfo info) { | ||
|
||
} | ||
|
||
@Override | ||
public void visitString(StringInfo info) { | ||
|
||
} | ||
|
||
@Override | ||
public void visistUTF8(UTF8Info info) { | ||
|
||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,5 @@ public String getUTF8String(int index){ | |
public Object getSize() { | ||
return this.constantInfos.size() -1; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ public int getType() { | |
public void accept(Visitor visitor) { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters