Java Puzzle: Square Root

Show your Java-fu by calculating the unknown.

Written by Wouter Coekaerts.

Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home

There are several algorithms to calculate a square root. But to solve this puzzle, you’ll need a different approach.

Can you find the square root of a huge number, without even looking at it?

package square;
import java.math.BigInteger;
public class SquareRoot {
public static final int BITS = 10000;
  private static BigInteger n =
new BigInteger(BITS, new SecureRandom()).pow(2);
  public static void answer(BigInteger root) {
if (n.divide(root).equals(root)) {
// The goal is to reach this line
System.out.println("Square root!");

Write a class that calls SquareRoot.answer, and reaches that line in the code. The rules:
* Using setAccessible takes all the fun out of the problem, so your code must run with the security manager enabled (java your.Class).
* Solve the problem in a single separate .java file which compiles and runs with JDK 6 or 7.
* Finding and exploiting security vulnerabilities in the JDK itself is interesting, but not the point of this puzzle.

Put your solution in a secret gist, and add a link to it in a comments below. To give everyone a chance to participate without spoilers the comments will stay private for a week.

Good luck!

Update: See this post about the solution