Fix a scope bug for java agent manifest writing.

Also fix a JavaAgent validation bug revelead by adding a test for
JarBuilder agent handling.

https://rbcommons.com/s/twitter/r/768/