Esempio n. 1
0
        void CreateJavaVM(string jvmDllPath)
        {
            var builder = new JreRuntimeOptions {
                JvmLibraryPath = jvmDllPath,
            };

            try {
                builder.CreateJreVM();
            } catch (Exception e) {
                ErrorAndExit(Message.ErrorUnableToCreateJavaVM, Environment.NewLine, e);
            }
        }
Esempio n. 2
0
        void CreateJavaVM(string jvmDllPath)
        {
            var builder = new JreRuntimeOptions {
                JvmLibraryPath = jvmDllPath,
            };

            try {
                builder.CreateJreVM();
            } catch (Exception e) {
                Error($"Unable to create Java VM{Environment.NewLine}{e}");
                Environment.Exit(3);
            }
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            string?jvmPath           = global::Java.InteropTests.TestJVM.GetJvmLibraryPath();
            bool   createMultipleVMs = false;
            bool   showHelp          = false;
            var    options           = new OptionSet()
            {
                "Using the JVM from C#!",
                "",
                "Options:",
                { "jvm=",
                  $"{{PATH}} to JVM to use.  Default is:\n  {jvmPath}",
                  v => jvmPath = v },
                { "m",
                  "Create multiple Java VMs.  This will likely creash.",
                  v => createMultipleVMs = v != null },
                { "h|help",
                  "Show this message and exit.",
                  v => showHelp = v != null },
            };

            options.Parse(args);
            if (showHelp)
            {
                options.WriteOptionDescriptions(Console.Out);
                return;
            }
            Console.WriteLine("Hello World!");
            var builder = new JreRuntimeOptions()
            {
                JniAddNativeMethodRegistrationAttributePresent = true,
                JvmLibraryPath = jvmPath,
            };

            builder.AddOption("-Xcheck:jni");
            var jvm = builder.CreateJreVM();

            Console.WriteLine($"JniRuntime.CurrentRuntime == jvm? {ReferenceEquals (JniRuntime.CurrentRuntime, jvm)}");
            foreach (var h in JniRuntime.GetAvailableInvocationPointers())
            {
                Console.WriteLine("PRE: GetCreatedJavaVMHandles: {0}", h);
            }

            CreateJLO();

            if (createMultipleVMs)
            {
                CreateAnotherJVM();
            }
        }
Esempio n. 4
0
    public static void Main()
    {
        var runtimeOptions = new JreRuntimeOptions()
        {
            JvmLibraryPath = Environment.GetEnvironmentVariable("JI_JVM_PATH"),
        };
        var    GlobalRuntime = runtimeOptions.CreateJreVM();
        IntPtr _env          = global::Java.Interop.JniEnvironment.EnvironmentPointer;

        SafeTiming(_env);
        XAIntPtrTiming(_env);
        JIIntPtrTiming(_env);
        JIPinvokeTiming(_env);

        GlobalRuntime.Dispose();
    }
Esempio n. 5
0
        static JniRuntime CreateJavaVM()
        {
            var builder = new JreRuntimeOptions();

            return(builder.CreateJreVM());
        }