src/share/vm/oops/klassVtable.cpp

changeset 1100
c89f86385056
parent 1045
70998f2e05ef
child 1111
d3676b4cb78c
     1.1 --- a/src/share/vm/oops/klassVtable.cpp	Thu Mar 19 09:13:24 2009 -0700
     1.2 +++ b/src/share/vm/oops/klassVtable.cpp	Fri Mar 20 23:19:36 2009 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -1153,6 +1153,27 @@
    1.11    return index;
    1.12  }
    1.13  
    1.14 +
    1.15 +// inverse to compute_itable_index
    1.16 +methodOop klassItable::method_for_itable_index(klassOop intf, int itable_index) {
    1.17 +  assert(instanceKlass::cast(intf)->is_interface(), "sanity check");
    1.18 +  objArrayOop methods = instanceKlass::cast(intf)->methods();
    1.19 +
    1.20 +  int index = itable_index;
    1.21 +  // Adjust for <clinit>, which is left out of table if first method
    1.22 +  if (methods->length() > 0 && ((methodOop)methods->obj_at(0))->name() == vmSymbols::class_initializer_name()) {
    1.23 +    index++;
    1.24 +  }
    1.25 +
    1.26 +  if (itable_index < 0 || index >= methods->length())
    1.27 +    return NULL;                // help caller defend against bad indexes
    1.28 +
    1.29 +  methodOop m = (methodOop)methods->obj_at(index);
    1.30 +  assert(compute_itable_index(m) == itable_index, "correct inverse");
    1.31 +
    1.32 +  return m;
    1.33 +}
    1.34 +
    1.35  void klassVtable::verify(outputStream* st, bool forced) {
    1.36    // make sure table is initialized
    1.37    if (!Universe::is_fully_initialized()) return;

mercurial