Following the docs I could run Polyglot application where the start language is Java and the target language is C++, which is in a separated source file.
I wonder how could I pass some arguments from Java to C++.
Code examples
Start Language (Java)
import org.graalvm.polyglot.*;
import java.io.File;
import java.io.IOException;
public class HelloPolyglot {
public static void main(String[] args) throws IOException {
File file = new File("polyglot"); // the path to the file
Source source = Source.newBuilder("llvm", file).build();
Context polyglot = Context.newBuilder().allowAllAccess(true).build();
Value cpart = polyglot.eval(source);
cpart.executeVoid();
}
}
Target Language (C++)
#include <iostream>
using namespace std;
int main(int argc, char** argv){
cout << "You have entered " << argc
<< " arguments:" << "\n";
for (int i = 0; i < argc; ++i)
cout << argv[i] << "\n";
return 0;
}
Thank you in advance.