java_gen: fix alignment on read of messages that are internally aligned
I.e., if the alignment is contained in the length field
diff --git a/java_gen/templates/of_class.java b/java_gen/templates/of_class.java
index 46dc1ea..7b3b762 100644
--- a/java_gen/templates/of_class.java
+++ b/java_gen/templates/of_class.java
@@ -229,9 +229,14 @@
//:: #endif
//:: #endfor
//:: if msg.align:
- // align message to ${msg.align} bytes
+ //:: if msg.length_includes_align:
+ // align message to ${msg.align} bytes (length contains aligned value)
+ bb.skipBytes(length - (bb.readerIndex() - start));
+ //:: else:
+ // align message to ${msg.align} bytes (length does not contain alignment)
bb.skipBytes(((length + ${msg.align-1})/${msg.align} * ${msg.align} ) - length );
//:: #endif
+ //:: #endif
//:: if msg.data_members:
//:: if os.path.exists("%s/custom/%s.Reader_normalize_stanza.java" % (template_dir, msg.name)):