[4898] in java-interest

home help back first fref pref prev next nref lref last post

Re: class String HAS BEEN COMPLETELY AND UTTERLY BROKEN IN BETA2

daemon@ATHENA.MIT.EDU (Jim Graham)
Thu Jan 18 19:06:28 1996

Date: Thu, 18 Jan 1996 14:14:20 -0800
From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
To: jpayne@starwave.com
Cc: java-interest@java.Eng.Sun.COM


Hi Jonathan,

> Class String has been seriously and completely and utterly
> mind-bogglingly broken in the beta2 release.  Apparently because of some
> sort of security issue (see below), all Strings now copy their
> arguments.

The following comment has been in String.java since 1994:

     /**
      * A general class of objects to represent character strings.
      * Strings are constant, their values cannot be changed after creation.
      * The compiler makes sure that each String constant actually results
      * in a String object. Because String objects are immutable they can
      * be shared. For example:
	...
      */

In Beta1 there was a bug, values in a String object could be changed
after creation.  That bug was fixed in Beta2.

> This means that making substrings ALSO copies, rather than
> making a reference to the original one.  This is incredibly inefficient.

You're right.  This should be fixed soon.  Strings should be able to
trust themselves.

> I will have a VERY hard time working around this mistake.

It is very unfortunate that you took advantage of a bug in Beta1.

> As far as the security issue is concerned, I believe it has something to
> do with an important piece of code not being able to trust a String it's
> handed, because if somebody else is holding onto the char [] that
> created that String, then that owner can play some tricky games with it.

It is not just security, but also using Strings as keys in hashtables.
If their values can change after creation, then their location in the
hash table will change as well.  This is unacceptable.

> This just kills me.  I will *not* be upgrading to beta2.

That is unfortunate as well.  You've done such great work in the past!
(Some of it on the String class itself  ;-)

I would hate to see you left behind because you have been depending on
a bug that we had to fix.

				...jim
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post