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

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





Back to the top