类 JavaAgentClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- java.security.SecureClassLoader
-
- java.net.URLClassLoader
-
- io.esastack.cabin.container.service.loader.AbstractClassLoader
-
- io.esastack.cabin.container.service.loader.JavaAgentClassLoader
-
- 所有已实现的接口:
Closeable,AutoCloseable
public class JavaAgentClassLoader extends AbstractClassLoader
When the agent classes are loaded? while jvm define a class, it will check if any agents are provided to instrument the class, and the enhanced class byte code are used to create the new Class Object with the original classloader, while the weaved-in code is executed, the agent classes are load by the original classloader. Default handling of JVM? By default, java agent jar URLs will be included in the SystemClassLoader classpath, if cabin is not used, no matter using java -jar or java -cp to setup a program, all the agent urls and biz urls are in the SystemClassloader. Handling of Cabin? + While cabin is used, agent urls can be handled as biz urls, and there is no isolation between agent and biz urls. + Cabin use JavaAgentClassLoader to load agent classes for isolation. + Agent classes can load classes from biz: default imported classes(spring/jedis/slf4j, etc.), provided classes. + Agent Classes can load classes from lib: exported classes, provided classes. + Biz and lib can load classes from agent: classes used in weaved-in code.
-
-
字段概要
-
从类继承的字段 io.esastack.cabin.container.service.loader.AbstractClassLoader
classLoaderService, moduleName, sharedClassService, sharedResourceService
-
-
构造器概要
构造器 构造器 说明 JavaAgentClassLoader(URL agentUrl)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 URLgetAgentUrl()protected URLgetResource0(String name)Pay attention to the priority of finding resource: jdk, exported, bizprotected Enumeration<URL>getResources0(String name)Pay attention to the priority of finding resource: jdk, exported, bizprotected Class<?>loadClass0(String name, boolean resolve)Why we need to load class from Biz and Libs?-
从类继承的方法 io.esastack.cabin.container.service.loader.AbstractClassLoader
debugClassLoadMessage, getBizResource, getBizResources, getExportResource, getExportResources, getJavaAgentResource, getJavaAgentResources, getJdkResource, getJdkResources, getLocalResource, getLocalResources, getModuleName, getResource, getResources, loadAgentClass, loadBizClass, loadCabinClass, loadClass, loadClassFromClasspath, loadFromRecords, loadImportClassFromBiz, loadJdkClass, loadLocalClass, loadSharedClass, shouldImportClassFromBiz
-
从类继承的方法 java.net.URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
-
从类继承的方法 java.security.SecureClassLoader
defineClass, defineClass
-
从类继承的方法 java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
-
-
-
构造器详细资料
-
JavaAgentClassLoader
public JavaAgentClassLoader(URL agentUrl)
-
-
方法详细资料
-
getAgentUrl
public URL getAgentUrl()
-
loadClass0
protected Class<?> loadClass0(String name, boolean resolve) throws CabinLoaderException
Why we need to load class from Biz and Libs? The Pre-Main class would be loaded by SystemClassLoader while the Jvm started; If some code are weaved in, the code may include another Class in the agent jar and this class may depend on some biz/module classes, this class would be loaded by agent classloader, so agent classloader must delegate class loading to biz and module classloader too; Because the agent implementation may dependency some provided jars which is provided by users; In normal setup way, these jars will loaded by AppClassloader, same classloader of agent jars.- 指定者:
loadClass0在类中AbstractClassLoader- 抛出:
CabinLoaderException
-
getResources0
protected Enumeration<URL> getResources0(String name) throws IOException
从类复制的说明:AbstractClassLoaderPay attention to the priority of finding resource: jdk, exported, biz- 指定者:
getResources0在类中AbstractClassLoader- 抛出:
IOException
-
getResource0
protected URL getResource0(String name)
从类复制的说明:AbstractClassLoaderPay attention to the priority of finding resource: jdk, exported, biz- 指定者:
getResource0在类中AbstractClassLoader
-
-