Simplify get_java_package implementation.
Simplify get_java_package implementation.

Root should be calculated by giving preference to fist occurrence not the last. Existing implementation is also incorrect.

PiperOrigin-RevId: 202095001

google/j2cl,google/j2cl,google/j2cl,google/j2cl,google/j2cl