`Hash` doesn't `dup.freeze` ruby string keys if they are already frozen, so this needs to be:
```java
if (key instanceof RubyString && !((RubyString)key).frozen) {
```