raydac/java-binary-block-parser

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

shute001 opened this issue · 4 comments

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());

}
}

reproducible, thanks a lot, I will check

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

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

release 2.0.6 is out