/* Given a list of class/method pairs, finds all non-abstract candidates to be made abstract, then mutates them. */ void make_methods_abstract(std::vector<DexClass*>& classes, CMethodStrs cMethodStrs) { CMethods methods; std::cout << "Marking methods to make abstract..." << std::endl; int64_t markedForAbstraction = 0; mark_methods(classes, cMethodStrs, methods, markedForAbstraction); int64_t madeAbstract = 0; for (auto const& cm : methods) { DexMethod* m = cm.second; std::string descriptor = gen_method_desc(cm); if (is_abstract(m)) { std::cout << descriptor << " is already abstract" << std::endl; } else { DexAccessFlags original_access = m->get_access(); DexMethodSpec ref(m->get_class(), m->get_name(), m->get_proto()); m->change(ref, false); if (m->is_def()) { std::cout << "Making " << descriptor << " abstract" << std::endl; m->set_access(original_access | ACC_ABSTRACT); } else { std::cout << descriptor << " has false is_def()" << std::endl; } madeAbstract++; } } std::cout << madeAbstract << " methods made abstract (from " << markedForAbstraction << " marked)." << std::endl; }
// ------------------------------------------------------------------ // ciMethod::build_method_data // // Generate new methodDataOop objects at compile time. void ciMethod::build_method_data(methodHandle h_m) { EXCEPTION_CONTEXT; if (is_native() || is_abstract() || h_m()->is_accessor()) return; if (h_m()->method_data() == NULL) { methodOopDesc::build_interpreter_method_data(h_m, THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; } } if (h_m()->method_data() != NULL) { _method_data = CURRENT_ENV->get_object(h_m()->method_data())->as_method_data(); _method_data->load_data(); } else { _method_data = CURRENT_ENV->get_empty_methodData(); } }
void AccessFlags::print_on(outputStream* st) const { if (is_public ()) st->print("public " ); if (is_private ()) st->print("private " ); if (is_protected ()) st->print("protected " ); if (is_static ()) st->print("static " ); if (is_final ()) st->print("final " ); if (is_synchronized()) st->print("synchronized "); if (is_volatile ()) st->print("volatile " ); if (is_transient ()) st->print("transient " ); if (is_native ()) st->print("native " ); if (is_interface ()) st->print("interface " ); if (is_abstract ()) st->print("abstract " ); if (is_strict ()) st->print("strict " ); if (is_synthetic ()) st->print("synthetic " ); if (is_old ()) st->print("{old} " ); if (is_obsolete ()) st->print("{obsolete} " ); }
bool tree_runner<b_class, c_class>::swap_child_position() { if (is_abstract()) { if (previous_label == it_was_abstract) return true; else return false; } else if (curent->parent == nullptr) { curent->is_left = !(curent->is_left); return true; } else return false; };
// ------------------------------------------------------------------ // ciMethod::ensure_method_data // // Generate new MethodData* objects at compile time. // Return true if allocation was successful or no MDO is required. bool ciMethod::ensure_method_data(methodHandle h_m) { EXCEPTION_CONTEXT; if (is_native() || is_abstract() || h_m()->is_accessor()) { return true; } if (h_m()->method_data() == NULL) { Method::build_interpreter_method_data(h_m, THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; } } if (h_m()->method_data() != NULL) { _method_data = CURRENT_ENV->get_method_data(h_m()->method_data()); _method_data->load_data(); return true; } else { _method_data = CURRENT_ENV->get_empty_methodData(); return false; } }
// ------------------------------------------------------------------ // ciFlags::print_klass_flags void ciFlags::print_klass_flags(outputStream* st) { if (is_public()) { st->print("public"); } else { st->print("DEFAULT_ACCESS"); } if (is_final()) { st->print(",final"); } if (is_super()) { st->print(",super"); } if (is_interface()) { st->print(",interface"); } if (is_abstract()) { st->print(",abstract"); } }
// ------------------------------------------------------------------ // ciFlags::print_member_flags void ciFlags::print_member_flags(outputStream* st) { if (is_public()) { st->print("public"); } else if (is_private()) { st->print("private"); } else if (is_protected()) { st->print("protected"); } else { st->print("DEFAULT_ACCESS"); } if (is_static()) { st->print(",static"); } if (is_final()) { st->print(",final"); } if (is_synchronized()) { st->print(",synchronized"); } if (is_volatile()) { st->print(",volatile"); } if (is_transient()) { st->print(",transient"); } if (is_native()) { st->print(",native"); } if (is_abstract()) { st->print(",abstract"); } if (is_strict()) { st->print(",strict"); } }