[Java]: Corrected position check location for var data and optimised the writes to the position in parent message.