I am having trouble linking a Java method in Rascal.
I have two files:
Func.rsc:
module Func
import Type;
import lang::flybytes::Compiler;
//other stuff
@javaClass{Func}
java void lalala();
//other stuff
Func.java:
import io.usethesource.vallang.IValue;
import io.usethesource.vallang.IValueFactory;
public class Func {
private final IValueFactory vf;
public Func(final IValueFactory vf) {
this.vf = vf;
}
public void lalala() {
System.out.println(2);
}
}
Now, running the Rascal shell and importing Func as follows gives me an error:
(base) bys1@MBP-21-19 flybytes-evalgen % java -cp rascal.jar:. org.rascalmpl.shell.RascalShell
Version: 0.26.5
INFO: detected |lib://rascal| at |jar+file:///Users/bys1/Documents/RUG/FBEG/flybytes-evalgen/rascal.jar!/|
INFO: detected |lib://flybytes-evalgen| at |file:///Users/bys1/Documents/RUG/FBEG/flybytes-evalgen/|
WARNING: could not resolve dependency on: |lib://flybytes| because it does not seem to exist as a project or a library.
rascal>import Func;
Loading module |file:///Users/bys1/Documents/RUG/FBEG/flybytes-evalgen/src/main/rascal/Func.rsc|
Loading module |jar+file:///Users/bys1/.m2/repository/org/rascalmpl/flybytes/0.1.7/flybytes-0.1.7.jar!/src/lang/flybytes/Syntax.rsc|
INFO: resolved |lib://rascal| at |jar+file:///Users/bys1/Documents/RUG/FBEG/flybytes-evalgen/rascal.jar!/|
Loading module |lib://rascal/List.rsc|
Loading module |lib://rascal/Map.rsc|
Loading module |lib://rascal/IO.rsc|
Loading module |lib://rascal/Exception.rsc|
Loading module |jar+file:///Users/bys1/.m2/repository/org/rascalmpl/flybytes/0.1.7/flybytes-0.1.7.jar!/src/lang/flybytes/Compiler.rsc|
Loading module |jar+file:///Users/bys1/.m2/repository/org/rascalmpl/flybytes/0.1.7/flybytes-0.1.7.jar!/src/lang/flybytes/Mirror.rsc|
Loading module |lib://rascal/util/Maybe.rsc|
Loading module |jar+file:///Users/bys1/.m2/repository/org/rascalmpl/flybytes/0.1.7/flybytes-0.1.7.jar!/src/lang/flybytes/api/String.rsc|
Loading module |jar+file:///Users/bys1/.m2/repository/org/rascalmpl/flybytes/0.1.7/flybytes-0.1.7.jar!/src/lang/flybytes/api/Object.rsc|
Loading module |jar+file:///Users/bys1/.m2/repository/org/rascalmpl/flybytes/0.1.7/flybytes-0.1.7.jar!/src/lang/flybytes/api/System.rsc|
Loading module |lib://rascal/Type.rsc|
Warning: Could not load Func due to: No such Java method: Func.lalala()
Advice: |http://tutor.rascal-mpl.org/Errors/Static/UndeclaredJavaMethod/UndeclaredJavaMethod.html| at |file:///Users/bys1/Documents/RUG/FBEG/flybytes-evalgen/src/main/rascal/Func.rsc|(387,36,<21,0>,<22,19>)
|file:///Users/bys1/Documents/RUG/FBEG/flybytes-evalgen/src/main/rascal/Func.rsc|(387,36,<21,0>,<22,19>): No such Java method: Func.lalala()
Advice: |http://tutor.rascal-mpl.org/Errors/Static/UndeclaredJavaMethod/UndeclaredJavaMethod.html|
ok
rascal>:quit
Quiting REPL
I have also tried packing Func.java into a jar and including the jar when running the Rascal shell, but that did not help me either (or I simply did that the wrong way...)
How can I successfully call my Java method from Rascal?
It might be that the Func.class file is not in the .
folder but nested somewhere else. Is that it?