java - Java 中的类加载器变体和用法

标签 java classloader

我知道 java.lang.ClassLoader 通常是我扩展的类加载器(在需要时)。另外,当我看到 tomcat、Jetty 等的自定义类加载器都是从 java.lang.ClassLoader 扩展而来的。

我很想了解 com.sun.org.apache.bcel.internal.util.ClassLoader 的目的和用法。

谁能帮我理解一下吗?

最佳答案

com.sun.org.apache.bcel.internal 只是 Apache BCEL 的重新打包。 。特别是,我们感兴趣的类 (ClassLoader) 记录在 here 中。 ...

Drop in replacement for the standard class loader of the JVM. You can use it in conjunction with the JavaWrapper to dynamically modify/create classes as they're requested.

This class loader recognizes special requests in a distinct format, i.e., when the name of the requested class contains with "$$BCEL$$" it calls the createClass() method with that name (everything before the $$BCEL$$ is considered to be the package name. You can subclass the class loader and override that method. "Normal" classes class can be modified by overriding the modifyClass() method which is called just before defineClass().

关于java - Java 中的类加载器变体和用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12337283/

相关文章:

java - 我得到一个 "exception in thread "main"java.lang.NoClassDefFoundError : org/openqa/selenium/WebDriver"

osgi - ClassLoader只在特定的Threads中查找Resource

java - 如何使用 DateTimeFormatter 解析非标准月份名称

java - 订阅者不是一个函数式接口(interface)

Java : Error in Cursor automatically move from one TextField to other

java - 测试重新部署 Web 应用程序时是否存在内存泄漏

java - Java 中的类加载器

java - 相同的java代码,两个.class文件的类加载问题?

java - 使用 java 在 HSQL 数据库中出现异常 - 用户缺乏权限或未找到对象错误

java - 为什么变量在同步时对其他线程不可见?