Add explicit support for bag in java backend

@dwightguth @andreistefanescu please review