-
Notifications
You must be signed in to change notification settings - Fork 149
Description
Context & Motivation
MBassador is currently a robust event bus, but it relies heavily on standard Reflection (java.lang.reflect) for dispatch and requires manual registration of listeners (bus.subscribe(bean)).
Dimension-DI, a lightweight dependency injection framework that achieves near zero-configuration startup by using the JDK Class-File API. It scans the classpath directly for annotations without loading classes into the ClassLoader, resulting in extremely fast startup times.
I believe MBassador could benefit significantly from adopting similar mechanisms, specifically leveraging features available in Java 24+ (JEP 484 - Class-File API).
The Proposal
I propose two key enhancements to modernize the library, drawing directly from my experience building Dimension-DI:
Zero-Config Auto-Discovery (The "Dimension-DI" approach):
Implement a classpath scanner using the JDK 24+ java.lang.classfile API. This allows MBassador to find classes containing @handler methods by reading bytecode directly. This enables auto-subscription of listeners without users needing to manually register them, and without the performance penalty of loading every class to check for annotations via reflection.
High-Performance Dispatch (MethodHandles):
Replace java.lang.reflect.Method.invoke in ReflectiveHandlerInvocation with java.lang.invoke.MethodHandle. MethodHandles provide performance closer to direct method calls and are the modern standard for dynamic invocation.
Is this a direction you would be interested in taking the project? I would be happy to work on a Pull Request if the concept is approved.