Inside Java™ 2 Platform Security: Architecture, API Design, and Implementation, Second Edition
by Li Gong, Gary Ellison, Mary Dageforde
9.7. Inner Classes
Inner classes as currently defined have some security implications. Suppose that class A has a private field accessible only from within the class itself. Further suppose that A is rewritten to use inner classes and now encloses an inner class B that requires access to the private field. During compilation, the compiler automatically inserts into the definition of A a package private access method to the private field so that B can call this method. One side effect of this design is that any class in the same package as A and B will be able to call the access method and thus access the private field whose access had been forbidden to it prior to the use of inner classes. Transforming a field from private to package private ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access