java - Class Availabilty Check -
i have dependency jar, build a, dependency.jar contain classes a,b,c,d. build b, dependency.jar contain classes a,b,c
problem:
source: code making use of classes a,b,c,d.
goal: code have written should remain same build , b.
problem: class d won't available in build b. code should handle availability of class d. @ same time code , going add handle availability of class d , should not slow down code.
please suggest possible solutions.
one solution: make use of class.forname() api check availability of class.
problem solution: api throw classdefnotfound every time if not available, , per understanding class.forname try load class , slow.
note: class d optional, if not available , functionality related class should disabled
you can use method getresource() on class or class loader object of class. if it's return null class not present below
url url=someclass.class.getclassloader().getresource("classname.class"); if(url==null)//class not present
Comments
Post a Comment