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

Premature deprecation of Event/InputEvent/KeyEvent in Java 9

    Details

    • Subcomponent:
    • Introduced In Version:
      9
    • Resolved In Build:
      b36
    • CPU:
      x86
    • OS:
      os_x

      Description

      FULL PRODUCT VERSION :
      java version "9"
      Java(TM) SE Runtime Environment (build 9+175)
      Java HotSpot(TM) 64-Bit Server VM (build 9+175, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      There is no replacement for Toolkit.getMenuShortcutKeyMask() that would return InputEvent.CTRL_DOWN_MASK instead of InputEvent.CTRL_MASK.

      This means that code working with the result of the above method call is forced to use deprecated functionality:

      - KeyEvent.getKeyModifiersText(int) instead of KeyEvent.getKeyModifiersTextEx(int)
      - InputEvent.getModifiers() instead of InputEvent.getModifiersEx()
      - Evaluating the result of InputEvent.getModifiers() requires the use of the deprecated Event/InputEvent.SHIFT_MASK, CTRL_MASK etc. constants.

      Even if a method along the lines of Toolkit.getMenuShortcutKeyMaskEx() would be added in Java 9 to circumvent this problem, it would be a less than ideal solution since there would be no way to write deprecation-free code that would compile and run fine on both Java 8 and Java 9.

      I'd suggest to add such a method in Java 9 and ideally postpone the deprecation of Event/InputEvent/KeyEvent and related methods to Java 10.

      Toolkit.getMenuShortcutKeyMask() should also be deprecated at the same time because it requires the use of deprecated functionality.

      REGRESSION. Last worked in version 8u131


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Ignoring the generated deprecation warnings.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                serb Sergey Bylokhov
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: