This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Recognize classes written in scheme from java
- From: Marius Kjeldahl <marius at kjeldahl dot net>
- To: kawa at sourceware dot org
- Date: Wed, 17 Jul 2013 00:46:39 +0200
- Subject: Recognize classes written in scheme from java
I'm struggling getting java to recognize kawa classes. Basically my
class "net.kjeldahl.tournman.Something" from Scheme does not get
recognized when I try to compile the rest of the project in java. I get
the following error:
error: cannot find symbol
Toast.makeText(this, Something.hello(),
^
symbol: variable Something
location: class TournmanActivity
I'm not a java expert, but it my understanding that the java compiler
should look for classes in jar or class files found in the classpath. On
this assumption, I've compiled a small scheme module using kawa named
"Something.scm":
(define (myhello)
"Hello world.")
This has been compiled using:
commandLine 'kawa', '-d', 'build/classes/debug', '-P', 'net.kjeldahl.tournman.', '--warn-undefined-variable', '--warn-invoke-unknown-method', '--warn-as-error', '-C', 'src/main/kawa/MyKawaActivity.scm', 'src/main/kawa/Something.scm'
That's copied from a build.gradle script, but if you remove commandLine
and quotes, that's the way it gets executed (yes, there is another scm
file also being compiled on that command line which is not relevant to
my question).
Compilation seems to go fine, here's the javap output showing the
resulting class file:
Compiled from "Something.scm"
public class net.kjeldahl.tournman.Something extends gnu.expr.ModuleBody implements java.lang.Runnable,gnu.expr.RunnableModule {
public static final gnu.expr.ModuleMethod myhello;
public static net.kjeldahl.tournman.Something $instance;
static final gnu.mapping.SimpleSymbol Lit0;
public static java.lang.String myhello();
public final void run(gnu.mapping.CallContext);
public static {};
public net.kjeldahl.tournman.Something();
public int match0(gnu.expr.ModuleMethod, gnu.mapping.CallContext);
public void apply(gnu.mapping.CallContext);
public java.lang.Object apply0(gnu.expr.ModuleMethod);
}
For the hell of it, I compare it to another "simple" java class file
from a java source file that gets compiled and works fine in my program.
Here's the javap output from that class:
Compiled from "MatchHelper.java"
public class net.kjeldahl.tournman.MatchHelper extends android.database.sqlite.SQLiteOpenHelper {
public static final java.lang.String MATCH_COLNAME_ID;
net.kjeldahl.tournman.MatchHelper(android.content.Context);
public void onCreate(android.database.sqlite.SQLiteDatabase);
public void onUpgrade(android.database.sqlite.SQLiteDatabase, int, int);
public net.kjeldahl.tournman.MatchHelper$MatchesCursor getMatchesx();
}
Looks pretty similar; namespaces match, they are both regular public
classes etc.
When I try to compile the whole thing (java sources, with class files
output by the kawa compiler references in the classpath), it is invoked
as follows:
javac -d ..outputdir..
-classpath ..pathstojarsetc.
..sourceDir../MatchHelper.java
Of course there are many more source files, the above example is just
for illustration purposes.
Now I've tried putting the path to my Something.class file both in the
-classpath section and also in the CLASSPATH environment variable when
running javac, but it is just not getting picked up. I've also tried
putting my Something.class file other places that the outputdir in case
java had special handling of that, but it still does not work.
So either my assumption about classes supposedly being recognized from
class files referenced in the classpath is wrong, or something else is
which I just do not understand.
Any ideas why I seem unable to use the class files from kawa mixed in
with a java project?
Thanks,
Marius Kjeldahl