Wiki Markup |
---|
In a Java Virtual Machine (JVM), a class is identified by its fully qualified class name and its class loader. A class with the same name but a different package name is different, and a class with the same fully qualified name but which has been loaded by a different class loader is also different. "Two classes are the same class (and consequently the same type) if they are loaded by the same class loader and they have the same fully qualified name" \[[JVMSpec 1999|AA. Java References#JVMSpecBibliography#JVMSpec 99]\]. |
Sometimes it is desirable to check whether a given object has a specific class type or whether two objects have the same class type associated with them, for example, when implementing the equals()
method. If the comparison is performed incorrectly, the code might assume that the two objects are of the same class whilst they're not.
...
Wiki Markup |
---|
\[[JVMSpec 1999|AA. Java References#JVMSpecBibliography#JVMSpec 99]\] [§2.8.1 Class Names|http://java.sun.com/docs/books/jvms/second_edition/html/Concepts.doc.html] \[[Christudas 2005|AA. Java References#ChristudasBibliography#Christudas 05]\] \[[Mcgraw 1998|AA. Java References#McgrawBibliography#Mcgraw 98]\] \[[Wheeler 2003|AA. Java References#WheelerBibliography#Wheeler 03]\] [Java|http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/java.html] \[[MITRE 2009|AA. Java References#MITREBibliography#MITRE 09]\] [CWE ID 486|http://cwe.mitre.org/data/definitions/486.html] "Comparison of Classes by Name" |
...