List.iterator does not return a valid iterator.
Brought to you by:
zhourenjian
List l = new ArrayList();
l.add("Something");
l.add("Else");
Iterator i = l.iterator();
while (i.hasNext()) {
//
}
Will say that i.hasNext() is not a function. In fact, this seems to be a problem when instantiating an inner class.
AbstractList defines two inner classes, SimpleListIterator and FullListIterator. The method iterator() should return a SimpleListIterator, but in fact, stepping inside with a javascript debugger, i've not seen any of the two classes being instantiated.
Unfortunately could not determine where the problem is.
Logged In: YES
user_id=1909372
Originator: YES
The iterator method calls :
return Clazz.innerTypeInstance (java.util.AbstractList, this, null);
But, ClazzExt innerTypeInstance states that the function should be in the form *$*, in fact there is no information in this call to understand that we want a java.util.AbstractList$SimpleListIterator .
This seems to be a bug in around lines 438/442 of ASTScriptVisitor, but cannot figure it out.
Logged In: YES
user_id=1909372
Originator: YES
Changing :
return Clazz.innerTypeInstance (java.util.AbstractList, this, null);
To :
return Clazz.innerTypeInstance (java.util.AbstractList.SimpleListIterator, this, null);
Solves the problem, so it's a problem during generation of the call, not during generation of the inner class itself.
Logged In: YES
user_id=1702895
Originator: NO
O, compiler bug. Big bug.
Logged In: YES
user_id=1702895
Originator: NO
Fixed.
Compiler trying to remove brackets results in wrong qualified name. For example:
java.util.AbstractList<E>.SimpleListIterator results in java.util.AbstractList, which is incorrect.
Update net.sf.j2s.core sources, export this plugin, restart Eclipse, clean and rebuilt net.sf.j2s.java.core, rebuild j2slib.z.js, ...
Java2Script 2.0.0 was released.