diff options
author | Max Cai <maxtroy@google.com> | 2013-07-29 17:20:50 +0100 |
---|---|---|
committer | Max Cai <maxtroy@google.com> | 2013-08-05 21:54:58 +0100 |
commit | 624c448fbef20a1a2fad2289f622b468c25763d1 (patch) | |
tree | 70294971235a3e23aea495f7b3c2ea39cbfedb66 /src/google/protobuf/unittest_multiple_nameclash_micro.proto | |
parent | be47f55e2f93df84abb55759e49cf381d2745cc5 (diff) | |
download | external_protobuf-624c448fbef20a1a2fad2289f622b468c25763d1.zip external_protobuf-624c448fbef20a1a2fad2289f622b468c25763d1.tar.gz external_protobuf-624c448fbef20a1a2fad2289f622b468c25763d1.tar.bz2 |
Fix outer classname for javamicro/javanano.
- File class name is defined as the java_outer_classname option value
or the file name ToCamelCase; never the single message's ClassName.
- File-scope enums are translated to constants in the file class,
regardless of java_multiple_files.
- If java_multiple_files=true, and file's class name equals a message's
class name, no error. This is done by detecting that the outer class
is not needed and skipping the outer class codegen and clash checks.
Note: there is a disparity between java[lite] and the previous
java{micr|nan}o: when generating code for a single-message proto, the
outer class is omitted by java{micr|nan}o if the file does not have
java_outer_classname. This change makes java{micr|nan}o align with
java[lite] codegen and create the outer class, but will print some
info to warn of potential change of code.
- Also fixed the "is_own_file" detection and made all parseX() methods
static. Previously, all messages in a java_multiple_files=true file
are (incorrectly) considered to be in their own files, including
nested messages, causing them to become inner classes (instance-
bound) and forcing the parseX() methods to lose the static modifier.
- This change supersedes c/60164 and c/60086, which causes javanano to
put enum values into enum shell classes if java_multiple_files=true.
We now always use the parent class to host the enum values. A future
change will add a command line option to provide more flexibility.
- Elaborated in java/README.txt.
Change-Id: I684932f90e0a028ef37c662b221def5ffa202439
Diffstat (limited to 'src/google/protobuf/unittest_multiple_nameclash_micro.proto')
-rw-r--r-- | src/google/protobuf/unittest_multiple_nameclash_micro.proto | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/google/protobuf/unittest_multiple_nameclash_micro.proto b/src/google/protobuf/unittest_multiple_nameclash_micro.proto new file mode 100644 index 0000000..089fd85 --- /dev/null +++ b/src/google/protobuf/unittest_multiple_nameclash_micro.proto @@ -0,0 +1,41 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// http://code.google.com/p/protobuf/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Author: maxtroy@google.com (Max Cai) + +package protobuf_unittest_import; + +option java_package = "com.google.protobuf.micro"; +option java_outer_classname = "MultipleNameClashMicro"; +option java_multiple_files = true; + +message MultipleNameClashMicro { + optional int32 field = 1; +} |