[Git][java-team/jackson-jr][upstream] 5 commits: New upstream version 2.11.2

Emmanuel Bourg gitlab at salsa.debian.org
Mon Jan 18 09:04:49 GMT 2021



Emmanuel Bourg pushed to branch upstream at Debian Java Maintainers / jackson-jr


Commits:
c0234e00 by Emmanuel Bourg at 2021-01-18T09:55:24+01:00
New upstream version 2.11.2
- - - - -
39b8d762 by Emmanuel Bourg at 2021-01-18T09:55:41+01:00
New upstream version 2.11.3
- - - - -
24fb24ce by Emmanuel Bourg at 2021-01-18T09:55:47+01:00
New upstream version 2.11.4
- - - - -
84bc4a9a by Emmanuel Bourg at 2021-01-18T09:55:53+01:00
New upstream version 2.12.0
- - - - -
d36dd0df by Emmanuel Bourg at 2021-01-18T09:55:58+01:00
New upstream version 2.12.1
- - - - -


28 changed files:

- .travis.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/AnnotationBasedIntrospector.java
- jr-annotation-support/src/main/java/com/fasterxml/jackson/jr/annotationsupport/JacksonAnnotationExtension.java
- jr-annotation-support/src/test/java/com/fasterxml/jackson/jr/annotationsupport/BasicIgnoralTest.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/EnumReader.java
- jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/SimpleValueReader.java
- jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadBeansTest.java
- jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadListTest.java
- jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadSimpleTest.java
- jr-retrofit2/pom.xml
- jr-stree/pom.xml
- jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/CreateNodesTest.java
- jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/TestBase.java → jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/JacksonJrTreeTestBase.java
- jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/ReadTreeSequencesTest.java
- jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/ReadViaCodecTest.java
- jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/ReadViaJSONTest.java
- jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/SimpleTraverseTest.java
- jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/WriteViaCodecTest.java
- jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/WriteViaJSONTest.java
- jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/failing/DupFieldNameInTree51Test.java
- pom.xml
- release-notes/VERSION-2.x


Changes:

=====================================
.travis.yml
=====================================
@@ -2,9 +2,23 @@ language: java
 
 jdk:
   - openjdk8
+  - openjdk11
+
+# 2020-05-23, tatu: Let's try caching Maven dependencies
+cache:
+  directories:
+    - $HOME/.m2
 
 # whitelist
 branches:
   only:
     - master
-    - "2.11"
+    - "2.12"
+
+before_install: "git clone -b travis `git config --get remote.origin.url` target/travis"
+script: "[ ${TRAVIS_PULL_REQUEST} = 'false' ] && mvn clean deploy --settings target/travis/settings.xml || mvn clean verify --settings target/travis/settings.xml"
+
+env:
+  global:
+    - secure: "b4w65PD3TmiywSKwz+uLRT6yOUa0zS012uIbpu51ZW74DZ5pXZWdzY/Ax4bQQkjxqKlAYNAWif7dkwon6xxDpTcfdv2orr7f0fDE7jPWl2gfnRMzqJUeRT1JKu7GkKac2J6nf8K8tK+xx1tcFklpLuk+M69mH9P44AN5Y+3bINU="
+    - secure: "ea1e7inahwTosc+ulPxW7jgN0UdsHqovByYGFxGNIzniNLpuax44OM4XkRex3r91ldSm/QU5n4yXDlvBFjH368ux8+fxvCbfC039BUEKc/GtbMqETX4dTOcd1KHEyEYuXN1oo2ZgmN97Yg7/igZc6HdUYOJLiUklq05l+lz4T1k="


=====================================
README.md
=====================================
@@ -3,24 +3,25 @@
 Jackson jr is a compact alternative to full [Jackson Databind](../../../jackson-databind) component.
 It implements a subset of functionality, for example for cases where:
 
-1. Size of jar matters (jackson-jr size is about 100 kB)
-2. Startup time matters (jackson-jr has very low initialization overhead)
+1. Size of jar matters (`jackson-jr-objects` is bit over 100 kB)
+2. Startup time matters (`jackson-jr` has very low initialization overhead)
 
 In addition to basic datatypes (core JDK types like `List`s, `Map`s, wrapper types),
 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 (starting with Jackson-jr `2.8`)
-you can alternatively use `public` fields).
+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.
 
-Jackson jr also adds  `composer` implementation that can be used to
+Jackson-jr also adds  `composer` implementation that can be used to
 construct JSON output with builder-style API, but without necessarily having
 to build an in-memory representation: instead, it can directly use `streaming-api`
 for direct output. It is also possible to build actual in-memory
 JSON `String` or `byte[]` representation, if that is preferable.
 
-Jackson jr artifact itself is currently about 95 kB in size, and only depends on
+Main Jackson-jr artifact (`jackson-jr-objects`) itself is currently about 120 kB in size, and only depends on
 [Jackson Streaming API](../../../jackson-core) package.
-Combined size, for "all" jar, is about 400 kB (of which streaming API is about 300 kB),
+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
 size down even further, by renaming and removing debug information.
