Menu

#12 javac problems with inner classes

closed-fixed
None
5
2003-01-11
2002-12-20
Daniel Grob
No

I obfuscated a public inner class, e.g.

public class OuterClass {
public static class ProblemWithInnerClass {
}
}

In another class I access the public inner class, e.g.

public class ObfuscatorTest {
public static void main(String[] args) {
OuterClass.ProblemWithInnerClass test;
}
}

This is a common pattern where OuterClass stands for
a library and ObfuscaterTest is an application using that
library.

The problem is now that I cannot compile the class
ObfuscatorTest! The javac compiler tells me the
following:

"Error: (9, 21) cannot resolve symbol class
ProblemInnerClass"

It only happens for inner classes. Maybe it is related to
the limitation you mention that ProGuard's obfuscation
process doesn't follow the naming rule specifying that
internal classes must be named as
ExternalClass$InternalClass.

Related

Bugs: #631
Bugs: #664

Discussion

  • Eric Lafortune

    Eric Lafortune - 2002-12-21

    Logged In: YES
    user_id=555208

    You're right. I'm surprised noone has reported this before.
    It appears one also has to keep the file name part of the
    InnerClasses attribute, in order to keep the inner class
    accessible. The following option will do just that:

    -keepattributes InnerClasses

    That's pretty painless. It should be added to the
    library.pro example.

    Thanks for your report!

    Eric.

     
  • Eric Lafortune

    Eric Lafortune - 2002-12-21
    • assigned_to: nobody --> lafortune
     
  • Eric Lafortune

    Eric Lafortune - 2003-01-11
    • status: open --> closed-fixed
     

Log in to post a comment.