JDK-1240681 : fp.bugs 3325 java.lang.String : monitor InternSet, get(this) and put(this)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5
  • CPU: sparc
  • Submitted: 1996-03-01
  • Updated: 1997-08-01
  • Resolved: 1997-08-01
Related Reports
Duplicate :  
Description
From: ###@###.###
This does not look like form output to me.


1) This is mainly a bug report, but I'm as well proposing a feature related to sa
me place
2) jdk-1.0 
3) jdk-1.0
4) see below
5)-9) don't apply; I found bug in source code...

Bug report:
===========
The method "intern" in java.lang.String has two bugs

a) creation of InternSet is not monitored; a race condition could cause
two intern of the same string to use different hashtables 

b) The sequence get(this) and put(this) is not monitored...


Feature request:
================
Also in java.lang.String
There is no way to check whether a string has been intern'ed without 
automatically interning the string and making the hashtable grow.  I 
think a method similar to intern but returning null if the string wasn't 
already intern'ed could allow a user in some cases to get benefits of 
intern without paying the cost...


Chris
###@###.###

Comments
EVALUATION Re: the bug part of this bug, the code has changed so much since -- but the latest version of String.intern grabs the monitor of the HashTable. Re: the RFE part of the bug. With 1.2 we will be garbage collecting interned string with weak refs. This size problem has been reported in 4035345, so I am closing this as a duplicate of that. anand.palaniswamy@Eng 1997-08-01
01-08-1997