-
Notifications
You must be signed in to change notification settings - Fork 0
Danger
This page covers the Danger module of Dark Matter.
Caution
Parts of this module can break on some JVM implementations.
Use of instrumentation will trigger CurseForge's malware detector, which will send your mods to review purgotory.
InstrumentationAccess is a class which... Allows access to instrumentation.
If you need direct access to instrumentation, use getOrEmpty(). This method returns an optional, which is empty if the agent couldn't be attached.
The other thing this class allows you to do, is retransform classes at runtime using ASM. A nice example of this would be BlameLog. Which patches AbstractLogger and Log4jLogger to prepend method caller's name.
Additional wrappers are provided:
addReads(Module, Module...)addExports(Module, Map<String, Set<Module>>)addOpens(Module, Map<String, Set<Module>>)addUses(Module, Class<?>...)addProvides(Module, Map<Class<?>, List<Class<?>>>)
The built-in instrumentation doesn't allow you to do much in terms of changing classes. You will only be able to modify method byte code and add/remove annotations. Other things are blocked by the JVM (Unless the user is running JBR with -XX:+AllowEnhancedClassRedefinition).
Note
The attachment process used by this module is non-standard (avoids ByteBuddy) and hooks into JVM internals. See InstrumentationInternals.
Dark Matter wiki by constellation-mc is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
