8 Replies Latest reply on Nov 3, 2008 9:04 AM by Ales Justin

    JBMDR-51; Annotation equals is completely broken

    Ales Justin Master

      This AnnotationProxy::doEquals looks like it misses a lot of logic. ;-)

       private Object doEquals(Object proxy, Object obj)
       {
       if (obj == proxy)
       return Boolean.TRUE;
       if (obj == null)
       return Boolean.FALSE;
      
       Class[] intfs = proxy.getClass().getInterfaces();
       if (intfs[0].isAssignableFrom(obj.getClass()) == false)
       {
       return Boolean.FALSE;
       }
       try
       {
       Proxy.getInvocationHandler(obj);
       }
       catch (Exception ex)
       {
       return Boolean.FALSE;
       }
       return Boolean.TRUE;
       }
      

      And that last attempt is wrong,
      e.g. this is totally legit, but would also fail:
       String expr = "@"+Name.class.getName() + "(type=\"type\",subtype=\"subtype\")";
       Name n0 = (Name) AnnotationCreator.createAnnotation(expr, Name.class);
       Name n2 = new NameImpl("type", "subtype");
       assertEquals(n0, n2); // FAILURE -- n2 has no InvocationHandler
      


      I'll fix the impl, but what to do with release, since we already did 2.0.0.GA?
      2.0.1.GA?