java: prevent overflow by using 'long int' arithmetic in multiplication

Change-Id: I8dda8f4621f265208c713c9edcfe725f1c9c5998
Reviewed-on: https://gerrit.libreoffice.org/12001
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>