Skip to content

Commit 547e368

Browse files
committed
Merge branch 'master' of https://github.com/alibaba/fastjson
2 parents 9c35748 + 2774ecb commit 547e368

File tree

92 files changed

+3327
-3458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+3327
-3458
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@
308308
<version>2.1.5</version>
309309
<scope>test</scope>
310310
</dependency>
311+
312+
<dependency>
313+
<groupId>org.springframework</groupId>
314+
<artifactId>spring-test</artifactId>
315+
<version>3.1.1.RELEASE</version>
316+
<scope>test</scope>
317+
</dependency>
311318
</dependencies>
312319
</project>
313320

src/main/java/com/alibaba/fastjson/JSONObject.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343

4444
import com.alibaba.fastjson.annotation.JSONField;
4545
import com.alibaba.fastjson.parser.ParserConfig;
46-
import com.alibaba.fastjson.util.AntiCollisionHashMap;
4746
import com.alibaba.fastjson.util.TypeUtils;
4847

4948
/**
@@ -76,7 +75,7 @@ public JSONObject(int initialCapacity, boolean ordered){
7675
if (ordered) {
7776
map = new LinkedHashMap<String, Object>(initialCapacity);
7877
} else {
79-
map = new AntiCollisionHashMap<String, Object>(initialCapacity);
78+
map = new HashMap<String, Object>(initialCapacity);
8079
}
8180
}
8281

src/main/java/com/alibaba/fastjson/JSONReader.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
package com.alibaba.fastjson;
22

3+
import static com.alibaba.fastjson.JSONStreamContext.ArrayValue;
4+
import static com.alibaba.fastjson.JSONStreamContext.PropertyKey;
5+
import static com.alibaba.fastjson.JSONStreamContext.PropertyValue;
6+
import static com.alibaba.fastjson.JSONStreamContext.StartArray;
7+
import static com.alibaba.fastjson.JSONStreamContext.StartObject;
8+
39
import java.io.Closeable;
410
import java.io.Reader;
511
import java.lang.reflect.Type;
612
import java.util.Map;
713

8-
import static com.alibaba.fastjson.JSONStreamContext.*;
914
import com.alibaba.fastjson.parser.DefaultJSONParser;
1015
import com.alibaba.fastjson.parser.Feature;
1116
import com.alibaba.fastjson.parser.JSONLexer;
1217
import com.alibaba.fastjson.parser.JSONReaderScanner;
1318
import com.alibaba.fastjson.parser.JSONToken;
19+
import com.alibaba.fastjson.util.IOUtils;
1420
import com.alibaba.fastjson.util.TypeUtils;
1521

1622
public class JSONReader implements Closeable {
@@ -19,7 +25,7 @@ public class JSONReader implements Closeable {
1925
private JSONStreamContext context;
2026

2127
public JSONReader(Reader reader){
22-
this(new DefaultJSONParser(new JSONReaderScanner(reader)));
28+
this(new JSONReaderScanner(reader));
2329
}
2430

2531
public JSONReader(JSONLexer lexer){
@@ -67,11 +73,12 @@ public void endArray() {
6773
}
6874

6975
private void startStructure() {
70-
int state = context.getState();
76+
final int state = context.getState();
7177
switch (state) {
7278
case PropertyKey:
7379
parser.accept(JSONToken.COLON);
7480
break;
81+
case PropertyValue:
7582
case ArrayValue:
7683
parser.accept(JSONToken.COMMA);
7784
break;
@@ -98,6 +105,10 @@ private void endStructure() {
98105
case StartArray:
99106
newState = ArrayValue;
100107
break;
108+
case PropertyValue:
109+
case StartObject:
110+
newState = PropertyKey;
111+
break;
101112
default:
102113
break;
103114
}
@@ -127,7 +138,7 @@ public boolean hasNext() {
127138
}
128139

129140
public void close() {
130-
parser.close();
141+
IOUtils.close(parser);
131142
}
132143

133144
public Integer readInteger() {

src/main/java/com/alibaba/fastjson/asm/Item.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ boolean isEqualTo(final Item i) {
174174
case ClassWriter.INT:
175175
case ClassWriter.FLOAT:
176176
return i.intVal == intVal;
177-
case ClassWriter.TYPE_UNINIT:
178-
return i.intVal == intVal && i.strVal1.equals(strVal1);
179177
case ClassWriter.NAME_TYPE:
180178
return i.strVal1.equals(strVal1) && i.strVal2.equals(strVal2);
181179
// case ClassWriter.FIELD:

src/main/java/com/alibaba/fastjson/asm/Label.java

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -212,35 +212,10 @@ boolean resolve(final MethodWriter owner, final int position, final byte[] data)
212212
while (i < referenceCount) {
213213
int source = srcAndRefPositions[i++];
214214
int reference = srcAndRefPositions[i++];
215-
int offset;
216-
if (source >= 0) {
217-
offset = position - source;
218-
if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) {
219-
/*
220-
* changes the opcode of the jump instruction, in order to be able to find it later (see
221-
* resizeInstructions in MethodWriter). These temporary opcodes are similar to jump instruction
222-
* opcodes, except that the 2 bytes offset is unsigned (and can therefore represent values from 0 to
223-
* 65535, which is sufficient since the size of a method is limited to 65535 bytes).
224-
*/
225-
int opcode = data[reference - 1] & 0xFF;
226-
if (opcode <= Opcodes.JSR) {
227-
// changes IFEQ ... JSR to opcodes 202 to 217
228-
data[reference - 1] = (byte) (opcode + 49);
229-
} else {
230-
// changes IFNULL and IFNONNULL to opcodes 218 and 219
231-
data[reference - 1] = (byte) (opcode + 20);
232-
}
233-
needUpdate = true;
234-
}
235-
data[reference++] = (byte) (offset >>> 8);
236-
data[reference] = (byte) offset;
237-
} else {
238-
offset = position + source + 1;
239-
data[reference++] = (byte) (offset >>> 24);
240-
data[reference++] = (byte) (offset >>> 16);
241-
data[reference++] = (byte) (offset >>> 8);
242-
data[reference] = (byte) offset;
243-
}
215+
int offset = position - source;
216+
data[reference++] = (byte) (offset >>> 8);
217+
data[reference] = (byte) offset;
218+
244219
}
245220
return needUpdate;
246221
}

