> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:[EMAIL PROTECTED]]
> > Because of the way the reflection is performed we can get
> > IllegalAccessException because we are working on a private
> class rather than
> > one of its interface or possibly public superclass. In the
> case above we are
> > working on java.util.AbstractList$Itr, while we would need
> to work on
> > java.util.Iterator
>
> Which in the above gives you the IllegalAccessException?
Anything which is part of the iterator... next, hasNext, ....
Here's a simple testcase that demonstrate the problem:
import java.util.*;
import java.lang.reflect.*
public class Test {
public void static main(String[] args) throws Exception {
ArrayList list = new ArrayList();
Object o = list.iterator();
Class clazz = o.getClass();
Method method = clazz.getMethod("hasNext", new Class[0]);
/*
int modifiers = method.getModifiers();
if ( Modifier.isPublic(modifiers) ){
method.setAccessible(true);
}*/
Object result = method.invoke(o, null);
}
}
--
Stephane Bailliez
Software Engineer, Paris - France
iMediation - http://www.imediation.com
Disclaimer: All the opinions expressed above are mine and not those from my
company.