More than that, since CompiledMethod redefines #=, it is strange that it's not redefines #hash as well, because it is one of requirements to make sure they are always in sync.
indeed!
Two conclusions:
The solution is to define CompiledMethod>hash such that it does not access bytes < initialPC. The hash it is inheriting from ByteArray is fine for ByteArray but not at all OK for CompiledMethod.
Yes, i would just do
self methodClass hash bitXor: self selector hash
that's one possibility. If we want to continue with the previous kind of hash we also could do something like: CompiledMethod >> hash "#hash is implemented, because #= is implemented" ^self class hashBytes: self bytecodes startingWith: self species hash CompiledMethod >> bytecodes | initialPC endPC bytecodes | initialPC := self initialPC. endPC := self endPC. bytecodes := ByteArray new: (endPC - initialPC + 1). initialPC to: endPC do: [:index | bytecodes at: (index - initialPC + 1) put: (self at: index) ]. ^ bytecodes I am not a hashing expert. What do you think? which impl should we do? -- Mariano http://marianopeck.wordpress.com