[antlr-interest] [OT] Static initialization in Java

Dennis Benzinger Dennis.Benzinger at gmx.net
Thu Sep 4 05:35:05 PDT 2008


Am 27.08.2008 13:33, Kay Röpke schrieb:
> [...]
> Further poking around seems to indicate some compiler change between  
> 1.4 and 1.5 with regards to Foo.class. 
> [...]

Yes, the change is documented on
http://java.sun.com/j2se/1.5.0/compatibility.html in section
"Incompatibilities in Java 2 Platform Standard Edition 5.0 (since
1.4.2)", item 5.

> Using .class (which is syntax, not a field) doesn't seem to fit into  
> the section of the spec you referred to, so I'm afraid that's not  
> really helpful to understand this :(
> [...]

Why aren't they helpful? The cited section of the spec lists the reasons
for initialization of a class and referring to a class literal (e.g.
HomePage.class) is not listed. Therefore the Java Language Specification
doesn't promise that a class literal will trigger class initialization.
That's what I wanted to say. This is also documented in the link above.

Bye,
Dennis Benzinger


More information about the antlr-interest mailing list