Today I was fiddling around with the classloading mechanism of IntelliJ IDEA.
The standard flow of the start-up mechanism is as follow:
And the custom com.intellij.util.lang.UrlClassLoader
- which loads all the IDEA-related JARs is created as follow:
The red area in the diagram shows where I modified UrlClassLoader
creation.
Instead of having directly PlatformClassLoader
as parent, it has AppClassLoader
first.
In the standard flow everything works, but when I introduce AppClassLoader
a ClassNotFoundException
is raised in com.intellij.ide.plugins.MainRunner
, specifically when it tries to load com.intellij.diagnostic.StartUpMeasurer
, which uses it.unimi.dsi.fastutil.objects.Object2LongMap
.
The exact exception is:
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.intellij.idea.Main.bootstrap(Main.java:123)
at com.intellij.idea.Main.main(Main.java:95)
Caused by: java.lang.NoClassDefFoundError: it/unimi/dsi/fastutil/objects/Object2LongMap
at com.intellij.ide.plugins.MainRunner.start(MainRunner.java:26)
... 6 more
Caused by: java.lang.ClassNotFoundException: it.unimi.dsi.fastutil.objects.Object2LongMap
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 7 more
What is happening here?