liveBook · Manning

Reflection

As explained in Quarkus in Action

Reflection is the runtime inspection and manipulation of program elements such as classes and methods through metadata rather than only statically referenced code.

Reflection lets a program inspect or access elements such as classes and methods through metadata instead of relying only on statically referenced code. In native compilation, this runtime flexibility creates a packaging requirement: the native-image builder must know reflectively accessed classes before producing the executable. section 2.7.2 section 12.1.8

Native Quarkus applications handle reflection through advance registration and build-time integration:

  • Register application classes explicitly with @RegisterForReflection when native mode needs their reflection metadata. section 12.1.8
  • Prefer Quarkus extensions for integrated libraries and frameworks; extensions can detect reflectively used classes and register them automatically. section 2.7.2 section 12.1.8
  • Treat missing registration as a native-build or runtime compatibility concern, even when the same code works on a regular Java runtime. section 2.7.2 section 12.1.8

Registering reflective access

An application class accessed reflectively can be marked with @RegisterForReflection before compiling a native executable. When the class belongs to a supported library or framework, a Quarkus extension can provide the equivalent registration during build-time processing, avoiding manual configuration. section 12.1.8 section 2.7.2

How Quarkus in Action covers it

How deep it goes
Explains native-image registration and extension assistance, but stops short of detailing reflection APIs or metadata internals.
Examples
Uses @RegisterForReflection and automatic class registration by Quarkus extensions as concrete configuration examples.
What you can do after
Operate/configure native builds by registering reflectively accessed classes or selecting extensions that register them automatically.
How it connects
Connects reflection with native compilation, GraalVM, Quarkus extensions, and build-time processing.

Also explained in

Compare how 13 books explain reflection →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.