My hobbyist coding updates and releases as the mysterious "Mr. Tines"

Wednesday, 30 January 2008

A tower of Babel

package com_ravnaandtines.jlayer;
public class JClass1
    public JClass1()
    public int doSomething(String arg)
        System.out.println("In "+this.getClass().toString()+".doSomething(), printing "+arg);
        return arg.length();
package com_ravnaandtines.slayer

import com_ravnaandtines.jlayer

class SClass(token: String) {
 private val in = new com_ravnaandtines.jlayer.JClass1()
 private val len = in.doSomething(token)
import com_ravnaandtines.jlayer.JClass1

direct = com_ravnaandtines.jlayer.JClass1()
val = direct.doSomething("from Jython")
print val

import com_ravnaandtines.slayer.SClass
x = com_ravnaandtines.slayer.SClass("Hello Babel!")

Build the first into JavaLayer.jar and copy it alongside the second

\scala-2.6.1-final\bin\scalac -classpath .JavaLayer.jar -d classes SClass.scala
cd classes
"\Program Files\Java\jdk1.6.0\bin\jar.exe" -cf ..\ScalaLayer.jar .

Then run the last with the two jars and the scala runtime jar in your path

In class com_ravnaandtines.jlayer.JClass1.doSomething(), printing from Jython
In class com_ravnaandtines.jlayer.JClass1.doSomething(), printing Hello Babel!

I had hoped that I could do the same in .Net, but having built the J# JavaLayer.dll, I got

>\scala-2.6.1-final\bin\scalac-net -d classes -Xassem-path JavaLayer.dll SClass.
error: error while loading Predef, type 'scala.Predef' is broken
($ClassSymbol cannot be cast to scala.runtime.Noth
one error found

so haven't yet managed to make a Scala-derived DLL for IronPython to consume. And that doesn't look like something I might obviously have done wrong.

No comments: