Feat: add JuiceRemapper runtime class remapping

- add JuiceRemapperService that listens for ClassFileLoadHook and calls
  the Java static Remap.remap(String, byte[]) via cached JNI declarations,
  then writes the returned bytes back to the JVMTI callback
- add JNI bindings (initNative, add/remove/clear include/exclude) with
  Remapper singleton init state and cached jclass/jmethodID stored in
  Remapper (global.hpp)
- cache static class/method declarations lazily in initNative to avoid
  repeated FindClass/GetStaticMethodID
- add generated JuiceRemapper JNI header and runtime-remap example config
This commit is contained in:
xiaozhou233 committed 2026-08-18 16:28:29 +08:00
1 parent 81905d6c3f
commit 4bed99f417
6 files changed
+375

No files matched your search

+27
View File
@@ -131,5 +131,32 @@ private:
std::unordered_map<std::string, PendingPatch> pendingPatches_;
};
class Remapper {
public:
static Remapper& getInstance() {
static Remapper instance;
return instance;
}
Remapper(const Remapper&) = delete;
Remapper& operator=(const Remapper&) = delete;
bool isInit() const { return initialized_; }
void setInit(bool init) { initialized_ = init; }
// Cached JNI static declarations for the Java remap class.
jclass getRemapClass() const { return remapClass_; }
jmethodID getRemapMethodId() const { return remapMethodId_; }
void setRemapClass(jclass clazz) { remapClass_ = clazz; }
void setRemapMethodId(jmethodID methodId) { remapMethodId_ = methodId; }
private:
Remapper() = default;
bool initialized_ = false;
jclass remapClass_ = nullptr; // global ref
jmethodID remapMethodId_ = nullptr; // static method id
};
}
}
+3
View File
@@ -10,6 +10,9 @@
// Generated by JuiceAgent-API
#include <JuiceAgent/cn_xiaozhou233_juiceagent_api_JuiceAgent.h>
// Generated by JuiceRemapper
#include <JuiceRemapper/cn_xiaozhou233_juiceremapper_JuiceRemapper.h>
// Event callbacks
// See https://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#ClassFileLoadHook
void JNICALL ClassFileLoadHook(