Uploaded image for project: 'Shiro'
  1. Shiro
  2. SHIRO-545

JavaEnvironment version getter

    XMLWordPrintableJSON

Details

    • Patch

    Description

      If Shiro is running in Java 8 it assumes that the major version is 1.3, because this case it's not included in the if blocks and goes to the default version which is 1.3, also the " if (version.indexOf("1.7.") != -1)

      {" should be contains, instead of indexOf, contains is highly more readable, so the code should be something like ..*/ {code:title=JavaEnvironment.java|borderStyle=solid}

      /**

      • Constant identifying the 1.8 JVM.
        */
        public static final int JAVA_18 = 5;
        /** The virtual machine version, i.e. <code>System.getProperty("java.version");</code>. */
        private static final String version;

      /**

      • The virtual machine <em>major</em> version. For example, with a <code>version</code> of
      • <code>1.5.6_10</code>, this would be <code>1.5</code>
        */
        private static final int majorVersion;

      /**

      • Static code initialization block that sets the
      • <code>version</code> and <code>majorVersion</code> Class constants
      • upon initialization.
        */
        static
        Unknown macro: { version = System.getProperty("java.version"); // version String should look like "1.4.2_10" if (version.contains("1.8.")) { majorVersion = JAVA_18; } else if (version.contains("1.7")){ majorVersion = JAVA_17; } else if (version.contains("1.6.")) { majorVersion = JAVA_16; } else if (version.contains("1.5.")) { majorVersion = JAVA_15; } else if (version.contains("1.4.")) { majorVersion = JAVA_14; } else { // else leave 1.3 as default (it's either 1.3 or unknown) majorVersion = JAVA_13; } }
        
        

      Attachments

        Activity

          People

            Unassigned Unassigned
            AIsaac Ariel Isaac
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 0.5h
                0.5h
                Remaining:
                Remaining Estimate - 0.5h
                0.5h
                Logged:
                Time Spent - Not Specified
                Not Specified