Debugging an annotation processor using IntelliJ IDEA in 2018

Joachim Beckers
May 10, 2018 · 5 min read


Option 1: Attach mode, using built-in IDEA feature

1. Create a Remote Run Configuration

Remote Run Configuration for Attach mode

2. Make sure the build process uses your port

3. Enable “Debug build process”

Built-in build process debugging

4. Try it out

Sprinkle those break point all around!
Work work work
Pause pause pause
Let the beast go!
It works!

Option 2: Attach mode, using custom settings

1. Create a Remote Run Configuration

Remote Run Configuration for Attach mode

2. Configure the Shared build process VM options

Shared build process VM options for Attach mode
-Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
-Xdebug [the string you copied earlier]
We don’t need no forked javac

4. Try it out

Sprinkle those break point all around!
Work work work
Let the beast go!
It works!

Option 3: Listen mode

1. Create a Remote Run Configuration

Run configuration for Listen mode

2. Configure the javac command line parameters

Compiler options
-J-Xdebug -J-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:8000,suspend=y,onuncaught=n
-J-Xdebug -J[the string you copied earlier]

3. Try it out

Sprinkle those break point all around!
Let the beast go!
Work work work
It works!

Notes

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade