You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any sufficiently advanced technology is indistinguishable from magic.
3
+
</p><divclass="attribution"><span>—<spanclass="attribution">Arthur C. Clarke</span></span></div></div><p>In this section we will examine Java2Script support for java emulation. When you include the j2slib.z.js script in your html documents
4
+
Java2Script provides 2 types of APIs: </p><divclass="itemizedlist"><ulclass="itemizedlist" type="disc"><liclass="listitem"><ptitle="Java Language API"><b>Java Language API. </b>. As we have seen in .js generated files, the object <codeclass="code">Clazz</code> contains
5
+
methods for that emulates the java language leting the javascript programmer to declare java elements like package, classes, methods and so on.
6
+
</p></li><liclass="listitem"><ptitle="Java Runtime API"><b>Java Runtime API. </b>. As we have seen in the html files generated by Java2Script when we run a J2S application,
7
+
the <codeclass="code">ClazzLoader</code> object contains an API for configuring the java runtime, for example, leting the javascript programmer configure the
8
+
"java classpath", loading a set of classes and executing some java code when those classes are available.
9
+
</p></li></ul></div><p>In this chapter we try to document the relevant API functions of this two javascript objects.</p><divclass="section" title="Java Language Emulation API"><divclass="titlepage"><div><div><h2class="title" style="clear: both"><aname="java-language-emulation-api"></a>Java Language Emulation API</h2></div></div></div><p>When including the script j2slib.z.js, there will be available the object Clazz that contains functions for "doing java" in javascript.
10
+
We have already examine this kind of JavaScript code generated by J2S in <aclass="xref" href="chap-java-to-js-translation.html#examining-generated-js-files" title="Examining generated javascript files">the section called “Examining generated javascript files”</a>. </p><p>a lot of documentation is at http://j2s.sourceforge.net/articles/oop-in-js-by-j2s.html.
11
+
TODO: include that in this section???</p><h3><aname="N107A5"></a>Clazz.defineMethod = function (clazzThis, funName, funBody, funParams)</h3><p>define a java method. the doc says:</p><preclass="programlisting">
12
+
/*
13
+
* Define method for the class with the given method name and method
14
+
* body and method parameter signature.
15
+
*
16
+
* @param clazzThis host class in which the method to be defined
17
+
* @param funName method name
18
+
* @param funBody function object, e.g function () { ... }
0 commit comments