Gram z prostą aplikacją na Androida za pomocą emulatora z Androidem 7 (2.1) i moto-defy z systemem Android-8 (2.2).Usterki implementacji systemu Android java .. czy są one udokumentowane?
Wpadłem na interesujący problem polegający na tym, że aplikacja parsująca CSV nie działała na emulatorze, ale udało jej się w przeciwstawnych i zwykłych aplikacjach java (używając Sun Java).
I śledzone problemu w dół, a przyczyną jest to, że realizacja StringReader android-7 nie obsługuje negatywne działanie Przeskoczyć:
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;
}
}
Dlatego zamiast przeskakiwania do tyłu (parser używa tego do wstępnego odczytu znaku w niektórych przypadkach) wersja Androida pozostaje jeden znak do przodu.
Moje pytanie brzmi, czy różne niezgodności i odmiany w specyfikacji J2SE są udokumentowane w dowolnym miejscu? Jeśli nie, jakie inne problemy napotkaliście.
Dzięki, p.