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.
翻譯如下:
不同于方法,構(gòu)造器不能是abstract, static, final, native, strictfp, 或者synchronized的.
1.構(gòu)造器不是通過繼承得到的,所以沒有必要把它聲明為final的。
2.同理,一個抽象的構(gòu)造器將永遠(yuǎn)不會被實現(xiàn)。(所以也不能聲明為abstract的)
3.構(gòu)造器總是關(guān)聯(lián)一個對象而被調(diào)用,所以把它聲明為static是沒有意義的。
4.沒有實際的需要把構(gòu)造器定義成同步的,因為它將會在構(gòu)造的時候鎖住該對象,直到所有的構(gòu)造器完成它們的工作,這個構(gòu)造的過程對其它線程來說,通常是不可訪問的。
5.沒有本地的構(gòu)造器是任意一種語言的設(shè)計選擇,這樣會使得在創(chuàng)建對象的過程中JVM實現(xiàn)很容易去校驗父類的構(gòu)造器是否總是被正確地調(diào)用了。
(本地化的方法情況特別復(fù)雜,所以JVM調(diào)用起來非常麻煩,需要考慮很多種情況,沒有native關(guān)鍵字的情況下,JVM實現(xiàn)起來比較容易。)
PS:受俺導(dǎo)師的影響,第一次有這種沖動想去翻譯一些英文資料。雖然翻譯得很爛,但很欣慰。
歡迎來訪!^.^!
本BLOG僅用于個人學(xué)習(xí)交流!
目的在于記錄個人成長.
所有文字均屬于個人理解.
如有錯誤,望多多指教!不勝感激!