kaitai-io / kaitai_struct

Kaitai Struct: declarative language to generate binary data parsers in C++ / C# / Go / Java / JavaScript / Lua / Nim / Perl / PHP / Python / Ruby
https://kaitai.io
4.04k stars 199 forks source link

Invalid Java code generated: Incompatible types: possible lossy conversion from int to byte #1097

Closed Gamebuster19901 closed 8 months ago

Gamebuster19901 commented 8 months ago

This is the compiler error:

2024-03-27T15:30:47.494-0400 [ERROR] [system.err] /home/gamebuster/Desktop/Modding/ExciteModder/build/generated/kaitai/src/com/gamebuster19901/excite/modding/kaitai/TocMonster.java:194: error: incompatible types: possible lossy conversion from int to byte
2024-03-27T15:30:47.494-0400 [ERROR] [system.err]             this.filename = new String(this._io.readBytesTerm(0, false, true, true), Charset.forName("utf-8"));
2024-03-27T15:30:47.494-0400 [ERROR] [system.err]                                                               ^

The generated .java file and the .ksy file are in TocMonster.zip

TocMonster.zip

generalmimon commented 8 months ago

I see that you're using kaitai-struct-compiler 0.8, i.e. a long outdated version from 2018 (check kaitai-struct-compiler --version). I strongly recommend using the latest KSC 0.10 (you can get it from https://github.com/kaitai-io/kaitai_struct_compiler/releases/tag/0.10, the download/installation instructions are here: https://kaitai.io/#download).

If (for some reason) you don't want to switch to KS 0.10, you can technically keep using the 0.8 compiler, but you also have to use the 0.8 version of the runtime library for Java (also published in the Maven Central repository). But keep in mind that this is not recommended and not supported, and at the very least you won't get any of the numerous bug fixes between 0.8 and 0.10.

Gamebuster19901 commented 8 months ago

Thank you, I will try that soon and see if that resolves the issue.

On Wed, Mar 27, 2024 at 4:48 PM Petr Pučil @.***> wrote:

I see that you're using kaitai-struct-compiler 0.8, i.e. a long outdated version from 2018 https://kaitai.io/news/2018/02/05/kaitai-struct-v0.8-released.html (check kaitai-struct-compiler --version). I strongly recommend using the latest KSC 0.10 (you can get it from https://github.com/kaitai-io/kaitai_struct_compiler/releases/tag/0.10, the download/installation instructions are here: https://kaitai.io/#download).

If (for some reason) you don't want to switch to KS 0.10, you can technically keep using the 0.8 compiler, but you also have to use the 0.8 version https://github.com/kaitai-io/kaitai_struct_java_runtime/tree/0.8 of the runtime library for Java (also published in the Maven Central repository https://central.sonatype.com/artifact/io.kaitai/kaitai-struct-runtime/0.8). But keep in mind that this is not recommended and not supported, and at the very least you won't get any of the numerous bug fixes between 0.8 and 0.10.

— Reply to this email directly, view it on GitHub https://github.com/kaitai-io/kaitai_struct/issues/1097#issuecomment-2023958444, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWTAIYJQ5TRGHNCTEOKLPDY2MPCBAVCNFSM6AAAAABFLRBAZ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRTHE2TQNBUGQ . You are receiving this because you authored the thread.Message ID: @.***>

Gamebuster19901 commented 8 months ago

I had to do some modifications to my buildscript to ensure the generated directory was cleared of old data every run, and so that the compiler would run for all gradle tasks, but I was able to get it done and it appears to compile fine.

https://github.com/TheGameCommunity/ExciteModder/commit/298711daad4c8ad254388a7d4dd5552976997b3b