Miranda methods and Methods added by Code Generators

Andrew Dinn adinn at redhat.com
Tue Aug 10 03:11:02 PDT 2010


On 08/10/2010 12:07 AM, John Rose wrote:
> If it weren't for explicit marks on this category of definitions in
> the bytecodes, it would be dangerous for the compiler to emit
> internal "helper" methods, fields, or classes.  They would be visible
> to other classes (if not private) and to reflection.  But they
> shouldn't be treated as if they were written or expected by the
> programmer.

Well, that's also true of some, if not all, of the code generated by 
many bytecode transformers. As I remarked in an earlier note the 
compiler tool chain is now much wider than just javac. However, these 
other tools have have different requirements for visibility, perhaps 
making SYNTHETIC unsuitable as a  means of hiding behaviours which are 
there as implementation mechanism.

In this present case, the subclass is failing to compile because its 
(abstract) parent class has been transformed to include an interface and 
a SYNTHETIC implementation of that interface. Since this transform is 
meant to be a strictly local affair confined only to the parent class 
this seems to be a case where use of SYNTHETIC should be appropriate. 
The subclass honours the original class's requirements (it implements 
abstract methods not introduced  by the transformation) and it only 
fails to honour those of the transformed class because the interface 
method is visible but the SYNTHETIC parent class implementation is not.

Perhaps what is needed is for the interface to be SYNTHETIC or, at 
least, for it's methods to be SYNTHETIC. Would this actually work? i.e. 
assume we were to compile the interface and then bytecode transform it 
so that either it or its methods were tagged with SYNTHETIC. If we then 
place this and the transformed superclass in the classpath would the 
checkOverride code still look for an implementation for the interface 
method on the subclass or would it ignore the interface methods on the 
assumption that they do not require validation?

regards,


Andrew Dinn
-----------




More information about the compiler-dev mailing list