Menu

Cannot generate a spliater for HashMap in Android

Anonymous
2015-07-29
2015-09-06
  • Anonymous

    Anonymous - 2015-07-29

    When i try to iterate HashMap, the following error occurs.

    java.lang.Error: java.lang.NoSuchFieldException: map
    at java8.util.HMSpliterators.<clinit>(HMSpliterators.java:445)
    at java8.util.Spliterators.spliterator(Spliterators.java:898)
    at java8.util.stream.StreamSupport.stream(StreamSupport.java:269)

    It was done in Galaxy Note 4 with Android 5.0.1.

    I think it's pretty dangerous to use reflection there in that all the Android forks may have different implementations of HashMap and HashSet. It might be better to wrap HashSet by Map interface one more time even though it can cause performance degradation instead of using Unsafe operations so it can work on every JVM safely.
    I know it's not easy to solve but I hope it get done :)

     
  • Stefan Zobel

    Stefan Zobel - 2015-07-29

    Hi,

    on Android (starting with streamsupport release 1.1.5) you absolutely have to set the system property "java8.util.Spliterators.assume.oracle.collections.impl" to "false".

    This is mentioned in the readme and a few discussion posts here several times.

    I don't get what you mean by "wrapping HashSet by Map interface"?

    Note that the library has been tested successfully on API 15 up to API 22 on a couple of devices and AVDs. It works on all these Android versions.

    Let me know if you have further questions or ideas for improvement.

     
  • Stefan Zobel

    Stefan Zobel - 2015-09-06

    Please note that, beginning with release 1.3.1, the above information about the necessity of setting the

    "java8.util.Spliterators.assume.oracle.collections.impl"

    property on Android to "false" is obsolete now.

    streamsupport-1.3.1 (and higher) can be used on Android without setting any special property.

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.