You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Symbols aren't always unique for equal strings #6706
Welcome to Scala version 2.10.0-RC3 (OpenJDK64-BitServerVM, Java1.7.0_09).
Type in expressions to have them evaluated.
Type:help for more information.
scala>varname="foo"+1
name:String= foo1
scala>vars1=Symbol(name)
s1:Symbol='foo1
scala> s1 =null
s1:Symbol=null
scala>System.gc
scala>vals2=Symbol("foo1")
s2:Symbol='foo1
scala> name =null
name:String=null
scala>System.gc
scala>vals3=Symbol("foo1")
s3:Symbol='foo1
scala> s2 eq s3
res2:Boolean=false
The problem arises if the symbol object for a particular name is garbage collected (so the weak reference stored in Symbol's weak hash map is null), but the string for that name has not been garbage collected (so the key still exists in the weak hash map). If a new symbol object with the same name is added, the weak hash map key will be a different object from the name field of the symbol object. If that string is subsequently garbage collected, the weak hash map entry disappears, so if the symbol is then created for a third time, it will end up being a different object from the second one.
Activity
scabug commentedon Nov 24, 2012
Imported From: https://issues.scala-lang.org/browse/SI-6706?orig=1
Reporter: @paulbutcher
Affected Versions: 2.9.2, 2.10.0-RC2
scabug commentedon Nov 24, 2012
@paulp said:
scala/scala#1662
scabug commentedon Nov 26, 2012
@paulp said:
d0de367e72