码迷,mamicode.com
首页 > 其他好文 > 详细

JNA的使用

时间:2015-04-18 10:07:56      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

JNA据说比jni简单很多,这里有一篇介绍,用法简单、但性能比jni有所下降(基于jni):
http://blog.csdn.net/shendl/article/details/3589676/


es中用得更简单:
package org.elasticsearch.common.jna;


import com.sun.jna.Native;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;




/**
 *
 */
public class CLibrary {


    private static ESLogger logger = Loggers.getLogger(CLibrary.class);


    public static final int MCL_CURRENT = 1;
    public static final int MCL_FUTURE = 2;


    public static final int ENOMEM = 12;


    static {
        try {
            Native.register("c");
        } catch (NoClassDefFoundError e) {
            logger.warn("JNA not found. native methods (mlockall) will be disabled.");
        } catch (UnsatisfiedLinkError e) {
            logger.warn("unable to link C library. native methods (mlockall) will be disabled.");
        }
    }


    public static native int mlockall(int flags);


    public static native int munlockall();


    private CLibrary() {
    }
}

JNA的使用

标签:

原文地址:http://blog.csdn.net/jollyjumper/article/details/45110621

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!