Recompile jodatime?
This is my first time using jodatime and i've got a stackoverflow error that i have no idea how to fix. I'm creating an android app that needs to be able to display the days between when a sqlite record was created and today. As far as i can tell everything is working correctly except jodatime. I got this error when building the project
[2010-08-10 02:08:50 - Grow Journal Beta] processing org/joda/time/DateTimeUtils.class... [2010-08-10 02:08:50 - Grow Journal Beta] processing org/joda/time/DateTimeZone$1.class... [2010-08-10 02:08:50 - Grow Journal Beta] warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.) [2010-08-10 02:08:50 - Grow Journal Beta] processing org/joda/time/DateTimeZone$Stub.class...
This is the logcat:
08-13 22:12:11.823: ERROR/AndroidRuntime(6537): Uncaught handler: thread main exiting due to uncaught exception 08-13 22:12:11.893: ERROR/AndroidRuntime(6537): java.lang.StackOverflowError 08-13 22:12:11.893: ERROR/AndroidRuntime(6537): at java.util.Hashtable.get(Hashtable.java:274) 08-13 22:12:11.893: ERROR/AndroidRuntime(6537): at java.util.Properties.getProperty(Properties.java:177) 08-13 22:12:11.893: ERROR/AndroidRuntime(6537): at java.lang.System.getProperty(System.java:440) 08-13 22:12:11.893: ERROR/AndroidRuntime(6537): at java.lang.System.getProperty(System.java:412) 08-13 22:12:11.893: ERROR/AndroidRuntime(6537): at org.joda.time.DateTimeZone.getDefault(DateTimeZone.java:132) 08-13 22:12:11.893: ERROR/AndroidRuntime(6537): at org.joda.time.DateTimeZone.forID(DateTimeZone.java:190) 08-13 22:12:11.893: ERROR/AndroidRuntime(6537): at org.joda.time.DateTimeZone.getDefault(DateTimeZone.java:132)
After looking around a bit i figure i just need to recompile the jodatime binary my self. I've been using eclipse, I created a new project, and imported the jodatime source. When I attempt to compile I get this in the console:
Usage: java org.joda.time.tz.ZoneInfoCompiler <options> <source files>
where possible options include: -src Specify where to read source files -dst Specify where to write generated files
Not really sure where to go from here. Any help would be greatly appreciated. Thanks for your time.
StackTrace from overflow:
Thread [ main] (Suspended (exception StackOverflowError))   
    DateTimeZone.getDefault() line: 147 
    ISOChronology.getInstance() line: 86    
    DateTimeUtils.getChronology(Chronology) line: 231   
    DateConverter(AbstractConverter).getChronology(Object, Chronology) line: 82 
    DateTime(BaseDateTime).(Object, Chronology) line: 170 
    DateTime.(Object) line: 168   
    PlantsCursorAdapter.newView(Context, Cursor, ViewGroup) line: 71    
    PlantsCursorAdapter(CursorAdapter).getView(int, View, ViewGroup) line: 182  
    ListView(AbsListView).obtainView(int) line: 1274    
    ListView.measureHeightOfChildren(int, int, int, int, int) line: 1147    
    ListView.onMeasure(int, int) line: 1060 
    ListView(View).measure(int, int) line: 7966 
    TableLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 3077 
    TableLayout(LinearLayout).measureChildBeforeLayout(View, int, int, int, int, int) line: 888 
    TableLayout.measureChildBeforeLayout(View, int, int, int, int, int) line: 453   
    TableLayout(LinearLayout).measureVertical(开发者_开发技巧int, int) line: 350   
    TableLayout.measureVertical(int, int) line: 465 
    TableLayout.onMeasure(int, int) line: 428   
    TableLayout(View).measure(int, int) line: 7966  
    FrameLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 3077 
    FrameLayout.onMeasure(int, int) line: 245   
    FrameLayout(View).measure(int, int) line: 7966  
    LinearLayout.measureVertical(int, int) line: 464    
    LinearLayout.onMeasure(int, int) line: 278  
    LinearLayout(View).measure(int, int) line: 7966 
    PhoneWindow$DecorView(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 3077   
    PhoneWindow$DecorView(FrameLayout).onMeasure(int, int) line: 245    
    PhoneWindow$DecorView(View).measure(int, int) line: 7966    
    ViewRoot.performTraversals() line: 767  
    ViewRoot.handleMessage(Message) line: 1650  
    ViewRoot(Handler).dispatchMessage(Message) line: 99 
    Looper.loop() line: 123 
    ActivityThread.main(String[]) line: 4595    
    Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
    Method.invoke(Object, Object...) line: 521  
    ZygoteInit$MethodAndArgsCaller.run() line: 860  
    ZygoteInit.main(String[]) line: 618 
    NativeStart.main(String[]) line: not available [native method]  
DateTimeZone.class source is Here
The problematic recursion is apparently between DateTimeZone.getDefault and DateTimeZone.forID.  However, the stack line numbers don't seem to line up with the Joda source code I see here.  And in that code, the DateTimeZone.getDefault() method doesn't look at the system properties ... that stuff happens in a static initializer.
It seems like the Android codebase uses a tweaked version of JodaTime.
Anyway, it looks like calling JodaTime.setDefault(...) might be a workaround.  Also, check that the "user.timezone" system property has been set.
(I don't think recompiling / using the standard JodaTime is the right strategy. The Android tweaks ... whatever they are ... are probably there for a reason.)
EDIT
Revisiting this, it transpires that this was a bug in JodaTime 1.6.1 on some platforms (Android, Google-Apps). The issue tracker shows it as fixed in the JodaTime 1.6.2.
Why can't you use something like:
SELECT julianday('now') - julianday('1776-07-04');  
In your query ?
I just have the same problem, I think it is a bug in joda-time 1.6.1, because all runs well whis 1.6 version. I posted a bug report on the joda-time bug tracker and I use 1.6 version.
Paulo
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论