MCPcopy Create free account
hub / github.com/apple/foundationdb / addToClassPath

Method addToClassPath

bindings/java/JavaWorkload.cpp:322–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320#define getField(clazz, name, signature) getFieldImpl(__FILE__, __LINE__, clazz, name, signature)
321
322 void addToClassPath(const std::string& path) {
323 log->trace(info, "TryAddToClassPath", { { "Path", path } });
324 if (!env) {
325 throw JNIError{};
326 }
327 if (classPath.count(path) > 0) {
328 // already added
329 return;
330 }
331 auto p = env->NewStringUTF(path.c_str());
332 checkException();
333 auto fileClass = getClass("java/io/File");
334 auto file = env->NewObject(fileClass, getMethod(fileClass, "<init>", "(Ljava/lang/String;)V"), p);
335 checkException();
336 auto uri = env->CallObjectMethod(file, env->GetMethodID(fileClass, "toURI", "()Ljava/net/URI;"));
337 checkException();
338 auto uriClass = getClass("java/net/URI");
339 auto url = env->CallObjectMethod(uri, getMethod(uriClass, "toURL", "()Ljava/net/URL;"));
340 checkException();
341 auto classLoaderClass = getClass("java/lang/ClassLoader");
342 auto sysLoaderMethod =
343 env->GetStaticMethodID(classLoaderClass, "getSystemClassLoader", "()Ljava/lang/ClassLoader;");
344 checkException();
345 auto classLoader = env->CallStaticObjectMethod(classLoaderClass, sysLoaderMethod);
346 checkException();
347 auto urlLoaderClass = getClass("java/net/URLClassLoader");
348 env->CallVoidMethod(classLoader, getMethod(urlLoaderClass, "addURL", "(Ljava/net/URL;)V"), url);
349 env->DeleteLocalRef(classLoader);
350 checkException();
351 }
352
353 void init() {
354 if (abstractWorkloadClass != nullptr) {

Callers 1

initMethod · 0.80

Calls 4

getMethodFunction · 0.85
countMethod · 0.65
traceMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected