Skip to content

Use child class for parsing will throw java.lang.IllegalStateException: There is not any opened struct #42

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

Closed
shute001 opened this issue Jun 29, 2023 · 4 comments
Assignees
Labels

Comments

@shute001
Copy link

When I use a child class for parsing will throw java.lang.IllegalStateException: There is not any opened struct. Below are my test code.
@bin
@Getter
@Setter
public class Parent {
@bin(order = 1, type = BinType.USHORT, comment = "Size of package header")
int headerSize;
}

@bin
@Getter
@Setter
public class Child extends Parent {
@bin(order = 2, type = BinType.BYTE_ARRAY, arraySizeExpr = "1024")
String body;
}

public class Test {

@Test
public void testParse() {
    byte[] data = new byte[] {0x12, 0x34, 0x56, 0x7F};
    final JBBPParser parser = JBBPParser.prepare(JBBPDslBuilder.Begin().AnnotatedClass(Child.class).End());
    JBBPFieldStruct parsed = parser.parse(data);

    final MenuPackageTwo parsedPackage = parsed.findFieldForNameAndType("Child", JBBPFieldStruct.class).mapTo(new Child());

}
}

@raydac
Copy link
Owner

raydac commented Jun 29, 2023

reproducible, thanks a lot, I will check

@raydac raydac self-assigned this Jun 29, 2023
@raydac raydac added the bug label Jun 29, 2023
@raydac
Copy link
Owner

raydac commented Jun 30, 2023

I have fixed the issue, you can try 2.0.6-SNAPSHOT and if all is ok then I will make release during the weekend

@shute001
Copy link
Author

I have used 2.0.6-SNAPSHOT try agaign, it's ok now. Thanks for the quick fix.

@raydac raydac closed this as completed Jul 1, 2023
@raydac
Copy link
Owner

raydac commented Jul 1, 2023

release 2.0.6 is out

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

No branches or pull requests

2 participants