1. EnumSet bug:
# dalvikvm -classpath ruboto.jar org.jruby.Main -e "puts 1"
86
HugeEnumSet.java:102:in `next': java.lang.ArrayIndexOutOfBoundsException
from HugeEnumSet.java:52:in `next'
from Ruby.java:1237:in `initErrno'
The "86" there is the size of the enumset, so it doesn't appear to be an
issue with it being empty. I haven't looked at Dalvik source yet
(assuming this is available?). I fixed it by switching to an array of
enums (Errno.values() in this case) rather than using an EnumSet (which
was unnecessary anyway).
2. The BufferedReader/BufferedInputStream warnings were annoying but
easy to fix.
3. The errors for exceeding -Xss are totally useless. Most common seems
to be NullPointerException at totally bizarre locations.
4. Trying to import android.content.Context blows up somewhere in
reflection. A few other java.* classes I tried seem ok:
irb(main):001:0> import 'android.content.Context'
Class.java:-2:in `getDeclaredMethods': java.lang.NoSuchMethodException
from ClassCache.java:137:in `getDeclaredMethods'
from Class.java:666:in `getDeclaredMethods'
from JavaClass.java:1738:in `getMethods'
from JavaClass.java:718:in `setupClassMethods'
from JavaClass.java:509:in `initializeClass'
from JavaClass.java:453:in `<init>'
from JavaClass.java:894:in `createJavaClass'
This kills my ability to do eye-popping demos of scripting Android
classes from Ruby, and therefore makes me sad.
All my modifications up to this point are on JRuby trunk and about to be
released in JRuby 1.2 RC1.
- Charlie
[1] http://blog.headius.com/2009/02/domo-arigato-mr-ruboto.html
Maybe others can chime in on the specific errors, since they're kinda
out of my area of expertise, but here's a couple of quick comments:
> I haven't looked at Dalvik source yet
> (assuming this is available?).
Dalvik's source can be found here:
http://android.git.kernel.org/?p=platform/dalvik.git;a=tree
> 4. Trying to import android.content.Context blows up somewhere in
> reflection. A few other java.* classes I tried seem ok:
>
> irb(main):001:0> import 'android.content.Context'
> Class.java:-2:in `getDeclaredMethods': java.lang.NoSuchMethodException
> from ClassCache.java:137:in `getDeclaredMethods'
> from Class.java:666:in `getDeclaredMethods'
> from JavaClass.java:1738:in `getMethods'
> from JavaClass.java:718:in `setupClassMethods'
> from JavaClass.java:509:in `initializeClass'
> from JavaClass.java:453:in `<init>'
> from JavaClass.java:894:in `createJavaClass'
FWIW, android.content.Context is an abstract class -- does that cause
any particular problems on the JRuby import?
--
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Published!
It shouldn't; we just create a proxy representation of it and populate
it with the data we gather from reflection. I was hoping to get at it
and access the services it provides; obviously this issue stands in the
way of a lot of things.
I will have a look at the Android source as well as JRuby, but it
certainly seems like Android's fault so far.
On a related question: if this were to get fixed, how frequently are
updates pushed to consumers?
- Charlie
I did not see a StackOverflowError, and the NPEs were reporting line
numbers that did not match the compiled code. I checked it multiple
times, and finally just tried upping -Xss, which ultimately seemed to
fix it in that particular case.
I know I had some other peculiar error that wasn't StackOverflowError,
but I don't recall what it was.
- Charlie
I'm not the best person to answer this question, since I'm not on the
core Android team, but, here goes:
Since the release of the T-Mobile G1, there have been two over-the-air
(OTA) updates that got a lot of discussion. These fixed bugs and added
some features. However, it is unclear if every bug fix gets updated this
way -- e.g., if somebody patched the bug you're experiencing, but the
bug is not noticeably affecting other device functionality, I don't know
that it will get shipped.
Major updates, such as oft-mentioned cupcake branch, are decidedly less
frequent. There is no official statement on frequency, but it feels like
it might wind up being 9-12 months. Again, that's just a guess.
All updates have to go through the device manufacturer (and, for OTA,
the carrier) as well. Once there are a half-dozen major manufacturers
and lots of little guys, I imagine the release timeframe for updates
(major and minor) will get fuzzier still.
My recommendation is that you put bugs in the issue tracker
(http://b.android.com). You will then have a shot at finding out which
Android release addresses them. You can use that to advise
JRuby-on-Android developers (e.g., gotta be running such-and-so release
of Android or newer).
Well, here's my counterpoint: I just went through and set them all to
8192 anyway, since this is the same code used for every other JRuby app.
Am I wrong to have done so? Are others going to be wrong when they do so?
I can appreciate wanting to reduce memory, but this would be better left
as a translation-to-dex warning or a tell-me-how-I-can-improve-please
mode than as an always-present runtime warning, and you'd save the extra
check and logging for apps that don't bother fixing it. Because I
suspect, as in my case, most folks will do little more than hardcode the
default 8192 size anyway.
Finally...those streams have default constructors for a reason, and
everyone uses them. Warning because people use the default constructor
is exceeding the contract of those types.
> With regard to the other issues, and emphasizing what I think others
> have already said, bug reports with explicit steps-to-reproduce that
> can be independently compiled and run are the gold standard and give
> us the best chance of being able to track down and fix the issues.
> Thanks in advance for putting them together.
I'll try to reduce them and file issues this week.
- Charlie
Well, it's your platform, you can do what you want :) I would not have
chosen to rap developers on the knuckles for doing what they do on a
desktop Java platform. I would have changed the default buffer size,
since nowhere in the specification of BufferedInputStream et al does it
say there's a specific size behind the scenes. Developers depending on
the default buffer size being 8192 are much more at fault than
developers using a default constructor because they presumably don't
care, and yet you penalize the latter group. Indeed, the default
constructor should be expected to do what's best on a given platform, so
changing it to be a smaller buffer size would seem to me totally acceptable.
> Hence, the message. It doesn't change the programmatic behavior of
> your code, but it does serve to warn folks of a known pitfall that we
> have already seen cause real problems. So, we ask you to be explicit,
> in the hope that that means you've actually considered the use case in
> context and are therefore making a conscious choice, not simply
> disregarding the issue without thought.
Then perhaps it could warn me exactly once? :) Is there a good need to
blast warnings every time I construct a buffered stream with a
*published* default constructor? It's basically a public, default
constructor I can't call. Doesn't that sound goofy?
- Charlie
I strongly agree with Charlie here. Arguing that changing the default
buffer size may have broken buggy code that may not even exist, but
then expecting developers to change perfectly fine existing code
(probably each and every java library that makes use of buffered IO)
seems backwards to me. It feels like you deprecated the zero-args
constructor instead of doing the sensible thing of making it work for
your vm and platform.
Hannes
I'd also play devil's advocate and say it wasn't *that* big an
annoyance. But I'd trade the annoyance for a smaller default buffer in a
heartbeat.
- Charlie
Encourage; do not force. There are better ways to encourage than
spraying warnings at runtime.
- Charlie
Such as?
On Feb 25, 2009 7:13 PM, "Charles Oliver Nutter" <charles...@sun.com> wrote:Dianne Hackborn wrote: > > What is the right default size?� It seems to me best to encourage develo...
Spray warnings at build time :)
- Charlie
Bingo, that's exactly what I saw. It made no sense to me at all. Great find!
- Charlie