1// Protocol Buffers - Google's data interchange format 2// Copyright 2008 Google Inc. All rights reserved. 3// https://developers.google.com/protocol-buffers/ 4// 5// Redistribution and use in source and binary forms, with or without 6// modification, are permitted provided that the following conditions are 7// met: 8// 9// * Redistributions of source code must retain the above copyright 10// notice, this list of conditions and the following disclaimer. 11// * Redistributions in binary form must reproduce the above 12// copyright notice, this list of conditions and the following disclaimer 13// in the documentation and/or other materials provided with the 14// distribution. 15// * Neither the name of Google Inc. nor the names of its 16// contributors may be used to endorse or promote products derived from 17// this software without specific prior written permission. 18// 19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 31// Author: jonp@google.com (Jon Perlow) 32 33// This file tests that various identifiers work as field and type names even 34// though the same identifiers are used internally by the java code generator. 35 36 37// Some generic_services option(s) added automatically. 38// See: http://go/proto2-generic-services-default 39option java_generic_services = true; // auto-added 40 41package io_protocol_tests; 42 43option java_package = "com.google.protobuf"; 44option java_outer_classname = "TestBadIdentifiersProto"; 45option java_generate_equals_and_hash = true; 46 47message TestMessage { 48 optional string cached_size = 1; 49 optional string serialized_size = 2; 50 optional string class = 3; 51} 52 53message Descriptor { 54 option no_standard_descriptor_accessor = true; 55 optional string descriptor = 1; 56 message NestedDescriptor { 57 option no_standard_descriptor_accessor = true; 58 optional string descriptor = 1; 59 } 60 optional NestedDescriptor nested_descriptor = 2; 61 enum NestedEnum { 62 FOO = 1; 63 } 64} 65 66message Parser { 67 enum ParserEnum { 68 PARSER = 1; 69 } 70 optional ParserEnum parser = 1; 71} 72 73message Deprecated { 74 enum TestEnum { 75 FOO = 1; 76 77 // Test if @Deprecated annotation conflicts with Deprecated message name. 78 BAR = 2 [ deprecated = true ]; 79 } 80 81 optional int32 field1 = 1 [deprecated=true]; 82 optional TestEnum field2 = 2 [deprecated=true]; 83 optional TestMessage field3 = 3 [deprecated=true]; 84} 85 86message Override { 87 optional int32 override = 1; 88} 89 90message Object { 91 optional int32 object = 1; 92 optional string string_object = 2; 93} 94 95message String { 96 optional string string = 1; 97} 98 99message Integer { 100 optional int32 integer = 1; 101} 102 103message Long { 104 optional int32 long = 1; 105} 106 107message Float { 108 optional float float = 1; 109} 110 111message Double { 112 optional double double = 1; 113} 114 115service TestConflictingMethodNames { 116 rpc Override(TestMessage) returns (TestMessage); 117} 118 119message TestConflictingFieldNames { 120 enum TestEnum { 121 FOO = 1; 122 } 123 message TestMessage { 124 } 125 repeated int32 int32_field = 1; 126 repeated TestEnum enum_field = 2; 127 repeated string string_field = 3; 128 repeated bytes bytes_field = 4; 129 repeated TestMessage message_field = 5; 130 131 optional int32 int32_field_count = 11; 132 optional TestEnum enum_field_count = 12; 133 optional string string_field_count = 13; 134 optional bytes bytes_field_count = 14; 135 optional TestMessage message_field_count = 15; 136 137 repeated int32 Int32Field = 21; 138 repeated TestEnum EnumField = 22; 139 repeated string StringField = 23; 140 repeated bytes BytesField = 24; 141 repeated TestMessage MessageField = 25; 142 143 // This field conflicts with "int32_field" as they both generate 144 // the method getInt32FieldList(). 145 required int32 int32_field_list = 31; 146 147 extensions 1000 to max; 148 149 repeated int64 int64_field = 41; 150 extend TestConflictingFieldNames { 151 // We don't generate accessors for extensions so the following extension 152 // fields don't conflict with the repeated field "int64_field". 153 optional int64 int64_field_count = 1001; 154 optional int64 int64_field_list = 1002; 155 } 156} 157 158