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
Scala 2.10 Futures on Android : sun.misc.Unsafe missing #6594
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6594?orig=1
|
@viktorklang said: |
@viktorklang said: |
François-Xavier Thomas (frx) said: |
François-Xavier Thomas (frx) said: |
François-Xavier Thomas (frx) said: > javap -c ForkJoinTask | grep throw 2.10.0-RC1-Patch [adaa5d2] untracked
27: athrow
135: invokestatic #48; //Method rethrow:(Ljava/lang/Throwable;)V
202: invokestatic #48; //Method rethrow:(Ljava/lang/Throwable;)V
public final java.lang.Object get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException;
39: athrow
63: athrow
public final java.lang.Object get(long, java.util.concurrent.TimeUnit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException;
13: athrow
244: athrow
314: athrow
327: athrow
355: athrow
370: athrow
390: athrow
56: ldc #116; //String throwException
100: athrow It seems fine... I'm not a huge Java hacker, so I do not know the specifics, but what's the reason behind the use of |
François-Xavier Thomas (frx) said: |
François-Xavier Thomas (frx) said: Will try to adapt it to the ForkJoinTask later to see if it works, even though I'm kinda shooting in the dark here. |
@viktorklang said: We can't use "throw" because Java doesn't allow you to throw anything but RuntimeException without a throws clause, and we cannot add that. |
@phaller said: |
@viktorklang said: |
@phaller said: |
@viktorklang said: |
François-Xavier Thomas (frx) said: |
François-Xavier Thomas (frx) said: Adding |
@viktorklang said: |
François-Xavier Thomas (frx) said (edited on Oct 31, 2012 7:45:47 PM UTC): Anyway, there should be a way to declare the the whole Scala libs as non-obfuscable by default in the Proguard configuration. I'm going to look into that, and maybe report my findings in the wiki, since there's very little official documentation. (https://www.assembla.com/wiki/show/scala-ide/Developing_for_Android ?) |
@viktorklang said: |
@viktorklang said: |
Martin Kneissl (mkneissl) said: |
Martin Kneissl (mkneissl) said: |
Martin Kneissl (mkneissl) said:
This is caused by Dalvik in Android 4 not having sun.misc.Unsafe.throwExeption. |
@viktorklang said: You'll need to confirm whether this is a bug or not ASAP if the fix is to be able to be included in Scala 2.10 |
François-Xavier Thomas (frx) said: |
@viktorklang said: @martin: Does the patch fix it? If not, if you remove the "Unsafely" and only use "Softly" does that fix the situation? |
François-Xavier Thomas (frx) said: |
@viktorklang said: The boat might have sailed on that now. |
Martin Kneissl (mkneissl) said: Here is the Unsafe class: http://omapzoom.org/?p=platform/libcore.git;a=history;f=luni/src/main/java/sun/misc/Unsafe.java;h=33bb9f1a0660acbb9e75ab0d252f55ea91c1cfd0;hb=HEAD As promised I'll try the patched version, but I haven't compiled Scala recently, so this might take a few hours... |
Martin Kneissl (mkneissl) said (edited on Nov 13, 2012 9:06:06 PM UTC): Now, with the patched library, calling ForkJoinTask.rethrow() (via reflection / setAccessible) throws the passed exception. Before, with the unpatched library, we get NoSuchMethodError. So, please patch ForkJoinPool in the same way and this issue should be solved. (BTW, building scala works like a charm!) |
François-Xavier Thomas (frx) said: Anyway, I just finished applying the patch as well, and came to the same conclusions. I only had 2 warnings though, with one remaining after the patch. |
@adriaanm said: an RC is only open to:
|
@viktorklang said (edited on Nov 14, 2012 12:37:12 AM UTC): In any case, I have a fix, and it's practically risk-free. I cannot comment on the impact of not fixing it as I have no experience with Dalvik. |
@adriaanm said: Your patch doesn't change the public API, right? That means it can go into 2.10.1. Seems like an open-and-shut case to me. |
@viktorklang said: As I said, I trust your judgement, I cannot say if it's critical for Dalvik or not, |
@adriaanm said: If there is no workaround and this makes Scala unusable on Android, I would be open to considering this a blocker. If not, someone please speak up in the next couple of days. |
François-Xavier Thomas (frx) said (edited on Nov 14, 2012 11:42:39 AM UTC): |
Martin Kneissl (mkneissl) said: |
@viktorklang said: |
@adriaanm said: 2.10.1-RC1 is scheduled for Feb 11. |
@viktorklang said: |
(This is a continuation of a thread on the mailing list)
Proguard has been configured to explicitely keep all the scala classes I need, and works nicely, but I get this error at runtime when trying to use futures on Android :
According to the very few results I got while searching, it's probably not Scala but the DalvikVM that's (at least on the surface) missing the sun.misc.Unsafe class.
Viktor provided a patch (attached) that could fix this, but I haven't had time to test it yet.
The text was updated successfully, but these errors were encountered: