ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject Re: Question about compiler error when calling log()
Date Sat, 06 Jan 2001 23:31:43 GMT
Thanks Stephane. Method 1 worked -- except I had to take the "static" out
of the two classes at the end of the file as well (the Fail and Success
classes that extends'ed SoundTask.BuildAlert) -- hope that's all kosher.

Diane

--- Stéphane_Bailliez <sbailliez@imediation.com> wrote:
> Hi Diane,
> 
> ----- Original Message -----
> From: "Diane Holt" <holtdl@yahoo.com>
> 
> > 137.     log(src + " is not a valid file.", Project.MSG_WARN) ;
> >          <->
> > *** Error: An instance of "SoundTask.this" is not accessible here
> because
> > it would have to cross a static region in the intervening type
> > "SoundTask$BuildAlert".
> 
> This is because BuildAlert is a static inner class and thus cannot
> reference
> implicitely SoundTask.log()
> 
> When an inner class is not static the compiler add a reference to its
> outer
> class.
> 
> class Outer {
>     class Inner {
>         ..
>         log("something"); // this is the same as
> Outer.this.log("something");
>     }
> }
> 
> class Outer {
>     static class Inner {
>         ..
>         log("something"); // not possible, Inner doesn't have access to
> Outer instance
>     }
> }
> 
> You could either:
> 1) make your inner class non static (I just look at it briefly but It
> seems
> that the only place where it could have a sense to be created would be
> the
> soundtask itself, so it is probably the best solution so far. The
> factory
> methods are in the soundtask itself.)
> 
> 2) subclass your static class so that your subclass is non static.
> class MySecureBuildAlert extends BuildAlert {
>     public File getSource(){
>         log("getting source");
>         return super.getSource();
>     }
> }
> fail = new MySecureBuildAlert();
> 
> I'm not sure what I said is meaningful...so just tell me, if you don't
> understand.
> 
> Use solution one for now. Unless I didn't sleep enough this should work
> fine
> without side effects.
> 
> --
> Stephane Bailliez, Paris - France
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ant-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: ant-dev-help@jakarta.apache.org
> 
> .
> 
> For additional commands, e-mail: ant-dev-help@jakarta.apache.org
> 
> .
> 


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/

Mime
View raw message