ProGuard:StringBuffer

时间:2016-10-21 13:39:37

标签: java proguard obfuscation

尝试使用ProGuard对我的代码进行模糊处理。

这些是我的配置

> -injars xxxx
> -outjars yyyyy
> 
> -libraryjars 'xxx\Java\jre7\lib\rt.jar'
> -libraryjars 'xxx\ProvaProGuard\lib'
> -libraryjars 'xxx\Java\jre7\lib\jce.jar'
> 
> -dontskipnonpubliclibraryclassmembers
> -dontshrink
> -dontoptimize
> 
> 
> -keepclasseswithmembers,allowshrinking class controller.* {
>     <fields>;
>     <methods>; }
> 
> # Keep - Applications. Keep all application classes, along with their 'main'
> # methods.
> -keepclasseswithmembers public class * {
>     public static void main(java.lang.String[]); }
> 
> # Also keep - Enumerations. Keep the special static methods that are required in
> # enumeration classes.
> -keepclassmembers enum  * {
>     public static **[] values();
>     public static ** valueOf(java.lang.String); }
> 
> # Also keep - Serialization code. Keep all fields and methods that are used for
> # serialization.
> -keepclassmembers class * extends java.io.Serializable {
>     static final long serialVersionUID;
>     static final java.io.ObjectStreamField[] serialPersistentFields;
>     private void writeObject(java.io.ObjectOutputStream);
>     private void readObject(java.io.ObjectInputStream);
>     java.lang.Object writeReplace();
>     java.lang.Object readResolve(); }
> 
> # Also keep - Database drivers. Keep all implementations of java.sql.Driver.
> -keep class * extends java.sql.Driver
> 
> # Also keep - Swing UI L&F. Keep all extensions of javax.swing.plaf.ComponentUI,
> # along with the special 'createUI' method.
> -keep class * extends javax.swing.plaf.ComponentUI {
>     public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent); }

因此。当我跑步时,没有发生任何问题。 但是,如果我打开我的.jar,我只能找到一个类,内部包控制器,它只是充满了注释(我认为堆栈)和/ *错误* /标题。

我很确定这个问题与StringBuffer有关。 我使用String Buffer为邮件创建一条消息。

我在另一个类中遇到同样的问题并解决了我已经改变了变量的范围。 (以下代码)

由此:

private static String sendMail() {
    try { 
        StringBuffer header = new StringBuffer();
        StringBuffer footer = new StringBuffer();
       //CODE WHERE I USE header and footer
         return "Mail Disabilitata.";
    } catch (Throwable t) {
        return MyUtils.stackTrace(t);
    }
}

到这个

private static String sendMail() {
    StringBuffer header = new StringBuffer();
    StringBuffer footer = new StringBuffer();
    try { 
        //CODE WHERE I USE header and footer
         return "Mail Disabilitata.";
    } catch (Throwable t) {
        return MyUtils.stackTrace(t);
    }
}

因为This reply

对于我的第一堂课,这种解决方法有效。

在我的第二堂课中,(控制器,我不试图混淆的那个,正如你在我的proguard配置中看到的那样)它没有。

我很确定这是关于StringBuffer的。

或者至少(我希望不是)多个String只在一个方法中反复改变

0 个答案:

没有答案