//System.out.println( "Verifying " + bcelClass.getClassName() );
// Get classes
ClassParser cp = new ClassParser( new ByteArrayInputStream(originalCode), targetClass.getName().replace( '.', '/') );
JavaClass originalClass;
try {
originalClass = cp.parse();
}
catch (java.io.IOException e) {
throw new RuntimeException( e.getMessage() );
}
JavaClass newClass = clGen.getJavaClass();
// Check class name
if( ! originalClass.getClassName().equals( newClass.getClassName() ) ) {
System.out.println( "Class name changed ( old: " + originalClass.getClassName() + ", new: " + newClass.getClassName() + ")" );
retval = false;
}
// Check class modifiers (access flags)
if( originalClass.getAccessFlags() != newClass.getAccessFlags() ) {
System.out.println( "Class modifiers changed (old: " + originalClass.getAccessFlags() + ", new: " + newClass.getAccessFlags() + ")" );
retval = false;
}
// Methods
org.apache.bcel.classfile.Method oldMethods[] = originalClass.getMethods();
org.apache.bcel.classfile.Method newMethods[] = newClass.getMethods();
int oldMethodsLength = oldMethods.length;
// number of methods
if( oldMethodsLength != newMethods.length ) {
System.out.println( "Number of methods changed (old: " + oldMethodsLength + ", new: " + newMethods.length + ")" );
retval = false;
}
else {
for( int i = 0; i < oldMethodsLength; i++ ) {
org.apache.bcel.classfile.Method oldMeth = oldMethods[i];
org.apache.bcel.classfile.Method newMeth = newMethods[i];
// method name
String oldMName = oldMeth.getName();
if( ! oldMName.equals( newMeth.getName() ) ) {
System.out.println( "Method name changed (old: " + oldMName + ", new: " + newMeth.getName() + ")" );
retval = false;
}
// method modifiers
if( oldMeth.getAccessFlags() != newMeth.getAccessFlags() ) {
System.out.println( "Method modifiers changed for" + oldMName );
retval = false;
}
// signature
if( ! oldMeth.getSignature().equals( newMeth.getSignature() ) ) {
System.out.println( "Method signature changed for " + oldMName );
retval = false;
}
}
}
// Check for JVMDI_ERROR_SCHEMA_CHANGE... (Fields)
org.apache.bcel.classfile.Field newFields[] = newClass.getFields();
org.apache.bcel.classfile.Field oldFields[] = originalClass.getFields();
int newFieldsLength = newFields.length;
if( newFieldsLength != oldFields.length ) {
System.out.println( "Number of fields changed (old " + oldFields.length + ", new " + newFieldsLength + ")" );
retval = false;