aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/javanano/javanano_message_field.cc
diff options
context:
space:
mode:
authorGravatar Ficus Kirkpatrick <ficus@android.com>2013-04-08 13:47:44 -0700
committerGravatar Ficus Kirkpatrick <ficus@android.com>2013-04-08 15:47:56 -0700
commit314a30293347a7a3d5dd032f08677d9e988721cf (patch)
treed6b265110ec1c8ba69aa46b5987b197326c75d3b /src/google/protobuf/compiler/javanano/javanano_message_field.cc
parentd4bb580f1bbeb108f3d750cce504921df0a4d535 (diff)
Don't use Arrays.copyOf in generated code.
It didn't appear until API 9 and is thus incompatible with Froyo. Instead, allocate a new array and System.arraycopy inline. Change-Id: I2e1cd07a4a762ef8edd5ec06ceaa1d38b302823d
Diffstat (limited to 'src/google/protobuf/compiler/javanano/javanano_message_field.cc')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_message_field.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_message_field.cc b/src/google/protobuf/compiler/javanano/javanano_message_field.cc
index 01529c81..ec9d995f 100644
--- a/src/google/protobuf/compiler/javanano/javanano_message_field.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_message_field.cc
@@ -144,7 +144,9 @@ GenerateParsingCode(io::Printer* printer) const {
printer->Print(variables_,
"int arrayLength = com.google.protobuf.nano.WireFormatNano.getRepeatedFieldArrayLength(input, $tag$);\n"
"int i = this.$name$.length;\n"
- "this.$name$ = java.util.Arrays.copyOf(this.$name$, i + arrayLength);\n"
+ "$type$[] newArray = new $type$[i + arrayLength];\n"
+ "System.arraycopy(this.$name$, 0, newArray, 0, i);\n"
+ "this.$name$ = newArray;\n"
"for (; i < this.$name$.length - 1; i++) {\n"
" this.$name$[i] = new $type$();\n");