本文整理汇总了Java中gnu.classpath.VMStackWalker.getCallingClassLoader方法的典型用法代码示例。如果您正苦于以下问题:Java VMStackWalker.getCallingClassLoader方法的具体用法?Java VMStackWalker.getCallingClassLoader怎么用?Java VMStackWalker.getCallingClassLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.classpath.VMStackWalker
的用法示例。
在下文中一共展示了VMStackWalker.getCallingClassLoader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClassLoader
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Get the ClassLoader that loaded this class. If the class was loaded
* by the bootstrap classloader, this method will return null.
* If there is a security manager, and the caller's class loader is not
* an ancestor of the requested one, a security check of
* <code>RuntimePermission("getClassLoader")</code>
* must first succeed. Primitive types and void return null.
*
* @return the ClassLoader that loaded this class
* @throws SecurityException if the security check fails
* @see ClassLoader
* @see RuntimePermission
*/
public ClassLoader getClassLoader()
{
if (isPrimitive())
return null;
ClassLoader loader = VMClass.getClassLoader(this);
// Check if we may get the classloader
SecurityManager sm = SecurityManager.current;
if (loader != null && sm != null)
{
// Get the calling classloader
ClassLoader cl = VMStackWalker.getCallingClassLoader();
if (cl != null && !cl.isAncestorOf(loader))
sm.checkPermission(new RuntimePermission("getClassLoader"));
}
return loader;
}
示例2: getContextClassLoader
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Returns the context classloader of this Thread. The context
* classloader can be used by code that want to load classes depending
* on the current thread. Normally classes are loaded depending on
* the classloader of the current class. There may be a security check
* for <code>RuntimePermission("getClassLoader")</code> if the caller's
* class loader is not null or an ancestor of this thread's context class
* loader.
*
* @return the context class loader
* @throws SecurityException when permission is denied
* @see #setContextClassLoader(ClassLoader)
* @since 1.2
*/
public synchronized ClassLoader getContextClassLoader()
{
ClassLoader loader = contextClassLoaderIsSystemClassLoader ?
ClassLoader.getSystemClassLoader() : contextClassLoader;
// Check if we may get the classloader
SecurityManager sm = SecurityManager.current;
if (loader != null && sm != null)
{
// Get the calling classloader
ClassLoader cl = VMStackWalker.getCallingClassLoader();
if (cl != null && !cl.isAncestorOf(loader))
sm.checkPermission(new RuntimePermission("getClassLoader"));
}
return loader;
}
示例3: getClassLoader
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Get the ClassLoader that loaded this class. If the class was loaded
* by the bootstrap classloader, this method will return null.
* If there is a security manager, and the caller's class loader is not
* an ancestor of the requested one, a security check of
* <code>RuntimePermission("getClassLoader")</code>
* must first succeed. Primitive types and void return null.
*
* @return the ClassLoader that loaded this class
* @throws SecurityException if the security check fails
* @see ClassLoader
* @see RuntimePermission
*/
public ClassLoader getClassLoader()
{
if (isPrimitive())
return null;
ClassLoader loader = VMClass.getClassLoader(this);
// Check if we may get the classloader
SecurityManager sm = SecurityManager.current;
if (loader != null && sm != null)
{
// Get the calling classloader
ClassLoader cl = VMStackWalker.getCallingClassLoader();
if (cl != null && !cl.isAncestorOf(loader))
sm.checkPermission(new RuntimePermission("getClassLoader"));
}
return loader;
}
示例4: getContextClassLoader
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Returns the context classloader of this Thread. The context
* classloader can be used by code that want to load classes depending
* on the current thread. Normally classes are loaded depending on
* the classloader of the current class. There may be a security check
* for <code>RuntimePermission("getClassLoader")</code> if the caller's
* class loader is not null or an ancestor of this thread's context class
* loader.
*
* @return the context class loader
* @throws SecurityException when permission is denied
* @see #setContextClassLoader(ClassLoader)
* @since 1.2
*/
public synchronized ClassLoader getContextClassLoader()
{
ClassLoader loader = contextClassLoaderIsSystemClassLoader ?
ClassLoader.getSystemClassLoader() : contextClassLoader;
// Check if we may get the classloader
SecurityManager sm = SecurityManager.current;
if (loader != null && sm != null)
{
// Get the calling classloader
ClassLoader cl = VMStackWalker.getCallingClassLoader();
if (cl != null && !cl.isAncestorOf(loader))
sm.checkPermission(new RuntimePermission("getClassLoader"));
}
return loader;
}
示例5: getPackages
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Returns all the packages that are known to the callers class loader.
* It may return an empty array if the classloader of the caller is null.
*
* @return an array of all known packages
*/
public static Package[] getPackages()
{
// Get the caller's classloader
ClassLoader cl = VMStackWalker.getCallingClassLoader();
return cl != null ? cl.getPackages() : VMClassLoader.getPackages();
}
示例6: getParent
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Returns the parent of this classloader. If the parent of this
* classloader is the bootstrap classloader then this method returns
* <code>null</code>. A security check may be performed on
* <code>RuntimePermission("getClassLoader")</code>.
*
* @return the parent <code>ClassLoader</code>
* @throws SecurityException if the security check fails
* @since 1.2
*/
public final ClassLoader getParent()
{
// Check if we may return the parent classloader.
SecurityManager sm = SecurityManager.current;
if (sm != null)
{
ClassLoader cl = VMStackWalker.getCallingClassLoader();
if (cl != null && ! cl.isAncestorOf(this))
sm.checkPermission(new RuntimePermission("getClassLoader"));
}
return parent;
}
示例7: getParent
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Returns the parent of this classloader. If the parent of this
* classloader is the bootstrap classloader then this method returns
* <code>null</code>. A security check may be performed on
* <code>RuntimePermission("getClassLoader")</code>.
*
* @return the parent <code>ClassLoader</code>
* @throws SecurityException if the security check fails
* @since 1.2
*/
public final ClassLoader getParent()
{
// Check if we may return the parent classloader.
SecurityManager sm = SecurityManager.current;
if (sm != null)
{
ClassLoader cl = VMStackWalker.getCallingClassLoader();
if (cl != null && ! cl.isAncestorOf(this))
sm.checkPermission(new RuntimePermission("getClassLoader"));
}
return parent;
}
示例8: forName
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Use the specified classloader to load and link a class. If the loader
* is null, this uses the bootstrap class loader (provide the security
* check succeeds). Unfortunately, this method cannot be used to obtain
* the Class objects for primitive types or for void, you have to use
* the fields in the appropriate java.lang wrapper classes.
*
* <p>Calls <code>classloader.loadclass(name, initialize)</code>.
*
* @param name the name of the class to find
* @param initialize whether or not to initialize the class at this time
* @param classloader the classloader to use to find the class; null means
* to use the bootstrap class loader
*
* @return the class object for the given class
*
* @throws ClassNotFoundException if the class was not found by the
* classloader
* @throws LinkageError if linking the class fails
* @throws ExceptionInInitializerError if the class loads, but an exception
* occurs during initialization
* @throws SecurityException if the <code>classloader</code> argument
* is <code>null</code> and the caller does not have the
* <code>RuntimePermission("getClassLoader")</code> permission
* @see ClassLoader
* @since 1.2
*/
public static Class<?> forName(String name, boolean initialize,
ClassLoader classloader)
throws ClassNotFoundException
{
if (classloader == null)
{
// Check if we may access the bootstrap classloader
SecurityManager sm = SecurityManager.current;
if (sm != null)
{
// Get the calling classloader
ClassLoader cl = VMStackWalker.getCallingClassLoader();
if (cl != null)
sm.checkPermission(new RuntimePermission("getClassLoader"));
}
}
return (Class<?>) VMClass.forName(name, initialize, classloader);
}
示例9: forName
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Use the specified classloader to load and link a class. If the loader
* is null, this uses the bootstrap class loader (provide the security
* check succeeds). Unfortunately, this method cannot be used to obtain
* the Class objects for primitive types or for void, you have to use
* the fields in the appropriate java.lang wrapper classes.
*
* <p>Calls <code>classloader.loadclass(name, initialize)</code>.
*
* @param name the name of the class to find
* @param initialize whether or not to initialize the class at this time
* @param classloader the classloader to use to find the class; null means
* to use the bootstrap class loader
*
* @return the class object for the given class
*
* @throws ClassNotFoundException if the class was not found by the
* classloader
* @throws LinkageError if linking the class fails
* @throws ExceptionInInitializerError if the class loads, but an exception
* occurs during initialization
* @throws SecurityException if the <code>classloader</code> argument
* is <code>null</code> and the caller does not have the
* <code>RuntimePermission("getClassLoader")</code> permission
* @see ClassLoader
* @since 1.2
*/
public static Class<?> forName(String name, boolean initialize,
ClassLoader classloader)
throws ClassNotFoundException
{
if (classloader == null)
{
// Check if we may access the bootstrap classloader
SecurityManager sm = SecurityManager.current;
if (sm != null)
{
// Get the calling classloader
ClassLoader cl = VMStackWalker.getCallingClassLoader();
if (cl != null)
sm.checkPermission(new RuntimePermission("getClassLoader"));
}
}
return (Class<?>) VMClass.forName(name, initialize, classloader);
}
示例10: getProperty
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Returns the value associated with a Security propery.
*
* @param key
* the key of the property to fetch.
* @return the value of the Security property associated with
* <code>key</code>. Returns <code>null</code> if no such property
* was found.
* @throws SecurityException
* if a {@link SecurityManager} is installed and it disallows this
* operation.
* @see #setProperty(String, String)
* @see SecurityPermission
*/
public static String getProperty(String key)
{
// XXX To prevent infinite recursion when the SecurityManager calls us,
// don't do a security check if the caller is trusted (by virtue of having
// been loaded by the bootstrap class loader).
SecurityManager sm = System.getSecurityManager();
if (sm != null && VMStackWalker.getCallingClassLoader() != null)
sm.checkSecurityAccess("getProperty." + key);
return secprops.getProperty(key);
}
示例11: getPackage
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Returns the named package if it is known by the callers class loader.
* It may return null if the package is unknown, when there is no
* information on that particular package available or when the callers
* classloader is null.
*
* @param name the name of the desired package
* @return the package by that name in the current ClassLoader
*/
public static Package getPackage(String name)
{
// Get the caller's classloader
ClassLoader cl = VMStackWalker.getCallingClassLoader();
return cl != null ? cl.getPackage(name) : VMClassLoader.getPackage(name);
}
示例12: getSystemClassLoader
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Returns the system classloader. The system classloader (also called
* the application classloader) is the classloader that is used to
* load the application classes on the classpath (given by the system
* property <code>java.class.path</code>. This is set as the context
* class loader for a thread. The system property
* <code>java.system.class.loader</code>, if defined, is taken to be the
* name of the class to use as the system class loader, which must have
* a public constructor which takes a ClassLoader as a parent. The parent
* class loader passed in the constructor is the default system class
* loader.
*
* <p>Note that this is different from the bootstrap classloader that
* actually loads all the real "system" classes.
*
* <p>A security check will be performed for
* <code>RuntimePermission("getClassLoader")</code> if the calling class
* is not a parent of the system class loader.
*
* @return the system class loader
* @throws SecurityException if the security check fails
* @throws IllegalStateException if this is called recursively
* @throws Error if <code>java.system.class.loader</code> fails to load
* @since 1.2
*/
public static ClassLoader getSystemClassLoader()
{
// Check if we may return the system classloader
SecurityManager sm = SecurityManager.current;
if (sm != null)
{
ClassLoader cl = VMStackWalker.getCallingClassLoader();
if (cl != null && cl != StaticData.systemClassLoader)
sm.checkPermission(new RuntimePermission("getClassLoader"));
}
return StaticData.systemClassLoader;
}
示例13: getBundle
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Get the appropriate ResourceBundle for the default locale. This is like
* calling <code>getBundle(baseName, Locale.getDefault(),
* getClass().getClassLoader()</code>, except that any security check of
* getClassLoader won't fail.
*
* @param baseName the name of the ResourceBundle
* @return the desired resource bundle
* @throws MissingResourceException if the resource bundle can't be found
* @throws NullPointerException if baseName is null
*/
public static ResourceBundle getBundle(String baseName)
{
ClassLoader cl = VMStackWalker.getCallingClassLoader();
if (cl == null)
cl = ClassLoader.getSystemClassLoader();
return getBundle(baseName, Locale.getDefault(), cl);
}
示例14: getProperty
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Returns the value associated with a Security propery.
*
* @param key
* the key of the property to fetch.
* @return the value of the Security property associated with
* <code>key</code>. Returns <code>null</code> if no such property
* was found.
* @throws SecurityException
* if a {@link SecurityManager} is installed and it disallows this
* operation.
* @see #setProperty(String, String)
* @see SecurityPermission
*/
public static String getProperty(String key)
{
// XXX To prevent infinite recursion when the SecurityManager calls us,
// don't do a security check if the caller is trusted (by virtue of having
// been loaded by the bootstrap class loader).
SecurityManager sm = System.getSecurityManager();
if (sm != null && VMStackWalker.getCallingClassLoader() != null)
sm.checkSecurityAccess("getProperty." + key);
return secprops.getProperty(key);
}
示例15: getSystemClassLoader
import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
* Returns the system classloader. The system classloader (also called
* the application classloader) is the classloader that is used to
* load the application classes on the classpath (given by the system
* property <code>java.class.path</code>. This is set as the context
* class loader for a thread. The system property
* <code>java.system.class.loader</code>, if defined, is taken to be the
* name of the class to use as the system class loader, which must have
* a public constructor which takes a ClassLoader as a parent. The parent
* class loader passed in the constructor is the default system class
* loader.
*
* <p>Note that this is different from the bootstrap classloader that
* actually loads all the real "system" classes.
*
* <p>A security check will be performed for
* <code>RuntimePermission("getClassLoader")</code> if the calling class
* is not a parent of the system class loader.
*
* @return the system class loader
* @throws SecurityException if the security check fails
* @throws IllegalStateException if this is called recursively
* @throws Error if <code>java.system.class.loader</code> fails to load
* @since 1.2
*/
public static ClassLoader getSystemClassLoader()
{
// Check if we may return the system classloader
SecurityManager sm = SecurityManager.current;
if (sm != null)
{
ClassLoader cl = VMStackWalker.getCallingClassLoader();
if (cl != null && cl != StaticData.systemClassLoader)
sm.checkPermission(new RuntimePermission("getClassLoader"));
}
return StaticData.systemClassLoader;
}