问了第一个问题,所以我将直接解决。
我有一些将与Java接口的C代码。我做了有关JNI和该主题的作业。这是代码:
C部分:
#include <stdio.h>
#include <jni.h>
#include <string.h>
#define CLASSPATH "-Djava.class.path=/scratch/workareas/JTest/Java/" //folder which contains .class files
#define DEBUG 0
JNIEnv* create_vm(JavaVM ** jvm)
{
JNIEnv *env;
JavaVMInitArgs vm_args;
JavaVMOption options;
strcpy(options.optionString, CLASSPATH); //fix for options.optionString = CLASSPATH;
if (DEBUG) printf("optionString = %s\n", options.optionString);
vm_args.version = JNI_VERSION_1_6; //JDK version. This indicates version 1.6
vm_args.nOptions = 1;
vm_args.options = &options;
vm_args.ignoreUnrecognized = 0;
int ret = JNI_CreateJavaVM(jvm, (void**) &env, &vm_args);
if (ret < 0) printf("\n<<<<< Unable to Launch JVM >>>>>\n");
return env;
}
int main(int argc, char* argv[])
{
JNIEnv* env;
JavaVM* jvm;
printf("Creating JVM....");
env = create_vm(&jvm);
printf(" done! [env = %p\tjvm = %p]\n", env, jvm);
if (env == NULL) return 1;
jclass myClass = NULL;
jmethodID dispatchMessage = NULL;
int counter = 0;
//Obtaining Class
myClass = (*env)->FindClass(env, "EventHandler");
printf("FindClass done! [%p]\n", myClass);
//Obtaining Method ID
if (myClass != NULL)
dispatchMessage = (*env)->GetStaticMethodID(env, myClass, "dispatchEvent", "(I)V");
else
printf("Unable to find the requested class\n");
printf("Calling dispatchEvent() [%p] ...\n", dispatchMessage);
if (dispatchMessage != NULL)
{
// jstring newMessage = (*env)->NewStringUTF(env, "Test call::Called from C\n");
for(counter = 0; counter < 10; counter ++)
{
jint newMessage = counter;
(*env)->CallStaticVoidMethod(env, myClass, dispatchMessage, newMessage);
}
} printf("dispatchMessage() done!\n");
//Release resources.
printf("Releasing resources...");
(*jvm)->DestroyJavaVM(jvm);
printf(" done! Exiting.\n");
return 0;
}
Java部分:
public class EventHandler
{
public static final int EVENT_CODE_E1 = 1;
public static final int EVENT_CODE_E2 = 2;
//...
public static final int EVENT_CODE_E10 = 10;
private static EventHandler instance = new EventHandler();
public EventHandler()
{
//TODO: create object here
}
public static EventHandler getInstance()
{
if(instance == null)
instance = new EventHandler();
return instance;
}
public static void dispatchEvent(int eventCode)
{
switch(eventCode)
{
case EVENT_CODE_E1:
System.out.println("Event 1 firing!");
getInstance().onEventE1();
break;
case EVENT_CODE_E2:
System.out.println("Event 2 just fired!");
break;
//case
default:
System.out.println("Unknown event with ID: "+eventCode+" triggered!");
break;
}
}
private void onEventE1()
{
System.out.println("heyoooo");
}
}
现在出现了一个问题:执行了10次调用之后,这就是我得到的输出:
Creating JVM.... done! [env = 0x80e6d20 jvm = 0x177e6a4]
FindClass done! [0x80e7c78]
Calling dispatchEvent() [0x90b3fe8c] ...
Unknown event with ID: 0 triggered!
Event 1 firing!
heyoooo
Event 2 just fired!
Unknown event with ID: 3 triggered!
Unknown event with ID: 4 triggered!
Unknown event with ID: 5 triggered!
Unknown event with ID: 6 triggered!
Unknown event with ID: 7 triggered!
Unknown event with ID: 8 triggered!
Unknown event with ID: 9 triggered!
dispatchMessage() done!
Releasing resources... done! Exiting.
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x632e6176, pid=14752, tid=3077634256
#
# JRE version: 6.0_26-b03
# Java VM: Java HotSpot(TM) Server VM (20.1-b02 mixed mode linux-x86 )
# Problematic frame:
# C 0x632e6176
[error occurred during error reporting (printing problematic frame), id 0xb]
# An error report file with more information is saved as:
# /scratch/workareas/JTest/hs_err_pid14752.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Aborted
我不知道是什么原因导致了崩溃。我浏览了日志,没有任何意义。有人在乎需要帮助吗?:)
编辑:我还附上了日志,以防有人发现有趣的东西。我尝试将其与JNITest的objdump进行交叉引用,并尝试使用addr2line,但这样做没有任何好处。GDB会话也无法确定根本原因。
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x632e6176, pid=14752, tid=3077634256
#
# JRE version: 6.0_26-b03
# Java VM: Java HotSpot(TM) Server VM (20.1-b02 mixed mode linux-x86 )
# Problematic frame:
# C 0x632e6176
[error occurred during error reporting (printing problematic frame), id 0xb]
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
--------------- T H R E A D ---------------
Current thread is native thread
siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x632e6176
Registers:
EAX=0x00000000, EBX=0x0063dff4, ECX=0x0063e4e0, EDX=0x0063f360
ESP=0xbfd2f380, EBP=0x616a442d, ESI=0x00000000, EDI=0x00000000
EIP=0x632e6176, EFLAGS=0x00210246, CR2=0x632e6176
Top of Stack: (sp=0xbfd2f380)
0xbfd2f380: 7373616c 7461702e 732f3d68 74617263
0xbfd2f390: 772f6863 616b726f 73616572 65544a2f
0xbfd2f3a0: 4a2f7473 2f617661 00f7c100 00f8bad0
0xbfd2f3b0: b77108d0 0063dff4 00000000 00000000
0xbfd2f3c0: bfd2f3f8 2f09115f 15974820 00000000
0xbfd2f3d0: 00000000 00000000 00000001 08048400
0xbfd2f3e0: 00000000 00f81d90 004fbc0b 00f8aff4
0xbfd2f3f0: 00000001 08048400 00000000 08048421
Instructions: (pc=0x632e6176)
0x632e6156:
[error occurred during error reporting (printing registers, top of stack, instructions near pc), id 0xb]
Register to memory mapping:
EAX=0x00000000 is an unknown value
EBX=0x0063dff4: <offset 0x158ff4> in /lib/libc.so.6 at 0x004e5000
ECX=0x0063e4e0: _IO_2_1_stdout_+0 in /lib/libc.so.6 at 0x004e5000
EDX=0x0063f360: <offset 0x15a360> in /lib/libc.so.6 at 0x004e5000
ESP=0xbfd2f380 is an unknown value
EBP=0x616a442d is an unknown value
ESI=0x00000000 is an unknown value
EDI=0x00000000 is an unknown value
Stack: [0xbfce0000,0xbfd30000], sp=0xbfd2f380, free space=316k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C 0x632e6176
[error occurred during error reporting (printing native stack), id 0xb]
--------------- P R O C E S S ---------------
VM state:at safepoint (shutting down)
VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
[0x080e4aa0] Threads_lock - owner thread: 0x90b72000
Heap
PSYoungGen total 9408K, used 322K [0xa9e40000, 0xaa8c0000, 0xb4640000)
eden space 8064K, 4% used [0xa9e40000,0xa9e90b48,0xaa620000)
from space 1344K, 0% used [0xaa770000,0xaa770000,0xaa8c0000)
to space 1344K, 0% used [0xaa620000,0xaa620000,0xaa770000)
PSOldGen total 21504K, used 0K [0x94e40000, 0x96340000, 0xa9e40000)
object space 21504K, 0% used [0x94e40000,0x94e40000,0x96340000)
PSPermGen total 16384K, used 1751K [0x90e40000, 0x91e40000, 0x94e40000)
object space 16384K, 10% used [0x90e40000,0x90ff5f40,0x91e40000)
Code Cache [0xb470f000, 0xb494f000, 0xb770f000)
total_blobs=90 nmethods=0 adapters=58 free_code_cache=50039104 largest_free_block=0
Dynamic libraries:
00110000-00133000 r-xp 00000000 08:06 1710021 /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/libjava.so
00133000-00135000 rw-p 00023000 08:06 1710021 /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/libjava.so
00135000-00148000 r-xp 00000000 08:06 1845308 /lib/libnsl-2.12.1.so
00148000-00149000 r--p 00012000 08:06 1845308 /lib/libnsl-2.12.1.so
00149000-0014a000 rw-p 00013000 08:06 1845308 /lib/libnsl-2.12.1.so
0014a000-0014c000 rw-p 00000000 00:00 0
00154000-0015a000 r-xp 00000000 08:06 1845309 /lib/libnss_compat-2.12.1.so
0015a000-0015b000 r--p 00006000 08:06 1845309 /lib/libnss_compat-2.12.1.so
0015b000-0015c000 rw-p 00007000 08:06 1845309 /lib/libnss_compat-2.12.1.so
0015c000-00166000 r-xp 00000000 08:06 1845311 /lib/libnss_files-2.12.1.so
00166000-00167000 r--p 00009000 08:06 1845311 /lib/libnss_files-2.12.1.so
00167000-00168000 rw-p 0000a000 08:06 1845311 /lib/libnss_files-2.12.1.so
0019d000-001c1000 r-xp 00000000 08:06 1845306 /lib/libm-2.12.1.so
001c1000-001c2000 r--p 00023000 08:06 1845306 /lib/libm-2.12.1.so
001c2000-001c3000 rw-p 00024000 08:06 1845306 /lib/libm-2.12.1.so
001c3000-001c6000 ---p 00000000 00:00 0
001c6000-00214000 rwxp 00000000 00:00 0
00243000-00244000 ---p 00000000 00:00 0
00244000-002c4000 rwxp 00000000 00:00 0
002c4000-002c7000 ---p 00000000 00:00 0
002c7000-00315000 rwxp 00000000 00:00 0
0032d000-00342000 r-xp 00000000 08:06 1845316 /lib/libpthread-2.12.1.so
00342000-00343000 ---p 00015000 08:06 1845316 /lib/libpthread-2.12.1.so
00343000-00344000 r--p 00015000 08:06 1845316 /lib/libpthread-2.12.1.so
00344000-00345000 rw-p 00016000 08:06 1845316 /lib/libpthread-2.12.1.so
00345000-00347000 rw-p 00000000 00:00 0
00347000-0034a000 ---p 00000000 00:00 0
0034a000-00398000 rwxp 00000000 00:00 0
003ba000-003c9000 r-xp 00000000 08:06 1710024 /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/libzip.so
003c9000-003cb000 rw-p 0000e000 08:06 1710024 /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/libzip.so
003cb000-003ce000 ---p 00000000 00:00 0
003ce000-0044c000 rwxp 00000000 00:00 0
0044c000-0044f000 ---p 00000000 00:00 0
0044f000-004cd000 rwxp 00000000 00:00 0
004e5000-0063c000 r-xp 00000000 08:06 1845302 /lib/libc-2.12.1.so
0063c000-0063e000 r--p 00157000 08:06 1845302 /lib/libc-2.12.1.so
0063e000-0063f000 rw-p 00159000 08:06 1845302 /lib/libc-2.12.1.so
0063f000-00642000 rw-p 00000000 00:00 0
00642000-00643000 ---p 00000000 00:00 0
00643000-006c3000 rwxp 00000000 00:00 0
0077a000-0077c000 r-xp 00000000 08:06 1845305 /lib/libdl-2.12.1.so
0077c000-0077d000 r--p 00001000 08:06 1845305 /lib/libdl-2.12.1.so
0077d000-0077e000 rw-p 00002000 08:06 1845305 /lib/libdl-2.12.1.so
008ec000-008ed000 ---p 00000000 00:00 0
008ed000-0096d000 rwxp 00000000 00:00 0
0098b000-0098c000 r-xp 00000000 00:00 0 [vdso]
00991000-00992000 ---p 00000000 00:00 0
00992000-00a12000 rwxp 00000000 00:00 0
00a50000-00a57000 r-xp 00000000 08:06 1845318 /lib/librt-2.12.1.so
00a57000-00a58000 r--p 00006000 08:06 1845318 /lib/librt-2.12.1.so
00a58000-00a59000 rw-p 00007000 08:06 1845318 /lib/librt-2.12.1.so
00c40000-00c49000 r-xp 00000000 08:06 1845313 /lib/libnss_nis-2.12.1.so
00c49000-00c4a000 r--p 00008000 08:06 1845313 /lib/libnss_nis-2.12.1.so
00c4a000-00c4b000 rw-p 00009000 08:06 1845313 /lib/libnss_nis-2.12.1.so
00c76000-00c81000 r-xp 00000000 08:06 1710020 /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/libverify.so
00c81000-00c82000 rw-p 0000b000 08:06 1710020 /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/libverify.so
00e31000-00e34000 ---p 00000000 00:00 0
00e34000-00e82000 rwxp 00000000 00:00 0
00f6e000-00f8a000 r-xp 00000000 08:06 1845299 /lib/ld-2.12.1.so
00f8a000-00f8b000 r--p 0001b000 08:06 1845299 /lib/ld-2.12.1.so
00f8b000-00f8c000 rw-p 0001c000 08:06 1845299 /lib/ld-2.12.1.so
00f8c000-0173e000 r-xp 00000000 08:06 1710009 /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/server/libjvm.so
0173e000-01792000 rw-p 007b1000 08:06 1710009 /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/server/libjvm.so
01792000-01bb0000 rw-p 00000000 00:00 0
08048000-08049000 r-xp 00000000 08:11 3670021 /scratch/workareas/JTest/JNItest
08049000-0804a000 r--p 00000000 08:11 3670021 /scratch/workareas/JTest/JNItest
0804a000-0804b000 rw-p 00001000 08:11 3670021 /scratch/workareas/JTest/JNItest
080e2000-08103000 rw-p 00000000 00:00 0 [heap]
90734000-90934000 r--p 00000000 08:06 919903 /usr/lib/locale/locale-archive
90934000-90968000 rw-p 00000000 00:00 0
90968000-90b00000 r--s 03029000 08:06 1583846 /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar
90b00000-90ba1000 rw-p 00000000 00:00 0
90ba1000-90c00000 ---p 00000000 00:00 0
90c5b000-90c63000 rw-p 00000000 00:00 0
90c63000-90c7b000 rw-p 00000000 00:00 0
90c7b000-90c86000 rw-p 00000000 00:00 0
90c86000-90d23000 rw-p 00000000 00:00 0
90d23000-90d2b000 rw-p 00000000 00:00 0
90d2b000-90d43000 rw-p 00000000 00:00 0
90d43000-90d4e000 rw-p 00000000 00:00 0
90d4e000-90deb000 rw-p 00000000 00:00 0
90deb000-90df1000 rw-p 00000000 00:00 0
90df1000-90e3f000 rw-p 00000000 00:00 0
90e3f000-91e40000 rw-p 00000000 00:00 0
91e40000-94e40000 rw-p 00000000 00:00 0
94e40000-96340000 rw-p 00000000 00:00 0
96340000-a9e40000 rw-p 00000000 00:00 0
a9e40000-aa8c0000 rw-p 00000000 00:00 0
aa8c0000-b4640000 rw-p 00000000 00:00 0
b464f000-b4658000 rw-p 00000000 00:00 0
b4658000-b470f000 rw-p 00000000 00:00 0
b470f000-b494f000 rwxp 00000000 00:00 0
b494f000-b770f000 rw-p 00000000 00:00 0
b770f000-b7711000 rw-p 00000000 00:00 0
b771a000-b771b000 r--p 002a1000 08:06 919903 /usr/lib/locale/locale-archive
b771b000-b7723000 rw-s 00000000 08:06 1181409 /tmp/hsperfdata_rtrk/14752 (deleted)
b7723000-b7724000 rw-p 00000000 00:00 0
b7724000-b7725000 ---p 00000000 00:00 0
b7725000-b7728000 rw-p 00000000 00:00 0
bfce4000-bfd30000 rwxp 00000000 00:00 0 [stack]
bfd30000-bfd32000 rw-p 00000000 00:00 0
VM Arguments:
java_command: <unknown>
Launcher Type: generic
Environment Variables:
PATH=<snip, it's not the path>
USERNAME=rtrk
LD_LIBRARY_PATH=/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/server:/home/rtrk/workspace/UPnP/bin-pc/usr/local/lib:
SHELL=/bin/bash
DISPLAY=:0.0
Signal Handlers:
SIGSEGV: [libjvm.so+0x725510], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGBUS: [libjvm.so+0x725510], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGFPE: [libjvm.so+0x5dff20], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGPIPE: [libjvm.so+0x5dff20], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGXFSZ: [libjvm.so+0x5dff20], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGILL: [libjvm.so+0x5dff20], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000
SIGUSR2: [libjvm.so+0x5e3160], sa_mask[0]=0x00000000, sa_flags=0x10000004
SIGHUP: [libjvm.so+0x5e2d40], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGINT: [libjvm.so+0x5e2d40], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGTERM: [libjvm.so+0x5e2d40], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
SIGQUIT: [libjvm.so+0x5e2d40], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
--------------- S Y S T E M ---------------
OS:squeeze/sid
uname:Linux 2.6.35-22-generic #33-Ubuntu SMP Sun Sep 19 20:34:50 UTC 2010 i686
libc:glibc 2.12.1 NPTL 2.12.1
rlimit: STACK 8192k, CORE 0k, NPROC infinity, NOFILE 1024, AS infinity
load average:0.02 0.42 1.02
/proc/meminfo:
MemTotal: 2060876 kB
MemFree: 78596 kB
Buffers: 231004 kB
Cached: 1029676 kB
SwapCached: 42504 kB
Active: 711912 kB
Inactive: 1193204 kB
Active(anon): 399420 kB
Inactive(anon): 251192 kB
Active(file): 312492 kB
Inactive(file): 942012 kB
Unevictable: 0 kB
Mlocked: 0 kB
HighTotal: 1187784 kB
HighFree: 18836 kB
LowTotal: 873092 kB
LowFree: 59760 kB
SwapTotal: 1998844 kB
SwapFree: 1841240 kB
Dirty: 232 kB
Writeback: 0 kB
AnonPages: 613140 kB
Mapped: 47840 kB
Shmem: 6164 kB
Slab: 54384 kB
SReclaimable: 41476 kB
SUnreclaim: 12908 kB
KernelStack: 3072 kB
PageTables: 7384 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 3029280 kB
Committed_AS: 1775172 kB
VmallocTotal: 122880 kB
VmallocUsed: 7284 kB
VmallocChunk: 108952 kB
HardwareCorrupted: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 4096 kB
DirectMap4k: 16376 kB
DirectMap4M: 892928 kB
CPU:total 2 (1 cores per cpu, 1 threads per core) family 6 model 42 stepping 7, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt
/proc/cpuinfo:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz
stepping : 7
cpu MHz : 3093.040
cache size : 6144 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat pln pts
bogomips : 6186.08
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz
stepping : 7
cpu MHz : 3093.040
cache size : 6144 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat pln pts
bogomips : 6186.08
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:
Memory: 4k page, physical 2060876k(78580k free), swap 1998844k(1841240k free)
vm_info: Java HotSpot(TM) Server VM (20.1-b02) for linux-x86 JRE (1.6.0_26-b03), built on May 4 2011 01:04:10 by "java_re" with gcc 3.2.1-7a (J2SE release)
time: Fri Dec 16 10:58:12 2011
elapsed time: 3 seconds
感谢大家的努力:)
问题已解决。
搜索更多内容后,我发现了这篇文章http://docs.oracle.com/javase/1.4.2/docs/guide/jni/jni-12.html#JNI_OnLoad
在它的底部附近是一个很好的示例,说明了如何传递多个选项以及如何命名它们。原来-Xcheck:jni是作为-
DXcheck:jni传递的(jni:pedantic也可以),当我将strcpy从代码中移出后,我不再获得崩溃转储。我怀疑这是罪魁祸首,但其中一个骗人。
这是更新的代码位:
JNIEnv* create_vm(JavaVM ** jvm)
{
JNIEnv *env;
JavaVMInitArgs vm_args;
JavaVMOption options[2];
options[0].optionString = CLASSPATH; //"-Djava.class.path=/scratch/workareas/JTest/Java/"
options[1].optionString = "-DXcheck:jni:pedantic";
vm_args.version = JNI_VERSION_1_6; //JDK version. This indicates version 1.6
vm_args.nOptions = 2;
vm_args.options = options;
vm_args.ignoreUnrecognized = JNI_TRUE; //drop unrecognized options
int ret = JNI_CreateJavaVM(jvm, (void**) &env, &vm_args);
if (ret < 0) printf("\n<<<<< Unable to Launch JVM >>>>>\n");
return env;
}
不久前,我打开电脑处理我一直在开发的Minecraft mod,但我没有像往常一样运行,而是得到了这个例外: 在尝试了几个小时之后,我意识到我的代码没有问题。我试着运行我制作的其他java程序。一个简单的Hello World程序工作了,但我的LWJGL游戏也出现了同样的异常,我使用的任何程序都因文件未找到而崩溃。IO程序也适用于通过GitHub从事同一项目的其他人。 来自IntelliJ的日志太
我的应用程序使用了一个定时器,该定时器使用格式的字符串构造。当用户超过resetTimeString记录的时间时,下一个重置时间将通过递增到下一天(“a”值不变)并将该值存储在数据库中来确定。简单地说,它代表一个每日计时器,每个用户都可以选择他们自己的'a'值。 我让许多用户联系了一次崩溃,在比较了数据库中的值之后,他们似乎都有的 我测试了值的一系列不同值,它们都工作得非常好: 我对这次撞车很困惑
问题内容: 这是成功的一个例子: 请注意,insert-select中的第二列是明确为null。 这是一个失败的示例: 请注意,在此示例中,我得到了,而不是第二列中的显式null ,它从delete语句作为null返回。 如果两个值都为null,那么第二个示例为什么会因为这个错误而困扰我?我已经仔细检查了两者,这是唯一的功能差异。 问题答案: 在第一个示例中,您为语句提供了一个 尚未输入类型的 N
下面是一些代码: Java代码: 上面所有的工作都很好,但是C++试图做同样的事情,却做不到。(注意:我需要本机库中的类作为类,而不是独立的静态调用) 更新了MyClass::SomeCall定义:
问题内容: 我收到了一些来自Android的崩溃报告(带有java.lang.NullPointerException),但 我不明白 下面的 stacktrace 中的 __null __是什么意思 : 而且我不明白什么是access $ xxx函数? 此外,既不直接也不间接从onEnterPressed调用formatElapsedTime!绝对是!从计时器线程通过runOnUiThread调
问题内容: 我有一个第三方.NET Assembly和一个大型Java应用程序。我需要从Java应用程序调用.NET类库提供的方法。该程序集不支持COM。我已经搜索过网络,到目前为止,我有以下内容: C#代码(cslib.cs): 编译使用(使用.net 3.5,但使用2.0时也会发生同样的情况): C ++代码(clib.cpp): (使用VC 2008工具进行编译),但使用2003工具时也会发