mirror of
https://github.com/morluto/rea.git
synced 2026-10-26 17:35:11 +00:00
fix(android): preserve native and abstract body absence
Freeze body-absence access flags with stable parsed method identity, before code generation can rewrite method metadata. Skip source slicing for these methods and return unavailable empty source with explicit native/abstract markers, rather than attributing neighbouring members to the selected method. Adapt the access-flag guard and tiny Smali fixtures from PR #3527. Extend real metadata and public CLI/MCP regressions for native, static native, abstract, concrete overloads and re-reading frozen facts after neighbouring generation. Rename the expanded method-body verifier and remove its old entry point. Validation: 72 focused tests in 3 files; real pinned-JAR baseline control fails and candidate passes without triggering code generation; 6 real CLI and 6 MCP fixture calls with parity, identity and unchanged APK; docs/static checks and two source reviews. Six measured real MCP workflows, no speedup claim. Tiny authored APK only; reported BinaryEye, Linux/Windows and browser workflows unverified. Heavy profiling/stress remain stopped. Fixes #3488 Co-authored-by: balkan16 <57933796+balkan16@users.noreply.github.com>
This commit is contained in:
1 parent
3c1cce78ee
commit
742b6f587f
8 files changed
+278
-137
No files matched your search
@@ -27,7 +27,8 @@ class ReaJadxBridge {
|
||||
private JadxSession indexedSession;
|
||||
private Map<String, List<ClassSnapshot>> classes = Map.of();
|
||||
|
||||
private record MethodSnapshot(String name, String shortId, Map<String, Object> summary) {}
|
||||
private record MethodSnapshot(String name, String shortId, List<String> bodyAbsenceMarkers,
|
||||
Map<String, Object> summary) {}
|
||||
private record ClassSnapshot(JavaClass node, List<MethodSnapshot> methods, Map<String, Object> summary) {}
|
||||
|
||||
private static final class InputFailure extends IllegalArgumentException {
|
||||
@@ -89,10 +90,13 @@ class ReaJadxBridge {
|
||||
if (!shortId.startsWith(rawName + "("))
|
||||
throw new IllegalStateException("JADX method ID has no raw-name prefix: " + shortId);
|
||||
String descriptor = shortId.substring(rawName.length());
|
||||
List<String> bodyAbsenceMarkers = new ArrayList<>();
|
||||
if (method.getAccessFlags().isNative()) bodyAbsenceMarkers.add("native_method");
|
||||
if (method.getAccessFlags().isAbstract()) bodyAbsenceMarkers.add("abstract_method");
|
||||
String signature = name + "(" + method.getArgTypes().stream()
|
||||
.map(Object::toString).collect(Collectors.joining(", "))
|
||||
+ "): " + method.getReturnType().toString();
|
||||
return new MethodSnapshot(name, shortId, Map.of(
|
||||
return new MethodSnapshot(name, shortId, List.copyOf(bodyAbsenceMarkers), Map.of(
|
||||
"name", name, "signature", signature,
|
||||
"dex_descriptor", descriptor,
|
||||
"is_constructor", method.isConstructor(), "def_pos", 0));
|
||||
@@ -139,6 +143,10 @@ class ReaJadxBridge {
|
||||
|
||||
private JadxSession.SmartCode methodBody(JadxSession current, ClassSnapshot cls,
|
||||
MethodSnapshot selected, JavaMethod method) {
|
||||
// Access flags belong to the parsed member, before code generation rewrites it.
|
||||
// These methods have no Java body; source slicing can include unrelated members.
|
||||
if (!selected.bodyAbsenceMarkers().isEmpty())
|
||||
return new JadxSession.SmartCode("", "java", false, selected.bodyAbsenceMarkers());
|
||||
if (!selected.shortId().equals("<clinit>()V"))
|
||||
return current.getMethodBodySmart(method, current.getMaxSourceBytes(), true);
|
||||
// Java code generation can fold all or part of <clinit> into field declarations.
|
||||
|
||||
Reference in new issue
Block a user