Пример #1
0
/*
 * Get Method Modifiers
 *
 * For the method indicated by method, return the access flags
 * via modifiers_ptr.
 *
 * REQUIRED Functionality.
 */
jvmtiError JNICALL
jvmtiGetMethodModifiers(jvmtiEnv* env,
                        jmethodID method,
                        jint* modifiers_ptr)
{
    TRACE("GetMethodModifiers called");
    SuspendEnabledChecker sec;
    /*
     * Check given env & current phase.
     */
    jvmtiPhase phases[] = {JVMTI_PHASE_START, JVMTI_PHASE_LIVE};

    CHECK_EVERYTHING();

    if( !method ) return JVMTI_ERROR_NULL_POINTER;
    if( !modifiers_ptr ) return JVMTI_ERROR_NULL_POINTER;

    *modifiers_ptr = 0;
    Method* mtd = reinterpret_cast<Method*>(method);
    if( mtd->is_public() ) *modifiers_ptr |= ACC_PUBLIC;
    if( mtd->is_private() ) *modifiers_ptr |= ACC_PRIVATE;
    if( mtd->is_protected() ) *modifiers_ptr |= ACC_PROTECTED;
    if( mtd->is_static() ) *modifiers_ptr |= ACC_STATIC;
    if( mtd->is_final() ) *modifiers_ptr |= ACC_FINAL;
    if( mtd->is_synchronized() ) *modifiers_ptr |= ACC_SYNCHRONIZED;
    if( mtd->is_native() ) *modifiers_ptr |= ACC_NATIVE;
    if( mtd->is_abstract() ) *modifiers_ptr |= ACC_ABSTRACT;

    return JVMTI_ERROR_NONE;
}
Пример #2
0
  // Find all methods on this hierarchy that match this
  // method's erased (name, signature)
  bool visit() {
    PseudoScope* scope = PseudoScope::cast(current_data());
    InstanceKlass* iklass = current_class();

    Method* m = iklass->find_method(_method_name, _method_signature);
    // private interface methods are not candidates for default methods
    // invokespecial to private interface methods doesn't use default method logic
    // private class methods are not candidates for default methods,
    // private methods do not override default methods, so need to perform
    // default method inheritance without including private methods
    // The overpasses are your supertypes' errors, we do not include them
    // future: take access controls into account for superclass methods
    if (m != NULL && !m->is_static() && !m->is_overpass() && !m->is_private()) {
      if (_family == NULL) {
        _family = new StatefulMethodFamily();
      }

      if (iklass->is_interface()) {
        StateRestorer* restorer = _family->record_method_and_dq_further(m);
        scope->add_mark(restorer);
      } else {
        // This is the rule that methods in classes "win" (bad word) over
        // methods in interfaces. This works because of single inheritance
        // private methods in classes do not "win", they will be found
        // first on searching, but overriding for invokevirtual needs
        // to find default method candidates for the same signature
        _family->set_target_if_empty(m);
      }
    }
    return true;
  }