<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
One groovy compiler guy run into the same issue a while ago:<br>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<a
href="http://www.mail-archive.com/jvm-languages@googlegroups.com/msg01195.html">http://www.mail-archive.com/jvm-languages@googlegroups.com/msg01195.html</a><br>
<br>
synthetic means that this is an implementation artifact,<br>
the latest draft of the JVMS 3 is clear about that:<br>
see <a class="moz-txt-link-freetext" href="http://blogs.sun.com/abuckley/resource/JVMS3-DRAFT-20090512.zip">http://blogs.sun.com/abuckley/resource/JVMS3-DRAFT-20090512.zip</a><br>
(section 4.7.8)<br>
<br>
cheers,<br>
Rémi<br>
<br>
<br>
Le 06/08/2010 17:21, Andrew Dinn a écrit :
<blockquote cite="mid:4C5C2863.3010603@redhat.com" type="cite">Dear
Compiler Devs,
<br>
<br>
The JBoss AOP team recently ran in to a problem when transforming an
abstract class offline (see <a class="moz-txt-link-freetext" href="https://jira.jboss.org/browse/JBAOP-731">https://jira.jboss.org/browse/JBAOP-731</a> 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.
<br>
<br>
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
<br>
<br>
com.sun.tools.javac.code.Types.implementation(MethodSymbol ms,
TypeSymbol, Types, boolean)
<br>
<br>
The offending code is
<br>
<br>
1967
<br>
1968 MethodSymbol impl = cache.get(origin);
<br>
. . . if (impl == null) {
<br>
for (Type t = origin.type; t.tag == CLASS || t.tag ==
TYPEVAR; t = types.supertype(t)) {
<br>
while (t.tag == TYPEVAR)
<br>
t = t.getUpperBound();
<br>
TypeSymbol c = t.tsym;
<br>
for (Scope.Entry e = c.members().lookup(ms.name);
<br>
e.scope != null;
<br>
e = e.next()) {
<br>
if (e.sym.kind == Kinds.MTH) {
<br>
MethodSymbol m = (MethodSymbol) e.sym;
<br>
if (m.overrides(ms, origin, types, checkResult)
&&
<br>
(m.flags() & SYNTHETIC) == 0) {
<br>
impl = m;
<br>
cache.put(origin, m);
<br>
return impl;
<br>
}
<br>
}
<br>
}
<br>
}
<br>
}
<br>
<br>
<br>
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?
<br>
<br>
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
<br>
<br>
if (m.overrides(ms, origin, types, checkResult)
&&
<br>
(m.flags() & (SYNTHETIC|ABSTRACT)) !=
(SYNTHETIC|ABSTRACT) {
<br>
<br>
regards,
<br>
<br>
<br>
Andrew Dinn
<br>
-----------
<br>
Senior Software Engineer, JBoss
<br>
Red Hat UK Ltd
<br>
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire,
<br>
SI4 1TE, United Kingdom.
<br>
Registered in UK and Wales under Company Registration No. 3798903
<br>
Directors: Michael Cunningham (USA), Charlie Peters (USA), Matt Parsons
<br>
(USA) and Brendan Lane (Ireland)
<br>
<br>
<br>
</blockquote>
<br>
</body>
</html>