summaryrefslogtreecommitdiff
path: root/tutorial/examples/bca
diff options
context:
space:
mode:
authorKenny Ballou <kballou@devnulllabs.io>2018-11-19 22:59:50 -0700
committerKenny Ballou <kballou@devnulllabs.io>2018-11-19 22:59:50 -0700
commitea3e1b949dcbdc09518f17eee0bcf21d41d76896 (patch)
tree7ec7a7fb4df67815a9b7bb0e4d95d67c4050e2a2 /tutorial/examples/bca
downloadopenjava-ea3e1b949dcbdc09518f17eee0bcf21d41d76896.tar.gz
openjava-ea3e1b949dcbdc09518f17eee0bcf21d41d76896.tar.xz
OJ (aka OpenJava) modernization/mirroring
Signed-off-by: Kenny Ballou <kballou@devnulllabs.io>
Diffstat (limited to 'tutorial/examples/bca')
-rw-r--r--tutorial/examples/bca/AutoAdaptationClass.java53
-rw-r--r--tutorial/examples/bca/AutoAdaptationClass.oj48
-rw-r--r--tutorial/examples/bca/Printable.java7
-rw-r--r--tutorial/examples/bca/RTReflClass.java51
-rw-r--r--tutorial/examples/bca/Test.java24
-rw-r--r--tutorial/examples/bca/Test.oj13
-rw-r--r--tutorial/examples/bca/Test2.java18
-rw-r--r--tutorial/examples/bca/Test2.oj12
-rw-r--r--tutorial/examples/bca/Writable.java10
9 files changed, 236 insertions, 0 deletions
diff --git a/tutorial/examples/bca/AutoAdaptationClass.java b/tutorial/examples/bca/AutoAdaptationClass.java
new file mode 100644
index 0000000..5e088bc
--- /dev/null
+++ b/tutorial/examples/bca/AutoAdaptationClass.java
@@ -0,0 +1,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 );
+ }
+
+}
diff --git a/tutorial/examples/bca/AutoAdaptationClass.oj b/tutorial/examples/bca/AutoAdaptationClass.oj
new file mode 100644
index 0000000..9819bc2
--- /dev/null
+++ b/tutorial/examples/bca/AutoAdaptationClass.oj
@@ -0,0 +1,48 @@
+/*
+ * 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 instantiates Metaclass extends OJClass
+{
+ /** Overrides to translate definition */
+ public convenient void translateDefinition() throws MOPException {
+ /* only the case this class implements Writable */
+ if (! Writable.class.isAssignableFrom( this )) return;
+
+ OJClass newface = 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 );
+ }
+}
diff --git a/tutorial/examples/bca/Printable.java b/tutorial/examples/bca/Printable.java
new file mode 100644
index 0000000..296850e
--- /dev/null
+++ b/tutorial/examples/bca/Printable.java
@@ -0,0 +1,7 @@
+package examples.bca;
+
+
+public interface Printable
+{
+ public void print();
+}
diff --git a/tutorial/examples/bca/RTReflClass.java b/tutorial/examples/bca/RTReflClass.java
new file mode 100644
index 0000000..429b241
--- /dev/null
+++ b/tutorial/examples/bca/RTReflClass.java
@@ -0,0 +1,51 @@
+/*
+ * This code was generated by ojc.
+ */
+/*
+ * RTReflClass.oj
+ *
+ * Source Code Adaptation example.
+ *
+ * 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 RTReflClass extends OJClass
+{
+
+ /** Overrides to translate definition */
+ public void translateDefinition()
+ throws MOPException
+ {
+ if (!openjava.mop.OJClass.forClass( Writable.class ).isAssignableFrom( this )) {
+ return;
+ }
+ addInterface( openjava.mop.OJClass.forClass( Printable.class ) );
+ OJMethod facemtd = getMethod( "write", new OJClass[]{ openjava.mop.OJClass.forClass( java.io.PrintStream.class ) } );
+ OJMethod impmtd = new OJMethod( this, facemtd.getModifiers(), facemtd.getReturnType(), facemtd.getName(), facemtd.getParameterTypes(), facemtd.getExceptionTypes(), null );
+ addMethod( impmtd );
+ StatementList body = makeStatementList( "this.write(java.lang.System.out);" );
+ impmtd.setBody( body );
+ }
+
+ public RTReflClass( openjava.mop.Environment oj_param0, openjava.mop.OJClass oj_param1, openjava.ptree.ClassDeclaration oj_param2 )
+ {
+ super( oj_param0, oj_param1, oj_param2 );
+ }
+
+ public RTReflClass( java.lang.Class oj_param0, openjava.mop.MetaInfo oj_param1 )
+ {
+ super( oj_param0, oj_param1 );
+ }
+
+}
diff --git a/tutorial/examples/bca/Test.java b/tutorial/examples/bca/Test.java
new file mode 100644
index 0000000..5de77d0
--- /dev/null
+++ b/tutorial/examples/bca/Test.java
@@ -0,0 +1,24 @@
+/*
+ * This code was generated by ojc.
+ */
+package examples.bca;
+
+
+import java.io.PrintStream;
+
+
+public class Test implements examples.bca.Writable, examples.bca.Printable
+{
+
+ public void write( PrintStream out )
+ {
+ out.println( "Hello" );
+ }
+
+
+ public void print()
+ {
+ this.write( java.lang.System.out );
+ }
+
+}
diff --git a/tutorial/examples/bca/Test.oj b/tutorial/examples/bca/Test.oj
new file mode 100644
index 0000000..2514028
--- /dev/null
+++ b/tutorial/examples/bca/Test.oj
@@ -0,0 +1,13 @@
+package examples.bca;
+
+
+import java.io.PrintStream;
+
+
+public class Test instantiates AutoAdaptationClass
+ implements Writable
+{
+ public void write(PrintStream out) {
+ out.println( "Hello" );
+ }
+}
diff --git a/tutorial/examples/bca/Test2.java b/tutorial/examples/bca/Test2.java
new file mode 100644
index 0000000..013c360
--- /dev/null
+++ b/tutorial/examples/bca/Test2.java
@@ -0,0 +1,18 @@
+/*
+ * This code was generated by ojc.
+ */
+package examples.bca;
+
+
+import java.io.PrintStream;
+
+
+public class Test2
+{
+
+ public void write( PrintStream out )
+ {
+ out.println( "Hello" );
+ }
+
+}
diff --git a/tutorial/examples/bca/Test2.oj b/tutorial/examples/bca/Test2.oj
new file mode 100644
index 0000000..ca72a4c
--- /dev/null
+++ b/tutorial/examples/bca/Test2.oj
@@ -0,0 +1,12 @@
+package examples.bca;
+
+
+import java.io.PrintStream;
+
+
+public class Test2 instantiates AutoAdaptationClass
+{
+ public void write(PrintStream out) {
+ out.println( "Hello" );
+ }
+}
diff --git a/tutorial/examples/bca/Writable.java b/tutorial/examples/bca/Writable.java
new file mode 100644
index 0000000..f8df297
--- /dev/null
+++ b/tutorial/examples/bca/Writable.java
@@ -0,0 +1,10 @@
+package examples.bca;
+
+
+import java.io.PrintStream;
+
+
+public interface Writable
+{
+ public void write(PrintStream out);
+}