Beispiel #1
0
        /// <summary>
        /// Gets the JVM options.
        /// </summary>
        private static JvmOption[] GetJvmOptions(IList <string> options)
        {
            var opt = new JvmOption[options.Count];

            for (var i = 0; i < options.Count; i++)
            {
                opt[i].optionString = Marshal.StringToHGlobalAnsi(options[i]);
            }

            return(opt);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the JVM pointer.
        /// </summary>
        private static IntPtr GetJvmPtr(IList <string> options)
        {
            IntPtr jvm;
            int    existingJvmCount;

            // Use existing JVM if present.
            var res = JvmDll.Instance.GetCreatedJvms(out jvm, 1, out existingJvmCount);

            if (res != JniResult.Success)
            {
                throw new IgniteException("JNI_GetCreatedJavaVMs failed: " + res);
            }

            if (existingJvmCount > 0)
            {
                return(jvm);
            }

            var args = new JvmInitArgs
            {
                version = JNI_VERSION_1_6
            };

            if (options != null && options.Count > 0)
            {
                args.nOptions = options.Count;
                var opt = new JvmOption[options.Count];

                for (int i = 0; i < options.Count; i++)
                {
                    opt[i].optionString = Marshal.StringToHGlobalAnsi(options[i]);
                }

                fixed(JvmOption *a = &opt[0])
                {
                    args.options = a;
                }
            }

            IntPtr env;

            res = JvmDll.Instance.CreateJvm(out jvm, out env, &args);
            if (res != JniResult.Success)
            {
                throw new IgniteException("JNI_CreateJavaVM failed: " + res);
            }

            return(jvm);
        }