Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在java中调用DLL:无法写入核心转储_Java_C++_Ifstream_Core - Fatal编程技术网

在java中调用DLL:无法写入核心转储

在java中调用DLL:无法写入核心转储,java,c++,ifstream,core,Java,C++,Ifstream,Core,我试图用C++构建DLL,然后从Java调用它。 DLL有一个简单的函数,它应该从文件中读取行,进行一些操作,然后以二进制模式保存文件。代码如下: const char* filepath = "C:\\tmp\\test.txt"; std::ifstream input_file; input_file.open(filepath, std::ios::in)); char line_array[100]; while( !input_file.eof() ) { in

我试图用C++构建DLL,然后从Java调用它。 DLL有一个简单的函数,它应该从文件中读取行,进行一些操作,然后以二进制模式保存文件。代码如下:

    const char* filepath = "C:\\tmp\\test.txt";

std::ifstream input_file;
input_file.open(filepath, std::ios::in));

char line_array[100];

while( !input_file.eof() ) {
    input_file.getline(line_array, sizeof(input_file));
}
input_file.close();

//some operations
//that gives me     
long int arrayToSave[100];

std::ofstream file;
const char* path = "C:\\tmp\\result.txt";
file.open(path, std::ios::out | std::ios::binary);
if (file.good()) {
    file.write((char*) &arrayToSave, sizeof (arrayToSave));
    file.close();
    res = 1;
}
在我尝试从Java调用它之前,一切都很好,错误如下:

 {
 A fatal error has been detected by the Java Runtime Environment:

  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000180103fd9, pid=5612, tid=5728

 JRE version: Java(TM) SE Runtime Environment (7.0_51-b13) (build 1.7.0_51-b13)
 Java VM: Java HotSpot(TM) 64-Bit Server VM (24.51-b03 mixed mode windows-amd64 compressed oops)
 Problematic frame:
 C  [cygwin1.dll+0xc3fd9]

 Failed to write core dump. Minidumps are not enabled by default on client versions of Windows

 An error report file with more information is saved as:
 C:\workspace\netbeansCAEE\JNAHelloWorldMWrobel\hs_err_pid5612.log
}


我已经在Windows 7选项中启用了小内存转储。

尝试找出它在哪一行上崩溃。这里要做的最好的事情就是打印好语句。或者,如果您正在使用IDE进行C++开发,您可以通过将C++IDE附加到java进程来使用断点<代码>C:\workspace\netbeansCAEE\JNAHelloWorldMWrobel\hs_err_pid5612.logJames;它正在std::ifstream输入文件上崩溃;(包括fstream)vojta:以下是hs_err_pid612.log内容: