TimeZone.setDefault ändert sich in JDK6

Mir ist gerade aufgefallen, dass JDK 6 einen anderen Ansatz zum Festlegen einer Standardzeitzone als JDK5 verwendet.

Bisher wurde der neue Standardwert in einer threadlokalen Variablen gespeichert. Mit JDK6 (ich habe gerade 1.6.0.18 überprüft) hat sich die Implementierung geändert, sodass sich die Zeitzone VM-weit ändert, wenn der Benutzer in die Eigenschaft "user.timezone" schreiben kann oder wenn kein SecurityManager installiert ist! Andernfalls tritt eine threadlokale Änderung auf.

Liege ich falsch? Dies scheint eine ziemlich drastische Veränderung zu sein, und ich konnte im Internet nichts darüber finden.

Hier ist der JDK6-Code:

 private static boolean hasPermission() {
  boolean hasPermission = true;
  SecurityManager sm = System.getSecurityManager();
  if (sm != null) {
   try {
    sm.checkPermission(new PropertyPermission("user.timezone", "write"));
   } catch (SecurityException e) {
    hasPermission = false;
   }
  }
  return hasPermission;
 }

 /**
  * Sets the <code>TimeZone</code> that is
  * returned by the <code>getDefault</code> method.  If <code>zone</code>
  * is null, reset the default to the value it had originally when the
  * VM first started.
  * @param zone the new default time zone
  * @see #getDefault
  */
 public static void setDefault(TimeZone zone)
 {
  if (hasPermission()) {
   synchronized (TimeZone.class) {
    defaultTimeZone = zone;
    defaultZoneTL.set(null);
   }
  } else {
   defaultZoneTL.set(zone);
  }
 }

Während zuvor (in JDK5) war es einfach:

 /**
  * Sets the <code>TimeZone</code> that is
  * returned by the <code>getDefault</code> method.  If <code>zone</code>
  * is null, reset the default to the value it had originally when the
  * VM first started.
  * @param zone the new default time zone
  * @see #getDefault
  */
 public static synchronized void setDefault(TimeZone zone)
 {
  defaultZoneTL.set(zone);
 }

Antworten auf die Frage(3)

Ihre Antwort auf die Frage