Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-dev] source location for initialization

For 1.0 Jim and I decided that in the structure model the source location
for both static and instance initializers within a block should be that of
their enclosing type declaration.  E.g. for 

01 class A {
02   int i;
03   static { i = 0; }
04   { i = 1; }
05 }

Both of the initializers would have 01 as their source location.  I think
that's better than using the first type declaration in the file when there
are numerous type declarations in the file.  It also seems less confusing
than using the location of the first initializer when many are present.

Mik

> -----Original Message-----
> From: aspectj-dev-admin@xxxxxxxxxxx [mailto:aspectj-dev-admin@xxxxxxxxxxx]
> On Behalf Of Adrian Colyer
> Sent: Thursday, February 13, 2003 12:41 AM
> To: aspectj-dev@xxxxxxxxxxx
> Subject: Re: [aspectj-dev] source location for initialization
> 
> 
> Wes wrote:
> > Should the compiler instead report the first instance of an
> > initializer, or the first line of the target class
> > if there is no initializer? [yes]
> >
> >   class Foo {
> >     // some comment
> >     static int i = 2;    // staticinitialization(Foo)
> >     int i = 3;           // initialization(Foo)
> >     Foo() { ...}
> >     ...
> >   }
> >   class Bar {
> >     // some comment      // {static}initialization(Bar)
> >     ...
> >   }
> 
> I agree with this. In general, having line 0 as a source location is not
> what you want in the various tools that use this information to jump to
> source locations - it puts you at the top of the file looking at the
> copyright statements etc.. Wherever line 0 is used to mean "we don't
> really
> know the location," my preference would be to use the first type
> declaration line in the file instead. Clearly, if a more accurate source
> location *can* be determined, we'd want to use that.
> 
> --Adrian
> Adrian_Colyer@xxxxxxxxxx
> 
> 
> 
>                       Wes Isberg
>                       <wes@xxxxxxxxxxxxx        To:       aspectj-
> dev@xxxxxxxxxxx
>                       m>                        cc:
>                       Sent by:                  Subject:  [aspectj-dev]
> source location for initialization
>                       aspectj-dev-admin@
>                       eclipse.org
> 
> 
>                       12/02/2003 22:57
>                       Please respond to
>                       aspectj-dev
> 
> 
> 
> 
> What should the source location be for initialization
> and staticinitialization?
> 
> Currently, it's reported as line 0.  E.g., try
> 
>   declare warning: initialization(Foo.new(..)) : "init";
> 
> AFAIR, the compiler gathers all initializers into one
> block of code, run before any constructor.
> 
> Questions presented [and my position]:
> 
> Should the compiler instead report the first instance of an
> initializer, or the first line of the target class
> if there is no initializer? [yes]
> 
>   class Foo {
>     // some comment
>     static int i = 2;    // staticinitialization(Foo)
>     int i = 3;           // initialization(Foo)
>     Foo() { ...}
>     ...
>   }
>   class Bar {
>     // some comment      // {static}initialization(Bar)
>     ...
>   }
> 
> Should the answer be different for static initializers,
> which (if not constant) are not run until a reference
> thereto is evaluated at runtime? [no]
> 
> Should it ignore initializers declared in aspects? [no, but...]
> Even if those are the only initializers declared for a class?
> 
> Is there any strong reason not to defer the answer and
> any related fix until after 1.1? [no]
> 
> Wes
> 
> cf http://dev.eclipse.org/bugs/show_bug.cgi?id=31724
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-dev
> 
> 
> 
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-dev



Back to the top