Skip to content
This repository was archived by the owner on Nov 29, 2025. It is now read-only.
melontini edited this page Jan 6, 2024 · 4 revisions

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

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.

Clone this wiki locally