public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcj/12350] New: StringBuffer.substring handles shared flag incorrected.
@ 2003-09-21 10:36 suckfish at ihug dot co dot nz
2003-09-21 11:05 ` [Bug libgcj/12350] " suckfish at ihug dot co dot nz
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: suckfish at ihug dot co dot nz @ 2003-09-21 10:36 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12350
Summary: StringBuffer.substring handles shared flag incorrected.
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libgcj
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: suckfish at ihug dot co dot nz
CC: gcc-bugs at gcc dot gnu dot org
The substring method of java.lang.StringBuffer can clear the boolean shared
field of the object. This is incorrect. The value may be shared for some
reason other than the current call to substring.
Test case and patch inline below.
-----------------test case------------------
public class test
{
static public void main (String[] ignored) throws Throwable
{
StringBuffer b = new StringBuffer ("Good string. More than 16 chars.");
// Should cause sharing.
String s = b.toString();
// Take a char by char unshared copy of s.
String t = new String (s.toCharArray());
b.substring (0, 4); // BUG: Clears shared flag.
b.replace (0, 4, "Bad "); // Modifies shared data.
System.out.println (s);
assert s.equals (t);
}
}
-------------------patch---------------------
Index: libjava/java/lang/StringBuffer.java
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/lang/StringBuffer.java,v
retrieving revision 1.15
diff -u -r1.15 StringBuffer.java
--- libjava/java/lang/StringBuffer.java 24 Mar 2003 00:50:18 -0000 1.15
+++ libjava/java/lang/StringBuffer.java 21 Sep 2003 08:53:19 -0000
@@ -565,7 +565,9 @@
if (len == 0)
return "";
// Share the char[] unless 3/4 empty.
- shared = (len << 2) >= value.length;
+ boolean shared = (len << 2) >= value.length;
+ if (shared)
+ this.shared = true;
// Package constructor avoids an array copy.
return new String(value, beginIndex, len, shared);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libgcj/12350] StringBuffer.substring handles shared flag incorrected.
2003-09-21 10:36 [Bug libgcj/12350] New: StringBuffer.substring handles shared flag incorrected suckfish at ihug dot co dot nz
@ 2003-09-21 11:05 ` suckfish at ihug dot co dot nz
2003-09-22 8:44 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: suckfish at ihug dot co dot nz @ 2003-09-21 11:05 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12350
------- Additional Comments From suckfish at ihug dot co dot nz 2003-09-21 09:14 -------
http://gcc.gnu.org/ml/java-patches/2003-q3/msg00741.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libgcj/12350] StringBuffer.substring handles shared flag incorrected.
2003-09-21 10:36 [Bug libgcj/12350] New: StringBuffer.substring handles shared flag incorrected suckfish at ihug dot co dot nz
2003-09-21 11:05 ` [Bug libgcj/12350] " suckfish at ihug dot co dot nz
@ 2003-09-22 8:44 ` cvs-commit at gcc dot gnu dot org
2003-09-22 8:51 ` bryce at mckinlay dot net dot nz
2003-10-17 18:14 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-09-22 8:44 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12350
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2003-09-22 08:17 -------
Subject: Bug 12350
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: bryce@gcc.gnu.org 2003-09-22 08:17:49
Modified files:
libjava : ChangeLog
libjava/java/lang: StringBuffer.java
libjava/testsuite: ChangeLog
Added files:
libjava/testsuite/libjava.lang: PR12350.java PR12350.out
Log message:
2003-09-21 Ralph Loader <suckfish@ihug.co.nz>
PR java/12350:
* java/lang/StringBuffer.java (substring): Fix handling of shared
flag.
2003-09-21 Ralph Loader <suckfish@ihug.co.nz>
PR java/12350
* libjava.lang/PR12350.java: New file.
* libjava.lang/PR12350.out: New file.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.2167&r2=1.2168
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/lang/StringBuffer.java.diff?cvsroot=gcc&r1=1.15&r2=1.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.291&r2=1.292
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.lang/PR12350.java.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.lang/PR12350.out.diff?cvsroot=gcc&r1=NONE&r2=1.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libgcj/12350] StringBuffer.substring handles shared flag incorrected.
2003-09-21 10:36 [Bug libgcj/12350] New: StringBuffer.substring handles shared flag incorrected suckfish at ihug dot co dot nz
2003-09-21 11:05 ` [Bug libgcj/12350] " suckfish at ihug dot co dot nz
2003-09-22 8:44 ` cvs-commit at gcc dot gnu dot org
@ 2003-09-22 8:51 ` bryce at mckinlay dot net dot nz
2003-10-17 18:14 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: bryce at mckinlay dot net dot nz @ 2003-09-22 8:51 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12350
bryce at mckinlay dot net dot nz changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
------- Additional Comments From bryce at mckinlay dot net dot nz 2003-09-22 08:21 -------
Fix checked in.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libgcj/12350] StringBuffer.substring handles shared flag incorrected.
2003-09-21 10:36 [Bug libgcj/12350] New: StringBuffer.substring handles shared flag incorrected suckfish at ihug dot co dot nz
` (2 preceding siblings ...)
2003-09-22 8:51 ` bryce at mckinlay dot net dot nz
@ 2003-10-17 18:14 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-10-17 18:14 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12350
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |3.4
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-10-17 18:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-21 10:36 [Bug libgcj/12350] New: StringBuffer.substring handles shared flag incorrected suckfish at ihug dot co dot nz
2003-09-21 11:05 ` [Bug libgcj/12350] " suckfish at ihug dot co dot nz
2003-09-22 8:44 ` cvs-commit at gcc dot gnu dot org
2003-09-22 8:51 ` bryce at mckinlay dot net dot nz
2003-10-17 18:14 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).