< prev index next >

src/java.base/share/classes/java/lang/InstantiationException.java

Print this page




  27 
  28 /**
  29  * Thrown when an application tries to create an instance of a class
  30  * using the {@code newInstance} method in class
  31  * {@code Class}, but the specified class object cannot be
  32  * instantiated.  The instantiation can fail for a variety of
  33  * reasons including but not limited to:
  34  *
  35  * <ul>
  36  * <li> the class object represents an abstract class, an interface,
  37  *      an array class, a primitive type, or {@code void}
  38  * <li> the class has no nullary constructor
  39  *</ul>
  40  *
  41  * @author  unascribed
  42  * @see     java.lang.Class#newInstance()
  43  * @since   1.0
  44  */
  45 public
  46 class InstantiationException extends ReflectiveOperationException {

  47     private static final long serialVersionUID = -8441929162975509110L;
  48 
  49     /**
  50      * Constructs an {@code InstantiationException} with no detail message.
  51      */
  52     public InstantiationException() {
  53         super();
  54     }
  55 
  56     /**
  57      * Constructs an {@code InstantiationException} with the
  58      * specified detail message.
  59      *
  60      * @param   s   the detail message.
  61      */
  62     public InstantiationException(String s) {
  63         super(s);
  64     }
  65 }


  27 
  28 /**
  29  * Thrown when an application tries to create an instance of a class
  30  * using the {@code newInstance} method in class
  31  * {@code Class}, but the specified class object cannot be
  32  * instantiated.  The instantiation can fail for a variety of
  33  * reasons including but not limited to:
  34  *
  35  * <ul>
  36  * <li> the class object represents an abstract class, an interface,
  37  *      an array class, a primitive type, or {@code void}
  38  * <li> the class has no nullary constructor
  39  *</ul>
  40  *
  41  * @author  unascribed
  42  * @see     java.lang.Class#newInstance()
  43  * @since   1.0
  44  */
  45 public
  46 class InstantiationException extends ReflectiveOperationException {
  47     @java.io.Serial
  48     private static final long serialVersionUID = -8441929162975509110L;
  49 
  50     /**
  51      * Constructs an {@code InstantiationException} with no detail message.
  52      */
  53     public InstantiationException() {
  54         super();
  55     }
  56 
  57     /**
  58      * Constructs an {@code InstantiationException} with the
  59      * specified detail message.
  60      *
  61      * @param   s   the detail message.
  62      */
  63     public InstantiationException(String s) {
  64         super(s);
  65     }
  66 }
< prev index next >