Compare commits

..
8 Commits
Author SHA1 Message Date
xiaozhou233 10ec330480 Version 4.1.1 2026-08-19 18:36:07 +08:00
xiaozhou233 0ddcfcd7c8 Remove remapper whitelist JNI declarations 2026-08-19 18:30:58 +08:00
xiaozhou233 87a91376c5 Remove JuiceRemapper module
Remove the runtime class remapping feature including its JNI bindings, service, config example, and Remapper singleton from global.hpp.
2026-08-19 18:29:38 +08:00
xiaozhou233 dbae5e5258 Fix: do not auto-read config when runtime dir is empty
Config no longer falls back to the current working directory when no
runtime directory is specified, so an empty runtime dir leaves the config
invalid instead of silently parsing config.toml from the CWD.
2026-08-18 20:11:00 +08:00
xiaozhou233 ff216aabee Fix: harden remapper filters and agent init guard
- skip empty include/exclude entries in Remapper::shouldRemap to avoid
  calling back() on an empty std::string (undefined behavior)
- null-check new_class_data_len/new_classbytes in JuiceRemapperService
  before writing remapped bytes back to the JVMTI callback
- add Agent::initialized_ guard so init() is a no-op on second call,
  preventing duplicate service instantiation and listeners
2026-08-18 16:51:21 +08:00
xiaozhou233 18a923373b Merge branch 'feat/remapper' into main 2026-08-18 16:43:47 +08:00
xiaozhou233 6fe467bccf Feat: add include/exclude filters for JuiceRemapper
- add thread-safe include/exclude sets to Remapper; shouldRemap matches
  exact name, package prefix (trailing '/'), or nested class ('\$' after
  the prefix), with exclude taking priority
- remapping stays OFF by default: an empty include set remaps nothing;
  it is only enabled once addInclude is called (no config include)
- implement addInclude/addExclude/removeInclude/removeExclude/
  clearIncludes/clearExcludes JNI bindings
- apply shouldRemap filter in JuiceRemapperService::onClassFileLoadHook
2026-08-18 16:41:55 +08:00
xiaozhou233 4bed99f417 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
2026-08-18 16:28:29 +08:00
5 changed files with 14 additions and 28 deletions

No files matched your search

+1 -1
View File
@@ -1 +1 @@
Version 4.1.0
Version 4.1.1
+7 -3
View File
@@ -15,9 +15,13 @@ class Config {
public:
explicit Config(const std::filesystem::path& runtime_dir = {})
{
_runtime_dir = runtime_dir.empty()
? std::filesystem::current_path()
: runtime_dir;
_runtime_dir = runtime_dir;
// No runtime directory specified: do not auto-read a config file
// from the current working directory.
if (runtime_dir.empty()) {
return;
}
const auto result = toml::try_parse(_runtime_dir / "config.toml");
@@ -111,30 +111,6 @@ JNIEXPORT jbyteArray JNICALL Java_cn_xiaozhou233_juiceagent_api_JuiceAgent_getCl
JNIEXPORT jbyteArray JNICALL Java_cn_xiaozhou233_juiceagent_api_JuiceAgent_getClassBytesByName
(JNIEnv *, jclass, jstring);
/*
* Class: cn_xiaozhou233_juiceagent_api_JuiceAgent
* Method: addRemapperWhiteList
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_cn_xiaozhou233_juiceagent_api_JuiceAgent_addRemapperWhiteList
(JNIEnv *, jclass, jstring);
/*
* Class: cn_xiaozhou233_juiceagent_api_JuiceAgent
* Method: removeRemapperWhiteList
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_cn_xiaozhou233_juiceagent_api_JuiceAgent_removeRemapperWhiteList
(JNIEnv *, jclass, jstring);
/*
* Class: cn_xiaozhou233_juiceagent_api_JuiceAgent
* Method: clearRemapperWhiteList
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_cn_xiaozhou233_juiceagent_api_JuiceAgent_clearRemapperWhiteList
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
+5
View File
@@ -69,6 +69,11 @@ namespace JuiceAgent {
spdlog::error("[JuiceAgent] Agent not loaded! Please call preload() first!");
return false;
}
if(initialized_) {
spdlog::warn("[JuiceAgent] Agent already initialized! Skipping...");
return true;
}
initialized_ = true;
// Add Abilities
jvmtiCapabilities caps{};
+1
View File
@@ -13,6 +13,7 @@ namespace JuiceAgent {
JuiceAgent::Config::Config config;
bool loaded = false;
bool initialized_ = false;
public:
// Singleton
static Agent& getInstance();