jni.cpp 里的问题在Google上搜了2天找不到答案,先寄希望与各位老兄。
这个问题是关于jni的。因为最近很多问题都与jni挂钩了。所以看了下jni.h,jni.cpp. 看到jni.cpp 我卡壳了!
问题1:jni.cpp包含的这2个文件在哪里?
# include "incls/_precompiled.incl"
# include "incls/_jni.cpp.incl"
问题2:这样的c++宏是什么意思 JNI_ENTRY 开头 JNI_END结束(下面是摘抄的一个例子)
DT_RETURN_MARK_DECL(DefineClass, jclass);
JNI_ENTRY(jclass, jni_DefineClass(JNIEnv *env, const char *name, jobject loaderRef,
const jbyte *buf, jsize bufLen))
JNIWrapper("DefineClass");
DTRACE_PROBE5(hotspot_jni, DefineClass__entry,
env, name, loaderRef, buf, bufLen);
jclass cls = NULL;
DT_RETURN_MARK(DefineClass, jclass, (const jclass&)cls);
// Since exceptions can be thrown, class initialization can take place
// if name is NULL no check for class name in .class stream has to be made.
symbolHandle class_name;
if (name != NULL) {
const int str_len = (int)strlen(name);
if (str_len > symbolOopDesc::max_length()) {
// It's impossible to create this class; the name cannot fit
// into the constant pool.
THROW_MSG_0(vmSymbols::java_lang_
NoClassDefFoundError(), name);
}
class_name = oopFactory::new_symbol_handle(name, str_len, CHECK_NULL);
}
ResourceMark rm(THREAD);
ClassFileStream st((u1*) buf, bufLen, NULL);
Handle class_loader (THREAD, JNIHandles::resolve(loaderRef));
if (UsePerfData && !class_loader.is_null()) {
// check whether the current caller thread holds the lock or not.
// If not, increment the corresponding counter
if (ObjectSynchronizer::
query_lock_ownership((JavaThread*)THREAD, class_loader) !=
ObjectSynchronizer::owner_self) {
ClassLoader::sync_JNIDefineClassLockFreeCounter()->inc();
}
}
klassOop k = SystemDictionary::resolve_from_stream(class_name, class_loader,
Handle(), &st, CHECK_NULL);
cls = (jclass)JNIHandles::make_local(
env, Klass::cast(k)->java_mirror());
return cls;
JNI_END
注:我在网上搜到这么个大略答案。上面包含的文件是构建过程中产生的。 但还是理解不上。希望那位老兄不吝赐教!
------解决方案--------------------
UP