java - 重新编译jodatime?

标签 java android jodatime

这是我第一次使用 jodatime,我遇到了一个 stackoverflow 错误,我不知道如何修复。我正在创建一个 Android 应用程序,它需要能够显示创建 sqlite 记录到今天之间的天数。据我所知,除了 jodatime 之外,一切都工作正常。我在构建项目时遇到此错误

[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>

可能的选项包括: -src 指定读取源文件的位置 -dst 指定生成文件写入位置

不太确定从这里该去哪里。任何帮助将不胜感激。感谢您抽出时间。

堆栈跟踪溢出:

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 源是 Here

最佳答案

有问题的递归显然是在 DateTimeZone.getDefaultDateTimeZone.forID 之间。然而,堆栈行号似乎与我看到的 Joda 源代码 here 不一致。 。在该代码中,DateTimeZone.getDefault() 方法不会查看系统属性……这些内容发生在静态初始值设定项中。

Android 代码库似乎使用了 JodaTime 的调整版本。

无论如何,调用 JodaTime.setDefault(...) 看起来可能是一种解决方法。另外,检查“user.timezone”系统属性是否已设置。

(我不认为重新编译/使用标准 JodaTime 是正确的策略。Android 的调整......无论它们是什么......可能是有原因的。)

编辑

重新审视这一点,发现这是某些平台(Android、Google-Apps)上 JodaTime 1.6.1 中的错误。问题跟踪器显示它已在 JodaTime 1.6.2 中修复。

关于java - 重新编译jodatime?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3481869/

相关文章:

java - 尝试在 android studio 中运行 java 程序时出现错误 :Execution failed for task ':app:preDebugAndroidTestBuild' ,

android - 如何在 Room 中使用 Joda DateTime 日期作为 id,或者如何在查询中获取日期?

hibernate - 如何在Grails中针对Joda LocalDate针对月份和日期进行查询

java - 查找 'li'元素

java - ArrayList 和单向链表一样吗?

java - 如何用Java打印Dijkstra算法的完整路径

java - datetimeformatter joda 使用可选的 millis 解析多种 utc 格式

java - 获取当前文件的目录

android - TextView 上用于 Rtl 和 Ltr 文本的 TextAlignment

Android - Activity Home/向上箭头在 SDK 24 中有额外的填充/边距