Miranda methods and Methods added by Code Generators

Andrew Dinn adinn at redhat.com
Mon Aug 9 06:01:59 PDT 2010

On 08/09/2010 12:59 PM, Maurizio Cimadamore wrote:
> Javac complains about Child not having an 'explicit' override of
> getAdvisor(), where by 'explicit' I mean a user-defined one (not
> SYNTHETIC). As I said, bridge methods are an important case of synthetic
> methods that should *not* be taken into account when determining as to
> whether a subclass implements all superclass/superinterfaces abstract
> methods.

Yes, I understand that javac needs to be able to discount the SYNTHETIC 
methods it adds to classes. In fact, my motivation for posting on this 
issue is to try to pin down the semantics of the SYNTHETIC attribute. 
AOP adds it to generated methods for good reasons (JBoss Application 
Server needs to discount these methods when it applies runtime container 
transformations to the code). If the assumption that it can use this 
attribute to identify AOP generated code is invalid I would like to know 
exactly why.

> Now, I admit that the currently implemented check is probably too strict
> for you, but please, keep in mind that the scenario you are describing
> (class with just a synthetic implementation of a superinterface method)
> is something that simply cannot happen when compiling Java sources -
> that's why javac is not prepared to handle this case [in the case of
> bridge methods, there's always at least one user-defined implementation
> in addition to compiler-generated ones, so the check in question is
> never problematic].

Your description of the current situation is not quite accurate. When 
javac compiles the source of Child it is not at that time compiling the 
source of Parent. It only has the bytecode of Parent available (the 
generated SYNTHETIC method _only occurs_ in the bytecode). So, it is 
possible for javac to end up finding SYNTHETIC methods in its method 
tables which it has not itself introduced directly through analysis of 
source code.

What I don't understand is why you have to rely on just the SYNTHETIC 
attribute to identify the cases which javac should discount. Looking at 
ClassWriter.java it appears that bridge methods are written to the 
classfile with the BRIDGE attribute. Similarly, Miranda methods are 
written with the SYNTHETIC and ABSTRACT attribute. So, why automatically 
discount SYNTHETIC methods? Could you not instead discount 

Are you saying that you cannot rely on the BRIDGE attribute to identify 
bridge methods? (I am assuming that the generated ones have 
SYNTHETIC|BRIDGE in their flags list while the user-defined ones merely 
have BRIDGE --  is that not the case?).


Andrew Dinn

More information about the compiler-dev mailing list