11 | 11 |
// The default implementation of Reader#read(CharBuffer) allocates a
|
12 | 12 |
// temporary char[], so we call Reader#read(char[], int, int) instead.
|
13 | 13 |
int read = (reader != null) ? reader.read(buf, 0, buf.length) : readable.read(cbuf);
|
|
14 |
--- a/guava/src/com/google/common/hash/AbstractByteHasher.java
|
|
15 |
+++ b/guava/src/com/google/common/hash/AbstractByteHasher.java
|
|
16 |
@@ -54,7 +54,7 @@
|
|
17 |
protected void update(ByteBuffer b) {
|
|
18 |
if (b.hasArray()) {
|
|
19 |
update(b.array(), b.arrayOffset() + b.position(), b.remaining());
|
|
20 |
- b.position(b.limit());
|
|
21 |
+ ((java.nio.Buffer) b).position(b.limit());
|
|
22 |
} else {
|
|
23 |
for (int remaining = b.remaining(); remaining > 0; remaining--) {
|
|
24 |
update(b.get());
|
|
25 |
@@ -67,7 +67,7 @@
|
|
26 |
try {
|
|
27 |
update(scratch.array(), 0, bytes);
|
|
28 |
} finally {
|
|
29 |
- scratch.clear();
|
|
30 |
+ ((java.nio.Buffer) scratch).clear();
|
|
31 |
}
|
|
32 |
return this;
|
|
33 |
}
|
|
34 |
--- a/guava/src/com/google/common/hash/AbstractCompositeHashFunction.java
|
|
35 |
+++ b/guava/src/com/google/common/hash/AbstractCompositeHashFunction.java
|
|
36 |
@@ -98,7 +98,7 @@
|
|
37 |
public Hasher putBytes(ByteBuffer bytes) {
|
|
38 |
int pos = bytes.position();
|
|
39 |
for (Hasher hasher : hashers) {
|
|
40 |
- bytes.position(pos);
|
|
41 |
+ ((java.nio.Buffer) bytes).position(pos);
|
|
42 |
hasher.putBytes(bytes);
|
|
43 |
}
|
|
44 |
return this;
|
|
45 |
--- a/guava/src/com/google/common/hash/AbstractHasher.java
|
|
46 |
+++ b/guava/src/com/google/common/hash/AbstractHasher.java
|
|
47 |
@@ -81,7 +81,7 @@
|
|
48 |
public Hasher putBytes(ByteBuffer b) {
|
|
49 |
if (b.hasArray()) {
|
|
50 |
putBytes(b.array(), b.arrayOffset() + b.position(), b.remaining());
|
|
51 |
- b.position(b.limit());
|
|
52 |
+ ((java.nio.Buffer) b).position(b.limit());
|
|
53 |
} else {
|
|
54 |
for (int remaining = b.remaining(); remaining > 0; remaining--) {
|
|
55 |
putByte(b.get());
|
|
56 |
--- a/guava/src/com/google/common/hash/AbstractStreamingHasher.java
|
|
57 |
+++ b/guava/src/com/google/common/hash/AbstractStreamingHasher.java
|
|
58 |
@@ -80,13 +80,13 @@
|
|
59 |
* <p>This implementation simply pads with zeros and delegates to {@link #process(ByteBuffer)}.
|
|
60 |
*/
|
|
61 |
protected void processRemaining(ByteBuffer bb) {
|
|
62 |
- bb.position(bb.limit()); // move at the end
|
|
63 |
- bb.limit(chunkSize + 7); // get ready to pad with longs
|
|
64 |
+ ((java.nio.Buffer) bb).position(bb.limit()); // move at the end
|
|
65 |
+ ((java.nio.Buffer) bb).limit(chunkSize + 7); // get ready to pad with longs
|
|
66 |
while (bb.position() < chunkSize) {
|
|
67 |
bb.putLong(0);
|
|
68 |
}
|
|
69 |
- bb.limit(chunkSize);
|
|
70 |
- bb.flip();
|
|
71 |
+ ((java.nio.Buffer) bb).limit(chunkSize);
|
|
72 |
+ ((java.nio.Buffer) bb).flip();
|
|
73 |
process(bb);
|
|
74 |
}
|
|
75 |
|
|
76 |
@@ -179,10 +179,10 @@
|
|
77 |
@Override
|
|
78 |
public final HashCode hash() {
|
|
79 |
munch();
|
|
80 |
- buffer.flip();
|
|
81 |
+ ((java.nio.Buffer) buffer).flip();
|
|
82 |
if (buffer.remaining() > 0) {
|
|
83 |
processRemaining(buffer);
|
|
84 |
- buffer.position(buffer.limit());
|
|
85 |
+ ((java.nio.Buffer) buffer).position(buffer.limit());
|
|
86 |
}
|
|
87 |
return makeHash();
|
|
88 |
}
|
|
89 |
@@ -203,7 +203,7 @@
|
|
90 |
}
|
|
91 |
|
|
92 |
private void munch() {
|
|
93 |
- buffer.flip();
|
|
94 |
+ ((java.nio.Buffer) buffer).flip();
|
|
95 |
while (buffer.remaining() >= chunkSize) {
|
|
96 |
// we could limit the buffer to ensure process() does not read more than
|
|
97 |
// chunkSize number of bytes, but we trust the implementations
|
|
98 |
--- a/guava/src/com/google/common/io/ByteStreams.java
|
|
99 |
+++ b/guava/src/com/google/common/io/ByteStreams.java
|
|
100 |
@@ -179,11 +179,11 @@
|
|
101 |
ByteBuffer buf = ByteBuffer.wrap(createBuffer());
|
|
102 |
long total = 0;
|
|
103 |
while (from.read(buf) != -1) {
|
|
104 |
- buf.flip();
|
|
105 |
+ ((java.nio.Buffer) buf).flip();
|
|
106 |
while (buf.hasRemaining()) {
|
|
107 |
total += to.write(buf);
|
|
108 |
}
|
|
109 |
- buf.clear();
|
|
110 |
+ ((java.nio.Buffer) buf).clear();
|
|
111 |
}
|
|
112 |
return total;
|
|
113 |
}
|
|
114 |
--- a/guava/src/com/google/common/io/CharStreams.java
|
|
115 |
+++ b/guava/src/com/google/common/io/CharStreams.java
|
|
116 |
@@ -140,10 +140,10 @@
|
|
117 |
long total = 0;
|
|
118 |
CharBuffer buf = createBuffer();
|
|
119 |
while (from.read(buf) != -1) {
|
|
120 |
- buf.flip();
|
|
121 |
+ ((java.nio.Buffer) buf).flip();
|
|
122 |
to.append(buf);
|
|
123 |
total += buf.remaining();
|
|
124 |
- buf.clear();
|
|
125 |
+ ((java.nio.Buffer) buf).clear();
|
|
126 |
}
|
|
127 |
return total;
|
|
128 |
}
|
|
129 |
@@ -343,7 +343,7 @@
|
|
130 |
CharBuffer buf = createBuffer();
|
|
131 |
while ((read = readable.read(buf)) != -1) {
|
|
132 |
total += read;
|
|
133 |
- buf.clear();
|
|
134 |
+ ((java.nio.Buffer) buf).clear();
|
|
135 |
}
|
|
136 |
return total;
|
|
137 |
}
|
|
138 |
--- a/guava/src/com/google/common/io/ReaderInputStream.java
|
|
139 |
+++ b/guava/src/com/google/common/io/ReaderInputStream.java
|
|
140 |
@@ -104,7 +104,7 @@
|
|
141 |
encoder.reset();
|
|
142 |
|
|
143 |
charBuffer = CharBuffer.allocate(bufferSize);
|
|
144 |
- charBuffer.flip();
|
|
145 |
+ ((java.nio.Buffer) charBuffer).flip();
|
|
146 |
|
|
147 |
byteBuffer = ByteBuffer.allocate(bufferSize);
|
|
148 |
}
|
|
149 |
@@ -143,7 +143,7 @@
|
|
150 |
return (totalBytesRead > 0) ? totalBytesRead : -1;
|
|
151 |
}
|
|
152 |
draining = false;
|
|
153 |
- byteBuffer.clear();
|
|
154 |
+ ((java.nio.Buffer) byteBuffer).clear();
|
|
155 |
}
|
|
156 |
|
|
157 |
while (true) {
|
|
158 |
@@ -189,8 +189,8 @@
|
|
159 |
private static CharBuffer grow(CharBuffer buf) {
|
|
160 |
char[] copy = Arrays.copyOf(buf.array(), buf.capacity() * 2);
|
|
161 |
CharBuffer bigger = CharBuffer.wrap(copy);
|
|
162 |
- bigger.position(buf.position());
|
|
163 |
- bigger.limit(buf.limit());
|
|
164 |
+ ((java.nio.Buffer) bigger).position(buf.position());
|
|
165 |
+ ((java.nio.Buffer) bigger).limit(buf.limit());
|
|
166 |
return bigger;
|
|
167 |
}
|
|
168 |
|
|
169 |
@@ -207,7 +207,7 @@
|
|
170 |
if (availableCapacity(charBuffer) == 0) {
|
|
171 |
if (charBuffer.position() > 0) {
|
|
172 |
// (2) There is room in the buffer. Move existing bytes to the beginning.
|
|
173 |
- charBuffer.compact().flip();
|
|
174 |
+ ((java.nio.Buffer) charBuffer.compact()).flip();
|
|
175 |
} else {
|
|
176 |
// (3) Entire buffer is full, need bigger buffer.
|
|
177 |
charBuffer = grow(charBuffer);
|
|
178 |
@@ -220,7 +220,7 @@
|
|
179 |
if (numChars == -1) {
|
|
180 |
endOfInput = true;
|
|
181 |
} else {
|
|
182 |
- charBuffer.limit(limit + numChars);
|
|
183 |
+ ((java.nio.Buffer) charBuffer).limit(limit + numChars);
|
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
@@ -235,7 +235,7 @@
|
|
188 |
* overflow must be due to a small output buffer.
|
|
189 |
*/
|
|
190 |
private void startDraining(boolean overflow) {
|
|
191 |
- byteBuffer.flip();
|
|
192 |
+ ((java.nio.Buffer) byteBuffer).flip();
|
|
193 |
if (overflow && byteBuffer.remaining() == 0) {
|
|
194 |
byteBuffer = ByteBuffer.allocate(byteBuffer.capacity() * 2);
|
|
195 |
} else {
|