langtools/src/share/classes/com/sun/tools/javap/TryBlockWriter.java
changeset 22163 3651128c74eb
parent 5847 1908176fd6e3
equal deleted inserted replaced
22162:3b3e23e67329 22163:3651128c74eb
    62         NoteKind(String text) {
    62         NoteKind(String text) {
    63             this.text = text;
    63             this.text = text;
    64         }
    64         }
    65         public abstract boolean match(Exception_data entry, int pc);
    65         public abstract boolean match(Exception_data entry, int pc);
    66         public final String text;
    66         public final String text;
    67     };
    67     }
    68 
    68 
    69     static TryBlockWriter instance(Context context) {
    69     static TryBlockWriter instance(Context context) {
    70         TryBlockWriter instance = context.get(TryBlockWriter.class);
    70         TryBlockWriter instance = context.get(TryBlockWriter.class);
    71         if (instance == null)
    71         if (instance == null)
    72             instance = new TryBlockWriter(context);
    72             instance = new TryBlockWriter(context);
    78         context.put(TryBlockWriter.class, this);
    78         context.put(TryBlockWriter.class, this);
    79         constantWriter = ConstantWriter.instance(context);
    79         constantWriter = ConstantWriter.instance(context);
    80     }
    80     }
    81 
    81 
    82     public void reset(Code_attribute attr) {
    82     public void reset(Code_attribute attr) {
    83         indexMap = new HashMap<Exception_data, Integer>();
    83         indexMap = new HashMap<>();
    84         pcMap = new HashMap<Integer, List<Exception_data>>();
    84         pcMap = new HashMap<>();
    85         for (int i = 0; i < attr.exception_table.length; i++) {
    85         for (int i = 0; i < attr.exception_table.length; i++) {
    86             Exception_data entry = attr.exception_table[i];
    86             Exception_data entry = attr.exception_table[i];
    87             indexMap.put(entry, i);
    87             indexMap.put(entry, i);
    88             put(entry.start_pc, entry);
    88             put(entry.start_pc, entry);
    89             put(entry.end_pc, entry);
    89             put(entry.end_pc, entry);
   127     }
   127     }
   128 
   128 
   129     private void put(int pc, Exception_data entry) {
   129     private void put(int pc, Exception_data entry) {
   130         List<Exception_data> list = pcMap.get(pc);
   130         List<Exception_data> list = pcMap.get(pc);
   131         if (list == null) {
   131         if (list == null) {
   132             list = new ArrayList<Exception_data>();
   132             list = new ArrayList<>();
   133             pcMap.put(pc, list);
   133             pcMap.put(pc, list);
   134         }
   134         }
   135         if (!list.contains(entry))
   135         if (!list.contains(entry))
   136             list.add(entry);
   136             list.add(entry);
   137     }
   137     }