• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java VMStackWalker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中gnu.classpath.VMStackWalker的典型用法代码示例。如果您正苦于以下问题:Java VMStackWalker类的具体用法?Java VMStackWalker怎么用?Java VMStackWalker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VMStackWalker类属于gnu.classpath包,在下文中一共展示了VMStackWalker类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:vilie,项目名称:javify,代码行数:31,代码来源:Class.java


示例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;
}
 
开发者ID:vilie,项目名称:javify,代码行数:30,代码来源:Thread.java


示例3: loadClass

import gnu.classpath.VMStackWalker; //导入依赖的package包/类
/**
 * Load the class. The method uses class loaders from the call stact first. If
 * this fails, the further behaviour depends on the System Property
 * "java.rmi.server.useCodebaseOnly" with default value "false".
 *
 * <ul>
 * <li>Try the current thread context class loader first.</li>
 * <li>If remoteCodebase is non-null and useCodebaseOnly is "false" then call
 * java.rmi.server.RMIClassLoader.loadClass (remoteCodebase, className)</li>
 * <li> If remoteCodebase is null or useCodebaseOnly is true then call
 * java.rmi.server.RMIClassLoader.loadClass(className)</li>
 * <li>If a class is still not successfully loaded and the loader != null
 * then try Class.forName(className, false, loader). </li>
 * </ul>
 *
 * @param className the name of the class.
 * @param remoteCodebase the codebase.
 * @param loader the class loader.
 * @return the loaded class.
 *
 * @throws ClassNotFoundException of the class cannot be loaded.
 */
public Class loadClass(String className, String remoteCodebase,
  ClassLoader loader)
  throws ClassNotFoundException
{
  if (loader == null)
    loader = VMStackWalker.firstNonNullClassLoader();

  String p_useCodebaseOnly = System.getProperty("java.rmi.server.useCodebaseOnly");

  boolean useCodebaseOnly = p_useCodebaseOnly != null
    && p_useCodebaseOnly.trim().equalsIgnoreCase("true");

  if (useCodebaseOnly)
    remoteCodebase = null;

  try
    {
      return RMIClassLoader.loadClass(remoteCodebase, className, loader);
    }
  catch (MalformedURLException x)
    {
      throw new ClassNotFoundException(className, x);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:47,代码来源:UtilDelegateImpl.java


示例4: 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;
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:31,代码来源:Class.java


示例5: 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;
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:30,代码来源:Thread.java


示例6: loadClass

import gnu.classpath.VMStackWalker; //导入依赖的package包/类
/**
 * Load the class. The method uses class loaders from the call stact first. If
 * this fails, the further behaviour depends on the System Property
 * "java.rmi.server.useCodebaseOnly" with default value "false".
 * 
 * <ul>
 * <li>Try the current thread context class loader first.</li>
 * <li>If remoteCodebase is non-null and useCodebaseOnly is "false" then call
 * java.rmi.server.RMIClassLoader.loadClass (remoteCodebase, className)</li>
 * <li> If remoteCodebase is null or useCodebaseOnly is true then call
 * java.rmi.server.RMIClassLoader.loadClass(className)</li>
 * <li>If a class is still not successfully loaded and the loader != null
 * then try Class.forName(className, false, loader). </li>
 * </ul>
 * 
 * @param className the name of the class.
 * @param remoteCodebase the codebase.
 * @param loader the class loader.
 * @return the loaded class.
 * 
 * @throws ClassNotFoundException of the class cannot be loaded.
 */
public Class loadClass(String className, String remoteCodebase,
  ClassLoader loader)
  throws ClassNotFoundException
{
  if (loader == null)
    loader = VMStackWalker.firstNonNullClassLoader();

  String p_useCodebaseOnly = System.getProperty("java.rmi.server.useCodebaseOnly");

  boolean useCodebaseOnly = p_useCodebaseOnly != null
    && p_useCodebaseOnly.trim().equalsIgnoreCase("true");

  if (useCodebaseOnly)
    remoteCodebase = null;

  try
    {
      return RMIClassLoader.loadClass(remoteCodebase, className, loader);
    }
  catch (MalformedURLException x)
    {
      throw new ClassNotFoundException(className, x);
    }
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:47,代码来源:UtilDelegateImpl.java


示例7: 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();
}
 
开发者ID:vilie,项目名称:javify,代码行数:13,代码来源:Package.java


示例8: 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;
}
 
开发者ID:vilie,项目名称:javify,代码行数:23,代码来源:ClassLoader.java


示例9: getClassContext

import gnu.classpath.VMStackWalker; //导入依赖的package包/类
/**
 * Get a list of all the classes currently executing methods on the Java
 * stack.  getClassContext()[0] is the currently executing method (ie. the
 * class that CALLED getClassContext, not SecurityManager).
 *
 * @return an array of classes on the Java execution stack
 */
protected Class[] getClassContext()
{
  Class[] stack1 = VMStackWalker.getClassContext();
  Class[] stack2 = new Class[stack1.length - 1];
  System.arraycopy(stack1, 1, stack2, 0, stack1.length - 1);
  return stack2;
}
 
开发者ID:vilie,项目名称:javify,代码行数:15,代码来源:SecurityManager.java


示例10: forName

import gnu.classpath.VMStackWalker; //导入依赖的package包/类
/**
 * Load the class with the given name. This method tries to use the context
 * class loader first. If this fails, it searches for the suitable class
 * loader in the caller stack trace. This method is a central point where all
 * requests to find a class by name are delegated.
 */
static Class forName(String className)
{
  try
    {
      return Class.forName(className, true,
                           Thread.currentThread().getContextClassLoader());
    }
  catch (ClassNotFoundException nex)
    {
      /**
       * Returns the first user defined class loader on the call stack, or
       * null when no non-null class loader was found.
       */
      Class[] ctx = VMStackWalker.getClassContext();
      for (int i = 0; i < ctx.length; i++)
        {
          // Since we live in a class loaded by the bootstrap
          // class loader, getClassLoader is safe to call without
          // needing to be wrapped in a privileged action.
          ClassLoader cl = ctx[i].getClassLoader();
          try
            {
              if (cl != null)
                return Class.forName(className, true, cl);
            }
          catch (ClassNotFoundException nex2)
            {
              // Try next.
            }
        }
    }
  return null;
}
 
开发者ID:vilie,项目名称:javify,代码行数:40,代码来源:NamingManager.java


示例11: resolveClass

import gnu.classpath.VMStackWalker; //导入依赖的package包/类
protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
        try {
                return RMIClassLoader.loadClass(
                    (String)getAnnotation(),
                    desc.getName(),
                    VMStackWalker.firstNonNullClassLoader());
        }
        catch (MalformedURLException x) {
                throw new ClassNotFoundException(desc.getName(), x);
        }
}
 
