getProperty() private method

private getProperty ( global par0 ) : global::java.lang.String
par0 global
return global::java.lang.String
示例#1
0
            public virtual Void Run()
            {
                bool   loaded = false;
                String jit    = System.getProperty("java.compiler");

                if ((jit != null) && (!jit.Equals("NONE")) && (!jit.Equals("")))
                {
                    try
                    {
//JAVA TO C# CONVERTER TODO TASK: The library is specified in the 'DllImport' attribute for .NET:
//						System.loadLibrary(jit);
                        initialize();
                        loaded = true;
                    }
                    catch (UnsatisfiedLinkError)
                    {
                        System.Console.Error.WriteLine("Warning: JIT compiler \"" + jit + "\" not found. Will use interpreter.");
                    }
                }
                String info = System.getProperty("java.vm.info");

                if (loaded)
                {
                    System.setProperty("java.vm.info", info + ", " + jit);
                }
                else
                {
                    System.setProperty("java.vm.info", info + ", nojit");
                }
                return(null);
            }
示例#2
0
        /// <summary>
        /// Returns {@code true} if and only if the system property
        /// named by the argument exists and is equal to the string
        /// {@code "true"}. (Beginning with version 1.0.2 of the
        /// Java<small><sup>TM</sup></small> platform, the test of
        /// this string is case insensitive.) A system property is accessible
        /// through {@code getProperty}, a method defined by the
        /// {@code System} class.
        /// <para>
        /// If there is no property with the specified name, or if the specified
        /// name is empty or null, then {@code false} is returned.
        ///
        /// </para>
        /// </summary>
        /// <param name="name">   the system property name. </param>
        /// <returns>  the {@code boolean} value of the system property. </returns>
        /// <exception cref="SecurityException"> for the same reasons as
        ///          <seealso cref="System#getProperty(String) System.getProperty"/> </exception>
        /// <seealso cref=     java.lang.System#getProperty(java.lang.String) </seealso>
        /// <seealso cref=     java.lang.System#getProperty(java.lang.String, java.lang.String) </seealso>
        public static bool GetBoolean(String name)
        {
            bool result = false;

            try
            {
                result = ParseBoolean(System.getProperty(name));
            }
//JAVA TO C# CONVERTER TODO TASK: There is no equivalent in C# to Java 'multi-catch' syntax:
            catch (IllegalArgumentException | NullPointerException e)
            {
            }
            return(result);
        }
示例#3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private ProcessImpl(String cmd[] , final String envblock, final String path, final long[] stdHandles, final boolean redirectErrorStream) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
        private ProcessImpl(String[] cmd, String envblock, String path, long[] stdHandles, bool redirectErrorStream)
        {
            String          cmdstr;
            SecurityManager security = System.SecurityManager;
            bool            allowAmbiguousCommands = false;

            if (security == null)
            {
                allowAmbiguousCommands = true;
                String value = System.getProperty("jdk.lang.Process.allowAmbiguousCommands");
                if (value != null)
                {
                    allowAmbiguousCommands = !"false".Equals(value, StringComparison.CurrentCultureIgnoreCase);
                }
            }
            if (allowAmbiguousCommands)
            {
                // Legacy mode.

                // Normalize path if possible.
                String executablePath = (new File(cmd[0])).Path;

                // No worry about internal, unpaired ["], and redirection/piping.
                if (NeedsEscaping(VERIFICATION_LEGACY, executablePath))
                {
                    executablePath = QuoteString(executablePath);
                }

                cmdstr = CreateCommandLine(VERIFICATION_LEGACY, executablePath, cmd);
                //legacy mode doesn't worry about extended verification
            }
            else
            {
                String executablePath;
                try
                {
                    executablePath = GetExecutablePath(cmd[0]);
                }
                catch (IllegalArgumentException)
                {
                    // Workaround for the calls like
                    // Runtime.getRuntime().exec("\"C:\\Program Files\\foo\" bar")

                    // No chance to avoid CMD/BAT injection, except to do the work
                    // right from the beginning. Otherwise we have too many corner
                    // cases from
                    //    Runtime.getRuntime().exec(String[] cmd [, ...])
                    // calls with internal ["] and escape sequences.

                    // Restore original command line.
                    StringBuilder join = new StringBuilder();
                    // terminal space in command line is ok
                    foreach (String s in cmd)
                    {
                        join.Append(s).Append(' ');
                    }

                    // Parse the command line again.
                    cmd            = GetTokensFromCommand(join.ToString());
                    executablePath = GetExecutablePath(cmd[0]);

                    // Check new executable name once more
                    if (security != null)
                    {
                        security.CheckExec(executablePath);
                    }
                }

                // Quotation protects from interpretation of the [path] argument as
                // start of longer path with spaces. Quotation has no influence to
                // [.exe] extension heuristic.
                cmdstr = CreateCommandLine(IsShellFile(executablePath) ? VERIFICATION_CMD_BAT : VERIFICATION_WIN32, QuoteString(executablePath), cmd);
                // We need the extended verification procedure for CMD files.
            }

            Handle = create(cmdstr, envblock, path, stdHandles, redirectErrorStream);

            AccessController.doPrivileged(new PrivilegedActionAnonymousInnerClassHelper(this, stdHandles));
        }