mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-13 08:53:20 +00:00
ICU-11565 BRS - svnprops check
X-SVN-Rev: 37195
This commit is contained in:
parent
6d54ab4174
commit
6c4df64d1f
2 changed files with 100 additions and 102 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -283,8 +283,6 @@ icu4j/main/classes/core/.settings/edu.umd.cs.findbugs.core.prefs -text
|
|||
icu4j/main/classes/core/.settings/org.eclipse.core.resources.prefs -text
|
||||
icu4j/main/classes/core/.settings/org.eclipse.jdt.core.prefs -text
|
||||
icu4j/main/classes/core/manifest.stub -text
|
||||
icu4j/main/classes/core/src/com/ibm/icu/impl/ClassLoaderUtil.java -text
|
||||
icu4j/main/classes/core/src/com/ibm/icu/impl/Pair.java -text
|
||||
icu4j/main/classes/currdata/.externalToolBuilders/copy-data-currdata.launch -text
|
||||
icu4j/main/classes/currdata/.settings/org.eclipse.core.resources.prefs -text
|
||||
icu4j/main/classes/currdata/.settings/org.eclipse.jdt.core.prefs -text
|
||||
|
|
|
@ -1,100 +1,100 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2015, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.impl;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
|
||||
/**
|
||||
* This utility class is used for resolving a right ClassLoader from
|
||||
* a given class. getClassLoader always returns a non-null ClassLoader
|
||||
* even a class is loaded through the bootstrap class loader of JRE.
|
||||
*/
|
||||
public class ClassLoaderUtil {
|
||||
|
||||
private static class BootstrapClassLoader extends ClassLoader {
|
||||
BootstrapClassLoader() {
|
||||
// Object.class.getClassLoader() may return null.
|
||||
//
|
||||
// On Android, the behavior of super(null) is not guaranteed,
|
||||
// but Object.class.getClassLoader() actually returns the
|
||||
// bootstrap class loader. Note that we probably do not reach
|
||||
// this constructor on Android, because ClassLoaderUtil.getClassLoader()
|
||||
// should get non-null ClassLoader before calling
|
||||
// ClassLoaderUtil.getBootstrapClassLoader().
|
||||
//
|
||||
// On other common JREs (such as Oracle, OpenJDK),
|
||||
// Object.class.getClassLoader() returns null, but
|
||||
// super(null) is commonly used for accessing the bootstrap
|
||||
// class loader.
|
||||
super(Object.class.getClassLoader());
|
||||
}
|
||||
}
|
||||
|
||||
private static volatile ClassLoader BOOTSTRAP_CLASSLOADER;
|
||||
|
||||
/**
|
||||
* Lazily create a singleton BootstrapClassLoader.
|
||||
* This class loader might be necessary when ICU4J classes are
|
||||
* initialized by bootstrap class loader.
|
||||
*
|
||||
* @return The BootStrapClassLoader singleton instance
|
||||
*/
|
||||
private static ClassLoader getBootstrapClassLoader() {
|
||||
if (BOOTSTRAP_CLASSLOADER == null) {
|
||||
synchronized(ClassLoaderUtil.class) {
|
||||
if (BOOTSTRAP_CLASSLOADER == null) {
|
||||
ClassLoader cl = null;
|
||||
if (System.getSecurityManager() != null) {
|
||||
cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
|
||||
public BootstrapClassLoader run() {
|
||||
return new BootstrapClassLoader();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
cl = new BootstrapClassLoader();
|
||||
}
|
||||
BOOTSTRAP_CLASSLOADER = cl;
|
||||
}
|
||||
}
|
||||
}
|
||||
return BOOTSTRAP_CLASSLOADER;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the class loader used for loading the specified class.
|
||||
* @param cls The class
|
||||
* @return the class loader
|
||||
*/
|
||||
public static ClassLoader getClassLoader(Class<?> cls) {
|
||||
ClassLoader cl = cls.getClassLoader();
|
||||
if (cl == null) {
|
||||
cl = getClassLoader();
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a fallback class loader.
|
||||
* @return A class loader
|
||||
*/
|
||||
public static ClassLoader getClassLoader() {
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if (cl == null) {
|
||||
cl = ClassLoader.getSystemClassLoader();
|
||||
if (cl == null) {
|
||||
// When this method is called for initializing a ICU4J class
|
||||
// during bootstrap, cl might be still null (other than Android?).
|
||||
// In this case, we want to use the bootstrap class loader.
|
||||
cl = getBootstrapClassLoader();
|
||||
}
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2015, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.impl;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
|
||||
/**
|
||||
* This utility class is used for resolving a right ClassLoader from
|
||||
* a given class. getClassLoader always returns a non-null ClassLoader
|
||||
* even a class is loaded through the bootstrap class loader of JRE.
|
||||
*/
|
||||
public class ClassLoaderUtil {
|
||||
|
||||
private static class BootstrapClassLoader extends ClassLoader {
|
||||
BootstrapClassLoader() {
|
||||
// Object.class.getClassLoader() may return null.
|
||||
//
|
||||
// On Android, the behavior of super(null) is not guaranteed,
|
||||
// but Object.class.getClassLoader() actually returns the
|
||||
// bootstrap class loader. Note that we probably do not reach
|
||||
// this constructor on Android, because ClassLoaderUtil.getClassLoader()
|
||||
// should get non-null ClassLoader before calling
|
||||
// ClassLoaderUtil.getBootstrapClassLoader().
|
||||
//
|
||||
// On other common JREs (such as Oracle, OpenJDK),
|
||||
// Object.class.getClassLoader() returns null, but
|
||||
// super(null) is commonly used for accessing the bootstrap
|
||||
// class loader.
|
||||
super(Object.class.getClassLoader());
|
||||
}
|
||||
}
|
||||
|
||||
private static volatile ClassLoader BOOTSTRAP_CLASSLOADER;
|
||||
|
||||
/**
|
||||
* Lazily create a singleton BootstrapClassLoader.
|
||||
* This class loader might be necessary when ICU4J classes are
|
||||
* initialized by bootstrap class loader.
|
||||
*
|
||||
* @return The BootStrapClassLoader singleton instance
|
||||
*/
|
||||
private static ClassLoader getBootstrapClassLoader() {
|
||||
if (BOOTSTRAP_CLASSLOADER == null) {
|
||||
synchronized(ClassLoaderUtil.class) {
|
||||
if (BOOTSTRAP_CLASSLOADER == null) {
|
||||
ClassLoader cl = null;
|
||||
if (System.getSecurityManager() != null) {
|
||||
cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
|
||||
public BootstrapClassLoader run() {
|
||||
return new BootstrapClassLoader();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
cl = new BootstrapClassLoader();
|
||||
}
|
||||
BOOTSTRAP_CLASSLOADER = cl;
|
||||
}
|
||||
}
|
||||
}
|
||||
return BOOTSTRAP_CLASSLOADER;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the class loader used for loading the specified class.
|
||||
* @param cls The class
|
||||
* @return the class loader
|
||||
*/
|
||||
public static ClassLoader getClassLoader(Class<?> cls) {
|
||||
ClassLoader cl = cls.getClassLoader();
|
||||
if (cl == null) {
|
||||
cl = getClassLoader();
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a fallback class loader.
|
||||
* @return A class loader
|
||||
*/
|
||||
public static ClassLoader getClassLoader() {
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if (cl == null) {
|
||||
cl = ClassLoader.getSystemClassLoader();
|
||||
if (cl == null) {
|
||||
// When this method is called for initializing a ICU4J class
|
||||
// during bootstrap, cl might be still null (other than Android?).
|
||||
// In this case, we want to use the bootstrap class loader.
|
||||
cl = getBootstrapClassLoader();
|
||||
}
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue