Updated: 3/13/2003; 2:20:19 PM.
IKVM.NET Weblog
The development of a Java VM for .NET
        

Thursday, August 22, 2002
This weblog has moved to http://weblog.ikvm.net/

Stuart commented:

You can also optimize the test away (in the other direction) if it's known at compile time that the object *is* a string. Or is that unnecessary since String provides its own GetHashCode implementation that will be invokespecialed already since it's a final class (or whatever the CLR equivalent of final is)?

When you compile the Java code "foo".hashCode() it will be compiled as an invokevirtual java/lang/String/hashCode()I. When IK.VM.NET tries to compile this, it looks up the hashCode() method on String and finds that it should redirect to the static StringHelper.hashCode() method. So that's automatic. It is possible to create bytecode that does an invokevirtual java/lang/Object/hashCode() on a string reference, but Java compilers won't do this, so this is hardly worth optimizing.


11:49:57 AM    Comments

© Copyright 2003 Jeroen Frijters.
 
August 2002
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Jul   Sep