This is the mail archive of the mailing list for the Kawa project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Interfaces in ClassType

This is a proposal for a patch in ClassType.
I changed getInterfaces so that it looks for implemented interfaces in the
reflectClass if it exists and interfaces is null (just like getSuperClass
does). I had a doubt with the semantics of the interfaces field, but I
assume it is the list of *declared* interfaces, not all the interfaces
implemented by this class. When writing a classType, this is what we need at
least (and I just realized this is just what Class.getInterfaces gives us,
so everything's fine).
Since a class with no declared interface will have a zero-length, non-null
interfaces array, the lookup is made only once.

2000-02-01  Daniel Bonniot  <>

        * (getInterfaces): Added use of reflect class

diff -u -r1.27
---      2000/01/24 06:48:50     1.27
+++      2000/02/01 20:14:54
@@ -125,7 +125,24 @@
     return superClass;

-  public ClassType[] getInterfaces() { return interfaces; }
+  /**
+   * @return the interfaces this class declared to implement
+   * (not those inherited from its superclass/superinterfaces).
+   */
+  public ClassType[] getInterfaces()

+    if (interfaces==null && reflectClass!=null)
+      {
+       Class[] reflectInterfaces = reflectClass.getInterfaces();
+       interfaces = new ClassType[reflectInterfaces.length];
+       for (int i=0; i<reflectInterfaces.length; i++)
+         interfaces[i] = (ClassType) make(reflectInterfaces[i]);
+      }
+    return interfaces;
+  }

   public String getNameOrSignature() { return getName(); }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]