Allows loading classes from Projector, Projector agent and Intellij Platform without the use of reflection
Default AppClassLoader of Projector Server doesn't know anything about JB IDE and so cannot load its classes as they were loaded by different classloader. Similar, IDE ClassLoader doesn't know anything about Projector classes (and can be gathered only after IDE startup).
The idea behind ProjectorClassLoader is simple - delegate classloading to the right classloader. If we think classname determines a class from Intellij Platform then we should load it via IDE ClassLoader. If not, then we fall back to load it via AppClassLoader.
To specify how classes should be loaded with ProjectorClassLoader you need to call one of the
|Method Name||ClassLoader for specified class(es)|
||ProjectorClassLoader (gather bytecode from any of AppClassLoader or IDE ClassLoader and then define class ourselves)|
||IDE ClassLoader (PathClassloader or UrlClassLoader, depending on IDE version)|
Another way to specify ClassLoader for class is to apply
To initialize ProjectorClassLoader, call function
package org.jetbrains.projector.server.core.classloader fun initClassLoader(classLoader: ClassLoader): ClassLoader
Don't forget to load some other class (which will be the actual entry point for the Projector/Projector agent logic) with returned ClassLoader (if current ClassLoader is not ProjectorClassLoader) to start using ProjectorClassLoader
Currently, function is used at:
||Default entry point|
||Entry point for CWM|
||Projector Plugin entry point|
Support for agent classes¶
Agent classes are now loaded in the same manner as regular Projector classes. However, if in the future ProjectorClassLoader will be set as a System ClassLoader, then ProjectorClassLoader needs to use
appendToClassPathForInstrumentation(String jarPath) method to get the location of agent jar file. It's already implemented, so no extra work to support loading classes from agent JAR file is required.