Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8280602

4.3.1: Avoid use of newInstance when it is terminally deprecated

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 17
    • specification

      Example 4.3.1-1 uses reflection, specifically Class::newInstance, to demonstrate object creation:

      (Point)Class.forName("Point").newInstance();

      Reflection is too sophisticated to show so early in the JLS, and in any case newInstance has been ordinarily deprecated since 9. When newInstance is terminally deprecated, the example should replace reflection with a simple `new Point()` clause. The mention of newInstance in 11.2.3 should be clarified at the same time to refer to Constructor::newInstance.

            abuckley Alex Buckley
            abuckley Alex Buckley
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: