summaryrefslogtreecommitdiff
path: root/external/ikvm/openjdk/java/util
diff options
context:
space:
mode:
Diffstat (limited to 'external/ikvm/openjdk/java/util')
-rw-r--r--external/ikvm/openjdk/java/util/ResourceBundle.java29
-rw-r--r--external/ikvm/openjdk/java/util/TimeZone.java69
2 files changed, 58 insertions, 40 deletions
diff --git a/external/ikvm/openjdk/java/util/ResourceBundle.java b/external/ikvm/openjdk/java/util/ResourceBundle.java
index b572875ec8..98ee3c5195 100644
--- a/external/ikvm/openjdk/java/util/ResourceBundle.java
+++ b/external/ikvm/openjdk/java/util/ResourceBundle.java
@@ -55,6 +55,8 @@ import java.security.PrivilegedExceptionAction;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.jar.JarEntry;
+
+import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;
import sun.util.locale.BaseLocale;
import sun.util.locale.LocaleObjectCache;
@@ -412,11 +414,10 @@ public abstract class ResourceBundle {
/*
* Automatic determination of the ClassLoader to be used to load
- * resources on behalf of the client. N.B. The client is getLoader's
- * caller's caller.
+ * resources on behalf of the client.
*/
- private static ClassLoader getLoader(Class c) {
- ClassLoader cl = (c == null) ? null : c.getClassLoader();
+ private static ClassLoader getLoader(Class<?> caller) {
+ ClassLoader cl = caller == null ? null : caller.getClassLoader();
if (cl == null) {
// When the caller's loader is the boot class loader, cl is null
// here. In that case, ClassLoader.getSystemClassLoader() may
@@ -714,12 +715,12 @@ public abstract class ResourceBundle {
* if no resource bundle for the specified base name can be found
* @return a resource bundle for the given base name and the default locale
*/
- @ikvm.internal.HasCallerID
+ @CallerSensitive
public static final ResourceBundle getBundle(String baseName)
{
return getBundleImpl(baseName, Locale.getDefault(),
/* must determine loader here, else we break stack invariant */
- getLoader(Reflection.getCallerClass(2)),
+ getLoader(Reflection.getCallerClass()),
Control.INSTANCE);
}
@@ -757,12 +758,12 @@ public abstract class ResourceBundle {
* needed.
* @since 1.6
*/
- @ikvm.internal.HasCallerID
+ @CallerSensitive
public static final ResourceBundle getBundle(String baseName,
Control control) {
return getBundleImpl(baseName, Locale.getDefault(),
/* must determine loader here, else we break stack invariant */
- getLoader(Reflection.getCallerClass(2)),
+ getLoader(Reflection.getCallerClass()),
control);
}
@@ -787,13 +788,13 @@ public abstract class ResourceBundle {
* if no resource bundle for the specified base name can be found
* @return a resource bundle for the given base name and locale
*/
- @ikvm.internal.HasCallerID
+ @CallerSensitive
public static final ResourceBundle getBundle(String baseName,
Locale locale)
{
return getBundleImpl(baseName, locale,
/* must determine loader here, else we break stack invariant */
- getLoader(Reflection.getCallerClass(2)),
+ getLoader(Reflection.getCallerClass()),
Control.INSTANCE);
}
@@ -834,12 +835,12 @@ public abstract class ResourceBundle {
* needed.
* @since 1.6
*/
- @ikvm.internal.HasCallerID
+ @CallerSensitive
public static final ResourceBundle getBundle(String baseName, Locale targetLocale,
Control control) {
return getBundleImpl(baseName, targetLocale,
/* must determine loader here, else we break stack invariant */
- getLoader(Reflection.getCallerClass(2)),
+ getLoader(Reflection.getCallerClass()),
control);
}
@@ -1675,9 +1676,9 @@ public abstract class ResourceBundle {
* @since 1.6
* @see ResourceBundle.Control#getTimeToLive(String,Locale)
*/
- @ikvm.internal.HasCallerID
+ @CallerSensitive
public static final void clearCache() {
- clearCache(getLoader(Reflection.getCallerClass(2)));
+ clearCache(getLoader(Reflection.getCallerClass()));
}
/**
diff --git a/external/ikvm/openjdk/java/util/TimeZone.java b/external/ikvm/openjdk/java/util/TimeZone.java
index e3b7cbd54b..63f1028c82 100644
--- a/external/ikvm/openjdk/java/util/TimeZone.java
+++ b/external/ikvm/openjdk/java/util/TimeZone.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,8 @@ import java.lang.ref.SoftReference;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.ConcurrentHashMap;
-import sun.awt.AppContextDC;
+import sun.misc.SharedSecrets;
+import sun.misc.JavaAWTAccess;
import sun.security.action.GetPropertyAction;
import sun.util.TimeZoneNameUtility;
import sun.util.calendar.ZoneInfo;
@@ -718,15 +719,27 @@ abstract public class TimeZone implements Serializable, Cloneable {
* Returns the default TimeZone in an AppContext if any AppContext
* has ever used. null is returned if any AppContext hasn't been
* used or if the AppContext doesn't have the default TimeZone.
- */
- private synchronized static TimeZone getDefaultInAppContext() {
- if (!hasSetInAppContext) {
- return null;
- }
-
- AppContextDC ac = AppContextDC.getAppContext();
- if (ac != null && !ac.isDisposed()) {
- return (TimeZone) ac.get(TimeZone.class);
+ *
+ * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
+ * been loaded. If so, it implies that AWTSecurityManager is not our
+ * SecurityManager and we can use a local static variable.
+ * This works around a build time issue.
+ */
+ private static TimeZone getDefaultInAppContext() {
+ // JavaAWTAccess provides access implementation-private methods without using reflection.
+ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+ if (javaAWTAccess == null) {
+ return mainAppContextDefault;
+ } else {
+ if (!javaAWTAccess.isDisposed()) {
+ TimeZone tz = (TimeZone)
+ javaAWTAccess.get(TimeZone.class);
+ if (tz == null && javaAWTAccess.isMainAppContext()) {
+ return mainAppContextDefault;
+ } else {
+ return tz;
+ }
+ }
}
return null;
}
@@ -736,19 +749,23 @@ abstract public class TimeZone implements Serializable, Cloneable {
* tz. null is handled special: do nothing if any AppContext
* hasn't been used, remove the default TimeZone in the
* AppContext otherwise.
- */
- private synchronized static void setDefaultInAppContext(TimeZone tz) {
- if (!hasSetInAppContext && tz == null) {
- return;
- }
-
- AppContextDC ac = AppContextDC.getAppContext();
- if (ac != null && !ac.isDisposed()) {
- if (tz != null) {
- ac.put(TimeZone.class, tz);
- hasSetInAppContext = true;
- } else {
- ac.remove(TimeZone.class);
+ *
+ * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
+ * been loaded. If so, it implies that AWTSecurityManager is not our
+ * SecurityManager and we can use a local static variable.
+ * This works around a build time issue.
+ */
+ private static void setDefaultInAppContext(TimeZone tz) {
+ // JavaAWTAccess provides access implementation-private methods without using reflection.
+ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+ if (javaAWTAccess == null) {
+ mainAppContextDefault = tz;
+ } else {
+ if (!javaAWTAccess.isDisposed()) {
+ javaAWTAccess.put(TimeZone.class, tz);
+ if (javaAWTAccess.isMainAppContext()) {
+ mainAppContextDefault = null;
+ }
}
}
}
@@ -804,8 +821,8 @@ abstract public class TimeZone implements Serializable, Cloneable {
static final String GMT_ID = "GMT";
private static final int GMT_ID_LENGTH = 3;
- // true if the default TimeZone has been set in any AppContext
- private static boolean hasSetInAppContext;
+ // a static TimeZone we can reference if no AppContext is in place
+ private static volatile TimeZone mainAppContextDefault;
/**
* Parses a custom time zone identifier and returns a corresponding zone.