Example #1
0
        private static Class LoadClass(string name, JNIEnv env, ClassLoader classLoader)
        {
            Class  res;
            string rn = name.Replace('.', '/');

            res = env.FindClassNoThrow(rn);
            if (res == null)
            {
                if (classLoader == null)
                {
                    classLoader = systemClassLoader;
                }
                if (classLoader != null)
                {
                    try
                    {
                        res = classLoader.loadClass(name);
                    }
                    catch (Throwable th)
                    {
                        throw new JNIException("Can't load java class for " + name +
                                               ((classLoader == null) ? "" : " from classLoader " + classLoader), th);
                    }
                }
            }
            return(res);
        }
Example #2
0
        private static Class LoadClass(string name, JNIEnv env, bool throwNoFound)
        {
            Class  res;
            string rn = name.Replace('.', '/');

            res = env.FindClassNoThrow(rn);
            if (res == null && systemClassLoader != null)
            {
                try
                {
                    res = systemClassLoader.loadClass(name);
                }
                catch (Throwable th)
                {
                }
            }
            if (res == null && throwNoFound)
            {
                throw new JNIException("Can't find java class for " + name);
            }
            return(res);
        }