classfile
This commit is contained in:
parent
cacf9b8226
commit
4f24288e20
76
src/com/gabongao/jvm/classfile/AttrCode.java
Normal file
76
src/com/gabongao/jvm/classfile/AttrCode.java
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class AttrCode implements AttributeInfo {
|
||||
char maxStack, maxLocals;
|
||||
byte[] code;
|
||||
ConstantPool constantPool;
|
||||
AttributeInfo[] attributes;
|
||||
ExceptionTableEntry[] exceptionTableEntries;
|
||||
|
||||
|
||||
public AttrCode(ConstantPool constantPool) {
|
||||
this.constantPool = constantPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
maxStack = classReader.readUint16();
|
||||
maxLocals = classReader.readUint16();
|
||||
int codeLength = classReader.readUint32();
|
||||
code = classReader.readBytes(codeLength);
|
||||
exceptionTableEntries = readExceptionTable(classReader);
|
||||
attributes = ClassFile.readAttributes(classReader, constantPool);
|
||||
}
|
||||
|
||||
public ExceptionTableEntry[] readExceptionTable(ClassReader classReader) {
|
||||
char exceptionTableLength = classReader.readUint16();
|
||||
ExceptionTableEntry[] exceptionTableEntries = new ExceptionTableEntry[exceptionTableLength];
|
||||
for (int i = 0; i < exceptionTableLength; i++) {
|
||||
exceptionTableEntries[i] = new ExceptionTableEntry(classReader.readUint16(), classReader.readUint16(), classReader.readUint16(), classReader.readUint16());
|
||||
}
|
||||
return exceptionTableEntries;
|
||||
}
|
||||
|
||||
class ExceptionTableEntry {
|
||||
char startPc, endPc, handlerPc, catchType;
|
||||
|
||||
ExceptionTableEntry(char startPc, char endPc, char handlerPc, char catchType) {
|
||||
this.startPc = startPc;
|
||||
this.endPc = endPc;
|
||||
this.handlerPc = handlerPc;
|
||||
this.catchType = catchType;
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/com/gabongao/jvm/classfile/AttrConstantValue.java
Normal file
46
src/com/gabongao/jvm/classfile/AttrConstantValue.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class AttrConstantValue implements AttributeInfo {
|
||||
char constantValueIndex;
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
constantValueIndex = classReader.readUint16();
|
||||
}
|
||||
|
||||
public char getConstantValueIndex() {
|
||||
return constantValueIndex;
|
||||
}
|
||||
}
|
||||
36
src/com/gabongao/jvm/classfile/AttrDeprecated.java
Normal file
36
src/com/gabongao/jvm/classfile/AttrDeprecated.java
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class AttrDeprecated extends AttrMarker {
|
||||
}
|
||||
46
src/com/gabongao/jvm/classfile/AttrExceptions.java
Normal file
46
src/com/gabongao/jvm/classfile/AttrExceptions.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class AttrExceptions implements AttributeInfo {
|
||||
char[] exceptionIndexTable;
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
exceptionIndexTable = classReader.readUint16s();
|
||||
}
|
||||
|
||||
public char[] getExceptionIndexTable() {
|
||||
return exceptionIndexTable;
|
||||
}
|
||||
}
|
||||
71
src/com/gabongao/jvm/classfile/AttrLineNumberTable.java
Normal file
71
src/com/gabongao/jvm/classfile/AttrLineNumberTable.java
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class AttrLineNumberTable implements AttributeInfo {
|
||||
LineNumberTableEntry[] lineNumberTable;
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
char lineNumberTableLength = classReader.readUint16();
|
||||
lineNumberTable = new LineNumberTableEntry[lineNumberTableLength];
|
||||
for (int i = 0; i < lineNumberTableLength; i++) {
|
||||
lineNumberTable[i] = new LineNumberTableEntry(classReader.readUint16(), classReader.readUint16());
|
||||
}
|
||||
}
|
||||
|
||||
class LineNumberTableEntry {
|
||||
char startPc, lineNumber;
|
||||
|
||||
LineNumberTableEntry(char startPc, char lineNumber) {
|
||||
this.startPc = startPc;
|
||||
this.lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
public char getStartPc() {
|
||||
return startPc;
|
||||
}
|
||||
|
||||
public void setStartPc(char startPc) {
|
||||
this.startPc = startPc;
|
||||
}
|
||||
|
||||
public char getLineNumber() {
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
public void setLineNumber(char lineNumber) {
|
||||
this.lineNumber = lineNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
98
src/com/gabongao/jvm/classfile/AttrLocalVariableTable.java
Normal file
98
src/com/gabongao/jvm/classfile/AttrLocalVariableTable.java
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class AttrLocalVariableTable implements AttributeInfo {
|
||||
LocalVariableTableEntry[] localVariableTable;
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
char localVariableTableLength = classReader.readUint16();
|
||||
localVariableTable = new LocalVariableTableEntry[localVariableTableLength];
|
||||
for (int i = 0; i < localVariableTableLength; i++) {
|
||||
localVariableTable[i] = new LocalVariableTableEntry(classReader.readUint16(), classReader.readUint16(), classReader.readUint16(), classReader.readUint16(), classReader.readUint16());
|
||||
}
|
||||
}
|
||||
|
||||
class LocalVariableTableEntry {
|
||||
char startPc, length, nameIndex, descriptorIndex, index;
|
||||
|
||||
LocalVariableTableEntry(char startPc, char length, char nameIndex, char descriptorIndex, char index) {
|
||||
this.startPc = startPc;
|
||||
this.length = length;
|
||||
this.nameIndex = nameIndex;
|
||||
this.descriptorIndex = descriptorIndex;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public char getStartPc() {
|
||||
return startPc;
|
||||
}
|
||||
|
||||
public void setStartPc(char startPc) {
|
||||
this.startPc = startPc;
|
||||
}
|
||||
|
||||
public char getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(char length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public char getNameIndex() {
|
||||
return nameIndex;
|
||||
}
|
||||
|
||||
public void setNameIndex(char nameIndex) {
|
||||
this.nameIndex = nameIndex;
|
||||
}
|
||||
|
||||
public char getDescriptorIndex() {
|
||||
return descriptorIndex;
|
||||
}
|
||||
|
||||
public void setDescriptorIndex(char descriptorIndex) {
|
||||
this.descriptorIndex = descriptorIndex;
|
||||
}
|
||||
|
||||
public char getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(char index) {
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
40
src/com/gabongao/jvm/classfile/AttrMarker.java
Normal file
40
src/com/gabongao/jvm/classfile/AttrMarker.java
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class AttrMarker implements AttributeInfo {
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
//read nothing
|
||||
}
|
||||
}
|
||||
51
src/com/gabongao/jvm/classfile/AttrSourceFile.java
Normal file
51
src/com/gabongao/jvm/classfile/AttrSourceFile.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class AttrSourceFile implements AttributeInfo {
|
||||
ConstantPool constantPool;
|
||||
char sourceFileIndex;
|
||||
|
||||
public AttrSourceFile(ConstantPool constantPool) {
|
||||
this.constantPool = constantPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
sourceFileIndex = classReader.readUint16();
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return constantPool.getUTF8(sourceFileIndex);
|
||||
}
|
||||
}
|
||||
36
src/com/gabongao/jvm/classfile/AttrSynthetic.java
Normal file
36
src/com/gabongao/jvm/classfile/AttrSynthetic.java
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class AttrSynthetic extends AttrMarker {
|
||||
}
|
||||
49
src/com/gabongao/jvm/classfile/AttrUnparsed.java
Normal file
49
src/com/gabongao/jvm/classfile/AttrUnparsed.java
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class AttrUnparsed implements AttributeInfo {
|
||||
String name;
|
||||
int length;
|
||||
byte[] info;
|
||||
|
||||
public AttrUnparsed(String attrName, int attrlen) {
|
||||
name = attrName;
|
||||
length = attrlen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
info = classReader.readBytes(length);
|
||||
}
|
||||
}
|
||||
51
src/com/gabongao/jvm/classfile/ConstantClassInfo.java
Normal file
51
src/com/gabongao/jvm/classfile/ConstantClassInfo.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class ConstantClassInfo extends ConstantInfo {
|
||||
ConstantPool constantPool;
|
||||
char nameIndex;
|
||||
|
||||
public ConstantClassInfo(ConstantPool constantPool) {
|
||||
this.constantPool = constantPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
nameIndex = classReader.readUint16();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return constantPool.getUTF8(nameIndex);
|
||||
}
|
||||
}
|
||||
39
src/com/gabongao/jvm/classfile/ConstantFieldrefInfo.java
Normal file
39
src/com/gabongao/jvm/classfile/ConstantFieldrefInfo.java
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class ConstantFieldrefInfo extends ConstantMemberrefInfo {
|
||||
public ConstantFieldrefInfo(ConstantPool constantPool) {
|
||||
super(constantPool);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class ConstantInterfaceMemberrefInfo extends ConstantMemberrefInfo {
|
||||
public ConstantInterfaceMemberrefInfo(ConstantPool constantPool) {
|
||||
super(constantPool);
|
||||
}
|
||||
}
|
||||
62
src/com/gabongao/jvm/classfile/ConstantMemberrefInfo.java
Normal file
62
src/com/gabongao/jvm/classfile/ConstantMemberrefInfo.java
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class ConstantMemberrefInfo extends ConstantInfo {
|
||||
ConstantPool constantPool;
|
||||
char classIndex, nameAndTypeIndex;
|
||||
|
||||
public ConstantMemberrefInfo() {
|
||||
|
||||
}
|
||||
|
||||
public ConstantMemberrefInfo(ConstantPool constantPool) {
|
||||
this.constantPool = constantPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
classIndex = classReader.readUint16();
|
||||
nameAndTypeIndex = classReader.readUint16();
|
||||
}
|
||||
|
||||
public String className() {
|
||||
return constantPool.getClassName(classIndex);
|
||||
}
|
||||
|
||||
public String[] nameAndDescriptor() {
|
||||
return constantPool.getNameAndType(nameAndTypeIndex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
39
src/com/gabongao/jvm/classfile/ConstantMethodrefInfo.java
Normal file
39
src/com/gabongao/jvm/classfile/ConstantMethodrefInfo.java
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class ConstantMethodrefInfo extends ConstantMemberrefInfo {
|
||||
public ConstantMethodrefInfo(ConstantPool constantPool) {
|
||||
super(constantPool);
|
||||
}
|
||||
}
|
||||
43
src/com/gabongao/jvm/classfile/ConstantNameAndTypeInfo.java
Normal file
43
src/com/gabongao/jvm/classfile/ConstantNameAndTypeInfo.java
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class ConstantNameAndTypeInfo extends ConstantInfo {
|
||||
char nameIndex, descriptorIndex;
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
nameIndex = classReader.readUint16();
|
||||
descriptorIndex = classReader.readUint16();
|
||||
}
|
||||
}
|
||||
52
src/com/gabongao/jvm/classfile/ConstantStringInfo.java
Normal file
52
src/com/gabongao/jvm/classfile/ConstantStringInfo.java
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class ConstantStringInfo extends ConstantInfo {
|
||||
private ConstantPool constantPool;
|
||||
private char stringIndex;
|
||||
|
||||
|
||||
public ConstantStringInfo(ConstantPool constantPool) {
|
||||
this.constantPool = constantPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
stringIndex = classReader.readUint16();
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return constantPool.getUTF8(stringIndex);
|
||||
}
|
||||
}
|
||||
57
src/com/gabongao/jvm/classfile/ConstantUtf8Info.java
Normal file
57
src/com/gabongao/jvm/classfile/ConstantUtf8Info.java
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.gabongao.jvm.classfile;
|
||||
|
||||
/**
|
||||
* ┏┓ ┏┓+ +
|
||||
* ┏┛┻━━━┛┻┓ + +
|
||||
* ┃ ┃
|
||||
* ┃ ━ ┃ ++ + + +
|
||||
* ████━████ ┃+
|
||||
* ┃ ┃ +
|
||||
* ┃ ┻ ┃
|
||||
* ┃ ┃ + +
|
||||
* ┗━┓ ┏━┛
|
||||
* ┃ ┃
|
||||
* ┃ ┃ + + + +
|
||||
* ┃ ┃ Code is far away from bug with the animal protecting
|
||||
* ┃ ┃ + 神兽保佑,代码无bug
|
||||
* ┃ ┃
|
||||
* ┃ ┃ +
|
||||
* ┃ ┗━━━┓ + +
|
||||
* ┃ ┣┓
|
||||
* ┃ ┏┛
|
||||
* ┗┓┓┏━┳┓┏┛ + + + +
|
||||
* ┃┫┫ ┃┫┫
|
||||
* ┗┻┛ ┗┻┛+ + + +
|
||||
* Created by Imgaojp on 2017/2/18.
|
||||
*/
|
||||
public class ConstantUtf8Info extends ConstantInfo {
|
||||
private String string;
|
||||
|
||||
@Override
|
||||
public void readInfo(ClassReader classReader) {
|
||||
int length = classReader.readUint16();
|
||||
byte[] bytes = classReader.readBytes(length);
|
||||
string = decodeMUTF8(bytes);
|
||||
}
|
||||
|
||||
private String decodeMUTF8(byte[] bytes) {
|
||||
try {
|
||||
return new String(bytes, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user