Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
d2d50f9a
Commit
d2d50f9a
authored
Nov 30, 2012
by
xiaofeng@google.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Java compile issues under JDK 1.5
parent
a4491ea1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
17 deletions
+15
-17
ByteString.java
java/src/main/java/com/google/protobuf/ByteString.java
+11
-3
LazyField.java
java/src/main/java/com/google/protobuf/LazyField.java
+0
-6
LazyStringArrayList.java
...rc/main/java/com/google/protobuf/LazyStringArrayList.java
+0
-1
RopeByteString.java
java/src/main/java/com/google/protobuf/RopeByteString.java
+4
-6
UnmodifiableLazyStringList.java
.../java/com/google/protobuf/UnmodifiableLazyStringList.java
+0
-1
No files found.
java/src/main/java/com/google/protobuf/ByteString.java
View file @
d2d50f9a
...
...
@@ -37,7 +37,6 @@ import java.io.OutputStream;
import
java.io.UnsupportedEncodingException
;
import
java.nio.ByteBuffer
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.List
;
...
...
@@ -777,6 +776,15 @@ public abstract class ByteString implements Iterable<Byte> {
return
ByteString
.
copyFrom
(
flushedBuffers
);
}
/**
* Implement java.util.Arrays.copyOf() for jdk 1.5.
*/
private
byte
[]
copyArray
(
byte
[]
buffer
,
int
length
)
{
byte
[]
result
=
new
byte
[
length
];
System
.
arraycopy
(
buffer
,
0
,
result
,
0
,
Math
.
min
(
buffer
.
length
,
length
));
return
result
;
}
/**
* Writes the complete contents of this byte array output stream to
* the specified output stream argument.
...
...
@@ -800,7 +808,7 @@ public abstract class ByteString implements Iterable<Byte> {
byteString
.
writeTo
(
out
);
}
out
.
write
(
Arrays
.
copyOf
(
cachedBuffer
,
cachedBufferPos
));
out
.
write
(
copyArray
(
cachedBuffer
,
cachedBufferPos
));
}
/**
...
...
@@ -853,7 +861,7 @@ public abstract class ByteString implements Iterable<Byte> {
private
void
flushLastBuffer
()
{
if
(
bufferPos
<
buffer
.
length
)
{
if
(
bufferPos
>
0
)
{
byte
[]
bufferCopy
=
Arrays
.
copyOf
(
buffer
,
bufferPos
);
byte
[]
bufferCopy
=
copyArray
(
buffer
,
bufferPos
);
flushedBuffers
.
add
(
new
LiteralByteString
(
bufferCopy
));
}
// We reuse this buffer for further writes.
...
...
java/src/main/java/com/google/protobuf/LazyField.java
View file @
d2d50f9a
...
...
@@ -157,12 +157,10 @@ class LazyField {
this
.
entry
=
entry
;
}
@Override
public
K
getKey
()
{
return
entry
.
getKey
();
}
@Override
public
Object
getValue
()
{
LazyField
field
=
entry
.
getValue
();
if
(
field
==
null
)
{
...
...
@@ -175,7 +173,6 @@ class LazyField {
return
entry
.
getValue
();
}
@Override
public
Object
setValue
(
Object
value
)
{
if
(!(
value
instanceof
MessageLite
))
{
throw
new
IllegalArgumentException
(
...
...
@@ -193,13 +190,11 @@ class LazyField {
this
.
iterator
=
iterator
;
}
@Override
public
boolean
hasNext
()
{
return
iterator
.
hasNext
();
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
Entry
<
K
,
Object
>
next
()
{
Entry
<
K
,
?>
entry
=
iterator
.
next
();
if
(
entry
.
getValue
()
instanceof
LazyField
)
{
...
...
@@ -208,7 +203,6 @@ class LazyField {
return
(
Entry
<
K
,
Object
>)
entry
;
}
@Override
public
void
remove
()
{
iterator
.
remove
();
}
...
...
java/src/main/java/com/google/protobuf/LazyStringArrayList.java
View file @
d2d50f9a
...
...
@@ -172,7 +172,6 @@ public class LazyStringArrayList extends AbstractList<String>
}
}
@Override
public
List
<?>
getUnderlyingElements
()
{
return
Collections
.
unmodifiableList
(
list
);
}
...
...
java/src/main/java/com/google/protobuf/RopeByteString.java
View file @
d2d50f9a
...
...
@@ -36,13 +36,12 @@ import java.io.OutputStream;
import
java.io.UnsupportedEncodingException
;
import
java.io.ByteArrayInputStream
;
import
java.nio.ByteBuffer
;
import
java.util.ArrayDeque
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Deque
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.NoSuchElementException
;
import
java.util.Stack
;
/**
* Class to represent {@code ByteStrings} formed by concatenation of other
...
...
@@ -590,8 +589,7 @@ class RopeByteString extends ByteString {
// Stack containing the part of the string, starting from the left, that
// we've already traversed. The final string should be the equivalent of
// concatenating the strings on the stack from bottom to top.
private
final
Deque
<
ByteString
>
prefixesStack
=
new
ArrayDeque
<
ByteString
>(
minLengthByDepth
.
length
);
private
final
Stack
<
ByteString
>
prefixesStack
=
new
Stack
<
ByteString
>();
private
ByteString
balance
(
ByteString
left
,
ByteString
right
)
{
doBalance
(
left
);
...
...
@@ -703,8 +701,8 @@ class RopeByteString extends ByteString {
*/
private
static
class
PieceIterator
implements
Iterator
<
LiteralByteString
>
{
private
final
Deque
<
RopeByteString
>
breadCrumbs
=
new
ArrayDeque
<
RopeByteString
>(
minLengthByDepth
.
length
);
private
final
Stack
<
RopeByteString
>
breadCrumbs
=
new
Stack
<
RopeByteString
>(
);
private
LiteralByteString
next
;
private
PieceIterator
(
ByteString
root
)
{
...
...
java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java
View file @
d2d50f9a
...
...
@@ -145,7 +145,6 @@ public class UnmodifiableLazyStringList extends AbstractList<String>
};
}
@Override
public
List
<?>
getUnderlyingElements
()
{
// The returned value is already unmodifiable.
return
list
.
getUnderlyingElements
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment