Re: Understanding class access
- From: Chris Smith <cdsmith@xxxxxxx>
- Date: Thu, 31 May 2007 11:04:08 -0600
André Wagner <andre.nho@xxxxxxxxx> wrote:
let's say I'm writing a extension organized in packages such as:
mycompany.mypackage.MyClass
mycompany.mypackage.subpackage.MySubClass
Is there anyway that I can access MySubClass from MyClass, but make
MySubClass invisible for packages outside mycompany.mypackage?
No, because in fact, though the names look herarchical, your
mycompany.mypackage.subpackage is outside of mycompany.mypackage. (As a
side note, if MySubClass is a subclass of MyClass, then trying to access
MySubClass from MyClass is a cyclic dependency anyway.)
It's hard to suggest more than that without knowing why you don't want
anyone outside of mycompany.mypackage to access MySubClass. Is it
simply an organizational principle? If so, then you'll notice a lot of
packages in the standard librari have "implementation" or "provider"
subpackages, and just rely on documentation to say that others shouldn't
use it. If it's a security issue, such as when running untrusted code
in the VM, then you'll have to redesign a bit more than that.
--
Chris Smith
.
- References:
- Understanding class access
- From: André Wagner
- Understanding class access
- Prev by Date: Understanding class access
- Next by Date: Re: Understanding class access
- Previous by thread: Understanding class access
- Next by thread: Re: Understanding class access
- Index(es):
Relevant Pages
|