Bug 54823 - Final static int initiialization in Eclispe M7 - (bug?)
Summary: Final static int initiialization in Eclispe M7 - (bug?)
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.0 M8   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-15 10:08 EST by markusle CLA
Modified: 2004-03-16 10:12 EST (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 markusle CLA 2004-03-15 10:08:16 EST
public class StaticInitBug {
	public static final int STATIC_INT;
	static {
                // Bug(?): Complies on Eclispe M7:
		STATIC_INT =StaticInitBug.STATIC_INT; 
		// Don't compile (if uncommented) on Eclipse M7 (as expected)
		// STATIC_INT =STATIC_INT; 
	}
}
Comment 1 Olivier Thomann CLA 2004-03-15 11:03:17 EST
See http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#37544.
Points 8.3.2 and 8.3.2.1.
Note that javac has exactly the same behavior.
Close as INVALID.
Comment 2 markusle CLA 2004-03-15 22:47:09 EST
You are right, javac behaves the same way. 
But: if this is the right behaviour (and I can't believe that it is),
then the question is: Which value has STATIC_INT after a successfull
initialization of the class?
I think that is not defined in the JLS, perhaps javac has the same bug?
Comment 3 Philipe Mulet CLA 2004-03-16 05:35:20 EST
StaticInitBug.STATIC_INT is reflecting int field default value: 0.
Comment 4 markusle CLA 2004-03-16 06:01:35 EST
That is what I expected, but it is not the answer of my Question ;-)
I assume you used Java's Reflection API to detect that, or your knowlegde
about your compiler. 
But how is it defined in the JLS? I believe it is not defined!
But one the other hand is defined that a "definite assignment" should 
init the static final field.
So if the static-clause in the example is real valid, then there is a very 
small and perhaps unintended gap in the JLS.
What do you think?
Comment 5 Philipe Mulet CLA 2004-03-16 07:57:13 EST
The JLS is often fuzzy, and requires some interpretation in order to implement 
corner cases. Remember though we don't own it...

See more information at:
http://www.ergnosis.com/java-spec-report/java-language/jls-16-c.html
Comment 6 markusle CLA 2004-03-16 10:12:40 EST
Thank you very much for your answer, the link is really interessting.
I learned there that it is much more compilcated to write a compiler as I thought!
I will read there before I write my next compiler "bug" report.
BTW: Good luck with your 1.5 compiler!