summaryrefslogtreecommitdiff
path: root/tutorial/examples/bca/AutoAdaptationClass.java
blob: 5e088bcf29282c31fa7f99287e05cea361f8f3ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * This code was generated by ojc.
 */
/*
 * AUtoAdaptationClass.oj
 *
 * Source Code Adaptation example.
 * (Not real Binary Code Adaptation)
 *
 * Oct 29, 1999 by Michiaki Tatsubori
 */
package examples.bca;


import openjava.mop.*;
import openjava.ptree.*;
import openjava.syntax.*;


/**
 * The class <code>RTReflClass</code> patches the class
 * implementing <code>Writable</code> to implement <code>Printable</code>.
 */
public class AutoAdaptationClass extends OJClass
{

    /** Overrides to translate definition */
    public void translateDefinition()
        throws MOPException
    {
        if (!openjava.mop.OJClass.forClass( Writable.class ).isAssignableFrom( this )) {
            return;
        }
        OJClass newface = openjava.mop.OJClass.forClass( Printable.class );
        addInterface( newface );
        OJMethod facemtd = newface.getMethod( "print", new OJClass[0] );
        OJMethod impmtd = new OJMethod( this, facemtd.getModifiers().remove( OJModifier.ABSTRACT ), facemtd.getReturnType(), facemtd.getName(), facemtd.getParameterTypes(), facemtd.getExceptionTypes(), null );
        addMethod( impmtd );
        StatementList body = makeStatementList( "this.write(java.lang.System.out);" );
        impmtd.setBody( body );
    }

    public AutoAdaptationClass( openjava.mop.Environment oj_param0, openjava.mop.OJClass oj_param1, openjava.ptree.ClassDeclaration oj_param2 )
    {
        super( oj_param0, oj_param1, oj_param2 );
    }

    public AutoAdaptationClass( java.lang.Class oj_param0, openjava.mop.MetaInfo oj_param1 )
    {
        super( oj_param0, oj_param1 );
    }

}