---
title: "Comment by Shai Almog on \"Is a String in Java really immutable?\" | Hashnode"
description: "Circumventing the Java language rules via reflection isn&#39;t &quot;really&quot; mutability. By that measure immutability is impossible in the JVM. If your app"
url: "https://hashnode.com/posts/is-a-string-in-java-really-immutable/6292125ed97f80b5091d9277/comment/62923e31d97f80b5091d97e3"
---

[Discussion](https://hashnode.com/posts/is-a-string-in-java-really-immutable/6292125ed97f80b5091d9277)

Comment [Is a String in Java really immutable?](https://hashnode.com/posts/is-a-string-in-java-really-immutable/6292125ed97f80b5091d9277)

[Shai Almog](https://hashnode.com/@talktotheduck)

[May 28, 2022](https://hashnode.com/posts/is-a-string-in-java-really-immutable/6292125ed97f80b5091d9277/comment/62923e31d97f80b5091d97e3)

Circumventing the Java language rules via reflection isn't "really" mutability. By that measure immutability is impossible in the JVM.

If your app was running under a security manager it would fail in runtime in any version of the JVM which is why String is immutable. This is actually enforced by the TCK since string mutability can be used for various attacks by untrusted code.

[Sourya Bhattacharya](https://hashnode.com/@BlackCoffeeIsEpic)

[May 30, 2022](https://hashnode.com/posts/is-a-string-in-java-really-immutable/6292125ed97f80b5091d9277/comment/62923e31d97f80b5091d97e3#reply-629431b1d97f80b5091dc1e1)

I see. Thanks for reviewing my post :)
