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] Android - NoSuchMethodError: No virtual method getBoolean(Ljava/lang/Object;J)Z in class Lsun/misc/Unsafe; #2497

Closed
xDragonZ opened this issue Apr 29, 2024 · 6 comments
Assignees
Labels
bug Something isn't working fixed
Milestone

Comments

@xDragonZ
Copy link

xDragonZ commented Apr 29, 2024

问题描述

https://github.com/alibaba/fastjson2/blob/main/core/src/main/java/com/alibaba/fastjson2/writer/FieldWriterBoolValField.java#L28

Caused by java.lang.NoSuchMethodError: No virtual method getBoolean(Ljava/lang/Object;J)Z in class Lsun/misc/Unsafe; or its super classes (declaration of 'sun.misc.Unsafe' appears in /system/framework/core-libart.jar)
       at com.alibaba.fastjson2.writer.FieldWriterBoolValField.getFieldValueBoolean(FieldWriterBoolValField.java:35)
       at com.alibaba.fastjson2.writer.FieldWriterBoolValField.getFieldValue(FieldWriterBoolValField.java:24)
       at com.alibaba.fastjson2.writer.FieldWriterBoolVal.write(FieldWriterBoolVal.java:29)
       at com.alibaba.fastjson2.writer.ObjectWriterAdapter.write(ObjectWriterAdapter.java:326)
       at com.alibaba.fastjson2.JSON.toJSONString(JSON.java:3076)

环境信息

com.alibaba.fastjson2:fastjson2:2.0.49.android5

com.android.application version "8.3.2"

Gradle 8.7

Android Studio Iguana | 2023.2.1 Patch 2
Runtime version: 17.0.9+0--11185874 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

minSdkVersion 21
targetSdkVersion 33

重现步骤

JSON.toJSONString(xxx, JSONWriter.Feature.FieldBased);

附加信息

Ref? : #2041

设备:

Oppo F1s, A57, A1601
Galaxy J1 Mini, Galaxy Note4, Galaxy J2 Prime
Vivo Y55A,
Xiaomi HM Note 2

VMOS Virtual Machine, Android 5.1 (64 Bit) 可以重现这个崩溃

image
@xDragonZ xDragonZ added the bug Something isn't working label Apr 29, 2024
@kraity
Copy link
Collaborator

kraity commented May 3, 2024

请问测试运行的Android系统版本是多少?

@wenshao wenshao added this to the 2.0.50 milestone May 3, 2024
@xDragonZ
Copy link
Author

xDragonZ commented May 3, 2024

请问测试运行的Android系统版本是多少?

主机 Android 10 跑 VMOS Android 5.1.1 (64 bit)

@wenshao
Copy link
Member

wenshao commented May 3, 2024

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.50.android5-SNAPSHOT/
问题已修复,请帮忙用2.0.50.android5-SNAPSHOT验证,2.0.50.android5预计在5月12日前发布

@wenshao wenshao added the fixed label May 3, 2024
@wenshao wenshao self-assigned this May 3, 2024
@kraity
Copy link
Collaborator

kraity commented May 3, 2024

请问测试运行的Android系统版本是多少?

主机 Android 10 跑 VMOS Android 5.1.1 (64 bit)

Android 7以下core-libart.jar中Unsafe魔法类不完整, 这边已发现并兼容, 麻烦使用上面温少发的快照版验收下.

@xDragonZ
Copy link
Author

xDragonZ commented May 3, 2024

测试了 2.0.50.android5-snapshot 没问题。谢谢 👍

@wenshao
Copy link
Member

wenshao commented May 12, 2024

https://github.com/alibaba/fastjson2/releases/tag/2.0.50
2.0.50已发布,请用新版本2.0.50.android5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

3 participants