/* * Class: java_lang_VMClassRegistry * Method: defineClass * Signature: (Ljava/lang/String;[BII)Ljava/lang/Class; */ JNIEXPORT jclass JNICALL Java_java_lang_ClassLoader_defineClass0 (JNIEnv *jenv, jobject cl, jstring name, jbyteArray data, jint offset, jint len) { const char* clssname = NULL; // obtain char * for the name if provided if(name) { clssname = GetStringUTFChars(jenv, name, NULL); } // obtain raw classfile data data pointer jboolean is_copy; jbyte *bytes = GetByteArrayElements(jenv, data, &is_copy); assert(bytes); // define class jclass clss = DefineClass(jenv, clssname, cl, bytes + offset, len); // release JNI objects ReleaseByteArrayElements(jenv, data, bytes, 0); if(clssname) ReleaseStringUTFChars(jenv, name, clssname); return clss; }
Napi::Object STLSurfJS::Init(Napi::Env env, Napi::Object exports) { Napi::HandleScope scope(env); Napi::Function func = DefineClass(env, "STLSurf", { InstanceMethod("getTriangles", &STLSurfJS::getTriangles) }); constructor = Napi::Persistent(func); constructor.SuppressDestruct(); exports.Set("STLSurf", func); return exports; }
void AdaptivePathDropCutterJS::Init(Napi::Env env, Napi::Object exports) { Napi::HandleScope scope(env); Napi::Function func = DefineClass(env, "AdaptivePathDropCutter", { InstanceMethod("setSTL", &AdaptivePathDropCutterJS::setSTL), InstanceMethod("setPath", &AdaptivePathDropCutterJS::setPath), InstanceMethod("setCylCutter", &AdaptivePathDropCutterJS::setCylCutter), InstanceMethod("setBallCutter", &AdaptivePathDropCutterJS::setBallCutter), InstanceMethod("setBullCutter", &AdaptivePathDropCutterJS::setBullCutter), InstanceMethod("setConeCutter", &AdaptivePathDropCutterJS::setConeCutter), InstanceMethod("setSampling", &AdaptivePathDropCutterJS::setSampling), InstanceMethod("setMinSampling", &AdaptivePathDropCutterJS::setMinSampling), InstanceMethod("getCLPoints", &AdaptivePathDropCutterJS::getCLPoints), InstanceMethod("run", &AdaptivePathDropCutterJS::run) }); constructor = Napi::Persistent(func); constructor.SuppressDestruct(); exports.Set("AdaptivePathDropCutter", func); }
Class* ClassLoader::FindClass(const char* name) { util::ClassName clsName(name); Class* cls = DefineClass(clsName.Get()); return cls; }