commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joerg Schaible (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LANG-624) SystemUtils.getJavaVersionAsFloat throws StringIndexOutOfBoundsException on Android runtime/Dalvik VM
Date Fri, 28 May 2010 12:04:36 GMT

    [ https://issues.apache.org/jira/browse/LANG-624?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12872942#action_12872942
] 

Joerg Schaible commented on LANG-624:
-------------------------------------

Sorry, this fix is simply. Aonix J9 VM (also used on mobile devices) returned "1.3.0 subset".
As explained, you cannot rely on "java.version" per definition.

{noformat}
Index: src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
===================================================================
--- src/test/java/org/apache/commons/lang3/SystemUtilsTest.java (revision 949153)
+++ src/test/java/org/apache/commons/lang3/SystemUtilsTest.java (working copy)
@@ -201,6 +201,7 @@
         assertEquals(1.5f, SystemUtils.toJavaVersionFloat("1.5.0"), 0.000001f);
         assertEquals(1.6f, SystemUtils.toJavaVersionFloat("1.6.0"), 0.000001f);
         assertEquals(1.31f, SystemUtils.toJavaVersionFloat("JavaVM-1.3.1"), 0.000001f);
+        assertEquals(1.3f, SystemUtils.toJavaVersionFloat("1.3.0 subset"), 0.000001f);
         // This used to return 0f in [lang] version 2.5:
         assertEquals(1.3f, SystemUtils.toJavaVersionFloat("XXX-1.3.x"), 0.000001f);
     }
@@ -219,6 +220,7 @@
         assertEquals(150, SystemUtils.toJavaVersionInt("1.5.0"), 0.000001f);
         assertEquals(160, SystemUtils.toJavaVersionInt("1.6.0"), 0.000001f);
         assertEquals(131, SystemUtils.toJavaVersionInt("JavaVM-1.3.1"), 0.000001f);
+        assertEquals(130, SystemUtils.toJavaVersionInt("1.3.1 subset"), 0.000001f);
         // This used to return 0f in [lang] version 2.5:
         assertEquals(130, SystemUtils.toJavaVersionInt("XXX-1.3.x"), 0.000001f);
     }
{noformat}

This simply fails.

> SystemUtils.getJavaVersionAsFloat throws StringIndexOutOfBoundsException on Android runtime/Dalvik
VM
> -----------------------------------------------------------------------------------------------------
>
>                 Key: LANG-624
>                 URL: https://issues.apache.org/jira/browse/LANG-624
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 2.5
>            Reporter: Travis Truman
>             Fix For: 3.0, Nightly Builds
>
>
> Can be replicated in the Android emulator quite easily.
> Stack trace:
> {noformat}
> at org.apache.commons.lang.builder.ToStringBuilder.<clinit>(ToStringBuilder.java:98)
> E/AndroidRuntime( 1681): 	... 17 more
> E/AndroidRuntime( 1681): Caused by: java.lang.ExceptionInInitializerError
> E/AndroidRuntime( 1681): 	at org.apache.commons.lang.builder.ToStringStyle$MultiLineToStringStyle.<init>(ToStringStyle.java:2276)
> E/AndroidRuntime( 1681): 	at org.apache.commons.lang.builder.ToStringStyle.<clinit>(ToStringStyle.java:94)
> E/AndroidRuntime( 1681): 	... 18 more
> E/AndroidRuntime( 1681): Caused by: java.lang.StringIndexOutOfBoundsException
> E/AndroidRuntime( 1681): 	at java.lang.String.substring(String.java:1571)
> E/AndroidRuntime( 1681): 	at org.apache.commons.lang.SystemUtils.getJavaVersionAsFloat(SystemUtils.java:1153)
> E/AndroidRuntime( 1681): 	at org.apache.commons.lang.SystemUtils.<clinit>(SystemUtils.java:818)
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message