View Single Post
  #1  
Old 03.12.2011, 15:24
fcpt
Guest
 
Posts: n/a
Default [JD 15413][AppWorkUtils 1023] getJavaVersion using the wrong variable

JD -----------> revision 15413
AppWorkUtils -> revision 1023

This bug report is 'against' AppWorkUtils, in the function org.appwork.utils.Application.getJavaVersion

In my computer, the String version in that function is assigned with "1.7.0_b147-icedtea"
And I get this errorlog:
Code:
1|org.appwork 03-12-2011 14:02:52 - SEVERE [org.appwork.utils.logging.Log(exception)] -> SEVERE Exception occurred
java.lang.NumberFormatException: null
	at java.lang.Long.parseLong(Long.java:404)
	at java.lang.Long.parseLong(Long.java:483)
	at org.appwork.utils.Application.getJavaVersion(Application.java:151)
	at jd.Main.javaCheck(Main.java:166)
	at jd.Main.preInitChecks(Main.java:345)
	at jd.Main.main(Main.java:240)
1 03-12-2011 14:02:52 - WARNING [jd.Main(javaCheck)] -> Javacheck: Wrong Java Version! JDownloader needs at least Java 1.5 or higher!
The function getJavaVersion:
Code:
    public static long getJavaVersion() {
        if (Application.javaVersion > 0) { return Application.javaVersion; }
        try {
            final String version = System.getProperty("java.version");
            String v = new Regex(version, "^(\\d+\\.\\d+\\.\\d+)").getMatch(0);
            final String u = new Regex(version, "^.*?_(\\d+)").getMatch(0);
            final String b = new Regex(version, "^.*?_b(\\d+)").getMatch(0);
            v = v.replaceAll("\\.", "");
            /* 170uubbb */
            /* eg 1.6 = 16000000 */
            long ret = Long.parseLong(v) * 100000;
            if (u != null) {
                /* append update number */
                ret = ret + Long.parseLong(u) * 1000;
            }
            if (b != null) {
                /* append beta number */
                ret = ret + Long.parseLong(u);
            }
            Application.javaVersion = ret;
            return ret;
        } catch (final Exception e) {
            Log.exception(e);
            return -1;
        }
    }
When the code check if b is not null then inside, the wrong variable is used(u instead of b).

One more thing not important to the code, I would not call that the beta number, but the build number. if it was a beta then "beta" tag is used.
Reply With Quote