Posted on 2007-04-10 21:03
久城 閱讀(2120)
評論(5) 編輯 收藏 所屬分類:
翻譯
Unlike methods, a constructor cannot be abstract, static, final, native or synchronized.
1. A constructor is not inherited, so there is no need to declare it final
2. As the same reason above, an abstract constructor could never be implemented.
3. A constructor is always invoked with respect to an object, so it makes no sense for a constructor to be static.
4. There is no practical need for a constructor to be synchronized, because it would lock the object under construction, which is normally not made available to other threads until all constructors for the object have completed their work.
5. The lack of native constructors is an arbitrary language design choice that makes it easy for an implementation of the Java virtual machine to verify that superclass constructors are always properly invoked during object creation.
翻譯如下:
不同于方法,構造器不能是abstract, static, final, native, strictfp, 或者synchronized的.
1.構造器不是通過繼承得到的,所以沒有必要把它聲明為final的。
2.同理,一個抽象的構造器將永遠不會被實現。(所以也不能聲明為abstract的)
3.構造器總是關聯一個對象而被調用,所以把它聲明為static是沒有意義的。
4.沒有實際的需要把構造器定義成同步的,因為它將會在構造的時候鎖住該對象,直到所有的構造器完成它們的工作,這個構造的過程對其它線程來說,通常是不可訪問的。
5.沒有本地的構造器是任意一種語言的設計選擇,這樣會使得在創建對象的過程中JVM實現很容易去校驗父類的構造器是否總是被正確地調用了。
(本地化的方法情況特別復雜,所以JVM調用起來非常麻煩,需要考慮很多種情況,沒有native關鍵字的情況下,JVM實現起來比較容易。)
PS:受俺導師的影響,第一次有這種沖動想去翻譯一些英文資料。雖然翻譯得很爛,但很欣慰。
歡迎來訪!^.^!
本BLOG僅用于個人學習交流!
目的在于記錄個人成長.
所有文字均屬于個人理解.
如有錯誤,望多多指教!不勝感激!