Skip to content

Commit a5b83bb

Browse files
committed
Update release notes wrt #3417
1 parent 2abd8b9 commit a5b83bb

File tree

7 files changed

+17
-6
lines changed

7 files changed

+17
-6
lines changed

release-notes/CREDITS-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ Thomas Mortagne (tmortagne@github)
406406
Jonas Konrad (yawkat@github)
407407
* Suggested #905: Add support for `@ConstructorProperties`
408408
(2.7.0)
409+
* Contributed #3417: Allow (de)serializing records using Bean(De)SerializerModifier
410+
even when reflection is unavailable
411+
(2.14.0)
409412
410413
Jirka Kremser (Jiri-Kremser@github)
411414
* Suggested #924: SequenceWriter.writeAll() could accept Iterable

release-notes/VERSION-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Project: jackson-databind
99
#3373: Change `TypeSerializerBase` to skip `generator.writeTypePrefix()`
1010
for `null` typeId
1111
#3405: Create DataTypeFeature abstraction (for JSTEP-7) with placeholder features
12+
#3417: Allow (de)serializing records using Bean(De)SerializerModifier even when
13+
reflection is unavailable
14+
(contributed by Jonas K)
1215
#3419: Improve performance of `UnresolvedForwardReference` for forward reference
1316
resolution
1417
(contributed by Gary M)

src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,7 @@ protected Object deserializeFromObjectUsingNonDefault(JsonParser p,
14121412
return ctxt.handleMissingInstantiator(raw, null, p,
14131413
"non-static inner classes like this can only by instantiated using default, no-argument constructor");
14141414
}
1415+
// 01-May-2022, tatu: [databind#3417] special handling for (Graal) native images
14151416
if (NativeImageUtil.needsReflectionConfiguration(raw)) {
14161417
return ctxt.handleMissingInstantiator(raw, null, p,
14171418
"cannot deserialize from Object value (no delegate- or property-based Creator): this appears to be a native image, in which case you may need to configure reflection for the class that is to be deserialized");

src/main/java/com/fasterxml/jackson/databind/introspect/DefaultAccessorNamingStrategy.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ public RecordNaming(MapperConfig<?> config, AnnotatedClass forClass) {
530530
// we also allow getter discovery? For now let's do so
531531
"get", "is", null);
532532
String[] recordFieldNames = JDK14Util.getRecordFieldNames(forClass.getRawType());
533+
// 01-May-2022, tatu: Due to [databind#3417] may return null when no info available
533534
_fieldNames = recordFieldNames == null ?
534535
Collections.emptySet() :
535536
new HashSet<>(Arrays.asList(recordFieldNames));

src/main/java/com/fasterxml/jackson/databind/ser/BeanSerializerFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,9 @@ protected JsonSerializer<Object> constructBeanOrAddOnSerializer(SerializerProvid
477477
}
478478
if (ser == null) { // Means that no properties were found
479479
// 21-Aug-2020, tatu: Empty Records should be fine tho
480-
// 18-Mar-2022, yawkat: Record will also appear empty when missing reflection info.
481-
// needsReflectionConfiguration will check that a constructor is present, else we fall back to the empty
482-
// bean error msg
480+
// 18-Mar-2022, yawkat: [databind#3417] Record will also appear empty when missing
481+
// reflection info. needsReflectionConfiguration will check that a constructor is present,
482+
// else we fall back to the empty bean error msg
483483
if (type.isRecordType() && !NativeImageUtil.needsReflectionConfiguration(type.getRawClass())) {
484484
return builder.createDummy();
485485
}

src/main/java/com/fasterxml/jackson/databind/util/NativeImageUtil.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import java.lang.reflect.InvocationTargetException;
44

55
/**
6-
* Utilities for graal native image support.
6+
* Utilities for graal native image support; mostly to improve error message handling
7+
* in case of missing information for native image.
8+
*
9+
* @since 2.14
710
*/
811
public class NativeImageUtil {
912
private static final boolean RUNNING_IN_SVM;
@@ -20,7 +23,7 @@ private NativeImageUtil() {
2023
* the static initializer may run early during build time
2124
*/
2225
private static boolean isRunningInNativeImage() {
23-
return RUNNING_IN_SVM && System.getProperty("org.graalvm.nativeimage.imagecode").equals("runtime");
26+
return RUNNING_IN_SVM && "runtime".equals(System.getProperty("org.graalvm.nativeimage.imagecode"));
2427
}
2528

2629
/**

src/test/java/com/fasterxml/jackson/databind/ser/GenericTypeSerializationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ public static <T extends Indexed<K>, K> IndexedList<T, K> fromJson(Iterable<? ex
446446
/**********************************************************
447447
*/
448448

449-
final ObjectMapper MAPPER = new ObjectMapper();
449+
private final ObjectMapper MAPPER = newJsonMapper();
450450

451451
@SuppressWarnings("unchecked")
452452
public void testIssue468a() throws Exception

0 commit comments

Comments
 (0)