This is the mail archive of the
kawa@sourceware.cygnus.com
mailing list for the Kawa project.
Interfaces in ClassType
- To: "Kawa" <kawa at sourceware dot cygnus dot com>
- Subject: Interfaces in ClassType
- From: "Daniel Bonniot" <bonniot at cma dot ensmp dot fr>
- Date: Tue, 1 Feb 2000 21:19:42 +0100
- Organization: d.bonniot@mail.dotcom.fr
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 <d.bonniot@mail.dotcom.fr>
* ClassType.java (getInterfaces): Added use of reflect class
information
diff -u -r1.27 ClassType.java
--- ClassType.java 2000/01/24 06:48:50 1.27
+++ ClassType.java 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(); }