Miranda methods and Methods added by Code Generators

Rémi Forax forax at univ-mlv.fr
Fri Aug 6 11:27:56 PDT 2010


One groovy compiler guy run into the same issue a while ago:
http://www.mail-archive.com/jvm-languages@googlegroups.com/msg01195.html

synthetic means that this is an implementation artifact,
the latest draft of the JVMS 3 is clear about that:
see http://blogs.sun.com/abuckley/resource/JVMS3-DRAFT-20090512.zip
(section  4.7.8)

cheers,
Rémi


Le 06/08/2010 17:21, Andrew Dinn a écrit :
> Dear Compiler Devs,
>
> The JBoss AOP team recently ran in to a problem when transforming an 
> abstract class offline (see https://jira.jboss.org/browse/JBAOP-731 
> for details). The AOP transform operation loads the bytecode for a 
> class, call it X, manipulates it to insert, inter alia, a getAdvisor() 
> method then rewrites the classfile. Method getAdvisor is SYNTHETIC and 
> has a Code attribute. It is _NOT_ ABSTRACT.
>
> When javac subsequently tries to compile the source for Y extends X it 
> complains that Y does not implement getAdvisor(). It turns out that 
> javac is assuming that the SYNTHETIC implementation found in the 
> transformed classfile for X is a Miranda method even though it is not 
> ABSTRACT. The relevant code is in method
>
> com.sun.tools.javac.code.Types.implementation(MethodSymbol ms, 
> TypeSymbol, Types, boolean)
>
> The offending code is
>
> 1967
> 1968    MethodSymbol impl = cache.get(origin);
> . . .   if (impl == null) {
>             for (Type t = origin.type; t.tag == CLASS || t.tag == 
> TYPEVAR; t = types.supertype(t)) {
>                 while (t.tag == TYPEVAR)
>                     t = t.getUpperBound();
>                 TypeSymbol c = t.tsym;
>                 for (Scope.Entry e = c.members().lookup(ms.name);
>                      e.scope != null;
>                      e = e.next()) {
>                     if (e.sym.kind == Kinds.MTH) {
>                         MethodSymbol m = (MethodSymbol) e.sym;
>                         if (m.overrides(ms, origin, types, 
> checkResult) &&
>                             (m.flags() & SYNTHETIC) == 0) {
>                             impl = m;
>                             cache.put(origin, m);
>                             return impl;
>                         }
>                     }
>                 }
>             }
>         }
>
>
> My contention is that this is a bug. javac should only regard ABSTRACT 
> SYNTHETIC methods as Miranda methods. After all, Miranda methods are 
> all abstract are they not?
>
> Is there some good reason why _ANY_ SYNTHETIC method has to be 
> rejected? If not then the recommended patch would be to change the 
> 'if' condition at line 1978/9 above to
>
>                         if (m.overrides(ms, origin, types, 
> checkResult) &&
>                             (m.flags() & (SYNTHETIC|ABSTRACT)) != 
> (SYNTHETIC|ABSTRACT) {
>
> regards,
>
>
> Andrew Dinn
> -----------
> Senior Software Engineer, JBoss
> Red Hat UK Ltd
> Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod 
> Street, Windsor, Berkshire,
> SI4 1TE, United Kingdom.
> Registered in UK and Wales under Company Registration No. 3798903
> Directors: Michael Cunningham (USA), Charlie Peters (USA), Matt Parsons
> (USA)  and Brendan Lane (Ireland)
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20100806/302866ce/attachment.html 


More information about the compiler-dev mailing list