为什么我在运行 java 程序时收到此消息
Why do i get this message when i run the java program?
Java Code :
package Package;
public class MyExceptionTester {
private native void compute() throws Exception;
public static void main(String... args) {
try {
MyExceptionTester met = new MyExceptionTester();
met.compute(); // This method will throw an exception which gets printed from the catch block
} catch(Exception exc) {
System.out.println("From Java :" + exc);
}
}
static {
System.loadLibrary("MyExceptionTester");
}
}
C++代码 :
#include "iostream"
#include "Package_MyExceptionTester.h"
void Java_Package_MyExceptionTester_compute
(JNIEnv *env, jobject obj) {
jthrowable exc;
try {
jint i = 1/0;
throw "C++ Message : Hey ! Can't Divide By Zero";
} catch(char *str) {
jclass excClass = env->FindClass("java/lang/Exception");
if(excClass == NULL) {
return;
}
env->ThrowNew(excClass,str);
}
}
当我在包含dll后运行java程序时,我收到以下消息:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_INT_DIVIDE_BY_ZERO (0xc0000094) at pc=0x65c4121a, pid=5292, tid=6000
#
# JRE version: 7.0
# Java VM: Java HotSpot(TM) Client VM (20.0-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [MyExceptionTester.dll+0x121a]
#
# An error report file with more information is saved as:
# W:elitajnitestersworkspacejavaJNIbuildclasseshs_err_pid5292.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
为什么我会收到此消息?为什么我看不到输出,它应该是从java catch块打印的消息。
jint i = 1/0;
throw "C++ Message : Hey ! Can't Divide By Zero";
您的try/catch
块不会捕获此异常,因为程序在 throw 语句之前崩溃。除以0
也不是您可以抓住的例外。
也许可能会有所帮助:
int d = 0;
jthrowable exc;
try
{
if ( d == 0 )
throw "C++ Message : Hey ! Can't Divide By Zero";
jint i = 1/d;
} catch(char *str)
{
jclass excClass = env->FindClass("java/lang/Exception");
if(excClass == NULL)
{
return;
}
env->ThrowNew(excClass,str);
}
本机代码调用已在 JVM 内部。由于本机程序在抛出异常之前崩溃,因此本机程序中的崩溃也会导致 JVM 崩溃。
相关文章:
- "string.h"在构建适用于iOS的qt应用程序中找不到消息
- 将加密消息从 php 发送到 C++ 应用程序,然后使用 CryptoPP 进行解密
- Log4net,将日志消息从 c++ dll 发送到 c# 应用程序?
- 如何制作一个程序,它使用特定单词加密和解密消息?
- 从函数打印 CLI 帮助消息后,我应该如何干净地退出 C++ 程序?
- Aysnc 处理程序用于 POCO Websocket 中的传入消息
- 消息分析程序继承的替代方法
- 客户端发送消息,但服务器在客户端结束程序之前不接收消息
- C++循环:如何让程序在用户输入无效输入时多次重复"error"消息
- 奇怪的消息 (_Base_bitset::_M_do_to_ulong) 从溢出异常处理程序中打印出来
- 从处理程序捕获时如何获取 Ada 异常消息C++?
- SDL Hello World 程序不输出消息
- 核心消息传递中未处理的异常.dll在程序关闭期间
- OpenGL 着色器程序无法验证,但不提供错误消息
- 将 Kamailio SIP 消息转发到 C 应用程序
- 使用 Microsoft VS 编写程序C++,但我在这里收到调试断言消息.它可以在 cpp.sh 上运行,repl.i
- 如果我在 Xbox UWP 应用程序上收到激活错误并且错误消息中没有任何有用的内容,该怎么办
- 任何人都有任何想法编写与C 旧手机中的消息作曲家以相同方式工作的程序
- 阻止后台应用程序接收消息
- 为什么调用单例类 Qt 消息处理程序成员函数会出现错误:缺少参数列表