Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > BotCompany Repo | #1032891 // javaLibraryPathHack

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3902L/23K).

import java.lang.invoke.*;

svoid javaLibraryPathHack() pcall {
  // hack for newer JDKs to accept a change java.library.path
  
  // see https://stackoverflow.com/questions/15409223/adding-new-paths-for-native-libraries-at-runtime-in-java
  
  // set sys_paths to null so that java.library.path will be reevalueted next time it is needed
  var cl = MethodHandles.privateLookupIn(ClassLoader.class, MethodHandles.lookup());
  VarHandle sys_paths = cl.findStaticVarHandle(ClassLoader.class, "sys_paths", String[].class);
  sys_paths.set(null);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032891
Snippet name: javaLibraryPathHack
Eternal ID of this version: #1032891/4
Text MD5: a1fe2e295824f9aeb3f6075a7eaaa03c
Transpilation MD5: bd92951e31e32e6c012de17c6437261e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-08 17:45:26
Source code size: 555 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 105 / 164
Version history: 3 change(s)
Referenced in: [show references]