Peter Reilly wrote:
[EMAIL PROTECTED] wrote:

I had a project where a code generator inserts one interface statement - and that
what missing. So I created just an empty interface to make the compiler happy. Couldnt
we "backport" the Iterable interface?


I played a little with these...
- build.xml
- src\oata\Iterable.java
- src\oata\MyClass.java


Nice, but not useful in ant core (kernel) until we move to using
java 1.5+ as we would not be able to use java 1.5+ to create
an ant distribution that can be used for java 1.4 and previous.


How about (in a java15 package), we have a class that uses reflection to look for the iterator() operator



Class IterateOver implements Iterable {

Object instance;

IterateOver(instance) {this.instance=instance}

public Iterator iterator() {
        Class clazz=instance.getClass();
        Method method=clazz.getMethod("iterator");
        return method.invoke(instance);
}

}

you could then do (for e:new IterateOver(something));

not ideal, I admit. Oh, there is all that generic typing stuff too. sigh.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to