Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#2 Interpreter Identity

open
nobody
None
5
2005-08-09
2005-08-09
Anonymous
No

Hi.

I am using beanshell 2.0b4. I'm using the
interpreter's "getIntergace(Class)" method to obtain an
object implementing a certain interface, whose methods
are scripted.

I found the following problem with the objects returned
by Iterpreter.getIntergace(Class):

Executable rule = compiler.compileRule(br);
System.out.println("equals?" + rule.equals(rule));
System.out.println("toString?" + rule.toString().equals
(rule.toString()));

When I execute this, I find that rule.equals(rule) always
returns false.
I came to this because I was having trouble using those
objects as keys in a hashtable. They never appeared to
be in the hashtable, and I diagnosed it down to
the .equals() method of those objects.

Funny thing is that rule.toString().equals(rule.toString())
does indeed return true. In the mean time I'm planning
to use rule.toString() instad of rule, as keys for the
hashtable. However, I fear that maybe the hashcode will
change in time. żis this a bug, or is this indeed inteded?

thank you for your time

Discussion