src/main/java/com/alibaba/fastjson/parser/CharTypes.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -121,27 +121,4 @@ public static boolean isSpecial_doubleQuotes(char ch) {
121121
'1', 'C', '1', 'D', '1', 'E', '1', 'F', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2',
122122
'6', '2', '7', '2', '8', '2', '9', '2', 'A', '2', 'B', '2', 'C', '2', 'D', '2', 'E', '2', 'F', };
123123

124-
public final static boolean isEmoji(char ch) {
125-
if (ch >= '\uE001' && ch <= '\uE05A') {
126-
return true;
127-
}
128-
129-
if (ch >= '\uE101' && ch <= '\uE15A') {
130-
return true;
131-
}
132-
133-
if (ch >= '\uE201' && ch <= '\uE253') {
134-
return true;
135-
}
136-
137-
if (ch >= '\uE401' && ch <= '\uE44C') {
138-
return true;
139-
}
140-
141-
if (ch >= '\uE501' && ch <= '\uE537') {
142-
return true;
143-
}
144-
145-
return false;
146-
}
147124
}

src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public final Object parseObject(final Map object, Object fieldName) {
392392
if (lexer.token() == JSONToken.LITERAL_INT) {
393393
value = lexer.integerValue();
394394
} else {
395-
value = lexer.decimalValue();
395+
value = lexer.numberValue();
396396
}
397397

398398
object.put(key, value);

0 commit comments

Comments
 (0)