Bug 72335 - problem with new/FieldInitializerJoinPoints.java
Summary: problem with new/FieldInitializerJoinPoints.java
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-20 05:39 EDT by Ganesh Sittampalam CLA
Modified: 2004-08-20 08:35 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ganesh Sittampalam CLA 2004-08-20 05:39:23 EDT
This bug is forked from a discussion in bug 72245. 

The new/FieldInitializerJoinPoints.java test case checks that constant
initializers of final instance fields are not treated as set field join points,
which may not be a sensible thing to do.

Quoting Erik Hilsdale:

My initial take on this is that new/FieldInitializerJoinPoints.java 
may just be wrong.  The problem comes from this really cool bit
o' code:

public class Test {
    public final int x= 3;

    public static void main(String[] args) {
	Test t = new Test();
	t.foo();
    }
    void foo() {
	System.err.println(x);  // a constant reference
	System.err.println(this.x);  // NOT a constant reference
    }
}

the field x, in this case, is a weird thing in Java:  a field that,
when referred to by plain name, must be inlined, but must also have a
runtime value for when it is referred to by qualified name.

For some reason we decided that this was a "constant field" and should
have no set join point.  I'm starting to believe that this should
have a set join point.  The semantics appendix currently (under the
"join points" section) only defines constant fields as static final
fields whose initializer is a constant string object or primitive value,
and I _think_ we should probably migrate the compiler to this behavior
as well.

(Not that we're sure any of this has to do with the actual bug we're
dealing with... Hmm.  Maybe we should create a new bug report crying foul at
new/FieldInitializerJoinPoints.java and move some of the discussion
over there)
Comment 1 Ganesh Sittampalam CLA 2004-08-20 08:35:50 EDT
(Some more comments about the general specification of this issue; I think they
belong best with this bug)

Is it specified somewhere that the initializer for a static final field with a
constant value should be omitted from the bytecode, but that it shouldn't be for
instance fields? I know that the ConstantValue attribute only applies to static
fields and must be supported by a JVM (JVMS 4.7.3), but I can't find anything
that actually insists that it be used for them or that the putstatic be omitted.
Making the semantics of the language dependent on a particular compiler
implementation decision, even one that is widely used, seems a bit dangerous.