由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Answer to "Is this a Bug or not? "
相关主题
Answer 2 to "Is this a Bug or not? "Stack Frame of your JVM implementation
anonymous innerclass reflection questionThe shape of JVM stack frame
问一个java的面试题 (转载)Top Ten Errors Java Programmers Make(10)
[合集] java 得 inner class 有没有 static 有什么区别啊?Is this a Bug or not?
Netbean duplicate class errorJava's performance myth
Where I can find comparison of JVMsJVM
Hibernate sequences questionRe: system property in java
An experiment with JVM Garbage Collection SchemesJava questions 51-100
相关话题的讨论汇总
话题: bug话题: answer话题: class话题: spec话题: private
进入Java版参与讨论
1 (共1页)
m***a
发帖数: 198
1
No, it is not a bug. All the "private", "protected" words
have no effect for classes if one of them is an inner class
of the other.
That is, if B is an inner class of A, then A can access any
memeber in B, and B can access any member of A, even private
members.
This is buried somewhere in the InnerClass Spec. try dig
java.sun.com for it.
FYI: The following is also valid:
//---------------------------------------------
public class A {
public void play(){
class B{
class C{
private int x=3;
}
C c
m***a
发帖数: 198
2
In my post #3404 I was answering the following question
that was originally raised by post #3394:
The generating of A$1 is an implementation-specific
feature. Neither JVM spec nor Java Language Spec
defined this behavior. In other words you can write
your own Java compiler that follows the Spec and generating
some classes like A$1, A$2, ...
They are legal.
see the following text from this URL, note the actural
name of the class can be "chosen by the compiler".
" target="_blank" class="a2">http:/
1 (共1页)
进入Java版参与讨论
相关主题
Java questions 51-100Netbean duplicate class error
[转载] 现在还有什么OS不是THREAD级调度的吗?Where I can find comparison of JVMs
[转载] linux下的java sound问题Hibernate sequences question
菜鸟问题一问An experiment with JVM Garbage Collection Schemes
Answer 2 to "Is this a Bug or not? "Stack Frame of your JVM implementation
anonymous innerclass reflection questionThe shape of JVM stack frame
问一个java的面试题 (转载)Top Ten Errors Java Programmers Make(10)
[合集] java 得 inner class 有没有 static 有什么区别啊?Is this a Bug or not?
相关话题的讨论汇总
话题: bug话题: answer话题: class话题: spec话题: private