Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>GCJ provides <em>two</em> native interfaces for Java: <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/jni/index.html" rel="nofollow">JNI</a> using C and <a href="http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcj/About-CNI.html#About-CNI" rel="nofollow">CNI</a> using C++. Since the example you quote uses a class, it has to refer to the latter. The <a href="http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcj/Interfaces.html#Interfaces" rel="nofollow">CNI documentation on interfaces</a> only describes how to access interfaces described in Java from C++ code. Your example appears to work the other way round: a class written in C++ which is accessible from Java and serves as a Java interface.</p> <p>But there are pretty few details about this available, so trial and error will be one way to experiment with this, and looking at the actual GCC sources would be another. If you want to see one example of both the <code>extern "Java"</code> block and the <code>java_interface</code> attribute, have a look at <a href="https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libjava/java/lang/Readable.h;h=d8e7d2185c30f37a7971af2f94627d158e3bc606;hb=c9b304ada7111264d743b1c588393b66a3e3edfb" rel="nofollow"><code>java/lang/Readable.h</code></a>. It contains the C++ representation of the Java interface <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Readable.html" rel="nofollow"><code>java.lang.Readable</code></a>. As the first line of that file states, it is machine generated. So probably the reason why there is so little documentation is because you aren't supposed to write this stuff yourself. It's just a detail of how GCJ implements CNI. And looking more closely at the above file, it seems they even violate their own documentation, since that <code>Readable.h</code> has the attribute outside the <code>extern</code> block, in contrast to the snippet you quoted.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload