Skip to content

Instrument project code (process-classes / process-test-classes) #1

@dblevins

Description

@dblevins

Summary

Add a new goal that enhances bytecode in target/classes/ and target/test-classes/ so developers can instrument their own project code, not just dependency jars.

Motivation

Currently, instrumentation only works on dependency jars (ProcessMojo swaps patched jars via Artifact.setFile()). But the primary debugging use case — a test fails, you need to see what your own code is doing — requires instrumenting project code.

Design

  • Single goal, two executions bound to process-classes and process-test-classes phases
  • Reads instrument configs from .jackknife/instrument/ (same as ProcessMojo)
  • Scans .class files in the target directory, applies HandlerEnhancer in place
  • Modified bytecode is what test and package phases see — no classloader tricks needed

Example

mvn jackknife:instrument -Dclass=com.example.MyService -Dmethod=process
mvn test

Debug output appears when tests call MyService.process().

Acceptance Criteria

  • Instrument a method in src/main/java, verify debug output during test
  • Instrument a method in src/test/java, verify debug output during test
  • Integration tests: single-instrument-mainclass, single-instrument-testclass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions