libgcj/1402: unmodifiableList isn't unmodifiable

bryce@albatross.co.nz bryce@albatross.co.nz
Wed Dec 20 12:26:00 GMT 2000


>Number:         1402
>Category:       libgcj
>Synopsis:       unmodifiableList isn't unmodifiable
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bryce
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 20 12:19:38 PST 2000
>Closed-Date:    Mon Nov 27 00:46:04 PST 2000
>Last-Modified:  Mon Nov 27 00:50:01 PST 2000
>Originator:     bryce@albatross.co.nz
>Release:        unknown-1.0
>Organization:
>Environment:

>Description:
Collections.UnModifiableList appears to be implemented
incorrectly. Refer to the test case.
>How-To-Repeat:
import java.util.*;

public class Unmodifiable
{
  public static void main(String[] args)
  {
    List l = new ArrayList();
    l.add("foo");
    l = Collections.unmodifiableList(l);
    System.out.println (l); // should print contents of list
    l.set(0, "bar"); // should throw exception
  }
}
>Fix:

>Release-Note:

>Audit-Trail:

Formerly PR java.util/372


From: Mark Wielaard <mark@klomp.org>
To: bryce@albatross.co.nz
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: java.util/372: unmodifiableList isn't unmodifiable
Date: Wed, 22 Nov 2000 12:43:35 +0100

 Hi,
 
 On Wed, Nov 22, 2000 at 10:11:42AM -0000, bryce@albatross.co.nz wrote:
 > 
 > >Description:
 > Collections.UnModifiableList appears to be implemented
 > incorrectly. Refer to the test case.
 > >How-To-Repeat:
 > import java.util.*;
 > 
 > public class Unmodifiable
 > {
 >   public static void main(String[] args)
 >   {
 >     List l = new ArrayList();
 >     l.add("foo");
 >     l = Collections.unmodifiableList(l);
 >     System.out.println (l); // should print contents of list
 >     l.set(0, "bar"); // should throw exception
 >   }
 > }
 
 You are cheating :) java.util.Collections is not (yet) in libgcj
 but I assume you mean the implementation of Collections in Classpath.
 Your observation is correct. The innerclass UnmodifiableCollection
 in Collections should implement toString() (and probably hashCode()
 and equals() which are now implemented by all the subclasses)
 some of the methods of UnmodifiableList methods should throw exceptions
 instead of just passing them to the wrapped list object.
 (add(), addAll(), remove() and set())
 
 Cheers,
 
 Mark

From: Bryce McKinlay <bryce@albatross.co.nz>
To: Mark Wielaard <mark@klomp.org>
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: java.util/372: unmodifiableList isn't unmodifiable
Date: Thu, 23 Nov 2000 00:55:43 +1300

 Mark Wielaard wrote:
 
 > You are cheating :) java.util.Collections is not (yet) in libgcj
 
 It will be very soon ;-)
 
 That PR was sort of a note-t0-self to remind me to fix it later as I can't
 be bothered looking at it right now (of course, others are more than
 welcome to fix it first ;-)
 
 regards
 
   [ bryce ]
 
 
Responsible-Changed-From-To: warrenl->bryce
Responsible-Changed-By: bryce
Responsible-Changed-When: Mon Nov 27 00:46:04 2000
Responsible-Changed-Why:
    I fixed it.
State-Changed-From-To: open->closed
State-Changed-By: bryce
State-Changed-When: Mon Nov 27 00:46:04 2000
State-Changed-Why:
    I checked in a fix.

From: bryce@albatross.co.nz
To: bryce@albatross.co.nz, java-gnats@sourceware.cygnus.com,
  warrenl@cygnus.com
Cc:  
Subject: Re: java.util/372
Date: 27 Nov 2000 08:46:04 -0000

 Synopsis: unmodifiableList isn't unmodifiable
 
 Responsible-Changed-From-To: warrenl->bryce
 Responsible-Changed-By: bryce
 Responsible-Changed-When: Mon Nov 27 00:46:04 2000
 Responsible-Changed-Why:
     I fixed it.
 State-Changed-From-To: open->closed
 State-Changed-By: bryce
 State-Changed-When: Mon Nov 27 00:46:04 2000
 State-Changed-Why:
     I checked in a fix.
 
 http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view&pr=372&database=java
>Unformatted:




More information about the Gcc-prs mailing list