#!/bin/bash
#
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Write out a file with a really huge catch range.

awk '
BEGIN {
    fileName = "Zorch.java";
    printf("public class Zorch {\n") > fileName;
    printf("    static public void test() {\n") > fileName;
    printf("        try {\n") > fileName;
    for (i = 0; i <= 1800; i++) {
        d = i + 1000000;
        printf("    Blort.blort(100%dL, 200%dL, 300%dL, 400%dL, 500%dL, " \
            "600%dL, 700%dL, 800%dL);\n",
            d, d + 1, d + 2, d + 3, d + 4, d + 5, d + 6, d + 7) > fileName;
    }
    printf("        } catch (RuntimeException ex) {\n") > fileName;
    printf("            throw ex;\n") > fileName;
    printf("        }\n") > fileName;
    printf("    }\n") > fileName;
    printf("}\n") > fileName;
}'

$JAVAC -d . *.java
dx --debug --dex --no-optimize --positions=none --no-locals \
    --dump-method=Zorch.test Zorch.class | grep 'try\|catch'
