Skip to content

Commit

Permalink
Merge branch '2.16'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 15, 2023
2 parents 55dd2b0 + cd40fa8 commit e4a91c5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
22 changes: 17 additions & 5 deletions android-record/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
Module that allows deserialization into records on Android,
where java records are supported through desugaring,
and Jackson's built-in support for records doesn't work,
since the desugared classes have a non-standard super class,
Module that allows (de)serialization of records using the canonical constructor and accessors on Android,
where java records are supported through desugaring, and Jackson's built-in support for records doesn't work,
since the desugared classes have a non-standard super class,
and record component-related reflection methods are missing.

See [Android Developers Blog article](https://android-developers.googleblog.com/2023/06/records-in-android-studio-flamingo.html)

Note: this module is a no-op when no Android-desugared records are being deserialized,
An attempt was made to make this module as consistent with Jackson's built-in support for records as possible,
but gaps exist when using some of Jackson's advanced mapping features.

Note: this module is a no-op when no Android-desugared records are being (de)serialized,
so it is safe to use in code shared between Android and non-Android platforms.

Note: the canonical record constructor is identified through matching of parameter names and types with fields.
Therefore, this module doesn't allow a deserialized desugared record to have a custom constructor
with the same set of parameter names and types as the canonical one.
For the same reason, this module requires that desugared canonical record constructor parameter names
be stored in class files. Apparently, with Android SDK 34 tooling, that is the case by default.
If that ever changes, it may require an explicit setting in build files.

Known limitation: this module replaces the default `ClassIntrospector`,
so it cannot be used together with any other module that does the same.

## Usage

Functionality can be used by registering the module and then just deserializing things
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,16 @@
* <p>
* See <a href="https://android-developers.googleblog.com/2023/06/records-in-android-studio-flamingo.html">
* Android Developers Blog article</a>
*
* <p>
* An attempt was made to make this module as consistent with Jackson's built-in support for records as possible,
* but gaps exist when using some of Jackson's advanced mapping features.
*
* <p>
* Note: this module is a no-op when no Android-desugared records are being (de)serialized,
* so it is safe to use in code shared between Android and non-Android platforms.
*
* <p>
* Note: the canonical record constructor is found through matching of parameter names and types with fields.
* Note: the canonical record constructor is identified through matching of parameter names and types with fields.
* Therefore, this module doesn't allow a deserialized desugared record to have a custom constructor
* with the same set of parameter names and types as the canonical one.
* For the same reason, this module requires that desugared canonical record constructor parameter names
* be stored in class files. Apparently, with Android SDK 34 tooling, that is the case by default.
* If that ever changes, it may require an explicit setting in build files.
*
* @author Eran Leshem
**/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ static final class MultipleConstructors extends RecordTag {
int i() {
return i;
}

List<String> l() {
return l;
}
}

static final class ConflictingConstructors extends RecordTag {
Expand Down

0 comments on commit e4a91c5

Please sign in to comment.