Rework plugin system
What's new
Plugin system is now reworked to act as a graph with dependencies.
Each plugin is loaded in its own class loader controlled by plugin manager.
Plugin loaders no longer participate in plugin loading, but only prepare plugins to be loaded.
To load plugins from a directory or any arbitrary source, PluginDiscoverer may be implemented.
TBD
- Plugin unloading
- Migrate to JGraphT
- Load plugins from the directory when Recaf starts. IMO the code to do that should be moved to main class and not be in
@PostConstructwith test env hack. - Think if we should even have the concept of "startup" plugins. There probably needs work to be done to properly cleanup plugins when they are unloaded.
Unit test results
53 files ±0 53 suites ±0 23s :stopwatch: -1s 382 tests +2 376 :white_check_mark: +2 6 :zzz: ±0 0 :x: ±0 393 runs +2 387 :white_check_mark: +2 6 :zzz: ±0 0 :x: ±0
Results for commit 5c440492. ± Comparison against base commit b5dab0ec.
:recycle: This comment has been updated with latest results.
Codecov Report
Attention: Patch coverage is 71.62162% with 147 lines in your changes missing coverage. Please review.
Project coverage is 70.24%. Comparing base (
b5dab0e) to head (5c44049).
Additional details and impacted files
@@ Coverage Diff @@
## dev4 #780 +/- ##
============================================
+ Coverage 70.01% 70.24% +0.23%
- Complexity 3106 3149 +43
============================================
Files 354 358 +4
Lines 16252 16527 +275
Branches 1872 1899 +27
============================================
+ Hits 11379 11610 +231
- Misses 3961 3992 +31
- Partials 912 925 +13
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
PhantomGeneratorTest > test() FAILED
org.opentest4j.AssertionFailedError at PhantomGeneratorTest.java:67
14:44:33.537 [JPhantomGenerator/main] ERROR: Phantom analysis encountered an exception.
java.lang.NoClassDefFoundError: org/jgrapht/DirectedGraph
at org.clyze.jphantom.JPhantom.run(JPhantom.java:73)
at software.coley.recaf.services.phantom.JPhantomGenerator.generate(JPhantomGenerator.java:177)
at software.coley.recaf.services.phantom.JPhantomGenerator.createPhantomsForClasses(JPhantomGenerator.java:102)
at software.coley.recaf.services.phantom.JPhantomGenerator$Proxy$_$$_WeldClientProxy.createPhantomsForClasses(Unknown Source)
at software.coley.recaf.services.phantom.PhantomGeneratorTest.lambda$test$0(PhantomGeneratorTest.java:63)
at org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:71)
at org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:58)
at org.junit.jupiter.api.Assertions.assertDoesNotThrow(Assertions.java:3228)
at software.coley.recaf.services.phantom.PhantomGeneratorTest.test(PhantomGeneratorTest.java:63)
Caused by: java.lang.ClassNotFoundException: org.jgrapht.DirectedGraph
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
... 77 common frames omitted
Adding JGraphT 1.5.2 breaks JPhantom
If you look at the JPhantom fork we have:
<dependency>
<groupId>org.jgrapht</groupId>
<artifactId>jgrapht-core</artifactId>
<version>1.0.1</version> <!-- After 1.1.0 are major api incompatibilities -->
</dependency>
🤦
Think if we should even have the concept of "startup" plugins.
I made it so that plugins are only loaded from the path discoverer if they have .jar as a suffix. We can thus handle this concept by changing the extension.