av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

Java訪問C++方法JavaCPP

JavaCPP提供了在Java中高效訪問本地C++的方法。采用JNI技術(shù)實(shí)現(xiàn),支持所有Java實(shí)現(xiàn)包括Android系統(tǒng),Avian 和 RoboVM。

JavaCPP提供了一系列的Annotation將Java代碼映射到C++代碼,并使用一個(gè)可執(zhí)行的jar包將C++代碼轉(zhuǎn)化為可以從JVM內(nèi)調(diào)用的動態(tài)鏈接庫文件。

Maven:

 
 
  1.     org.bytedeco
  2.     javacpp
  3.     0.11

使用方法:

C++:

 
 
  1. #include 
  2.  
  3. namespace LegacyLibrary {
  4.     class LegacyClass {
  5.         public:
  6.             const std::string& get_property() { return property; }
  7.             void set_property(const std::string& property) { this->property = property; }
  8.             std::string property;
  9.     };
  10. }

Java:

 
 
  1. import org.bytedeco.javacpp.*;
  2. import org.bytedeco.javacpp.annotation.*;
  3.  
  4. @Platform(include="LegacyLibrary.h")
  5. @Namespace("LegacyLibrary")
  6. public class LegacyLibrary {
  7.     public static class LegacyClass extends Pointer {
  8.         static { Loader.load(); }
  9.         public LegacyClass() { allocate(); }
  10.         private native void allocate();
  11.  
  12.         // to call the getter and setter functions 
  13.         public native @StdString String get_property(); public native void set_property(String property);
  14.  
  15.         // to access the member variable directly
  16.         public native @StdString String property();     public native void property(String property);
  17.     }
  18.  
  19.     public static void main(String[] args) {
  20.         // Pointer objects allocated in Java get deallocated once they become unreachable,
  21.         // but C++ destructors can still be called in a timely fashion with Pointer.deallocate()
  22.         LegacyClass l = new LegacyClass();
  23.         l.set_property("Hello World!");
  24.         System.out.println(l.property());
  25.     }
  26. }

分享題目:Java訪問C++方法JavaCPP
文章路徑:http://uogjgqi.cn/article/cdhiiej.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們在微信上24小時(shí)期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流