Skip to content

Commit

Permalink
Consider all supertypes for serialization constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
loicottet committed Oct 28, 2024
1 parent dea1968 commit da249b0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void parseSerializationDescriptorObject(EconomicMap<String, Object> da
} else {
checkAttributes(data, "serialization descriptor object", Collections.singleton(NAME_KEY), Arrays.asList(CUSTOM_TARGET_CONSTRUCTOR_CLASS_KEY, CONDITIONAL_KEY));
}
RuntimeReflectionSupport.increaseCount(false);
RuntimeReflectionSupport.increaseCount(true);

ConfigurationTypeDescriptor targetSerializationClass = new NamedConfigurationTypeDescriptor(asString(data.get(NAME_KEY)));
UnresolvedConfigurationCondition unresolvedCondition = parseCondition(data, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected void parseSerializationDescriptorObject(EconomicMap<String, Object> da

Object optionalCustomCtorValue = data.get(CUSTOM_TARGET_CONSTRUCTOR_CLASS_KEY);
if (optionalCustomCtorValue != null) {
RuntimeReflectionSupport.increaseCount(false);
RuntimeReflectionSupport.increaseCount(true);
}
registerType(targetSerializationClass.get(), condition.get(), optionalCustomCtorValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,11 @@ public void registerWithTargetConstructorClass(ConfigurationCondition condition,
return;
}
}
Optional.ofNullable(addConstructorAccessor(cnd, serializationTargetClass, customTargetConstructorClass))
.map(ReflectionUtil::lookupConstructor)
.ifPresent(methods -> ImageSingletons.lookup(RuntimeReflectionSupport.class).register(ConfigurationCondition.alwaysTrue(), false, methods));
for (Class<?> superclass = serializationTargetClass.getSuperclass(); superclass != null; superclass = superclass.getSuperclass()) {
Optional.ofNullable(addConstructorAccessor(cnd, serializationTargetClass, superclass))
.map(ReflectionUtil::lookupConstructor)
.ifPresent(methods -> ImageSingletons.lookup(RuntimeReflectionSupport.class).register(ConfigurationCondition.alwaysTrue(), false, methods));
}

Class<?> superclass = serializationTargetClass.getSuperclass();
if (superclass != null) {
Expand Down

0 comments on commit da249b0

Please sign in to comment.