On Mon, Jan 19, 2009 at 9:46 PM, Jochen Theodorou <[email protected]> wrote:
>
> Hi all,
>
> someone showed my a rather strange thing with javac. It is not possible
> to express this in normal Java, so I am not sure it works as intended.
>
> imagine an interface:
>
> interface A {
>   void foo();
> }
>
>
> and an implementing class:
>
> abstract class B implements A {
>   synthetic void foo() {}
> }
>
> you will notice two possibly odd things here, the class B is abstract
> even though it implements all methods, but that is legal. The other
> thing is that he foo implementation is synthetic, which is a flag for
> the method, but not a valid keyword in Java. Anyway, just imagine you
> would have those two classe precompiled and now you want to compile this:
>
> class C extends B{}
>
> Now javac does not compile this. It complains that foo is not
> implemented. And that is strange, because B does implement the method.
> The only thing here is that the implementation method is synthetic. I
> confirmed this here with 1.7.0-ea-b24 and someone else with other
> versions of javac.
>
> If I go and remove synthetic in B, then javac does compile it.
>
> Now my question here is if javac is behaving correctly or not.

I would say that it's behaving correctly. Synthetic methods are not
intended to be visible to programmers (other than via reflection when
the programmer explicitly asks to look at synthetic methods).

If B is not abstract I presume it will not compile. Is that so?

John Wilson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to