Example in 4.3.1 uses deprecated API

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 18
    • Component/s: specification

      Example 4.3.1-1. Object Creation contains the code

              try {
                  p = (Point)Class.forName("Point").newInstance();
              } catch (Exception e) {
                  System.out.println(e);
              }

      Class.newInstance was deprecated by JDK-6850612 in JDK 9 since it can throw undeclared checked exceptions. The recommended replacement code is:

              try {
                  p = (Point)Class.forName("Point").getDeclaredConstructor().newInstance();
              } catch (ReflectiveOperationException e) {
                  System.out.println(e);
              }

            Assignee:
            Alex Buckley
            Reporter:
            Joe Darcy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: