Example #1
0
        public FileInfo CppJniReflectionJavaP(string file, string currDir, string directory = "")
        {
            lock (this)
            {
                JavaCppReflectionOutput     = "";
                CurrentCppReflectionFile    = Path.Combine(currDir, file);
                if (!CurrentCppReflectionFile.Contains(".class"))
                {
                    CurrentCppReflectionFile += ".class";
                }
                else if (CurrentCppReflectionFile == "")
                {
                    CurrentCppReflectionFile = file;
                }

                JavaCppReflectionProcess            = new Process();
                JavaCppReflectionMessageBox         = new MessageScreenScrollable();
                JavaCppReflectionMessageBox.Text    = "javap Output";
                JavaCppReflectionMessageBox.AddOnCloseDelegate(JavaCppReflectionProcess_Exit);

                JavaCppReflectionProcess.Exited             += new EventHandler(JavaCppReflectionProcess_Exited);
                JavaCppReflectionProcess.OutputDataReceived += new DataReceivedEventHandler(JavaCppReflectionProcess_OutputDataReceived);
                JavaCppReflectionProcess.ErrorDataReceived  += new DataReceivedEventHandler(JavaCppReflectionProcess_ErrorDataReceived);

                try
                {
                    JavaCppReflectionMessageBox.Show();
                    JavaCppReflectionMessageBox.AppendText("Processing 1 File\n");

                    JavaCppReflectionMessageBox.AppendText("Calling argument:\n" + MainWindow.Instance.SelectedJdkEnvironment.JavaPLocation + " -s " + file + "\nWorking Directory:\t" + currDir + "\n\n----------------\n");

                    JavaCppReflectionProcess.StartInfo                          = new ProcessStartInfo(MainWindow.Instance.SelectedJdkEnvironment.JavaPLocation);
                    JavaCppReflectionProcess.StartInfo.WindowStyle              = ProcessWindowStyle.Minimized;
                    JavaCppReflectionProcess.StartInfo.WorkingDirectory         = currDir;
                    JavaCppReflectionProcess.StartInfo.Arguments                = "-s " + file;
                    JavaCppReflectionProcess.StartInfo.UseShellExecute          = false;
                    JavaCppReflectionProcess.StartInfo.CreateNoWindow           = true;
                    JavaCppReflectionProcess.StartInfo.RedirectStandardOutput   = true;
                    JavaCppReflectionProcess.StartInfo.RedirectStandardError    = true;

                    JavaCppReflectionProcess.Start();
                    JavaCppReflectionProcess.BeginOutputReadLine();
                    JavaCppReflectionProcess.BeginErrorReadLine();
                }
                catch (Exception e) { }
            }

            return null;
        }
Example #2
0
        public static void JavaHBatchForProjectModule(ref ProjectEnvironment.ProjectModule tanner, ref MessageScreenScrollable mockConsole, FileInfo javaH)
        {
            string arg                  = "-classpath ";
            string classPaths           = "";
            ProjectEnvironment project  = tanner.Project;
            List<string> allClasses     = new List<string>();
            int numberOfClasses         = 0;

            foreach (ProjectEnvironment.ProjectModule module in project.ProjectModules)
            {
                classPaths += module.JavaBinDirectory + Path.PathSeparator;
                allClasses.AddRange(module.JniClasses);
            }
            arg += classPaths.Substring(0, classPaths.Length - 1) + " -d jni ";

            numberOfClasses = allClasses.Count;
            if (mockConsole != null)
            {
                mockConsole.AppendText(Environment.NewLine + "found " + numberOfClasses + " classes with native methods");
            }

            RunBatch(allClasses.ToArray(), arg, javaH.FullName, tanner.ModuleRootDirectory, ref mockConsole);
        }
Example #3
0
        public static void RunBatch(string[] files, string arg, string javaH, string cwd, ref MessageScreenScrollable mockConsole)
        {
            if (files == null)
            {
                return;
            }

            int numberOfFiles                   = files.Length;
            JavaHBatchEntry[] batches           = new JavaHBatchEntry[numberOfFiles];
            Thread[] threads                    = new Thread[numberOfFiles];
            JavaHBatchIncrementer incrementer   = new JavaHBatchIncrementer(numberOfFiles, ref mockConsole);

            for (int i = 0; i < numberOfFiles; i++)
            {
                FileInfo file   = new FileInfo(files[i]);
                batches[i]      = new JavaHBatchEntry(file, arg, javaH, cwd, ref mockConsole, ref threads[i], ref incrementer);
                batches[i].Execute();
            }

            while (!AllThreadsDone(threads))
            {
                if (mockConsole != null)
                {
                    mockConsole.AppendText(Environment.NewLine + "...");
                }
                Thread.Sleep(1000);
            }
        }
        // Returns StdOut from javap for the given argumenbt in the current directory
        private void Javap(string arg, string currDir, int numFiles)
        {
            JavaPProcess                    = new Process();
            JavaPMessageBox                 = new MessageScreenScrollable();
            JavaPMessageBox.Text            = "javap Output";
            JavaPMessageBox.AddOnCloseDelegate(JavaPProcess_Exit);

            JavaPProcess.Exited             += new EventHandler(JavaPProcess_Exited);
            JavaPProcess.OutputDataReceived += new DataReceivedEventHandler(JavaPProcess_OutputDataReceived);
            JavaPProcess.ErrorDataReceived  += new DataReceivedEventHandler(JavaPProcess_ErrorDataReceived);

            try
            {
                JavaPMessageBox.Show();

                if (numFiles == 1)
                {
                    JavaPMessageBox.AppendText("Processing 1 File\n");
                }
                else
                {
                    JavaPMessageBox.AppendText("Processing " + numFiles + " Files\n");
                }

                JavaPMessageBox.AppendText("Calling argument:\n" + MainWindow.Instance.SelectedJdkEnvironment.JavaPLocation + " -s " + arg + "\nWorking Directory:\t" + currDir + "\n\n----------------\n");

                JavaPProcess.StartInfo = new ProcessStartInfo(MainWindow.Instance.SelectedJdkEnvironment.JavaPLocation);
                JavaPProcess.StartInfo.WindowStyle              = ProcessWindowStyle.Minimized;
                JavaPProcess.StartInfo.WorkingDirectory         = currDir;
                JavaPProcess.StartInfo.Arguments                = "-s " + arg;
                JavaPProcess.StartInfo.UseShellExecute          = false;
                JavaPProcess.StartInfo.CreateNoWindow           = true;
                JavaPProcess.StartInfo.RedirectStandardOutput   = true;
                JavaPProcess.StartInfo.RedirectStandardError    = true;

                JavaPProcess.Start();
                JavaPProcess.BeginOutputReadLine();
                JavaPProcess.BeginErrorReadLine();
            }
            catch (Exception e) {}
        }