他们记录了android java实现的缺陷?

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

我碰到一个有趣的问题,一个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版本保持一个字符向前,而不是向后跳过(解析器在某些情况下使用这个来预读字符).

我的问题是J2EE规范中存在的各种不兼容性和差异性在哪里?如果没有,你们还遇到什么其他问题.

谢谢,p.

解决方法

Android的问题追踪器有一个要看的地方.

一个地方是Apache Harmony问题追踪器.

诚然,使用问题跟踪器将涉及搜索而不是浏览精心分类的网络.你可以认为这是一个机会…

FWIW – 搜索和谐问题跟踪器显示了在各种流类中跳过的行为有一些问题.一个问题抱怨一些类的行为与javadoc不匹配,而且被关闭的行为表示它的DID与RI行为相匹配,因此该错误在javadoc中.

我的看法是,Sun / Oracle对这种事情承担了很多责任,因为他们拒绝以合理的条件向TCM和Apache Harmony项目许可证.

相关文章

这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...
这篇文章主要介绍“Android岛屿数量算法怎么使用”的相关知识...
本篇内容主要讲解“Android如何开发MQTT协议的模型及通信”,...
本文小编为大家详细介绍“Android数据压缩的方法是什么”,内...