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
ab6950d7
Commit
ab6950d7
authored
Jan 28, 2010
by
kenton@google.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More Java warning tweaks from Evan Jones.
parent
28c2ec0d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
18 deletions
+30
-18
GeneratedMessage.java
java/src/main/java/com/google/protobuf/GeneratedMessage.java
+4
-4
GeneratedMessageLite.java
...c/main/java/com/google/protobuf/GeneratedMessageLite.java
+1
-0
DescriptorsTest.java
java/src/test/java/com/google/protobuf/DescriptorsTest.java
+1
-0
java_enum.cc
src/google/protobuf/compiler/java/java_enum.cc
+15
-8
java_message.cc
src/google/protobuf/compiler/java/java_message.cc
+9
-6
No files found.
java/src/main/java/com/google/protobuf/GeneratedMessage.java
View file @
ab6950d7
...
@@ -769,7 +769,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
...
@@ -769,7 +769,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
/** For use by generated code only. */
/** For use by generated code only. */
public
void
internalInit
(
final
FieldDescriptor
descriptor
,
public
void
internalInit
(
final
FieldDescriptor
descriptor
,
final
Class
type
)
{
final
Class
<?>
type
)
{
if
(
this
.
descriptor
!=
null
)
{
if
(
this
.
descriptor
!=
null
)
{
throw
new
IllegalStateException
(
"Already initialized."
);
throw
new
IllegalStateException
(
"Already initialized."
);
}
}
...
@@ -809,7 +809,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
...
@@ -809,7 +809,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
}
}
private
FieldDescriptor
descriptor
;
private
FieldDescriptor
descriptor
;
private
Class
type
;
private
Class
<?>
type
;
private
Method
enumValueOf
;
private
Method
enumValueOf
;
private
Method
enumGetValueDescriptor
;
private
Method
enumGetValueDescriptor
;
private
Message
messageDefaultInstance
;
private
Message
messageDefaultInstance
;
...
@@ -1054,7 +1054,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
...
@@ -1054,7 +1054,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
// Note: We use Java reflection to call public methods rather than
// Note: We use Java reflection to call public methods rather than
// access private fields directly as this avoids runtime security
// access private fields directly as this avoids runtime security
// checks.
// checks.
protected
final
Class
type
;
protected
final
Class
<?>
type
;
protected
final
Method
getMethod
;
protected
final
Method
getMethod
;
protected
final
Method
setMethod
;
protected
final
Method
setMethod
;
protected
final
Method
hasMethod
;
protected
final
Method
hasMethod
;
...
@@ -1118,7 +1118,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
...
@@ -1118,7 +1118,7 @@ public abstract class GeneratedMessage extends AbstractMessage {
clearMethod
=
getMethodOrDie
(
builderClass
,
"clear"
+
camelCaseName
);
clearMethod
=
getMethodOrDie
(
builderClass
,
"clear"
+
camelCaseName
);
}
}
protected
final
Class
type
;
protected
final
Class
<?>
type
;
protected
final
Method
getMethod
;
protected
final
Method
getMethod
;
protected
final
Method
getRepeatedMethod
;
protected
final
Method
getRepeatedMethod
;
protected
final
Method
setRepeatedMethod
;
protected
final
Method
setRepeatedMethod
;
...
...
java/src/main/java/com/google/protobuf/GeneratedMessageLite.java
View file @
ab6950d7
...
@@ -524,6 +524,7 @@ public abstract class GeneratedMessageLite extends AbstractMessageLite {
...
@@ -524,6 +524,7 @@ public abstract class GeneratedMessageLite extends AbstractMessageLite {
}
}
/** For use by generated code only. */
/** For use by generated code only. */
@SuppressWarnings
(
"unchecked"
)
public
void
internalInitRepeated
(
public
void
internalInitRepeated
(
final
ContainingType
containingTypeDefaultInstance
,
final
ContainingType
containingTypeDefaultInstance
,
final
MessageLite
messageDefaultInstance
,
final
MessageLite
messageDefaultInstance
,
...
...
java/src/test/java/com/google/protobuf/DescriptorsTest.java
View file @
ab6950d7
...
@@ -70,6 +70,7 @@ public class DescriptorsTest extends TestCase {
...
@@ -70,6 +70,7 @@ public class DescriptorsTest extends TestCase {
// Regression test for bug where referencing a FieldDescriptor.Type value
// Regression test for bug where referencing a FieldDescriptor.Type value
// before a FieldDescriptorProto.Type value would yield a
// before a FieldDescriptorProto.Type value would yield a
// ExceptionInInitializerError.
// ExceptionInInitializerError.
@SuppressWarnings
(
"unused"
)
private
static
final
Object
STATIC_INIT_TEST
=
FieldDescriptor
.
Type
.
BOOL
;
private
static
final
Object
STATIC_INIT_TEST
=
FieldDescriptor
.
Type
.
BOOL
;
public
void
testFieldTypeEnumMapping
()
throws
Exception
{
public
void
testFieldTypeEnumMapping
()
throws
Exception
{
...
...
src/google/protobuf/compiler/java/java_enum.cc
View file @
ab6950d7
...
@@ -138,7 +138,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
...
@@ -138,7 +138,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
" internalValueMap =
\n
"
" internalValueMap =
\n
"
" new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {
\n
"
" new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {
\n
"
" public $classname$ findValueByNumber(int number) {
\n
"
" public $classname$ findValueByNumber(int number) {
\n
"
" return $classname$.valueOf(number)
\n
;
"
" return $classname$.valueOf(number)
;
\n
"
" }
\n
"
" }
\n
"
" };
\n
"
" };
\n
"
"
\n
"
,
"
\n
"
,
...
@@ -190,6 +190,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
...
@@ -190,6 +190,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
printer
->
Print
(
printer
->
Print
(
"
\n
"
"
\n
"
"};
\n
"
"};
\n
"
"
\n
"
"public static $classname$ valueOf(
\n
"
"public static $classname$ valueOf(
\n
"
" com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
\n
"
" com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
\n
"
" if (desc.getType() != getDescriptor()) {
\n
"
" if (desc.getType() != getDescriptor()) {
\n
"
...
@@ -197,20 +198,26 @@ void EnumGenerator::Generate(io::Printer* printer) {
...
@@ -197,20 +198,26 @@ void EnumGenerator::Generate(io::Printer* printer) {
"
\"
EnumValueDescriptor is not for this type.
\"
);
\n
"
"
\"
EnumValueDescriptor is not for this type.
\"
);
\n
"
" }
\n
"
" }
\n
"
" return VALUES[desc.getIndex()];
\n
"
" return VALUES[desc.getIndex()];
\n
"
"}
\n
"
,
"}
\n
"
"
\n
"
,
"classname"
,
descriptor_
->
name
());
"classname"
,
descriptor_
->
name
());
// index is only used for reflection; lite implementation does not need it
printer
->
Print
(
"private final int index;
\n
"
);
}
}
// -----------------------------------------------------------------
// -----------------------------------------------------------------
printer
->
Print
(
printer
->
Print
(
"private final int index;
\n
"
"private final int value;
\n\n
"
"private final int value;
\n
"
"private $classname$(int index, int value) {
\n
"
,
"private $classname$(int index, int value) {
\n
"
" this.index = index;
\n
"
" this.value = value;
\n
"
"}
\n
"
,
"classname"
,
descriptor_
->
name
());
"classname"
,
descriptor_
->
name
());
if
(
HasDescriptorMethods
(
descriptor_
))
{
printer
->
Print
(
" this.index = index;
\n
"
);
}
printer
->
Print
(
" this.value = value;
\n
"
"}
\n
"
);
if
(
HasDescriptorMethods
(
descriptor_
))
{
if
(
HasDescriptorMethods
(
descriptor_
))
{
// Force the static initialization code for the file to run, since it may
// Force the static initialization code for the file to run, since it may
...
...
src/google/protobuf/compiler/java/java_message.cc
View file @
ab6950d7
...
@@ -420,15 +420,18 @@ GenerateMessageSerializationMethods(io::Printer* printer) {
...
@@ -420,15 +420,18 @@ GenerateMessageSerializationMethods(io::Printer* printer) {
if
(
descriptor_
->
extension_range_count
()
>
0
)
{
if
(
descriptor_
->
extension_range_count
()
>
0
)
{
if
(
descriptor_
->
options
().
message_set_wire_format
())
{
if
(
descriptor_
->
options
().
message_set_wire_format
())
{
printer
->
Print
(
printer
->
Print
(
"com.google.protobuf.GeneratedMessage$lite$
.ExtendableMessage
\n
"
"com.google.protobuf.GeneratedMessage$lite$
\n
"
" .ExtensionWriter extensionWriter =
\n
"
" .Exten
dableMessage<$classname$>.Exten
sionWriter extensionWriter =
\n
"
" newMessageSetExtensionWriter();
\n
"
,
" newMessageSetExtensionWriter();
\n
"
,
"lite"
,
HasDescriptorMethods
(
descriptor_
)
?
""
:
"Lite"
);
"lite"
,
HasDescriptorMethods
(
descriptor_
)
?
""
:
"Lite"
,
"classname"
,
ClassName
(
descriptor_
));
}
else
{
}
else
{
printer
->
Print
(
printer
->
Print
(
"com.google.protobuf.GeneratedMessage$lite$.ExtendableMessage
\n
"
"com.google.protobuf.GeneratedMessage$lite$
\n
"
" .ExtensionWriter extensionWriter = newExtensionWriter();
\n
"
,
" .ExtendableMessage<$classname$>.ExtensionWriter extensionWriter =
\n
"
"lite"
,
HasDescriptorMethods
(
descriptor_
)
?
""
:
"Lite"
);
" newExtensionWriter();
\n
"
,
"lite"
,
HasDescriptorMethods
(
descriptor_
)
?
""
:
"Lite"
,
"classname"
,
ClassName
(
descriptor_
));
}
}
}
}
...
...
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