-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Description
I've written a JBBPCustomFieldTypeProcessor to parse uint32 fields into Java longs: https://gist.github.com/use-sparingly/ac1539784af7ae7569cd50135016cf2c
It seems to work for single, read all ([_]
) and defined length arrays ([1]
). However, if I try to reference the value as a field length in a subsequent field I get a nullpointer exception.
Example:
final JBBPParser sasParser = JBBPParser.prepare(
">uint32 keycount;" +
"key [keycount] {" +
"byte[1] contentId; " +
"byte[1] keyData; " +
"}"
, new Uint32()
);
final String inputSHex = "00000001fc05";
byte inputS[] = Hex.decodeHex(inputSHex.toCharArray());
final JBBPFieldStruct result = sasParser.parse(inputS);
I get:
Exception in thread "main" java.lang.NullPointerException
at com.igormaznitsa.jbbp.compiler.varlen.JBBPOnlyFieldEvaluator.eval(JBBPOnlyFieldEvaluator.java:52)
at com.igormaznitsa.jbbp.JBBPParser.parseStruct(JBBPParser.java:174)
at com.igormaznitsa.jbbp.JBBPParser.parse(JBBPParser.java:489)
at com.igormaznitsa.jbbp.JBBPParser.parse(JBBPParser.java:515)
at Main.main(Main.java:31)
If I replace uint32
with int
then it works as expected (until I use a true uint32 value).