diff --git a/pom.xml b/pom.xml
index 9d5cfb0b9c..018d2909ce 100755
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
com.alibaba
fastjson
- 1.2.55_preview_06
+ 1.2.56_preview_01
jar
fastjson
diff --git a/src/main/java/com/alibaba/fastjson/JSON.java b/src/main/java/com/alibaba/fastjson/JSON.java
index 6eda08486b..c72b336554 100755
--- a/src/main/java/com/alibaba/fastjson/JSON.java
+++ b/src/main/java/com/alibaba/fastjson/JSON.java
@@ -111,6 +111,12 @@ private static void config(Properties properties) {
DEFAULT_PARSER_FEATURE |= Feature.NonStringKeyAsString.getMask();
}
}
+
+ {
+ if ("true".equals(properties.getProperty("parser.features.ErrorOnEnumNotMatch"))) {
+ DEFAULT_PARSER_FEATURE |= Feature.ErrorOnEnumNotMatch.getMask();
+ }
+ }
}
/**
diff --git a/src/test/java/com/alibaba/json/bvt/issue_2200/Issue2206.java b/src/test/java/com/alibaba/json/bvt/issue_2200/Issue2206.java
index c6e8918770..b874aff994 100644
--- a/src/test/java/com/alibaba/json/bvt/issue_2200/Issue2206.java
+++ b/src/test/java/com/alibaba/json/bvt/issue_2200/Issue2206.java
@@ -1,7 +1,6 @@
package com.alibaba.json.bvt.issue_2200;
import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.parser.ParserConfig;
import junit.framework.TestCase;
import java.time.LocalDateTime;
diff --git a/src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumTest.java b/src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumTest.java
index e25f6d7ded..dc6faba320 100755
--- a/src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumTest.java
+++ b/src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumTest.java
@@ -24,4 +24,13 @@ public void test_enum() throws Exception {
Assert.assertEquals("'Small'", JSON.toJSONString(Type.Small, SerializerFeature.UseSingleQuotes)); // "Small"
}
+ public void test_empty() throws Exception {
+ Model model = JSON.parseObject("{\"type\":\"\"}", Model.class);
+ assertNull(model.type);
+ }
+
+ public static class Model {
+ public Type type;
+ }
+
}
diff --git a/src/test/java/com/alibaba/json/bvt/serializer/filters/ContextValueClassLevelTest.java b/src/test/java/com/alibaba/json/bvt/serializer/filters/ContextValueClassLevelTest.java
index 779ab0cb5e..1d0c43e27c 100644
--- a/src/test/java/com/alibaba/json/bvt/serializer/filters/ContextValueClassLevelTest.java
+++ b/src/test/java/com/alibaba/json/bvt/serializer/filters/ContextValueClassLevelTest.java
@@ -19,7 +19,6 @@ public void test_0() throws Exception {
config.addFilter(ModelA.class, //
new ContextValueFilter() {
- @Override
public Object process(BeanContext context, Object object, String name, Object value) {
return 30001;
}
@@ -27,7 +26,6 @@ public Object process(BeanContext context, Object object, String name, Object va
config.addFilter(ModelB.class, //
new ContextValueFilter() {
- @Override
public Object process(BeanContext context, Object object, String name, Object value) {
return 20001;
}
diff --git a/src/test/java/com/alibaba/json/bvt/util/UTF8DecoderTest.java b/src/test/java/com/alibaba/json/bvt/util/UTF8DecoderTest.java
index b93fdeff8a..1cbec232bc 100644
--- a/src/test/java/com/alibaba/json/bvt/util/UTF8DecoderTest.java
+++ b/src/test/java/com/alibaba/json/bvt/util/UTF8DecoderTest.java
@@ -137,4 +137,29 @@ public void test_4() throws Exception {
}
}
+
+ /**
+ * @deprecated
+ */
+ public void test_5() throws Exception {
+ UTF8Decoder decoder = new UTF8Decoder();
+
+ String str = "⌛︎€\uD83D\uDC69\uD83D\uDC68\uD83D\uDC68\uD83C\uDFFB\uD83D\uDC69\uD83C\uDFFFU+1F9D2: Child\tText\t\uD83E\uDDD2\t\uD83E\uDDD2\uD83C\uDFFB\t\uD83E\uDDD2\uD83C\uDFFC\t\uD83E\uDDD2\uD83C\uDFFD\t\uD83E\uDDD2\uD83C\uDFFE\t\uD83E\uDDD2\uD83C\uDFFF\n\uD83E\uDDD1\uD83C\uDFFF\uD83C\uDE1A️\uD83C\uDC04️❤️";
+ byte[] bytes =str.getBytes("UTF-8");
+ ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
+ decoder.decode(byteBuffer);
+ }
+
+ /**
+ * @deprecated
+ */
+ public void test_6() throws Exception {
+ UTF8Decoder decoder = new UTF8Decoder();
+
+ String str = "\u20AC";
+ byte[] bytes =str.getBytes("UTF-8");
+ ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
+ decoder.decode(byteBuffer);
+ }
+
}
diff --git a/src/test/java/com/alibaba/json/test/A1.java b/src/test/java/com/alibaba/json/test/A1.java
index 9a72d58e3e..49229522af 100644
--- a/src/test/java/com/alibaba/json/test/A1.java
+++ b/src/test/java/com/alibaba/json/test/A1.java
@@ -1,9 +1,16 @@
package com.alibaba.json.test;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.alibaba.fastjson.util.IOUtils;
import junit.framework.TestCase;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
/**
* Created by wenshao on 14/03/2017.
*/
@@ -13,5 +20,29 @@ public void test_a() throws Exception {
Object obj = JSON.parse("[{\"feature\":\"\\u3A56\\u3A26\"}]");
String json = JSON.toJSONString(obj, SerializerFeature.BrowserCompatible);
System.out.println(json);
+
+
+ }
+
+
+ public void test_ser() throws Exception {
+// JSONObject obj = new JSONObject();
+//
+// ByteArrayOutputStream out = new ByteArrayOutputStream();
+// ObjectOutputStream objOut = new ObjectOutputStream(out);
+// objOut.writeObject(obj);
+// objOut.flush();
+// objOut.close();
+// byte[] bytes = out.toByteArray();
+//
+// String str = Base64.encodeToString(bytes, false);
+// System.out.println(str);
+
+ byte[] bytes2 = IOUtils.decodeBase64("rO0ABXNyAB9jb20uYWxpYmFiYS5mYXN0anNvbi5KU09OT2JqZWN0AAAAAAAAAAECAAFMAANtYXB0AA9MamF2YS91dGlsL01hcDt4cHNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAABB3CAAAABAAAAAAeA==");
+ ByteArrayInputStream byteIn = new ByteArrayInputStream(bytes2);
+ ObjectInputStream objIn = new ObjectInputStream(byteIn);
+ Object obj = objIn.readObject();
+ assertEquals(JSONObject.class, obj.getClass());
+
}
}
diff --git a/src/test/java/com/alibaba/json/test/Base64.java b/src/test/java/com/alibaba/json/test/Base64.java
index 70ce078c30..2b11b5fdea 100755
--- a/src/test/java/com/alibaba/json/test/Base64.java
+++ b/src/test/java/com/alibaba/json/test/Base64.java
@@ -86,56 +86,56 @@ public class Base64
// ****************************************************************************************
/** Encodes a raw byte array into a BASE64 char[]
representation i accordance with RFC 2045.
- * @param sArr The bytes to convert. If null
or length 0 an empty array will be returned.
+ * @param bytes The bytes to convert. If null
or length 0 an empty array will be returned.
* @param lineSep Optional "\r\n" after 76 characters, unless end of file.
* No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a
* little faster.
* @return A BASE64 encoded array. Never null
.
*/
- public final static char[] encodeToChar(byte[] sArr, boolean lineSep)
+ public final static char[] encodeToChar(byte[] bytes, boolean lineSep)
{
// Check special case
- int sLen = sArr != null ? sArr.length : 0;
- if (sLen == 0)
+ int bytes_len = bytes != null ? bytes.length : 0;
+ if (bytes_len == 0)
return new char[0];
- int eLen = (sLen / 3) * 3; // Length of even 24-bits.
- int cCnt = ((sLen - 1) / 3 + 1) << 2; // Returned character count
- int dLen = cCnt + (lineSep ? (cCnt - 1) / 76 << 1 : 0); // Length of returned array
- char[] dArr = new char[dLen];
+ int eLen = (bytes_len / 3) * 3; // Length of even 24-bits.
+ int cCnt = ((bytes_len - 1) / 3 + 1) << 2; // Returned character count
+ int chars_len = cCnt + (lineSep ? (cCnt - 1) / 76 << 1 : 0); // Length of returned array
+ char[] chars = new char[chars_len];
// Encode even 24-bits
for (int s = 0, d = 0, cc = 0; s < eLen;) {
// Copy next three bytes into lower 24 bits of int, paying attension to sign.
- int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff);
+ int i = (bytes[s++] & 0xff) << 16 | (bytes[s++] & 0xff) << 8 | (bytes[s++] & 0xff);
// Encode the int into four chars
- dArr[d++] = CA[(i >>> 18) & 0x3f];
- dArr[d++] = CA[(i >>> 12) & 0x3f];
- dArr[d++] = CA[(i >>> 6) & 0x3f];
- dArr[d++] = CA[i & 0x3f];
+ chars[d++] = CA[(i >>> 18) & 0x3f];
+ chars[d++] = CA[(i >>> 12) & 0x3f];
+ chars[d++] = CA[(i >>> 6) & 0x3f];
+ chars[d++] = CA[i & 0x3f];
// Add optional line separator
- if (lineSep && ++cc == 19 && d < dLen - 2) {
- dArr[d++] = '\r';
- dArr[d++] = '\n';
+ if (lineSep && ++cc == 19 && d < chars_len - 2) {
+ chars[d++] = '\r';
+ chars[d++] = '\n';
cc = 0;
}
}
// Pad and encode last bits if source isn't even 24 bits.
- int left = sLen - eLen; // 0 - 2.
+ int left = bytes_len - eLen; // 0 - 2.
if (left > 0) {
// Prepare the int
- int i = ((sArr[eLen] & 0xff) << 10) | (left == 2 ? ((sArr[sLen - 1] & 0xff) << 2) : 0);
+ int i = ((bytes[eLen] & 0xff) << 10) | (left == 2 ? ((bytes[bytes_len - 1] & 0xff) << 2) : 0);
// Set last four chars
- dArr[dLen - 4] = CA[i >> 12];
- dArr[dLen - 3] = CA[(i >>> 6) & 0x3f];
- dArr[dLen - 2] = left == 2 ? CA[i & 0x3f] : '=';
- dArr[dLen - 1] = '=';
+ chars[chars_len - 4] = CA[i >> 12];
+ chars[chars_len - 3] = CA[(i >>> 6) & 0x3f];
+ chars[chars_len - 2] = left == 2 ? CA[i & 0x3f] : '=';
+ chars[chars_len - 1] = '=';
}
- return dArr;
+ return chars;
}
/** Decodes a BASE64 encoded char array. All illegal characters will be ignored and can handle both arrays with
@@ -517,7 +517,7 @@ public final static byte[] decode(String str)
* @param s The source string. Length 0 will return an empty array. null
will throw an exception.
* @return The decoded array of bytes. May be of length 0.
*/
- public final static byte[] decodeFast(String s)
+ public final static byte[] dedecodeFast(String s)
{
// Check special case
int sLen = s.length();
diff --git a/src/test/java/com/alibaba/json/test/UTF8Test.java b/src/test/java/com/alibaba/json/test/UTF8Test.java
index d1611cbdf3..f20ce80ce1 100644
--- a/src/test/java/com/alibaba/json/test/UTF8Test.java
+++ b/src/test/java/com/alibaba/json/test/UTF8Test.java
@@ -32,20 +32,22 @@ protected void setUp() throws Exception {
public void test_encode() throws Exception {
- for (int i = 0; i < 5; ++i) {
- f0();
- }
+// for (int i = 0; i < 5; ++i) {
+// f0();
+// }
for (int i = 0; i < 5; ++i) {
f1();
}
- for (int i = 0; i < 5; ++i) {
- f2();
- }
+// for (int i = 0; i < 5; ++i) {
+// f2();
+// }
}
+ final static int COUNT = 1000 * 1000 * 5;
+
private void f0() throws Exception {
long start = System.currentTimeMillis();
- for (int i = 0; i < 1000 * 1000; ++i) {
+ for (int i = 0; i < COUNT; ++i) {
text.getBytes(charset);
}
long millis = System.currentTimeMillis() - start;
@@ -54,7 +56,7 @@ private void f0() throws Exception {
private void f1() throws Exception {
long start = System.currentTimeMillis();
- for (int i = 0; i < 1000 * 1000; ++i) {
+ for (int i = 0; i < COUNT; ++i) {
IOUtils.encodeUTF8(chars, 0, chars.length, bytes);
}
long millis = System.currentTimeMillis() - start;
@@ -63,7 +65,7 @@ private void f1() throws Exception {
private void f2() throws Exception {
long start = System.currentTimeMillis();
- for (int i = 0; i < 1000 * 1000; ++i) {
+ for (int i = 0; i < COUNT; ++i) {
charset.newEncoder().encode(CharBuffer.wrap(chars));
}
long millis = System.currentTimeMillis() - start;
diff --git a/src/test/java/com/alibaba/json/test/UTF8Test_decode.java b/src/test/java/com/alibaba/json/test/UTF8Test_decode.java
index 4419790387..f352ba6267 100644
--- a/src/test/java/com/alibaba/json/test/UTF8Test_decode.java
+++ b/src/test/java/com/alibaba/json/test/UTF8Test_decode.java
@@ -37,8 +37,8 @@ public void test_encode() throws Exception {
for (int i = 0; i < 10; ++i) {
long start = System.currentTimeMillis();
-// f0(); // 764
- f1(); // 695
+ f0(); // 764
+// f1(); // 695
// f2(); // 975
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
diff --git a/src/test/java/com/alibaba/json/test/benchmark/BenchmarkMain.java b/src/test/java/com/alibaba/json/test/benchmark/BenchmarkMain.java
index c1f745bfce..7a6d71b72b 100755
--- a/src/test/java/com/alibaba/json/test/benchmark/BenchmarkMain.java
+++ b/src/test/java/com/alibaba/json/test/benchmark/BenchmarkMain.java
@@ -29,10 +29,14 @@ public static void main(String[] args) throws Exception {
// executor.getCaseList().add(new EishayDecodeBytes());
// executor.getCaseList().add(new EishayEncodeOutputStream());
// executor.getCaseList().add(new EishayEncodeToBytes());
-// executor.getCaseList().add(new EishayDecode());
+ executor.getCaseList().add(new EishayDecode()); // 1069
+ //JDK8_162 1094
+ //JDK9_01 1214
+ //JDK9_04 1252
+ //JDK10 1088
// executor.getCaseList().add(new EishayDecodeByClassName());
// executor.getCaseList().add(new EishayTreeDecode());
- executor.getCaseList().add(new EishayEncode());
+// executor.getCaseList().add(new EishayEncode());
// executor.getCaseList().add(new EishayEncodeManual());
// executor.getCaseList().add(new IntArray1000Decode());
// executor.getCaseList().add(new StringArray1000Decode());
diff --git a/src/test/java/com/alibaba/json/test/benchmark/JSONPathBenchmarkTest.java b/src/test/java/com/alibaba/json/test/benchmark/JSONPathBenchmarkTest.java
index 8e998e9f02..773b8621e6 100644
--- a/src/test/java/com/alibaba/json/test/benchmark/JSONPathBenchmarkTest.java
+++ b/src/test/java/com/alibaba/json/test/benchmark/JSONPathBenchmarkTest.java
@@ -8,10 +8,10 @@ public class JSONPathBenchmarkTest {
public static void main(String[] args) throws Exception {
for (int i = 0; i < 5; ++i) {
- f0();
+ f0(); // 390 353
}
for (int i = 0; i < 5; ++i) {
- f1();
+// f1();
}
}
diff --git a/src/test/java/com/alibaba/json/test/benchmark/basic/IntBenchmark.java b/src/test/java/com/alibaba/json/test/benchmark/basic/IntBenchmark.java
index 6dd5b48d59..acea490feb 100644
--- a/src/test/java/com/alibaba/json/test/benchmark/basic/IntBenchmark.java
+++ b/src/test/java/com/alibaba/json/test/benchmark/basic/IntBenchmark.java
@@ -19,6 +19,7 @@ public class IntBenchmark {
"}";
public static void main(String[] args) throws Exception {
+ System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
// Model model = new Model();
// model.v1 = new Random().nextInt();
// model.v2 = new Random().nextInt();
@@ -30,9 +31,9 @@ public static void main(String[] args) throws Exception {
for (int i = 0; i < 10; ++i) {
-// perf(); // 1798
+ perf(); // 1798
// perf2(); // 1877
- perf3(); // 20624 2334
+// perf3(); // 20624 2334
}
}
diff --git a/src/test/java/com/alibaba/json/test/benchmark/jdk10/StringBenchmark_jackson.java b/src/test/java/com/alibaba/json/test/benchmark/jdk10/StringBenchmark_jackson.java
index 8e5a96e222..4de26b3d59 100644
--- a/src/test/java/com/alibaba/json/test/benchmark/jdk10/StringBenchmark_jackson.java
+++ b/src/test/java/com/alibaba/json/test/benchmark/jdk10/StringBenchmark_jackson.java
@@ -1,47 +1,57 @@
package com.alibaba.json.test.benchmark.jdk10;
import com.alibaba.fastjson.JSON;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.openjdk.jmh.annotations.*;
+import java.io.IOException;
import java.util.HashMap;
@Warmup(iterations = 10)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class StringBenchmark_jackson {
-
+ static ObjectMapper mapper = new ObjectMapper();
static private String s = "{\"compress\":true,\"queryParams\":\"^^$$Z29e389d72fca43e2591dfa6d5bd182039|null{$_$}H4sIAAAAAAAAAK1YW2/kthX+K4GeGsCdkpRIit6XztrehVHf4ssmabwYUCRlay2Jii72ThcD9L3IY5/7NwL076To3+ghJc1obDd2g754R0fnfvnO0X4J0loW5sHWd2cSfjWHRZUHu1+CKpdtauviclkZ96xy2TQnwBrsBsoWM5lniUzkrK2lNjOVZ6ZsZ4XVJp81tquVmZ1NNH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n/g2iNh8JBg8AAA==\",\"validateParams\":\"^^$$5da126afd2e7ebcf402eecea37f8e6df{$_$}H4sIAAAAAAAAAIVRTWsCMRT8LzlLcNePVW9ZG4ogItpaepJn9qmL2WRJIq0VoffSY8/9G4X+HUv/Rt9WSr2U3ibzXmaGeXu2dFDgnXWbMRDyg6LUrLdnpYawtK642pVYvZUG70e0ynpM2YKDzhewAB4cZMiVztEEXtgMNfd26xTy8ZnCLGY1Zk6/bwYTOZTT6bwxrxNrXZYbIM/4UGMlrPAvxwB2AZYTLK2p3LIdKeaKFxjgjK6QxnueXt/GfPwjeNImqRUadORXYxl6RcTn++vx7fH49vTx/EJsAW6DgfjfxJdyJCdieB42obDaKtDV/GE9748YMVuPTnifr8z/lfk1OMx46dBTagi5NbysTsAvIMCMlrPvi5yqQ8z6a1SbPjXMekvQHmsMjXK7MkyDy82KTLrtSLRF0ql32qLRkEIK0WzFUookitMo7cq006wnddGKREd22y12OHwB3aDYjQACAAA=\"}";
- static private DO d_o = JSON.parseObject(s, DO.class);
+ static private DO d_o;
static private Object o;
static private int i;
static private HashMap methodMap = new HashMap();
+ static {
+ try {
+ d_o = mapper.readValue(s, DO.class);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
@Setup
public void prepare() {
- methodMap.put("org.openjdk.jmh.annotations.org.openjdk.jmh.annotations.StringBenchmark.prepare(aaa,bbb,com.alibaba.fastjson.JSON)", "");
+ methodMap.put("org.openjdk.jmh.annotations.org.openjdk.jmh.annotations.StringBenchmark.prepare(aaa,bbb,com.fasterxml.jackson.databind.ObjectMapper)", "");
}
@Benchmark
@Fork(value = 3, jvmArgs = "-XX:+CompactStrings")
- public void testParseJsonComp() {
- o = JSON.parseObject(s, DO.class);
+ public void testParseJsonComp() throws Exception {
+ o = mapper.readValue(s, DO.class);
}
@Benchmark
@Fork(value = 3, jvmArgs = "-XX:-CompactStrings")
- public void testParseJson() {
- o = JSON.parseObject(s, DO.class);
+ public void testParseJson() throws Exception {
+ o = mapper.readValue(s, DO.class);
}
// @Benchmark
@Fork(value = 3, jvmArgs = "-XX:+CompactStrings")
- public void testToJsonComp() {
+ public void testToJsonComp() throws Exception {
o = JSON.toJSON(d_o);
}
// @Benchmark
@Fork(value = 3, jvmArgs = "-XX:-CompactStrings")
- public void testToJson() {
+ public void testToJson() throws Exception {
o = JSON.toJSON(d_o);
}
@@ -75,7 +85,7 @@ private Object testFindMethod0() {
sb.append("org.openjdk.jmh.annotations.org.openjdk.jmh.annotations.StringBenchmark")
.append(".").append("prepare").append("(")
.append("aaa").append(",").append("bbb").append(",")
- .append("com.alibaba.fastjson.JSON").append(")");
+ .append("com.fasterxml.jackson.databind.ObjectMapper").append(")");
return methodMap.get(sb.toString());
}