fixing the following coverity issues, which entails the issue with print and most of the java issues:
1196398, 1196403, 1196402, 1196401, 1196400, 1196413, 1196415, 1196414, 1196411