Annotations for controlling code obfuscation behavior in Zelix KlassMaster and JNIC Native Obfuscator
This project provides a collection of Java annotations designed to work with popular obfuscation tools:
- Zelix KlassMaster - A powerful Java bytecode obfuscator
- JNIC Native Obfuscator - Native code obfuscation tool
These annotations enable fine-grained control over which parts of your code get obfuscated, allowing you to protect sensitive logic while keeping public APIs readable and maintainable.
- 🔒 Selective obfuscation control
- 📝 Clean, intuitive annotation syntax
- 🔧 Compatible with industry-standard obfuscators
- ⚡ Zero runtime overhead (annotations are compile-time only)
# Clone the repository
git clone https://github.com/yourusername/Obfuscate-Annotation.git
cd Obfuscate-Annotation
# Build with Maven (if applicable)
mvn clean packageAdd the annotation JAR to your project classpath and use annotations in your Java code:
@NoStringObfuscate
public class SensitiveClass {
// String obfuscation will be skipped for this class
}| Annotation | Target | Description |
|---|---|---|
@ZKMIndy |
Class, Method | Enable invokedynamic obfuscation |
@NoRenameObfuscate |
Class, Method | Disable class/method renaming |
@NoStringObfuscate |
Class, Method | Disable string obfuscation |
@NoLongObfuscate |
Class, Method | Disable long constant obfuscation |
@NoIntegerObfuscate |
Class, Method | Disable integer obfuscation |
@NoFlowObfuscate |
Class, Method | Disable control flow obfuscation |
@NoExceptionsObfuscate |
Class, Method | Disable exception flow obfuscation |
@NoParameterChange |
Class, Method | Disable parameter transformation |
@NoReferencesObfuscate |
Class, Method | Disable invokedynamic obfuscation |
| Annotation | Target | Description |
|---|---|---|
@JNICInclude |
Class, Method | Include for native code obfuscation |
@JNICExclude |
Class, Method | Exclude from native code obfuscation |
// Protect a class from renaming, useful for reflection
@NoRenameObfuscate
public class ConfigLoader {
public String loadConfig(String name) {
return "config";
}
}
// Keep strings readable for API calls
@NoStringObfuscate
public class APIClient {
public void connect() {
String endpoint = "https://api.example.com";
}
}
// Include critical security code for native obfuscation
@JNICInclude
public class CryptoUtils {
public String encrypt(String data) {
// Sensitive encryption logic
return data;
}
}
// Disable multiple obfuscation types
@NoStringObfuscate
@NoFlowObfuscate
public class LegacyModule {
// This module won't have string or control flow obfuscation
}Contributions are welcome! Please feel free to submit issues and pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
用于控制 Zelix KlassMaster 和 JNIC Native Obfuscator 代码混淆行为的注解库
本项目提供了一套 Java 注解库,用于与流行的混淆工具配合使用:
- Zelix KlassMaster - 功能强大的 Java 字节码混淆器
- JNIC Native Obfuscator - 本地代码混淆工具
这些注解可以对代码的混淆行为进行细粒度控制,让你在保护敏感逻辑的同时保持公共 API 的可读性和可维护性。
- 🔒 细粒度混淆控制
- 📝 简洁直观的注解语法
- 🔧 兼容行业标准混淆工具
- ⚡ 零运行时开销(注解仅用于编译时)
# 克隆仓库
git clone https://github.com/yourusername/Obfuscate-Annotation.git
cd Obfuscate-Annotation
# 使用 Maven 构建
mvn clean package将注解 JAR 添加到项目的 classpath 中,然后在 Java 代码中使用注解:
@NoStringObfuscate
public class SensitiveClass {
// 该类的字符串混淆将被跳过
}| 注解 | 作用范围 | 功能说明 |
|---|---|---|
@ZKMIndy |
类、方法 | 启用 invokedynamic 混淆 |
@NoRenameObfuscate |
类、方法 | 禁用类/方法重命名 |
@NoStringObfuscate |
类、方法 | 禁用字符串混淆 |
@NoLongObfuscate |
类、方法 | 禁用长整型常量混淆 |
@NoIntegerObfuscate |
类、方法 | 禁用整数混淆 |
@NoFlowObfuscate |
类、方法 | 禁用控制流混淆 |
@NoExceptionsObfuscate |
类、方法 | 禁用异常流混淆 |
@NoParameterChange |
类、方法 | 禁用参数转换 |
@NoReferencesObfuscate |
类、方法 | 禁用 invokedynamic 混淆 |
| 注解 | 作用范围 | 功能说明 |
|---|---|---|
@JNICInclude |
类、方法 | 纳入本地代码混淆 |
@JNICExclude |
类、方法 | 排除本地代码混淆 |
// 保护类名不被重命名,对于反射调用很有用
@NoRenameObfuscate
public class ConfigLoader {
public String loadConfig(String name) {
return "config";
}
}
// 保持字符串可读,用于 API 调用
@NoStringObfuscate
public class APIClient {
public void connect() {
String endpoint = "https://api.example.com";
}
}
// 将关键安全代码纳入本地混淆
@JNICInclude
public class CryptoUtils {
public String encrypt(String data) {
// 敏感加密逻辑
return data;
}
}
// 禁用多种混淆方式
@NoStringObfuscate
@NoFlowObfuscate
public class LegacyModule {
// 该模块不会进行字符串和控制流混淆
}欢迎提交 Issue 和 Pull Request!
本项目采用 MIT 许可证 - 详见 LICENSE 文件