Bug 10490 - JavaClass.instanceOf(JavaClass) broken
Summary: JavaClass.instanceOf(JavaClass) broken
Status: RESOLVED FIXED
Alias: None
Product: BCEL - Now in Jira
Classification: Unclassified
Component: Main (show other bugs)
Version: unspecified
Hardware: All Linux
: P3 major
Target Milestone: ---
Assignee: issues@commons.apache.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-04 23:09 UTC by Enver Haase
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enver Haase 2002-07-04 23:09:52 UTC
Consider:
-------
import org.apache.bcel.*;
import org.apache.bcel.classfile.*;
public class Test{
public static void main(String[] args){
 JavaClass a = Repository.lookupClass("Test");
 System.out.println(a.instanceOf(Repository.lookupClass("java.lang.Object")));
}
}
-------
This fine program tells us "false", i.e. "Test" is not derived from
"java.lang.Object". *sigh*
Comment 1 Enver Haase 2002-07-04 23:11:42 UTC
*** Bug 10269 has been marked as a duplicate of this bug. ***
Comment 2 Enver Haase 2002-07-05 11:58:14 UTC
The bug is in the CVS version of 05-Jul-2002, 13:00 CET;

Peter Schneider <schneidp@lathanda.de> reports the Test.java
program prints the correct "true" value on BCEL 5.0.
Comment 3 Enver Haase 2002-07-05 14:19:34 UTC
Confirm: 5.0 did not have this bug.
Comment 4 Peter Schneider 2002-07-05 17:27:56 UTC
I located that bug.
JavaClass#getSuperClass will never return java.lang.Object
therefore getSuperClasses() doesn't contain java.lang.Object
To fix it change getSuperclassName to getClassName

   public JavaClass getSuperClass() {
    if("java.lang.Object".equals(getSuperclassName())) {//<--------
      return null;
    }