Can I use native compilation as Java obfuscation
I am writing a plugin for a Java application. I could obfuscate the plugin, but it would still be easily reverse engineered.
I believe that if I could compile this plugin to a shared library, which heavily uses JNI to communicate with the main application, it would be much harder to reverse engineer. I am willing to sacrifice some performance to JNI, and the开发者_运维百科 application I am coding against does support shared library loading. The only problem is that I am not aware of a tool which does the job: gcj seems to depend on its own runtime and IKVM.NET - on .NET
To be precise:
public class PluginImpl implements Plugin {
@Override
public void startPlugin(PluginContext ctx) {
ctx.helloWorld();
}
}
should be converted to
public class PluginImpl implements Plugin {
@Override
public native void startPlugin(PluginContext ctx);
}
and the body of my startPlugin method is compiled into a shared library.
(well, yes, I know, I could have written this plugin in C in first place)
You can't really use anything for code obfuscation if you are distributing executable code in any form. Any executable code can be reverse engineered. This is a business problem not a technical problem, and it is solved by busniess means: licence agreements, price, time to market, or most probably a more realistic assessment of the risks and values, i.e. admitting to yourself that your code just isn't that valuable. Alternatively deliver your product as a service rather than as an executable.
I assume you have good reasons to go for native compilation. An option that you can examine is Excelsior JET that is a Certified Java solution.
You could make your plugin provide its service over RMI. This way the plugin would be an application and could be compiled to native code.
精彩评论