Reputation: 410
This question is similar to this one. I am trying to call a Java method from Rascal, but I'm getting an error (this time a different one):
Cannot link method com.mypackage.Teste because: com.mypackage.Teste.<init>(io.usethesource.vallang.IValueFactory)
.
Rascal code:
@javaClass{com.mypackage.Teste}
java void testeJava();
Java code:
package com.mypackage;
import io.usethesource.vallang.IValueFactory;
public class Teste {
private final IValueFactory vf;
public Teste(IValueFactory vf) {
this.vf = vf;
}
public void testeJava() {
System.out.println("it worked");
}
}
I noticed that I was using an old Rascal version (0.8), as pointed out in this comment. I changed it to 0.9 but the error remains. I'm using Eclipse Rascal plugin.
Upvotes: 1
Views: 123
Reputation: 271
So, to summarise the discussion, likely causes of this error include:
public ClassName(IValueFactory vf) { this.vf = vf; }
As jurgenv mentions, your Eclipse project also needs both the Rascal and Java natures, otherwise the Java builder doesn't run. This should be correctly set up from the start, as long as you created it using New → Rascal Project. For reference, the natures part of your Eclipse .project file should look like this:
<natures>
<nature>rascal_eclipse.rascal_nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>rascal_eclipse.term_nature</nature>
</natures>
Upvotes: 4