Uploaded image for project: 'JBeret'
  1. JBeret
  2. JBERET-443

newInstance() in java.lang.Class has been deprecated

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 1.4.0.Alpha1
    • 1.3.0.Final
    • jberet-core
    • None

    Description

      https://docs.oracle.com/javase/10/docs/api/java/lang/Class.html#newInstance()

      @Deprecated(since="9")
      public T newInstance()
      throws InstantiationException,
      IllegalAccessException

      Deprecated.
      This method propagates any exception thrown by the nullary constructor, including a checked exception. Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. The Constructor.newInstance method avoids this problem by wrapping any exception thrown by the constructor in a (checked) InvocationTargetException.

      The call

      clazz.newInstance()

      can be replaced by

      clazz.getDeclaredConstructor().newInstance()

      The latter sequence of calls is inferred to be able to throw the additional exception types InvocationTargetException and NoSuchMethodException. Both of these exception types are subclasses of ReflectiveOperationException.
      Creates a new instance of the class represented by this Class object. The class is instantiated as if by a new expression with an empty argument list. The class is initialized if it has not already been initialized.


      [WARNING] /Users/cfang/dev/jsr352/jberet-core/src/main/java/org/jberet/creation/ArtifactFactoryWrapper.java:[46,24] newInstance() in java.lang.Class has been deprecated

      [WARNING] /Users/cfang/dev/jsr352/jberet-core/src/main/java/org/jberet/repository/PurgeBatchlet.java:[282,71] newInstance() in java.lang.Class has been deprecated

      [WARNING] /Users/cfang/dev/jsr352/jberet-core/src/test/java/org/jberet/creation/AbstractArtifactFactoryTest.java:[26,51] newInstance() in java.lang.Class has been deprecated

      [WARNING] /Users/cfang/dev/jsr352/jberet-se/src/main/java/org/jberet/se/BatchSEEnvironment.java:[152,67] newInstance() in java.lang.Class has been deprecated

      [WARNING] /Users/cfang/dev/jsr352/jberet-se/src/main/java/org/jberet/se/BatchSEEnvironment.java:[219,73] newInstance() in java.lang.Class has been deprecated

      jberet-core/src/main/java/org/jberet/creation/BatchBeanProducer.java

      Attachments

        Activity

          People

            cfang@redhat.com Cheng Fang
            cfang@redhat.com Cheng Fang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: