javassist.Loader.findClass()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(244)

本文整理了Java中javassist.Loader.findClass()方法的一些代码示例,展示了Loader.findClass()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Loader.findClass()方法的具体详情如下:
包路径:javassist.Loader
类名称:Loader
方法名:findClass

Loader.findClass介绍

[英]Finds the specified class using ClassPath. If the source throws an exception, this returns null.

This method can be overridden by a subclass of Loader. Note that the overridden method must not throw an exception when it just fails to find a class file.
[中]使用ClassPath查找指定的类。如果源抛出异常,则返回null。
此方法可由Loader的子类重写。请注意,被重写的方法在找不到类文件时不能引发异常。

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Requests the class loader to load a class.
 */
protected Class loadClass(String name, boolean resolve)
  throws ClassFormatError, ClassNotFoundException {
  name = name.intern();
  synchronized (name) {
    Class c = findLoadedClass(name);
    if (c == null)
      c = loadClassByDelegation(name);
    if (c == null)
      c = findClass(name);
    if (c == null)
      c = delegateToParent(name);
    if (resolve)
      resolveClass(c);
    return c;
  }
}

代码示例来源:origin: org.javassist/javassist

/**
 * Requests the class loader to load a class.
 */
@Override
protected Class<?> loadClass(String name, boolean resolve)
  throws ClassFormatError, ClassNotFoundException {
  name = name.intern();
  synchronized (name) {
    Class<?> c = findLoadedClass(name);
    if (c == null)
      c = loadClassByDelegation(name);
    if (c == null)
      c = findClass(name);
    if (c == null)
      c = delegateToParent(name);
    if (resolve)
      resolveClass(c);
    return c;
  }
}

代码示例来源:origin: google/gwtmockito

@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
 // If the class is in a blacklisted package, load it with the parent or default classloader.
 for (String blacklistedPackage : getPackagesToLoadViaStandardClassloader()) {
  if (name.startsWith(blacklistedPackage)) {
   return null;
  }
 }
 // Otherwise load it with our custom classloader.
 return super.findClass(name);
}

代码示例来源:origin: com.google.gwt.gwtmockito/gwtmockito

@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
 // If the class is in a blacklisted package, load it with the parent or default classloader.
 for (String blacklistedPackage : getPackagesToLoadViaStandardClassloader()) {
  if (name.startsWith(blacklistedPackage)) {
   return null;
  }
 }
 // Otherwise load it with our custom classloader.
 return super.findClass(name);
}

代码示例来源:origin: com.github.japgolly.android.test/robolectric

@Override
  protected Class findClass(String name) throws ClassNotFoundException {
    byte[] classBytes = classCache.getClassBytesFor(name);
    if (classBytes != null) {
      return defineClass(name, classBytes, 0, classBytes.length);
    }
    return super.findClass(name);
  }
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

/**
 * Requests the class loader to load a class.
 */
protected Class loadClass(String name, boolean resolve)
  throws ClassFormatError, ClassNotFoundException {
  name = name.intern();
  synchronized (name) {
    Class c = findLoadedClass(name);
    if (c == null)
      c = loadClassByDelegation(name);
    if (c == null)
      c = findClass(name);
    if (c == null)
      c = delegateToParent(name);
    if (resolve)
      resolveClass(c);
    return c;
  }
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

/**
 * Requests the class loader to load a class.
 */
protected Class loadClass(String name, boolean resolve)
  throws ClassFormatError, ClassNotFoundException {
  name = name.intern();
  synchronized (name) {
    Class c = findLoadedClass(name);
    if (c == null)
      c = loadClassByDelegation(name);
    if (c == null)
      c = findClass(name);
    if (c == null)
      c = delegateToParent(name);
    if (resolve)
      resolveClass(c);
    return c;
  }
}

代码示例来源:origin: org.jboss.javassist/com.springsource.javassist

/**
 * Requests the class loader to load a class.
 */
protected Class loadClass(String name, boolean resolve)
  throws ClassFormatError, ClassNotFoundException {
  name = name.intern();
  synchronized (name) {
    Class c = findLoadedClass(name);
    if (c == null)
      c = loadClassByDelegation(name);
    if (c == null)
      c = findClass(name);
    if (c == null)
      c = delegateToParent(name);
    if (resolve)
      resolveClass(c);
    return c;
  }
}

代码示例来源:origin: org.jboss/javassist

/**
 * Requests the class loader to load a class.
 */
protected Class loadClass(String name, boolean resolve)
  throws ClassFormatError, ClassNotFoundException {
  name = name.intern();
  synchronized (name) {
    Class c = findLoadedClass(name);
    if (c == null)
      c = loadClassByDelegation(name);
    if (c == null)
      c = findClass(name);
    if (c == null)
      c = delegateToParent(name);
    if (resolve)
      resolveClass(c);
    return c;
  }
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

/**
 * Requests the class loader to load a class.
 */
protected Class loadClass(String name, boolean resolve)
  throws ClassFormatError, ClassNotFoundException {
  name = name.intern();
  synchronized (name) {
    Class c = findLoadedClass(name);
    if (c == null)
      c = loadClassByDelegation(name);
    if (c == null)
      c = findClass(name);
    if (c == null)
      c = delegateToParent(name);
    if (resolve)
      resolveClass(c);
    return c;
  }
}

相关文章