Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Annotation Processing

Annotation Processing

Building a Java Annotation Processor.

We look at runtime and compile time annotation processing.

Corneil du Plessis

June 25, 2018
Tweet

More Decks by Corneil du Plessis

Other Decks in Programming

Transcript

  1. Agenda • What are annotation processors? • How can we

    use annotation processors? • How do we build an annotation processor?
  2. Java Annotations – A Primer • Annotations are Class metadata

    • Annotations can be used at runtime. • Annotations can be used at compile time.
  3. Annotation Processors – Why? • Generate source code or resources.

    • Modify existing source. • Analyse existing code to provide diagnostic feedback.
  4. Debugging your Annotation Processors • Add Compiler option: -Xdebug -

    agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=7777 • Debug remote (Attach) with options: -Xdebug - agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7777 • Set break point on process method. • Build will pause so that you can attach debugger.
  5. Finally • Contact: @corneil • Source Code - https://github.com/corneil/static-requirements •

    Resources • https://www.javacodegeeks.com/2015/09/java-annotation-proc essors.html • http://hannesdorfmann.com/annotation-processing/annotation processing101 Questions?