Q: 如何使用符号保留指令?
A: 除了在命令行用-Xobfuscate参数控制符号混淆级别外,还可以在源代码中使用
符号保留指令来控制那些符号需要保留,符号保留指令是一个Java文档注释指令,
可以插入在类和类成员的文档注释中,例如:
/**
* This class should preserve.
* @preserve
*/
public class Foo {
/**
* You can specify which field should be preserved.
* @preserve
*/
private int x;
/**
* This field is not preserved.
*/
private int y;
/**
* You can also preserve methods.
* @preserve
*/
public void hello() {}
/**
* This method is not preserved.
*/
private void collect() {}
}
如果没有@preserve指令,则根据混淆级别及成员的访问级别来确定符号是否保留