@@ -94,6 +95,21 @@ List<MyType> beans = JSON.std.listOfFrom(MyType.class, INPUT);
 
 (writing of `List`s and arrays works without addition effort: just pass List/array as-is)
 
+### Reading "streaming JSON" (LD-JSON)
+
+Version 2.10 added ability to read [Streaming JSON](https://en.wikipedia.org/wiki/JSON_streaming) content.
+See ["Jackson 2.10 features"](https://medium.com/@cowtowncoder/jackson-2-10-features-cd880674d8a2) (section "Jackson-jr feature expansion") for full example, but basic
+reading is done using new `ValueIterator` abstraction: 
+
+```
+File input = new File("json-stream.ldjson");
+try (ValueIterator<Bean> it = JSON.std.beanSequenceFrom(Bean.class, input)) {
+  while ((Bean bean = it.nextValue()) != null) {
+    // do something with 'bean'
+  }
+}
+```
+
 ### Writing with composers
 
 An alternative method exists for writing: "fluent" style output can be used as follows:
@@ -160,17 +176,20 @@ and in future other tree models may be offered as part of jackson-jr, or via oth
 
 To support readability and writability of your own types, your Java objects must either:
 
-* Implement Bean style accesors (getters for accessing data to write and/or setter for binding JSON data into objects), and define no-argument (default) constructor, OR
+* Implement Bean style accessors (getters for accessing data to write and/or setter for binding JSON data into objects), and define no-argument (default) constructor, OR
 * Define single-argument constructor if binding from JSON String (single-String argument) or JSON integer number (single-`long` or `Long` argument)
 
 Note that although getters and setters need to be public (since JDK Bean Introspection does not find any other methods),
 constructors may have any access right, including `private`.
 
-Also: starting with version 2.8, `public` fields may also be used (although their
+Starting with version 2.8, `public` fields may also be used (although their
 discovery may be disabled using `JSON.Feature.USE_FIELDS`) as an alternative:
 this is useful when limiting number of otherwise useless "getter" and "setter"
 methods.
 
+NEW! Jackson-jr 2.11 introduce `jackson-jr-annotation-support` extension (see more below)
+which allows use of Jackson annotations like `@JsonProperty`, `@JsonIgnore` and even `@JsonAutoDetect` for even more granular control of inclusion, naming and renaming.
+
 ### Customizing behavior with Features
 
 There are many customizable features you can use with `JSON` object; see [Full List of Features](../../wiki/JSON-Features) for details. But usage itself is via fluent methods like so:
@@ -182,6 +201,34 @@ String json = JSON.std
   .asString(...);
 ```
 
+### Adding custom value readers, writers
+
+Version 2.10 added ability to add custom `ValueReader`s and `ValueWriter`s, to
+allow pluggable support for types beyond basic JDK types and Beans.
+
+See section "Jackson-jr ValueReaders" of [Jackson-jr 2.10 improvements](https://cowtowncoder.medium.com/jackson-2-10-jackson-jr-improvements-9eb5bb7b35f) for an explanation of how to add custom `ValueReader`s and `ValueWriter`s
+
+You can also check out unit test
+
+   jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/impl/CustomValueReadersTest.java
+
+for sample usage.
+
+### Using (some of) Jackson annotations
+
+Jackson 2.11 added a new extension (a `JacksonJrExtension`) -- `jr-annotation-support` -- that adds support for a subset of Jackson annotations.
+See [jr-annotation-support/README.md](../../tree/master/jr-annotation-support) for details of this extension, but basic usage is by registering extension:
+
+```
+import com.fasterxml.jackson.jr.annotationsupport.JacksonAnnotationExtension;
+
+JSON json = JSON.builder()
+    .register(JacksonAnnotationExtension.std)
+    .build();
+```
+
+and then using `JSON` instance as usual.
+
 ## Get it!
 
 You can use Maven dependency like:
@@ -190,7 +237,7 @@ You can use Maven dependency like:
 <dependency>
   <groupId>com.fasterxml.jackson.jr</groupId>
   <artifactId>jackson-jr-objects</artifactId>
-  <version>2.9.0</version>
+  <version>2.12.0</version>
 </dependency>
 ```
 


=====================================
jr-all/pom.xml
=====================================
@@ -1,11 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
-
   <parent>
     <groupId>com.fasterxml.jackson.jr</groupId>
     <artifactId>jackson-jr-parent</artifactId>
-    <version>2.11.1</version>
+    <version>2.12.1</version>
   </parent>
   <artifactId>jackson-jr-all</artifactId>
   <name>jackson-jr-all</name>


=====================================
jr-annotation-support/README.md
=====================================
@@ -6,8 +6,7 @@ This package contains a simple extension, `JacksonAnnotationExtension` (subtype
 
 ### Status
 
-Added in Jackson 2.11 (to be released in Feb/March 2020),
-considered experimental until following minor version.
+Added in Jackson 2.11, considered stable as of 2.12 release.
 
 ### Usage
 


=====================================
jr-annotation-support/pom.xml
=====================================
@@ -1,9 +1,14 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <!-- This module was also published with a richer model, Gradle metadata,  -->
+  <!-- which should be used instead. Do not delete the following line which  -->
+  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
+  <!-- that they should prefer consuming it instead. -->
+  <!-- do_not_remove: published-with-gradle-metadata -->
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>com.fasterxml.jackson.jr</groupId>
     <artifactId>jackson-jr-parent</artifactId>
-    <version>2.11.1</version>
+    <version>2.12.1</version>
   </parent>
   <artifactId>jackson-jr-annotation-support</artifactId>
   <packaging>bundle</packaging>
@@ -66,6 +71,11 @@
         <groupId>org.moditect</groupId>
         <artifactId>moditect-maven-plugin</artifactId>
       </plugin>
+      <!-- 05-Jul-2020, tatu: Add generation of Gradle Module Metadata -->
+       <plugin>
+        <groupId>de.jjohannes</groupId>
+        <artifactId>gradle-module-metadata-maven-plugin</artifactId>
+      </plugin>
     </plugins>
   </build>
 


=====================================
jr-annotation-support/src/main/java/com/fasterxml/jackson/jr/annotationsupport/AnnotationBasedIntrospector.java
=====================================
@@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
 import com.fasterxml.jackson.jr.ob.impl.JSONReader;
 import com.fasterxml.jackson.jr.ob.impl.JSONWriter;
 import com.fasterxml.jackson.jr.ob.impl.POJODefinition;
@@ -220,7 +221,20 @@ public class AnnotationBasedIntrospector
     }
 
     protected void _findFields() {
-        for (Field f : _type.getDeclaredFields()) {
+        _findFields(_type);
+    }
+
+    protected void _findFields(final Class<?> currType)
+    {
+        if (currType == null || currType == Object.class) {
+            return;
+        }
+        // [jackson-jr#76]: Was not doing recursive field detection
+        // Start with base type fields (so overrides work)
+        _findFields(currType.getSuperclass());
+
+        // then get fields from within class itself
+        for (Field f : currType.getDeclaredFields()) {
             // Does not include static fields, but there are couple of things we do
             // not include regardless:
             if (f.isEnumConstant() || f.isSynthetic()) {


=====================================
jr-annotation-support/src/main/java/com/fasterxml/jackson/jr/annotationsupport/JacksonAnnotationExtension.java
=====================================
@@ -14,8 +14,6 @@ import com.fasterxml.jackson.jr.ob.api.ExtensionContext;
  * <li>{link com.fasterxml.jackson.annotation.JsonAlias}: supported on accessors
  *  (fields, getters, setters)
  *  </li>
- * <li>{@link com.fasterxml.jackson.annotation.JsonPropertyOrder}: supported on classes
- *  </li>
  * <li>{link com.fasterxml.jackson.annotation.JsonIgnore}: supported on accessors
  *  (fields, getters, setters)
  *  </li>


=====================================
jr-annotation-support/src/test/java/com/fasterxml/jackson/jr/annotationsupport/BasicIgnoralTest.java
=====================================
@@ -18,14 +18,25 @@ public class BasicIgnoralTest extends ASTestBase
         }
     }
 
+    static class BaseXY {
+        public int x, y;
+
+        protected BaseXY() { }
+        protected BaseXY(int x, int y) {
+            this.x = x;
+            this.y = y;
+        }
+    }
+
     @JsonIgnoreProperties({ "y" })
-    static class XYZ {
-        public int x, y, z;
+    static class XYZ
+        extends BaseXY
+    {
+        public int z;
 
         protected XYZ() { }
         public XYZ(int x, int y, int z) {
-            this.x = x;
-            this.y = y;
+            super(x, y);
             this.z = z;
         }
     }


=====================================
jr-annotation-support/src/test/java/com/fasterxml/jackson/jr/annotationsupport/BasicRenameTest.java
=====================================
@@ -37,7 +37,7 @@ public class BasicRenameTest extends ASTestBase
         // default, no ignorals:
         assertEquals(a2q("{'_first':'Bob','_last':'Burger'}"), JSON.std.asString(input));
 
-        // but if we ignore 'x'...
+        // but if we rename "_last"
         assertEquals(a2q("{'_last':'Burger','firstName':'Bob'}"), JSON_WITH_ANNO.asString(input));
 
         // and ensure no leakage to default one:


=====================================
jr-objects/pom.xml
=====================================
@@ -1,9 +1,14 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <!-- This module was also published with a richer model, Gradle metadata,  -->
+  <!-- which should be used instead. Do not delete the following line which  -->
+  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
+  <!-- that they should prefer consuming it instead. -->
+  <!-- do_not_remove: published-with-gradle-metadata -->
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>com.fasterxml.jackson.jr</groupId>
     <artifactId>jackson-jr-parent</artifactId>
-    <version>2.11.1</version>
+    <version>2.12.1</version>
   </parent>
   <artifactId>jackson-jr-objects</artifactId>
   <packaging>bundle</packaging>
@@ -94,6 +99,11 @@ has no other dependencies, and provides additional builder-style content generat
         <groupId>org.moditect</groupId>
         <artifactId>moditect-maven-plugin</artifactId>
       </plugin>
+      <!-- 05-Jul-2020, tatu: Add generation of Gradle Module Metadata -->
+       <plugin>
+        <groupId>de.jjohannes</groupId>
+        <artifactId>gradle-module-metadata-maven-plugin</artifactId>
+      </plugin>
     </plugins>
   </build>
 


=====================================
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/EnumReader.java
=====================================
@@ -51,9 +51,16 @@ public class EnumReader extends ValueReader
             }
             return _byIndex[ix];
         }
-        return _enum(p.getValueAsString().trim());
+        if (p.hasToken(JsonToken.VALUE_NULL)) {
+            return null;
+        }
+        if (p.hasToken(JsonToken.VALUE_STRING)) {
+            return _enum(p.getValueAsString().trim());
+        }
+        throw JSONObjectException.from(p, "Can not read Enum `"+_valueType.getName()+"` from "
+                +_tokenDesc(p, p.currentToken()));
     }
-    
+
     private Object _enum(String id) throws IOException
     {
         Object e = _byName.get(id);


=====================================
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/SimpleValueReader.java
=====================================
@@ -10,6 +10,7 @@ import java.util.*;
 
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.core.JsonTokenId;
 import com.fasterxml.jackson.jr.ob.JSONObjectException;
 import com.fasterxml.jackson.jr.ob.api.ValueReader;
 
@@ -35,22 +36,46 @@ public class SimpleValueReader extends ValueReader
         // Textual types, related:
         case SER_STRING:
         case SER_CHARACTER_SEQUENCE:
-            return _nextString(p);
+            {
+                String str = p.nextTextValue();
+                if (str != null) {
+                    return str;
+                }
+                return read(reader, p);
+            }
 
         case SER_CHAR_ARRAY:
-            String str = _nextString(p);
-            return (str == null) ? null : str.toCharArray();
+            {
+                String str = p.nextTextValue();
+                if (str != null) {
+                    return str.toCharArray();
+                }
+                return read(reader, p);
+            }
 
         // Number types:
 
-        case SER_NUMBER_SHORT: // fall through
-            return Short.valueOf((short) _nextInt(p));
+        // Let's only optimize common ones, int/Integer, long/Long;
+        // and only when `nextXxx()` correctly returns value. In all other
+        // cases default to "standard" handling which does range checks etc
 
         case SER_NUMBER_INTEGER:
-            return Integer.valueOf(_nextInt(p));
+            {
+                int i = p.nextIntValue(-2);
+                if (i != -2) {
+                    return i;
+                }
+                return read(reader, p);
+            }
 
         case SER_NUMBER_LONG:
-            return Long.valueOf(_nextLong(p));
+            {
+                long l = p.nextLongValue(-2L);
+                if (l != -2L) {
+                    return l;
+                }
+                return read(reader, p);
+            }
 
         // Other scalar types:
 
@@ -60,7 +85,7 @@ public class SimpleValueReader extends ValueReader
                 if (b != null) {
                     return b;
                 }
-                return p.getValueAsBoolean();
+                return read(reader, p);
             }
         }
 
@@ -114,15 +139,34 @@ public class SimpleValueReader extends ValueReader
         // Other scalar types:
 
         case SER_BOOLEAN:
-            return p.getValueAsBoolean();
-            
+            switch (p.currentTokenId()) {
+            case JsonTokenId.ID_TRUE:
+                return Boolean.TRUE;
+            case JsonTokenId.ID_FALSE:
+                return Boolean.FALSE;
+            case JsonTokenId.ID_NULL:
+                // 07-Jul-2020, tatu: since `boolean` and `java.lang.Boolean` both handled
+                //   here, can not (alas!) separate yet
+                return Boolean.FALSE;
+
+            case JsonTokenId.ID_STRING:
+                // 07-Jul-2020, tatu: Allow coercion for backwards compatibility (with 2.11)
+                return p.getValueAsBoolean();
+            }
+            // 07-Jul-2020, tatu: leave out more esoteric coercions with 2.12
+            break;
+
         case SER_CHAR:
             {
                 String str = p.getValueAsString();
                 return (str == null || str.isEmpty()) ? ' ' : str.charAt(0);
             }
-            
+
         case SER_CALENDAR:
+            // [jackson-jr#73]: should allow null
+            if (p.hasToken(JsonToken.VALUE_NULL)) {
+                return null;
+            }
             {
                 long l = _fetchLong(p);
                 Calendar cal = Calendar.getInstance();
@@ -131,10 +175,18 @@ public class SimpleValueReader extends ValueReader
             }
 
         case SER_DATE:
+            // [jackson-jr#73]: should allow null
+            if (p.hasToken(JsonToken.VALUE_NULL)) {
+                return null;
+            }
             return new Date(_fetchLong(p));
 
         case SER_CLASS:
         {
+            // [jackson-jr#73]: should allow null
+            if (p.hasToken(JsonToken.VALUE_NULL)) {
+                return null;
+            }
             String v = p.getValueAsString();
             try {
                 return Class.forName(v);
@@ -143,13 +195,28 @@ public class SimpleValueReader extends ValueReader
             }
         }
         case SER_FILE:
+            // [jackson-jr#73]: should allow null
+            if (p.hasToken(JsonToken.VALUE_NULL)) {
+                return null;
+            }
             return new File(p.getValueAsString());
         case SER_UUID:
+            // [jackson-jr#73]: should allow null
+            if (p.hasToken(JsonToken.VALUE_NULL)) {
+                return null;
+            }
             return UUID.fromString(p.getValueAsString());
         case SER_URL:
+            // [jackson-jr#73]: should allow null
+            if (p.hasToken(JsonToken.VALUE_NULL)) {
+                return null;
+            }
             return new URL(p.getValueAsString());
         case SER_URI:
-        
+            // [jackson-jr#73]: should allow null
+            if (p.hasToken(JsonToken.VALUE_NULL)) {
+                return null;
+            }
             return URI.create(p.getValueAsString());
 
 //        case SER_MAP:
@@ -160,9 +227,9 @@ public class SimpleValueReader extends ValueReader
         default: // types that shouldn't get here
         //case SER_ENUM:
         }
-        
+
         throw JSONObjectException.from(p,
-                "Can not create a "+_valueType.getName()+" instance out of "+_tokenDesc(p));
+                "Can not create a `"+_valueType.getName()+"` instance out of "+_tokenDesc(p));
     }    
 
     /*
@@ -190,25 +257,4 @@ public class SimpleValueReader extends ValueReader
         throw JSONObjectException.from(p, "Can not get long numeric value from JSON (to construct "
                 +_valueType.getName()+") from "+_tokenDesc(p, t));
     }
-
-    private final String _nextString(JsonParser p) throws IOException {
-        String str = p.nextTextValue();
-        return (str == null) ? p.getValueAsString() : str;
-    }
-
-    private final int _nextInt(JsonParser p) throws IOException {
-        int i = p.nextIntValue(-2);
-        if (i != -2) {
-            return i;
-        }
-        return p.getValueAsInt();
-    }
-
-    private final long _nextLong(JsonParser p) throws IOException {
-        long l = p.nextLongValue(-2L);
-        if (l != -2L) {
-            return l;
-        }
-        return p.getValueAsLong();
-    }
 }


=====================================
jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadBeansTest.java
=====================================
@@ -53,7 +53,7 @@ public class ReadBeansTest extends TestBase
 
     /*
     /**********************************************************************
-    /* Test methdods
+    /* Test methods
     /**********************************************************************
      */
 


