add getDeclaringClassFile()

This commit is contained in:
Volker Berlin 2018-03-20 20:30:57 +01:00
parent f2efc5aafd
commit 0803c290c5
2 changed files with 229 additions and 221 deletions

View File

@ -182,7 +182,7 @@ public class ClassFile {
private MethodInfo[] readMethods() throws IOException {
MethodInfo[] methods = new MethodInfo[input.readUnsignedShort()];
for( int i = 0; i < methods.length; i++ ) {
methods[i] = new MethodInfo( input, constantPool );
methods[i] = new MethodInfo( input, constantPool, this );
}
return methods;
}

View File

@ -40,6 +40,8 @@ public class MethodInfo {
private Exceptions exceptions;
private ClassFile classFile;
/**
* Read the method_info structure
* http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.6
@ -47,14 +49,20 @@ public class MethodInfo {
*
* @param input
* @param constantPool
* @param classFile the declaring class file
* @throws IOException
*/
MethodInfo( DataInputStream input, ConstantPool constantPool ) throws IOException {
MethodInfo( DataInputStream input, ConstantPool constantPool, ClassFile classFile ) throws IOException {
this.accessFlags = input.readUnsignedShort();
this.name = (String)constantPool.get( input.readUnsignedShort() );
this.description = (String)constantPool.get( input.readUnsignedShort() );
this.constantPool = constantPool;
this.attributes = new Attributes( input, constantPool );
this.classFile = classFile;
}
public ClassFile getDeclaringClassFile() {
return classFile;
}
/**