Nice/src/bossa/syntax javaMethod.nice,1.16,1.17

Artem Gr Kozarezov <[email protected]> Wed, 11 Oct 2006 12:34:57 +0000
Newsgroups gmane.comp.lang.nice.cvs
Message-ID <[email protected]>
Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17102/src/bossa/syntax

Modified Files:
	javaMethod.nice 
Log Message:
Bug 1509635; support Java5 covariant return types.

Index: javaMethod.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/javaMethod.nice,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** javaMethod.nice	18 Jun 2005 12:46:47 -0000	1.16
--- javaMethod.nice	11 Oct 2006 12:34:55 -0000	1.17
***************
*** 288,300 ****
  }
  
! ?gnu.bytecode.Method alreadyHasMethod(gnu.bytecode.ClassType c, gnu.bytecode.Method m) =
!    c.getMethod(m.getName(), m.getParameterTypes());
  
  private ?gnu.bytecode.Method findBaseMethod(gnu.bytecode.ClassType classType, gnu.bytecode.Method m)
  {
    ?gnu.bytecode.Method res = null;
- 
    /* Skips m if it was just overriden in classType
!      but declared in a superclass or superinterface.
    */
    ?gnu.bytecode.ClassType superClass = classType.getSuperclass();
--- 288,327 ----
  }
  
! ?gnu.bytecode.Method alreadyHasMethod(gnu.bytecode.ClassType c, gnu.bytecode.Method m) {
!   ?gnu.bytecode.Method res = c.getMethod(m.getName(), m.getParameterTypes());
!   if(res==null)
!     return null;
!   /* 1.5's covariant return types means we need to check return
!      types too.
!    */
!   let thisReturn = m.getReturnType(); 
!   let superReturn = res.getReturnType();
!   if(thisReturn.equals(superReturn))
!     return res;
!   return null;
! }
! private ?gnu.bytecode.Method checkInterfaces(gnu.bytecode.ClassType classType, gnu.bytecode.Method m)
! {
!   /* Check all of the interfaces of classType to see
!      if m is overriding one of them.
!    */
!   ?gnu.bytecode.Method res = null;
!   for (gnu.bytecode.ClassType itf : classType.getInterfaces())
!     {
!       res = alreadyHasMethod(itf,m);
!       if (res != null){
! 	return res;
!       }
!     }
!   return null;
! }
  
  private ?gnu.bytecode.Method findBaseMethod(gnu.bytecode.ClassType classType, gnu.bytecode.Method m)
  {
    ?gnu.bytecode.Method res = null;
    /* Skips m if it was just overriden in classType
!      but declared in a superclass or superinterface
!      and the overriding method did not change the return
!      type.
    */
    ?gnu.bytecode.ClassType superClass = classType.getSuperclass();
***************
*** 307,322 ****
    if (superClass == null)
      superClass = gnu.bytecode.Type.pointer_type;
! 
!   res = alreadyHasMethod(superClass,m);
!   if (res != null)
!     return res;
! 
!   for (gnu.bytecode.ClassType itf : classType.getInterfaces())
!     {
!        res = alreadyHasMethod(itf,m);
!        if (res != null)
!          return res;
      }
! 
    return null;
  }
--- 334,354 ----
    if (superClass == null)
      superClass = gnu.bytecode.Type.pointer_type;
!   /* Traverse the parents. There is probably a better way to do this
!      rather than seaching the whole set every time. 
!    */
!   for(;superClass!=null; superClass = superClass.getSuperclass()){ 
!     res = checkInterfaces(superClass,m);
!     if (res != null){
!       return res;
      }
!     res = alreadyHasMethod(superClass,m);
!     if (res != null){
!       return res;
!     }
!   }
!   res = checkInterfaces(classType,m);
!   if (res != null){
!     return res;
!   }
    return null;
  }


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642