http://wiki.erights.org/mediawiki/index.php?title=Walnut/Ordinary_Programming/Interfacing_to_Java&feed=atom&action=historyWalnut/Ordinary Programming/Interfacing to Java - Revision history2024-03-19T02:19:16ZRevision history for this page on the wikiMediaWiki 1.15.5-7http://wiki.erights.org/mediawiki/index.php?title=Walnut/Ordinary_Programming/Interfacing_to_Java&diff=1522&oldid=prevThomasLeonard: /* Arrays and Java types */2011-09-12T12:12:46Z<p><span class="autocomment">Arrays and Java types</span></p>
<p><b>New page</b></p><div>[[Category:Walnut|2]]<br />
<br />
===Interfacing to Java===<br />
<br />
====Importing classes from the Java API====<br />
<br />
We can import a class from the underlying Java virtual machine with the import statement, and speak to the Java object much as we would speak to an E object: <span class="note" style="color:red">replace vector as example</span><br />
<br />
<pre><br />
<br />
<nowiki># E sample<br />
#create a single vector with a direct call to Java<br />
def myVector := <unsafe:java.util.makeVector>()<br />
myVector.addElement("abc")<br />
<br />
#create a makeVector function which can be called repeatedly to make more vectors<br />
def makeVector := <unsafe:java.util.makeVector><br />
def vector2 := makeVector()<br />
<br />
# create a shorthand for the java.util package, that gives quick access to all the <br />
# classes in java.util<br />
def <util> := <unsafe:java.util.*><br />
def vector3 := <util:makeVector>()</nowiki><br />
</pre><br />
<br />
In the example, we showed 3 ways of getting a Java object, which are roughly comparable to the different styles of using "import" in Java. If you just want one vector, you can get it by directly calling the vector constructor. If you plan to make many vectors, you can import the class into a variable. And if you plan to use many classes in a particular package, you can create your own representative for the package that you can use instead of "&lt;unsafe&gt;".<br />
<br />
Note that the angle-brackets here are simply syntactic sugar: '''&lt;util&gt;''' is short for '''util__uriGetter''' and '''&lt;util:makeVector&gt;''' is short for '''util__uriGetter.get("makeVector")'''.<br />
<br />
Note also that E prefixes every Java class name with "make". The idea here is to make existing Java classes match the naming conventions of E constructors.<br />
<br />
We have now seen 3 uriGetters, file:, unsafe:, and the programmer-defined util:. Four other uriGetters are also predefined, swing: (for accessing javax.swing) and awt: (for accessing java.awt), resource: (for read-only access to resource files such as images, sounds, and static texts), and import:, described next.<br />
<br />
The import: uriGetter is similar to unsafe:, except it only imports those parts of the Java API that have been audited for capability security and found to convey no authority (see the Appendix for a definition of "authority").<br />
<br />
<font color="#FF0000">Put in link, think of better example. Remove vector from the book. Since the Vector class conveys no authority, you should be able to get a vector with import, but currently you can't.</font><br />
<br />
<pre><br />
def vector4 := <unsafe:java.util.makeVector>()<br />
</pre><br />
<br />
As discussed later with Library Packages and Secure Mobile Code, emakers cannot use unsafe: unless the unsafe__uriGetter is explicitly handed to them. So import: is often useful in these security-aware situations. A complete list of safe versus unsafe classes, and the small percentage of Java API methods which are suppressed for security reasons, are listed in the Appendix.<span class="note">link</span><br />
<br />
&lt;resource&gt; is considered safe, and can therefore be used directly in emakers.<br />
<br />
As noted earlier, <span class="e">''E''</span> does not have an expression to directly represent public static final variables. To use such static finals from a Java class, put parentheses at the end of the variable name, making it syntactically look like a function call, prefix it with "get", uppercase the first letter, and <span class="e">''E''</span> will get the value for you:<br />
<br />
<pre><br />
<br />
<nowiki># E sample<br />
<unsafe:java.util.makeCalendar>.getYEAR()</nowiki><br />
<br />
</pre><br />
<br />
====Speaking to Java objects with superclass/subclass overloaded methods====<br />
<br />
Speaking to Java objects is usually as easy as shown above, where we simply sent myVector an addElement(object) message as if it were an <span class="e">E</span> object. A problem arises with some Java objects if they have overloaded methods for which the only distinguishing mark is the static typing of the parameters in which one of the methods specifies a type that is a superclass of the type in the other method — a rare but not unheard-of situation. {{XXX|coercion causes same problem}} In that case, we need to revert to a more descriptive messaging convention.<br />
<br />
Overloaded methods in Java are presented to E with verbs qualified by the types of the arguments. In this example, we see that the print function for the System.out object is overloaded for both String and Object, with String being a subclass of Object, so the full signature is required:<br />
<br />
<pre><br />
<nowiki>? def out := <unsafe:java.lang.makeSystem>.getOut()<br />
# value: <a PrintStream><br />
<br />
? out.print("abc")<br />
# example problem: <IllegalArgumentException: ...><br />
<br />
? out."print(String)"("abc")</nowiki><br />
</pre><br />
<br />
In general, quotes can be used to name a verb which is not a valid identifier in E syntax. Here, the verb is exactly “<code>print(String)</code>”.<br />
<br />
(Where should the following explanation go?)<br />
To use an example from awt: or swing:, we need our vat to be running with the AWT event loop. Normally this happens by running in a vat spawned to run a "*.e-awt" file. <tt>currentVat.morphInto("awt")</tt> asks the current vat to start executing instead in the awt event loop. It returns a promise which resolves to null or broken once this operation succeeds or fails. <tt>? interp.waitAtTop(p)</tt> pauses our interpreter (E's read-eval-print loop) until p is resolved.<br />
<br />
<pre><br />
? interp.waitAtTop(currentVat.morphInto("awt"))<br />
</pre><br />
<br />
Now that that's done, we can proceed to the next example.<br />
<br />
<pre><br />
<nowiki>? def myLabel := <swing:makeJLabel>."run(String)"("label text")</nowiki><br />
</pre><br />
<br />
If you encounter one of these special cases that requires multiple parameters, the signatures must be laid out with exact spelling and exact spacing, notably with exactly one space between the comma and the next signature:<br />
<br />
<pre><br />
javaObject."method(String, int)"("abc", 23)<br />
</pre><br />
<br />
Accessing functions in the java.lang.Math class are a particularly interesting case. Some of these functions are overloaded on float, double and perhaps int and long. While E does not support float and has a different view of integers, it still sees these functions as overloaded. Accessing the correct function is simple, if verbose:<br />
<br />
<pre><br />
def Math := <unsafe:java.lang.makeMath><br />
def abs(value) {<br />
return Math."abs(double)"(value)<br />
}<br />
</pre><br />
<br />
====Arrays and Java types====<br />
<br />
If you call a Java method which requires an array and you pass in an E list, E will automatically convert it. For example, to create a Java BigInteger from an EList of ints, you can just do:<br />
<br />
? def makeBigInteger := <import:java.math.makeBigInteger><br />
# value: <makeBigInteger><br />
? def x := makeBigInteger([1, 2])<br />
# value: 258<br />
<br />
E automatically converts from its own EList type to the required int[] type in this case.<br />
<br />
However, if the Java method took an Object argument then E would pass it an EList directly. You can use E's conversion features from your own Java code using E.as():<br />
<br />
import org.erights.e.elib.prim.E;<br />
<br />
public class Test {<br />
public Test(Object obj) {<br />
System.out.println("obj = " + obj + ", of type " + obj.getClass());<br />
<br />
String[] list = (String[]) E.as(obj, String[].class);<br />
<br />
System.out.println("list = " + list + ", of type " + list.getClass());<br />
}<br />
}<br />
<br />
When called from E:<br />
<br />
? <unsafe:makeTest>(["foo", "bar"])<br />
obj = ["foo", "bar"], of type class org.erights.e.elib.tables.ConstListImpl<br />
list = [Ljava.lang.String;@39cd2b99, of type class [Ljava.lang.String;<br />
# value: <a Test><br />
<br />
====Promises====<br />
<br />
Internally, an E promise is an object which, when resolved, holds a pointer to its resolution. From E code, a resolved promise is identical to the resolution, but from Java they are separate objects.<br />
<br />
For example (using the Test class above):<br />
<br />
? def listVow <br />
# value: <Resolver><br />
<br />
? bind listVow := ["foo", "bar"]<br />
# value: ["foo", "bar"]<br />
<br />
? <unsafe:makeTest>(listVow)<br />
obj = ["foo", "bar"], of type class org.erights.e.elib.ref.SwitchableRef<br />
list = [Ljava.lang.String;@5fc9d050, of type class [Ljava.lang.String;<br />
# value: <a Test><br />
<br />
Notice that we now get a '''SwitchableRef''' rather than a '''ConstListImpl'''. Using E.as to coerce it to String[] still works, but you can also do it directly using '''Ref.resolution(vow)''' (which would get you the '''ConstListImpl''').<br />
<br />
====Java Adapters and Interfaces====<br />
<br />
As described earlier, you can use the match[verb,args] construct to aid in writing adapters and other objects that must meet a Java interface specification. <span class="e">''E''</span> will automatically manipulate the resulting <span class="e">''E''</span> objects and the java virtual machine so that Java understands that the <span class="e">''E''</span> object meets the interface specification. It is not possible to make subclasses of Java classes in <span class="e">''E''</span>. However, because the developers of the Java API have wisely moved aggressively to make sure that interfaces, rather than subclasses, are core to Java object interoperability, there is virtually no Java interfacing goal that cannot be achieved with this machinery.<br />
<br />
====The Java API versus capability security====<br />
<br />
A final note: almost all of the objects and methods in the Java API are available in <span class="e">''E''</span> for version 1.0 through the unsafe_uriGetter; unfortunately very few have been audited sufficiently to be included with the import__uriGetter. In the future, more of the API will be accessible through the import__uriGetter; however, some parts of the Java API will be altered and/or suppressed even in unsafe__uriGetter to achieve a more secure yet easier to use computing framework. This is discussed further in the chapter on Mobile Code. You can see the list of suppressed methods and unsafe classes [http://www.erights.org/javadoc/index.html in the Javadoc].</div>ThomasLeonardhttp://wiki.erights.org/mediawiki/index.php?title=Walnut/Ordinary_Programming/Interfacing_to_Java&diff=2663&oldid=prevThomasLeonard: /* Arrays and primitive types */2011-09-12T12:06:06Z<p><span class="autocomment">Arrays and primitive types</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 12:06, 12 September 2011</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 99:</td>
<td colspan="2" class="diff-lineno">Line 99:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>====Arrays and <del class="diffchange diffchange-inline">primitive </del>types====</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>====Arrays and <ins class="diffchange diffchange-inline">Java </ins>types====</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">It is possible </del>to <del class="diffchange diffchange-inline">make </del>Java <del class="diffchange diffchange-inline">arrays </del>of <del class="diffchange diffchange-inline">Java primitive types</del>, <del class="diffchange diffchange-inline">as in this example</del>:</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">If you call a Java method which requires an array and you pass in an E list, E will automatically convert it. For example, </ins>to <ins class="diffchange diffchange-inline">create a </ins>Java <ins class="diffchange diffchange-inline">BigInteger from an EList </ins>of <ins class="diffchange diffchange-inline">ints</ins>, <ins class="diffchange diffchange-inline">you can just do</ins>:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><<del class="diffchange diffchange-inline">pre</del>></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> ? def makeBigInteger := </ins><<ins class="diffchange diffchange-inline">import:java.math.makeBigInteger</ins>></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> # value: <makeBigInteger></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> ? def x := makeBigInteger([1, 2])</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> # value: 258</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> <nowiki># </del>E <del class="diffchange diffchange-inline">sample</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>E <ins class="diffchange diffchange-inline">automatically converts from its own EList </ins>type <ins class="diffchange diffchange-inline">to the required int</ins>[] <ins class="diffchange diffchange-inline">type in this case.</ins></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> def makeFlexList := <elib:tables.makeFlexList></del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> def byteArray := makeFlexList.fromType(<</del>type<del class="diffchange diffchange-inline">:byte>, 300)</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> byteArray.setSize(300)</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> byteArray</del>[<del class="diffchange diffchange-inline">0</del>] <del class="diffchange diffchange-inline">:= 3</nowiki></del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"></pre></del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">However, if the Java method took an Object argument then E would pass it an EList directly. You can use E's conversion features from your own Java code using E.as():</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">Here we have created a 300-element editable array </del>of <del class="diffchange diffchange-inline">bytes</del>. <del class="diffchange diffchange-inline">The individual elements can be accessed with square bracket notation</del>.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> import org.erights.e.elib.prim.E;</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> public class Test {</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> public Test(Object obj) {</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> System.out.println("obj = " + obj + ", </ins>of <ins class="diffchange diffchange-inline">type " + obj</ins>.<ins class="diffchange diffchange-inline">getClass());</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> String[] list = (String[]) E.as(obj, String[].class);</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> </ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> System.out.println("list = " + list + ", of type " + list</ins>.<ins class="diffchange diffchange-inline">getClass());</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> }</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> }</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><<del class="diffchange diffchange-inline">font color</del>="<del class="diffchange diffchange-inline">#FF0000</del>"<del class="diffchange diffchange-inline">>XXX Now that this example has been corrected</del>, <del class="diffchange diffchange-inline">does it still serve its purpose? Also</del>, <del class="diffchange diffchange-inline">it's not technically correct to say this makes a Java array</del>. <del class="diffchange diffchange-inline">It makes an E FlexList, which, on E-on-Java, currently happens to be implemented by wrapping a Java array</del>. <del class="diffchange diffchange-inline">However, if your program depends on this fact</del>, <del class="diffchange diffchange-inline">it is probably broken</del>. <<del class="diffchange diffchange-inline">/font</del>></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">When called from E:</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> ? </ins><<ins class="diffchange diffchange-inline">unsafe:makeTest>(["foo", "bar"])</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> obj </ins>= <ins class="diffchange diffchange-inline">[</ins>"<ins class="diffchange diffchange-inline">foo</ins>", <ins class="diffchange diffchange-inline">"bar"]</ins>, <ins class="diffchange diffchange-inline">of type class org</ins>.<ins class="diffchange diffchange-inline">erights</ins>.<ins class="diffchange diffchange-inline">e.elib.tables.ConstListImpl</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> list = [Ljava.lang.String;@39cd2b99</ins>, <ins class="diffchange diffchange-inline">of type class [Ljava</ins>.<ins class="diffchange diffchange-inline">lang.String;</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"> # value: </ins><<ins class="diffchange diffchange-inline">a Test</ins>></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>====Java Adapters and Interfaces====</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>====Java Adapters and Interfaces====</div></td></tr>
<!-- diff generator: internal 2024-03-19 02:19:17 -->
</table>ThomasLeonardhttp://wiki.erights.org/mediawiki/index.php?title=Walnut/Ordinary_Programming/Interfacing_to_Java&diff=2662&oldid=prevKevin Reid: /* Speaking to Java objects with superclass/subclass overloaded methods */ use verb-string syntax, misc markup/copyediting2011-03-12T01:44:35Z<p><span class="autocomment">Speaking to Java objects with superclass/subclass overloaded methods: </span> use verb-string syntax, misc markup/copyediting</p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 01:44, 12 March 2011</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 55:</td>
<td colspan="2" class="diff-lineno">Line 55:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>====Speaking to Java objects with superclass/subclass overloaded methods====</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>====Speaking to Java objects with superclass/subclass overloaded methods====</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>Speaking to Java objects is usually as easy as shown above, where we simply sent myVector an addElement(object) message as if it were an <span class="e"><del class="diffchange diffchange-inline">''</del>E<del class="diffchange diffchange-inline">''</del></span> object. A problem arises with some Java objects if they have overloaded methods for which the only distinguishing mark is the static typing of the parameters in which one of the methods specifies a type that is a superclass of the type in the other method<del class="diffchange diffchange-inline">--</del>a rare but not unheard-of situation. <del class="diffchange diffchange-inline"><span class="note" style="color:red"></del>coercion causes same problem<del class="diffchange diffchange-inline"></span></del>In that case, we need to revert to a more descriptive messaging convention.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>Speaking to Java objects is usually as easy as shown above, where we simply sent myVector an addElement(object) message as if it were an <span class="e">E</span> object. A problem arises with some Java objects if they have overloaded methods for which the only distinguishing mark is the static typing of the parameters in which one of the methods specifies a type that is a superclass of the type in the other method <ins class="diffchange diffchange-inline">— </ins>a rare but not unheard-of situation. <ins class="diffchange diffchange-inline">{{XXX|</ins>coercion causes same problem<ins class="diffchange diffchange-inline">}} </ins>In that case, we need to revert to a more descriptive messaging convention.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">We introduced the E.call() function earlier for communicating with E objects. It can also be used to call </del>Java <del class="diffchange diffchange-inline">objects and </del>to <del class="diffchange diffchange-inline">specify the signature of an overloaded method </del>with the types of the <del class="diffchange diffchange-inline">parameters</del>. In this example, we see that the print function for the System.out object is overloaded for both String and Object, with String being a subclass of Object, so the full signature is required:</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">Overloaded methods in </ins>Java <ins class="diffchange diffchange-inline">are presented </ins>to <ins class="diffchange diffchange-inline">E </ins>with <ins class="diffchange diffchange-inline">verbs qualified by </ins>the types of the <ins class="diffchange diffchange-inline">arguments</ins>. In this example, we see that the print function for the System.out object is overloaded for both String and Object, with String being a subclass of Object, so the full signature is required:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 66:</td>
<td colspan="2" class="diff-lineno">Line 66:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # example problem: <IllegalArgumentException: ...></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # example problem: <IllegalArgumentException: ...></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> ? <del class="diffchange diffchange-inline">E.call(</del>out<del class="diffchange diffchange-inline">, </del>"print(String)"<del class="diffchange diffchange-inline">, [</del>"abc"<del class="diffchange diffchange-inline">]</del>)</nowiki></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> ? <ins class="diffchange diffchange-inline"> </ins>out<ins class="diffchange diffchange-inline">.</ins>"print(String)"<ins class="diffchange diffchange-inline">(</ins>"abc")</nowiki></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">In general, quotes can be used to name a verb which is not a valid identifier in E syntax. Here, the verb is exactly “<code>print(String)</code>”.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>(Where should the following explanation go?)</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>(Where should the following explanation go?)</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 79:</td>
<td colspan="2" class="diff-lineno">Line 81:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> <nowiki>? def myLabel := <del class="diffchange diffchange-inline">E.call(</del><swing:makeJLabel><del class="diffchange diffchange-inline">, </del>"run(String)"<del class="diffchange diffchange-inline">,[</del>"label text"<del class="diffchange diffchange-inline">]</del>)</nowiki></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> <nowiki>? def myLabel := <swing:makeJLabel><ins class="diffchange diffchange-inline">.</ins>"run(String)"<ins class="diffchange diffchange-inline">(</ins>"label text")</nowiki></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 85:</td>
<td colspan="2" class="diff-lineno">Line 87:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> <del class="diffchange diffchange-inline">E</del>.<del class="diffchange diffchange-inline">call(javaObject, </del>"method(String, int)"<del class="diffchange diffchange-inline">, [</del>"abc", 23<del class="diffchange diffchange-inline">]</del>)</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> <ins class="diffchange diffchange-inline">javaObject</ins>."method(String, int)"<ins class="diffchange diffchange-inline">(</ins>"abc", 23)</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 93:</td>
<td colspan="2" class="diff-lineno">Line 95:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>def Math := <unsafe:java.lang.makeMath></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>def Math := <unsafe:java.lang.makeMath></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>def abs(value) {</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>def abs(value) {</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> return <del class="diffchange diffchange-inline">E.call(</del>Math<del class="diffchange diffchange-inline">, </del>"abs(double)"<del class="diffchange diffchange-inline">, [</del>value<del class="diffchange diffchange-inline">]</del>)</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> return Math<ins class="diffchange diffchange-inline">.</ins>"abs(double)"<ins class="diffchange diffchange-inline">(</ins>value)</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>}</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>}</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<!-- diff generator: internal 2024-03-19 02:19:17 -->
</table>Kevin Reidhttp://wiki.erights.org/mediawiki/index.php?title=Walnut/Ordinary_Programming/Interfacing_to_Java&diff=2661&oldid=prev173.75.83.140: /* Speaking to Java objects with superclass/subclass overloaded methods */2011-03-12T01:26:39Z<p><span class="autocomment">Speaking to Java objects with superclass/subclass overloaded methods</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 01:26, 12 March 2011</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 88:</td>
<td colspan="2" class="diff-lineno">Line 88:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>Accessing functions in the java.lang.Math class are a particularly interesting case. Some of these functions are overloaded on float, double and perhaps int and long. While E does not support float and has a different view of integers, it still sees these functions as overloaded. Accessing the correct function is simple,if verbose:</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>Accessing functions in the java.lang.Math class are a particularly interesting case. Some of these functions are overloaded on float, double and perhaps int and long. While E does not support float and has a different view of integers, it still sees these functions as overloaded. Accessing the correct function is simple, if verbose:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td></tr>
<!-- diff generator: internal 2024-03-19 02:19:17 -->
</table>173.75.83.140http://wiki.erights.org/mediawiki/index.php?title=Walnut/Ordinary_Programming/Interfacing_to_Java&diff=2660&oldid=prev173.75.83.140: /* Speaking to Java objects with superclass/subclass overloaded methods */2011-03-12T01:11:33Z<p><span class="autocomment">Speaking to Java objects with superclass/subclass overloaded methods</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 01:11, 12 March 2011</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 88:</td>
<td colspan="2" class="diff-lineno">Line 88:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>Accessing functions in the java.lang.Math class are a particularly interesting case. <del class="diffchange diffchange-inline">Most </del>of these <del class="diffchange diffchange-inline">mathematical </del>functions are overloaded on float <del class="diffchange diffchange-inline">and </del>double. While E does not support float, it still sees these functions as overloaded. Accessing the correct function is simple,if verbose:</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>Accessing functions in the java.lang.Math class are a particularly interesting case. <ins class="diffchange diffchange-inline">Some </ins>of these functions are overloaded on float<ins class="diffchange diffchange-inline">, </ins>double <ins class="diffchange diffchange-inline">and perhaps int and long</ins>. While E does not support float <ins class="diffchange diffchange-inline">and has a different view of integers</ins>, it still sees these functions as overloaded. Accessing the correct function is simple,if verbose:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td></tr>
<!-- diff generator: internal 2024-03-19 02:19:18 -->
</table>173.75.83.140http://wiki.erights.org/mediawiki/index.php?title=Walnut/Ordinary_Programming/Interfacing_to_Java&diff=2659&oldid=prev173.75.83.140: /* Speaking to Java objects with superclass/subclass overloaded methods */2011-03-12T01:01:27Z<p><span class="autocomment">Speaking to Java objects with superclass/subclass overloaded methods</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 01:01, 12 March 2011</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 86:</td>
<td colspan="2" class="diff-lineno">Line 86:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> E.call(javaObject, "method(String, int)", ["abc", 23])</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> E.call(javaObject, "method(String, int)", ["abc", 23])</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></pre></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">Accessing functions in the java.lang.Math class are a particularly interesting case. Most of these mathematical functions are overloaded on float and double. While E does not support float, it still sees these functions as overloaded. Accessing the correct function is simple,if verbose:</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"><pre></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">def Math := <unsafe:java.lang.makeMath></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">def abs(value) {</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"> return E.call(Math, "abs(double)", [value])</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">}</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<!-- diff generator: internal 2024-03-19 02:19:18 -->
</table>173.75.83.140http://wiki.erights.org/mediawiki/index.php?title=Walnut/Ordinary_Programming/Interfacing_to_Java&diff=2658&oldid=prevThomasLeonard: /* Importing classes from the Java API */2010-10-21T13:57:49Z<p><span class="autocomment">Importing classes from the Java API</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 13:57, 21 October 2010</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 32:</td>
<td colspan="2" class="diff-lineno">Line 32:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>We have now seen 3 uriGetters, file:, unsafe:, and the programmer-defined util:. Four other uriGetters are also predefined, swing: (for accessing javax.swing) and awt: (for accessing java.awt), resource: (for read-only access to resource files such as images, sounds, and static texts), and import:, described next.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>We have now seen 3 uriGetters, file:, unsafe:, and the programmer-defined util:. Four other uriGetters are also predefined, swing: (for accessing javax.swing) and awt: (for accessing java.awt), resource: (for read-only access to resource files such as images, sounds, and static texts), and import:, described next.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>The import: uriGetter is similar to unsafe:, except it only imports those parts of the Java API that have been audited for capability security and found to convey no authority (see the Appendix for a definition of "authority").<<del class="diffchange diffchange-inline">span class</del>="<del class="diffchange diffchange-inline">note</del>"><del class="diffchange diffchange-inline">put </del>in link, think of better example. Remove vector from the book<del class="diffchange diffchange-inline"></span> </del>Since the Vector class <del class="diffchange diffchange-inline"><font color="#FF0000"></del>conveys no authority, you <del class="diffchange diffchange-inline">could also </del>get a vector with import</font<del class="diffchange diffchange-inline">><nowiki>:</nowiki</del>></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>The import: uriGetter is similar to unsafe:, except it only imports those parts of the Java API that have been audited for capability security and found to convey no authority (see the Appendix for a definition of "authority").</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><<ins class="diffchange diffchange-inline">font color</ins>="<ins class="diffchange diffchange-inline">#FF0000</ins>"><ins class="diffchange diffchange-inline">Put </ins>in link, think of better example. Remove vector from the book<ins class="diffchange diffchange-inline">. </ins>Since the Vector class conveys no authority, you <ins class="diffchange diffchange-inline">should be able to </ins>get a vector with import<ins class="diffchange diffchange-inline">, but currently you can't.</ins></font></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def vector4 := <unsafe:java.util.makeVector>()</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def vector4 := <unsafe:java.util.makeVector>()</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>As discussed later with Library Packages and Secure Mobile Code, emakers cannot use unsafe: unless the unsafe__uriGetter is explicitly handed to them. So import: is often useful in these security-aware situations. A complete list of safe versus unsafe classes, and the small percentage of Java API methods which are suppressed for security reasons, are listed in the Appendix.<span class="note">link</span></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>As discussed later with Library Packages and Secure Mobile Code, emakers cannot use unsafe: unless the unsafe__uriGetter is explicitly handed to them. So import: is often useful in these security-aware situations. A complete list of safe versus unsafe classes, and the small percentage of Java API methods which are suppressed for security reasons, are listed in the Appendix.<span class="note">link</span></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>resource<del class="diffchange diffchange-inline">: mention it </del>is safe, can be used in emakers</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">&lt;</ins>resource<ins class="diffchange diffchange-inline">&gt; </ins>is <ins class="diffchange diffchange-inline">considered </ins>safe, <ins class="diffchange diffchange-inline">and </ins>can <ins class="diffchange diffchange-inline">therefore </ins>be used <ins class="diffchange diffchange-inline">directly </ins>in emakers.</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">getting static public constants from Java: must put parens after the name as if it was a method returning a value, not a variable</del>.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>As noted earlier, <span class="e">''E''</span> does not have an expression to directly represent public static final variables. To use such static finals from a Java class, put parentheses at the end of the variable name, making it syntactically look like a function call, prefix it with "get", uppercase the first letter, and <span class="e">''E''</span> will get the value for you:</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>As noted earlier, <span class="e">''E''</span> does not have an expression to directly represent public static final variables. To use such static finals from a Java class, put parentheses at the end of the variable name, making it syntactically look like a function call, prefix it with "get", uppercase the first letter, and <span class="e">''E''</span> will get the value for you:</div></td></tr>
<!-- diff generator: internal 2024-03-19 02:19:18 -->
</table>ThomasLeonardhttp://wiki.erights.org/mediawiki/index.php?title=Walnut/Ordinary_Programming/Interfacing_to_Java&diff=2657&oldid=prevThomasLeonard: /* Importing classes from the Java API */2010-10-21T13:49:16Z<p><span class="autocomment">Importing classes from the Java API</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 13:49, 21 October 2010</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 26:</td>
<td colspan="2" class="diff-lineno">Line 26:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>In the example, we showed 3 ways of getting a Java object, which are roughly comparable to the different styles of using "import" in Java. If you just want one vector, you can get it by directly calling the vector constructor. If you plan to make many vectors, you can import the class into a variable. And if you plan to use many classes in a particular package, you can create your own representative for the package that you can use instead of "&lt;unsafe&gt;".</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>In the example, we showed 3 ways of getting a Java object, which are roughly comparable to the different styles of using "import" in Java. If you just want one vector, you can get it by directly calling the vector constructor. If you plan to make many vectors, you can import the class into a variable. And if you plan to use many classes in a particular package, you can create your own representative for the package that you can use instead of "&lt;unsafe&gt;".</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>Note that the angle-brackets here are simply syntactic sugar: '''&lt;util&gt;'''<del class="diffchange diffchange-inline">; </del>is short for '''util__uriGetter''' and '''&lt;util:makeVector&gt;''' is short for '''util__uriGetter.get("makeVector")'''.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>Note that the angle-brackets here are simply syntactic sugar: '''&lt;util&gt;''' is short for '''util__uriGetter''' and '''&lt;util:makeVector&gt;''' is short for '''util__uriGetter.get("makeVector")'''.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Note also that E prefixes every Java class name with "make". The idea here is to make existing Java classes match the naming conventions of E constructors.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Note also that E prefixes every Java class name with "make". The idea here is to make existing Java classes match the naming conventions of E constructors.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>We have now seen 3 <del class="diffchange diffchange-inline">of these </del>uriGetters, file:, unsafe:, and the programmer-defined util:. Four other uriGetters are also predefined, swing: (for accessing javax.swing) and awt: (for accessing java.awt), resource: (for read-only access to resource files such as images, sounds, and static texts), and import:, described next.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>We have now seen 3 uriGetters, file:, unsafe:, and the programmer-defined util:. Four other uriGetters are also predefined, swing: (for accessing javax.swing) and awt: (for accessing java.awt), resource: (for read-only access to resource files such as images, sounds, and static texts), and import:, described next.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>The import: uriGetter is similar to unsafe:, except it only imports those parts of the Java API that have been audited for capability security and found to convey no authority (see the Appendix for a definition of "authority").<span class="note">put in link, think of better example. Remove vector from the book</span> Since the Vector class <font color="#FF0000">conveys no authority, you could also get a vector with import</font><nowiki>:</nowiki></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>The import: uriGetter is similar to unsafe:, except it only imports those parts of the Java API that have been audited for capability security and found to convey no authority (see the Appendix for a definition of "authority").<span class="note">put in link, think of better example. Remove vector from the book</span> Since the Vector class <font color="#FF0000">conveys no authority, you could also get a vector with import</font><nowiki>:</nowiki></div></td></tr>
<!-- diff generator: internal 2024-03-19 02:19:18 -->
</table>ThomasLeonardhttp://wiki.erights.org/mediawiki/index.php?title=Walnut/Ordinary_Programming/Interfacing_to_Java&diff=2656&oldid=prevThomasLeonard: /* Interfacing to Java */2010-10-21T13:48:05Z<p><span class="autocomment">Interfacing to Java</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 13:48, 21 October 2010</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 13:</td>
<td colspan="2" class="diff-lineno">Line 13:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def myVector := <unsafe:java.util.makeVector>()</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def myVector := <unsafe:java.util.makeVector>()</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> myVector.addElement("abc")</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> myVector.addElement("abc")</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> #create a makeVector function which can be called repeatedly to make more vectors</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> #create a makeVector function which can be called repeatedly to make more vectors</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def makeVector := <unsafe:java.util.makeVector></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def makeVector := <unsafe:java.util.makeVector></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def vector2 := makeVector()</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def vector2 := makeVector()</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # create a shorthand for the java.util package, that gives quick access to all the </div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # create a shorthand for the java.util package, that gives quick access to all the </div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # classes in java.util</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # classes in java.util</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def <util> := <unsafe:java.util.*></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def <util> := <unsafe:java.util.*></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def vector3 := <util:makeVector>()</nowiki></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> def vector3 := <util:makeVector>()</nowiki></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>In the example, we showed 3 ways of getting a Java object, which are roughly comparable to the different styles of using "import" in Java. If you just want one vector, you can get it by directly calling the vector constructor. If you plan to make many vectors, you can import the class into a variable. And if you plan to use many classes in a particular package, you can create your own representative for the package that you can use instead of "unsafe<del class="diffchange diffchange-inline">:</del>". <del class="diffchange diffchange-inline"><span class=</del>"<del class="diffchange diffchange-inline">warn</del>"<del class="diffchange diffchange-inline">>fix</span></del>Note <del class="diffchange diffchange-inline">the suffix </del>"<del class="diffchange diffchange-inline">__uriGetter</del>" <del class="diffchange diffchange-inline">on the util variable</del>. <del class="diffchange diffchange-inline">This </del>is <del class="diffchange diffchange-inline">a special suffix that allows the variable </del>to <del class="diffchange diffchange-inline">be used in statements of </del>the <del class="diffchange diffchange-inline">form <uri:name></del>.</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>In the example, we showed 3 ways of getting a Java object, which are roughly comparable to the different styles of using "import" in Java. If you just want one vector, you can get it by directly calling the vector constructor. If you plan to make many vectors, you can import the class into a variable. And if you plan to use many classes in a particular package, you can create your own representative for the package that you can use instead of "<ins class="diffchange diffchange-inline">&lt;</ins>unsafe<ins class="diffchange diffchange-inline">&gt;</ins>".</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">Note that the angle-brackets here are simply syntactic sugar: '''&lt;util&gt;'''; is short for '''util__uriGetter''' and '''&lt;util:makeVector&gt;''' is short for '''util__uriGetter.get(</ins>"<ins class="diffchange diffchange-inline">makeVector</ins>"<ins class="diffchange diffchange-inline">)'''.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>Note <ins class="diffchange diffchange-inline">also that E prefixes every Java class name with </ins>"<ins class="diffchange diffchange-inline">make</ins>". <ins class="diffchange diffchange-inline">The idea here </ins>is to <ins class="diffchange diffchange-inline">make existing Java classes match </ins>the <ins class="diffchange diffchange-inline">naming conventions of E constructors</ins>.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>We have now seen 3 of these uriGetters, file:, unsafe:, and the programmer-defined util:. Four other uriGetters are also predefined, swing: (for accessing javax.swing) and awt: (for accessing java.awt), resource: (for read-only access to resource files such as images, sounds, and static texts), and import:, described next.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>We have now seen 3 of these uriGetters, file:, unsafe:, and the programmer-defined util:. Four other uriGetters are also predefined, swing: (for accessing javax.swing) and awt: (for accessing java.awt), resource: (for read-only access to resource files such as images, sounds, and static texts), and import:, described next.</div></td></tr>
<!-- diff generator: internal 2024-03-19 02:19:18 -->
</table>ThomasLeonardhttp://wiki.erights.org/mediawiki/index.php?title=Walnut/Ordinary_Programming/Interfacing_to_Java&diff=2655&oldid=prevMarkm: /* Speaking to Java objects with superclass/subclass overloaded methods */2006-12-04T08:35:10Z<p><span class="autocomment">Speaking to Java objects with superclass/subclass overloaded methods</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 08:35, 4 December 2006</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 57:</td>
<td colspan="2" class="diff-lineno">Line 57:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> <nowiki>? def out := <unsafe:java.lang.makeSystem>.getOut()</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> <nowiki>? def out := <unsafe:java.lang.makeSystem>.getOut()</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # value: <a PrintStream></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # value: <a PrintStream></div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 64:</td>
<td colspan="2" class="diff-lineno">Line 63:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # example problem: <IllegalArgumentException: ...></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> # example problem: <IllegalArgumentException: ...></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> ? E.call(out, "print(String)", ["abc"])</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> ? E.call(out, "print(String)", ["abc"])<<ins class="diffchange diffchange-inline">/nowiki</ins>></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> ? def myLabel := E.call(</del><<del class="diffchange diffchange-inline">swing:makeJLabel</del>><del class="diffchange diffchange-inline">, "run(String)",["label text"])</del></<del class="diffchange diffchange-inline">nowiki</del>></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></<ins class="diffchange diffchange-inline">pre</ins>></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">(Where should the following explanation go?)</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">To use an example from awt: or swing:, we need our vat to be running with the AWT event loop. Normally this happens by running in a vat spawned to run a "*.e-awt" file. <tt>currentVat.morphInto("awt")</tt> asks the current vat to start executing instead in the awt event loop. It returns a promise which resolves to null or broken once this operation succeeds or fails. <tt>? interp.waitAtTop(p)</tt> pauses our interpreter (E's read-eval-print loop) until p is resolved.</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"><pre></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"> ? interp.waitAtTop(currentVat.morphInto("awt"))</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">If you encounter one of these special cases </del>that <del class="diffchange diffchange-inline">requires multiple parameters</del>, <del class="diffchange diffchange-inline">the signatures must be laid out with exact spelling and exact spacing, notably with exactly one space between the comma and </del>the next <del class="diffchange diffchange-inline">signature:</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">Now </ins>that <ins class="diffchange diffchange-inline">that's done</ins>, <ins class="diffchange diffchange-inline">we can proceed to </ins>the next <ins class="diffchange diffchange-inline">example.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div><pre></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"> <nowiki>? def myLabel := E.call(<swing:makeJLabel>, "run(String)",["label text"])</nowiki></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></pre></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> E.call(javaObject</del>, <del class="diffchange diffchange-inline">"method(String</del>, <del class="diffchange diffchange-inline">int)", ["abc", 23])</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">If you encounter one of these special cases that requires multiple parameters</ins>, <ins class="diffchange diffchange-inline">the signatures must be laid out with exact spelling and exact spacing</ins>, <ins class="diffchange diffchange-inline">notably with exactly one space between the comma and the next signature:</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"><pre></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"> E.call(javaObject, "method(String, int)", ["abc", 23])</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<!-- diff generator: internal 2024-03-19 02:19:18 -->
</table>Markm