gpt4 book ai didi

android java 实现缺陷.. 是否记录在案?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:14:37 24 4
gpt4 key购买 nike

我正在使用运行 android-7 (2.1) 的模拟器和运行 android-8 (2.2) 的 moto-defy 来玩一个简单的 android 应用程序。

我遇到了一个有趣的问题,即 CSV 解析应用程序在模拟器上失败,但在 defy 和常规 java 应用程序(使用 sun java)中成功。

我追踪到问题,原因是android-7的StringReader实现不支持否定跳过操作:

Android-7:

/**
* Skips {@code amount} characters in the source string. Subsequent calls of
* {@code read} methods will not return these characters unless {@code
* reset()} is used.
*
* @param ns
* the maximum number of characters to skip.
* @return the number of characters actually skipped or 0 if {@code ns < 0}.
* @throws IOException
* if this reader is closed.
* @see #mark(int)
* @see #markSupported()
* @see #reset()
*/
@Override
public long skip(long ns) throws IOException {
synchronized (lock) {
if (isClosed()) {
throw new IOException(Msg.getString("K0083")); //$NON-NLS-1$
}
if (ns <= 0) {
return 0;
}
long skipped = 0;
if (ns < this.count - pos) {
pos = pos + (int) ns;
skipped = ns;
} else {
skipped = this.count - pos;
pos = this.count;
}
return skipped;
}
}

J2SE 1.6:

/**
* Skips the specified number of characters in the stream. Returns
* the number of characters that were skipped.
*
* <p>The <code>ns</code> parameter may be negative, even though the
* <code>skip</code> method of the {@link Reader} superclass throws
* an exception in this case. Negative values of <code>ns</code> cause the
* stream to skip backwards. Negative return values indicate a skip
* backwards. It is not possible to skip backwards past the beginning of
* the string.
*
* <p>If the entire string has been read or skipped, then this method has
* no effect and always returns 0.
*
* @exception IOException If an I/O error occurs
*/
public long skip(long ns) throws IOException {
synchronized (lock) {
ensureOpen();
if (next >= length)
return 0;
// Bound skip by beginning and end of the source
long n = Math.min(length - next, ns);
n = Math.max(-next, n);
next += n;
return n;
}
}

因此,Android 版本不会向后跳过(在某些情况下解析器使用它来预读一个字符),而是保持向前一个字符。

我的问题是,J2SE 规范中的各种不兼容性和变体是否在任何地方都有记录?如果没有,你们还遇到了什么其他问题。

谢谢,p。

最佳答案

一个值得关注的地方是 Android 问题跟踪器。

另一个值得关注的地方是 Apache Harmony 问题跟踪器。

不可否认,使用问题跟踪器将涉及搜索而不是浏览经过仔分割类的问题的网络。您可以将此视为一个机会...


FWIW - 搜索 Harmony 问题跟踪器显示在各种流类中 skip 的行为存在一些问题。有一个问题提示某些类的行为与 javadoc 不匹配......并且关闭说它确实与 RI 行为匹配,因此错误在 javadoc 中。

我的看法是,Sun/Oracle 因拒绝以合理的条件将 TCK 许可给 Apache Harmony 项目而对此类事情负有很多责任。

关于android java 实现缺陷.. 是否记录在案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6721928/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com