summaryrefslogtreecommitdiff
path: root/tutorial/Introduction.html
blob: fdec2c2f3a3d0ac8b79a7e8c24c86df334df195d (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> 
<html>


<head>
<title>OpenJava : Tutorial</title>
<meta http-equiv="Keywords" content="java, openjava, reflection">
</head>


<body bgcolor="white"
        text="#000000" link="#007fff" vlink="#006fdf" alink="#ff0000">


<!---------------------------------------------------------------------->


<center>

<h1><font color="Blue">OpenJava Tutorial</font></h1>

</center>


<!---------------------------------------------------------------------->
<hr width="100%">
<!---------------------------------------------------------------------->


<h2>1. <font color="blue">Introduction</font></h2>


<p>OpenJava is an extensible language based on Java. The extended
features of OpenJava are specified by a meta-level program given at
compile time. For distinction, programs written in OpenJava are called
base-level programs. If no meta-level program is given, OpenJava is
identical to regular Java.

<p>The meta-level program extends OpenJava through the interface
called the OpenJava MOP (Metaobject Protocol). The OpenJava compiler
consists of three stages: preprocessor, source-to-source translator
from OpenJava to Java, and the back-end Java compiler. The OpenJava
MOP is an interface to control the translator at the second stage. It
allows to specify how an extended feature of OpenJava is translated
into regular Java code.

<p>An extended feature of OpenJava is supplied as an add-on software
for the compiler. The add-on software consists of not only the
meta-level program but runtime support code. The runtime support code
provides classes used by the base-level program translated into
Java. The base-level program in OpenJava is first translated into Java
by the meta-level program and is dynamically linked with the runtime
support code.  This flow is illustrated by Figure 1.

<center>
<img src="images/comflow.gif"><br>
Figure 1 : Data Flow of OpenJava Compiler
</center>

<p>The meta-level program is written in Java, accurately in OpenJava
because OpenJava is a self-reflective language. It defines new
metaobjects to control source-to-source translation. The metaobjects
are the meta-level representation of the base-level program and they
perform the translation. Details of the metaobjects are specified by
the OpenJava MOP. In the following, we go through a few examples so
that we illustrate how the OpenJava MOP is used to implement language
extensions.
<p>


<!---------------------------------------------------------------------->
<hr width="100%">
<!---------------------------------------------------------------------->


<center>

Please send any message to :
<address>
mich@acm.org
</address><BR>

</center>


<font size=1>Copyright (C) 1999 by Michaki Tatsubori.</font><br>
<font size=1>Java(TM) is a trademark of Sun Microsystems, Inc.</font>


<!---------------------------------------------------------------------->


</body>


</html>