static nested class with reference to outer class
Brian
brian_252@yahoo.com
Tue Feb 25 16:40:00 GMT 2003
Hello all,
Here's one i hope is new to you. When compiling and
executing ant-1.5.1 i ran into an IllegalAccessError.
Specifically it was in ProjectHelperImpl. They make a
nested class static. The make an explicit reference to the
outer class. And finally refer to a private member.
Here's a generalization...
public class PHI
{
public static void main( String Args[] )
{
PHI phi = new PHI();
RH rh = new RH( phi );
rh.setLocator( "hound" );
}
private String locator;
static class RH // RootHandler
{
PHI phi;
public RH( PHI phi )
{
this.phi = phi;
}
public void setLocator( String locator )
{
phi.locator = locator;
}
}
}
It compiles successfully. But when running it i get an
IllegalAccessError in RH.setLocator(). Is this correct
behavior according to the JLS?
If RH was non-static and the reference to the outer class
was implicit, it executes successfully.
thanks,
Brian
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
More information about the Java
mailing list