Home | History | Annotate | Download | only in 096-dex-giant-catch
      1 #!/bin/bash
      2 #
      3 # Copyright (C) 2008 The Android Open Source Project
      4 #
      5 # Licensed under the Apache License, Version 2.0 (the "License");
      6 # you may not use this file except in compliance with the License.
      7 # You may obtain a copy of the License at
      8 #
      9 #     http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 # Unless required by applicable law or agreed to in writing, software
     12 # distributed under the License is distributed on an "AS IS" BASIS,
     13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 # See the License for the specific language governing permissions and
     15 # limitations under the License.
     16 
     17 # Write out a file with a really huge catch range.
     18 
     19 awk '
     20 BEGIN {
     21     fileName = "Zorch.java";
     22     printf("public class Zorch {\n") > fileName;
     23     printf("    static public void test() {\n") > fileName;
     24     printf("        try {\n") > fileName;
     25     for (i = 0; i <= 1800; i++) {
     26         d = i + 1000000;
     27         printf("    Blort.blort(100%dL, 200%dL, 300%dL, 400%dL, 500%dL, " \
     28             "600%dL, 700%dL, 800%dL);\n",
     29             d, d + 1, d + 2, d + 3, d + 4, d + 5, d + 6, d + 7) > fileName;
     30     }
     31     printf("        } catch (RuntimeException ex) {\n") > fileName;
     32     printf("            throw ex;\n") > fileName;
     33     printf("        }\n") > fileName;
     34     printf("    }\n") > fileName;
     35     printf("}\n") > fileName;
     36 }'
     37 
     38 $JAVAC -d . *.java
     39 dx --debug --dex --no-optimize --positions=none --no-locals \
     40     --dump-method=Zorch.test Zorch.class | grep 'try\|catch'
     41