/HoTea

Plug-In framework with HOT Class reloading for dynamic script-like Java

Primary LanguageJavaApache License 2.0Apache-2.0

Hot Chai (tea) with Java coffee (ch.vorburger.hotea)

Please also check out the follow-up projects ch.vorburger.osgi.gradle and ch.vorburger.minecraft.osgi.

The Minecraft specific part is in the minecraft/ module. What follows here is a general library (not Minecraft related, but the Minecraft module uses this).

Hotea is a "kept it simple and stupid" (KISS) Java Mod-ules/Plug-In mini framework with HOT Class reloading to "support dynamic script like source code" (through isolated ClassLoader/s). This may be of interest and useful to you to build things ranging from e.g. plugins for game engines to perhaps some sort of runtime changeable coded out "business rule" stuff.

Watch this https://www.youtube.com/watch?v=oMhY075hx9k and this https://www.youtube.com/watch?v=mibW8MhenGc vidoe, or see e.g. the HotSwingExampleMain or the Tests, for illustrations regarding what this is really all about.

Caveat emptor: This is intended for and best works with simple plugin-like scenarios, where the classpath of each such plugin does not overlap nor need to share instances among different plugins. In more interesting use cases, by experience, Very Weired Things (VWT) may happen if you don't fully understand what you are actually doing when several class loaders are involved in Java. You have been warned.

Use of Java 8 is recommended to avoid PermGen memory issues due to Class reloading.

Features: (what it does do)

  • Load Java byte code for additional *.classes from directory/-ies and/or JARs, through a child ClassLoader
  • Hot reload such extensions/modules/plugins/bundles whenever any files in the watched classpath directory are updated
  • Notify your code whenever it hot reloaded, so that you can do what you need to do in your code (say cleanly shut down previous instances of your classes, and re-instantiate objects using your new class definitions)
  • TODO Build *.class files from *.java sources files, and auto. rebuild on any changes (ch.vorburger.hotea.compilewatchedfiles)
  • No need to follow a particular "Plugin API" at all (of Hotea, there is none) - you can hot (re)load any class implementing any of your own "API" interface

Non-Features, what it does NOT do, not today and not planned:

  • Hot-reload classes on your (already loaded) "main" primary classpath - no JVM Agent
  • Dependencies between modules/plugins/bundles (perhaps you want to look at OSGi?)
  • Versioning of modules/plugins/bundles (perhaps you want to look at OSGi?)
  • Repositories, remote provisioning, etc.
  • Remote API export etc.

Hotea is thus somewhat similar yet quite different from:

Class A: Approaches which hot-reload classes on your (already loaded) "main" primary classpath typically through a custom JVM Agent (with more or less limitations):

Class B: Other extensions/modules/plugins/bundles

Class C: Approaches between A/B

Class D: Other related stuff

Class E: Related articles