Skip to main content

UndeclaredJavaMethod

rascal-0.42.2

Synopsis​

Attempt to call a non-existing 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 a method with the same name as the Rascal function cannot be found in the mentioned Java class. Most likely, this is a missing or misspelled function/method name.

Remedy: see Getting Help. 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}
|1 >>>>public java int size(list[&T] lst);
int (list[&T]): function(|prompt:///|(0,77,<1,0>,<2,35>))

This is the result of misspelling the function name (siz instead of size):

rascal>@javaClass{org.rascalmpl.library.Prelude}
|1 >>>>public java int siz(list[&T] lst);
|prompt:///|(0,76,<1,0>,<2,34>): No such Java method: org.rascalmpl.library.Prelude.siz(io.usethesource.vallang.IList)
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UndeclaredJavaMethod|