I tested with a simple class (all these methods are unreferenced) :
public class Test
{
private void privateMethod()
{
System.out.println("private");
}
protected void protectedMethod()
{
System.out.println("protected");
}
public void publicMethod()
{
System.out.println("public");
}
void method()
{
System.out.println("method");
}
}
I compiled the APK, extracted Test.class
and decompiled it (with javap -c
). I got the following results. I also tested with a jar instead of an APK, and the result is exactly the same. I used Java 1.6.0_29.
protected void protectedMethod();
Code:
0: getstatic #44 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #47 // String protected
5: invokevirtual #46 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: return
public void publicMethod();
Code:
0: getstatic #44 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #48 // String public
5: invokevirtual #46 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: return
void method();
Code:
0: getstatic #44 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #49 // String method
5: invokevirtual #46 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: return
Which means only private functions are excluded at compile time.
I also tried to declare the class final
, but the result was the same.