├── .circleci
└── config.yml
├── .gitattributes
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.yaml
│ ├── feature_request.yaml
│ └── question.yaml
├── dependabot.yml
├── pull_request_template.md
└── workflows
│ ├── dep_build_v2.yml
│ ├── dep_build_v3.yml
│ └── main.yml
├── .gitignore
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── .travis.yml
├── LICENSE
├── README.md
├── SECURITY.md
├── docs
├── javadoc
│ ├── 2.10
│ │ ├── allclasses-frame.html
│ │ ├── allclasses-noframe.html
│ │ ├── com
│ │ │ └── fasterxml
│ │ │ │ └── jackson
│ │ │ │ └── module
│ │ │ │ └── kotlin
│ │ │ │ ├── PackageVersion.html
│ │ │ │ ├── class-use
│ │ │ │ └── PackageVersion.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ ├── constant-values.html
│ │ ├── deprecated-list.html
│ │ ├── help-doc.html
│ │ ├── index-all.html
│ │ ├── index.html
│ │ ├── overview-tree.html
│ │ ├── package-list
│ │ ├── script.js
│ │ └── stylesheet.css
│ ├── 2.11
│ │ ├── allclasses-frame.html
│ │ ├── allclasses-noframe.html
│ │ ├── com
│ │ │ └── fasterxml
│ │ │ │ └── jackson
│ │ │ │ └── module
│ │ │ │ └── kotlin
│ │ │ │ ├── PackageVersion.html
│ │ │ │ ├── class-use
│ │ │ │ └── PackageVersion.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ ├── constant-values.html
│ │ ├── deprecated-list.html
│ │ ├── help-doc.html
│ │ ├── index-all.html
│ │ ├── index.html
│ │ ├── overview-tree.html
│ │ ├── package-list
│ │ ├── script.js
│ │ └── stylesheet.css
│ ├── 2.12
│ │ ├── allclasses-frame.html
│ │ ├── allclasses-noframe.html
│ │ ├── com
│ │ │ └── fasterxml
│ │ │ │ └── jackson
│ │ │ │ └── module
│ │ │ │ └── kotlin
│ │ │ │ ├── PackageVersion.html
│ │ │ │ ├── class-use
│ │ │ │ └── PackageVersion.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ ├── constant-values.html
│ │ ├── deprecated-list.html
│ │ ├── help-doc.html
│ │ ├── index-all.html
│ │ ├── index.html
│ │ ├── overview-tree.html
│ │ ├── package-list
│ │ ├── script.js
│ │ └── stylesheet.css
│ ├── 2.13
│ │ ├── allclasses-frame.html
│ │ ├── allclasses-noframe.html
│ │ ├── com
│ │ │ └── fasterxml
│ │ │ │ └── jackson
│ │ │ │ └── module
│ │ │ │ └── kotlin
│ │ │ │ ├── PackageVersion.html
│ │ │ │ ├── class-use
│ │ │ │ └── PackageVersion.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ ├── constant-values.html
│ │ ├── deprecated-list.html
│ │ ├── help-doc.html
│ │ ├── index-all.html
│ │ ├── index.html
│ │ ├── overview-tree.html
│ │ ├── package-list
│ │ ├── script.js
│ │ └── stylesheet.css
│ ├── 2.14
│ │ ├── allclasses-frame.html
│ │ ├── allclasses-noframe.html
│ │ ├── com
│ │ │ └── fasterxml
│ │ │ │ └── jackson
│ │ │ │ └── module
│ │ │ │ └── kotlin
│ │ │ │ ├── PackageVersion.html
│ │ │ │ ├── class-use
│ │ │ │ └── PackageVersion.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ ├── constant-values.html
│ │ ├── deprecated-list.html
│ │ ├── help-doc.html
│ │ ├── index-all.html
│ │ ├── index.html
│ │ ├── overview-tree.html
│ │ ├── package-list
│ │ ├── script.js
│ │ └── stylesheet.css
│ ├── 2.6
│ │ ├── allclasses-frame.html
│ │ ├── allclasses-noframe.html
│ │ ├── com
│ │ │ └── fasterxml
│ │ │ │ └── jackson
│ │ │ │ └── module
│ │ │ │ └── kotlin
│ │ │ │ ├── PackageVersion.html
│ │ │ │ ├── class-use
│ │ │ │ └── PackageVersion.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ ├── constant-values.html
│ │ ├── deprecated-list.html
│ │ ├── help-doc.html
│ │ ├── index-all.html
│ │ ├── index.html
│ │ ├── overview-tree.html
│ │ ├── package-list
│ │ ├── resources
│ │ │ ├── background.gif
│ │ │ ├── tab.gif
│ │ │ ├── titlebar.gif
│ │ │ └── titlebar_end.gif
│ │ └── stylesheet.css
│ ├── 2.8
│ │ ├── allclasses-frame.html
│ │ ├── allclasses-noframe.html
│ │ ├── com
│ │ │ └── fasterxml
│ │ │ │ └── jackson
│ │ │ │ └── module
│ │ │ │ └── kotlin
│ │ │ │ ├── PackageVersion.html
│ │ │ │ ├── class-use
│ │ │ │ └── PackageVersion.html
│ │ │ │ ├── package-frame.html
│ │ │ │ ├── package-summary.html
│ │ │ │ ├── package-tree.html
│ │ │ │ └── package-use.html
│ │ ├── constant-values.html
│ │ ├── deprecated-list.html
│ │ ├── help-doc.html
│ │ ├── index-all.html
│ │ ├── index.html
│ │ ├── overview-tree.html
│ │ ├── package-list
│ │ ├── resources
│ │ │ ├── background.gif
│ │ │ ├── tab.gif
│ │ │ ├── titlebar.gif
│ │ │ └── titlebar_end.gif
│ │ └── stylesheet.css
│ └── 2.9
│ │ ├── allclasses-frame.html
│ │ ├── allclasses-noframe.html
│ │ ├── com
│ │ └── fasterxml
│ │ │ └── jackson
│ │ │ └── module
│ │ │ └── kotlin
│ │ │ ├── PackageVersion.html
│ │ │ ├── class-use
│ │ │ └── PackageVersion.html
│ │ │ ├── package-frame.html
│ │ │ ├── package-summary.html
│ │ │ ├── package-tree.html
│ │ │ └── package-use.html
│ │ ├── constant-values.html
│ │ ├── deprecated-list.html
│ │ ├── help-doc.html
│ │ ├── index-all.html
│ │ ├── index.html
│ │ ├── overview-tree.html
│ │ ├── package-list
│ │ ├── script.js
│ │ └── stylesheet.css
├── value-class-handling.md
└── value-class-support.md
├── mvnw
├── mvnw.cmd
├── pom.xml
├── release-notes
├── CREDITS-2.x
└── VERSION-2.x
└── src
├── main
├── java
│ └── com
│ │ └── fasterxml
│ │ └── jackson
│ │ └── module
│ │ └── kotlin
│ │ ├── PackageVersion.java.in
│ │ └── WrapsNullableValueClassDeserializer.java
├── kotlin
│ └── com
│ │ └── fasterxml
│ │ └── jackson
│ │ └── module
│ │ └── kotlin
│ │ ├── ArgumentBucket.kt
│ │ ├── ConstructorValueCreator.kt
│ │ ├── Converters.kt
│ │ ├── Exceptions.kt
│ │ ├── Extensions.kt
│ │ ├── InternalCommons.kt
│ │ ├── KotlinAnnotationIntrospector.kt
│ │ ├── KotlinBeanDeserializerModifier.kt
│ │ ├── KotlinDeserializers.kt
│ │ ├── KotlinFeature.kt
│ │ ├── KotlinKeyDeserializers.kt
│ │ ├── KotlinKeySerializers.kt
│ │ ├── KotlinMixins.kt
│ │ ├── KotlinModule.kt
│ │ ├── KotlinNamesAnnotationIntrospector.kt
│ │ ├── KotlinObjectSingletonDeserializer.kt
│ │ ├── KotlinSerializers.kt
│ │ ├── KotlinValueInstantiator.kt
│ │ ├── MethodValueCreator.kt
│ │ ├── ReflectionCache.kt
│ │ ├── UnsignedNumbers.kt
│ │ └── ValueCreator.kt
└── resources
│ └── META-INF
│ ├── LICENSE
│ ├── NOTICE
│ └── services
│ └── com.fasterxml.jackson.databind.Module
├── moditect
└── module-info.java
└── test
└── kotlin
└── com
└── fasterxml
└── jackson
└── module
└── kotlin
├── ArgumentBucketTest.kt
├── DslTest.kt
├── JDKSerializabilityTestHelper.kt
├── KotlinInstantiatorsTest.kt
├── KotlinModuleTest.kt
├── MissingKotlinParameterExceptionTest.kt
├── README.md
├── ReadValueTest.kt
├── ReadValuesTest.kt
├── ReflectionCacheTest.kt
├── TestCommons.kt
├── kogeraIntegration
├── README.md
├── deser
│ ├── StrictNullChecksTest.kt
│ └── valueClass
│ │ ├── JacksonInjectTest.kt
│ │ ├── NullableObjectEdgeCases.kt
│ │ ├── ValueClasses.kt
│ │ ├── WithoutCustomDeserializeMethodTest.kt
│ │ ├── defaultArgument
│ │ ├── NonNullObjectTest.kt
│ │ ├── NullableObjectTest.kt
│ │ ├── NullablePrimitiveTest.kt
│ │ ├── PrimitiveTest.kt
│ │ └── TwoUnitPrimitiveTest.kt
│ │ ├── deserializer
│ │ ├── SpecifiedForObjectMapperTest.kt
│ │ └── byAnnotation
│ │ │ ├── SpecifiedForClassTest.kt
│ │ │ └── specifiedForProperty
│ │ │ ├── NonNullObjectTest.kt
│ │ │ ├── NullableObjectTest.kt
│ │ │ ├── NullablePrimitiveTest.kt
│ │ │ ├── PrimitiveTest.kt
│ │ │ └── TwoUnitPrimitiveTest.kt
│ │ ├── jsonCreator
│ │ ├── HandledByJacksonTest.kt
│ │ ├── HandledByKogeraTest.kt
│ │ └── InCreatorArgumentTest.kt
│ │ ├── mapKey
│ │ ├── WithoutCustomDeserializeMethodTest.kt
│ │ └── keyDeserializer
│ │ │ ├── SpecifiedForObjectMapperTest.kt
│ │ │ └── byAnnotation
│ │ │ ├── SpecifiedForClassTest.kt
│ │ │ └── SpecifiedForPropertyTest.kt
│ │ └── parameterSize
│ │ ├── nonNullObject
│ │ ├── DeserializeByConstructorWithDefaultArgumentsTest.kt
│ │ ├── DeserializeByConstructorWithoutDefaultArgumentsTest.kt
│ │ ├── DeserializeByFactoryWithDefaultArgumentsTest.kt
│ │ └── DeserializeByFactoryWithoutDefaultArgumentsTest.kt
│ │ ├── nullableObject
│ │ ├── DeserializeByConstructorWithDefaultArgumentsTest.kt
│ │ ├── DeserializeByConstructorWithoutDefaultArgumentsTest.kt
│ │ ├── DeserializeByFactoryWithDefaultArgumentsTest.kt
│ │ └── DeserializeByFactoryWithoutDefaultArgumentsTest.kt
│ │ ├── nullablePrimitive
│ │ ├── DeserializeByConstructorWithDefaultArgumentsTest.kt
│ │ ├── DeserializeByConstructorWithoutDefaultArgumentsTest.kt
│ │ ├── DeserializeByFactoryWithDefaultArgumentsTest.kt
│ │ └── DeserializeByFactoryWithoutDefaultArgumentsTest.kt
│ │ ├── primitive
│ │ ├── DeserializeByConstructorWithDefaultArgumentsTest.kt
│ │ ├── DeserializeByConstructorWithoutDefaultArgumentsTest.kt
│ │ ├── DeserializeByFactoryWithDefaultArgumentsTest.kt
│ │ └── DeserializeByFactoryWithoutDefaultArgumentsTest.kt
│ │ └── twoUnitPrimitive
│ │ ├── DeserializeByConstructorWithDefaultArgumentsTest.kt
│ │ ├── DeserializeByConstructorWithoutDefaultArgumentsTest.kt
│ │ ├── DeserializeByFactoryWithDefaultArgumentsTest.kt
│ │ └── DeserializeByFactoryWithoutDefaultArgumentsTest.kt
└── ser
│ └── valueClass
│ ├── JsonKeyTest.kt
│ ├── WithoutCustomSerializeMethodTest.kt
│ ├── jsonInclude
│ ├── JsonIncludeCustomTest.kt
│ ├── JsonIncludeNonNullTest.kt
│ └── ValueClasses.kt
│ └── serializer
│ ├── SpecifiedForObjectMapperTest.kt
│ ├── ValueClasses.kt
│ └── byAnnotation
│ ├── nonNullObject
│ └── ByAnnotationTest.kt
│ ├── nullableObject
│ ├── NonNullValueTest.kt
│ └── NullValueTest.kt
│ ├── nullablePrimitive
│ ├── NonNullValueTest.kt
│ └── NullValueTest.kt
│ ├── primitive
│ └── ByAnnotationTest.kt
│ └── twoUnitPrimitive
│ └── ByAnnotationTest.kt
└── test
├── DurationTests.kt
├── ExtensionMethodsTests.kt
├── FailNullForPrimitiveTest.kt
├── IteratorTests.kt
├── KClassSerializerDeserializerTest.kt
├── KotlinBuiltinsTest.kt
├── KotlinFeatures.kt
├── NullToDefaultTests.kt
├── NullToEmptyCollectionTest.kt
├── NullToEmptyMapTest.kt
├── ObjectSingletonTest.kt
├── ParameterNameTests.kt
├── PropertyRequirednessTests.kt
├── SealedClassTest.kt
├── SequenceSerdesTests.kt
├── StrictNullChecksTest.kt
├── StrictNullChecksTestOld.kt
├── TestHelpers.kt
├── TestHelpersTest.kt
├── UnsignedNumbersOnKeyTest.kt
├── UnsignedNumbersTests.kt
├── VarargDeserTest.kt
├── github
├── CloneableJavaObj.java
├── GitHub281.kt
├── GitHub314.kt
├── GitHub338.kt
├── GitHub524.kt
├── GitHub530.kt
├── GitHub618.kt
├── GitHub625.kt
├── GitHub757.kt
├── GitHub800.kt
├── GitHub832.kt
├── GitHub841.kt
├── GitHub844.kt
├── GitHub873.kt
├── GitHub876.kt
├── GitHub917.kt
├── GitHub922.kt
├── GitHub922RequiredCollectionsDtoJava.java
├── GitHub976.kt
├── Github101.kt
├── Github104.kt
├── Github114.kt
├── Github120.kt
├── Github124.kt
├── Github131.kt
├── Github145.kt
├── Github148.kt
├── Github149.kt
├── Github15.kt
├── Github153.kt
├── Github155.kt
├── Github158.kt
├── Github161.kt
├── Github165.kt
├── Github165JavaTest.java
├── Github167.kt
├── Github168.kt
├── Github179.kt
├── Github180.kt
├── Github181.kt
├── Github194.kt
├── Github196.kt
├── Github207.kt
├── Github210.kt
├── Github22.kt
├── Github239.kt
├── Github25.kt
├── Github26.kt
├── Github269.kt
├── Github27.kt
├── Github270.kt
├── Github29.kt
├── Github308.kt
├── Github32.kt
├── Github335.kt
├── Github340.kt
├── Github356.kt
├── Github396.kt
├── Github42.kt
├── Github46.kt
├── Github464.kt
├── Github47.kt
├── Github490.kt
├── Github50.kt
├── Github52.kt
├── Github526.kt
├── Github536.kt
├── Github56.kt
├── Github57.kt
├── Github62.kt
├── Github630.kt
├── Github710.kt
├── Github722.kt
├── Github738.kt
├── Github80.kt
├── Github88.kt
├── Github91.kt
├── GithubDatabind1005Test.kt
├── GithubDatabind1328.kt
├── TestCasesFromSlack.kt
└── failing
│ ├── GitHub337.kt
│ ├── GitHub451.kt
│ ├── GitHub478.kt
│ ├── Github138.kt
│ ├── Github160DisableAnnotations.kt
│ ├── Github242.kt
│ ├── Github271AlphaSortProperties.kt
│ ├── Github474.kt
│ ├── Github518.kt
│ ├── Github54.kt
│ ├── Github611.kt
│ ├── Github71.kt
│ └── GithubDatabind1329.kt
└── parameterSize
├── DeserializeByConstructorWithDefaultArgumentsTest.kt
├── DeserializeByConstructorWithoutDefaultArgumentsTest.kt
├── DeserializeByFactoryWithDefaultArgumentsTest.kt
└── DeserializeByFactoryWithoutDefaultArgumentsTest.kt
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2.1
2 | orbs:
3 | maven: circleci/maven@1.0.2
4 | workflows:
5 | maven_test:
6 | when: false
7 | jobs:
8 | - maven/test
9 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Do not merge `pom.xml` from older version, as it will typically conflict
2 |
3 | pom.xml merge=ours
4 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [k163377, cowtowncoder]
4 | tidelift: maven/com.fasterxml.jackson.module:jackson-module-kotlin
5 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.yaml:
--------------------------------------------------------------------------------
1 | name: Feature request
2 | description: Suggest an idea for this project
3 | labels: [ "enhancement" ]
4 | assignees: [ ]
5 |
6 | body:
7 | - type: textarea
8 | id: use-case
9 | attributes:
10 | label: Use case
11 | description: "A clear and concise description of what the use-case is. This will better help us understand the context in which you're looking for a new feature."
12 | validations:
13 | required: true
14 | - type: textarea
15 | id: desired-solution
16 | attributes:
17 | label: Describe the solution you'd like
18 | description: "A clear and concise description of what you want to happen."
19 | validations:
20 | required: true
21 | - type: textarea
22 | id: alternatives
23 | attributes:
24 | label: Describe alternatives you've considered
25 | description: "A clear and concise description of any alternative solutions or features you've considered."
26 | validations:
27 | required: false
28 | - type: textarea
29 | id: additional-context
30 | attributes:
31 | label: Additional context
32 | description: "Add any other context or screenshots about the feature request here."
33 | - type: markdown
34 | attributes:
35 | value: "Thanks for suggesting a feature! We appreciate your feedback and will consider it for future enhancements."
36 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.yaml:
--------------------------------------------------------------------------------
1 | name: Question
2 | description: Anything you're not sure about? Just ask us
3 | labels: [ "question" ]
4 | assignees: [ ]
5 |
6 | body:
7 | - type: markdown
8 | attributes:
9 | value: "Before asking your question, please check out the docs."
10 | - type: textarea
11 | id: user-question
12 | attributes:
13 | label: Your question
14 | placeholder: "What would you like to know?"
15 | validations:
16 | required: true
17 | - type: markdown
18 | attributes:
19 | value: "Thanks for reaching out! We'll do our best to help."
20 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "github-actions"
4 | directory: "/"
5 | schedule:
6 | interval: "monthly"
7 | groups:
8 | github-actions:
9 | patterns:
10 | - "*"
11 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | Thanks for submitting a pull request! Please ensure that you have based your code on [the correct branch](https://github.com/FasterXML/jackson-module-kotlin/#branches):
2 |
3 | - The current stable release branch for bugfixes of limited scope
4 | - The upcoming [minor](https://semver.org) release branch for backwards compatible changes to existing functionality or addition of new functionality
5 | - `master` for significant changes to existing behavior
6 |
7 | If you're unsure which branch to use, open an [issue](https://github.com/FasterXML/jackson-module-kotlin/issues) and ask, we're happy to talk over proposed changes.
8 |
9 | Finally, to have your code merged you will have to fill out the [Contributor License Agreement](https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf) and email a scan/photo of the result to info at fasterxml dot com.
10 |
--------------------------------------------------------------------------------
/.github/workflows/dep_build_v2.yml:
--------------------------------------------------------------------------------
1 | name: Re-build on jackson-databind v2 push
2 | on:
3 | repository_dispatch:
4 | types: [jackson-databind-pushed]
5 | # just for testing
6 | workflow_dispatch:
7 |
8 | permissions:
9 | contents: read
10 |
11 | jobs:
12 | build:
13 | runs-on: ubuntu-latest
14 | strategy:
15 | fail-fast: false
16 | matrix:
17 | java_version: ['8', '17', '21', '24']
18 | # Versions need to align with ones in 'main.yml' workflow
19 | kotlin_version: ['2.0.21', '2.1.20', '2.2.0-RC']
20 | env:
21 | JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
22 | steps:
23 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24 | with:
25 | ref: 2.x
26 | - name: Set up JDK
27 | uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
28 | with:
29 | distribution: 'temurin'
30 | java-version: ${{ matrix.java_version }}
31 | cache: 'maven'
32 | - name: Build and test
33 | run: ./mvnw -B -ff -ntp -Dversion.kotlin=${{ matrix.kotlin_version }} clean verify
34 |
35 | # No recursive rebuild (yet?)
36 |
--------------------------------------------------------------------------------
/.github/workflows/dep_build_v3.yml:
--------------------------------------------------------------------------------
1 | name: Re-build on jackson-databind v3 push
2 | on:
3 | repository_dispatch:
4 | types: [jackson-databind-pushed-v3]
5 |
6 | permissions:
7 | contents: read
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 | strategy:
13 | fail-fast: false
14 | matrix:
15 | java_version: ['17', '21', '24']
16 | # Versions need to align with ones in 'main.yml' workflow
17 | kotlin_version: ['2.0.21', '2.1.20', '2.2.0-RC']
18 | env:
19 | JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
20 | steps:
21 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22 | with:
23 | ref: 3.x
24 | - name: Set up JDK
25 | uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
26 | with:
27 | distribution: 'temurin'
28 | java-version: ${{ matrix.java_version }}
29 | cache: 'maven'
30 | - name: Build and test
31 | run: ./mvnw -B -ff -ntp -Dversion.kotlin=${{ matrix.kotlin_version }} clean verify
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # use glob syntax.
2 | syntax: glob
3 | *.class
4 | *~
5 | *.bak
6 | *.off
7 | *.old
8 | .DS_Store
9 |
10 | # building
11 | target
12 |
13 | # Eclipse
14 | .classpath
15 | .project
16 | .settings
17 |
18 | # IDEA
19 | .idea
20 | *.iml
21 | *.ipr
22 | *.iws
23 | /target
24 | /.gradle/
25 | /gradle/
26 | /out/
27 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FasterXML/jackson-module-kotlin/a41d7479fbfae2f581bf83bef872e4cf7e54e365/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # https://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar
19 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 |
3 | jdk:
4 | - openjdk8
5 | - openjdk11
6 |
7 | # whitelist
8 | branches:
9 | only:
10 | - master
11 | - "2.13"
12 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | Last Updated: 2022-09-20
4 |
5 | ## Supported Versions
6 |
7 | Current status of open branches, with new releases, can be found from [Jackson Releases](https://github.com/FasterXML/jackson/wiki/Jackson-Releases)
8 | wiki page
9 |
10 | ## Reporting a Vulnerability
11 |
12 | The recommended mechanism for reporting possible security vulnerabilities follows
13 | so-called "Coordinated Disclosure Plan" (see [definition of DCP](https://vuls.cert.org/confluence/display/Wiki/Coordinated+Vulnerability+Disclosure+Guidance)
14 | for general idea). The first step is to file a [Tidelift security contact](https://tidelift.com/security):
15 | Tidelift will route all reports via their system to maintainers of relevant package(s), and start the
16 | process that will evaluate concern and issue possible fixes, send update notices and so on.
17 | Note that you do not need to be a Tidelift subscriber to file a security contact.
18 |
19 | Alternatively you may also report possible vulnerabilities to `info` at fasterxml dot com
20 | mailing address. Note that filing an issue to go with report is fine, but if you do that please
21 | DO NOT include details of security problem in the issue but only in email contact.
22 | This is important to give us time to provide a patch, if necessary, for the problem.
23 |
24 | ## Verifying Artifact signatures
25 |
26 | (for more in-depth explanation, see [Apache Release Signing](https://infra.apache.org/release-signing#keys-policy) document)
27 |
28 | To verify that any given Jackson artifact has been signed with a valid key, have a look at `KEYS` file of the main Jackson repo:
29 |
30 | https://github.com/FasterXML/jackson/blob/master/KEYS
31 |
32 | which lists all known valid keys in use.
33 |
--------------------------------------------------------------------------------
/docs/javadoc/2.10/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.10.0 API)
8 |
9 |
10 |
11 |
12 |
13 | All Classes
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.10/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.10.0 API)
8 |
9 |
10 |
11 |
12 |
13 | All Classes
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.10/com/fasterxml/jackson/module/kotlin/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | com.fasterxml.jackson.module.kotlin (jackson-module-kotlin 2.10.0 API)
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/javadoc/2.10/package-list:
--------------------------------------------------------------------------------
1 | com.fasterxml.jackson.module.kotlin
2 |
--------------------------------------------------------------------------------
/docs/javadoc/2.10/script.js:
--------------------------------------------------------------------------------
1 | function show(type)
2 | {
3 | count = 0;
4 | for (var key in methods) {
5 | var row = document.getElementById(key);
6 | if ((methods[key] & type) != 0) {
7 | row.style.display = '';
8 | row.className = (count++ % 2) ? rowColor : altColor;
9 | }
10 | else
11 | row.style.display = 'none';
12 | }
13 | updateTabs(type);
14 | }
15 |
16 | function updateTabs(type)
17 | {
18 | for (var value in tabs) {
19 | var sNode = document.getElementById(tabs[value][0]);
20 | var spanNode = sNode.firstChild;
21 | if (value == type) {
22 | sNode.className = activeTableTab;
23 | spanNode.innerHTML = tabs[value][1];
24 | }
25 | else {
26 | sNode.className = tableTab;
27 | spanNode.innerHTML = "" + tabs[value][1] + "";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/docs/javadoc/2.11/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.11.0 API)
8 |
9 |
10 |
11 |
12 |
13 | All Classes
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.11/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.11.0 API)
8 |
9 |
10 |
11 |
12 |
13 | All Classes
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.11/com/fasterxml/jackson/module/kotlin/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | com.fasterxml.jackson.module.kotlin (jackson-module-kotlin 2.11.0 API)
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/javadoc/2.11/package-list:
--------------------------------------------------------------------------------
1 | com.fasterxml.jackson.module.kotlin
2 |
--------------------------------------------------------------------------------
/docs/javadoc/2.11/script.js:
--------------------------------------------------------------------------------
1 | function show(type)
2 | {
3 | count = 0;
4 | for (var key in methods) {
5 | var row = document.getElementById(key);
6 | if ((methods[key] & type) != 0) {
7 | row.style.display = '';
8 | row.className = (count++ % 2) ? rowColor : altColor;
9 | }
10 | else
11 | row.style.display = 'none';
12 | }
13 | updateTabs(type);
14 | }
15 |
16 | function updateTabs(type)
17 | {
18 | for (var value in tabs) {
19 | var sNode = document.getElementById(tabs[value][0]);
20 | var spanNode = sNode.firstChild;
21 | if (value == type) {
22 | sNode.className = activeTableTab;
23 | spanNode.innerHTML = tabs[value][1];
24 | }
25 | else {
26 | sNode.className = tableTab;
27 | spanNode.innerHTML = "" + tabs[value][1] + "";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/docs/javadoc/2.12/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.12.0 API)
8 |
9 |
10 |
11 |
12 |
13 | All Classes
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.12/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.12.0 API)
8 |
9 |
10 |
11 |
12 |
13 | All Classes
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.12/com/fasterxml/jackson/module/kotlin/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | com.fasterxml.jackson.module.kotlin (jackson-module-kotlin 2.12.0 API)
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/javadoc/2.12/package-list:
--------------------------------------------------------------------------------
1 | com.fasterxml.jackson.module.kotlin
2 |
--------------------------------------------------------------------------------
/docs/javadoc/2.12/script.js:
--------------------------------------------------------------------------------
1 | function show(type)
2 | {
3 | count = 0;
4 | for (var key in methods) {
5 | var row = document.getElementById(key);
6 | if ((methods[key] & type) != 0) {
7 | row.style.display = '';
8 | row.className = (count++ % 2) ? rowColor : altColor;
9 | }
10 | else
11 | row.style.display = 'none';
12 | }
13 | updateTabs(type);
14 | }
15 |
16 | function updateTabs(type)
17 | {
18 | for (var value in tabs) {
19 | var sNode = document.getElementById(tabs[value][0]);
20 | var spanNode = sNode.firstChild;
21 | if (value == type) {
22 | sNode.className = activeTableTab;
23 | spanNode.innerHTML = tabs[value][1];
24 | }
25 | else {
26 | sNode.className = tableTab;
27 | spanNode.innerHTML = "" + tabs[value][1] + "";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/docs/javadoc/2.13/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.13.0 API)
8 |
9 |
10 |
11 |
12 |
13 | All Classes
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.13/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.13.0 API)
8 |
9 |
10 |
11 |
12 |
13 | All Classes
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.13/com/fasterxml/jackson/module/kotlin/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | com.fasterxml.jackson.module.kotlin (jackson-module-kotlin 2.13.0 API)
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/javadoc/2.13/package-list:
--------------------------------------------------------------------------------
1 | com.fasterxml.jackson.module.kotlin
2 |
--------------------------------------------------------------------------------
/docs/javadoc/2.13/script.js:
--------------------------------------------------------------------------------
1 | function show(type)
2 | {
3 | count = 0;
4 | for (var key in methods) {
5 | var row = document.getElementById(key);
6 | if ((methods[key] & type) != 0) {
7 | row.style.display = '';
8 | row.className = (count++ % 2) ? rowColor : altColor;
9 | }
10 | else
11 | row.style.display = 'none';
12 | }
13 | updateTabs(type);
14 | }
15 |
16 | function updateTabs(type)
17 | {
18 | for (var value in tabs) {
19 | var sNode = document.getElementById(tabs[value][0]);
20 | var spanNode = sNode.firstChild;
21 | if (value == type) {
22 | sNode.className = activeTableTab;
23 | spanNode.innerHTML = tabs[value][1];
24 | }
25 | else {
26 | sNode.className = tableTab;
27 | spanNode.innerHTML = "" + tabs[value][1] + "";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/docs/javadoc/2.14/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.14.0 API)
8 |
9 |
10 |
11 |
12 | All Classes
13 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/javadoc/2.14/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.14.0 API)
8 |
9 |
10 |
11 |
12 | All Classes
13 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/javadoc/2.14/com/fasterxml/jackson/module/kotlin/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | com.fasterxml.jackson.module.kotlin (jackson-module-kotlin 2.14.0 API)
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.14/package-list:
--------------------------------------------------------------------------------
1 | com.fasterxml.jackson.module.kotlin
2 |
--------------------------------------------------------------------------------
/docs/javadoc/2.14/script.js:
--------------------------------------------------------------------------------
1 | function show(type)
2 | {
3 | count = 0;
4 | for (var key in methods) {
5 | var row = document.getElementById(key);
6 | if ((methods[key] & type) != 0) {
7 | row.style.display = '';
8 | row.className = (count++ % 2) ? rowColor : altColor;
9 | }
10 | else
11 | row.style.display = 'none';
12 | }
13 | updateTabs(type);
14 | }
15 |
16 | function updateTabs(type)
17 | {
18 | for (var value in tabs) {
19 | var sNode = document.getElementById(tabs[value][0]);
20 | var spanNode = sNode.firstChild;
21 | if (value == type) {
22 | sNode.className = activeTableTab;
23 | spanNode.innerHTML = tabs[value][1];
24 | }
25 | else {
26 | sNode.className = tableTab;
27 | spanNode.innerHTML = "" + tabs[value][1] + "";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/docs/javadoc/2.6/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.6.0 API)
8 |
9 |
10 |
11 |
12 | All Classes
13 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/javadoc/2.6/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.6.0 API)
8 |
9 |
10 |
11 |
12 | All Classes
13 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/javadoc/2.6/com/fasterxml/jackson/module/kotlin/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | com.fasterxml.jackson.module.kotlin (jackson-module-kotlin 2.6.0 API)
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.6/package-list:
--------------------------------------------------------------------------------
1 | com.fasterxml.jackson.module.kotlin
2 |
--------------------------------------------------------------------------------
/docs/javadoc/2.6/resources/background.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FasterXML/jackson-module-kotlin/a41d7479fbfae2f581bf83bef872e4cf7e54e365/docs/javadoc/2.6/resources/background.gif
--------------------------------------------------------------------------------
/docs/javadoc/2.6/resources/tab.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FasterXML/jackson-module-kotlin/a41d7479fbfae2f581bf83bef872e4cf7e54e365/docs/javadoc/2.6/resources/tab.gif
--------------------------------------------------------------------------------
/docs/javadoc/2.6/resources/titlebar.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FasterXML/jackson-module-kotlin/a41d7479fbfae2f581bf83bef872e4cf7e54e365/docs/javadoc/2.6/resources/titlebar.gif
--------------------------------------------------------------------------------
/docs/javadoc/2.6/resources/titlebar_end.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FasterXML/jackson-module-kotlin/a41d7479fbfae2f581bf83bef872e4cf7e54e365/docs/javadoc/2.6/resources/titlebar_end.gif
--------------------------------------------------------------------------------
/docs/javadoc/2.8/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.8.0 API)
8 |
9 |
10 |
11 |
12 | All Classes
13 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/javadoc/2.8/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.8.0 API)
8 |
9 |
10 |
11 |
12 | All Classes
13 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/docs/javadoc/2.8/com/fasterxml/jackson/module/kotlin/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | com.fasterxml.jackson.module.kotlin (jackson-module-kotlin 2.8.0 API)
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.8/package-list:
--------------------------------------------------------------------------------
1 | com.fasterxml.jackson.module.kotlin
2 |
--------------------------------------------------------------------------------
/docs/javadoc/2.8/resources/background.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FasterXML/jackson-module-kotlin/a41d7479fbfae2f581bf83bef872e4cf7e54e365/docs/javadoc/2.8/resources/background.gif
--------------------------------------------------------------------------------
/docs/javadoc/2.8/resources/tab.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FasterXML/jackson-module-kotlin/a41d7479fbfae2f581bf83bef872e4cf7e54e365/docs/javadoc/2.8/resources/tab.gif
--------------------------------------------------------------------------------
/docs/javadoc/2.8/resources/titlebar.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FasterXML/jackson-module-kotlin/a41d7479fbfae2f581bf83bef872e4cf7e54e365/docs/javadoc/2.8/resources/titlebar.gif
--------------------------------------------------------------------------------
/docs/javadoc/2.8/resources/titlebar_end.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FasterXML/jackson-module-kotlin/a41d7479fbfae2f581bf83bef872e4cf7e54e365/docs/javadoc/2.8/resources/titlebar_end.gif
--------------------------------------------------------------------------------
/docs/javadoc/2.9/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.9.0 API)
8 |
9 |
10 |
11 |
12 |
13 | All Classes
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.9/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (jackson-module-kotlin 2.9.0 API)
8 |
9 |
10 |
11 |
12 |
13 | All Classes
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/javadoc/2.9/com/fasterxml/jackson/module/kotlin/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | com.fasterxml.jackson.module.kotlin (jackson-module-kotlin 2.9.0 API)
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/javadoc/2.9/package-list:
--------------------------------------------------------------------------------
1 | com.fasterxml.jackson.module.kotlin
2 |
--------------------------------------------------------------------------------
/docs/javadoc/2.9/script.js:
--------------------------------------------------------------------------------
1 | function show(type)
2 | {
3 | count = 0;
4 | for (var key in methods) {
5 | var row = document.getElementById(key);
6 | if ((methods[key] & type) != 0) {
7 | row.style.display = '';
8 | row.className = (count++ % 2) ? rowColor : altColor;
9 | }
10 | else
11 | row.style.display = 'none';
12 | }
13 | updateTabs(type);
14 | }
15 |
16 | function updateTabs(type)
17 | {
18 | for (var value in tabs) {
19 | var sNode = document.getElementById(tabs[value][0]);
20 | var spanNode = sNode.firstChild;
21 | if (value == type) {
22 | sNode.className = activeTableTab;
23 | spanNode.innerHTML = tabs[value][1];
24 | }
25 | else {
26 | sNode.className = tableTab;
27 | spanNode.innerHTML = "" + tabs[value][1] + "";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/fasterxml/jackson/module/kotlin/PackageVersion.java.in:
--------------------------------------------------------------------------------
1 | package @package@;
2 |
3 | import com.fasterxml.jackson.core.Version;
4 | import com.fasterxml.jackson.core.Versioned;
5 | import com.fasterxml.jackson.core.util.VersionUtil;
6 |
7 | /**
8 | * Automatically generated from PackageVersion.java.in during
9 | * packageVersion-generate execution of maven-replacer-plugin in
10 | * pom.xml.
11 | */
12 | public final class PackageVersion implements Versioned {
13 | public final static Version VERSION = VersionUtil.parseVersion(
14 | "@projectversion@", "@projectgroupid@", "@projectartifactid@");
15 |
16 | @Override
17 | public Version version() {
18 | return VERSION;
19 | }
20 | }
--------------------------------------------------------------------------------
/src/main/java/com/fasterxml/jackson/module/kotlin/WrapsNullableValueClassDeserializer.java:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin;
2 |
3 | import com.fasterxml.jackson.core.JacksonException;
4 | import com.fasterxml.jackson.core.JsonParser;
5 | import com.fasterxml.jackson.databind.DeserializationContext;
6 | import com.fasterxml.jackson.databind.JavaType;
7 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
8 | import kotlin.jvm.JvmClassMappingKt;
9 | import kotlin.reflect.KClass;
10 | import org.jetbrains.annotations.NotNull;
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | import java.io.IOException;
14 |
15 | /**
16 | * An interface to be inherited by JsonDeserializer that handles value classes that may wrap nullable.
17 | */
18 | // To ensure maximum compatibility with StdDeserializer, this class is written in Java.
19 | public abstract class WrapsNullableValueClassDeserializer extends StdDeserializer {
20 | protected WrapsNullableValueClassDeserializer(@NotNull KClass> vc) {
21 | super(JvmClassMappingKt.getJavaClass(vc));
22 | }
23 |
24 | protected WrapsNullableValueClassDeserializer(@NotNull Class> vc) {
25 | super(vc);
26 | }
27 |
28 | protected WrapsNullableValueClassDeserializer(@NotNull JavaType valueType) {
29 | super(valueType);
30 | }
31 |
32 | protected WrapsNullableValueClassDeserializer(@NotNull StdDeserializer src) {
33 | super(src);
34 | }
35 |
36 | @Override
37 | @NotNull
38 | public final Class handledType() {
39 | //noinspection unchecked
40 | return (Class) super.handledType();
41 | }
42 |
43 | /**
44 | * If the parameter definition is a value class that wraps a nullable and is non-null,
45 | * and the input to JSON is explicitly null, this value is used.
46 | * Note that this will only be called from the KotlinValueInstantiator,
47 | * so it will not work for top-level deserialization of value classes.
48 | */
49 | // It is defined so that null can also be returned so that Nulls.SKIP can be applied.
50 | @Nullable
51 | public abstract D getBoxedNullValue();
52 |
53 | @Override
54 | public abstract D deserialize(@NotNull JsonParser p, @NotNull DeserializationContext ctxt)
55 | throws IOException, JacksonException;
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/fasterxml/jackson/module/kotlin/ConstructorValueCreator.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import kotlin.reflect.KFunction
4 | import kotlin.reflect.jvm.isAccessible
5 |
6 | internal class ConstructorValueCreator(override val callable: KFunction) : ValueCreator() {
7 | override val accessible: Boolean = callable.isAccessible
8 | override val bucketGenerator: BucketGenerator = BucketGenerator.forConstructor(callable.parameters.size)
9 |
10 | init {
11 | // To prevent the call from failing, save the initial value and then rewrite the flag.
12 | if (!accessible) callable.isAccessible = true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import com.fasterxml.jackson.core.JsonParser
4 | import com.fasterxml.jackson.databind.JsonMappingException
5 | import com.fasterxml.jackson.databind.exc.InvalidNullException
6 | import kotlin.reflect.KParameter
7 |
8 | /**
9 | * Specialized [JsonMappingException] sub-class used to indicate that a mandatory Kotlin constructor
10 | * parameter was missing or null.
11 | */
12 | @Deprecated(
13 | "It is recommended that MismatchedInputException be referenced when possible," +
14 | " as the change is discussed for 2.17 and later." +
15 | " See #617 for details.",
16 | ReplaceWith(
17 | "MismatchedInputException",
18 | "com.fasterxml.jackson.databind.exc.MismatchedInputException"
19 | ),
20 | DeprecationLevel.WARNING
21 | )
22 | // When deserialized by the JDK, the parameter property will be null, ignoring nullability.
23 | // This is a temporary workaround for #572 and we will eventually remove this class.
24 | class MissingKotlinParameterException(
25 | @property:Deprecated(
26 | "KParameter is not serializable and will be removed in 2.17 or later. See #572 for details.",
27 | level = DeprecationLevel.WARNING
28 | )
29 | @Transient
30 | val parameter: KParameter,
31 | processor: JsonParser? = null,
32 | msg: String
33 | ) : InvalidNullException(processor, msg, null)
34 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/fasterxml/jackson/module/kotlin/InternalCommons.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import com.fasterxml.jackson.annotation.JsonCreator
4 | import com.fasterxml.jackson.databind.JsonMappingException
5 | import java.lang.reflect.AnnotatedElement
6 | import java.util.*
7 | import kotlin.reflect.KClass
8 | import kotlin.reflect.KType
9 | import kotlin.reflect.full.memberProperties
10 | import kotlin.reflect.jvm.javaField
11 | import kotlin.reflect.jvm.jvmErasure
12 |
13 | internal val defaultConstructorMarker: Class<*> by lazy {
14 | Class.forName("kotlin.jvm.internal.DefaultConstructorMarker")
15 | }
16 |
17 | internal fun JsonMappingException.wrapWithPath(refFrom: Any?, refFieldName: String) = JsonMappingException.wrapWithPath(this, refFrom, refFieldName)
18 | internal fun JsonMappingException.wrapWithPath(refFrom: Any?, index: Int) = JsonMappingException.wrapWithPath(this, refFrom, index)
19 |
20 | internal fun Int.toBitSet(): BitSet {
21 | var i = this
22 | var index = 0
23 | val bits = BitSet(32)
24 | while (i != 0) {
25 | if (i % 2 != 0) {
26 | bits.set(index)
27 | }
28 | ++index
29 | i = i shr 1
30 | }
31 | return bits
32 | }
33 |
34 | // In the future, value classes without @JvmInline will be available, and unboxing may not be able to handle it.
35 | // https://github.com/FasterXML/jackson-module-kotlin/issues/464
36 | // The JvmInline annotation can be added to Java classes,
37 | // so the isKotlinClass decision is necessary (the order is preferable in terms of possible frequency).
38 | internal fun Class<*>.isUnboxableValueClass() = annotations.any { it is JvmInline } && this.isKotlinClass()
39 |
40 | internal fun KType.erasedType(): Class = this.jvmErasure.java
41 |
42 | internal fun AnnotatedElement.hasCreatorAnnotation(): Boolean = getAnnotation(JsonCreator::class.java)
43 | ?.let { it.mode != JsonCreator.Mode.DISABLED }
44 | ?: false
45 |
46 | // Determine if the unbox result of value class is nullable
47 | internal fun KClass<*>.wrapsNullable(): Boolean =
48 | this.memberProperties.first { it.javaField != null }.returnType.isMarkedNullable
49 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinBeanDeserializerModifier.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import com.fasterxml.jackson.databind.BeanDescription
4 | import com.fasterxml.jackson.databind.DeserializationConfig
5 | import com.fasterxml.jackson.databind.JsonDeserializer
6 | import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier
7 |
8 | // [module-kotlin#225]: keep Kotlin singletons as singletons
9 | object KotlinBeanDeserializerModifier : BeanDeserializerModifier() {
10 | private fun readResolve(): Any = KotlinBeanDeserializerModifier
11 |
12 | override fun modifyDeserializer(
13 | config: DeserializationConfig,
14 | beanDesc: BeanDescription,
15 | deserializer: JsonDeserializer<*>
16 | ): JsonDeserializer {
17 | val modifiedFromParent = super.modifyDeserializer(config, beanDesc, deserializer)
18 |
19 | val objectSingletonInstance = objectSingletonInstance(beanDesc.beanClass)
20 | return if (objectSingletonInstance != null) {
21 | KotlinObjectSingletonDeserializer(objectSingletonInstance, modifiedFromParent)
22 | } else {
23 | modifiedFromParent
24 | }
25 | }
26 | }
27 |
28 | private fun objectSingletonInstance(beanClass: Class<*>): Any? = if (!beanClass.isKotlinClass()) {
29 | null
30 | } else {
31 | beanClass.kotlin.objectInstance
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinMixins.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import com.fasterxml.jackson.annotation.JsonCreator
4 | import com.fasterxml.jackson.annotation.JsonIgnore
5 | import com.fasterxml.jackson.annotation.JsonProperty
6 |
7 | internal abstract class ClosedRangeMixin @JsonCreator constructor(public val start: T, @get:JsonProperty("end") public val endInclusive: T) {
8 | @JsonIgnore abstract public fun getEnd(): T
9 | @JsonIgnore abstract public fun getFirst(): T
10 | @JsonIgnore abstract public fun getLast(): T
11 | @JsonIgnore abstract public fun getIncrement(): T
12 | @JsonIgnore abstract public fun isEmpty(): Boolean
13 | @JsonIgnore abstract public fun getStep(): T
14 | @JsonIgnore abstract public fun getEndExclusive(): T
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinObjectSingletonDeserializer.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import com.fasterxml.jackson.core.JsonParser
4 | import com.fasterxml.jackson.databind.BeanProperty
5 | import com.fasterxml.jackson.databind.DeserializationContext
6 | import com.fasterxml.jackson.databind.JsonDeserializer
7 | import com.fasterxml.jackson.databind.deser.ContextualDeserializer
8 | import com.fasterxml.jackson.databind.deser.ResolvableDeserializer
9 |
10 | internal fun JsonDeserializer<*>.asSingletonDeserializer(singleton: Any) =
11 | KotlinObjectSingletonDeserializer(singleton, this)
12 |
13 | /** deserialize as normal, but return the canonical singleton instance. */
14 | internal class KotlinObjectSingletonDeserializer(
15 | private val singletonInstance: Any,
16 | private val defaultDeserializer: JsonDeserializer<*>
17 | ) : JsonDeserializer(),
18 | // Additional interfaces of a specific 'JsonDeserializer' must be supported
19 | // Kotlin objectInstances are currently handled by a BeanSerializer which
20 | // implements 'ContextualDeserializer' and 'ResolvableDeserializer'.
21 | ContextualDeserializer,
22 | ResolvableDeserializer {
23 |
24 | override fun resolve(ctxt: DeserializationContext?) {
25 | if (defaultDeserializer is ResolvableDeserializer) {
26 | defaultDeserializer.resolve(ctxt)
27 | }
28 | }
29 |
30 | override fun createContextual(ctxt: DeserializationContext?, property: BeanProperty?): JsonDeserializer<*> =
31 | if (defaultDeserializer is ContextualDeserializer) {
32 | defaultDeserializer.createContextual(ctxt, property)
33 | .asSingletonDeserializer(singletonInstance)
34 | } else {
35 | this
36 | }
37 |
38 | override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Any {
39 | defaultDeserializer.deserialize(p, ctxt)
40 | return singletonInstance
41 | }
42 | }
--------------------------------------------------------------------------------
/src/main/kotlin/com/fasterxml/jackson/module/kotlin/UnsignedNumbers.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import java.math.BigInteger
4 |
5 | fun Short.asUByte() = when {
6 | this >= 0 && this <= UByte.MAX_VALUE.toShort() -> this.toUByte()
7 | else -> null
8 | }
9 |
10 | fun Int.asUShort() = when {
11 | this >= 0 && this <= UShort.MAX_VALUE.toInt() -> this.toUShort()
12 | else -> null
13 | }
14 |
15 | fun Long.asUInt() = when {
16 | this >= 0 && this <= UInt.MAX_VALUE.toLong() -> this.toUInt()
17 | else -> null
18 | }
19 |
20 | private val uLongMaxValue = BigInteger(ULong.MAX_VALUE.toString())
21 | fun BigInteger.asULong() = when {
22 | this >= BigInteger.ZERO && this <= uLongMaxValue -> this.toLong().toULong()
23 | else -> null
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/kotlin/com/fasterxml/jackson/module/kotlin/ValueCreator.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import com.fasterxml.jackson.databind.DeserializationContext
4 | import com.fasterxml.jackson.databind.MapperFeature
5 | import kotlin.reflect.KFunction
6 | import kotlin.reflect.KParameter
7 | import kotlin.reflect.full.valueParameters
8 |
9 | /**
10 | * A class that abstracts the creation of instances by calling KFunction.
11 | * @see KotlinValueInstantiator
12 | */
13 | internal sealed class ValueCreator {
14 | /**
15 | * Function to be call.
16 | */
17 | protected abstract val callable: KFunction
18 |
19 | /**
20 | * Initial value for accessibility by reflection.
21 | */
22 | protected abstract val accessible: Boolean
23 |
24 | protected abstract val bucketGenerator: BucketGenerator
25 |
26 | fun generateBucket(): ArgumentBucket = bucketGenerator.generate()
27 |
28 | /**
29 | * ValueParameters of the KFunction to be called.
30 | */
31 | // If this result is cached, it will coexist with the SoftReference managed value in kotlin-reflect,
32 | // and there is a risk of doubling the memory consumption, so it should not be cached.
33 | // @see #584
34 | val valueParameters: List get() = callable.valueParameters
35 |
36 | /**
37 | * Checking process to see if access from context is possible.
38 | * @throws IllegalAccessException
39 | */
40 | fun checkAccessibility(ctxt: DeserializationContext) {
41 | if ((!accessible && ctxt.config.isEnabled(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS)) ||
42 | (accessible && ctxt.config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS))) {
43 | return
44 | }
45 |
46 | throw IllegalAccessException("Cannot access to function or companion object instance, target: $callable")
47 | }
48 |
49 | /**
50 | * Function call with default values enabled.
51 | */
52 | fun callBy(args: ArgumentBucket): T = if (args.isFullInitialized) {
53 | callable.call(*args.arguments)
54 | } else {
55 | callable.callBy(args)
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/LICENSE:
--------------------------------------------------------------------------------
1 | This copy of Jackson JSON processor databind module is licensed under the
2 | Apache (Software) License, version 2.0 ("the License").
3 | See the License for details about distribution rights, and the
4 | specific rights regarding derivative works.
5 |
6 | You may obtain a copy of the License at:
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/NOTICE:
--------------------------------------------------------------------------------
1 | # Jackson JSON processor
2 |
3 | Jackson is a high-performance, Free/Open Source JSON processing library.
4 | It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has
5 | been in development since 2007.
6 | It is currently developed by a community of developers, as well as supported
7 | commercially by FasterXML.com.
8 |
9 | ## Copyright
10 |
11 | Copyright 2007-, Tatu Saloranta (tatu.saloranta@iki.fi)
12 |
13 | ## Licensing
14 |
15 | Jackson core and extension components may be licensed under different licenses.
16 | To find the details that apply to this artifact see the accompanying LICENSE file.
17 | For more information, including possible other licensing options, contact
18 | FasterXML.com (http://fasterxml.com).
19 |
20 | ## Credits
21 |
22 | A list of contributors may be found from CREDITS file, which is included
23 | in some artifacts (usually source distributions); but is always available
24 | from the source code management (SCM) system project uses.
25 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/services/com.fasterxml.jackson.databind.Module:
--------------------------------------------------------------------------------
1 | com.fasterxml.jackson.module.kotlin.KotlinModule
2 |
--------------------------------------------------------------------------------
/src/moditect/module-info.java:
--------------------------------------------------------------------------------
1 | // Manually created 02-Nov-2020 for
2 | // https://github.com/FasterXML/jackson-module-kotlin/issues/385
3 | module com.fasterxml.jackson.kotlin {
4 | requires java.desktop;
5 |
6 | requires kotlin.reflect;
7 | requires kotlin.stdlib;
8 |
9 | requires com.fasterxml.jackson.annotation;
10 | requires com.fasterxml.jackson.databind;
11 |
12 | exports com.fasterxml.jackson.module.kotlin;
13 |
14 | provides com.fasterxml.jackson.databind.Module with
15 | com.fasterxml.jackson.module.kotlin.KotlinModule;
16 | }
17 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/JDKSerializabilityTestHelper.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import org.junit.jupiter.api.Assertions.fail
4 | import java.io.ByteArrayInputStream
5 | import java.io.ByteArrayOutputStream
6 | import java.io.ObjectInputStream
7 | import java.io.ObjectOutputStream
8 |
9 | fun jdkSerialize(o: Any): ByteArray {
10 | val bytes = ByteArrayOutputStream(1000)
11 | val obOut = ObjectOutputStream(bytes)
12 | obOut.writeObject(o)
13 | obOut.close()
14 | return bytes.toByteArray()
15 | }
16 |
17 | fun jdkDeserialize(raw: ByteArray): T {
18 | val objIn = ObjectInputStream(ByteArrayInputStream(raw))
19 | return try {
20 | @Suppress("UNCHECKED_CAST")
21 | objIn.readObject() as T
22 | } catch (e: ClassNotFoundException) {
23 | fail("Missing class: " + e.message)
24 | } finally {
25 | objIn.close()
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/KotlinInstantiatorsTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import com.fasterxml.jackson.databind.deser.std.StdValueInstantiator
4 | import org.junit.jupiter.api.Assertions.*
5 | import org.junit.jupiter.api.Test
6 |
7 | class KotlinInstantiatorsTest {
8 | private val deserConfig = defaultMapper.deserializationConfig
9 |
10 | private val kotlinInstantiators = KotlinInstantiators(
11 | ReflectionCache(10),
12 | nullToEmptyCollection = false,
13 | nullToEmptyMap = false,
14 | nullIsSameAsDefault = false,
15 | strictNullChecks = false
16 | )
17 |
18 | @Test
19 | fun `Provides default instantiator for Java class`() {
20 | val javaType = defaultMapper.constructType(String::class.java)
21 | val defaultInstantiator = StdValueInstantiator(deserConfig, javaType)
22 | val instantiator = kotlinInstantiators.findValueInstantiator(
23 | deserConfig,
24 | deserConfig.introspect(javaType),
25 | defaultInstantiator
26 | )
27 |
28 | assertEquals(defaultInstantiator, instantiator)
29 | }
30 |
31 | @Test
32 | fun `Provides KotlinValueInstantiator for Kotlin class`() {
33 | class TestClass
34 |
35 | val javaType = defaultMapper.constructType(TestClass::class.java)
36 | val instantiator = kotlinInstantiators.findValueInstantiator(
37 | deserConfig,
38 | deserConfig.introspect(javaType),
39 | StdValueInstantiator(deserConfig, javaType)
40 | )
41 |
42 | assertTrue(instantiator is StdValueInstantiator)
43 | assertTrue(instantiator::class == KotlinValueInstantiator::class)
44 | }
45 |
46 | @Test
47 | fun `Throws for Kotlin class when default instantiator isn't StdValueInstantiator`() {
48 | class TestClass
49 | class DefaultClass
50 |
51 | val subClassInstantiator = object : StdValueInstantiator(
52 | deserConfig,
53 | defaultMapper.constructType(DefaultClass::class.java)
54 | ) {}
55 |
56 | assertThrows(IllegalStateException::class.java) {
57 | kotlinInstantiators.findValueInstantiator(
58 | deserConfig,
59 | deserConfig.introspect(defaultMapper.constructType(TestClass::class.java)),
60 | subClassInstantiator
61 | )
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/MissingKotlinParameterExceptionTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import org.junit.jupiter.api.Test
4 | import kotlin.test.assertNotNull
5 | import kotlin.test.assertNull
6 |
7 | class MissingKotlinParameterExceptionTest {
8 | @Test
9 | fun jdkSerializabilityTest() {
10 | val param = ::MissingKotlinParameterException.parameters.first()
11 | val ex = MissingKotlinParameterException(param, null, "test")
12 |
13 | val serialized = jdkSerialize(ex)
14 | val deserialized = jdkDeserialize(serialized)
15 |
16 | assertNotNull(deserialized)
17 | // see comment at MissingKotlinParameterException
18 | assertNull(deserialized.parameter)
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/README.md:
--------------------------------------------------------------------------------
1 | # Failing tests
2 |
3 | These are tests for filed issues on GitHub that have not been fixed. Failing tests are good to
4 | have because they can both concisely document known issues with the library but also serve as
5 | notification for when that functionality has been fixed.
6 |
7 | The tests pass because either the failing assertions have their `AssertionError` or the Jackson call
8 | that throws has its exception caught.
9 |
10 | ## Writing a failing test
11 |
12 | Create a failing test by writing it as you would any other test, making any calls or assertions
13 | necessary to demonstrate the failing behavior. Then, surround the failing call with the
14 | `expectFailure()` function, passing the expected exception and a message that will be printed
15 | if the failure does _not_ occur, which implies that the functionality has been fixed.
16 |
17 | See the below examples:
18 |
19 | ```kotlin
20 | @Test
21 | fun failingTest() {
22 | expectFailure("The call that fails with MismatchedInputException has been fixed!") {
23 | mapper.callThatFailsWithMismatchedInputException()
24 | }
25 | }
26 | ```
27 |
28 | ```kotlin
29 | @Test
30 | fun serializeAndDeserializeTypeable() {
31 | val oldEntity = MyEntity(null, null)
32 | val json = mapper.writeValueAsString(oldEntity)
33 | val newEntity = mapper.readValue(json)
34 |
35 | expectFailure("GitHub #335 has been fixed!") {
36 | // newEntity.type is the string "null" instead of the null value
37 | assertNull(newEntity.type)
38 | }
39 | }
40 | ```
41 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/ReadValuesTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import com.fasterxml.jackson.core.JsonParser
4 | import com.fasterxml.jackson.databind.DeserializationContext
5 | import com.fasterxml.jackson.databind.RuntimeJsonMappingException
6 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer
7 | import com.fasterxml.jackson.databind.module.SimpleModule
8 | import org.junit.jupiter.api.Nested
9 | import org.junit.jupiter.api.Test
10 | import org.junit.jupiter.api.assertThrows
11 | import kotlin.test.assertEquals
12 |
13 | class ReadValuesTest {
14 | class MyStrDeser : StdDeserializer(String::class.java) {
15 | override fun deserialize(
16 | p: JsonParser,
17 | ctxt: DeserializationContext
18 | ): String? = p.valueAsString.takeIf { it != "bar" }
19 | }
20 |
21 | @Nested
22 | inner class CheckTypeMismatchTest {
23 | val mapper = jacksonObjectMapper().registerModule(
24 | object : SimpleModule() {
25 | init {
26 | addDeserializer(String::class.java, MyStrDeser())
27 | }
28 | }
29 | )!!
30 |
31 | @Test
32 | fun readValuesJsonParserNext() {
33 | val src = mapper.createParser(""""foo"${"\n"}"bar"""")
34 | val itr = mapper.readValues(src)
35 |
36 | assertEquals("foo", itr.next())
37 | assertThrows {
38 | itr.next()
39 | }
40 | }
41 |
42 | @Test
43 | fun readValuesJsonParserNextValue() {
44 | val src = mapper.createParser(""""foo"${"\n"}"bar"""")
45 | val itr = mapper.readValues(src)
46 |
47 | assertEquals("foo", itr.nextValue())
48 | assertThrows {
49 | itr.nextValue()
50 | }
51 | }
52 |
53 | @Test
54 | fun readValuesTypedJsonParser() {
55 | val reader = mapper.reader()
56 | val src = reader.createParser(""""foo"${"\n"}"bar"""")
57 | val itr = reader.readValuesTyped(src)
58 |
59 | assertEquals("foo", itr.next())
60 | assertThrows {
61 | itr.next()
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/ReflectionCacheTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import org.junit.jupiter.api.Test
4 | import kotlin.test.assertNotNull
5 |
6 | class ReflectionCacheTest {
7 | @Test
8 | fun serializeEmptyCache() {
9 | val cache = ReflectionCache(100)
10 | val serialized = jdkSerialize(cache)
11 | val deserialized = jdkDeserialize(serialized)
12 |
13 | assertNotNull(deserialized)
14 | // Deserialized instance also do not raise exceptions
15 | deserialized.kotlinFromJava(ReflectionCacheTest::class.java.getDeclaredMethod("serializeEmptyCache"))
16 | }
17 |
18 | @Test
19 | fun serializeNotEmptyCache() {
20 | val method = ReflectionCacheTest::class.java.getDeclaredMethod("serializeNotEmptyCache")
21 |
22 | val cache = ReflectionCache(100).apply { kotlinFromJava(method) }
23 | val serialized = jdkSerialize(cache)
24 | val deserialized = jdkDeserialize(serialized)
25 |
26 | assertNotNull(deserialized)
27 | // Deserialized instance also do not raise exceptions
28 | deserialized.kotlinFromJava(method)
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/TestCommons.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin
2 |
3 | import com.fasterxml.jackson.core.PrettyPrinter
4 | import com.fasterxml.jackson.core.util.DefaultIndenter
5 | import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
6 | import com.fasterxml.jackson.databind.ObjectMapper
7 | import com.fasterxml.jackson.databind.ObjectWriter
8 | import java.io.File
9 | import java.io.FileOutputStream
10 | import java.io.OutputStreamWriter
11 | import java.nio.charset.StandardCharsets
12 | import kotlin.reflect.KParameter
13 | import kotlin.reflect.full.memberProperties
14 | import kotlin.reflect.full.primaryConstructor
15 | import kotlin.test.assertEquals
16 |
17 | // This `printer` is used to match the output from Jackson to the newline char of the source code.
18 | // If this is removed, comparisons will fail in a Windows-like platform.
19 | val LF_PRINTER: PrettyPrinter =
20 | DefaultPrettyPrinter().withObjectIndenter(DefaultIndenter().withLinefeed("\n"))
21 |
22 | fun ObjectMapper.testPrettyWriter(): ObjectWriter = this.writer().with(LF_PRINTER)
23 | internal val defaultMapper = jacksonObjectMapper()
24 |
25 | internal inline fun callPrimaryConstructor(mapper: (KParameter) -> Any? = { it.name }): T =
26 | T::class.primaryConstructor!!.run {
27 | val args = parameters.associateWith { mapper(it) }
28 | callBy(args)
29 | }
30 |
31 | // Function for comparing non-data classes.
32 | internal inline fun assertReflectEquals(expected: T, actual: T) {
33 | T::class.memberProperties.forEach {
34 | assertEquals(it.get(expected), it.get(actual))
35 | }
36 | }
37 |
38 | internal fun createTempJson(json: String): File {
39 | val file = File.createTempFile("temp", ".json")
40 | file.deleteOnExit()
41 | OutputStreamWriter(
42 | FileOutputStream(file),
43 | StandardCharsets.UTF_8
44 | ).use { writer ->
45 | writer.write(json)
46 | writer.flush()
47 | }
48 | return file
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/kogeraIntegration/README.md:
--------------------------------------------------------------------------------
1 | This package contains some portions from `zIntegration` of the `jackson-module-kogera` project.
2 | https://github.com/ProjectMapK/jackson-module-kogera/tree/develop/src/test/kotlin/io/github/projectmapk/jackson/module/kogera/zIntegration
3 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/kogeraIntegration/deser/valueClass/defaultArgument/NonNullObjectTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.defaultArgument
2 |
3 | import com.fasterxml.jackson.annotation.JsonCreator
4 | import com.fasterxml.jackson.module.kotlin.defaultMapper
5 | import com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.NonNullObject
6 | import com.fasterxml.jackson.module.kotlin.readValue
7 | import org.junit.jupiter.api.Assertions.assertEquals
8 | import org.junit.jupiter.api.Test
9 |
10 | class NonNullObjectTest {
11 | data class ByConstructor(
12 | val nn: NonNullObject = NonNullObject("foo"),
13 | val nNn: NonNullObject? = NonNullObject("bar"),
14 | val nN: NonNullObject? = null
15 | )
16 |
17 | @Test
18 | fun byConstructorTest() {
19 | assertEquals(ByConstructor(), defaultMapper.readValue("{}"))
20 | }
21 |
22 | data class ByFactory(val nn: NonNullObject, val nNn: NonNullObject?, val nN: NonNullObject?) {
23 | companion object {
24 | @JvmStatic
25 | @JsonCreator
26 | fun creator(
27 | nn: NonNullObject = NonNullObject("foo"),
28 | nNn: NonNullObject? = NonNullObject("bar"),
29 | nN: NonNullObject? = null
30 | ) = ByFactory(nn, nNn, nN)
31 | }
32 | }
33 |
34 | @Test
35 | fun byFactoryTest() {
36 | assertEquals(ByFactory.creator(), defaultMapper.readValue("{}"))
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/kogeraIntegration/deser/valueClass/defaultArgument/NullableObjectTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.defaultArgument
2 |
3 | import com.fasterxml.jackson.annotation.JsonCreator
4 | import com.fasterxml.jackson.module.kotlin.defaultMapper
5 | import com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.NullableObject
6 | import com.fasterxml.jackson.module.kotlin.readValue
7 | import org.junit.jupiter.api.Assertions.assertEquals
8 | import org.junit.jupiter.api.Assertions.assertThrows
9 | import org.junit.jupiter.api.Test
10 |
11 | class NullableObjectTest {
12 | data class ByConstructor(
13 | val nnNn: NullableObject = NullableObject("foo"),
14 | val nnN: NullableObject = NullableObject(null),
15 | val nNn: NullableObject? = NullableObject("bar"),
16 | val nN: NullableObject? = null
17 | )
18 |
19 | @Test
20 | fun byConstructorTestFailing() {
21 | // #761(KT-57357) fixed
22 | assertThrows(Error::class.java) {
23 | assertEquals(ByConstructor(), defaultMapper.readValue("{}"))
24 | }
25 | }
26 |
27 | data class ByFactory(
28 | val nnNn: NullableObject = NullableObject("foo"),
29 | val nnN: NullableObject = NullableObject(null),
30 | val nNn: NullableObject? = NullableObject("bar"),
31 | val nN: NullableObject? = null
32 | ) {
33 | companion object {
34 | @JvmStatic
35 | @JsonCreator
36 | fun creator(
37 | nn: NullableObject = NullableObject("foo"),
38 | nnN: NullableObject = NullableObject(null),
39 | nNn: NullableObject? = NullableObject("bar"),
40 | nN: NullableObject? = null
41 | ) = ByFactory(nn, nnN, nNn, nN)
42 | }
43 | }
44 |
45 | @Test
46 | fun byFactoryTest() {
47 | // #761(KT-57357) fixed
48 | assertThrows(Error::class.java) {
49 | assertEquals(ByFactory.creator(), defaultMapper.readValue("{}"))
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/kogeraIntegration/deser/valueClass/defaultArgument/NullablePrimitiveTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.defaultArgument
2 |
3 | import com.fasterxml.jackson.annotation.JsonCreator
4 | import com.fasterxml.jackson.module.kotlin.defaultMapper
5 | import com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.NullablePrimitive
6 | import com.fasterxml.jackson.module.kotlin.readValue
7 | import org.junit.jupiter.api.Assertions
8 | import org.junit.jupiter.api.Assertions.assertEquals
9 | import org.junit.jupiter.api.Test
10 |
11 | class NullablePrimitiveTest {
12 | data class ByConstructor(
13 | val nnNn: NullablePrimitive = NullablePrimitive(1),
14 | val nnN: NullablePrimitive = NullablePrimitive(null),
15 | val nNn: NullablePrimitive? = NullablePrimitive(2),
16 | val nN: NullablePrimitive? = null
17 | )
18 |
19 | @Test
20 | fun byConstructorTestFailing() {
21 | // #761(KT-57357) fixed
22 | Assertions.assertThrows(Error::class.java) {
23 | assertEquals(ByConstructor(), defaultMapper.readValue("{}"))
24 | }
25 | }
26 |
27 | data class ByFactory(
28 | val nnNn: NullablePrimitive = NullablePrimitive(1),
29 | val nnN: NullablePrimitive = NullablePrimitive(null),
30 | val nNn: NullablePrimitive? = NullablePrimitive(2),
31 | val nN: NullablePrimitive? = null
32 | ) {
33 | companion object {
34 | @JvmStatic
35 | @JsonCreator
36 | fun creator(
37 | nnNn: NullablePrimitive = NullablePrimitive(1),
38 | nnN: NullablePrimitive = NullablePrimitive(null),
39 | nNn: NullablePrimitive? = NullablePrimitive(2),
40 | nN: NullablePrimitive? = null
41 | ) = ByFactory(nnNn, nnN, nNn, nN)
42 | }
43 | }
44 |
45 | @Test
46 | fun byFactoryTest() {
47 | // #761(KT-57357) fixed
48 | Assertions.assertThrows(Error::class.java) {
49 | assertEquals(ByFactory.creator(), defaultMapper.readValue("{}"))
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/kogeraIntegration/deser/valueClass/defaultArgument/PrimitiveTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.defaultArgument
2 |
3 | import com.fasterxml.jackson.annotation.JsonCreator
4 | import com.fasterxml.jackson.module.kotlin.defaultMapper
5 | import com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.Primitive
6 | import com.fasterxml.jackson.module.kotlin.readValue
7 | import org.junit.jupiter.api.Assertions.assertEquals
8 | import org.junit.jupiter.api.Test
9 |
10 | class PrimitiveTest {
11 | data class ByConstructor(
12 | val nn: Primitive = Primitive(1),
13 | val nNn: Primitive? = Primitive(2),
14 | val nN: Primitive? = null
15 | )
16 |
17 | @Test
18 | fun byConstructorTest() {
19 | assertEquals(ByConstructor(), defaultMapper.readValue("{}"))
20 | }
21 |
22 | data class ByFactory(val nn: Primitive, val nNn: Primitive?, val nN: Primitive?) {
23 | companion object {
24 | @JvmStatic
25 | @JsonCreator
26 | fun creator(
27 | nn: Primitive = Primitive(1),
28 | nNn: Primitive? = Primitive(2),
29 | nN: Primitive? = null
30 | ) = ByFactory(nn, nNn, nN)
31 | }
32 | }
33 |
34 | @Test
35 | fun byFactoryTest() {
36 | assertEquals(ByFactory.creator(), defaultMapper.readValue("{}"))
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/kogeraIntegration/deser/valueClass/defaultArgument/TwoUnitPrimitiveTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.defaultArgument
2 |
3 | import com.fasterxml.jackson.annotation.JsonCreator
4 | import com.fasterxml.jackson.module.kotlin.defaultMapper
5 | import com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.TwoUnitPrimitive
6 | import com.fasterxml.jackson.module.kotlin.readValue
7 | import org.junit.jupiter.api.Assertions.assertEquals
8 | import org.junit.jupiter.api.Test
9 |
10 | class TwoUnitPrimitiveTest {
11 | data class ByConstructor(
12 | val nn: TwoUnitPrimitive = TwoUnitPrimitive(1),
13 | val nNn: TwoUnitPrimitive? = TwoUnitPrimitive(2),
14 | val nN: TwoUnitPrimitive? = null
15 | )
16 |
17 | @Test
18 | fun byConstructorTest() {
19 | assertEquals(ByConstructor(), defaultMapper.readValue("{}"))
20 | }
21 |
22 | data class ByFactory(val nn: TwoUnitPrimitive, val nNn: TwoUnitPrimitive?, val nN: TwoUnitPrimitive?) {
23 | companion object {
24 | @JvmStatic
25 | @JsonCreator
26 | fun creator(
27 | nn: TwoUnitPrimitive = TwoUnitPrimitive(1),
28 | nNn: TwoUnitPrimitive? = TwoUnitPrimitive(2),
29 | nN: TwoUnitPrimitive? = null
30 | ) = ByFactory(nn, nNn, nN)
31 | }
32 | }
33 |
34 | @Test
35 | fun byFactoryTest() {
36 | assertEquals(ByFactory.creator(), defaultMapper.readValue("{}"))
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/kogeraIntegration/deser/valueClass/deserializer/byAnnotation/SpecifiedForClassTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.deserializer.byAnnotation
2 |
3 | import com.fasterxml.jackson.core.JsonParser
4 | import com.fasterxml.jackson.databind.DeserializationContext
5 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize
6 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer
7 | import com.fasterxml.jackson.module.kotlin.defaultMapper
8 | import com.fasterxml.jackson.module.kotlin.readValue
9 | import org.junit.jupiter.api.Assertions.assertEquals
10 | import org.junit.jupiter.api.Test
11 |
12 | class SpecifiedForClassTest {
13 | @JsonDeserialize(using = Value.Deserializer::class)
14 | @JvmInline
15 | value class Value(val v: Int) {
16 | class Deserializer : StdDeserializer(Value::class.java) {
17 | override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Value = Value(p.intValue + 100)
18 | }
19 | }
20 |
21 | @Test
22 | fun directDeserTest() {
23 | val result = defaultMapper.readValue("1")
24 |
25 | assertEquals(Value(101), result)
26 | }
27 |
28 | data class Wrapper(val v: Value)
29 |
30 | @Test
31 | fun paramDeserTest() {
32 | val result = defaultMapper.readValue("""{"v":1}""")
33 |
34 | assertEquals(Wrapper(Value(101)), result)
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/kogeraIntegration/deser/valueClass/deserializer/byAnnotation/specifiedForProperty/PrimitiveTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.deserializer.byAnnotation.specifiedForProperty
2 |
3 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize
4 | import com.fasterxml.jackson.module.kotlin.defaultMapper
5 | import com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.Primitive
6 | import com.fasterxml.jackson.module.kotlin.readValue
7 | import org.junit.jupiter.api.Assertions.assertEquals
8 | import org.junit.jupiter.api.Nested
9 | import org.junit.jupiter.api.Test
10 |
11 | class PrimitiveTest {
12 | data class NonNull(
13 | @get:JsonDeserialize(using = Primitive.Deserializer::class)
14 | val getterAnn: Primitive,
15 | @field:JsonDeserialize(using = Primitive.Deserializer::class)
16 | val fieldAnn: Primitive
17 | )
18 |
19 | @Test
20 | fun nonNull() {
21 | val result = defaultMapper.readValue(
22 | """
23 | {
24 | "getterAnn" : 1,
25 | "fieldAnn" : 2
26 | }
27 | """.trimIndent()
28 | )
29 | assertEquals(NonNull(Primitive(101), Primitive(102)), result)
30 | }
31 |
32 | data class Nullable(
33 | @get:JsonDeserialize(using = Primitive.Deserializer::class)
34 | val getterAnn: Primitive?,
35 | @field:JsonDeserialize(using = Primitive.Deserializer::class)
36 | val fieldAnn: Primitive?
37 | )
38 |
39 | @Nested
40 | inner class NullableTest {
41 | @Test
42 | fun nonNullInput() {
43 | val result = defaultMapper.readValue(
44 | """
45 | {
46 | "getterAnn" : 1,
47 | "fieldAnn" : 2
48 | }
49 | """.trimIndent()
50 | )
51 | assertEquals(Nullable(Primitive(101), Primitive(102)), result)
52 | }
53 |
54 | @Test
55 | fun nullInput() {
56 | val result = defaultMapper.readValue(
57 | """
58 | {
59 | "getterAnn" : null,
60 | "fieldAnn" : null
61 | }
62 | """.trimIndent()
63 | )
64 | assertEquals(Nullable(null, null), result)
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/kogeraIntegration/deser/valueClass/jsonCreator/HandledByJacksonTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.jsonCreator
2 |
3 | import com.fasterxml.jackson.annotation.JsonCreator
4 | import com.fasterxml.jackson.module.kotlin.defaultMapper
5 | import com.fasterxml.jackson.module.kotlin.readValue
6 | import org.junit.jupiter.api.Assertions.assertEquals
7 | import org.junit.jupiter.api.Test
8 |
9 | // Test for Creator that can be handled by the Jackson mechanism.
10 | class HandledByJacksonTest {
11 | @JvmInline
12 | value class PrimitiveMultiParamCreator(val value: Int) {
13 | companion object {
14 | // Avoiding unboxing by making the return value of Creator nullable
15 | @JvmStatic
16 | @JsonCreator
17 | fun creator(first: Int, second: Int): PrimitiveMultiParamCreator? =
18 | PrimitiveMultiParamCreator(first + second)
19 | }
20 | }
21 |
22 | @Test
23 | fun primitiveNullableCreatorTest() {
24 | val r: PrimitiveMultiParamCreator = defaultMapper.readValue("""{"first":1,"second":2}""")
25 | assertEquals(PrimitiveMultiParamCreator(3), r)
26 | }
27 |
28 | @JvmInline
29 | value class NullableObjectMultiParamCreator(val value: Int?) {
30 | companion object {
31 | // Avoiding unboxing by making the return value of Creator nullable
32 | @JvmStatic
33 | @JsonCreator
34 | fun creator(first: Int, second: Int): NullableObjectMultiParamCreator? =
35 | NullableObjectMultiParamCreator(first + second)
36 | }
37 | }
38 |
39 | @Test
40 | fun nullableObjectNullableCreatorTest() {
41 | val r: NullableObjectMultiParamCreator = defaultMapper.readValue("""{"first":1,"second":2}""")
42 | assertEquals(NullableObjectMultiParamCreator(3), r)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/kotlin/com/fasterxml/jackson/module/kotlin/kogeraIntegration/deser/valueClass/mapKey/keyDeserializer/byAnnotation/SpecifiedForClassTest.kt:
--------------------------------------------------------------------------------
1 | package com.fasterxml.jackson.module.kotlin.kogeraIntegration.deser.valueClass.mapKey.keyDeserializer.byAnnotation
2 |
3 | import com.fasterxml.jackson.databind.DeserializationContext
4 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize
5 | import com.fasterxml.jackson.module.kotlin.defaultMapper
6 | import com.fasterxml.jackson.module.kotlin.readValue
7 | import org.junit.jupiter.api.Assertions.assertEquals
8 | import org.junit.jupiter.api.Test
9 | import com.fasterxml.jackson.databind.KeyDeserializer as JacksonKeyDeserializer
10 |
11 | class SpecifiedForClassTest {
12 | @JsonDeserialize(keyUsing = Value.KeyDeserializer::class)
13 | @JvmInline
14 | value class Value(val v: Int) {
15 | class KeyDeserializer : JacksonKeyDeserializer() {
16 | override fun deserializeKey(key: String, ctxt: DeserializationContext) = Value(key.toInt() + 100)
17 | }
18 | }
19 |
20 | @Test
21 | fun directDeserTest() {
22 | val result = defaultMapper.readValue