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

"generate build" falls with JSON parsing error #14

Open
snoopy-coder opened this issue Feb 22, 2020 · 1 comment
Open

"generate build" falls with JSON parsing error #14

snoopy-coder opened this issue Feb 22, 2020 · 1 comment

Comments

@snoopy-coder
Copy link

snoopy-coder commented Feb 22, 2020

Launching "generate build" falls with JSON parsing error:

C:\Temp\qemu-java-master>gradlew generate build
:qemu-qapi:compileGenerateJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:qemu-qapi:processGenerateResources
:qemu-qapi:generateClasses
:qemu-qapi:generate
Exception in thread "main" com.google.gson.JsonSyntaxException: Failed to parse {"enum":"BlockdevAioOptions","data":["threads","native",{"name":"io_uring","if":
"defined(CONFIG_LINUX_IO_URING)"}]}
        at org.anarres.qemu.qapi.generator.SchemaParser.parse(SchemaParser.java:118)
        at org.anarres.qemu.qapi.generator.Main.main(Main.java:43)
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:200)
        at com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:281)
        at org.anarres.qemu.qapi.generator.SchemaParser.parse(SchemaParser.java:116)
        ... 1 more
Caused by: java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT
        at com.google.gson.internal.bind.JsonTreeReader.nextString(JsonTreeReader.java:154)
        at com.google.gson.internal.bind.TypeAdapters$13.read(TypeAdapters.java:358)
        at com.google.gson.internal.bind.TypeAdapters$13.read(TypeAdapters.java:346)
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:81)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196)
        ... 3 more
:qemu-qapi:generate FAILED

FAILURE: Build failed with an exception.

If I am not mistaken, nested objects parsing is not supported yet?
Is it difficult to add this feature?
Thanks a lot.

@snoopy-coder
Copy link
Author

snoopy-coder commented Mar 4, 2020

A few days ago, the error message is slightly changed:

C:\Temp\qemu-java-master>gradlew generate build
:qemu-qapi:compileGenerateJava UP-TO-DATE
:qemu-qapi:processGenerateResources UP-TO-DATE
:qemu-qapi:generateClasses UP-TO-DATE
:qemu-qapi:generate
Exception in thread "main" com.google.gson.JsonSyntaxException: Failed to parse {"enum":"MultiFDCompression","data":["none","zlib",{"name":"zstd","if":"defined(
CONFIG_ZSTD)"}]}:qemu-qapi:generate
        at org.anarres.qemu.qapi.generator.SchemaParser.parse(SchemaParser.java:118)
        at org.anarres.qemu.qapi.generator.Main.main(Main.java:43)
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:200)
        at com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:281)
        at org.anarres.qemu.qapi.generator.SchemaParser.parse(SchemaParser.java:116)
        ... 1 more
Caused by: java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT
        at com.google.gson.internal.bind.JsonTreeReader.nextString(JsonTreeReader.java:154)
        at com.google.gson.internal.bind.TypeAdapters$13.read(TypeAdapters.java:358)
        at com.google.gson.internal.bind.TypeAdapters$13.read(TypeAdapters.java:346)
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:81)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196)
        ... 3 more
:qemu-qapi:generate FAILED

FAILURE: Build failed with an exception.

As I understand it, something like https://github.com/wnameless/json-flattener should be used when parsing. Can anybody help in implementation? I would be very grateful.

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

No branches or pull requests

1 participant