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

JOptionPane.getValue() unexpected change between JRE 1.6 and JRE 1.7

    Details

    • Subcomponent:
    • Resolved In Build:
      b27
    • CPU:
      x86
    • OS:
      windows_vista

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.7.0_02"
        Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
        Java HotSpot(TM) Client VM (build 22.0-b10, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Windows Vista (32 bit)

        A DESCRIPTION OF THE PROBLEM :
        JOptionPane behavior has change in JDK 1.7,
        and can break existing applications (typically illegal cast exception),
        because for some scenarios, JOptionPane.getValue() now returns JOptionPane.UNINITIALIZED_VALUE while it was returning Integer(0) before.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the following program.
        Enter some text in the the dialog and *press enter key*.
        (If you click a button, this bug is not triggered.)



        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        "Resut => 0"
        (like JRE 1.6)

        ACTUAL -
        "Resut => uninitializedValue"


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
                JOptionPane pane = new JOptionPane("Enter value", JOptionPane.QUESTION_MESSAGE,
                        JOptionPane.OK_CANCEL_OPTION, null,null, null);
                pane.setWantsInput(true);
                JDialog dialog = pane.createDialog(null, "My Dialog");
                dialog.setVisible(true);
                Object result = pane.getValue();
                System.out.println("Resut => " + result);
                dialog.dispose();
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        In client code, check if result is JOptionPane.UNINITIALIZED_VALUE and use 0 instead.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  rupashka Pavel Porvatov (Inactive)
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: