Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static method missing in bytecode

Tags:

java

I have a simple program like below:

    public class StringDemo {

          public static String s = "abcdef";

          private static boolean test(String str) {
            if (!str.startsWith("abc")) {
              return false;
            }
            return true;
          } 

          public static void doTest() {
            test(s);
          }

          public static void main(String srgs[]) {
            doTest();
          }
    }

Both test and doTest are static methods, but after compiling to bytecode, I can only see doTest, and testis missing. Can anybody explain for me why? Thanks.

P/S: I can't put bytecode in here, because stackoverflow keeps showing an error "your post is mostly code, please put more details"...etc

like image 904
sean Avatar asked May 25 '26 21:05

sean


1 Answers

you should use javap with -private flag in order to see private methods javap -c -private xxxxxxxx

like image 149
nik Avatar answered May 28 '26 10:05

nik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!