You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to load a jar file during plugin startup. But unable to load it with JDK 12 or later version.
below is the code snippet :
-------------------------------------CODE---------------------------------------------------
URLClassLoader urlSysLoader = new URLClassLoader(new URL[] {url}, sysLoader);
Method method = sysClass.getDeclaredMethod("addURL", parameters);
/**
The addURL() appends the specified URL to the list of URLs to search for
classes and resources. and since this Method is Protected and we are not inheriting
i'm forced to make it visible.
*/
method.setAccessible(true);
// Invoke addURL method with jar URL to add the classes to URL ClassLoader
method.invoke(urlSysLoader, new Object[] { url });
Field scl = ClassLoader.class.getDeclaredField("scl");
scl.setAccessible(true);
// Replace the static scl (System Class Loader for running instance) with
// newly created URL ClassLoader (system class loader + jar files loaded)
scl.set(null, urlSysLoader);
-----------------------------------------CODE----------------------------------------------
Getting below error :
----------------------------------------ERROR---------------------------------------------------------------------------------
java.lang.NoSuchFieldException: scl
at java.base/java.lang.Class.getDeclaredField(Class.java:2569)
at com.unisys.tde.core.characterset.OS2200CharSetPlugin.loadCharSetLib(OS2200CharSetPlugin.java:160)
at com.unisys.tde.core.characterset.OS2200CharSetPlugin$1.run(OS2200CharSetPlugin.java:66)
----------------------------------------ERROR---------------------------------------------------------------------------------
The above code was working till JDK 11 version.
Please let me know any suggestion or any other alternative approach to achieve the same.
Thanks and Regards,
Raghu
The text was updated successfully, but these errors were encountered:
I am trying to load a jar file during plugin startup. But unable to load it with JDK 12 or later version.
below is the code snippet :
-------------------------------------CODE---------------------------------------------------
URLClassLoader urlSysLoader = new URLClassLoader(new URL[] {url}, sysLoader);
Method method = sysClass.getDeclaredMethod("addURL", parameters);
/**
The addURL() appends the specified URL to the list of URLs to search for
classes and resources. and since this Method is Protected and we are not inheriting
i'm forced to make it visible.
*/
method.setAccessible(true);
// Invoke addURL method with jar URL to add the classes to URL ClassLoader
method.invoke(urlSysLoader, new Object[] { url });
Field scl = ClassLoader.class.getDeclaredField("scl");
scl.setAccessible(true);
// Replace the static scl (System Class Loader for running instance) with
// newly created URL ClassLoader (system class loader + jar files loaded)
scl.set(null, urlSysLoader);
-----------------------------------------CODE----------------------------------------------
Getting below error :
----------------------------------------ERROR---------------------------------------------------------------------------------
java.lang.NoSuchFieldException: scl
at java.base/java.lang.Class.getDeclaredField(Class.java:2569)
at com.unisys.tde.core.characterset.OS2200CharSetPlugin.loadCharSetLib(OS2200CharSetPlugin.java:160)
at com.unisys.tde.core.characterset.OS2200CharSetPlugin$1.run(OS2200CharSetPlugin.java:66)
----------------------------------------ERROR---------------------------------------------------------------------------------
The above code was working till JDK 11 version.
Please let me know any suggestion or any other alternative approach to achieve the same.
Thanks and Regards,
Raghu
The text was updated successfully, but these errors were encountered: