0

I am developing a java plugin (for BungeeCord) which uses Methods from Guava 28.2. But BungeeCord, the programm that actually loads my plugin, only uses Guava 21. Therefor my plugin crashes since it can't find some methods from Guava 28.2.

Is there a way to make my plugin load its own version of guava and use this version instead of the old one? Can this be done using classloader magic?

Any help is appreciated

derteufelqwe
  • 113
  • 2
  • 9
  • Possible duplicate: https://stackoverflow.com/questions/6105124/java-classpath-classloading-multiple-versions-of-the-same-jar-project – Kartal Tabak Apr 12 '20 at 22:32

2 Answers2

0

If you are developing a plugin for a program, then try to obey the limitations of the program. The handling of multiple versions of the same library is not very trivial and often prone to errors.

Options that I would follow:

  • Downgrade to Guava 21.
  • Propose the upgrade to Guava 21.
  • If that plugin is running part of an application server, try to deploy as a separate application, employ inter-application communication.
  • Try OSGi.
Kartal Tabak
  • 760
  • 1
  • 7
  • 18
0

No classloader magic needed. The wanted mechanism from maven is called relocation. Relocations can change the package of a library at compile time to prevent conflicts. Using this you can relocate com.google.commons to my.shaded.version.com.google.commons for example and prevent conflicts.

https://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html

derteufelqwe
  • 113
  • 2
  • 9