Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

1.2.71版本,在JDK1.7下运行JSON.parseObject时,报错java.lang.ClassNotFoundException: java.time.LocalDateTime #3280

Closed
eksgem opened this issue Jun 18, 2020 · 3 comments
Assignees
Labels
Milestone

Comments

@eksgem
Copy link

eksgem commented Jun 18, 2020

你好:
在1.2.71版本下,使用如下方法测试可以复现。JDK版本1.7.
public class DbInfoTest {
public static void main(String[] args) throws Exception {
String json = "{"test":"test"}";
Test t = JSON.parseObject(json,Test.class);
System.out.println(t.test);
}
}
public class Test {
public String test;
}
报错信息:
Exception in thread "main" java.lang.NoClassDefFoundError: java/time/LocalDateTime
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
at java.lang.Class.getConstructor0(Class.java:2895)
at java.lang.Class.getConstructor(Class.java:1731)
at com.alibaba.fastjson.parser.deserializer.ASMDeserializerFactory.createJavaBeanDeserializer(ASMDeserializerFactory.java:90)
at com.alibaba.fastjson.parser.ParserConfig.createJavaBeanDeserializer(ParserConfig.java:1075)
at com.alibaba.fastjson.parser.ParserConfig.getDeserializer(ParserConfig.java:882)
at com.alibaba.fastjson.parser.ParserConfig.getDeserializer(ParserConfig.java:592)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:679)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:396)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:300)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:573)
at com.rkhd.ienterprise.dbinfo.DbInfoTest.main(DbInfoTest.java:11)
Caused by: java.lang.ClassNotFoundException: java.time.LocalDateTime
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 13 more

@eksgem
Copy link
Author

eksgem commented Jun 18, 2020

如果注释掉JavaBeanDeserializer的1460行value = TypeUtils.castToLocalDateTime(value, format);则可以正常运行。
else if (format != null && (paramType instanceof Class) && (((Class) paramType).getName().equals("java.time.LocalDateTime"))) {
value = TypeUtils.castToLocalDateTime(value, format);
}

@eksgem eksgem changed the title 1.2.71版本在JSON.parseObject时,报错java.lang.ClassNotFoundException: java.time.LocalDateTime 1.2.71版本,在JDK1.7下运行JSON.parseObject时,报错java.lang.ClassNotFoundException: java.time.LocalDateTime Jun 18, 2020
@zhoufanshou
Copy link

确实有这个bug存在,还是回退到1.2.70

@wenshao wenshao added this to the 1.2.72 milestone Jun 18, 2020
@wenshao wenshao self-assigned this Jun 18, 2020
@wenshao wenshao added the bug label Jun 18, 2020
@wenshao
Copy link
Member

wenshao commented Jun 27, 2020

https://github.com/alibaba/fastjson/releases/tag/1.2.72
问题已修复,请用新版本

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants