-
Notifications
You must be signed in to change notification settings - Fork 194
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
Unknown values for enums that are used in switch-on cases leads to NPE in Java #300
Comments
Good catch, thanks! We totally need a test for that. |
Probably we really need to do something to unify behavior of enums in various languages. This example shows why it is important. |
Yeah, that's a java specific stuff. |
Actually, the situation is even more dire with Python: trying to access an unknown enum value results in runtime exception there. |
So for python we need the compiler to use a custom enum class catching such exceptions. |
I re-up this topic. Today's only solution is to handle the execption viaa try: execpt: solution on the .py generated file. |
I re-up it as well: I have files where I need to parse the structures I know, but it is impossible for me to know in advance all possible |
Trying to use an enum causes unavoidable parse errors in Java and Python when new/unknown FourCC values are encountered. See kaitai-io/kaitai_struct#300
@Aladarion and @brunchboy: would it help if you added a default case ( |
No, Java can’t handle |
Two tests created to demonstrate the problem:
Ruby spec for it passes, Java spec demonstrates NPE as of now. Next stop: delivering Java fix. |
Crude, but working fix is done. Actually, this opened a big can of worms:
|
I've created #568 as a reminder that the deeper problem still exists. Given that:
... it's unlikely that it will be fixed soon. |
Is this fix available in a released version of KSC? |
I should have been more specific in my question, I meant released as a Maven artifact, and it appears the answer is “no,” the latest version out there is 0.8 released well before this change. Is there any hope of getting this released, and incorporated into the KSC maven plugin? It would make my mapping files for interacting with Pioneer DJ equipment so much nicer. |
Issue kaitai-io/kaitai_struct#300 is resolved.
I have a field that is defined as an enum and the second field that in uses this enum in switch-on case:
For these case, I have to define all the possible values for enum, even if I care only about two values, otherwise I will get NPE in Java as the field
type
isnull
and this field is used in Javaswitch
statement.The expected behavior for me is to get
generic_type
if thetype
field will be oftype3
.The text was updated successfully, but these errors were encountered: