[prev in list] [next in list] [prev in thread] [next in thread]
List: bcel-user
Subject: AW: VerifyError after modifing a Class
From: "Pasch, Thomas (ACTGRO)" <extern.thomas.pasch () volkswagen ! de>
Date: 2002-06-13 7:27:06
[Download RAW message or body]
Dear Markus,
thank you for support. The error though, is still there. It
seem to depend on whether there are (more) methods
after the (static) main.
I attached a class to test the problem with.
Kind regards,
Thomas
/*
* BcelVerifyError.java
*/
import org.apache.bcel.*;
import org.apache.bcel.classfile.*;
import org.apache.bcel.generic.*;
import org.apache.bcel.util.*;
public class BcelVerifyError {
private Object trash2;
private BcelVerifyError(int dummy) {
}
private int getDummy() {
return 1;
}
public Object setDummy(Object o) {
return o;
}
public static void main(String args[]) throws Exception {
// read in Class
Class clazz = Class.forName("BcelVerifyError");
String name = clazz.getName();
JavaClass jclass = Repository.lookupClass(name);
// prepare modification
ClassGen classGen = new ClassGen(jclass);
ConstantPoolGen poolGen = classGen.getConstantPool();
InstructionFactory instr = new InstructionFactory(classGen,
poolGen);
// modify
classGen.addEmptyConstructor(Constants.ACC_PUBLIC);
classGen.setClassName("Modified");
// dump modified Class
JavaClass modifiedClass = classGen.getJavaClass();
modifiedClass.dump("D:/dl80pas/java.projects/try/Modified.class");
// read in modified Class
Class modClass = Class.forName("Modified");
// list methods
java.lang.reflect.Method[] methods;
methods = modClass.getDeclaredMethods();
java.lang.reflect.Method method;
for (int i = 0; i < methods.length; ++i) {
method = methods[i];
System.out.println("method: " + method.getName());
}
}
/**
* Without this two methods the Class will be all right...
*/
public void setObject(Object trash) {
trash2 = trash;
}
public Object getObject() {
return trash2;
}
}
--
To unsubscribe, e-mail: <mailto:bcel-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:bcel-user-help@jakarta.apache.org>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic