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.
- Is it theoretically possible to achieve the same 'reflection & injection' effect with C++? If I wanted to make a mod for my application in C++ (as an example), is that theoretically possible?
Some approaches I have thought of
-
- I assume that the approach would have to be different...:
org.reflections
works off ofClassLoader
s, so the C++ code would have to be in a format which could be loaded as such, if this were to work. It seems like inter-language conversion is often problematic (Converting Borland C++ code to Java code), so using an automated tool might be hard.
- I assume that the approach would have to be different...:
-
- 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
.dll
s using thenative
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
- 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
-
- 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.
Aucun commentaire:
Enregistrer un commentaire