• 11
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I am currently attempting to obfuscate a series of libraries. My base library, which contains several classes and methods that use type parameters, is unusable by other code due to the type parameters being removed by Proguard obfuscation. Eliminating the obfuscation removes these issues. I have read through all of the ProGuard usage documents, examples, and troubleshooting, but have been unable to find any documentation on how to deal with type parameters or which aspect of ProGuard strips the type parameters.

Constructor Type Parameter Issue:

Library 1 contains the following class:

public abstract class AbstractFactoryFactory<T>

Library 2 contains several classes that extend the above class but the constructor throws a compiler error that states:

error: type AbstractFactoryFactory does not take parameters

Return Type Parameter Issue:

Library 1 has a Foo class with the following method:

public List<String> doSomething()

Libary 2 tries to use the doSomething method, but after obfuscation the method returns an untyped list that generates the following compiler error that states:

error: incompatible types Object

Proguard.cfg

-dontoptimize

-renamesourcefileattribute SourceFile
-keepparameternames
-keepattributes Exceptions,*Annotation*,InnerClasses,SourceFile,LineNumberTable,Deprecated

-keep public class * {
    public protected *;
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keepclassmembernames class * {
    java.lang.Class class$(java.lang.String);
    java.lang.Class class$(java.lang.String, boolean);
}

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private 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();
}

According to the ProGuard Typical Library usage guide:

The "Signature" attribute is required to be able to access generic types when compiling in JDK 5.0 and higher.

Adding the following line fixed my issues with missing type parameters:

-keepattributes Signature
  • 63
Reply Report
      • 2
    • Thanks! This is also needed for Netty 4 library obfuscation. TypeParameterMatcher in Netty 4 is failed cause it is needed for constructing HttpClientCodec, HttpRequestEncoder or MessageToMessageEncoder, and probably other classes. I write this comment for other users who faces with similar Netty obfuscation issue.
      • 1
    • Took me forever to find the root of the problem, but once I found it the answer just popped up in google!