开发者ID:vilie,项目名称:javify,代码行数:12,代码来源:RMIObjectInputStream.java


示例12: resolveProxyClass

import gnu.classpath.VMStackWalker; //导入依赖的package包/类
protected Class resolveProxyClass(String intfs[]) throws IOException,
    ClassNotFoundException
{
  try
    {
      return RMIClassLoader.loadProxyClass(
          (String)getAnnotation(),
          intfs,
          VMStackWalker.firstNonNullClassLoader());
    }
  catch (MalformedURLException x)
    {
      throw new ClassNotFoundException(null, x);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:16,代码来源:RMIObjectInputStream.java


示例13: forName

import gnu.classpath.VMStackWalker; //导入依赖的package包/类
/**
 * Load the class with the given name. This method tries to use the context
 * class loader first. If this fails, it searches for the suitable class
 * loader in the caller stack trace. This method is a central point where all
 * requests to find a class by name are delegated.
 */
public static Class forName(String className) throws ClassNotFoundException
{
  try
    {
      return Class.forName(className, true,
                           Thread.currentThread().getContextClassLoader());
    }
  catch (ClassNotFoundException nex)
    {
      /**
       * Returns the first user defined class loader on the call stack, or
       * null when no non-null class loader was found.
       */
      Class[] ctx = VMStackWalker.getClassContext();
      for (int i = 0; i < ctx.length; i++)
        {
          // Since we live in a class loaded by the bootstrap
          // class loader, getClassLoader is safe to call without
          // needing to be wrapped in a privileged action.
          ClassLoader cl = ctx[i].getClassLoader();
          try
            {
              if (cl != null)
                return Class.forName(className, true, cl);
            }
          catch (ClassNotFoundException nex2)
            {
              // Try next.
            }
        }
    }
  throw new ClassNotFoundException(className);
}
 
开发者ID:vilie,项目名称:javify,代码行数:40,代码来源:ObjectCreator.java


示例14: 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;
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:23,代码来源:ClassLoader.java


示例15: resolveClass

import gnu.classpath.VMStackWalker; //导入依赖的package包/类
protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
	try {
                return RMIClassLoader.loadClass(
                    (String)getAnnotation(),
                    desc.getName(),
                    VMStackWalker.firstNonNullClassLoader());
	}
	catch (MalformedURLException x) {
		throw new ClassNotFoundException(desc.getName(), x);
	}
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:12,代码来源:RMIObjectInputStream.java


示例16: resolveProxyClass

import gnu.classpath.VMStackWalker; //导入依赖的package包/类
protected Class resolveProxyClass(String intfs[]) throws IOException,
    ClassNotFoundException
{
  try 
    {
      return RMIClassLoader.loadProxyClass(
          (String)getAnnotation(),
          intfs,
          VMStackWalker.firstNonNullClassLoader());
    }
  catch (MalformedURLException x) 
    {
      throw new ClassNotFoundException(null, x);
    }
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:16,代码来源:RMIObjectInputStream.java



注:本文中的gnu.classpath.VMStackWalker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WebResponseData类代码示例发布时间:2022-05-22
下一篇:
Java View类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap