Navigation
Synopsis Cannot link to a Java method.
Description Rascal functions can be implemented in Java. This is the case for many functions in the standard library. This requires these elements:
  • An abstract Rascal function declaration (= a function header without a body).
  • The keyword java should be part of the function header.
  • The function declaration is annotated (uing javaClass) with the name of the Java class that implements this function.
This error is generated when the Java implementation cannot be found. Most likely, this is a missing or misspelled Java class name. It is also generated when the function declaration does have a body.

Remedy: Contact the Rascal developers:
  • Ask a question at Rascal Ask site.
  • Read the currently open issues at the Rascal's issue tracker. If your problem has not yet been reported by someone else, please report it here.
If you are an expert developer and have implemented your own extension in Java, please check your own extension code first.
Examples This is how the size function on lists is declared in the Rascal library:
rascal>@javaClass{org.rascalmpl.library.Prelude}
>>>>>>>public java int size(list[&T] lst);
int (list[&T]): int size(list[&T]);
Misspelling the class name will generate the JavaMethodLink error:
rascal>@javaClass{org.rascalmpl.library.Preludexxx}
>>>>>>>public java int size(list[&T] lst);
|stdin:///|(0,80,<1,0>,<2,35>): Cannot link method org.rascalmpl.library.Preludexxx because: class not found
The same error message is generated if the function declaration contains a body:
rascal>@javaClass{org.rascalmpl.library.Preludexxx}
>>>>>>>public java int size(list[&T] lst){
>>>>>>>  return 0;
>>>>>>>}
|stdin:///|(0,94,<1,0>,<4,1>): Java function has a body
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.