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
5a5e67a2
Commit
5a5e67a2
authored
Apr 28, 2011
by
liujisi@google.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make protobuf java JDK 1.5 compatible.
parent
9cf65b7d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
77 additions
and
35 deletions
+77
-35
GeneratedMessage.java
java/src/main/java/com/google/protobuf/GeneratedMessage.java
+4
-4
RepeatedFieldBuilder.java
...c/main/java/com/google/protobuf/RepeatedFieldBuilder.java
+1
-1
SingleFieldBuilder.java
...src/main/java/com/google/protobuf/SingleFieldBuilder.java
+1
-1
SmallSortedMap.java
java/src/main/java/com/google/protobuf/SmallSortedMap.java
+11
-11
UnmodifiableLazyStringList.java
.../java/com/google/protobuf/UnmodifiableLazyStringList.java
+15
-15
ForceFieldBuildersPreRun.java
...st/java/com/google/protobuf/ForceFieldBuildersPreRun.java
+1
-1
SmallSortedMapTest.java
...src/test/java/com/google/protobuf/SmallSortedMapTest.java
+43
-1
TestUtil.java
java/src/test/java/com/google/protobuf/TestUtil.java
+1
-1
No files found.
java/src/main/java/com/google/protobuf/GeneratedMessage.java
View file @
5a5e67a2
...
...
@@ -421,7 +421,7 @@ public abstract class GeneratedMessage extends AbstractMessage
return
true
;
}
@Override
//@Override (Java
public
final
UnknownFieldSet
getUnknownFields
()
{
return
unknownFields
;
}
...
...
@@ -445,7 +445,7 @@ public abstract class GeneratedMessage extends AbstractMessage
*/
private
class
BuilderParentImpl
implements
BuilderParent
{
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
markDirty
()
{
onChanged
();
}
...
...
@@ -1130,7 +1130,7 @@ public abstract class GeneratedMessage extends AbstractMessage
// obtained.
return
new
GeneratedExtension
<
ContainingType
,
Type
>(
new
ExtensionDescriptorRetriever
()
{
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
FieldDescriptor
getDescriptor
()
{
return
scope
.
getDescriptorForType
().
getExtensions
()
.
get
(
descriptorIndex
);
...
...
@@ -1225,7 +1225,7 @@ public abstract class GeneratedMessage extends AbstractMessage
throw
new
IllegalStateException
(
"Already initialized."
);
}
descriptorRetriever
=
new
ExtensionDescriptorRetriever
()
{
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
FieldDescriptor
getDescriptor
()
{
return
descriptor
;
}
...
...
java/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java
View file @
5a5e67a2
...
...
@@ -573,7 +573,7 @@ public class RepeatedFieldBuilder
}
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
markDirty
()
{
onChanged
();
}
...
...
java/src/main/java/com/google/protobuf/SingleFieldBuilder.java
View file @
5a5e67a2
...
...
@@ -234,7 +234,7 @@ public class SingleFieldBuilder
}
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
markDirty
()
{
onChanged
();
}
...
...
java/src/main/java/com/google/protobuf/SmallSortedMap.java
View file @
5a5e67a2
...
...
@@ -411,22 +411,22 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
this
.
value
=
value
;
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
K
getKey
()
{
return
key
;
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
V
getValue
()
{
return
value
;
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
int
compareTo
(
Entry
other
)
{
return
getKey
().
compareTo
(
other
.
getKey
());
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
V
setValue
(
V
newValue
)
{
checkMutable
();
final
V
oldValue
=
this
.
value
;
...
...
@@ -535,13 +535,13 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
private
boolean
nextCalledBeforeRemove
;
private
Iterator
<
Map
.
Entry
<
K
,
V
>>
lazyOverflowIterator
;
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
boolean
hasNext
()
{
return
(
pos
+
1
)
<
entryList
.
size
()
||
getOverflowIterator
().
hasNext
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
Map
.
Entry
<
K
,
V
>
next
()
{
nextCalledBeforeRemove
=
true
;
// Always increment pos so that we know whether the last returned value
...
...
@@ -552,7 +552,7 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
return
getOverflowIterator
().
next
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
remove
()
{
if
(!
nextCalledBeforeRemove
)
{
throw
new
IllegalStateException
(
"remove() was called before next()"
);
...
...
@@ -589,22 +589,22 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
private
static
class
EmptySet
{
private
static
final
Iterator
<
Object
>
ITERATOR
=
new
Iterator
<
Object
>()
{
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
boolean
hasNext
()
{
return
false
;
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
Object
next
()
{
throw
new
NoSuchElementException
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
remove
()
{
throw
new
UnsupportedOperationException
();
}
};
private
static
final
Iterable
<
Object
>
ITERABLE
=
new
Iterable
<
Object
>()
{
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
Iterator
<
Object
>
iterator
()
{
return
ITERATOR
;
}
...
...
java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java
View file @
5a5e67a2
...
...
@@ -60,62 +60,62 @@ public class UnmodifiableLazyStringList extends AbstractList<String>
return
list
.
size
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
ByteString
getByteString
(
int
index
)
{
return
list
.
getByteString
(
index
);
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
add
(
ByteString
element
)
{
throw
new
UnsupportedOperationException
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
ListIterator
<
String
>
listIterator
(
final
int
index
)
{
return
new
ListIterator
<
String
>()
{
ListIterator
<
String
>
iter
=
list
.
listIterator
(
index
);
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
boolean
hasNext
()
{
return
iter
.
hasNext
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
String
next
()
{
return
iter
.
next
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
boolean
hasPrevious
()
{
return
iter
.
hasPrevious
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
String
previous
()
{
return
iter
.
previous
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
int
nextIndex
()
{
return
iter
.
nextIndex
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
int
previousIndex
()
{
return
iter
.
previousIndex
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
remove
()
{
throw
new
UnsupportedOperationException
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
set
(
String
o
)
{
throw
new
UnsupportedOperationException
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
add
(
String
o
)
{
throw
new
UnsupportedOperationException
();
}
...
...
@@ -127,17 +127,17 @@ public class UnmodifiableLazyStringList extends AbstractList<String>
return
new
Iterator
<
String
>()
{
Iterator
<
String
>
iter
=
list
.
iterator
();
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
boolean
hasNext
()
{
return
iter
.
hasNext
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
String
next
()
{
return
iter
.
next
();
}
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
remove
()
{
throw
new
UnsupportedOperationException
();
}
...
...
java/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java
View file @
5a5e67a2
...
...
@@ -41,7 +41,7 @@ package com.google.protobuf;
*/
public
class
ForceFieldBuildersPreRun
implements
Runnable
{
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
run
()
{
GeneratedMessage
.
enableAlwaysUseFieldBuildersForTesting
();
}
...
...
java/src/test/java/com/google/protobuf/SmallSortedMapTest.java
View file @
5a5e67a2
...
...
@@ -32,7 +32,6 @@ package com.google.protobuf;
import
junit.framework.TestCase
;
import
java.util.AbstractMap.SimpleEntry
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
...
...
@@ -46,6 +45,49 @@ import java.util.TreeSet;
* @author darick@google.com Darick Tong
*/
public
class
SmallSortedMapTest
extends
TestCase
{
// java.util.AbstractMap.SimpleEntry is private in JDK 1.5. We re-implement it
// here for JDK 1.5 users.
private
static
class
SimpleEntry
<
K
,
V
>
implements
Map
.
Entry
<
K
,
V
>
{
private
final
K
key
;
private
V
value
;
SimpleEntry
(
K
key
,
V
value
)
{
this
.
key
=
key
;
this
.
value
=
value
;
}
public
K
getKey
()
{
return
key
;
}
public
V
getValue
()
{
return
value
;
}
public
V
setValue
(
V
value
)
{
V
oldValue
=
this
.
value
;
this
.
value
=
value
;
return
oldValue
;
}
private
static
boolean
eq
(
Object
o1
,
Object
o2
)
{
return
o1
==
null
?
o2
==
null
:
o1
.
equals
(
o2
);
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(!(
o
instanceof
Map
.
Entry
))
return
false
;
Map
.
Entry
e
=
(
Map
.
Entry
)
o
;
return
eq
(
key
,
e
.
getKey
())
&&
eq
(
value
,
e
.
getValue
());
}
@Override
public
int
hashCode
()
{
return
((
key
==
null
)
?
0
:
key
.
hashCode
())
^
((
value
==
null
)
?
0
:
value
.
hashCode
());
}
}
public
void
testPutAndGetArrayEntriesOnly
()
{
runPutAndGetTest
(
3
);
...
...
java/src/test/java/com/google/protobuf/TestUtil.java
View file @
5a5e67a2
...
...
@@ -3799,7 +3799,7 @@ public final class TestUtil {
private
int
invalidations
;
@Override
//@Override (Java 1.6 override semantics, but we must support 1.5)
public
void
markDirty
()
{
invalidations
++;
}
...
...
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