This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: quickie about visibility


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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]