Search |
||
Bitten by the class literal change in TigerPosted by mister__m on August 16, 2006 at 10:02 PM PDT
If you are a returning reader, you're probably aware of the enum implementation I wrote for Java 1.4 almost three years ago. Running some Java 1.4 compatible code compiled with Java 5 has just called my attention to a supposedly low impact change that was implemented in Tiger. Since Java 5, a class literal, i.e., an expression such as Let me explain how my enum implementation is affected by this bug so you can understand if this bug might affect your Java 1.4 code. Enum's sole constructor registers the newly created instance's in a few internal
, cache is populated to tell what is the domain for Ok, now that we have a real world example, let's see what worked with Java 1.4 and fails with Tiger and Mustang:
With Java 1.4, it works; with Java 5, you will get Now, to the shocking news: there is no way to tell whether a
will require you to handle an exception that should never been thrown in this situation ( Therefore, I've submitted a RFE to add For now, beware of code that relies on class literal triggering class initialization and hope the ugly workaround above works for you if you cannot avoid it. »
Related Topics >>
J2SE Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|