src/share/vm/oops/methodOop.hpp

changeset 3917
8150fa46d2ed
parent 3849
eba1d5bce9e8
child 3921
e74da3c2b827
     1.1 --- a/src/share/vm/oops/methodOop.hpp	Mon Jun 25 15:34:06 2012 -0400
     1.2 +++ b/src/share/vm/oops/methodOop.hpp	Tue Jun 26 19:08:44 2012 -0400
     1.3 @@ -282,12 +282,12 @@
     1.4    }
     1.5  
     1.6    // exception handler table
     1.7 -  typeArrayOop exception_table() const
     1.8 -                                   { return constMethod()->exception_table(); }
     1.9 -  void set_exception_table(typeArrayOop e)
    1.10 -                                     { constMethod()->set_exception_table(e); }
    1.11    bool has_exception_handler() const
    1.12                               { return constMethod()->has_exception_handler(); }
    1.13 +  int exception_table_length() const
    1.14 +                             { return constMethod()->exception_table_length(); }
    1.15 +  ExceptionTableElement* exception_table_start() const
    1.16 +                             { return constMethod()->exception_table_start(); }
    1.17  
    1.18    // Finds the first entry point bci of an exception handler for an
    1.19    // exception of klass ex_klass thrown at throw_bci. A value of NULL
    1.20 @@ -835,4 +835,66 @@
    1.21    void clear(methodOop method);
    1.22  };
    1.23  
    1.24 +// Utility class for access exception handlers
    1.25 +class ExceptionTable : public StackObj {
    1.26 + private:
    1.27 +  ExceptionTableElement* _table;
    1.28 +  u2  _length;
    1.29 +
    1.30 + public:
    1.31 +  ExceptionTable(methodOop m) {
    1.32 +    if (m->has_exception_handler()) {
    1.33 +      _table = m->exception_table_start();
    1.34 +      _length = m->exception_table_length();
    1.35 +    } else {
    1.36 +      _table = NULL;
    1.37 +      _length = 0;
    1.38 +    }
    1.39 +  }
    1.40 +
    1.41 +  int length() const {
    1.42 +    return _length;
    1.43 +  }
    1.44 +
    1.45 +  u2 start_pc(int idx) const {
    1.46 +    assert(idx < _length, "out of bounds");
    1.47 +    return _table[idx].start_pc;
    1.48 +  }
    1.49 +
    1.50 +  void set_start_pc(int idx, u2 value) {
    1.51 +    assert(idx < _length, "out of bounds");
    1.52 +    _table[idx].start_pc = value;
    1.53 +  }
    1.54 +
    1.55 +  u2 end_pc(int idx) const {
    1.56 +    assert(idx < _length, "out of bounds");
    1.57 +    return _table[idx].end_pc;
    1.58 +  }
    1.59 +
    1.60 +  void set_end_pc(int idx, u2 value) {
    1.61 +    assert(idx < _length, "out of bounds");
    1.62 +    _table[idx].end_pc = value;
    1.63 +  }
    1.64 +
    1.65 +  u2 handler_pc(int idx) const {
    1.66 +    assert(idx < _length, "out of bounds");
    1.67 +    return _table[idx].handler_pc;
    1.68 +  }
    1.69 +
    1.70 +  void set_handler_pc(int idx, u2 value) {
    1.71 +    assert(idx < _length, "out of bounds");
    1.72 +    _table[idx].handler_pc = value;
    1.73 +  }
    1.74 +
    1.75 +  u2 catch_type_index(int idx) const {
    1.76 +    assert(idx < _length, "out of bounds");
    1.77 +    return _table[idx].catch_type_index;
    1.78 +  }
    1.79 +
    1.80 +  void set_catch_type_index(int idx, u2 value) {
    1.81 +    assert(idx < _length, "out of bounds");
    1.82 +    _table[idx].catch_type_index = value;
    1.83 +  }
    1.84 +};
    1.85 +
    1.86  #endif // SHARE_VM_OOPS_METHODOOP_HPP

mercurial