This is the code for the exercise in Java code instrumentation for beginners workshop. The exercise is to build a simple profiler in java to test and see how instrumentation in java works.
The workshop was presented in DevConf.us 2022.
Then it transformed to Interactive Application Security Testing (IAST) - Under the hood workshop in Hackeriot 2024
There are three modules this project:
-
tested-app
A simple app that just writes to a log a constant message. It is used to test the profiler. -
profiler
A profiler agent that instruments the log method. You should work on this folder to improve the profiler. It instruments the java.util.logging.Logger.log using JavaAssist. -
profiler-solution
A profiler agent that instruments the log method. This is a solution to the exercises given in the workshop. It instruments the java.util.logging.Logger.log using JavaAssist. -
riddles
The riddles folder contains two riddles that can be solved using the profiler you will write. You can find there aREADMEfile with the run instructions.
- Go to the GitHub repository: JavaInstrumentationWorkshop.
- Click the green Code button.
- Select Codespaces → Create codespace on main.
- Wait for the environment to initialize. It will automatically:
- Clone the workshop repo
- Install Java 17, Maven, and Git
- Set up Java extensions for VS Code
You can now start coding directly in your browser!
- Download and install JetBrains Gateway
- Open JetBrains Gateway and install the GitHub Codespaces plugin
- Log in with your GitHub account
- Select the
JavaInstrumentationWorkshopCodespace - Launch it in JetBrains Gateway
This gives you a full IntelliJ experience backed by a cloud-hosted VM.
Happy coding! 🎉
For working on this project you will need an IDE, Maven as the build tool and a JDK.
If you have these installed you can move to Test and run the profiler section.
Otherwise, install the following - or go to DEV_ENV_SETUP file for a step by step instructions.
- IDE.
If you don't have a preferred working IDE, download and install Intellij Community Edition for free. - Maven
Download Maven, the build tool used in this project, from here and extract it to a folder (no installation required). Then, add the maven/build folder to the PATH variable. - JDK
If you don't have a JDK installed, download any version of JDK. The project was tested with JDK 1.8, 17 and 23. You can use IntelliJ to download the JDK by following the steps explained here.
Build the project
mvn installTo execute the tested app without the profiler run
java -jar ./tested-app/target/tested-app-1.0.jarTo execute the tested app with the profiler run
java -javaagent:./profiler/target/profiler-1.0-jar-with-dependencies.jar -jar ./tested-app/target/tested-app-1.0.jar