title: How to add prefixes to jni dll function names
body: <p>I have a jni dll that has functions being called from java. The problem is that this dll has all the java classes in the default package (in the dll "Java_classname_methodname"). It is impossible to get the source of this dll and it would take EXTREMELY long to rewrite. So I basically need to call the functions in this dll from java in a different package than default. I've tried for hours on end to rename the functions in the dll with a hex editor and several tools to modify the checksum and addresses in the dll but it's just too much for me because I have almost no experience with this. I would very much prefer this route, but I just don't have the proper tools or the know-how. So what I'm left with is trying to hardcode the package name in java. I tried using jna as described in <a href="https://stackoverflow.com/questions/518131/renaming-dll-functions-in-jna-using-stdcallfunctionmapper">this</a> stack overflow post to do something like this:</p>
  
  <pre><code>Map options = new HashMap();
  
  options.
      put(
          Library.OPTION_FUNCTION_MAPPER, 
          new StdCallFunctionMapper() {
              public String getFunctionName(NativeLibrary library, Method method) {
                  method.setName(method.getName().replace("com.test.", "");
                  return super.getFunctionName(library, method);
              }
          }
      );
  
  Native.loadLibrary(..., ..., options);
  </code></pre>
  
  <p>But there is no setName in Method. Ideally I'd like to get this done without any extra libraries but I'm obviously not opposed to using something like jna. And before anyone asks, yes this is permitted by the library's usage license. Please don't tell me it's not possible because know that it's possible, just difficult. Whichever way it must be done I am willing to put in the work (either modifying dll or using java code with some external library). And by the way, I also need this done on .so and .dylib files eventually (not as important as dll). Thank you for your time.</p>