Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix for graal support #121

Merged
merged 1 commit into from
May 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions core/src/main/java/com/alibaba/fastjson2/JSONReaderStr.java
Original file line number Diff line number Diff line change
Expand Up @@ -3146,6 +3146,8 @@ protected ZonedDateTime readZonedDateTimeX(int len) {

char first = str.charAt(this.offset + zoneIdBegin);

LocalDateTime ldt = getLocalDateTime(y0, y1, y2, y3, m0, m1, d0, d1, h0, h1, i0, i1, s0, s1, S0, S1, S2, S3, S4, S5, S6, S7, S8);

ZoneId zoneId;
if (isTimeZone) {
String tzStr = this.str.substring(this.offset + zoneIdBegin, this.offset + len);
Expand All @@ -3162,29 +3164,19 @@ protected ZonedDateTime readZonedDateTimeX(int len) {
;
// zoneIdStr = new String(chars, this.offset + zoneIdBegin, len - zoneIdBegin);
} else if (first == ' ') {
zoneIdStr = this.str.substring(this.offset + zoneIdBegin + 1, this.offset + len - 1);
zoneIdStr = this.str.substring(this.offset + zoneIdBegin + 1, this.offset + len);
} else { // '[
if (zoneIdBegin < len) {
zoneIdStr = this.str.substring(this.offset + zoneIdBegin + 1, this.offset + len - 1);
} else {
zoneIdStr = null;
}
}
if (zoneIdStr != null) {
if (zoneIdStr.equals("000")) {
zoneId = UTC;
} else if (zoneIdStr.equals("+08:00[Asia/Shanghai]") || zoneIdStr.equals("Asia/Shanghai")) {
zoneId = SHANGHAI;
} else {
zoneId = ZoneId.of(zoneIdStr);
}
} else {
zoneId = context.getZoneId();
}
zoneId = getZoneId(ldt, zoneIdStr);
}
}

ZonedDateTime zdt = getZonedDateTime(y0, y1, y2, y3, m0, m1, d0, d1, h0, h1, i0, i1, s0, s1, S0, S1, S2, S3, S4, S5, S6, S7, S8, zoneId);
ZonedDateTime zdt = ldt.atZone(zoneId);
if (zdt == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void readFieldValue(JSONReader jsonReader, T object) {
JSONReader.Context ctx = context;
ObjectReader itemObjectReader = getItemObjectReader(ctx);

List list = createList();
Collection list = (Collection) this.fieldObjectReader.createInstance(jsonReader.getContext().getFeatures() | features);
jsonReader.next();
for (; ; ) {
if (jsonReader.nextIfMatch(']')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ public T readObject(JSONReader jsonReader, long features) {
}

long nameHashCodeLCase = jsonReader.getNameHashCodeLCase();
if (nameHashCodeLCase == hashCode0) {
if (nameHashCodeLCase == hashCode0LCase) {
fieldReader0.readFieldValue(jsonReader, object);
} else if (nameHashCodeLCase == hashCode1) {
} else if (nameHashCodeLCase == hashCode1LCase) {
fieldReader1.readFieldValue(jsonReader, object);
} else if (nameHashCodeLCase == hashCode2) {
} else if (nameHashCodeLCase == hashCode2LCase) {
fieldReader2.readFieldValue(jsonReader, object);
} else {
jsonReader.skipValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ public void getFieldInfo(FieldInfo fieldInfo, Class objectType, Field field) {
jsonFieldFormat = jsonFieldFormat.replaceAll("T", "'T'");
}

fieldInfo.format = jsonFieldFormat;
if (!jsonFieldFormat.isEmpty()) {
fieldInfo.format = jsonFieldFormat;
}
}

if (!fieldInfo.ignore) {
Expand Down Expand Up @@ -272,7 +274,9 @@ private void processJSONField1x(FieldInfo fieldInfo, Annotation annotation) {
format = format.replaceAll("T", "'T'");
}

fieldInfo.format = format;
if (!format.isEmpty()) {
fieldInfo.format = format;
}
}
break;
}
Expand Down Expand Up @@ -414,7 +418,9 @@ public void getFieldInfo(FieldInfo fieldInfo, Class objectClass, Method method)
jsonFieldFormat = jsonFieldFormat.replaceAll("T", "'T'");
}

fieldInfo.format = jsonFieldFormat;
if (!jsonFieldFormat.isEmpty()) {
fieldInfo.format = jsonFieldFormat;
}
}

if (!fieldInfo.ignore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ public void test_codec_asm() {
V0 v = new V0();
v.setValue(new Date());

SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(true);

String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
String text = JSON.toJSONString(v, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"value\":" + v.getValue().getTime() + "}", text);
}

Expand Down