Dennis' Blog of Indiscriminate | I thought what I’d do was, I’d pretend I was one of those deaf-mutes

Jul/08

28

網摘: Immutability in Java

很久沒 quote Java 的東東了

Part 1 on Immutability in Java:
http://jeremymanson.blogspot.com/2008/04/immutability-in-java.html

Part 2 on Immutability in Java:
http://jeremymanson.blogspot.com/2008/07/immutability-in-java-part-2.html

Part 3 on Immutability in Java – Deserialization and Reflection:
http://jeremymanson.blogspot.com/2008/07/immutability-in-java-part-3.html

 

 

重點是, final 是必需的。之前的 Javaspeciallist 的文章有有提到。final 的功用不但會限制寫入和方便 inner class 存取而已,它會影響 Just-In-Time compiler 的行為,和防止它作出過份優化而引起的錯誤。

該記著,JRE 不是一行一行執行你的 code(那只會在 debugger發生),而且在 JIT 在 SMP 的情況下會令到 bytecode 執行次序更加難以估計。該加上 final / violate 地方不要偷懶。

RSS Feed

No comments yet.

Leave a comment!

<< 網摘: 1-555-CONFIDE – 馬爾薩斯之悲劇

Google 地圖發佈會點滴 – 網絡暴民 Jacky’s Blog >>

Theme Design by devolux.org