JDK-4998264 : Recommended changes to immutable classes for conformance to jsr133 (mem model)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 5.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-02-20
  • Updated: 2017-05-19
  • Resolved: 2004-03-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b42Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
From: <###@###.###>

As part of JSR133, the expert group promised to discover and offer
suggested changes to make JDK code sensibly conform to the revised
memory model. Among the simplest but most important of these was to
identify core classes advertised as immutable but not using "final"
fields. These fields really must be declared as final to behave
correctly. Although breaches are extremely rare and hard to exploit,
it is important to revise them accordingly to make definite guarantees
that when for example, you create a Integer(3), no thread ever sees
its value as zero.

Looking only at the core libraries (lang, util), we've identified
the following classes, and have made versions with suggested changes.
lang:
  Boolean.java  Character.java  Float.java    Package.java  String.java
  Byte.java     Double.java     Integer.java  Short.java
util:
  UUID.java

In most cases, this was just a matter of adding "final". Code inside
some constructors (mostly in class String) also needed a few other
minor rearrangements though.

There are of course no API changes. These are pure bug fixes.

To check that these changes do not affect performance, we've run
specJVM and specJJB using revised version, and didn't see any
consistent difference one way or the other. (While using finals in
general leads to a few more opportunities for optimizations, hotspot
doesn't much expolit these yet. Also, finals can disable a few code
reorderings but we can't see any observable performance effect.)  I've
sent mail to ###@###.### asking if he knows of better tests; if he
does, we'll run them, but we don't expect to find any interesting
differences.

[ ... ]

- ###@###.###

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b42 tiger-beta2
14-06-2004

EVALUATION Should be fixed for tiger-beta2. -- iag@sfbay 2004-02-20 java/lang/UUID.java are not necessary as similar changes have already been made to that file. This has been confirmed by ###@###.###. -- iag@sfbay 2004-02-25
20-02-2004