Fix make class inheritable

This commit is contained in:
LoveSy 2022-03-21 01:04:21 +08:00
parent 2bd7051841
commit 050561ac9a
2 changed files with 4 additions and 4 deletions

View File

@ -858,7 +858,7 @@ public:
Iterator operator++(int) { return Iterator(e_++); }
Iterator operator--(int) { return Iterator(e_--); }
bool operator==(const Iterator &other) const { return other.e_ == e_; }
bool operator!=(const Iterator &other) const { return other.e_ == e_; }
bool operator!=(const Iterator &other) const { return other.e_ != e_; }
};
class ConstIterator {
@ -874,7 +874,7 @@ public:
ConstIterator operator++(int) { return ConstIterator(e_++); }
ConstIterator operator--(int) { return ConstIterator(e_--); }
bool operator==(const ConstIterator &other) const { return other.e_ == e_; }
bool operator!=(const ConstIterator &other) const { return other.e_ == e_; }
bool operator!=(const ConstIterator &other) const { return other.e_ != e_; }
};
auto begin() {

View File

@ -669,14 +669,14 @@ using ::lsplant::IsHooked;
LOGE("target class is null");
return false;
}
auto constructors =
const auto constructors =
JNI_Cast<jobjectArray>(JNI_CallObjectMethod(env, target, class_get_declared_constructors));
uint8_t access_flags = JNI_GetIntField(env, target, class_access_flags);
constexpr static uint32_t kAccFinal = 0x0010;
JNI_SetIntField(env, target, class_access_flags, static_cast<jint>(access_flags & ~kAccFinal));
for (auto &constructor : constructors) {
auto *method = ArtMethod::FromReflectedMethod(env, constructor.get());
if (method && (!method->IsPublic() || !method->IsProtected())) method->SetProtected();
if (method && !method->IsPublic() && !method->IsProtected()) method->SetProtected();
if (method && method->IsFinal()) method->SetNonFinal();
}
return true;