Exception in thread "main" java.lang.InstantiationException
今天在做Class.forName 反射获取jar里所有类内的方法和属性时,出现这个错误,后来查了下才知道原来Class.forName是不能加载接口和抽象类的,害的我弄了好久

解决方案 »

  1.   

    如果由Class.forName().newInstance() 则加载的类必须有个无参构造函数
      

  2.   

    接口和抽象类能实例化?只能通过接口和抽象类推断他们的实现类,再用Class.forName()加载....
      

  3.   

    上网查了 在javadoc里好像有这么一句啊 "Thrown when an application tries to create an instance of a class using the newInstance method in class Class, but the specified class object cannot be instantiated because it is an interface or is an abstract class."