From ea3e1b949dcbdc09518f17eee0bcf21d41d76896 Mon Sep 17 00:00:00 2001 From: Kenny Ballou Date: Mon, 19 Nov 2018 22:59:50 -0700 Subject: OJ (aka OpenJava) modernization/mirroring Signed-off-by: Kenny Ballou --- tutorial/examples/copy/CopiedClass.oj | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tutorial/examples/copy/CopiedClass.oj (limited to 'tutorial/examples/copy/CopiedClass.oj') diff --git a/tutorial/examples/copy/CopiedClass.oj b/tutorial/examples/copy/CopiedClass.oj new file mode 100644 index 0000000..7799f59 --- /dev/null +++ b/tutorial/examples/copy/CopiedClass.oj @@ -0,0 +1,37 @@ +/* + * CopiedClass.oj + * + * @author Michiaki Tatsubori + * @see java.lang.Object + * + * COPYRIGHT 1999 by Michiaki Tatsubori, ALL RIGHTS RESERVED. + */ +package examples.copy; + + +import openjava.mop.*; +import openjava.ptree.*; +import openjava.syntax.*; +import openjava.ptree.util.TypeNameQualifier; + + +public class CopiedClass instantiates Metaclass extends OJClass +{ + /* overrides for translation */ + public convenient void translateDefinition() throws MOPException { + String newqname = getName() + "Shadow"; + OJClass shadow = makeCopy( newqname ); + /*** + ClassDeclaration org = getSourceCode(); + ClassDeclaration copy = (ClassDeclaration) org.makeRecursiveCopy(); + String pack = Environment.toPackageName( newqname ); + String sname = Environment.toSimpleName( newqname ); + copy.setName( sname ); + copy.accept( new TypeNameQualifier( getEnvironment(), sname ) ); + FileEnvironment env = new FileEnvironment( OJSystem.env, pack, sname ); + OJClass shadow = new OJClass( env, null, copy ); + ***/ + OJSystem.addNewClass( shadow ); + } + +} -- cgit v1.2.1