Memory JNA:java.lang.Error:对Fortran DLL的内存访问无效

Memory JNA:java.lang.Error:对Fortran DLL的内存访问无效,memory,dll,fortran,jna,Memory,Dll,Fortran,Jna,对JNA来说相当陌生,但尝试链接Fortran dll时获得的内存访问无效 fortran代码: FUNCTION OpenFile(FileName,LenFileName) RESULT(Stat) INTEGER,INTENT(IN) :: LenFileName CHARACTER(LEN=LenFileName),INTENT(IN) :: FileName INTEGER :: Stat !Set the level of messaging to error and war

对JNA来说相当陌生,但尝试链接Fortran dll时获得的内存访问无效

fortran代码:

FUNCTION OpenFile(FileName,LenFileName) RESULT(Stat)   
INTEGER,INTENT(IN) :: LenFileName
CHARACTER(LEN=LenFileName),INTENT(IN) :: FileName
INTEGER :: Stat

!Set the level of messaging to error and warning messages only
CALL ZSET('MLEVEL','',0)

!Set an unconnected unit number for the file
CALL ZSET('UNIT','',1111)

!Open file
CALL ZOPEN(IFLTAB(:,iOpenFiles+1),FileName,Stat)

iOpenFiles             = iOpenFiles + 1
cFileNames(iOpenFiles) = FileName
END FUNCTION OpenFile
界面:

public interface test extends com.sun.jna.Library {
    test reader = (test) Native.loadLibrary("test.dll", test.class);

    int OpenFile(String FileName, int LenFileName);
} 
用这个来称呼它:

int ret = test.reader.OpenFile(fileName, fileName.length());    
接收错误

Exception in thread "main" java.lang.Error: Invalid memory access
at com.sun.jna.Native.invokeInt(Native Method)
at com.sun.jna.Function.invoke(Function.java:383)
at com.sun.jna.Function.invoke(Function.java:315)
at com.sun.jna.Library$Handler.invoke(Library.java:212)
at com.sun.proxy.$Proxy0.OpenFile(Unknown Source)
Java Result: 1

尝试使用jnavior util提供apriori正确的方法映射