protected constructor confusion Permanently deleted user 创建于 2003年12月04日 22:41 Hi AllPlease see the following codenew C1(); is an error. But IDEA is not showing any error and there is Green light.Is this a bug in IDEA? Or Am I missing something?ThanksAnki.N
Forgot to mention --- Build is 944
Why would this code be invalid? C2 extends C1 and thus has access to all protected members (including constructors).
Thats why confusing. Compile this class, it gives error.
Is still access modifiers not stabilized in JLS???
By the way JDK is 1.3.0_03
Imagine you have a protected method
in C1.
It's ok to call
from a method in C2. However it's
not allowed to call foo on an another object of class C1:
<-- error
That's why you can call
from within C2's constructor but cannot usr
.
So it's a bug in Idea, please file a tracker item (btw the bug is still there in 977).
Please submit an SCR.
--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"
"Anki" <no_mail@jetbrains.com> wrote in message
news:3423438.1070577704896.JavaMail.javamailuser@localhost...
>
>
Green light.
>
>
The protected constructors is not easy.
http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#72728
You can call protected constructors by "new" operators only in case of inner class, as i can understand
Thanks!
You learn something new every day. Thanks.
--Dave
I Just submitted
Thanks.