public class Test {
    public static void main(String[] args) {
        String s = "9999999999e10000";
        System.out.println("parseDouble(" + s + "): " + Double.parseDouble(s) + " (expected: Infinity)");

        s = "9".repeat(Integer.MAX_VALUE - 100) + "e10000";
        System.out.println("parseDouble(999<...>99e10000): " + Double.parseDouble(s) + " (expected: Infinity)");

        int x = 1 + Integer.MAX_VALUE / 2;
        s = "9".repeat(x) + "e" + x;
        try {
            double d = Double.parseDouble(s);
            System.out.println(d);
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("parseDouble(999<...>99e<...>): " + e);
            e.printStackTrace(System.out);
        }
    }
}