linux - Java Class.isAssignableFrom ALWAYS returning false... only outside IDE -
i've tested on 3 windows machines, , 2 linux vpses, on different versions of java, both on openjdk & oracle jdk. functioned perfectly, , of sudden, works in ide, though haven't changed relevant code, , can't imagine can cause this.
prevalent code in system:
class<?> cls = (session == null ? secjlcl : session.getjlcl()).loadclass(name); logger.log(javaloader.class.isassignablefrom(cls) + " - " + cls + " - " + cls.getsuperclass().getname()); if (javaloader.class.isassignablefrom(cls)) {
and classloader:
public class javaloaderclassloader extends urlclassloader { public javaloaderclassloader(url[] url, classloader parent) { super(url); } private hashmap<string, class<?>> javaloaders = new hashmap<string, class<?>>(); public string addclass(byte[] data) throws linkageerror { class<?> cls = defineclass(null, data, 0, data.length); javaloaders.put(cls.getname(), cls); return cls.getname(); } public class<?> loadclass(string name, boolean resolve) { if (javaloaders.containskey(name)) return javaloaders.get(name); try { class<?> see = super.loadclass(name, resolve); if (see != null) return see; }catch (classnotfoundexception e) { logger.logerror(e); } return null; } public void finalize() throws throwable { super.finalize(); javaloaders = null; } }
one note, expect many classloaders load different file in same name/package, use separate classloaders keep them separate, in testing, not tested.
now, had worked flawlessly in past, , have 0 clue why stopped. assume broke something, code still works in ide?
this appears bug:
public javaloaderclassloader(url[] url, classloader parent) { super(url); }
you aren't installing parent
parent class loader through super constructor.
Comments
Post a Comment