[Git][java-team/jackson-jr][upstream] New upstream version 2.14.0

Markus Koschany (@apo) gitlab at salsa.debian.org
Sat Nov 12 20:24:25 GMT 2022



Markus Koschany pushed to branch upstream at Debian Java Maintainers / jackson-jr


Commits:
d518417c by Markus Koschany at 2022-11-12T15:56:33+01:00
New upstream version 2.14.0
- - - - -


20 changed files:

- .github/workflows/main.yml
- README.md
- jr-all/pom.xml
- jr-annotation-support/README.md
- jr-annotation-support/pom.xml
- jr-annotation-support/src/main/java/com/fasterxml/jackson/jr/annotationsupport/AnnotationBasedValueRWModifier.java
- jr-annotation-support/src/moditect/module-info.java
- jr-annotation-support/src/test/java/com/fasterxml/jackson/jr/annotationsupport/ASTestBase.java
- jr-annotation-support/src/test/java/com/fasterxml/jackson/jr/annotationsupport/BasicRenameTest.java
- jr-objects/pom.xml
- + jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/Types.java
- jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/ValueLocatorBase.java
- jr-retrofit2/pom.xml
- jr-stree/pom.xml
- jr-stree/src/moditect/module-info.java
- jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/JrsValueEqualsTest.java
- + jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/failing/ReadAsBigDecimal90Test.java
- pom.xml
- release-notes/CREDITS-2.x
- release-notes/VERSION-2.x


Changes:

=====================================
.github/workflows/main.yml
=====================================
@@ -4,9 +4,20 @@ on:
     branches:
     - master
     - "3.0"
+    - "2.14"
     - "2.13"
     paths-ignore:
     - "README.md"
+    - "release-notes/*"
+  pull_request:
+    branches:
+    - master
+    - "3.0"
+    - "2.14"
+    - "2.13"
+    paths-ignore:
+    - "README.md"
+    - "release-notes/*"
 jobs:
   build:
     runs-on: ${{ matrix.os }}
@@ -18,27 +29,38 @@ jobs:
     env:
       JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
     steps:
-    - uses: actions/checkout at v2
+    - uses: actions/checkout at v3
     - name: Set up JDK
-      uses: actions/setup-java at v2
+      uses: actions/setup-java at v3
       with:
-        distribution: "adopt"
+        distribution: 'temurin'
         java-version: ${{ matrix.java_version }}
+        cache: 'maven'
         server-id: sonatype-nexus-snapshots
         server-username: CI_DEPLOY_USERNAME
         server-password: CI_DEPLOY_PASSWORD
-    - uses: actions/cache at v2.1.6
-      with:
-        path: ~/.m2/repository
-        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
-        restore-keys: |
-          ${{ runner.os }}-maven-
+        # See https://github.com/actions/setup-java/blob/v2/docs/advanced-usage.md#Publishing-using-Apache-Maven
+        # gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
+        # gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
     - name: Build
-      run: ./mvnw -V -B -ff -ntp verify
+      run: ./mvnw -B -q -ff -ntp verify
+    - name: Extract project Maven version
+      id: projectVersion
+      run: echo "version=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -DforceStdout -Dexpression=project.version -q)" >> $GITHUB_OUTPUT
     - name: Deploy snapshot
-      if: github.event_name != 'pull_request' && matrix.java_version == '8'
+      if: github.event_name != 'pull_request' && matrix.java_version == '8' && endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT')
       env:
         CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
         CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
         # MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
-      run: ./mvnw -V -B -ff -DskipTests -ntp source:jar deploy
+      run: ./mvnw -B -q -ff -DskipTests -ntp source:jar deploy
+    - name: Generate code coverage
+      if: github.event_name != 'pull_request' && matrix.java_version == '8'
+      run: ./mvnw -B -q -ff -ntp test
+    - name: Publish code coverage
+      if: github.event_name != 'pull_request' && matrix.java_version == '8'
+      uses: codecov/codecov-action at v1
+      with:
+        token: ${{ secrets.CODECOV_TOKEN }}
+        file: ./target/site/jacoco/jacoco.xml
+        flags: unittests


