phoneme
  1. phoneme
  2. PHONEME-47

java.util.Vector size() method is not synchronized

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: bug-process-dummy
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      47

      Description

      Bug:

      java.util.Vector size() method is not synchronized but should be:

      https://phoneme.dev.java.net/source/browse/phoneme/components/cldc/trunk/src/javaapi/cldc1.0/java/util/Vector.java

      /**

      • Returns the number of components in this vector.
        *
      • @return the number of components in this vector.
      • @since JDK1.0
        */
        public int size() { return elementCount; }

      Vector is a synchronized collection.

      Synchronizing size() is important for subclassing as well as JMM visibility.
      (The latter will someday be an issue on mobile handsets...)

      Unless size() is synchronized, overriding a synchronized method such as
      addElement() in order to implement ring-buffer semantics will not prevent
      another thread from seeing an interim size().

      This bug was reported against JDK 1.3 in 2001 and FIXED:

      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4420686

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            fsuliman
            Reporter:
            jozart
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: