Details
-
Bug
-
Resolution: Obsolete
-
Major
-
None
-
EJB 3.0 RC3
-
None
-
None
Description
An equals or hashCode method in a Session bean class is ignored for the final bean objects. There seems to be some internal implementation of these two methods and it cannot be overrided.
For example:
Test.java
========
public interface Test { }
TestBean.java
============
@Stateless
public class TestBean implements Test
{
public boolean equals(Object obj)
public int hashCode()
{ return 5; }}
Client code
==========
InitialContext ctx = new InitialContext();
Test test = (Test) ctx.lookup(Test.class.getName());
if (!test.equals("anything"))
System.err.println("this is wrong");
if (test.hashCode() != 5)
System.err.println("this is also wrong");
Both of those error messages are printed, when in fact neither should be printed since the equals() method should always return true in this case, and the result of hashCode() should always be 5.