diff --git a/DependencyUpdateSearch_Rules.xml b/DependencyUpdateSearch_Rules.xml new file mode 100644 index 00000000..77cc7db8 --- /dev/null +++ b/DependencyUpdateSearch_Rules.xml @@ -0,0 +1,15 @@ + + + + + (?i).*Alpha(?:-?\d+)? + (?i).*a(?:-?\d+)? + (?i).*Beta(?:-?\d+)? + (?i).*-B(?:-?\d+)? + (?i).*RC(?:-?\d+)? + (?i).*CR(?:-?\d+)? + (?i).*M(?:-?\d+)? + + + + diff --git a/README.md b/README.md index b621a36c..1e2eeee8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,52 @@ + +#### Note: this is a fork for a private project that includes PRs for the Java module system and Java Record classes. I'm not actively supporting this. + +Original Project status (not this fork): [![Build Status](https://travis-ci.org/json-iterator/java.svg?branch=master)](https://travis-ci.org/json-iterator/java) [![codecov](https://codecov.io/gh/json-iterator/java/branch/master/graph/badge.svg)](https://codecov.io/gh/json-iterator/java) [![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/json-iterator/java/master/LICENSE) [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/json-iterator/Lobby) -Documentation : [http://jsoniter.com/java-features.html](http://jsoniter.com/java-features.html) +Documentation : [http://jsoniter.com/java-features.html](http://jsoniter.com/java-features.html) + +Scala User: https://github.com/plokhotnyuk/jsoniter-scala + +#### To use this fork: + +Add jitpack.io as a repository: + +```xml + + + + false + + central + Central Repository + https://repo.maven.apache.org/maven2 + + + + jitpack.io + https://jitpack.io + + +``` + +Add this dependency, by referring to this Github page: + +```xml + + com.github.Brixomatic + json-iterator-java + master-SNAPSHOT + +``` -Scala User: https://github.com/plokhotnyuk/jsoniter-scala \ No newline at end of file +Note: + **The Java Module System enhancement has not been tested with jackson, gson or javassist.** + You might however vote for this PR in the original project, so it gets more popularity and the remaning problems can be addressed: + [https://github.com/json-iterator/java/pull/325](https://github.com/json-iterator/java/pull/325) + + The original author seems to have abandoned the project though. + diff --git a/pom.xml b/pom.xml index fe0bd30c..1f1f06da 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ junit junit - 4.12 + 4.13.2 test @@ -52,38 +52,38 @@ com.fasterxml.jackson.core jackson-annotations - 2.9.5 + 2.13.3 true com.fasterxml.jackson.core jackson-databind - 2.9.5 + 2.13.3 true com.google.code.gson gson - 2.8.3 + 2.9.1 true org.openjdk.jmh jmh-core - 1.20 + 1.35 test org.openjdk.jmh jmh-generator-annprocess - 1.20 + 1.35 test org.apache.commons commons-lang3 - 3.5 + 3.12.0 test @@ -125,16 +125,18 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + 3.10.1 - 16 + 17 + 17 + 17 UTF-8 org.apache.maven.plugins maven-source-plugin - 3.0.1 + 3.2.1 attach-sources @@ -147,7 +149,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.0.0 + 3.4.0 attach-javadocs @@ -160,6 +162,7 @@ + org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.6.13 true ossrh @@ -199,7 +203,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.21.0 + 2.20 true methods @@ -215,6 +219,46 @@ + + + org.codehaus.mojo + versions-maven-plugin + 2.11.0 + + file:///${project.basedir}/DependencyUpdateSearch_Rules.xml + + + + verify + + display-dependency-updates + display-plugin-updates + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.1.0 + + + enforce-maven + + enforce + + + + + [3.3.2,) + + + + + + + diff --git a/src/main/java/com/jsoniter/spi/JsoniterSpi.java b/src/main/java/com/jsoniter/spi/JsoniterSpi.java index 4b40e77e..050ccab3 100644 --- a/src/main/java/com/jsoniter/spi/JsoniterSpi.java +++ b/src/main/java/com/jsoniter/spi/JsoniterSpi.java @@ -292,6 +292,15 @@ private synchronized static void addObjectFactory(Class clazz, Extension extensi objectFactories = copy; } + public static synchronized void clearCaches() { + mapKeyEncoders = new HashMap<>(); + mapKeyDecoders = new HashMap<>(); + encoders = new HashMap<>(); + decoders = new HashMap<>(); + objectFactories = new HashMap<>(); + } + + private static class TypeProperty { public final Type type; diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 00000000..57b5d2c8 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,38 @@ +open module com.jsoniter { + + exports com.jsoniter; + + exports com.jsoniter.fuzzy; + + exports com.jsoniter.static_codegen; + + exports com.jsoniter.extra; + + exports com.jsoniter.output; + + exports com.jsoniter.annotation; + + exports com.jsoniter.spi; + + exports com.jsoniter.any; + + + /** static, because marked as optional in pom.xml*/ + requires static javassist; + + /** static, because marked as optional in pom.xml*/ + requires static com.fasterxml.jackson.core; + + /** static, because marked as optional in pom.xml*/ + requires static com.fasterxml.jackson.annotation; + + /** static, because marked as optional in pom.xml*/ + requires static com.fasterxml.jackson.databind; + + /** static, because marked as optional in pom.xml*/ + requires static com.google.gson; + + /** static, because only used in testing */ + requires static java.desktop; + +} \ No newline at end of file diff --git a/src/test/java/com/jsoniter/output/TestNested.java b/src/test/java/com/jsoniter/output/TestNested.java index 00fd8d6d..e3750c66 100644 --- a/src/test/java/com/jsoniter/output/TestNested.java +++ b/src/test/java/com/jsoniter/output/TestNested.java @@ -1,16 +1,12 @@ package com.jsoniter.output; +import java.io.*; +import java.util.*; + import com.jsoniter.annotation.JsonProperty; -import com.jsoniter.spi.JsoniterSpi; -import com.jsoniter.spi.TypeLiteral; -import junit.framework.TestCase; +import com.jsoniter.spi.*; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import junit.framework.TestCase; public class TestNested extends TestCase { @@ -45,7 +41,7 @@ public void test_collection_of_objects() throws IOException { obj1.field1 = "1"; obj1.field2 = "2"; String output = JsonStream.serialize(new TypeLiteral>() { - }, new ArrayList() {{ + }, new ArrayList<>() {{ add(obj1); }}); assertTrue(output.contains("field1")); @@ -92,7 +88,7 @@ public void test_map_of_objects() throws IOException { obj1.field1 = "1"; obj1.field2 = "2"; stream.writeVal(new TypeLiteral>() { - }, new HashMap() {{ + }, new HashMap<>() {{ put("hello", obj1); }}); stream.close();