Search code examples
javadefault-methodjavap

Why, after compiling an interface, "default" method modifier is gone from "javap -v"?


I have observed, that after compiling an interface containing default method definition, like:

interface Delta {

    default void someMethod() {
        System.out.println("Hi.");
    }

}

and after disassembling the respective .class file (including only corresponding snippet here):

javap -v Delta.class

####

{
  public void someMethod();
    descriptor: ()V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=2, locals=1, args_size=1
         0: getstatic     #1                  // Field java/lang/System.out:Ljava/io/PrintStream;
         3: ldc           #2                  // String Hi.
         5: invokevirtual #3                  // Method java/io/PrintStream.println:(Ljava/lang/String;)V
         8: return
      LineNumberTable:
        line 10: 0
        line 11: 8
}

default modifier is gone.

Could anyone explain - why?

I am running:

openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

Note, that I am aware, that all methods are implicitly public, when no modifier is defined. So, I am not asking why public modifier is present in the compiled version of the file.


Solution

  • Surely looks like a javap bug, see this defect. I've encountered a few more of these javap issues when new features where added, just FYI.