This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: quickie about visibility
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- To: Nic Ferrier <nferrier at tapsellferrier dot co dot uk>
- Cc: java at gcc dot gnu dot org
- Date: Wed, 23 Jan 2002 16:15:56 +1300
- Subject: Re: quickie about visibility
- References: <87wuy9wzhz.fsf@tf1.tapsellferrier.co.uk>
Nic Ferrier wrote:
>Sorry about all these, I'm just asking them as they occur to me...
>
>Is a C++ method allowed to call a C++ method which is not visible to
>Java through a class reference?
>
>For example:
>
>
>class T
>{
>
> public native void someX ();
>}
>
>
>CNI::
>
>void
>::someX ()
>{
> ::S s = new ::S ();
> s->privMethod ();
>}
>
>
>
>class S
>{
>}
>
>CNI::
>
>void
>privMethod ()
>{
> // do nothing.
>}
>
This should work assuming "privMethod" is not virtual. gcjh's --append
option allows you to add random methods to the header which lets you do
things like this pretty easily. I wouldn't reccomend it however, because
we may one day change the way static methods are dispatched for java types.
>T::someX creates a new S and then calls a method that is only visible
>to the C++ layer.
>
>I need to do this because I have some types that I'm trying to hide
>from Java, I need to expose them across class boundaries though so I
>was going to have the CNI of one class set them on another via a C++
>method not visible to the Java code.
>
>
>Anyone got any idea how to do this?
>
You could make them "private native" and use "gcjh --friend" or just
make them package-private native because those get mapped to public
methods in C++.
regards
Bryce.