Tôi đang chơi với một ứng dụng Android đơn giản bằng cách sử dụng trình mô phỏng chạy android-7 (2.1) và một ứng dụng chống bụi chạy android-8 (2.2).lỗ hổng triển khai java android .. chúng có được ghi lại không?
Tôi gặp phải sự cố thú vị, trong đó ứng dụng phân tích cú pháp CSV không thành công trên trình mô phỏng, nhưng đã thành công trên các ứng dụng java thông thường (sử dụng java mặt trời).
tôi theo dõi các vấn đề xuống và nguyên nhân là android-7 thực hiện StringReader không hỗ trợ một hoạt động tiêu cực bỏ qua:
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;
}
}
Vì vậy, thay vì bỏ qua lùi (trình phân tích cú pháp sử dụng tính năng này để đọc trước một ký tự trong một số trường hợp nhất định), phiên bản Android vẫn còn một ký tự phía trước.
Câu hỏi của tôi là, là các sự không tương thích và biến thể khác nhau từ thông số J2SE được ghi ở bất kỳ đâu? Nếu không, những gì các vấn đề khác có các bạn chạy vào.
Cảm ơn, tr.