Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #27592
| From | markspace <markspace@nospam.nospam> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: praise |
| Date | 2014-02-25 16:46 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <lejdhe$9m5$1@dont-email.me> (permalink) |
| References | <praise-20140225152547@ram.dialup.fu-berlin.de> <b19ab8ff-6c01-4435-a38e-ab2b92dd584d@googlegroups.com> |
On 2/25/2014 3:01 PM, Lew wrote: > Stefan Ram wrote: >> One can even learn from it notions such as »package-tree >> semantics« versus »traditional package semantics« or facts >> such as »a class's constructors and methods can run prior to >> its initialization« (»its« = »the class'«). > > Strange. The JLS says: > http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.4 > "A class or interface type T will be initialized immediately before the first occurrence of any one of the following: > [the class is used] > So that contradicts. > The paragraph Stefan is referring to, I think, is: " There is, however, one corner case that demands special treatment. It is possible, though generally not desirable, to execute methods or constructors prior to initialization. This can happen when a class hierarchy contains a circularity in its static initialization." So it looks to me like the JLS is implying a "best effort" to initialize a class before it is used, but can't absolutely guarantee it in all cases. It would be an interesting experiment to try to write some code to reproduce the case where a ctor is called before its initialization.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: praise Lew <lewbloch@gmail.com> - 2014-02-25 15:01 -0800
Re: praise markspace <markspace@nospam.nospam> - 2014-02-25 16:46 -0800
Re: praise Mike Amling <mamling@chaff.us> - 2014-03-04 13:06 -0600
csiph-web