Simon Kitching wrote:.
* Class.getName returns strings that have been interned. I don't think this is explicitly required by the java specs but is certainly true for Sun's JVM and seems likely to be done by any sensible JVM.
You definitely make some good arguments, but this one is not neccesarily true. In fact, I'd argue a JVM that interns every class' name (even if only on demand) is potentially wasting a bunch of heap space. I.e., is there something special about class names which means they should be treated differently from any other String randomly created and used in a Java application? (rhetorical question) Otherwise, why not intern all Strings? Etc. In any case, to provide two concrete counter-examples: $ cat > zz.java public class zz { public static void main(String[] args) { zz z = new zz(); System.out.println(z.getClass().getName() == "zz"); } } $ javac zz.java $ java zz true $ jc -Xint zz false $ jamvm zz false On the other hand, comparing reference equality is very low cost, so it seems like adding "==" to equals() might make good sense. Of course, the "real" answer lies in empirical testing (something I can't claim to have done). -Archie __________________________________________________________________________ Archie Cobbs * CTO, Awarix * http://www.awarix.com _______________________________________________ Classpath mailing list Classpath@gnu.org http://lists.gnu.org/mailman/listinfo/classpath