Interface private & "default" added by javac
Remi Forax
forax at univ-mlv.fr
Sat Apr 14 17:44:30 UTC 2018
< Was sent to the wrong mailing list >
default is a keyword in Java the Language but it doesn't exist at bytecode level (non abstract is enough),
so it seems you decompiler add the keyword default for every methods non-abstract in an interface,
your compiler is wrong.
If you use javap -private InterfacePrivateMethod.class, you get
Compiled from "InterfacePrivateMethod.java"
public interface InterfacePrivateMethod {
public void foo();
private void print();
}
cheers,
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/compiler-dev/attachments/20180414/4ceca9dc/attachment.html>
More information about the compiler-dev
mailing list