Fix java compilation issues when processing large .proto files

Fix issues 485 and 501 on the code.google.com issues list.

Specifically, large .proto files lead to too much static code, leading to a
compilation error from javac: "code too large". This divides the code used
in static initialization into multiple methods to avoid that error. Also,
this incorporates the fix in issue 485 on the code.google.com issues list
to call registry.add only once per extension.