diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/RegisterForReflectionBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/RegisterForReflectionBuildStep.java
index 264350bb54b5c..7deaf882534f9 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/steps/RegisterForReflectionBuildStep.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/RegisterForReflectionBuildStep.java
@@ -50,7 +50,7 @@ public void build(CombinedIndexBuildItem combinedIndexBuildItem, Capabilities ca
boolean methods = getBooleanValue(i, "methods");
boolean fields = getBooleanValue(i, "fields");
- boolean ignoreNested = getBooleanValue(i, "ignoreNested");
+ boolean ignoreNested = i.value("ignoreNested") != null && i.value("ignoreNested").asBoolean();
boolean serialization = i.value("serialization") != null && i.value("serialization").asBoolean();
boolean unsafeAllocated = i.value("unsafeAllocated") != null && i.value("unsafeAllocated").asBoolean();
diff --git a/core/runtime/src/main/java/io/quarkus/runtime/annotations/RegisterForReflection.java b/core/runtime/src/main/java/io/quarkus/runtime/annotations/RegisterForReflection.java
index 8cf279a84f64b..f08da15fcdd9b 100644
--- a/core/runtime/src/main/java/io/quarkus/runtime/annotations/RegisterForReflection.java
+++ b/core/runtime/src/main/java/io/quarkus/runtime/annotations/RegisterForReflection.java
@@ -7,9 +7,12 @@
/**
* Annotation that can be used to force a class to be registered for reflection in native image mode.
- * Note that by default nested classes and interfaces are not registered, unless {@link #ignoreNested()} is set to false.
- * Similarly, by default only the class itself is registered, not the full class hierarchy. This can be changed by setting
- * {@link #registerFullHierarchy()} to true.
+ * Note that by default the class itself is registered including nested classes and interfaces,
+ * but not the full class hierarchy. This can be changed by setting:
+ *
+ * - {@link #ignoreNested()} to true, to ignore nested classes.
+ * - {@link #registerFullHierarchy()} to true, to register the full hierarchy.
+ *
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@@ -26,11 +29,10 @@
boolean fields() default true;
/**
- * If nested classes/interfaces should be ignored/registered
- *
- * This is useful when it's necessary to register inner (especially private) classes for Reflection.
+ * If nested classes/interfaces should be ignored.
+ * By default, nested classes are registered. To ignore them set it to true.
*/
- boolean ignoreNested() default true;
+ boolean ignoreNested() default false;
/**
* Alternative classes that should actually be registered for reflection instead of the current class.
diff --git a/devtools/cli/src/main/java/io/quarkus/cli/core/Reflections.java b/devtools/cli/src/main/java/io/quarkus/cli/core/Reflections.java
index 2fe0dffa125d3..b3e6eb35849de 100644
--- a/devtools/cli/src/main/java/io/quarkus/cli/core/Reflections.java
+++ b/devtools/cli/src/main/java/io/quarkus/cli/core/Reflections.java
@@ -39,6 +39,6 @@
org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory.class,
org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.class,
org.eclipse.aether.transport.wagon.WagonTransporterFactory.class
-})
+}, ignoreNested = true)
public class Reflections {
}
diff --git a/integration-tests/devtools-registry-client/src/main/java/io/quarkus/registry/Reflections.java b/integration-tests/devtools-registry-client/src/main/java/io/quarkus/registry/Reflections.java
index ab4237ffc5c5d..305063b67eb54 100644
--- a/integration-tests/devtools-registry-client/src/main/java/io/quarkus/registry/Reflections.java
+++ b/integration-tests/devtools-registry-client/src/main/java/io/quarkus/registry/Reflections.java
@@ -28,6 +28,6 @@
io.quarkus.registry.json.JsonArtifactCoordsSerializer.class,
io.quarkus.registry.json.JsonBooleanTrueFilter.class,
io.quarkus.registry.json.JsonEntityWithAnySupport.class,
-})
+}, ignoreNested = true)
public class Reflections {
}
diff --git a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/DogDto2.java b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/DogDto2.java
index eaff3a23a772e..22d772fd165d4 100644
--- a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/DogDto2.java
+++ b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/DogDto2.java
@@ -3,7 +3,7 @@
import io.quarkus.hibernate.orm.panache.common.NestedProjectedClass;
import io.quarkus.runtime.annotations.RegisterForReflection;
-@RegisterForReflection(ignoreNested = false)
+@RegisterForReflection
public class DogDto2 {
public String name;
public PersonDto2 owner;
diff --git a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/PersonDTO.java b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/PersonDTO.java
index 1cb1e585aba96..58f5c874c63c7 100644
--- a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/PersonDTO.java
+++ b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/PersonDTO.java
@@ -4,7 +4,7 @@
import io.quarkus.hibernate.orm.panache.common.ProjectedFieldName;
import io.quarkus.runtime.annotations.RegisterForReflection;
-@RegisterForReflection(ignoreNested = false)
+@RegisterForReflection
public class PersonDTO extends PersonName {
public final AddressDTO address;
diff --git a/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/DogDto.java b/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/DogDto.java
index a8bc84a1cb024..594c600e25c05 100644
--- a/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/DogDto.java
+++ b/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/DogDto.java
@@ -3,7 +3,7 @@
import io.quarkus.hibernate.reactive.panache.common.NestedProjectedClass;
import io.quarkus.runtime.annotations.RegisterForReflection;
-@RegisterForReflection(ignoreNested = false)
+@RegisterForReflection
public class DogDto {
public String name;
public PersonDto owner;
diff --git a/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/PersonDTO.java b/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/PersonDTO.java
index 1be79e060457a..79aa802a9e5a2 100644
--- a/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/PersonDTO.java
+++ b/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/PersonDTO.java
@@ -4,7 +4,7 @@
import io.quarkus.hibernate.reactive.panache.common.ProjectedFieldName;
import io.quarkus.runtime.annotations.RegisterForReflection;
-@RegisterForReflection(ignoreNested = false)
+@RegisterForReflection
public class PersonDTO extends PersonName {
public final AddressDTO address;
diff --git a/integration-tests/jackson/src/main/java/io/quarkus/it/jackson/model/ModelWithSerializerAndDeserializerOnField.java b/integration-tests/jackson/src/main/java/io/quarkus/it/jackson/model/ModelWithSerializerAndDeserializerOnField.java
index 8cb4ff7f6963d..a5dca13f503d5 100644
--- a/integration-tests/jackson/src/main/java/io/quarkus/it/jackson/model/ModelWithSerializerAndDeserializerOnField.java
+++ b/integration-tests/jackson/src/main/java/io/quarkus/it/jackson/model/ModelWithSerializerAndDeserializerOnField.java
@@ -15,7 +15,7 @@
import io.quarkus.runtime.annotations.RegisterForReflection;
-@RegisterForReflection
+@RegisterForReflection(ignoreNested = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ModelWithSerializerAndDeserializerOnField {
diff --git a/integration-tests/jsonb/src/main/java/io/quarkus/it/jsonb/ModelWithSerializerAndDeserializerOnField.java b/integration-tests/jsonb/src/main/java/io/quarkus/it/jsonb/ModelWithSerializerAndDeserializerOnField.java
index ca13e2f3de83e..f3a5b1ce549a3 100644
--- a/integration-tests/jsonb/src/main/java/io/quarkus/it/jsonb/ModelWithSerializerAndDeserializerOnField.java
+++ b/integration-tests/jsonb/src/main/java/io/quarkus/it/jsonb/ModelWithSerializerAndDeserializerOnField.java
@@ -13,7 +13,7 @@
import io.quarkus.runtime.annotations.RegisterForReflection;
-@RegisterForReflection
+@RegisterForReflection(ignoreNested = true)
public class ModelWithSerializerAndDeserializerOnField {
private String name;
diff --git a/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceA.java b/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceA.java
index c5cdb5debb026..2d6fd6b205a6f 100644
--- a/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceA.java
+++ b/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceA.java
@@ -5,7 +5,7 @@
/**
* Only Parent Class will be registered and none of the inner classes will be registered for reflection.
*/
-@RegisterForReflection
+@RegisterForReflection(ignoreNested = true)
class ResourceA {
private class InnerClassOfA {
diff --git a/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceB.java b/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceB.java
index e0725f45acc6c..72993daad9315 100644
--- a/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceB.java
+++ b/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceB.java
@@ -5,7 +5,7 @@
/**
* Both Parent Class and all nested classed will be registered for reflection
*/
-@RegisterForReflection(ignoreNested = false)
+@RegisterForReflection
public class ResourceB {
private class InnerClassOfB {
diff --git a/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceC.java b/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceC.java
index 3441c74b47805..6a4e4db08b673 100644
--- a/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceC.java
+++ b/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceC.java
@@ -6,7 +6,7 @@
* This class is registering targets = ResourceD.StaticClassOfD
* The class itself won't be registered by this, only target will be registered without registering nested classes
*/
-@RegisterForReflection(targets = ResourceD.StaticClassOfD.class)
+@RegisterForReflection(targets = ResourceD.StaticClassOfD.class, ignoreNested = true)
public class ResourceC {
private class InaccessibleClassOfC {
diff --git a/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceD.java b/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceD.java
index 5591a7104a8d7..7030fcea0a93a 100644
--- a/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceD.java
+++ b/integration-tests/main/src/main/java/io/quarkus/it/rest/ResourceD.java
@@ -6,7 +6,7 @@
* This class is registering targets = ResourceC$InaccessibleClassOfC
* The class itself won't be registered by this, only target will be registered including target's nested classes
*/
-@RegisterForReflection(classNames = "io.quarkus.it.rest.ResourceC$InaccessibleClassOfC", ignoreNested = false)
+@RegisterForReflection(classNames = "io.quarkus.it.rest.ResourceC$InaccessibleClassOfC")
public class ResourceD {
// Parent class won't be registered, only the below private class will be registered without nested classes