=====================================
jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadListTest.java
=====================================
@@ -3,7 +3,6 @@ package com.fasterxml.jackson.jr.ob;
 import java.util.*;
 
 import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.jr.ob.ReadMapTest.TreeMapBuilder;
 import com.fasterxml.jackson.jr.ob.api.CollectionBuilder;
 
 public class ReadListTest extends TestBase


=====================================
jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadSimpleTest.java
=====================================
@@ -2,6 +2,9 @@ package com.fasterxml.jackson.jr.ob;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
 import java.util.*;
 
 import com.fasterxml.jackson.core.JsonParser;
@@ -23,6 +26,10 @@ public class ReadSimpleTest extends TestBase
         public TreeNode value;
     }
 
+    static class DateWrapper {
+        public Date value;
+    }
+
     /*
     /**********************************************************************
     /* Tests for arrays
@@ -145,13 +152,34 @@ public class ReadSimpleTest extends TestBase
         assertEquals(0.25f, JSON.std.beanFrom(Float.class, "0.25"));
     }
 
+    // 07-Jul-2020, tatu: Should probably make fail, but doesn't yet:
+    /*
+    public void testNumberFail() throws Exception {
+        try {
+            Integer I = JSON.std.beanFrom(Integer.class, "true");
+            fail("Should not pass, got: "+I);
+        } catch (JSONObjectException e) {
+            verifyException(e, "Can not get long numeric");
+        }
+    }
+    */
+
+    public void testBooleanFail() throws Exception {
+        try {
+            Boolean B = JSON.std.beanFrom(Boolean.class, "13");
+            fail("Should not pass, got: "+B);
+        } catch (JSONObjectException e) {
+            verifyException(e, "Can not create a `java.lang.Boolean` instance out of JSON Number");
+        }
+    }
+
     public void testMiscScalars() throws Exception {
         assertEquals(new Date(123456L), JSON.std.beanFrom(Date.class,"123456"));
         assertEquals(Object.class, JSON.std.beanFrom(Class.class, quote(Object.class.getName())));
     }
 
     public void testMiscScalarFail() throws Exception {
-        for (String input : new String[] { " false ",  "true", "[ ]", "{ }", "null" } ) {
+        for (String input : new String[] { " false ",  "true", "[ ]", "{ }" } ) {
             try {
                 JSON.std.beanFrom(Date.class, input);
                 fail("Should not pass");
@@ -161,6 +189,98 @@ public class ReadSimpleTest extends TestBase
         }
     }
 
+    /*
+    /**********************************************************************
+    /* Tests for Scalars, null handling
+    /**********************************************************************
+     */
+
+    // 07-Jul-2020, tatu: Should be able to check but as of 2.11 same reader used
+    //    for wrapper and primitives.
+    /*
+    public void testNullForMiscNumbers() throws Exception {
+        assertNull(JSON.std.beanFrom(Integer.class," null "));
+        assertNull(JSON.std.beanFrom(Long.class," null "));
+        assertNull(JSON.std.beanFrom(Double.class," null "));
+
+        assertNull(JSON.std.beanFrom(BigInteger.class," null "));
+        assertNull(JSON.std.beanFrom(BigDecimal.class," null "));
+    }
+    */
+
+    public void testNullForMiscScalars() throws Exception {
+        assertNull(JSON.std.beanFrom(Date.class," null "));
+        assertNull(JSON.std.beanFrom(Calendar.class," null "));
+
+        assertNull(JSON.std.beanFrom(String.class," null "));
+        assertNull(JSON.std.beanFrom(Class.class," null "));
+        assertNull(JSON.std.beanFrom(File.class," null "));
+        assertNull(JSON.std.beanFrom(URL.class," null "));
+        assertNull(JSON.std.beanFrom(URI.class," null "));
+    }
+
+    // Testing that `null` will not cause an exception, for now at least
+    public void testNullForPrimitiveProperties() throws Exception {
+        BooleanWrapper w = JSON.std.beanFrom(BooleanWrapper.class, aposToQuotes("{'value':null}"));
+        assertNotNull(w);
+        assertFalse(w.value);
+    }
+
+    public void testNullForScalarProperties() throws Exception {
+        DateWrapper w = JSON.std.beanFrom(DateWrapper.class, aposToQuotes("{'value':null}"));
+        assertNotNull(w);
+        assertNull(w.value);
+    }
+
+    /*
+    /**********************************************************************
+    /* Tests for other simple types
+    /**********************************************************************
+     */
+
+    public void testSimpleMixed() throws Exception
+    {
+        final String INPUT = "{\"a\":[1,2,{\"b\":true},3],\"c\":3}";
+        _verifySimpleMixed(JSON.std.anyFrom(INPUT), INPUT);
+        JsonParser p = parserFor(INPUT);
+        _verifySimpleMixed(JSON.std.anyFrom(p), INPUT);
+        p.close();
+    }
+
+    private void _verifySimpleMixed(Object ob, String json) throws Exception
+    {
+        assertTrue(ob instanceof Map);
+        assertEquals(2, ((Map<?,?>) ob).size());
+        Object list = (((Map<?,?>) ob).get("a"));
+        assertTrue(list instanceof List<?>);
+        
+        // actually, verify with write...
+        assertEquals(json, JSON.std.asString(ob));
+    }
+
+    public void testSimpleEnums() throws Exception
+    {
+        // First using index
+        ABC abc = JSON.std.beanFrom(ABC.class, String.valueOf(ABC.B.ordinal()));
+        assertEquals(ABC.B, abc);
+
+        // then from name
+        abc = JSON.std.beanFrom(ABC.class, quote("C"));
+        assertEquals(ABC.C, abc);
+
+        // `null`s ok too
+        assertNull(JSON.std.beanFrom(ABC.class, "null"));
+
+        // But not others...
+        try {
+            JSON.std.beanFrom(ABC.class, " true ");
+            fail("Should not pass");
+        } catch (JSONObjectException e) {
+            verifyException(e, "Can not read Enum ");
+            verifyException(e, "from `true`");
+        }
+    }
+
     /*
     /**********************************************************************
     /* Failing tests (mostly for code coverage)
@@ -241,41 +361,4 @@ public class ReadSimpleTest extends TestBase
             verifyException(e, "No content to map due to end-of-input");
         }
     }
-    
-    /*
-    /**********************************************************************
-    /* Other tests
-    /**********************************************************************
-     */
-
-    public void testSimpleMixed() throws Exception
-    {
-        final String INPUT = "{\"a\":[1,2,{\"b\":true},3],\"c\":3}";
-        _verifySimpleMixed(JSON.std.anyFrom(INPUT), INPUT);
-        JsonParser p = parserFor(INPUT);
-        _verifySimpleMixed(JSON.std.anyFrom(p), INPUT);
-        p.close();
-    }
-
-    private void _verifySimpleMixed(Object ob, String json) throws Exception
-    {
-        assertTrue(ob instanceof Map);
-        assertEquals(2, ((Map<?,?>) ob).size());
-        Object list = (((Map<?,?>) ob).get("a"));
-        assertTrue(list instanceof List<?>);
-        
-        // actually, verify with write...
-        assertEquals(json, JSON.std.asString(ob));
-    }
-
-    public void testSimpleEnums() throws Exception
-    {
-        // First using index
-        ABC abc = JSON.std.beanFrom(ABC.class, String.valueOf(ABC.B.ordinal()));
-        assertEquals(ABC.B, abc);
-
-        // then from name
-        abc = JSON.std.beanFrom(ABC.class, quote("C"));
-        assertEquals(ABC.C, abc);
-    }
 }


=====================================
jr-retrofit2/pom.xml
=====================================
@@ -1,9 +1,14 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <!-- This module was also published with a richer model, Gradle metadata,  -->
+  <!-- which should be used instead. Do not delete the following line which  -->
+  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
+  <!-- that they should prefer consuming it instead. -->
+  <!-- do_not_remove: published-with-gradle-metadata -->
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>com.fasterxml.jackson.jr</groupId>
     <artifactId>jackson-jr-parent</artifactId>
-    <version>2.11.1</version>
+    <version>2.12.1</version>
   </parent>
   <artifactId>jackson-jr-retrofit2</artifactId>
   <packaging>bundle</packaging>
@@ -70,6 +75,11 @@ ${project.groupId}.retrofit2;version=${project.version}
         <groupId>org.moditect</groupId>
         <artifactId>moditect-maven-plugin</artifactId>
       </plugin>
+      <!-- 05-Jul-2020, tatu: Add generation of Gradle Module Metadata -->
+       <plugin>
+        <groupId>de.jjohannes</groupId>
+        <artifactId>gradle-module-metadata-maven-plugin</artifactId>
+      </plugin>
     </plugins>
   </build>
 


=====================================
jr-stree/pom.xml
=====================================
@@ -1,9 +1,14 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <!-- This module was also published with a richer model, Gradle metadata,  -->
+  <!-- which should be used instead. Do not delete the following line which  -->
+  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
+  <!-- that they should prefer consuming it instead. -->
+  <!-- do_not_remove: published-with-gradle-metadata -->
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>com.fasterxml.jackson.jr</groupId>
     <artifactId>jackson-jr-parent</artifactId>
-    <version>2.11.1</version>
+    <version>2.12.1</version>
   </parent>
   <artifactId>jackson-jr-stree</artifactId>
   <packaging>bundle</packaging>
@@ -15,7 +20,7 @@ has no other dependencies.
     <!-- Looks like we need to be bit careful on OSGi exports, to avoid
         accidentally double-exporting jr-objects types
       -->
-    <osgi.export>${project.groupId}.stree;version=${project.version}</osgi.export>
+    <osgi.export>${project.groupId}.stree.*;version=${project.version}</osgi.export>
 
     <packageVersion.dir>com/fasterxml/jackson/jr/stree</packageVersion.dir>
     <packageVersion.package>${project.groupId}.stree</packageVersion.package>
@@ -63,6 +68,11 @@ has no other dependencies.
         <groupId>org.moditect</groupId>
         <artifactId>moditect-maven-plugin</artifactId>
       </plugin>
+      <!-- 05-Jul-2020, tatu: Add generation of Gradle Module Metadata -->
+       <plugin>
+        <groupId>de.jjohannes</groupId>
+        <artifactId>gradle-module-metadata-maven-plugin</artifactId>
+      </plugin>
     </plugins>
   </build>
 


=====================================
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/CreateNodesTest.java
=====================================
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.jr.ob.JSON;
  * so while Array/Object nodes may be created, they will be empty and can not
  * really be changed.
  */
-public class CreateNodesTest extends TestBase
+public class CreateNodesTest extends JacksonJrTreeTestBase
 {
      private final JSON treeJSON = jsonWithTreeCodec();
 


=====================================
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/TestBase.java → jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/JacksonJrTreeTestBase.java
=====================================
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.jr.ob.JSON;
 
 import junit.framework.TestCase;
 
-public abstract class TestBase extends TestCase
+public abstract class JacksonJrTreeTestBase extends TestCase
 {
     protected final JsonFactory _factory = new JsonFactory();
 


=====================================
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/ReadTreeSequencesTest.java
=====================================
@@ -8,7 +8,7 @@ import com.fasterxml.jackson.core.JsonParser.NumberType;
 import com.fasterxml.jackson.jr.ob.JSON;
 import com.fasterxml.jackson.jr.ob.ValueIterator;
 
-public class ReadTreeSequencesTest extends TestBase
+public class ReadTreeSequencesTest extends JacksonJrTreeTestBase
 {
     private final JSON treeJSON = jsonWithTreeCodec();
 


=====================================
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/ReadViaCodecTest.java
=====================================
@@ -10,7 +10,7 @@ import com.fasterxml.jackson.core.TreeNode;
  * Tests for reading content directly using codec, and not
  * through <code>JSON</code>
  */
-public class ReadViaCodecTest extends TestBase
+public class ReadViaCodecTest extends JacksonJrTreeTestBase
 {
     private final TreeCodec TREE_CODEC = new JacksonJrsTreeCodec();
 


=====================================
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/ReadViaJSONTest.java
=====================================
@@ -10,7 +10,7 @@ import com.fasterxml.jackson.jr.ob.JSON;
  * Tests for reading content using {@link JSON} with proper
  * codec registration
  */
-public class ReadViaJSONTest extends TestBase
+public class ReadViaJSONTest extends JacksonJrTreeTestBase
 {
     private final TreeCodec TREE_CODEC = new JacksonJrsTreeCodec();
     private final JSON treeJSON = jsonWithTreeCodec();


=====================================
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/SimpleTraverseTest.java
=====================================
@@ -3,7 +3,7 @@ package com.fasterxml.jackson.jr.stree;
 import com.fasterxml.jackson.core.*;
 import com.fasterxml.jackson.jr.stree.JacksonJrsTreeCodec;
 
-public class SimpleTraverseTest extends TestBase
+public class SimpleTraverseTest extends JacksonJrTreeTestBase
 {
     private final TreeCodec TREE_CODEC = new JacksonJrsTreeCodec();
 


=====================================
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/WriteViaCodecTest.java
=====================================
@@ -15,7 +15,7 @@ import com.fasterxml.jackson.jr.stree.JrsObject;
 import com.fasterxml.jackson.jr.stree.JrsString;
 import com.fasterxml.jackson.jr.stree.JrsValue;
 
-public class WriteViaCodecTest extends TestBase
+public class WriteViaCodecTest extends JacksonJrTreeTestBase
 {
     public void testSimpleList() throws Exception
     {


=====================================
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/WriteViaJSONTest.java
=====================================
@@ -4,7 +4,7 @@ import java.util.*;
 
 import com.fasterxml.jackson.jr.ob.JSON;
 
-public class WriteViaJSONTest extends TestBase
+public class WriteViaJSONTest extends JacksonJrTreeTestBase
 {
      private final JSON treeJSON = jsonWithTreeCodec();
 


=====================================
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/failing/DupFieldNameInTree51Test.java
=====================================
@@ -2,13 +2,13 @@ package com.fasterxml.jackson.jr.stree.failing;
 
 import com.fasterxml.jackson.jr.ob.JSON;
 import com.fasterxml.jackson.jr.ob.JSONObjectException;
-import com.fasterxml.jackson.jr.stree.TestBase;
+import com.fasterxml.jackson.jr.stree.JacksonJrTreeTestBase;
 
 /**
  * Tests for reading content using {@link JSON} with proper
  * codec registration
  */
-public class DupFieldNameInTree51Test extends TestBase
+public class DupFieldNameInTree51Test extends JacksonJrTreeTestBase
 {
     private final JSON treeJSON = jsonWithTreeCodec();
 


=====================================
pom.xml
=====================================
@@ -3,12 +3,12 @@
   <parent>
     <groupId>com.fasterxml.jackson</groupId>
     <artifactId>jackson-base</artifactId>
-    <version>2.11.1</version>
+    <version>2.12.1</version>
   </parent>
   <groupId>com.fasterxml.jackson.jr</groupId>
   <artifactId>jackson-jr-parent</artifactId>
   <name>Parent pom for Jackson jr components</name>
-  <version>2.11.1</version>
+  <version>2.12.1</version>
   <packaging>pom</packaging>
   <description>Parent pom for Jackson jr components
   </description>
@@ -26,7 +26,7 @@
     <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.11.1</tag>
+    <tag>jackson-jr-parent-2.12.1</tag>
   </scm>
 
   <properties>
@@ -41,7 +41,10 @@
            build for Java 6 need to downgrade here to last working 2.x version
           (2.5.4 had some issues wrt shading)
       -->
-    <version.plugin.bundle>2.5.3</version.plugin.bundle>
+    <!-- 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>
+      -->
 
     <!-- Aggressively minimize jar size; drop 'lines' and 'vars' -->
     <javac.debuglevel>source</javac.debuglevel>


=====================================
release-notes/VERSION-2.x
=====================================
@@ -4,11 +4,30 @@ Project: jackson-jr
 === Releases ===
 ------------------------------------------------------------------------
 
+2.12.1 (08-Jan-2021)
+
+#76: Annotation-based introspector does not include super-class fields
+
+2.12.0 (29-Nov-2020)
+
+- Add Gradle Module Metadata (https://blog.gradle.org/alignment-with-gradle-module-metadata)
+
+2.11.4 (12-Dec-2020)
+2.11.3 (02-Oct-2020)
+
+No changes since 2.11.2
+
+2.11.2 (02-Aug-2020)
+
+- Remove `maven-bundle-plugin` version override (was pinned to old 2.5.3)
+
 2.11.1 (25-Jun-2020)
 
 #72: Duplicate classes from `com.fasterxml.jackson.jr.ob` and
   `com.fasterxml.jackson.jr.type` in 2.11.0
   (reported by CListery at github)
+#74: jackson-jr-stree-2.11.1.jar is missing util package classes
+ (reported by Turloch O'T)
 
 2.11.0 (26-Apr-2020)
 
@@ -18,6 +37,11 @@ Project: jackson-jr
 #70: Add extension point (`ReaderWriterModifier`) to allow more customization of
   POJO readers, writers
 
+2.10.5 (21-Jul-2020)
+
+#73: Allow for reading `null` fields when reading simple objects
+ (reported by Jozsef B)
+
 2.10.4 (03-May-2020)
 2.10.3 (03-Mar-2020)
 



View it on GitLab: https://salsa.debian.org/java-team/jackson-jr/-/compare/49a6320008ae1f0b21f6568da939dbf00de36dd2...d36dd0dff631a0c947ecb36747ca2562741112dc

-- 
View it on GitLab: https://salsa.debian.org/java-team/jackson-jr/-/compare/49a6320008ae1f0b21f6568da939dbf00de36dd2...d36dd0dff631a0c947ecb36747ca2562741112dc
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/20210118/e1373f76/attachment.html>


More information about the pkg-java-commits mailing list