android java实现缺陷..他们有记录吗?

时间:2011-07-17 04:29:14

标签: java android java-api

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

我遇到了一个有趣的问题,即一个CSV解析应用程序在emmulator上失败,但在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。

1 个答案:

答案 0 :(得分:1)

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

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

不可否认,使用问题跟踪器将涉及搜索而不是浏览精心分类的问题网络。你可以把这看作是一个机会...


FWIW - 搜索Harmony问题跟踪器显示skip在各种流类中的行为存在一些问题。有一个问题抱怨某些类的行为与javadoc不匹配......而且它已经关闭,说它与RI行为相匹配,因此该bug是在javadoc中。

我认为Sun / Oracle承担了很多责任,因为他们拒绝在合理条款下将TCK许可给Apache Harmony项目。

相关问题