From 11f883e185a2ea6fd6d0b19520e9f0f004e90e5c Mon Sep 17 00:00:00 2001 From: Max Cai Date: Tue, 15 Jul 2014 15:15:28 +0100 Subject: Fix access around unknownFieldData. Instead of publishing its class I chose to encapsulate the troublesome references in equals()/hashCode() in the generated code into superclass methods in ExtendableMessageNano. Changed a couple of java packages in the test suite to catch this issue easier in the future. Change-Id: I43f88411f63bb6f3ffc8d63361f2f77bebf6220a --- src/google/protobuf/compiler/javanano/javanano_message.cc | 9 ++------- src/google/protobuf/unittest_extension_nano.proto | 2 +- src/google/protobuf/unittest_import_nano.proto | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/javanano/javanano_message.cc b/src/google/protobuf/compiler/javanano/javanano_message.cc index 0cf9f97..7a2b4a0 100644 --- a/src/google/protobuf/compiler/javanano/javanano_message.cc +++ b/src/google/protobuf/compiler/javanano/javanano_message.cc @@ -501,11 +501,7 @@ void MessageGenerator::GenerateEquals(io::Printer* printer) { if (params_.store_unknown_fields()) { printer->Print( - "if (unknownFieldData == null || unknownFieldData.isEmpty()) {\n" - " return other.unknownFieldData == null || other.unknownFieldData.isEmpty();" - "} else {\n" - " return unknownFieldData.equals(other.unknownFieldData);\n" - "}\n"); + "return unknownFieldDataEquals(other);\n"); } else { printer->Print( "return true;\n"); @@ -534,8 +530,7 @@ void MessageGenerator::GenerateHashCode(io::Printer* printer) { if (params_.store_unknown_fields()) { printer->Print( - "result = 31 * result + (unknownFieldData == null || unknownFieldData.isEmpty()\n" - " ? 0 : unknownFieldData.hashCode());\n"); + "result = 31 * result + unknownFieldDataHashCode();\n"); } printer->Print("return result;\n"); diff --git a/src/google/protobuf/unittest_extension_nano.proto b/src/google/protobuf/unittest_extension_nano.proto index 0a775f4..2a678a8 100644 --- a/src/google/protobuf/unittest_extension_nano.proto +++ b/src/google/protobuf/unittest_extension_nano.proto @@ -1,7 +1,7 @@ syntax = "proto2"; option java_outer_classname = "Extensions"; -option java_package = "com.google.protobuf.nano"; +option java_package = "com.google.protobuf.nano.testext"; message ExtendableMessage { optional int32 field = 1; diff --git a/src/google/protobuf/unittest_import_nano.proto b/src/google/protobuf/unittest_import_nano.proto index 7813715..0a2fde7 100644 --- a/src/google/protobuf/unittest_import_nano.proto +++ b/src/google/protobuf/unittest_import_nano.proto @@ -35,7 +35,7 @@ package protobuf_unittest_import; // java_package and java_outer_classname are specified on the command line. -//option java_package = "com.google.protobuf.nano"; +//option java_package = "com.google.protobuf.nano.testimport"; //option java_outer_classname = "UnittestImportNano"; message ImportMessageNano { -- cgit v1.1