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

Methods for addXxxListener have inconsistent synchronization.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.1.5
    • 1.1
    • client-libs
    • None
    • 1.1.5
    • sparc
    • solaris_2.5
    • Not verified


      From jkanerva Wed Jan 1 08:03:18 1997
      Date: Wed, 1 Jan 97 08:03:18 PST
      From: Jonni Kanerva <###@###.###>
      To: aim
      Subject: add<type>Listener synchronization
      Reply-to: Jonni Kanerva <###@###.###>

      Aim,

      FYI -- another consistency check as I work through the 1.1 event
      model. I grepped for all the add<type>Listener methods in
      src/share/java/java/awt and found that some are synchronized and some
      aren't. First, the synchronized:

      Component.java: public synchronized void addComponentListener(ComponentListener l) {
      Component.java: public synchronized void addFocusListener(FocusListener l) {
      Component.java: public synchronized void addKeyListener(KeyListener l) {
      Component.java: public synchronized void addMouseListener(MouseListener l) {
      Component.java: public synchronized void addMouseMotionListener(MouseMotionListener l) {
      Dialog.java: public synchronized void addWindowListener(WindowListener l) {
      Frame.java: public synchronized void addWindowListener(WindowListener l) {

      Next, the unsynchronized:

      Button.java: public void addActionListener(ActionListener l) {
      Checkbox.java: public void addItemListener(ItemListener l) {
      CheckboxMenuItem.java: public void addItemListener(ItemListener l) {
      Choice.java: public void addItemListener(ItemListener l) {
      Container.java: public void addContainerListener(ContainerListener l) {
      ItemSelectable.java: public void addItemListener(ItemListener l);
      List.java: public void addActionListener(ActionListener l) {
      List.java: public void addItemListener(ItemListener l) {
      MenuItem.java: public void addActionListener(ActionListener l) {
      ScrollPane.java: public void addAdjustmentListener(AdjustmentListener l) {
      Scrollbar.java: public void addAdjustmentListener(AdjustmentListener l) {
      TextComponent.java: public void addTextListener(TextListener l) {
      TextField.java: public void addActionListener(ActionListener l) {


      Or, if you break it down just by method name, regardless of class:

          public synchronized void addComponentListener(ComponentListener l) {
          public synchronized void addFocusListener(FocusListener l) {
          public synchronized void addKeyListener(KeyListener l) {
          public synchronized void addMouseListener(MouseListener l) {
          public synchronized void addMouseMotionListener(MouseMotionListener l) {
          public synchronized void addWindowListener(WindowListener l) {
          public void addActionListener(ActionListener l) {
          public void addAdjustmentListener(AdjustmentListener l) {
          public void addContainerListener(ContainerListener l) {
          public void addItemListener(ItemListener l) {
          public void addTextListener(TextListener l) {


      From a quick look at the source, it seems like all the
      add<type>Listener methods should receive the same synchronization
      treatment. What do you think?

            duke J. Duke
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: