Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Wiki Markup
In a Java Virtual Machine (JVM), "Two classes are the same class (and  In a Java Virtual Machine (JVM), a class is identified by itsconsequently the same type) if they are loaded by the same class loader and they have the same fully qualified class name" and its class loader\[[JVMSpec 1999|AA. Bibliography#JVMSpec 99]\]. 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. Bibliography#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
\[[Christudas 2005|AA. Bibliography#Christudas 05]\]
\[[JVMSpec 1999|AA. Bibliography#JVMSpec 99]\] [§2§2.8.1 Class Names|http://java.sun.com/docs/books/jvms/second_edition/html/Concepts.doc.html]
\[[Mcgraw 1998|AA. Bibliography#Mcgraw 98]\]
\[[MITRE 2009|AA. Bibliography#MITRE 09]\] [CWE ID 486|http://cwe.mitre.org/data/definitions/486.html] "Comparison of Classes by Name"
\[[Wheeler 2003|AA. Bibliography#Wheeler 03]\] [Java|http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/java.html]

...