当前位置: 首页>>代码示例>>Java>>正文


Java VMStackWalker.getClassContext方法代码示例

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


在下文中一共展示了VMStackWalker.getClassContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: getCallerClass

import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
 * A stack-walking wrapper method used by the JSR 166 RI.
 */
public static Class getCallerClass(int depth)
{
  return VMStackWalker.getClassContext()[depth];
}
 
开发者ID:vilie,项目名称:javify,代码行数:8,代码来源:Reflection.java

示例5: getCallerClass

import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
 * A stack-walking wrapper method used by the JSR 166 RI. 
 */
public static Class getCallerClass(int depth)
{
  return VMStackWalker.getClassContext()[depth];
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:8,代码来源:Reflection.java

示例6: callerClassLoader

import gnu.classpath.VMStackWalker; //导入方法依赖的package包/类
/**
 * This method must be included, as it is used by System.load(),
 * System.loadLibrary(). The reference implementation of this method uses
 * the getStackClassLoader() method. Returns the ClassLoader of the method
 * that called the caller. i.e. A.x() calls B.y() calls callerClassLoader(),
 * A's ClassLoader will be returned. Returns null for the bootstrap
 * ClassLoader.
 * 
 * @return a ClassLoader or null for the bootstrap ClassLoader
 */
static ClassLoader callerClassLoader() {
       Class[] classes = VMStackWalker.getClassContext();
       return classes[2].getClassLoader();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:15,代码来源:ClassLoader.java


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