java - Class.forName() is not working with a particular class -
i trying load java reflection bunch of classes. seems working fine (i handling exception if class not found).
however there particular class raising exception not thrown call class.forname() internal method , cannot catch it.
here code:
try { url url = class.forname(qualifiednameoftheclass); } catch (classnotfoundexception ex) { // ok class not found can handled } catch (exception e){ // catch every other exception try strange exception }
so code working, using on lots of classes , it's working (sometimes finds doesn't).
however there 1 case not working , cannot understand why. if qualifiednameoftheclass = sun.security.krb5.scdynamicstoreconfig
code raising exception:
exception in thread "mythread-1" java.lang.unsatisfiedlinkerror: no osx in java.library.path @ java.lang.classloader.loadlibrary(classloader.java:1886) @ java.lang.runtime.loadlibrary0(runtime.java:849) @ java.lang.system.loadlibrary(system.java:1088) @ sun.security.action.loadlibraryaction.run(loadlibraryaction.java:67) @ sun.security.action.loadlibraryaction.run(loadlibraryaction.java:47) @ java.security.accesscontroller.doprivileged(native method) @ sun.security.krb5.scdynamicstoreconfig.(scdynamicstoreconfig.java:39) @ java.lang.class.forname0(native method) @ java.lang.class.forname(class.java:190) @ com.myclass.getjarfromclassforname(javaid.java:510) @ com.myclass.getjarurl(id.java:550) @ com.myclass.collectinformation(graph.java:366) @ com.myclass.createnode(graph.java:166) @ com.myclass.graph.(graph.java:143) @ com.myclass2.run(myclass2.java:246) @ java.lang.thread.run(thread.java:745)
so can see in error have strange exception cannot caught generic catch in code , cannot understand why has been raised , osx library (i on linux)
edit: thing found link http://www.straub.as/java/pocketapi/index7.html in german , read google translate , don't know if got right saying classes listed there cannot reproduced class.forname() itself.
is true? there reason why cannot loaded reflection or doing wrong?
as can see in link have provided, there classes method fails.
when calling method on these objects, java needs first load additional stuff, platform specific stuff not shipped default. in case, kerberos, security api. can see in documentation, searches files in specific paths (java.library.path). can not find there, throws error.
note error unsatisfiedlinkerror not refer finding class name sun.security.krb5.scdynamicstoreconfig itself. refers not finding native library in paths provided java.library.path.
path points, example on windows, c:windows/system32/.
however, may catch error catch(error e)
, note error not exception (throwable hierarchy). aware catching error in general no idead can not sure if jvm can recover it.
Comments
Post a Comment