=====================================
README.md
=====================================
@@ -10,8 +10,8 @@ In addition to basic datatypes (core JDK types like `List`s, `Map`s, wrapper typ
 package supports reading and writing of standard Java Beans (implementation that mimics standard
 JDK Bean Introspection): that is,
 subset of POJOs that define setters/getters and/or `public` fields.
-And with 2.11 there is even optional support for a subset of Jackson annotations
-via optional `jackson-jr-annotatin-support` extension.
+And starting with 2.11 there is even optional support for a subset of Jackson annotations
+via optional `jackson-jr-annotation-support` extension.
 
 Jackson-jr also adds  `composer` implementation that can be used to
 construct JSON output with builder-style API, but without necessarily having
@@ -23,12 +23,12 @@ Main Jackson-jr artifact (`jackson-jr-objects`) itself is currently about 120 kB
 [Jackson Streaming API](../../../jackson-core) package.
 Combined size, for "all" jar, is bit over 500 kB (of which streaming API is about 350 kB),
 for use cases where a single jar is preferred over more modular approach.
-Finally, use of jar minimizers like [ProGuard](http://proguard.sourceforge.net/) can bring the jar
+Finally, use of jar minimizers like [ProGuard](https://proguard.sourceforge.net/) can bring the jar
 size down even further, by renaming and removing debug information.
 
 ## License
 
-Good old [Apache License](http://www.apache.org/licenses/LICENSE-2.0).
+Good old [Apache License](https://www.apache.org/licenses/LICENSE-2.0).
 
 ## Packaging
 
@@ -37,7 +37,7 @@ Project is composed of multiple Maven sub-modules, each corresponding to a jar:
 * [jr-objects](../../tree/master/jr-objects) contains the "core" databinding implementation, and is commonly the only dependency to use
     * Depends on `jackson-core` for low-level reading/writing
 * [jr-stree](../../tree/master/jr-stree) contains a simple `TreeCodec` implementation, with which it is possible to read JSON as `TreeNode`s (see more below)
-* [jr-retrofit2](../../tree/master/jr-retrofit2) contains `jackson-jr` - based handlers for [Retrofit 2](http://square.github.io/retrofit/) library
+* [jr-retrofit2](../../tree/master/jr-retrofit2) contains `jackson-jr` - based handlers for [Retrofit 2](https://square.github.io/retrofit/) library
     * Depends on `jackson-jr` and `Retrofit` API jars, and indirectly on `jackson-core`
 * [jr-annotation-support](../../tree/master/jr-annotation-support) contains extension with support for a subset of core [Jackson annotations](../../../jackson-annotations)
 * jr-all creates an "uber-jar" that contains individual modules along with all their dependencies:
@@ -52,7 +52,7 @@ If you are not sure which package to use, the answer is usually `jr-objects`, an
 
 [![Build Status](https://travis-ci.org/FasterXML/jackson-jr.svg)](https://travis-ci.org/FasterXML/jackson-jr)
 [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.fasterxml.jackson.jr/jackson-jr-objects/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.fasterxml.jackson.jr/jackson-jr-objects/)
-[![Javadoc](https://javadoc.io/badge/com.fasterxml.jackson.jr/jackson-jr-objects.svg)](http://www.javadoc.io/doc/com.fasterxml.jackson.jr/jackson-jr-objects)
+[![Javadoc](https://javadoc.io/badge/com.fasterxml.jackson.jr/jackson-jr-objects.svg)](https://www.javadoc.io/doc/com.fasterxml.jackson.jr/jackson-jr-objects)
 
 ## Usage
 
@@ -240,18 +240,18 @@ You can use Maven dependency like:
 <dependency>
   <groupId>com.fasterxml.jackson.jr</groupId>
   <artifactId>jackson-jr-objects</artifactId>
-  <version>2.12.0</version>
+  <version>2.13.0</version>
 </dependency>
 ```
 
-and then you can also download jars via [Central Maven repository](http://repo1.maven.org/maven2/com/fasterxml/jackson/jr/jackson-jr-objects/).
+and then you can also download jars via [Central Maven repository](https://repo1.maven.org/maven2/com/fasterxml/jackson/jr/jackson-jr-objects/).
 
 Or you can also clone the project and build it locally with `mvn clean install`.
 
 Alternatively if you want a single jar deployment, you can use `jackson-jr-all` jar which embeds `jackson-core`
 (repackaged using Shade plug-in, so as not to conflict with "vanilla" `jackson-core`):
 
-    http://repo1.maven.org/maven2/com/fasterxml/jackson/jr/jackson-jr-all/
+    https://repo1.maven.org/maven2/com/fasterxml/jackson/jr/jackson-jr-all/
 
 ## Performance
 


=====================================
jr-all/pom.xml
=====================================
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.fasterxml.jackson.jr</groupId>
     <artifactId>jackson-jr-parent</artifactId>
-    <version>2.13.0</version>
+    <version>2.14.0</version>
   </parent>
   <artifactId>jackson-jr-all</artifactId>
   <name>jackson-jr-all</name>
@@ -12,9 +12,18 @@
   <description>"Uber" jar that contains all Jackson jr components as well as underlying Jackson core
 Streaming, in a single jar.
 </description>
-  <url>http://wiki.fasterxml.com/JacksonHome</url>
+  <url>https://wiki.fasterxml.com/JacksonHome</url>
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
 
   <properties>
+    <!-- for Reproducible Builds -->
+    <project.build.outputTimestamp>2022-11-05T22:46:04Z</project.build.outputTimestamp>
   </properties>
 
   <dependencies>


=====================================
jr-annotation-support/README.md
=====================================
@@ -59,6 +59,7 @@ Following Jackson annotations are supported either partially or completely:
 * `@JsonProperty` (partial: accessor, only for inclusion/renaming (other properties ignored)
     * In 2.13, will also support renaming of `Enum` constants
 * `@JsonPropertyOrder` (complete: class)
+* `@JsonValue`/`@JsonCreator` (partial: enum only)
 
 Support for additional properties is possible in future versions.
 
@@ -72,6 +73,56 @@ limited in some ways for all annotations:
     * In future handling of Class annotations may be improved if this seems feasible
 * No support for "mix-in" annotations
 
+### Enum Support
+
+An `enum` can be tagged with `@JsonProperty` on its values to alias them
+for serialization and deserialization:
+
+```java
+enum ABCRename {
+  // first two are aliased, the last is not
+  @JsonProperty("A1") A, 
+  @JsonProperty("B1") B, 
+  C; 
+}
+```
+
+If an `enum` contains a method annotated with `@JsonValue` that returns a `String`
+then it will be used to serialize. Similarly, if it has a `@JsonCreator`
+method that can be used to deserialize, then that will be used:
+
+```java
+enum ABCJsonValueJsonCreator
+{
+    A("A1"),
+    B("B1"),
+    C("C");
+
+    private String label;
+
+    ABCJsonValueJsonCreator(String label) {
+      this.label = label;
+    }
+
+    // will be used for serialization
+    @JsonValue
+    public String serialize() {
+        return label;
+    }
+
+    // will be used for deserialization
+    @JsonCreator
+    public static ABCJsonValueJsonCreator fromLabel(String label) {
+      for (ABCJsonValueJsonCreator value : ABCJsonValueJsonCreator.values()) {
+          if (value.label.equals(label)) {
+              return value;
+          }
+      }
+      throw new IllegalArgumentException("Unexpected label '" + label + "'");
+    }
+}
+```
+
 ### Other configuration
 
 In addition to annotations, there is following configuration available


=====================================
jr-annotation-support/pom.xml
=====================================
@@ -8,7 +8,7 @@
   <parent>
     <groupId>com.fasterxml.jackson.jr</groupId>
     <artifactId>jackson-jr-parent</artifactId>
-    <version>2.13.0</version>
+    <version>2.14.0</version>
   </parent>
   <artifactId>jackson-jr-annotation-support</artifactId>
   <packaging>bundle</packaging>
@@ -16,6 +16,13 @@
   https://github.com/FasterXML/jackson-annotations
 </description>
   <url>https://github.com/FasterXML/jackson-jr</url>
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
   <properties>
     <!-- Looks like we need to be bit careful on OSGi exports, to avoid
         accidentally double-exporting jr-objects types
@@ -24,6 +31,9 @@
 
     <packageVersion.dir>com/fasterxml/jackson/jr/annotationsupport</packageVersion.dir>
     <packageVersion.package>${project.groupId}.annotationsupport</packageVersion.package>
+
+    <!-- for Reproducible Builds -->
+    <project.build.outputTimestamp>2022-11-05T22:46:04Z</project.build.outputTimestamp>
   </properties>
 
   <dependencies>


=====================================
jr-annotation-support/src/main/java/com/fasterxml/jackson/jr/annotationsupport/AnnotationBasedValueRWModifier.java
=====================================
@@ -2,14 +2,21 @@ package com.fasterxml.jackson.jr.annotationsupport;
 
 import java.io.IOException;
 import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.util.*;
 
 import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
+import com.fasterxml.jackson.annotation.JsonValue;
 import com.fasterxml.jackson.core.JsonGenerator;
 
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.jr.ob.JSONObjectException;
 import com.fasterxml.jackson.jr.ob.api.ReaderWriterModifier;
+import com.fasterxml.jackson.jr.ob.api.ValueReader;
 import com.fasterxml.jackson.jr.ob.api.ValueWriter;
 import com.fasterxml.jackson.jr.ob.impl.JSONReader;
 import com.fasterxml.jackson.jr.ob.impl.JSONWriter;
@@ -43,11 +50,29 @@ public class AnnotationBasedValueRWModifier extends ReaderWriterModifier
     @Override
     public ValueWriter overrideStandardValueWriter(JSONWriter writeContext, Class<?> type, int stdTypeId) {
         if (stdTypeId == SER_ENUM_ID) {
-            return new EnumWriter(type);
+            ValueWriter writeByJsonValue = EnumJsonValueWriter.of(type);
+            if (writeByJsonValue != null) {
+                return writeByJsonValue;
+            }
+            // the EnumWriter requires this to be the actual enum type, rather than a subclass of Enum
+            if (type.isEnum()) {
+                return new EnumWriter(type);
+            }
         }
         return null;
     }
 
+    @Override // since 2.14
+    public ValueReader modifyValueReader(JSONReader readContext, Class<?> type, ValueReader defaultReader) {
+        if (type.isEnum()) {
+            ValueReader readUsingJsonCreator = EnumJsonCreatorReader.of(type);
+            if (readUsingJsonCreator != null) {
+                return readUsingJsonCreator;
+            }
+        }
+        return super.modifyValueReader(readContext, type, defaultReader);
+    }
+
     private static class EnumWriter implements ValueWriter {
         private final Class<?> _valueType;
         private final Map<String, String> enumMap;
@@ -75,4 +100,126 @@ public class AnnotationBasedValueRWModifier extends ReaderWriterModifier
             return _valueType;
         }
     }
+
+    /**
+     * Serialize an enum using the {@link JsonValue} tagged method.
+     *
+     * @since 2.14
+     */
+    private static class EnumJsonValueWriter implements ValueWriter
+    {
+        private final Class<?> _valueType;
+        private final Method _jsonValueMethod;
+
+        private EnumJsonValueWriter(Class<?> _valueType, Method _jsonValueMethod) {
+            this._valueType = _valueType;
+            this._jsonValueMethod = _jsonValueMethod;
+            _jsonValueMethod.setAccessible(true);
+        }
+
+        @Override
+        public void writeValue(JSONWriter context, JsonGenerator g, Object value) throws IOException {
+            try {
+                context.writeValue(_jsonValueMethod.invoke(value));
+            } catch (Exception e) {
+                throw new JSONObjectException("Cannot call JsonValue method", e);
+            }
+        }
+
+        @Override
+        public Class<?> valueType() {
+            return _valueType;
+        }
+
+        /**
+         * Scan the methods of the enum to find a {@link JsonValue} tagged method
+         * which takes no parameters and returns a {@link String}
+         * @param type the type
+         * @return either a {@link EnumJsonValueWriter} to write this enum with, or <code>null</code> if no suitable
+         * method found
+         */
+        public static EnumJsonValueWriter of(Class<?> type) {
+            return getJsonValueFunction(type, type);
+        }
+
+        private static EnumJsonValueWriter getJsonValueFunction(Class<?> type, Class<?> inspectionType) {
+            for (Method method : inspectionType.getDeclaredMethods()) {
+                JsonValue jsonValueAnnotation = method.getDeclaredAnnotation(JsonValue.class);
+                if (!Modifier.isStatic(method.getModifiers()) &&
+                        jsonValueAnnotation != null &&
+                        method.getParameterCount() == 0 &&
+                        method.getReturnType().equals(String.class)) {
+                    // this is the @JsonValue on the lowest descendent of any hierarchy
+                    // it may be put here to disable it
+                    if (jsonValueAnnotation.value()) {
+                        return new EnumJsonValueWriter(type, method);
+                    }
+
+                    // if @JsonValue is disabled, then we deliberately stop searching for another one
+                    return null;
+                }
+            }
+
+            Class<?> superClass = inspectionType.getSuperclass();
+            if (superClass != null) {
+                EnumJsonValueWriter writer = getJsonValueFunction(type, superClass);
+                if (writer != null) {
+                    return writer;
+                }
+            }
+
+            for (Class<?> parentInterface : inspectionType.getInterfaces()) {
+                EnumJsonValueWriter writer = getJsonValueFunction(type, parentInterface);
+                if (writer != null) {
+                    return writer;
+                }
+            }
+
+            return null;
+        }
+    }
+
+    /**
+     * Deserialize into an enum using the {@link JsonCreator} tagged method
+     *
+     * @since 2.14
+     */
+    private static class EnumJsonCreatorReader extends ValueReader
+    {
+        private final Method _jsonCreatorMethod;
+
+        private EnumJsonCreatorReader(Class<?> valueType, Method jsonCreatorMethod) {
+            super(valueType);
+            this._jsonCreatorMethod = jsonCreatorMethod;
+            jsonCreatorMethod.setAccessible(true);
+        }
+
+        @Override
+        public Object read(JSONReader reader, JsonParser p) throws IOException {
+            try {
+                return _jsonCreatorMethod.invoke(_valueType, p.getText());
+            } catch (Exception e) {
+                throw new JSONObjectException("Cannot call JsonCreator method", e);
+            }
+        }
+
+        /**
+         * Scan the methods of the enum type to find a static method tagged with {@link JsonCreator}
+         * which takes exactly one parameter and returns a value of the enum's type
+         * @param type the type to scan
+         * @return a new {@link EnumJsonCreatorReader} to deserialize with, or <code>null</code> if there
+         * is no {@link JsonCreator} method to use
+         */
+        public static EnumJsonCreatorReader of(Class<?> type) {
+            for (Method method : type.getDeclaredMethods()) {
+                if (Modifier.isStatic(method.getModifiers()) &&
+                        method.getDeclaredAnnotation(JsonCreator.class) != null &&
+                        method.getParameterCount() == 1 &&
+                        method.getReturnType().equals(type)) {
+                    return new EnumJsonCreatorReader(type, method);
+                }
+            }
+            return null;
+        }
+    }
 }


=====================================
jr-annotation-support/src/moditect/module-info.java
=====================================
@@ -2,8 +2,6 @@ module com.fasterxml.jackson.jr.annotationsupport {
     requires com.fasterxml.jackson.core;
 
     requires com.fasterxml.jackson.jr.ob;
-    requires com.fasterxml.jackson.jr.ob.api;
-    requires com.fasterxml.jackson.jr.ob.impl;
 
     exports com.fasterxml.jackson.jr.annotationsupport;
 }


=====================================
jr-annotation-support/src/test/java/com/fasterxml/jackson/jr/annotationsupport/ASTestBase.java
=====================================
@@ -2,17 +2,15 @@ package com.fasterxml.jackson.jr.annotationsupport;
 
 import java.util.Arrays;
 
+import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonValue;
 import com.fasterxml.jackson.jr.ob.JSON;
 
 import junit.framework.TestCase;
 
 public abstract class ASTestBase extends TestCase
 {
-    protected enum ABC { A, B, C; }
-
-    protected enum ABCRename { @JsonProperty("A1") A, @JsonProperty("B1") B, C; }
-
     protected static class NameBean {
         protected String first, last;
 


=====================================
jr-annotation-support/src/test/java/com/fasterxml/jackson/jr/annotationsupport/BasicRenameTest.java
=====================================
@@ -1,7 +1,9 @@
 package com.fasterxml.jackson.jr.annotationsupport;
 
+import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
+import com.fasterxml.jackson.annotation.JsonValue;
 import com.fasterxml.jackson.jr.ob.JSON;
 import com.fasterxml.jackson.jr.ob.JSONObjectException;
 
@@ -21,6 +23,96 @@ public class BasicRenameTest extends ASTestBase
         }
     }
 
+    private interface EnumIdentifier {
+        @JsonValue
+        String getId();
+    }
+
+    /**
+     * enum that uses {@link JsonProperty} to alias values
+     */
+    protected enum ABCRename { @JsonProperty("A1") A, @JsonProperty("B1") B, C; }
+
+    /**
+     * enum that uses a {@link JsonValue} method to alias its values and a {@link JsonCreator} to
+     * deserialize
+     */
+    protected enum ABCJsonValueJsonCreator
+    {
+        A("A1"),
+        B("B1"),
+        C("C");
+
+        private String label;
+
+        ABCJsonValueJsonCreator(String label) {
+            this.label = label;
+        }
+
+        @Override
+        public String toString() {
+            return "ABCJsonValueJsonCreator{" +
+                    "label='" + label + '\'' +
+                    '}';
+        }
+
+        @JsonValue
+        public String serialize() {
+            return label;
+        }
+
+        @JsonCreator
+        public static ABCJsonValueJsonCreator fromLabel(String label) {
+            for (ABCJsonValueJsonCreator value : ABCJsonValueJsonCreator.values()) {
+                if (value.label.equals(label)) {
+                    return value;
+                }
+            }
+            throw new IllegalArgumentException("Unexpected label '" + label + "'");
+        }
+    }
+
+    /**
+     * Enum values in this class are anonymous inner classes
+     */
+    protected enum SubclassingEnum implements EnumIdentifier {
+        ENUM_A {
+            @Override
+            public String getId() {
+                return "A";
+            }
+        },
+        ENUM_B {
+            @Override
+            public String getId() {
+                return "B";
+            }
+        },
+        ENUM_NO_JSON_VALUE {
+            // don't use this to make the serialized version
+            // hiding the superclass's @JsonValue
+            @JsonValue(false)
+            @Override
+            public String getId() {
+                return "NONE";
+            }
+        };
+
+
+        @JsonCreator
+        public static SubclassingEnum from(String id) {
+            if ("A".equals(id)) {
+                return ENUM_A;
+            }
+            if ("B".equals(id)) {
+                return ENUM_B;
+            }
+            return null;
+        }
+    }
+
+
+
     /*
     /**********************************************************************
     /* Test methods
@@ -96,4 +188,75 @@ public class BasicRenameTest extends ASTestBase
         ABCRename resultC = JSON_WITH_ANNO.beanFrom(ABCRename.class, jsonC);
         assertEquals(ABCRename.C, resultC);
     }
+
+    public void testJsonValueCreatorEnumRenameOnSerialize() throws Exception
+    {
+        ABCJsonValueJsonCreator inputA = ABCJsonValueJsonCreator.A;
+        // default
+        assertEquals("\"ABCJsonValueJsonCreator{label='A1'}\"", JSON.std.asString(inputA));
+        // with annotations
+        assertEquals(a2q("\"A1\""), JSON_WITH_ANNO.asString(inputA));
+
+        ABCJsonValueJsonCreator inputB = ABCJsonValueJsonCreator.B;
+        // default
+        assertEquals("\"ABCJsonValueJsonCreator{label='B1'}\"", JSON.std.asString(inputB));
+        // with annotations
+        assertEquals(a2q("\"B1\""), JSON_WITH_ANNO.asString(inputB));
+
+        ABCJsonValueJsonCreator inputC = ABCJsonValueJsonCreator.C;
+        // default
+        assertEquals("\"ABCJsonValueJsonCreator{label='C'}\"", JSON.std.asString(inputC));
+        // with annotations
+        assertEquals(a2q("\"C\""), JSON_WITH_ANNO.asString(inputC));
+    }
+
+    public void testJsonValueCreatorEnumRenameOnDeserialize() throws Exception
+    {
+        String jsonA = a2q("\"A1\"");
+        ABCJsonValueJsonCreator resultA = JSON_WITH_ANNO.beanFrom(ABCJsonValueJsonCreator.class, jsonA);
+        assertEquals(ABCJsonValueJsonCreator.A, resultA);
+
+        String jsonB = a2q("\"B1\"");
+        ABCJsonValueJsonCreator resultB = JSON_WITH_ANNO.beanFrom(ABCJsonValueJsonCreator.class, jsonB);
+        assertEquals(ABCJsonValueJsonCreator.B, resultB);
+
+        String jsonC = a2q("\"C\"");
+        ABCJsonValueJsonCreator resultC = JSON_WITH_ANNO.beanFrom(ABCJsonValueJsonCreator.class, jsonC);
+        assertEquals(ABCJsonValueJsonCreator.C, resultC);
+    }
+
+    public void testJsonValueCreatorHierarchicalEnumRenameOnSerialize() throws Exception
+    {
+        SubclassingEnum inputA = SubclassingEnum.ENUM_A;
+        // default
+        assertEquals("\"ENUM_A\"", JSON.std.asString(inputA));
+        // with annotations
+        assertEquals(a2q("\"A\""), JSON_WITH_ANNO.asString(inputA));
+
+        SubclassingEnum inputB = SubclassingEnum.ENUM_B;
+        // default
+        assertEquals("\"ENUM_B\"", JSON.std.asString(inputB));
+        // with annotations
+        assertEquals(a2q("\"B\""), JSON_WITH_ANNO.asString(inputB));
+    }
+
+    public void testJsonValueCreatorHierarchicalEnumRenameOnDeserialize() throws Exception
+    {
+        String jsonA = a2q("\"A\"");
+        SubclassingEnum resultA = JSON_WITH_ANNO.beanFrom(SubclassingEnum.class, jsonA);
+        assertEquals(SubclassingEnum.ENUM_A, resultA);
+
+        String jsonB = a2q("\"B\"");
+        SubclassingEnum resultB = JSON_WITH_ANNO.beanFrom(SubclassingEnum.class, jsonB);
+        assertEquals(SubclassingEnum.ENUM_B, resultB);
+    }
+
+    public void testJsonValueHidingSubclass() throws Exception
+    {
+        SubclassingEnum input = SubclassingEnum.ENUM_NO_JSON_VALUE;
+        // default
+        assertEquals("\"ENUM_NO_JSON_VALUE\"", JSON.std.asString(input));
+        // with annotations
+        assertEquals(a2q("\"ENUM_NO_JSON_VALUE\""), JSON_WITH_ANNO.asString(input));
+    }
 }


=====================================
jr-objects/pom.xml
=====================================
@@ -8,20 +8,30 @@
   <parent>
     <groupId>com.fasterxml.jackson.jr</groupId>
     <artifactId>jackson-jr-parent</artifactId>
-    <version>2.13.0</version>
+    <version>2.14.0</version>
   </parent>
   <artifactId>jackson-jr-objects</artifactId>
   <packaging>bundle</packaging>
   <description>Simple data-binding that builds directly on jackson-core (streaming),
 has no other dependencies, and provides additional builder-style content generator
 </description>
-  <url>http://wiki.fasterxml.com/JacksonHome</url>
+  <url>https://github.com/FasterXML/jackson-jr</url>
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
   <properties>
     <!-- 01-Dec-2015, tatu: OSGi imports, exports should be fine with defaults from parent -->
     <packageVersion.dir>com/fasterxml/jackson/jr/ob</packageVersion.dir>
     <packageVersion.package>${project.groupId}.ob</packageVersion.package>
     <packageVersion.template.input>${basedir}/src/main/java/${packageVersion.dir}/PackageVersion.java.in</packageVersion.template.input>
     <packageVersion.template.output>${generatedSourcesDir}/${packageVersion.dir}/PackageVersion.java</packageVersion.template.output>
+
+    <!-- for Reproducible Builds -->
+    <project.build.outputTimestamp>2022-11-05T22:46:04Z</project.build.outputTimestamp>
   </properties>
 
   <dependencies>
@@ -39,7 +49,7 @@ has no other dependencies, and provides additional builder-style content generat
         <artifactId>maven-javadoc-plugin</artifactId>
         <configuration>
           <links combine.children="append">
-            <link>http://fasterxml.github.com/jackson-core/javadoc/2.13</link>
+            <link>https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-core/2.13/</link>
           </links>
         </configuration>
 


=====================================
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/Types.java
=====================================
@@ -0,0 +1,25 @@
+package com.fasterxml.jackson.jr.ob.impl;
+
+/**
+ * Utilities to help with reflection and types
+ */
+public final class Types {
+    private Types() {
+        // utility class
+    }
+
+    /**
+     * Detect whether a class is an enum or a subclass of an enum - e.g. an anonymous inner class
+     * inside an enum
+     * @param type the type to inspect
+     * @return <code>true</code> if effectively an enum
+     */
+    public static boolean isEnum(Class<?> type) {
+        return type.isEnum() || isParentEnum(type);
+    }
+
+    private static boolean isParentEnum(Class<?> type) {
+        Class<?> superClass = type.getSuperclass();
+        return superClass != null && isEnum(superClass);
+    }
+}


=====================================
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/ValueLocatorBase.java
=====================================
@@ -10,6 +10,8 @@ import java.util.*;
 import com.fasterxml.jackson.core.TreeNode;
 import com.fasterxml.jackson.jr.ob.JSON;
 
+import static com.fasterxml.jackson.jr.ob.impl.Types.isEnum;
+
 // Only public for reference by `AnnotationBasedValueRWModifier`
 public abstract class ValueLocatorBase
 {
@@ -187,7 +189,7 @@ public abstract class ValueLocatorBase
         if (raw == Character.class) {
             return SER_CHAR;
         }
-        if (raw.isEnum()) {
+        if (isEnum(raw)) {
             return SER_ENUM;
         }
         if (Map.class.isAssignableFrom(raw)) {


=====================================
jr-retrofit2/pom.xml
=====================================
@@ -8,12 +8,19 @@
   <parent>
     <groupId>com.fasterxml.jackson.jr</groupId>
     <artifactId>jackson-jr-parent</artifactId>
-    <version>2.13.0</version>
+    <version>2.14.0</version>
   </parent>
   <artifactId>jackson-jr-retrofit2</artifactId>
   <packaging>bundle</packaging>
   <description>Basic provider implementation for Retrofit 2 library
 </description>
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
   <properties>
     <!-- Looks like we need to be bit careful on OSGi exports, to avoid
         accidentally double-exporting jr-objects types
@@ -24,6 +31,9 @@ ${project.groupId}.retrofit2;version=${project.version}
 
     <!-- No PackageVersion defined or needed, since N/A for this package
       -->
+
+    <!-- for Reproducible Builds -->
+    <project.build.outputTimestamp>2022-11-05T22:46:04Z</project.build.outputTimestamp>
   </properties>
 
   <dependencies>


=====================================
jr-stree/pom.xml
=====================================
@@ -8,7 +8,7 @@
   <parent>
     <groupId>com.fasterxml.jackson.jr</groupId>
     <artifactId>jackson-jr-parent</artifactId>
-    <version>2.13.0</version>
+    <version>2.14.0</version>
   </parent>
   <artifactId>jackson-jr-stree</artifactId>
   <packaging>bundle</packaging>
@@ -16,6 +16,14 @@
 has no other dependencies.
 </description>
   <url>https://github.com/FasterXML/jackson-jr</url>
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+
   <properties>
     <!-- Looks like we need to be bit careful on OSGi exports, to avoid
         accidentally double-exporting jr-objects types
@@ -24,6 +32,9 @@ has no other dependencies.
 
     <packageVersion.dir>com/fasterxml/jackson/jr/stree</packageVersion.dir>
     <packageVersion.package>${project.groupId}.stree</packageVersion.package>
+
+    <!-- for Reproducible Builds -->
+    <project.build.outputTimestamp>2022-11-05T22:46:04Z</project.build.outputTimestamp>
   </properties>
 
   <dependencies>


=====================================
jr-stree/src/moditect/module-info.java
=====================================
@@ -2,7 +2,6 @@
 module com.fasterxml.jackson.jr.stree {
     requires transitive com.fasterxml.jackson.core;
     requires com.fasterxml.jackson.jr.ob;
-    requires com.fasterxml.jackson.jr.ob.api;
 
     exports com.fasterxml.jackson.jr.stree;
     exports com.fasterxml.jackson.jr.stree.util;


=====================================
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/JrsValueEqualsTest.java
=====================================
@@ -41,13 +41,16 @@ public class JrsValueEqualsTest extends JacksonJrTreeTestBase
 
     public void testScalarEquality() throws Exception
     {
-        assertEquals(treeJSON.treeFrom("12"), treeJSON.treeFrom("12"));
+        TreeNode tree = treeJSON.treeFrom("12");
+        assertEquals(tree, treeJSON.treeFrom("12"));
         assertFalse(treeJSON.treeFrom("12").equals(treeJSON.treeFrom("-12")));
 
-        assertEquals(treeJSON.treeFrom("true"), treeJSON.treeFrom("true"));
+        tree = treeJSON.treeFrom("true");
+        assertEquals(tree, treeJSON.treeFrom("true"));
         assertFalse(treeJSON.treeFrom("true").equals(treeJSON.treeFrom("137")));
 
-        assertEquals(treeJSON.treeFrom(q("name")), treeJSON.treeFrom(q("name")));
+        tree = treeJSON.treeFrom(q("name"));
+        assertEquals(tree, treeJSON.treeFrom(q("name")));
         assertFalse(treeJSON.treeFrom(q("true")).equals(treeJSON.treeFrom("true")));
     }
 }


=====================================
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/failing/ReadAsBigDecimal90Test.java
=====================================
@@ -0,0 +1,30 @@
+package com.fasterxml.jackson.jr.stree.failing;
+
+import java.math.BigDecimal;
+
+import com.fasterxml.jackson.core.TreeNode;
+
+import com.fasterxml.jackson.jr.ob.*;
+import com.fasterxml.jackson.jr.stree.*;
+
+public class ReadAsBigDecimal90Test extends JacksonJrTreeTestBase
+{
+    // [jackson-jr#90]
+    public void testReadAsBigDecimal() throws Exception
+    {
+        JSON json = JSON.builder()
+                .treeCodec(new JacksonJrsTreeCodec())
+                .enable(JSON.Feature.USE_BIG_DECIMAL_FOR_FLOATS)
+                .build();
+
+        String input = "[1.1]";
+
+        TreeNode node = json.treeFrom(input);
+        TreeNode elemNode = node.get(0);
+
+        assertTrue(elemNode.isValueNode());
+        assertTrue(elemNode instanceof JrsNumber);
+        assertEquals(BigDecimal.class,
+                ((JrsNumber) elemNode).getValue().getClass());
+    }
+}


=====================================
pom.xml
=====================================
@@ -3,15 +3,22 @@
   <parent>
     <groupId>com.fasterxml.jackson</groupId>
     <artifactId>jackson-base</artifactId>
-    <version>2.13.0</version>
+    <version>2.14.0</version>
   </parent>
   <groupId>com.fasterxml.jackson.jr</groupId>
   <artifactId>jackson-jr-parent</artifactId>
   <name>Parent pom for Jackson jr components</name>
-  <version>2.13.0</version>
+  <version>2.14.0</version>
   <packaging>pom</packaging>
   <description>Parent pom for Jackson jr components
   </description>
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
 
   <modules>
     <module>jr-objects</module>
@@ -25,29 +32,22 @@
   <scm>
     <connection>scm:git:git at github.com:FasterXML/jackson-jr.git</connection>
     <developerConnection>scm:git:git at github.com:FasterXML/jackson-jr.git</developerConnection>
-    <url>http://github.com/FasterXML/jackson-jr</url>    
-    <tag>jackson-jr-parent-2.13.0</tag>
+    <url>https://github.com/FasterXML/jackson-jr</url>
+    <tag>jackson-jr-parent-2.14.0</tag>
   </scm>
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    <!-- 04-May-2016, tatu: This should still work with 2.8, as jackson-core
-        only requires Java 6 (unlike databind and other modules)
-      -->
-    <javac.src.version>1.6</javac.src.version>
-    <javac.target.version>1.6</javac.target.version>
-
-    <!-- 04-May-2016, tatu: Bundle-plugin 3.x seems to require Java 7, so to
-           build for Java 6 need to downgrade here to last working 2.x version
-          (2.5.4 had some issues wrt shading)
-      -->
-    <!-- 30-Jul-2020, tatu: But 4.2.0 seems to have worked for `jackson-annotations`
-           for a while now (since 2.10.x) so remove version lock
-    <version.plugin.bundle>4.2.1</version.plugin.bundle>
+    <!-- 03-May-2022: Change Java compatibility for Jackson-Core 2.14 from Java6 to Java8,
+       still use Moditect to get JDK9+ module info support; need newer bundle plugin as well
+       (can just defaults from `jackson-parent`)
       -->
 
     <!-- Aggressively minimize jar size; drop 'lines' and 'vars' -->
     <javac.debuglevel>source</javac.debuglevel>
+
+    <!-- for Reproducible Builds -->
+    <project.build.outputTimestamp>2022-11-05T22:46:04Z</project.build.outputTimestamp>
   </properties>
 
   <!-- Alas, need to include snapshot reference since otherwise can not find
@@ -68,7 +68,6 @@
       <plugin>
         <groupId>org.jacoco</groupId>
         <artifactId>jacoco-maven-plugin</artifactId>
-        <version>0.8.4</version>
         <executions>
           <execution>
             <goals>


=====================================
release-notes/CREDITS-2.x
=====================================
@@ -22,3 +22,9 @@ Jonas Konrad (yawkat at github)
 
 * Suggested #88: Make `jr-stree` dependency to `jr-objects` optional
  (2.13.0)
+
+Gerben Oolbekkink (qurben at github)
+
+* Reported #98: `module-info.java` of `jr-stree` refers to module `com.fasterxml.jackson.jr.ob.api`,
+  which is not defined
+ (2.13.5)


=====================================
release-notes/VERSION-2.x
=====================================
@@ -11,6 +11,22 @@ Modules:
 === Releases ===
 ------------------------------------------------------------------------
 
+2.14.0 (05-Nov-2022)
+
+#91: Annotation support should allow `@JsonValue`/`JsonCreator` on `enum`
+ (contributed by Ashley F)
+#95: Increase minimum Java baseline from 6 to 8 for version 2.14
+#98: `module-info.java` of `jr-stree` refers to module `com.fasterxml.jackson.jr.ob.api`,
+  which is not defined
+ (reported by Gerben O)
+
+2.13.4 (03-Sep-2022)
+2.13.3 (14-May-2022)
+2.13.2 (06-Mar-2022)
+2.13.1 (19-Dec-2021)
+
+No changes since 2.13.0
+
 2.13.0 (30-Sep-2021)
 
 #79: Reuse of ClassKey in ValueWriterLocator not working
@@ -26,6 +42,14 @@ Modules:
  (suggested by Jonas K)
 - Update retrofit dependency to 2.7.2 (and okhttp to 3.14.9)
 
+2.12.7 (26-May-2022)
+
+No changes since 2.12.6
+
+2.12.6 (15-Dec-2021)
+
+* Update `okhttp` dep: 3.12.0 -> 3.14.9
+
 2.12.5 (27-Aug-2021)
 2.12.4 (06-Jul-2021)
 2.12.3 (12-Apr-2021)



View it on GitLab: https://salsa.debian.org/java-team/jackson-jr/-/commit/d518417cca53f8fb34503bf75a7566aaef931dfa

-- 
View it on GitLab: https://salsa.debian.org/java-team/jackson-jr/-/commit/d518417cca53f8fb34503bf75a7566aaef931dfa
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20221112/63fec287/attachment.htm>


More information about the pkg-java-commits mailing list