RFR 8170984: java.util.logging might force the initialization of ResourceBundle class too early.

Daniel Fuchs daniel.fuchs at oracle.com
Fri Dec 9 14:09:25 UTC 2016


Hi,

Please find below a fix for:

issue:
https://bugs.openjdk.java.net/browse/JDK-8170984
8170984: java.util.logging might force the initialization
          of ResourceBundle class too early.

webrev:
http://cr.openjdk.java.net/~dfuchs/webrev_8170984/webrev.00/

The issue here is that j.u.l.Level and j.u.l.Logging
statically initialize a variable used to provide
internal access to ResourceBundle at class loading.

This has the unfortunately side effect to force the
initialization of the ResourceBundle class, which might
happen too early.

The fix is simple: instead of doing:

      static final JavaUtilResourceBundleAccess RB_ACCESS =
               SharedSecrets.getJavaUtilResourceBundleAccess();

do:

      private static final class RbAccess {
          static final JavaUtilResourceBundleAccess RB_ACCESS =
               SharedSecrets.getJavaUtilResourceBundleAccess();
      }

which will delay the call to 
SharedSecrets.getJavaUtilResourceBundleAccess()
until RB_ACCESS is actually needed.

best regards,

-- daniel


More information about the core-libs-dev mailing list