且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Android中使用Java进行方法混淆

更新时间:2023-12-03 22:53:46

我认为在任何环境下都无法使用Java使用该技术.

I think that technique could not be used using Java in any environment.

也许使用AOP可以达到类似的结果.

Maybe you could achieve a similar result using AOP.

但是您只能在Android上执行此操作.请参见 Android中面向方面的编程.实际上,由于您不会编译目标代码(系统方法),因此在这种情况下,编译时编织(似乎是您可以在Android上使用的所有东西)将毫无用处.我想的就是这个答案.

But what you can do with that looks limited on Android. See Aspect-oriented programming in android. In fact, since you won't be compiling the target code (system method), compile-time weaving (which appears to be all you could use on Android) will be useless for this case. As is this answer I suppose.

另一个想法...我想您想一直进行此日志记录.但是,如果您需要此工具来调试问题,则可以使用

One other thought... I guess you want to do this logging consistently. But if you needed this to debug a problem, you could do it using a conditional breakpoint in Eclipse.

条件表达式可以包含任意Java代码,并且可以 包含多个语句,允许断点条件 实现跟踪等功能.例如,条件可以执行 打印语句,然后返回硬编码值以永不挂起 ("System.out.println(...);返回false;").

A conditional expression can contain arbitrary Java code and may contain more than one statement, allowing breakpoint conditions to implement features like tracing. For example, a condition can execute a print statement and then return a hard coded value to never suspend ("System.out.println(...); return false;").

我具体不知道这是否适用于Android SDK中的方法.但是它可以与Java SDK中的方法一起使用.例如,下面是简单的代码:

I don't know specifically whether this works with methods in the Android SDK. But it does work with methods in the Java SDK. For example, here is simple code:

    System.err.println("foo");

我在PrintStream.print中创建了一个条件断点,如下所示:

I made a conditional breakpoint in PrintStream.print, like this:

System.err.println("hello: " + arg0);
return false;

在程序中调试时的控制台输出是这样的:

And the console output when debugging in the program is this:

hello: foo
foo

请注意,由于JDK并未使用调试符号进行编译,因此我无法按名称引用方法参数,而只能使用arg0..argn.

Note that since the JDK is not compiled with debug symbols, I can't refer to method parameters by name, but using the arg0..argn.