Skip to content

Instantly share code, notes, and snippets.

@TuxCoding
Created December 9, 2016 14:59
Show Gist options
  • Select an option

  • Save TuxCoding/d61927af33ae8a15e36e2e9f1d1a318e to your computer and use it in GitHub Desktop.

Select an option

Save TuxCoding/d61927af33ae8a15e36e2e9f1d1a318e to your computer and use it in GitHub Desktop.
Disable jar resources cache
/**
* Disable or enable the use of class caching. Workaround for linking to an
* old jar version while the plugin jar was changed during a reload.
*
* @param status should the cache be activated
* @return if the process succeed.
*/
public static boolean setClassCache(boolean status) {
try {
Field cacheField = URLConnection.class.getDeclaredField("defaultUseCaches");
cacheField.setAccessible(true);
cacheField.setBoolean(null, status);
return true;
} catch (Exception ex) {
Logger.getLogger("").log(Level.SEVERE, null, ex);
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment