Interface private & "default" added by javac

Remi Forax forax at univ-mlv.fr
Sat Apr 14 17:39:27 UTC 2018


Wrong mailing list, 
hotspot-compiler == Java Virtual Machine JIT Compiler, not Java Compiler. 

Rémi 

> De: "Ionut" <ionutb83 at yahoo.com>
> À: "hotspot compiler" <hotspot-compiler-dev at openjdk.java.net>, "Ionut B"
> <ionutb83 at yahoo.com>
> Envoyé: Samedi 14 Avril 2018 14:03:21
> Objet: Interface private & "default" added by javac

> Hello All,

> I have an initial interface containing one default and one private method:

> public interface InterfacePrivateMethod {
> default void foo(){
> print();
> }
> private void print() {
> System.out.println("Private Method");
> }
> }

> After I compile it with javac and then decompile, the class I get looks like:

> public interface InterfacePrivateMethod {
> default void foo() {
> this.print();
> }
> private default void print() { // private default !?
> System.out.println("Private Method");
> }
> }

> Basically javac inserts default in the private method signature.

> Could you please provide more details about this, why is that?
> At the Java source code level a private method cannot be default in the same
> time inside an Interface.

> Thanks a lot,
> Ionut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20180414/a8e7c636/attachment.html>


More information about the hotspot-compiler-dev mailing list