Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.x: Possible 6.x/Android compatibility issue #4653

Closed
ZacSweers opened this issue Oct 1, 2016 · 7 comments
Closed

2.x: Possible 6.x/Android compatibility issue #4653

ZacSweers opened this issue Oct 1, 2016 · 7 comments
Labels

Comments

@ZacSweers
Copy link
Contributor

ZacSweers commented Oct 1, 2016

If I have an Android app targeting source compatibility 1.8, I get the following exception at runtime on a 7.0 device:

FATAL EXCEPTION: RxSchedulerPurge-1
     Process: io.sweers.catchup.debug, PID: 29250
     java.lang.NoSuchMethodError: No virtual method keySet()Ljava/util/concurrent/ConcurrentHashMap$KeySetView; in class Ljava/util/concurrent/ConcurrentHashMap; or its super classes (declaration of 'java.util.concurrent.ConcurrentHashMap' appears in /system/framework/core-libart.jar)
         at io.reactivex.internal.schedulers.SchedulerPoolFactory$1.run(SchedulerPoolFactory.java:69)
         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
         at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:278)
         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:273)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
         at java.lang.Thread.run(Thread.java:761)

The exact line is:

for (ScheduledThreadPoolExecutor e : new ArrayList<ScheduledThreadPoolExecutor>(POOLS.keySet())) {  // CHM.keySet returns KeySetView in Java 8+; false positive here

When I look at it in the debugger, it is indeed a KeySetView, but I'm not sure what the issue is here. Let me know if this would be better served posting in RxAndroid.

CC @JakeWharton

@ZacSweers
Copy link
Contributor Author

Interestingly, if I breakpoint this line, the rest of the app appears to run just fine and isn't blocked. As soon as I let it pass though, it crashes.

@akarnokd
Copy link
Member

akarnokd commented Oct 1, 2016

Java 8 changed the return type of keySet and it trips AnimalSniffer as well. In theory, by compiling with javac 7, there should be no binding to Java 8's type there.

@ZacSweers
Copy link
Contributor Author

doesn't that come at the expense of being able to target Java 8 entirely though?

@akarnokd
Copy link
Member

akarnokd commented Oct 1, 2016

Let's see if http://stackoverflow.com/a/32955708/61158 works for us as well.

@akarnokd
Copy link
Member

akarnokd commented Oct 1, 2016

While you are at this, could you post a PR with the fix above?

@akarnokd akarnokd added the Bug label Oct 1, 2016
@ZacSweers
Copy link
Contributor Author

Looks like that fixed it when I test locally, will upload a PR in a sec

akarnokd pushed a commit that referenced this issue Oct 1, 2016
* Upcast ConcurrentHashMap to Map to avoid compatibility issue

Resovles #4653

See http://stackoverflow.com/a/32955708/61158

* Fix imports, remove now-unnecessary animalsniffer suppression
@akarnokd
Copy link
Member

akarnokd commented Oct 1, 2016

Closing via #4654.

@akarnokd akarnokd closed this as completed Oct 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants