Mod java application in using C++

Viewed 93

The context

I am writing an application in Java which is moddable. The application searches a /mods directory for .jar files and uses org.reflections to find @Mod annotations on classes. It then creates a newInstance() of the class, and injects the mod's objects into the application's registries. The objects that are being injected into the application registries are primarily java.util.Supplier<T>s, where T is a complex object, such as a Tile.

That all works fine when writing the mod in Java.

  • If I wanted to make a mod for my application in C++ (as an example), how could I go about that?

Some approaches

    1. Through comments we have determined that translation code would not work
    1. Perhaps a different approach would be to not convert have either the modder, or the application convert the C++ code to Java, but to use a take on the JNI to load the C++ code as a library? Java can call methods from .dlls using the native keyword, assuming that it knows the name of the method it will call, and the library is loaded. If C++ can be compiled into a .dll, then would that help? How to compile a cpp to a dll in visual studio 2010 express
    1. Although I don't know a lot about it, perhaps a tool like SWIG would work for making the files cross compatible?

Would any of these three be viable solutions?

Any additional information or clarification, please ask.

0 Answers
Related