Menu

#2 Interpreter Identity

None
closed
nobody
None
5
2018-08-02
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

  • nickl-

    nickl- - 2018-08-02
    • status: open --> closed
    • Group: -->
     
  • nickl-

    nickl- - 2018-08-02

    Ticket has been migrated to github.
    Please follow up on this over here: https://github.com/beanshell/beanshell/issues/482

     

Log in to post a comment.