ADD: added new version of protobuf
This commit is contained in:
@@ -33,7 +33,6 @@ pkg_files(
|
||||
"bom/pom.xml",
|
||||
"lite.md",
|
||||
"pom.xml",
|
||||
"protoc/pom.xml",
|
||||
],
|
||||
strip_prefix = strip_prefix.from_root(""),
|
||||
visibility = ["//pkg:__pkg__"],
|
||||
|
||||
@@ -23,7 +23,7 @@ If you are using Maven, use the following:
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.21.8</version>
|
||||
<version>3.21.12</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -37,7 +37,7 @@ protobuf-java-util package:
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java-util</artifactId>
|
||||
<version>3.21.8</version>
|
||||
<version>3.21.12</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -45,7 +45,7 @@ protobuf-java-util package:
|
||||
|
||||
If you are using Gradle, add the following to your `build.gradle` file's dependencies:
|
||||
```
|
||||
implementation 'com.google.protobuf:protobuf-java:3.21.8'
|
||||
implementation 'com.google.protobuf:protobuf-java:3.21.12'
|
||||
```
|
||||
Again, be sure to check that the version number matches (or is newer than) the version number of protoc that you are using.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-bom</artifactId>
|
||||
<version>3.21.8</version>
|
||||
<version>3.21.12</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Protocol Buffers [BOM]</name>
|
||||
|
||||
@@ -191,7 +191,7 @@ java_export(
|
||||
maven_coordinates = "com.google.protobuf:protobuf-java:%s" % PROTOBUF_JAVA_VERSION,
|
||||
pom_template = "pom_template.xml",
|
||||
resources = [
|
||||
"//src/google/protobuf:descriptor_proto_srcs",
|
||||
"//:built_in_runtime_protos",
|
||||
"//:well_known_type_protos",
|
||||
],
|
||||
tags = ["manual"],
|
||||
@@ -242,9 +242,8 @@ proto_library(
|
||||
deps = [
|
||||
"//:any_proto",
|
||||
"//:descriptor_proto",
|
||||
"//:lite_test_protos",
|
||||
"//:generic_test_protos",
|
||||
"//:wrappers_proto",
|
||||
"//src/google/protobuf:generic_test_protos",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -253,15 +252,7 @@ java_proto_library(
|
||||
visibility = [
|
||||
"//java:__subpackages__",
|
||||
],
|
||||
deps = ["//src/google/protobuf:generic_test_protos"],
|
||||
)
|
||||
|
||||
java_proto_library(
|
||||
name = "lite_test_protos_java_proto",
|
||||
visibility = [
|
||||
"//java:__subpackages__",
|
||||
],
|
||||
deps = ["//:lite_test_protos"],
|
||||
deps = ["//:generic_test_protos"],
|
||||
)
|
||||
|
||||
java_proto_library(
|
||||
@@ -280,7 +271,6 @@ java_library(
|
||||
":core",
|
||||
":generic_test_protos_java_proto",
|
||||
":java_test_protos_java_proto",
|
||||
":lite_test_protos_java_proto",
|
||||
"@maven//:com_google_guava_guava",
|
||||
"@maven//:junit_junit",
|
||||
],
|
||||
@@ -322,12 +312,11 @@ junit_tests(
|
||||
"src/test/java/com/google/protobuf/TestUtilLite.java",
|
||||
],
|
||||
),
|
||||
data = ["//src/google/protobuf:testdata"],
|
||||
data = ["//:testdata"],
|
||||
deps = [
|
||||
":core",
|
||||
":generic_test_protos_java_proto",
|
||||
":java_test_protos_java_proto",
|
||||
":lite_test_protos_java_proto",
|
||||
":test_util",
|
||||
"@maven//:com_google_guava_guava",
|
||||
"@maven//:com_google_truth_truth",
|
||||
@@ -360,16 +349,7 @@ java_lite_proto_library(
|
||||
"//java/kotlin-lite:__pkg__",
|
||||
"//java/lite:__pkg__",
|
||||
],
|
||||
deps = ["//src/google/protobuf:generic_test_protos"],
|
||||
)
|
||||
|
||||
java_lite_proto_library(
|
||||
name = "lite_test_protos_java_proto_lite",
|
||||
visibility = [
|
||||
"//java/kotlin-lite:__pkg__",
|
||||
"//java/lite:__pkg__",
|
||||
],
|
||||
deps = ["//:lite_test_protos"],
|
||||
deps = ["//:generic_test_protos"],
|
||||
)
|
||||
|
||||
java_lite_proto_library(
|
||||
@@ -404,7 +384,6 @@ java_library(
|
||||
":generic_test_protos_java_proto_lite",
|
||||
":java_test_protos_java_proto_lite",
|
||||
":lite_runtime_only",
|
||||
":lite_test_protos_java_proto_lite",
|
||||
"@maven//:com_google_guava_guava",
|
||||
"@maven//:junit_junit",
|
||||
],
|
||||
@@ -461,13 +440,12 @@ junit_tests(
|
||||
["src/test/java/**/*.java"],
|
||||
exclude = LITE_TEST_EXCLUSIONS,
|
||||
),
|
||||
data = ["//src/google/protobuf:testdata"],
|
||||
data = ["//:testdata"],
|
||||
test_prefix = "Lite",
|
||||
deps = [
|
||||
":generic_test_protos_java_proto_lite",
|
||||
":java_test_protos_java_proto_lite",
|
||||
":lite",
|
||||
":lite_test_protos_java_proto_lite",
|
||||
":test_util_lite",
|
||||
"@maven//:com_google_truth_truth",
|
||||
"@maven//:junit_junit",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.21.8</version>
|
||||
<version>3.21.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
|
||||
@@ -209,7 +209,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeInt32List_Internal(int fieldNumber, List<Integer> list, boolean packed)
|
||||
private final void writeInt32List_Internal(int fieldNumber, List<Integer> list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * MAX_VARINT64_SIZE));
|
||||
@@ -227,7 +227,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
|
||||
private final void writeInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * MAX_VARINT64_SIZE));
|
||||
@@ -255,7 +255,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFixed32List_Internal(int fieldNumber, List<Integer> list, boolean packed)
|
||||
private final void writeFixed32List_Internal(int fieldNumber, List<Integer> list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * FIXED32_SIZE));
|
||||
@@ -273,7 +273,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFixed32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
|
||||
private final void writeFixed32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * FIXED32_SIZE));
|
||||
@@ -307,7 +307,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeUInt64List_Internal(int fieldNumber, List<Long> list, boolean packed)
|
||||
private final void writeUInt64List_Internal(int fieldNumber, List<Long> list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * MAX_VARINT64_SIZE));
|
||||
@@ -325,7 +325,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeUInt64List_Internal(int fieldNumber, LongArrayList list, boolean packed)
|
||||
private final void writeUInt64List_Internal(int fieldNumber, LongArrayList list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * MAX_VARINT64_SIZE));
|
||||
@@ -353,7 +353,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFixed64List_Internal(int fieldNumber, List<Long> list, boolean packed)
|
||||
private final void writeFixed64List_Internal(int fieldNumber, List<Long> list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * FIXED64_SIZE));
|
||||
@@ -371,7 +371,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFixed64List_Internal(int fieldNumber, LongArrayList list, boolean packed)
|
||||
private final void writeFixed64List_Internal(int fieldNumber, LongArrayList list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * FIXED64_SIZE));
|
||||
@@ -399,7 +399,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFloatList_Internal(int fieldNumber, List<Float> list, boolean packed)
|
||||
private final void writeFloatList_Internal(int fieldNumber, List<Float> list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * FIXED32_SIZE));
|
||||
@@ -417,7 +417,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFloatList_Internal(int fieldNumber, FloatArrayList list, boolean packed)
|
||||
private final void writeFloatList_Internal(int fieldNumber, FloatArrayList list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * FIXED32_SIZE));
|
||||
@@ -445,7 +445,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeDoubleList_Internal(int fieldNumber, List<Double> list, boolean packed)
|
||||
private final void writeDoubleList_Internal(int fieldNumber, List<Double> list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * FIXED64_SIZE));
|
||||
@@ -463,7 +463,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeDoubleList_Internal(int fieldNumber, DoubleArrayList list, boolean packed)
|
||||
private final void writeDoubleList_Internal(int fieldNumber, DoubleArrayList list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * FIXED64_SIZE));
|
||||
@@ -497,7 +497,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeBoolList_Internal(int fieldNumber, List<Boolean> list, boolean packed)
|
||||
private final void writeBoolList_Internal(int fieldNumber, List<Boolean> list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + list.size());
|
||||
@@ -515,7 +515,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeBoolList_Internal(int fieldNumber, BooleanArrayList list, boolean packed)
|
||||
private final void writeBoolList_Internal(int fieldNumber, BooleanArrayList list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + list.size());
|
||||
@@ -572,7 +572,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeUInt32List_Internal(int fieldNumber, List<Integer> list, boolean packed)
|
||||
private final void writeUInt32List_Internal(int fieldNumber, List<Integer> list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * MAX_VARINT32_SIZE));
|
||||
@@ -590,7 +590,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeUInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
|
||||
private final void writeUInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * MAX_VARINT32_SIZE));
|
||||
@@ -630,7 +630,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeSInt32List_Internal(int fieldNumber, List<Integer> list, boolean packed)
|
||||
private final void writeSInt32List_Internal(int fieldNumber, List<Integer> list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * MAX_VARINT32_SIZE));
|
||||
@@ -648,7 +648,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeSInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
|
||||
private final void writeSInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * MAX_VARINT32_SIZE));
|
||||
@@ -759,7 +759,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeSInt64List_Internal(int fieldNumber, List<Long> list, boolean packed)
|
||||
private final void writeSInt64List_Internal(int fieldNumber, List<Long> list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * MAX_VARINT64_SIZE));
|
||||
@@ -777,7 +777,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeSInt64List_Internal(int fieldNumber, LongArrayList list, boolean packed)
|
||||
private final void writeSInt64List_Internal(int fieldNumber, LongArrayList list, boolean packed)
|
||||
throws IOException {
|
||||
if (packed) {
|
||||
requireSpace((MAX_VARINT32_SIZE * 2) + (list.size() * MAX_VARINT64_SIZE));
|
||||
|
||||
@@ -75,7 +75,6 @@ import java.util.NoSuchElementException;
|
||||
*/
|
||||
@CheckReturnValue
|
||||
public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* When two strings to be concatenated have a combined length shorter than this, we just copy
|
||||
@@ -386,7 +385,8 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
// String -> ByteString
|
||||
|
||||
/**
|
||||
* Returns a {@code ByteString} from a hexadecimal String.
|
||||
* Returns a {@code ByteString} from a hexadecimal String. Alternative CharSequences should use
|
||||
* {@link ByteStrings#decode(CharSequence, BaseEncoding)}
|
||||
*
|
||||
* @param hexString String of hexadecimal digits to create {@code ByteString} from.
|
||||
* @throws NumberFormatException if the hexString does not contain a parsable hex String.
|
||||
@@ -946,8 +946,6 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
|
||||
/** Base class for leaf {@link ByteString}s (i.e. non-ropes). */
|
||||
abstract static class LeafByteString extends ByteString {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected final int getTreeDepth() {
|
||||
return 0;
|
||||
@@ -1132,6 +1130,13 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
return ByteString.copyFrom(flushedBuffers);
|
||||
}
|
||||
|
||||
/** Implement java.util.Arrays.copyOf() for jdk 1.5. */
|
||||
private byte[] copyArray(byte[] buffer, int length) {
|
||||
byte[] result = new byte[length];
|
||||
System.arraycopy(buffer, 0, result, 0, Math.min(buffer.length, length));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the complete contents of this byte array output stream to the specified output stream
|
||||
* argument.
|
||||
@@ -1146,7 +1151,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
synchronized (this) {
|
||||
// Copy the information we need into local variables so as to hold
|
||||
// the lock for as short a time as possible.
|
||||
cachedFlushBuffers = flushedBuffers.toArray(new ByteString[0]);
|
||||
cachedFlushBuffers = flushedBuffers.toArray(new ByteString[flushedBuffers.size()]);
|
||||
cachedBuffer = buffer;
|
||||
cachedBufferPos = bufferPos;
|
||||
}
|
||||
@@ -1154,7 +1159,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
byteString.writeTo(out);
|
||||
}
|
||||
|
||||
out.write(Arrays.copyOf(cachedBuffer, cachedBufferPos));
|
||||
out.write(copyArray(cachedBuffer, cachedBufferPos));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1205,7 +1210,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
private void flushLastBuffer() {
|
||||
if (bufferPos < buffer.length) {
|
||||
if (bufferPos > 0) {
|
||||
byte[] bufferCopy = Arrays.copyOf(buffer, bufferPos);
|
||||
byte[] bufferCopy = copyArray(buffer, bufferPos);
|
||||
flushedBuffers.add(new LiteralByteString(bufferCopy));
|
||||
}
|
||||
// We reuse this buffer for further writes.
|
||||
@@ -1606,6 +1611,7 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
// Keep this class private to avoid deadlocks in classloading across threads as ByteString's
|
||||
// static initializer loads LiteralByteString and another thread loads BoundedByteString.
|
||||
private static final class BoundedByteString extends LiteralByteString {
|
||||
|
||||
private final int bytesOffset;
|
||||
private final int bytesLength;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
package com.google.protobuf;
|
||||
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
@@ -44,6 +45,6 @@ import java.lang.annotation.Target;
|
||||
* annotated with {@code @CheckReturnValue} to exempt specific methods from the default.
|
||||
*/
|
||||
@Documented
|
||||
@Target(METHOD) // TODO(kak): consider adding CONSTRUCTOR later if necessary
|
||||
@Target({METHOD, TYPE})
|
||||
@Retention(CLASS)
|
||||
@interface CanIgnoreReturnValue {}
|
||||
|
||||
@@ -41,13 +41,13 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Indicates that the return value of the annotated method must be used. An error is triggered when
|
||||
* one of these methods is called but the result is not used.
|
||||
* Indicates that the return value of the annotated method must be checked. An error is triggered
|
||||
* when one of these methods is called but the result is not used.
|
||||
*
|
||||
* <p>{@code @CheckReturnValue} may be applied to a class or package to indicate that all methods in
|
||||
* that class (including indirectly; that is, methods of inner classes within the annotated class)
|
||||
* or package must have their return values used. For convenience, we provide an annotation, {@link
|
||||
* CanIgnoreReturnValue}, to exempt specific methods or classes from this behavior.
|
||||
* that class or package must have their return values checked. For convenience, we provide an
|
||||
* annotation, {@link CanIgnoreReturnValue}, to exempt specific methods or classes from this
|
||||
* behavior.
|
||||
*/
|
||||
@Documented
|
||||
@Target({METHOD, CONSTRUCTOR, TYPE, PACKAGE})
|
||||
|
||||
@@ -78,7 +78,6 @@ import java.util.logging.Logger;
|
||||
*
|
||||
* @author kenton@google.com Kenton Varda
|
||||
*/
|
||||
@CheckReturnValue
|
||||
public final class Descriptors {
|
||||
private static final Logger logger = Logger.getLogger(Descriptors.class.getName());
|
||||
private static final int[] EMPTY_INT_ARRAY = new int[0];
|
||||
@@ -462,20 +461,21 @@ public final class Descriptors {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to be called by generated code only. It updates the
|
||||
* This method is to be called by generated code only. It is used to update the
|
||||
* FileDescriptorProto associated with the descriptor by parsing it again with the given
|
||||
* ExtensionRegistry. This is needed to recognize custom options.
|
||||
*/
|
||||
public static void internalUpdateFileDescriptor(
|
||||
FileDescriptor descriptor, ExtensionRegistry registry) {
|
||||
final FileDescriptor descriptor, final ExtensionRegistry registry) {
|
||||
ByteString bytes = descriptor.proto.toByteString();
|
||||
FileDescriptorProto proto;
|
||||
try {
|
||||
FileDescriptorProto proto = FileDescriptorProto.parseFrom(bytes, registry);
|
||||
descriptor.setProto(proto);
|
||||
proto = FileDescriptorProto.parseFrom(bytes, registry);
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
throw new IllegalArgumentException(
|
||||
"Failed to parse protocol buffer descriptor for generated code.", e);
|
||||
}
|
||||
descriptor.setProto(proto);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1788,27 +1788,6 @@ public final class Descriptors {
|
||||
return Collections.unmodifiableList(Arrays.asList(values));
|
||||
}
|
||||
|
||||
/** Determines if the given field number is reserved. */
|
||||
public boolean isReservedNumber(final int number) {
|
||||
for (final EnumDescriptorProto.EnumReservedRange range : proto.getReservedRangeList()) {
|
||||
if (range.getStart() <= number && number <= range.getEnd()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Determines if the given field name is reserved. */
|
||||
public boolean isReservedName(final String name) {
|
||||
checkNotNull(name);
|
||||
for (final String reservedName : proto.getReservedNameList()) {
|
||||
if (reservedName.equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an enum value by name.
|
||||
*
|
||||
|
||||
@@ -123,15 +123,16 @@ public class ExtensionRegistryLite {
|
||||
* ExtensionRegistry} (if the full (non-Lite) proto libraries are available).
|
||||
*/
|
||||
public static ExtensionRegistryLite getEmptyRegistry() {
|
||||
if (!doFullRuntimeInheritanceCheck) {
|
||||
return EMPTY_REGISTRY_LITE;
|
||||
}
|
||||
ExtensionRegistryLite result = emptyRegistry;
|
||||
if (result == null) {
|
||||
synchronized (ExtensionRegistryLite.class) {
|
||||
result = emptyRegistry;
|
||||
if (result == null) {
|
||||
result = emptyRegistry = ExtensionRegistryFactory.createEmpty();
|
||||
result =
|
||||
emptyRegistry =
|
||||
doFullRuntimeInheritanceCheck
|
||||
? ExtensionRegistryFactory.createEmpty()
|
||||
: EMPTY_REGISTRY_LITE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -728,10 +728,6 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
if (descriptor.isRepeated()) {
|
||||
final List<?> valueList = (List<?>) value;
|
||||
if (descriptor.isPacked()) {
|
||||
if (valueList.isEmpty()) {
|
||||
// The tag should not be written for empty packed fields.
|
||||
return;
|
||||
}
|
||||
output.writeTag(number, WireFormat.WIRETYPE_LENGTH_DELIMITED);
|
||||
// Compute the total data size so the length can be written.
|
||||
int dataSize = 0;
|
||||
@@ -897,13 +893,9 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
WireFormat.FieldType type = descriptor.getLiteType();
|
||||
int number = descriptor.getNumber();
|
||||
if (descriptor.isRepeated()) {
|
||||
List<?> valueList = (List<?>) value;
|
||||
if (descriptor.isPacked()) {
|
||||
if (valueList.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
int dataSize = 0;
|
||||
for (final Object element : valueList) {
|
||||
for (final Object element : (List<?>) value) {
|
||||
dataSize += computeElementSizeNoTag(type, element);
|
||||
}
|
||||
return dataSize
|
||||
@@ -911,7 +903,7 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
+ CodedOutputStream.computeUInt32SizeNoTag(dataSize);
|
||||
} else {
|
||||
int size = 0;
|
||||
for (final Object element : valueList) {
|
||||
for (final Object element : (List<?>) value) {
|
||||
size += computeElementSize(type, number, element);
|
||||
}
|
||||
return size;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -188,7 +188,7 @@ public abstract class GeneratedMessageLite<
|
||||
// any unnecessary intermediary allocations while reducing the generated code size.
|
||||
|
||||
/** Lazily initializes unknown fields. */
|
||||
private void ensureUnknownFieldsInitialized() {
|
||||
private final void ensureUnknownFieldsInitialized() {
|
||||
if (unknownFields == UnknownFieldSetLite.getDefaultInstance()) {
|
||||
unknownFields = UnknownFieldSetLite.newInstance();
|
||||
}
|
||||
@@ -295,16 +295,11 @@ public abstract class GeneratedMessageLite<
|
||||
*
|
||||
* <p>For use by generated code only.
|
||||
*/
|
||||
protected abstract Object dynamicMethod(
|
||||
MethodToInvoke method,
|
||||
Object arg0,
|
||||
Object arg1);
|
||||
protected abstract Object dynamicMethod(MethodToInvoke method, Object arg0, Object arg1);
|
||||
|
||||
/** Same as {@link #dynamicMethod(MethodToInvoke, Object, Object)} with {@code null} padding. */
|
||||
@CanIgnoreReturnValue
|
||||
protected Object dynamicMethod(
|
||||
MethodToInvoke method,
|
||||
Object arg0) {
|
||||
protected Object dynamicMethod(MethodToInvoke method, Object arg0) {
|
||||
return dynamicMethod(method, arg0, null);
|
||||
}
|
||||
|
||||
@@ -1355,11 +1350,11 @@ public abstract class GeneratedMessageLite<
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Object fromFieldSetType(Object value) {
|
||||
Object fromFieldSetType(final Object value) {
|
||||
if (descriptor.isRepeated()) {
|
||||
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
|
||||
List<Object> result = new ArrayList<>();
|
||||
for (Object element : (List) value) {
|
||||
final List result = new ArrayList<>();
|
||||
for (final Object element : (List) value) {
|
||||
result.add(singularFromFieldSetType(element));
|
||||
}
|
||||
return result;
|
||||
@@ -1371,7 +1366,7 @@ public abstract class GeneratedMessageLite<
|
||||
}
|
||||
}
|
||||
|
||||
Object singularFromFieldSetType(Object value) {
|
||||
Object singularFromFieldSetType(final Object value) {
|
||||
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
|
||||
return descriptor.enumTypeMap.findValueByNumber((Integer) value);
|
||||
} else {
|
||||
@@ -1379,11 +1374,12 @@ public abstract class GeneratedMessageLite<
|
||||
}
|
||||
}
|
||||
|
||||
Object toFieldSetType(Object value) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Object toFieldSetType(final Object value) {
|
||||
if (descriptor.isRepeated()) {
|
||||
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
|
||||
List<Object> result = new ArrayList<>();
|
||||
for (Object element : (List) value) {
|
||||
final List result = new ArrayList<>();
|
||||
for (final Object element : (List) value) {
|
||||
result.add(singularToFieldSetType(element));
|
||||
}
|
||||
return result;
|
||||
@@ -1395,7 +1391,7 @@ public abstract class GeneratedMessageLite<
|
||||
}
|
||||
}
|
||||
|
||||
Object singularToFieldSetType(Object value) {
|
||||
Object singularToFieldSetType(final Object value) {
|
||||
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
|
||||
return ((Internal.EnumLite) value).getNumber();
|
||||
} else {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -600,7 +600,6 @@ public final class Internal {
|
||||
void addInt(int element);
|
||||
|
||||
/** Like {@link #set(int, Object)} but more efficient in that it doesn't box the element. */
|
||||
@CanIgnoreReturnValue
|
||||
int setInt(int index, int element);
|
||||
|
||||
/** Returns a mutable clone of this list with the specified capacity. */
|
||||
@@ -621,7 +620,6 @@ public final class Internal {
|
||||
void addBoolean(boolean element);
|
||||
|
||||
/** Like {@link #set(int, Object)} but more efficient in that it doesn't box the element. */
|
||||
@CanIgnoreReturnValue
|
||||
boolean setBoolean(int index, boolean element);
|
||||
|
||||
/** Returns a mutable clone of this list with the specified capacity. */
|
||||
@@ -642,7 +640,6 @@ public final class Internal {
|
||||
void addLong(long element);
|
||||
|
||||
/** Like {@link #set(int, Object)} but more efficient in that it doesn't box the element. */
|
||||
@CanIgnoreReturnValue
|
||||
long setLong(int index, long element);
|
||||
|
||||
/** Returns a mutable clone of this list with the specified capacity. */
|
||||
@@ -663,7 +660,6 @@ public final class Internal {
|
||||
void addDouble(double element);
|
||||
|
||||
/** Like {@link #set(int, Object)} but more efficient in that it doesn't box the element. */
|
||||
@CanIgnoreReturnValue
|
||||
double setDouble(int index, double element);
|
||||
|
||||
/** Returns a mutable clone of this list with the specified capacity. */
|
||||
@@ -684,7 +680,6 @@ public final class Internal {
|
||||
void addFloat(float element);
|
||||
|
||||
/** Like {@link #set(int, Object)} but more efficient in that it doesn't box the element. */
|
||||
@CanIgnoreReturnValue
|
||||
float setFloat(int index, float element);
|
||||
|
||||
/** Returns a mutable clone of this list with the specified capacity. */
|
||||
|
||||
@@ -39,12 +39,11 @@ import java.util.Map;
|
||||
*
|
||||
* <p>See also {@link MessageLite}, which defines most of the methods that typical users care about.
|
||||
* {@link Message} adds methods that are not available in the "lite" runtime. The biggest added
|
||||
* features are introspection and reflection; that is, getting descriptors for the message type and
|
||||
* accessing the field values dynamically.
|
||||
* features are introspection and reflection; that is, getting descriptors for the message type
|
||||
* and accessing the field values dynamically.
|
||||
*
|
||||
* @author kenton@google.com Kenton Varda
|
||||
*/
|
||||
@CheckReturnValue
|
||||
public interface Message extends MessageLite, MessageOrBuilder {
|
||||
|
||||
// (From MessageLite, re-declared here only for return type covariance.)
|
||||
@@ -103,7 +102,6 @@ public interface Message extends MessageLite, MessageOrBuilder {
|
||||
// (From MessageLite.Builder, re-declared here only for return type
|
||||
// covariance.)
|
||||
@Override
|
||||
@CanIgnoreReturnValue
|
||||
Builder clear();
|
||||
|
||||
/**
|
||||
@@ -123,7 +121,6 @@ public interface Message extends MessageLite, MessageOrBuilder {
|
||||
*
|
||||
* <p>This is equivalent to the {@code Message::MergeFrom} method in C++.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(Message other);
|
||||
|
||||
// (From MessageLite.Builder, re-declared here only for return type
|
||||
@@ -138,11 +135,9 @@ public interface Message extends MessageLite, MessageOrBuilder {
|
||||
Builder clone();
|
||||
|
||||
@Override
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(CodedInputStream input) throws IOException;
|
||||
|
||||
@Override
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
|
||||
throws IOException;
|
||||
|
||||
@@ -195,21 +190,18 @@ public interface Message extends MessageLite, MessageOrBuilder {
|
||||
* Sets a field to the given value. The value must be of the correct type for this field, that
|
||||
* is, the same type that {@link Message#getField(Descriptors.FieldDescriptor)} returns.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder setField(Descriptors.FieldDescriptor field, Object value);
|
||||
|
||||
/**
|
||||
* Clears the field. This is exactly equivalent to calling the generated "clear" accessor method
|
||||
* corresponding to the field.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder clearField(Descriptors.FieldDescriptor field);
|
||||
|
||||
/**
|
||||
* Clears the oneof. This is exactly equivalent to calling the generated "clear" accessor method
|
||||
* corresponding to the oneof.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder clearOneof(Descriptors.OneofDescriptor oneof);
|
||||
|
||||
/**
|
||||
@@ -220,7 +212,6 @@ public interface Message extends MessageLite, MessageOrBuilder {
|
||||
* @throws IllegalArgumentException if the field is not a repeated field, or {@code
|
||||
* field.getContainingType() != getDescriptorForType()}.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value);
|
||||
|
||||
/**
|
||||
@@ -229,15 +220,12 @@ public interface Message extends MessageLite, MessageOrBuilder {
|
||||
* @throws IllegalArgumentException if the field is not a repeated field, or {@code
|
||||
* field.getContainingType() != getDescriptorForType()}
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value);
|
||||
|
||||
/** Set the {@link UnknownFieldSet} for this message. */
|
||||
@CanIgnoreReturnValue
|
||||
Builder setUnknownFields(UnknownFieldSet unknownFields);
|
||||
|
||||
/** Merge some unknown fields into the {@link UnknownFieldSet} for this message. */
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeUnknownFields(UnknownFieldSet unknownFields);
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
@@ -246,38 +234,30 @@ public interface Message extends MessageLite, MessageOrBuilder {
|
||||
// (From MessageLite.Builder, re-declared here only for return type
|
||||
// covariance.)
|
||||
@Override
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(ByteString data) throws InvalidProtocolBufferException;
|
||||
|
||||
@Override
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
|
||||
throws InvalidProtocolBufferException;
|
||||
|
||||
@Override
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(byte[] data) throws InvalidProtocolBufferException;
|
||||
|
||||
@Override
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException;
|
||||
|
||||
@Override
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
|
||||
throws InvalidProtocolBufferException;
|
||||
|
||||
@Override
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)
|
||||
throws InvalidProtocolBufferException;
|
||||
|
||||
@Override
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(InputStream input) throws IOException;
|
||||
|
||||
@Override
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
|
||||
throws IOException;
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ import java.io.OutputStream;
|
||||
*
|
||||
* @author kenton@google.com Kenton Varda
|
||||
*/
|
||||
@CheckReturnValue
|
||||
public interface MessageLite extends MessageLiteOrBuilder {
|
||||
|
||||
/**
|
||||
@@ -139,7 +138,6 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
/** Abstract interface implemented by Protocol Message builders. */
|
||||
interface Builder extends MessageLiteOrBuilder, Cloneable {
|
||||
/** Resets all fields to their default values. */
|
||||
@CanIgnoreReturnValue
|
||||
Builder clear();
|
||||
|
||||
/**
|
||||
@@ -183,12 +181,11 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* <p>Note: The caller should call {@link CodedInputStream#checkLastTagWas(int)} after calling
|
||||
* this to verify that the last tag seen was the appropriate end-group tag, or zero for EOF.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct according
|
||||
* to the protobuf wire format specification. The data is corrupt, incomplete, or was never
|
||||
* a protobuf in the first place.
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @throws IOException an I/O error reading from the stream
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(CodedInputStream input) throws IOException;
|
||||
|
||||
/**
|
||||
@@ -196,12 +193,11 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* that you want to be able to parse must be registered in {@code extensionRegistry}. Extensions
|
||||
* not in the registry will be treated as unknown fields.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct according
|
||||
* to the protobuf wire format specification. The data is corrupt, incomplete, or was never
|
||||
* a protobuf in the first place.
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @throws IOException an I/O error reading from the stream
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
|
||||
throws IOException;
|
||||
|
||||
@@ -213,11 +209,10 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
|
||||
* was never a protobuf in the first place.
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(ByteString data) throws InvalidProtocolBufferException;
|
||||
|
||||
/**
|
||||
@@ -225,11 +220,10 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream,ExtensionRegistryLite)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
|
||||
* was never a protobuf in the first place.
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
|
||||
throws InvalidProtocolBufferException;
|
||||
|
||||
@@ -238,11 +232,10 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
|
||||
* was never a protobuf in the first place.
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(byte[] data) throws InvalidProtocolBufferException;
|
||||
|
||||
/**
|
||||
@@ -250,11 +243,10 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
|
||||
* was never a protobuf in the first place.
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException;
|
||||
|
||||
/**
|
||||
@@ -262,11 +254,10 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream,ExtensionRegistryLite)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
|
||||
* was never a protobuf in the first place.
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
|
||||
throws InvalidProtocolBufferException;
|
||||
|
||||
@@ -275,11 +266,10 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream,ExtensionRegistryLite)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete, or
|
||||
* was never a protobuf in the first place.
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)
|
||||
throws InvalidProtocolBufferException;
|
||||
|
||||
@@ -293,13 +283,12 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
*
|
||||
* <p>Despite usually reading the entire input, this does not close the stream.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct according
|
||||
* to the protobuf wire format specification. The data is corrupt, incomplete, or was never
|
||||
* a protobuf in the first place.
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @throws IOException an I/O error reading from the stream
|
||||
* @return this
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(InputStream input) throws IOException;
|
||||
|
||||
/**
|
||||
@@ -309,7 +298,6 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
|
||||
throws IOException;
|
||||
|
||||
@@ -329,7 +317,6 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
*
|
||||
* <p>This is equivalent to the {@code Message::MergeFrom} method in C++.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
Builder mergeFrom(MessageLite other);
|
||||
|
||||
/**
|
||||
@@ -339,9 +326,9 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
*
|
||||
* @return true if successful, or false if the stream is at EOF when the method starts. Any
|
||||
* other error (including reaching EOF during parsing) causes an exception to be thrown.
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct according
|
||||
* to the protobuf wire format specification. The data is corrupt, incomplete, or was never
|
||||
* a protobuf in the first place.
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @throws IOException an I/O error reading from the stream
|
||||
*/
|
||||
boolean mergeDelimitedFrom(InputStream input) throws IOException;
|
||||
@@ -351,9 +338,9 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
*
|
||||
* @return true if successful, or false if the stream is at EOF when the method starts. Any
|
||||
* other error (including reaching EOF during parsing) causes an exception to be thrown.
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct according
|
||||
* to the protobuf wire format specification. The data is corrupt, incomplete, or was never
|
||||
* a protobuf in the first place.
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @throws IOException an I/O error reading from the stream
|
||||
*/
|
||||
boolean mergeDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
|
||||
|
||||
@@ -36,7 +36,6 @@ package com.google.protobuf;
|
||||
*
|
||||
* @author jonp@google.com (Jon Perlow)
|
||||
*/
|
||||
@CheckReturnValue
|
||||
public interface MessageLiteOrBuilder {
|
||||
/**
|
||||
* Get an instance of the type with no fields set. Because no fields are set, all getters for
|
||||
|
||||
@@ -39,7 +39,6 @@ import java.util.Map;
|
||||
*
|
||||
* @author jonp@google.com (Jon Perlow)
|
||||
*/
|
||||
@CheckReturnValue
|
||||
public interface MessageOrBuilder extends MessageLiteOrBuilder {
|
||||
|
||||
// (From MessageLite, re-declared here only for return type covariance.)
|
||||
|
||||
@@ -277,7 +277,6 @@ public class RepeatedFieldBuilder<
|
||||
* @param message the message to set
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public RepeatedFieldBuilder<MType, BType, IType> setMessage(int index, MType message) {
|
||||
checkNotNull(message);
|
||||
ensureMutableMessageList();
|
||||
@@ -299,7 +298,6 @@ public class RepeatedFieldBuilder<
|
||||
* @param message the message to add
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public RepeatedFieldBuilder<MType, BType, IType> addMessage(MType message) {
|
||||
checkNotNull(message);
|
||||
ensureMutableMessageList();
|
||||
@@ -321,7 +319,6 @@ public class RepeatedFieldBuilder<
|
||||
* @param message the message to add
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public RepeatedFieldBuilder<MType, BType, IType> addMessage(int index, MType message) {
|
||||
checkNotNull(message);
|
||||
ensureMutableMessageList();
|
||||
@@ -341,7 +338,6 @@ public class RepeatedFieldBuilder<
|
||||
* @param values the messages to add
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public RepeatedFieldBuilder<MType, BType, IType> addAllMessages(
|
||||
Iterable<? extends MType> values) {
|
||||
for (final MType value : values) {
|
||||
|
||||
@@ -277,7 +277,6 @@ public class RepeatedFieldBuilderV3<
|
||||
* @param message the message to set
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public RepeatedFieldBuilderV3<MType, BType, IType> setMessage(int index, MType message) {
|
||||
checkNotNull(message);
|
||||
ensureMutableMessageList();
|
||||
@@ -299,7 +298,6 @@ public class RepeatedFieldBuilderV3<
|
||||
* @param message the message to add
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public RepeatedFieldBuilderV3<MType, BType, IType> addMessage(MType message) {
|
||||
checkNotNull(message);
|
||||
ensureMutableMessageList();
|
||||
@@ -321,7 +319,6 @@ public class RepeatedFieldBuilderV3<
|
||||
* @param message the message to add
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public RepeatedFieldBuilderV3<MType, BType, IType> addMessage(int index, MType message) {
|
||||
checkNotNull(message);
|
||||
ensureMutableMessageList();
|
||||
@@ -341,7 +338,6 @@ public class RepeatedFieldBuilderV3<
|
||||
* @param values the messages to add
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public RepeatedFieldBuilderV3<MType, BType, IType> addAllMessages(
|
||||
Iterable<? extends MType> values) {
|
||||
for (final MType value : values) {
|
||||
|
||||
@@ -156,7 +156,6 @@ public class SingleFieldBuilder<
|
||||
* @param message the message to set
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public SingleFieldBuilder<MType, BType, IType> setMessage(MType message) {
|
||||
this.message = checkNotNull(message);
|
||||
if (builder != null) {
|
||||
@@ -173,7 +172,6 @@ public class SingleFieldBuilder<
|
||||
* @param value the value to merge from
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public SingleFieldBuilder<MType, BType, IType> mergeFrom(MType value) {
|
||||
if (builder == null && message == message.getDefaultInstanceForType()) {
|
||||
message = value;
|
||||
@@ -190,7 +188,6 @@ public class SingleFieldBuilder<
|
||||
* @return the builder
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@CanIgnoreReturnValue
|
||||
public SingleFieldBuilder<MType, BType, IType> clear() {
|
||||
message =
|
||||
(MType)
|
||||
|
||||
@@ -156,7 +156,6 @@ public class SingleFieldBuilderV3<
|
||||
* @param message the message to set
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public SingleFieldBuilderV3<MType, BType, IType> setMessage(MType message) {
|
||||
this.message = checkNotNull(message);
|
||||
if (builder != null) {
|
||||
@@ -173,7 +172,6 @@ public class SingleFieldBuilderV3<
|
||||
* @param value the value to merge from
|
||||
* @return the builder
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public SingleFieldBuilderV3<MType, BType, IType> mergeFrom(MType value) {
|
||||
if (builder == null && message == message.getDefaultInstanceForType()) {
|
||||
message = value;
|
||||
@@ -190,7 +188,6 @@ public class SingleFieldBuilderV3<
|
||||
* @return the builder
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@CanIgnoreReturnValue
|
||||
public SingleFieldBuilderV3<MType, BType, IType> clear() {
|
||||
message =
|
||||
(MType)
|
||||
@@ -202,6 +199,9 @@ public class SingleFieldBuilderV3<
|
||||
builder = null;
|
||||
}
|
||||
onChanged();
|
||||
// After clearing, parent is dirty, but this field builder is now clean and any changes should
|
||||
// trickle up.
|
||||
isClean = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public final class TextFormat {
|
||||
|
||||
private static final String DEBUG_STRING_SILENT_MARKER = "\t ";
|
||||
|
||||
|
||||
/**
|
||||
* Outputs a textual representation of the Protocol Message supplied into the parameter output.
|
||||
* (This representation is the new version of the classic "ProtocolPrinter" output from the
|
||||
@@ -115,8 +116,8 @@ public final class TextFormat {
|
||||
|
||||
/**
|
||||
* Generates a human readable form of this message, useful for debugging and other purposes, with
|
||||
* no newline characters. This is just a trivial wrapper around {@link
|
||||
* TextFormat.Printer#shortDebugString(MessageOrBuilder)}.
|
||||
* no newline characters. This is just a trivial wrapper around
|
||||
* {@link TextFormat.Printer#shortDebugString(MessageOrBuilder)}.
|
||||
*/
|
||||
public static String shortDebugString(final MessageOrBuilder message) {
|
||||
return printer().shortDebugString(message);
|
||||
@@ -458,7 +459,9 @@ public final class TextFormat {
|
||||
}
|
||||
}
|
||||
|
||||
/** An adapter class that can take a {@link MapEntry} and returns its key and entry. */
|
||||
/**
|
||||
* An adapter class that can take a {@link MapEntry} and returns its key and entry.
|
||||
*/
|
||||
private static class MapEntryAdapter implements Comparable<MapEntryAdapter> {
|
||||
private Object entry;
|
||||
|
||||
@@ -738,9 +741,9 @@ public final class TextFormat {
|
||||
// Groups must be serialized with their original capitalization.
|
||||
generator.print(field.getMessageType().getName());
|
||||
} else {
|
||||
generator.print(field.getName());
|
||||
generator.print(field.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
|
||||
generator.print(" {");
|
||||
@@ -950,7 +953,6 @@ public final class TextFormat {
|
||||
* the next token is parsed.
|
||||
*/
|
||||
private boolean containsSilentMarkerAfterCurrentToken = false;
|
||||
|
||||
private boolean containsSilentMarkerAfterPrevToken = false;
|
||||
|
||||
/** Construct a tokenizer that parses tokens from the given text. */
|
||||
@@ -1376,6 +1378,7 @@ public final class TextFormat {
|
||||
private ParseException floatParseException(final NumberFormatException e) {
|
||||
return parseException("Couldn't parse number: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Thrown when parsing an invalid text format message. */
|
||||
@@ -1548,7 +1551,7 @@ public final class TextFormat {
|
||||
* the current token is part of the field value, so the silent marker is indicated by
|
||||
* containsSilentMarkerAfterPrevToken.
|
||||
*/
|
||||
private void detectSilentMarker(Tokenizer tokenizer, String fieldName) {
|
||||
private void detectSilentMarker(Tokenizer tokenizer) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1625,8 +1628,8 @@ public final class TextFormat {
|
||||
* unknown field is encountered. If this is set, the parser will only log a warning. Allow
|
||||
* unknown fields will also allow unknown extensions.
|
||||
*
|
||||
* <p>Use of this parameter is discouraged which may hide some errors (e.g. spelling error on
|
||||
* field name).
|
||||
* <p>Use of this parameter is discouraged which may hide some errors (e.g.
|
||||
* spelling error on field name).
|
||||
*/
|
||||
public Builder setAllowUnknownFields(boolean allowUnknownFields) {
|
||||
this.allowUnknownFields = allowUnknownFields;
|
||||
@@ -1634,9 +1637,10 @@ public final class TextFormat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this parser will allow unknown extensions. By default, an exception is thrown
|
||||
* if unknown extension is encountered. If this is set true, the parser will only log a
|
||||
* warning. Allow unknown extensions does not mean allow normal unknown fields.
|
||||
* Set whether this parser will allow unknown extensions. By default, an
|
||||
* exception is thrown if unknown extension is encountered. If this is set true,
|
||||
* the parser will only log a warning. Allow unknown extensions does not mean
|
||||
* allow normal unknown fields.
|
||||
*/
|
||||
public Builder setAllowUnknownExtensions(boolean allowUnknownExtensions) {
|
||||
this.allowUnknownExtensions = allowUnknownExtensions;
|
||||
@@ -1721,8 +1725,7 @@ public final class TextFormat {
|
||||
|
||||
static final class UnknownField {
|
||||
static enum Type {
|
||||
FIELD,
|
||||
EXTENSION;
|
||||
FIELD, EXTENSION;
|
||||
}
|
||||
|
||||
final String message;
|
||||
@@ -1783,6 +1786,7 @@ public final class TextFormat {
|
||||
throws ParseException {
|
||||
final Tokenizer tokenizer = new Tokenizer(input);
|
||||
MessageReflection.BuilderAdapter target = new MessageReflection.BuilderAdapter(builder);
|
||||
|
||||
List<UnknownField> unknownFields = new ArrayList<UnknownField>();
|
||||
|
||||
while (!tokenizer.atEnd()) {
|
||||
@@ -1799,7 +1803,12 @@ public final class TextFormat {
|
||||
final MessageReflection.MergeTarget target,
|
||||
List<UnknownField> unknownFields)
|
||||
throws ParseException {
|
||||
mergeField(tokenizer, extensionRegistry, target, parseInfoTreeBuilder, unknownFields);
|
||||
mergeField(
|
||||
tokenizer,
|
||||
extensionRegistry,
|
||||
target,
|
||||
parseInfoTreeBuilder,
|
||||
unknownFields);
|
||||
}
|
||||
|
||||
/** Parse a single field from {@code tokenizer} and merge it into {@code target}. */
|
||||
@@ -1811,40 +1820,38 @@ public final class TextFormat {
|
||||
List<UnknownField> unknownFields)
|
||||
throws ParseException {
|
||||
FieldDescriptor field = null;
|
||||
String name;
|
||||
int startLine = tokenizer.getLine();
|
||||
int startColumn = tokenizer.getColumn();
|
||||
final Descriptor type = target.getDescriptorForType();
|
||||
ExtensionRegistry.ExtensionInfo extension = null;
|
||||
|
||||
if ("google.protobuf.Any".equals(type.getFullName()) && tokenizer.tryConsume("[")) {
|
||||
mergeAnyFieldValue(
|
||||
tokenizer, extensionRegistry, target, parseTreeBuilder, unknownFields, type);
|
||||
mergeAnyFieldValue(tokenizer, extensionRegistry, target, parseTreeBuilder, unknownFields,
|
||||
type);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tokenizer.tryConsume("[")) {
|
||||
// An extension.
|
||||
StringBuilder nameBuilder = new StringBuilder(tokenizer.consumeIdentifier());
|
||||
final StringBuilder name = new StringBuilder(tokenizer.consumeIdentifier());
|
||||
while (tokenizer.tryConsume(".")) {
|
||||
nameBuilder.append('.');
|
||||
nameBuilder.append(tokenizer.consumeIdentifier());
|
||||
name.append('.');
|
||||
name.append(tokenizer.consumeIdentifier());
|
||||
}
|
||||
name = nameBuilder.toString();
|
||||
|
||||
extension = target.findExtensionByName(extensionRegistry, name);
|
||||
extension = target.findExtensionByName(extensionRegistry, name.toString());
|
||||
|
||||
if (extension == null) {
|
||||
String message =
|
||||
(tokenizer.getPreviousLine() + 1)
|
||||
+ ":"
|
||||
+ (tokenizer.getPreviousColumn() + 1)
|
||||
+ ":\t"
|
||||
+ type.getFullName()
|
||||
+ ".["
|
||||
+ name
|
||||
+ "]";
|
||||
unknownFields.add(new UnknownField(message, UnknownField.Type.EXTENSION));
|
||||
String message =
|
||||
(tokenizer.getPreviousLine() + 1)
|
||||
+ ":"
|
||||
+ (tokenizer.getPreviousColumn() + 1)
|
||||
+ ":\t"
|
||||
+ type.getFullName()
|
||||
+ ".["
|
||||
+ name
|
||||
+ "]";
|
||||
unknownFields.add(new UnknownField(message, UnknownField.Type.EXTENSION));
|
||||
} else {
|
||||
if (extension.descriptor.getContainingType() != type) {
|
||||
throw tokenizer.parseExceptionPreviousToken(
|
||||
@@ -1859,7 +1866,7 @@ public final class TextFormat {
|
||||
|
||||
tokenizer.consume("]");
|
||||
} else {
|
||||
name = tokenizer.consumeIdentifier();
|
||||
final String name = tokenizer.consumeIdentifier();
|
||||
field = type.findFieldByName(name);
|
||||
|
||||
// Group names are expected to be capitalized as they appear in the
|
||||
@@ -1883,14 +1890,13 @@ public final class TextFormat {
|
||||
}
|
||||
|
||||
if (field == null) {
|
||||
String message =
|
||||
(tokenizer.getPreviousLine() + 1)
|
||||
+ ":"
|
||||
+ (tokenizer.getPreviousColumn() + 1)
|
||||
+ ":\t"
|
||||
+ type.getFullName()
|
||||
+ "."
|
||||
+ name;
|
||||
String message = (tokenizer.getPreviousLine() + 1)
|
||||
+ ":"
|
||||
+ (tokenizer.getPreviousColumn() + 1)
|
||||
+ ":\t"
|
||||
+ type.getFullName()
|
||||
+ "."
|
||||
+ name;
|
||||
unknownFields.add(new UnknownField(message, UnknownField.Type.FIELD));
|
||||
}
|
||||
}
|
||||
@@ -1903,7 +1909,7 @@ public final class TextFormat {
|
||||
// start with "{" or "<" which indicates the beginning of a message body.
|
||||
// If there is no ":" or there is a "{" or "<" after ":", this field has
|
||||
// to be a message or the input is ill-formed.
|
||||
detectSilentMarker(tokenizer, name);
|
||||
detectSilentMarker(tokenizer);
|
||||
if (tokenizer.tryConsume(":") && !tokenizer.lookingAt("{") && !tokenizer.lookingAt("<")) {
|
||||
skipFieldValue(tokenizer);
|
||||
} else {
|
||||
@@ -1914,7 +1920,7 @@ public final class TextFormat {
|
||||
|
||||
// Handle potential ':'.
|
||||
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
|
||||
detectSilentMarker(tokenizer, field.getFullName());
|
||||
detectSilentMarker(tokenizer);
|
||||
tokenizer.tryConsume(":"); // optional
|
||||
if (parseTreeBuilder != null) {
|
||||
TextFormatParseInfoTree.Builder childParseTreeBuilder =
|
||||
@@ -1938,7 +1944,7 @@ public final class TextFormat {
|
||||
unknownFields);
|
||||
}
|
||||
} else {
|
||||
detectSilentMarker(tokenizer, field.getFullName());
|
||||
detectSilentMarker(tokenizer);
|
||||
tokenizer.consume(":"); // required
|
||||
consumeFieldValues(
|
||||
tokenizer,
|
||||
@@ -1961,29 +1967,6 @@ public final class TextFormat {
|
||||
}
|
||||
}
|
||||
|
||||
private String consumeFullTypeName(Tokenizer tokenizer) throws ParseException {
|
||||
// If there is not a leading `[`, this is just a type name.
|
||||
if (!tokenizer.tryConsume("[")) {
|
||||
return tokenizer.consumeIdentifier();
|
||||
}
|
||||
|
||||
// Otherwise, this is an extension or google.protobuf.Any type URL: we consume proto path
|
||||
// elements until we've addressed the type.
|
||||
String name = tokenizer.consumeIdentifier();
|
||||
while (tokenizer.tryConsume(".")) {
|
||||
name += "." + tokenizer.consumeIdentifier();
|
||||
}
|
||||
if (tokenizer.tryConsume("/")) {
|
||||
name += "/" + tokenizer.consumeIdentifier();
|
||||
while (tokenizer.tryConsume(".")) {
|
||||
name += "." + tokenizer.consumeIdentifier();
|
||||
}
|
||||
}
|
||||
tokenizer.consume("]");
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a one or more field values from {@code tokenizer} and merge it into {@code builder}.
|
||||
*/
|
||||
@@ -2075,13 +2058,8 @@ public final class TextFormat {
|
||||
// (java_proto_library for any_java_proto depends on the protobuf_impl).
|
||||
Message anyBuilder = DynamicMessage.getDefaultInstance(field.getMessageType());
|
||||
MessageReflection.MergeTarget anyField = target.newMergeTargetForField(field, anyBuilder);
|
||||
mergeAnyFieldValue(
|
||||
tokenizer,
|
||||
extensionRegistry,
|
||||
anyField,
|
||||
parseTreeBuilder,
|
||||
unknownFields,
|
||||
field.getMessageType());
|
||||
mergeAnyFieldValue(tokenizer, extensionRegistry, anyField, parseTreeBuilder,
|
||||
unknownFields, field.getMessageType());
|
||||
value = anyField.finish();
|
||||
tokenizer.consume(endToken);
|
||||
} else {
|
||||
@@ -2228,7 +2206,7 @@ public final class TextFormat {
|
||||
throw tokenizer.parseExceptionPreviousToken("Expected a valid type URL.");
|
||||
}
|
||||
}
|
||||
detectSilentMarker(tokenizer, typeUrlBuilder.toString());
|
||||
detectSilentMarker(tokenizer);
|
||||
tokenizer.tryConsume(":");
|
||||
final String anyEndToken;
|
||||
if (tokenizer.tryConsume("<")) {
|
||||
@@ -2266,7 +2244,15 @@ public final class TextFormat {
|
||||
|
||||
/** Skips the next field including the field's name and value. */
|
||||
private void skipField(Tokenizer tokenizer) throws ParseException {
|
||||
String name = consumeFullTypeName(tokenizer);
|
||||
if (tokenizer.tryConsume("[")) {
|
||||
// Extension name.
|
||||
do {
|
||||
tokenizer.consumeIdentifier();
|
||||
} while (tokenizer.tryConsume("."));
|
||||
tokenizer.consume("]");
|
||||
} else {
|
||||
tokenizer.consumeIdentifier();
|
||||
}
|
||||
|
||||
// Try to guess the type of this field.
|
||||
// If this field is not a message, there should be a ":" between the
|
||||
@@ -2274,7 +2260,7 @@ public final class TextFormat {
|
||||
// start with "{" or "<" which indicates the beginning of a message body.
|
||||
// If there is no ":" or there is a "{" or "<" after ":", this field has
|
||||
// to be a message or the input is ill-formed.
|
||||
detectSilentMarker(tokenizer, name);
|
||||
detectSilentMarker(tokenizer);
|
||||
if (tokenizer.tryConsume(":") && !tokenizer.lookingAt("<") && !tokenizer.lookingAt("{")) {
|
||||
skipFieldValue(tokenizer);
|
||||
} else {
|
||||
@@ -2483,10 +2469,9 @@ public final class TextFormat {
|
||||
}
|
||||
Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(codepoint);
|
||||
if (unicodeBlock != null
|
||||
&& (unicodeBlock.equals(Character.UnicodeBlock.LOW_SURROGATES)
|
||||
|| unicodeBlock.equals(Character.UnicodeBlock.HIGH_SURROGATES)
|
||||
|| unicodeBlock.equals(
|
||||
Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES))) {
|
||||
&& (unicodeBlock.equals(Character.UnicodeBlock.LOW_SURROGATES)
|
||||
|| unicodeBlock.equals(Character.UnicodeBlock.HIGH_SURROGATES)
|
||||
|| unicodeBlock.equals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES))) {
|
||||
throw new InvalidEscapeSequenceException(
|
||||
"Invalid escape sequence: '\\U"
|
||||
+ input.substring(i, i + 8).toStringUtf8()
|
||||
|
||||
@@ -43,7 +43,7 @@ import java.nio.ByteBuffer;
|
||||
* ByteString} can lead to unexpected and undesirable consequences in your application, and will
|
||||
* likely be difficult to debug. Proceed with caution!
|
||||
*
|
||||
* <p>This can have a number of significant side effects that have spooky-action-at-a-distance-like
|
||||
* <p>This can have a number of significant side affects that have spooky-action-at-a-distance-like
|
||||
* behavior. In particular, if the bytes value changes out from under a Protocol Buffer:
|
||||
*
|
||||
* <ul>
|
||||
|
||||
@@ -61,7 +61,6 @@ import protobuf_unittest.UnittestProto.TestExtremeDefaultValues;
|
||||
import protobuf_unittest.UnittestProto.TestJsonName;
|
||||
import protobuf_unittest.UnittestProto.TestMultipleExtensionRanges;
|
||||
import protobuf_unittest.UnittestProto.TestRequired;
|
||||
import protobuf_unittest.UnittestProto.TestReservedEnumFields;
|
||||
import protobuf_unittest.UnittestProto.TestReservedFields;
|
||||
import protobuf_unittest.UnittestProto.TestService;
|
||||
import java.util.Collections;
|
||||
@@ -464,15 +463,15 @@ public class DescriptorsTest {
|
||||
/** Tests that parsing an unknown enum throws an exception */
|
||||
@Test
|
||||
public void testParseUnknownEnum() {
|
||||
FieldDescriptorProto.Builder field =
|
||||
FieldDescriptorProto.newBuilder()
|
||||
.setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL)
|
||||
.setTypeName("UnknownEnum")
|
||||
.setType(FieldDescriptorProto.Type.TYPE_ENUM)
|
||||
.setName("bar")
|
||||
.setNumber(1);
|
||||
DescriptorProto.Builder messageType =
|
||||
DescriptorProto.newBuilder().setName("Foo").addField(field);
|
||||
FieldDescriptorProto.Builder field = FieldDescriptorProto.newBuilder()
|
||||
.setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL)
|
||||
.setTypeName("UnknownEnum")
|
||||
.setType(FieldDescriptorProto.Type.TYPE_ENUM)
|
||||
.setName("bar")
|
||||
.setNumber(1);
|
||||
DescriptorProto.Builder messageType = DescriptorProto.newBuilder()
|
||||
.setName("Foo")
|
||||
.addField(field);
|
||||
FileDescriptorProto fooProto =
|
||||
FileDescriptorProto.newBuilder()
|
||||
.setName("foo.proto")
|
||||
@@ -487,6 +486,7 @@ public class DescriptorsTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the translate/crosslink for an example where a message field's name and type name are the
|
||||
* same.
|
||||
@@ -560,10 +560,8 @@ public class DescriptorsTest {
|
||||
Descriptors.FileDescriptor.buildFrom(barProto, new FileDescriptor[] {fooFile});
|
||||
|
||||
// Items in the FileDescriptor array can be in any order.
|
||||
FileDescriptor unused1 =
|
||||
Descriptors.FileDescriptor.buildFrom(bazProto, new FileDescriptor[] {fooFile, barFile});
|
||||
FileDescriptor unused2 =
|
||||
Descriptors.FileDescriptor.buildFrom(bazProto, new FileDescriptor[] {barFile, fooFile});
|
||||
Descriptors.FileDescriptor.buildFrom(bazProto, new FileDescriptor[] {fooFile, barFile});
|
||||
Descriptors.FileDescriptor.buildFrom(bazProto, new FileDescriptor[] {barFile, fooFile});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -625,8 +623,7 @@ public class DescriptorsTest {
|
||||
.setName("bar")
|
||||
.setNumber(1)))
|
||||
.build();
|
||||
FileDescriptor unused =
|
||||
Descriptors.FileDescriptor.buildFrom(fooProto, new FileDescriptor[0], true);
|
||||
Descriptors.FileDescriptor.buildFrom(fooProto, new FileDescriptor[0], true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -660,8 +657,7 @@ public class DescriptorsTest {
|
||||
Descriptors.FileDescriptor.buildFrom(forwardProto, new FileDescriptor[] {barFile});
|
||||
|
||||
try {
|
||||
FileDescriptor unused =
|
||||
Descriptors.FileDescriptor.buildFrom(fooProto, new FileDescriptor[] {forwardFile});
|
||||
Descriptors.FileDescriptor.buildFrom(fooProto, new FileDescriptor[] {forwardFile});
|
||||
assertWithMessage("DescriptorValidationException expected").fail();
|
||||
} catch (DescriptorValidationException e) {
|
||||
assertThat(e).hasMessageThat().contains("Bar");
|
||||
@@ -699,8 +695,7 @@ public class DescriptorsTest {
|
||||
FileDescriptor barFile = Descriptors.FileDescriptor.buildFrom(barProto, new FileDescriptor[0]);
|
||||
FileDescriptor forwardFile =
|
||||
Descriptors.FileDescriptor.buildFrom(forwardProto, new FileDescriptor[] {barFile});
|
||||
FileDescriptor unused =
|
||||
Descriptors.FileDescriptor.buildFrom(fooProto, new FileDescriptor[] {forwardFile});
|
||||
Descriptors.FileDescriptor.buildFrom(fooProto, new FileDescriptor[] {forwardFile});
|
||||
}
|
||||
|
||||
/** Tests the translate/crosslink for an example with a more complex namespace referencing. */
|
||||
@@ -797,20 +792,6 @@ public class DescriptorsTest {
|
||||
assertThat(d.isReservedName("baz")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReservedEnumFields() {
|
||||
EnumDescriptor d = TestReservedEnumFields.getDescriptor();
|
||||
assertThat(d.isReservedNumber(2)).isTrue();
|
||||
assertThat(d.isReservedNumber(8)).isFalse();
|
||||
assertThat(d.isReservedNumber(9)).isTrue();
|
||||
assertThat(d.isReservedNumber(10)).isTrue();
|
||||
assertThat(d.isReservedNumber(11)).isTrue();
|
||||
assertThat(d.isReservedNumber(12)).isFalse();
|
||||
assertThat(d.isReservedName("foo")).isFalse();
|
||||
assertThat(d.isReservedName("bar")).isTrue();
|
||||
assertThat(d.isReservedName("baz")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
assertThat(
|
||||
@@ -845,8 +826,7 @@ public class DescriptorsTest {
|
||||
.build())
|
||||
.build())
|
||||
.build();
|
||||
FileDescriptor unused =
|
||||
Descriptors.FileDescriptor.buildFrom(fileDescriptorProto, new FileDescriptor[0]);
|
||||
Descriptors.FileDescriptor.buildFrom(fileDescriptorProto, new FileDescriptor[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -44,7 +44,6 @@ import protobuf_unittest.UnittestProto.TestAllTypes;
|
||||
import protobuf_unittest.UnittestProto.TestAllTypes.NestedMessage;
|
||||
import protobuf_unittest.UnittestProto.TestEmptyMessage;
|
||||
import protobuf_unittest.UnittestProto.TestPackedTypes;
|
||||
import java.util.ArrayList;
|
||||
import org.junit.Test;
|
||||
import org.junit.function.ThrowingRunnable;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -231,19 +230,6 @@ public class DynamicMessageTest {
|
||||
assertThat(rawBytes).isEqualTo(TestUtil.getPackedSet().toByteString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDynamicMessagePackedEmptySerialization() throws Exception {
|
||||
Message message =
|
||||
DynamicMessage.newBuilder(TestPackedTypes.getDescriptor())
|
||||
.setField(
|
||||
TestPackedTypes.getDescriptor()
|
||||
.findFieldByNumber(TestPackedTypes.PACKED_INT64_FIELD_NUMBER),
|
||||
new ArrayList<Long>())
|
||||
.build();
|
||||
|
||||
assertThat(message.toByteString()).isEqualTo(ByteString.EMPTY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDynamicMessagePackedParsing() throws Exception {
|
||||
TestPackedTypes.Builder builder = TestPackedTypes.newBuilder();
|
||||
|
||||
@@ -1529,7 +1529,7 @@ public class GeneratedMessageTest {
|
||||
assertThat(builder.getFooInt()).isEqualTo(123);
|
||||
TestOneof2 message = builder.buildPartial();
|
||||
assertThat(message.hasFooInt()).isTrue();
|
||||
assertThat(message.getFooInt()).isEqualTo(123);
|
||||
assertThat(123).isEqualTo(message.getFooInt());
|
||||
|
||||
assertThat(builder.clearFooInt().hasFooInt()).isFalse();
|
||||
TestOneof2 message2 = builder.build();
|
||||
@@ -1943,7 +1943,7 @@ public class GeneratedMessageTest {
|
||||
|
||||
@Test
|
||||
public void
|
||||
extendableBuilder_extensionFieldContainingBuilder_setRepeatedFieldOverwritesElement() {
|
||||
extendableBuilder_extensionFieldContainingBuilder_setRepeatedFieldOverwritesElement() {
|
||||
TestAllExtensions.Builder builder = TestAllExtensions.newBuilder();
|
||||
builder.addRepeatedField(REPEATED_NESTED_MESSAGE_EXTENSION, NestedMessage.getDefaultInstance());
|
||||
// Calling getRepeatedFieldBuilder and ignoring the returned Builder should have no
|
||||
|
||||
@@ -30,13 +30,14 @@
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.Bar;
|
||||
import protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.BarPrime;
|
||||
import protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.Foo;
|
||||
import protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.TestOneofEquals;
|
||||
import protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.TestRecursiveOneof;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Test generate equal and hash methods for the lite runtime.
|
||||
*
|
||||
@@ -119,6 +120,6 @@ public class LiteEqualsAndHashTest extends TestCase {
|
||||
|
||||
public void testRecursiveHashcode() {
|
||||
// This tests that we don't infinite loop.
|
||||
int unused = TestRecursiveOneof.getDefaultInstance().hashCode();
|
||||
TestRecursiveOneof.getDefaultInstance().hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ package com.google.protobuf;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import protobuf_unittest.Engine;
|
||||
import protobuf_unittest.TimingBelt;
|
||||
import protobuf_unittest.Vehicle;
|
||||
import protobuf_unittest.Wheel;
|
||||
import java.util.ArrayList;
|
||||
@@ -48,6 +49,27 @@ import org.junit.runners.JUnit4;
|
||||
@RunWith(JUnit4.class)
|
||||
public class NestedBuildersTest {
|
||||
|
||||
@Test
|
||||
public void test3LayerPropagationWithIntermediateClear() {
|
||||
Vehicle.Builder vehicleBuilder = Vehicle.newBuilder();
|
||||
vehicleBuilder.getEngineBuilder().getTimingBeltBuilder();
|
||||
|
||||
// This step detaches the TimingBelt.Builder (though it leaves a SingleFieldBuilder in place)
|
||||
vehicleBuilder.getEngineBuilder().clear();
|
||||
|
||||
// These steps build the middle and top level messages, it used to leave the vestigial
|
||||
// TimingBelt.Builder in a state where further changes didn't propagate anymore
|
||||
Object unused = vehicleBuilder.getEngineBuilder().build();
|
||||
unused = vehicleBuilder.build();
|
||||
|
||||
TimingBelt expected = TimingBelt.newBuilder().setNumberOfTeeth(124).build();
|
||||
vehicleBuilder.getEngineBuilder().setTimingBelt(expected);
|
||||
// Testing that b/254158939 is fixed. It used to be that the setTimingBelt call above didn't
|
||||
// propagate a change notification and the call below would return a stale version of the timing
|
||||
// belt.
|
||||
assertThat(vehicleBuilder.getEngine().getTimingBelt()).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessagesAndBuilders() {
|
||||
Vehicle.Builder vehicleBuilder = Vehicle.newBuilder();
|
||||
|
||||
@@ -82,7 +82,7 @@ public class SingleFieldBuilderV3Test {
|
||||
assertThat(mockParent.getInvalidationCount()).isEqualTo(0);
|
||||
assertThat(builder.getBuilder().getOptionalInt32()).isEqualTo(1);
|
||||
assertThat(builder.getMessage().getOptionalInt32()).isEqualTo(1);
|
||||
TestAllTypes unused = builder.build();
|
||||
builder.build();
|
||||
builder.getBuilder().setOptionalInt32(2);
|
||||
assertThat(builder.getBuilder().getOptionalInt32()).isEqualTo(2);
|
||||
assertThat(builder.getMessage().getOptionalInt32()).isEqualTo(2);
|
||||
|
||||
@@ -34,7 +34,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static java.lang.Math.min;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -49,6 +48,52 @@ import org.junit.runners.JUnit4;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class SmallSortedMapTest {
|
||||
// java.util.AbstractMap.SimpleEntry is private in JDK 1.5. We re-implement it
|
||||
// here for JDK 1.5 users.
|
||||
private static class SimpleEntry<K, V> implements Map.Entry<K, V> {
|
||||
private final K key;
|
||||
private V value;
|
||||
|
||||
SimpleEntry(K key, V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public K getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V setValue(V value) {
|
||||
V oldValue = this.value;
|
||||
this.value = value;
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
private static boolean eq(Object o1, Object o2) {
|
||||
return o1 == null ? o2 == null : o1.equals(o2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Map.Entry)) {
|
||||
return false;
|
||||
}
|
||||
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
|
||||
return eq(key, e.getKey()) && eq(value, e.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ((key == null) ? 0 : key.hashCode()) ^ ((value == null) ? 0 : value.hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPutAndGetArrayEntriesOnly() {
|
||||
@@ -197,8 +242,8 @@ public class SmallSortedMapTest {
|
||||
}
|
||||
Set<Map.Entry<Integer, Integer>> entrySet = map.entrySet();
|
||||
for (int i = 0; i < 6; i++) {
|
||||
assertThat(entrySet).contains(new AbstractMap.SimpleEntry<Integer, Integer>(i, i + 1));
|
||||
assertThat(entrySet).doesNotContain(new AbstractMap.SimpleEntry<Integer, Integer>(i, i));
|
||||
assertThat(entrySet).contains(new SimpleEntry<Integer, Integer>(i, i + 1));
|
||||
assertThat(entrySet).doesNotContain(new SimpleEntry<Integer, Integer>(i, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +252,7 @@ public class SmallSortedMapTest {
|
||||
SmallSortedMap<Integer, Integer> map = SmallSortedMap.newInstanceForTest(3);
|
||||
Set<Map.Entry<Integer, Integer>> entrySet = map.entrySet();
|
||||
for (int i = 0; i < 6; i++) {
|
||||
Map.Entry<Integer, Integer> entry = new AbstractMap.SimpleEntry<>(i, i + 1);
|
||||
Map.Entry<Integer, Integer> entry = new SimpleEntry<>(i, i + 1);
|
||||
assertThat(entrySet.add(entry)).isTrue();
|
||||
assertThat(entrySet.add(entry)).isFalse();
|
||||
}
|
||||
@@ -227,7 +272,7 @@ public class SmallSortedMapTest {
|
||||
assertThat(map.put(i, i + 1)).isNull();
|
||||
}
|
||||
for (int i = 0; i < 6; i++) {
|
||||
Map.Entry<Integer, Integer> entry = new AbstractMap.SimpleEntry<>(i, i + 1);
|
||||
Map.Entry<Integer, Integer> entry = new SimpleEntry<>(i, i + 1);
|
||||
assertThat(entrySet.remove(entry)).isTrue();
|
||||
assertThat(entrySet.remove(entry)).isFalse();
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class TestBadIdentifiers extends TestCase {
|
||||
TestBadIdentifiersProto.Override.getDefaultInstance();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"IgnoredPureGetter", "CheckReturnValue"}) // TODO(b/221602772): Fix this
|
||||
@SuppressWarnings("IgnoredPureGetter") // TODO(b/221602772): Fix this
|
||||
public void testGetDescriptor() {
|
||||
TestBadIdentifiersProto.getDescriptor();
|
||||
TestBadIdentifiersProto.Descriptor.getDefaultInstance().getDescriptor();
|
||||
|
||||
@@ -235,7 +235,6 @@ import protobuf_unittest.UnittestProto.TestRequired;
|
||||
import protobuf_unittest.UnittestProto.TestUnpackedTypes;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -3843,11 +3842,7 @@ public final class TestUtil {
|
||||
|
||||
private static ByteString readBytesFromResource(String name) {
|
||||
try {
|
||||
InputStream in = TestUtil.class.getResourceAsStream(name);
|
||||
if (in == null) { //
|
||||
throw new RuntimeException("Tests data file " + name + " is missing.");
|
||||
}
|
||||
return ByteString.readFrom(in);
|
||||
return ByteString.readFrom(TestUtil.class.getResourceAsStream(name));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,9 @@ import org.junit.function.ThrowingRunnable;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Test case for {@link TextFormat}. */
|
||||
/**
|
||||
* Test case for {@link TextFormat}.
|
||||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class TextFormatTest {
|
||||
|
||||
@@ -823,7 +825,6 @@ public class TextFormatTest {
|
||||
}
|
||||
}
|
||||
|
||||
@CanIgnoreReturnValue
|
||||
private TestAllTypes assertParseSuccessWithOverwriteForbidden(String text)
|
||||
throws TextFormat.ParseException {
|
||||
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
|
||||
@@ -1449,18 +1450,6 @@ public class TextFormatTest {
|
||||
+ "unknown_field3: 3\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseUnknownExtensionWithAnyMessage() throws Exception {
|
||||
assertParseSuccessWithUnknownExtensions(
|
||||
"[unknown_extension]: { "
|
||||
+ " any_value { "
|
||||
+ " [type.googleapis.com/protobuf_unittest.OneString] { "
|
||||
+ " data: 123 "
|
||||
+ " } "
|
||||
+ " } "
|
||||
+ "}");
|
||||
}
|
||||
|
||||
// See additional coverage in testOneofOverwriteForbidden and testMapOverwriteForbidden.
|
||||
@Test
|
||||
public void testParseNonRepeatedFields() throws Exception {
|
||||
@@ -1773,7 +1762,6 @@ public class TextFormatTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("LenientFormatStringValidation")
|
||||
private void assertLocation(
|
||||
TextFormatParseInfoTree tree,
|
||||
final Descriptor descriptor,
|
||||
@@ -1787,7 +1775,6 @@ public class TextFormatTest {
|
||||
TextFormatParseLocation expected = TextFormatParseLocation.create(line, column);
|
||||
assertThat(location).isEqualTo(expected);
|
||||
} else if (line != -1 && column != -1) {
|
||||
// Expected 0 args, but got 3.
|
||||
assertWithMessage(
|
||||
"Tree/descriptor/fieldname did not contain index %d, line %d column %d expected",
|
||||
index, line, column)
|
||||
|
||||
@@ -31,10 +31,7 @@
|
||||
syntax = "proto2";
|
||||
|
||||
|
||||
package map_for_proto2_lite_test;
|
||||
option java_outer_classname = "MapForProto2TestProto";
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
option java_package = "map_lite_test";
|
||||
|
||||
message TestMap {
|
||||
message MessageValue {
|
||||
@@ -128,3 +125,6 @@ message ReservedAsMapFieldWithEnumValue {
|
||||
// null is not a 'reserved word' per se but as a literal needs similar care
|
||||
map<string, SampleEnum> null = 10;
|
||||
}
|
||||
package map_for_proto2_lite_test;
|
||||
option java_package = "map_lite_test";
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
|
||||
@@ -45,6 +45,11 @@ message Vehicle {
|
||||
message Engine {
|
||||
optional int32 cylinder = 1;
|
||||
optional int32 liters = 2;
|
||||
optional TimingBelt timing_belt = 3;
|
||||
}
|
||||
|
||||
message TimingBelt {
|
||||
optional int32 number_of_teeth = 1;
|
||||
}
|
||||
|
||||
message Wheel {
|
||||
|
||||
@@ -36,6 +36,7 @@ package protobuf.experimental;
|
||||
option java_package = "com.google.protobuf.testing";
|
||||
option java_outer_classname = "Proto2Testing";
|
||||
|
||||
|
||||
message Proto2SpecialFieldName {
|
||||
optional double regular_name = 1;
|
||||
optional int32 cached_size = 2;
|
||||
|
||||
@@ -36,6 +36,7 @@ package protobuf.experimental.lite;
|
||||
option java_package = "com.google.protobuf.testing";
|
||||
option java_outer_classname = "Proto2TestingLite";
|
||||
|
||||
|
||||
message Proto2MessageLite {
|
||||
|
||||
enum TestEnum {
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
|
||||
|
||||
package(default_visibility = ["//java:__subpackages__"])
|
||||
|
||||
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
|
||||
|
||||
pkg_files(
|
||||
name = "dist_files",
|
||||
srcs = [
|
||||
"BUILD.bazel",
|
||||
"JavaVersionTest.java",
|
||||
"testing.bzl",
|
||||
],
|
||||
strip_prefix = strip_prefix.from_root(""),
|
||||
visibility = ["//java:__pkg__"],
|
||||
)
|
||||
|
||||
java_test(
|
||||
name = "java_version",
|
||||
srcs = ["JavaVersionTest.java"],
|
||||
test_class = "JavaVersionTest",
|
||||
deps = [
|
||||
"@maven//:com_google_truth_truth",
|
||||
"@maven//:junit_junit",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
// Test that Kokoro is using the expected version of Java.
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class JavaVersionTest {
|
||||
@Test
|
||||
public void testJavaVersion() throws Exception {
|
||||
String exp = System.getenv("KOKORO_JAVA_VERSION");
|
||||
if(exp == null || exp.isEmpty()) {
|
||||
System.err.println("No kokoro java version found, skipping check");
|
||||
return;
|
||||
}
|
||||
String version = System.getProperty("java.version");
|
||||
assertWithMessage("Expected Python " + exp + " but found Python " + version)
|
||||
.that(version.startsWith(exp))
|
||||
.isTrue();
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ def junit_tests(name, srcs, data = [], deps = [], package_name = "com.google.pro
|
||||
if not test_name.endswith("Test") or test_name.startswith("Abstract"):
|
||||
continue
|
||||
if test_prefix:
|
||||
test_name = "%s%s" % (test_prefix, test_name)
|
||||
test_name = "%s%s" % (test_prefix, test_name)
|
||||
test_names = test_names + [test_name]
|
||||
suite_name = prefix + '_' + test_name
|
||||
_gen_suite(
|
||||
|
||||
@@ -140,7 +140,7 @@ internal_gen_kt_protos(
|
||||
internal_gen_kt_protos(
|
||||
name = "gen_kotlin_unittest_lite",
|
||||
lite = True,
|
||||
deps = ["//src/google/protobuf:lite_test_protos"],
|
||||
deps = ["//:kt_unittest_lite"],
|
||||
)
|
||||
|
||||
kt_jvm_library(
|
||||
@@ -152,7 +152,6 @@ kt_jvm_library(
|
||||
deps = [
|
||||
":evil_names_proto2_java_proto_lite",
|
||||
"//java/core:generic_test_protos_java_proto_lite",
|
||||
"//java/core:lite_test_protos_java_proto_lite",
|
||||
"//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests",
|
||||
"//java/kotlin:shared_runtime",
|
||||
"//java/lite",
|
||||
@@ -162,7 +161,7 @@ kt_jvm_library(
|
||||
internal_gen_kt_protos(
|
||||
name = "gen_kotlin_proto3_unittest_lite",
|
||||
lite = True,
|
||||
deps = ["//src/google/protobuf:kt_proto3_unittest_protos"],
|
||||
deps = ["//:kt_proto3_unittest"],
|
||||
)
|
||||
|
||||
kt_jvm_library(
|
||||
@@ -176,7 +175,6 @@ kt_jvm_library(
|
||||
":evil_names_proto3_java_proto_lite",
|
||||
":multiple_files_proto3_java_proto_lite",
|
||||
"//java/core:generic_test_protos_java_proto_lite",
|
||||
"//java/core:lite_test_protos_java_proto_lite",
|
||||
"//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests",
|
||||
"//java/kotlin:shared_runtime",
|
||||
"//java/lite",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.21.8</version>
|
||||
<version>3.21.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-kotlin-lite</artifactId>
|
||||
|
||||
@@ -46,6 +46,13 @@ import com.google.protobuf.UnittestLite.TestEmptyMessageLite
|
||||
import com.google.protobuf.UnittestLite.TestEmptyMessageWithExtensionsLite
|
||||
import com.google.protobuf.copy
|
||||
import com.google.protobuf.foreignMessageLite
|
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.EvilNamesProto2
|
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.HardKeywordsAllTypesProto2
|
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.Interface
|
||||
import com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto2Kt
|
||||
import com.google.protobuf.kotlin.generator.evilNamesProto2
|
||||
import com.google.protobuf.kotlin.generator.hardKeywordsAllTypesProto2
|
||||
import com.google.protobuf.kotlin.generator.interface_
|
||||
import com.google.protobuf.optionalGroupExtensionLite
|
||||
import com.google.protobuf.repeatedGroupExtensionLite
|
||||
import com.google.protobuf.testAllExtensionsLite
|
||||
@@ -55,13 +62,6 @@ import com.google.protobuf.testEmptyMessageWithExtensionsLite
|
||||
import protobuf_unittest.MapLiteUnittest.MapEnumLite
|
||||
import protobuf_unittest.MapLiteUnittest.TestMapLite
|
||||
import protobuf_unittest.testMapLite
|
||||
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.EvilNamesProto2
|
||||
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.HardKeywordsAllTypesProto2
|
||||
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.Interface
|
||||
import `in`.com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto2Kt
|
||||
import `in`.com.google.protobuf.kotlin.generator.evilNamesProto2
|
||||
import `in`.com.google.protobuf.kotlin.generator.hardKeywordsAllTypesProto2
|
||||
import `in`.com.google.protobuf.kotlin.generator.interface_
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.JUnit4
|
||||
@@ -178,7 +178,6 @@ class Proto2LiteTest {
|
||||
.isEqualTo(TestUtilLite.getAllLiteSetBuilder().build())
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testGetters() {
|
||||
testAllTypesLite {
|
||||
@@ -199,7 +198,6 @@ class Proto2LiteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testDefaultGetters() {
|
||||
testAllTypesLite {
|
||||
@@ -210,7 +208,6 @@ class Proto2LiteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testRepeatedGettersAndSetters() {
|
||||
testAllTypesLite {
|
||||
@@ -301,7 +298,6 @@ class Proto2LiteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testHazzers() {
|
||||
testAllTypesLite {
|
||||
@@ -332,7 +328,6 @@ class Proto2LiteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testClears() {
|
||||
testAllTypesLite {
|
||||
@@ -525,7 +520,6 @@ class Proto2LiteTest {
|
||||
.isEqualTo(TestUtilLite.getAllLiteExtensionsSet())
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testExtensionGetters() {
|
||||
testAllExtensionsLite {
|
||||
@@ -549,7 +543,6 @@ class Proto2LiteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testRepeatedExtensionGettersAndSetters() {
|
||||
testAllExtensionsLite {
|
||||
@@ -639,7 +632,6 @@ class Proto2LiteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testExtensionContains() {
|
||||
testAllExtensionsLite {
|
||||
@@ -671,7 +663,6 @@ class Proto2LiteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testExtensionClears() {
|
||||
testAllExtensionsLite {
|
||||
@@ -760,7 +751,6 @@ class Proto2LiteTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testMapGettersAndSetters() {
|
||||
testMapLite {
|
||||
@@ -816,7 +806,6 @@ class Proto2LiteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testMapRemove() {
|
||||
testMapLite {
|
||||
@@ -842,7 +831,6 @@ class Proto2LiteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testMapClear() {
|
||||
testMapLite {
|
||||
@@ -889,6 +877,7 @@ class Proto2LiteTest {
|
||||
boolean = 1L
|
||||
sealed = "foo"
|
||||
interface_ = 1F
|
||||
in_ = 1
|
||||
object_ = "foo"
|
||||
cachedSize_ = "foo"
|
||||
serializedSize_ = true
|
||||
@@ -914,6 +903,7 @@ class Proto2LiteTest {
|
||||
.setBoolean(1L)
|
||||
.setSealed("foo")
|
||||
.setInterface(1F)
|
||||
.setIn(1)
|
||||
.setObject("foo")
|
||||
.setCachedSize_("foo")
|
||||
.setSerializedSize_(true)
|
||||
@@ -924,13 +914,15 @@ class Proto2LiteTest {
|
||||
assertThat(interface_ {}).isEqualTo(Interface.newBuilder().build())
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testHardKeywordGettersAndSetters() {
|
||||
hardKeywordsAllTypesProto2 {
|
||||
as_ = 1
|
||||
assertThat(as_).isEqualTo(1)
|
||||
|
||||
in_ = "foo"
|
||||
assertThat(in_).isEqualTo("foo")
|
||||
|
||||
break_ = HardKeywordsAllTypesProto2.NestedEnum.FOO
|
||||
assertThat(break_).isEqualTo(HardKeywordsAllTypesProto2.NestedEnum.FOO)
|
||||
|
||||
@@ -954,13 +946,15 @@ class Proto2LiteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testHardKeywordHazzers() {
|
||||
hardKeywordsAllTypesProto2 {
|
||||
as_ = 1
|
||||
assertThat(hasAs_()).isTrue()
|
||||
|
||||
in_ = "foo"
|
||||
assertThat(hasIn_()).isTrue()
|
||||
|
||||
break_ = HardKeywordsAllTypesProto2.NestedEnum.FOO
|
||||
assertThat(hasBreak_()).isTrue()
|
||||
|
||||
@@ -969,7 +963,6 @@ class Proto2LiteTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testHardKeywordClears() {
|
||||
hardKeywordsAllTypesProto2 {
|
||||
@@ -977,6 +970,10 @@ class Proto2LiteTest {
|
||||
clearAs_()
|
||||
assertThat(hasAs_()).isFalse()
|
||||
|
||||
in_ = "foo"
|
||||
clearIn_()
|
||||
assertThat(hasIn_()).isFalse()
|
||||
|
||||
break_ = HardKeywordsAllTypesProto2.NestedEnum.FOO
|
||||
clearBreak_()
|
||||
assertThat(hasBreak_()).isFalse()
|
||||
|
||||
@@ -25,7 +25,6 @@ kt_jvm_library(
|
||||
deps = [
|
||||
":only_for_use_in_proto_generated_code_its_generator_and_tests",
|
||||
"//java/lite",
|
||||
"@maven//:com_google_errorprone_error_prone_annotations",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -60,7 +59,7 @@ kt_jvm_export(
|
||||
maven_coordinates = "com.google.protobuf:protobuf-kotlin:%s" % PROTOBUF_JAVA_VERSION,
|
||||
pom_template = "//java/kotlin:pom_template.xml",
|
||||
resources = [
|
||||
"//src/google/protobuf:descriptor_proto_srcs",
|
||||
"//:built_in_runtime_protos",
|
||||
"//:well_known_type_protos",
|
||||
],
|
||||
tags = ["manual"],
|
||||
@@ -225,7 +224,7 @@ internal_gen_kt_protos(
|
||||
internal_gen_kt_protos(
|
||||
name = "gen_kotlin_unittest",
|
||||
visibility = ["//java:__subpackages__"],
|
||||
deps = ["//src/google/protobuf:kt_unittest_protos"],
|
||||
deps = ["//:kt_unittest"],
|
||||
)
|
||||
|
||||
kt_jvm_library(
|
||||
@@ -241,13 +240,12 @@ kt_jvm_library(
|
||||
":well_known_protos_kotlin",
|
||||
"//java/core",
|
||||
"//java/core:generic_test_protos_java_proto",
|
||||
"//java/core:lite_test_protos_java_proto",
|
||||
],
|
||||
)
|
||||
|
||||
internal_gen_kt_protos(
|
||||
name = "gen_kotlin_proto3_unittest",
|
||||
deps = ["//src/google/protobuf:kt_proto3_unittest_protos"],
|
||||
deps = ["//:kt_proto3_unittest"],
|
||||
)
|
||||
|
||||
kt_jvm_library(
|
||||
@@ -264,7 +262,6 @@ kt_jvm_library(
|
||||
":shared_runtime",
|
||||
"//java/core",
|
||||
"//java/core:generic_test_protos_java_proto",
|
||||
"//java/core:lite_test_protos_java_proto",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.21.8</version>
|
||||
<version>3.21.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-kotlin</artifactId>
|
||||
@@ -34,11 +34,6 @@
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.errorprone</groupId>
|
||||
<artifactId>error_prone_annotations</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
|
||||
@@ -33,6 +33,13 @@ package com.google.protobuf.kotlin
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.google.protobuf.TestUtil
|
||||
import com.google.protobuf.TestUtil.toBytes
|
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.EvilNamesProto2
|
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.HardKeywordsAllTypesProto2
|
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.Interface
|
||||
import com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto2Kt
|
||||
import com.google.protobuf.kotlin.generator.evilNamesProto2
|
||||
import com.google.protobuf.kotlin.generator.hardKeywordsAllTypesProto2
|
||||
import com.google.protobuf.kotlin.generator.interface_
|
||||
import com.google.protobuf.test.UnittestImport.ImportEnum
|
||||
import com.google.protobuf.test.UnittestImport.ImportMessage
|
||||
import com.google.protobuf.test.UnittestImportPublic.PublicImportMessage
|
||||
@@ -60,13 +67,6 @@ import protobuf_unittest.testEmptyMessageWithExtensions
|
||||
import protobuf_unittest.testEnumMap
|
||||
import protobuf_unittest.testIntIntMap
|
||||
import protobuf_unittest.testMaps
|
||||
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.EvilNamesProto2
|
||||
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.HardKeywordsAllTypesProto2
|
||||
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.Interface
|
||||
import `in`.com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto2Kt
|
||||
import `in`.com.google.protobuf.kotlin.generator.evilNamesProto2
|
||||
import `in`.com.google.protobuf.kotlin.generator.hardKeywordsAllTypesProto2
|
||||
import `in`.com.google.protobuf.kotlin.generator.interface_
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.JUnit4
|
||||
@@ -183,7 +183,6 @@ class Proto2Test {
|
||||
.isEqualTo(TestUtil.getAllSetBuilder().build())
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testGetters() {
|
||||
testAllTypes {
|
||||
@@ -204,7 +203,6 @@ class Proto2Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testDefaultGetters() {
|
||||
testAllTypes {
|
||||
@@ -215,7 +213,6 @@ class Proto2Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testRepeatedGettersAndSetters() {
|
||||
testAllTypes {
|
||||
@@ -297,7 +294,6 @@ class Proto2Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testHazzers() {
|
||||
testAllTypes {
|
||||
@@ -328,7 +324,6 @@ class Proto2Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testClears() {
|
||||
testAllTypes {
|
||||
@@ -517,7 +512,6 @@ class Proto2Test {
|
||||
.isEqualTo(TestUtil.getAllExtensionsSet())
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testExtensionGetters() {
|
||||
testAllExtensions {
|
||||
@@ -540,7 +534,6 @@ class Proto2Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testRepeatedExtensionGettersAndSetters() {
|
||||
testAllExtensions {
|
||||
@@ -621,7 +614,6 @@ class Proto2Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testExtensionContains() {
|
||||
testAllExtensions {
|
||||
@@ -652,7 +644,6 @@ class Proto2Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testExtensionClears() {
|
||||
testAllExtensions {
|
||||
@@ -734,7 +725,6 @@ class Proto2Test {
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testMapGettersAndSetters() {
|
||||
val intMap = testIntIntMap {
|
||||
@@ -786,7 +776,6 @@ class Proto2Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testMapRemove() {
|
||||
val intMap = testIntIntMap {
|
||||
@@ -814,7 +803,6 @@ class Proto2Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testMapClear() {
|
||||
val intMap = testIntIntMap {
|
||||
@@ -863,6 +851,7 @@ class Proto2Test {
|
||||
boolean = 1L
|
||||
sealed = "foo"
|
||||
interface_ = 1F
|
||||
in_ = 1
|
||||
object_ = "foo"
|
||||
cachedSize_ = "foo"
|
||||
serializedSize_ = true
|
||||
@@ -888,6 +877,7 @@ class Proto2Test {
|
||||
.setBoolean(1L)
|
||||
.setSealed("foo")
|
||||
.setInterface(1F)
|
||||
.setIn(1)
|
||||
.setObject("foo")
|
||||
.setCachedSize_("foo")
|
||||
.setSerializedSize_(true)
|
||||
@@ -898,13 +888,15 @@ class Proto2Test {
|
||||
assertThat(interface_ {}).isEqualTo(Interface.newBuilder().build())
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testHardKeywordGettersAndSetters() {
|
||||
hardKeywordsAllTypesProto2 {
|
||||
as_ = 1
|
||||
assertThat(as_).isEqualTo(1)
|
||||
|
||||
in_ = "foo"
|
||||
assertThat(in_).isEqualTo("foo")
|
||||
|
||||
break_ = HardKeywordsAllTypesProto2.NestedEnum.FOO
|
||||
assertThat(break_).isEqualTo(HardKeywordsAllTypesProto2.NestedEnum.FOO)
|
||||
|
||||
@@ -928,13 +920,15 @@ class Proto2Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testHardKeywordHazzers() {
|
||||
hardKeywordsAllTypesProto2 {
|
||||
as_ = 1
|
||||
assertThat(hasAs_()).isTrue()
|
||||
|
||||
in_ = "foo"
|
||||
assertThat(hasIn_()).isTrue()
|
||||
|
||||
break_ = HardKeywordsAllTypesProto2.NestedEnum.FOO
|
||||
assertThat(hasBreak_()).isTrue()
|
||||
|
||||
@@ -943,7 +937,6 @@ class Proto2Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testHardKeywordClears() {
|
||||
hardKeywordsAllTypesProto2 {
|
||||
@@ -951,6 +944,10 @@ class Proto2Test {
|
||||
clearAs_()
|
||||
assertThat(hasAs_()).isFalse()
|
||||
|
||||
in_ = "foo"
|
||||
clearIn_()
|
||||
assertThat(hasIn_()).isFalse()
|
||||
|
||||
break_ = HardKeywordsAllTypesProto2.NestedEnum.FOO
|
||||
clearBreak_()
|
||||
assertThat(hasBreak_()).isFalse()
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
package com.google.protobuf.kotlin
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.google.protobuf.kotlin.generator.`in`.EvilNamesProto3OuterClass.Class
|
||||
import com.google.protobuf.kotlin.generator.`in`.EvilNamesProto3OuterClass.EvilNamesProto3
|
||||
import com.google.protobuf.kotlin.generator.`in`.EvilNamesProto3OuterClass.HardKeywordsAllTypesProto3
|
||||
import com.google.protobuf.kotlin.generator.`in`.HardKeywordsAllTypesProto3Kt
|
||||
import com.google.protobuf.kotlin.generator.`in`.class_
|
||||
import com.google.protobuf.kotlin.generator.`in`.evilNamesProto3
|
||||
import com.google.protobuf.kotlin.generator.`in`.hardKeywordsAllTypesProto3
|
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto3OuterClass.Class
|
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto3OuterClass.EvilNamesProto3
|
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto3OuterClass.HardKeywordsAllTypesProto3
|
||||
import com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto3Kt
|
||||
import com.google.protobuf.kotlin.generator.class_
|
||||
import com.google.protobuf.kotlin.generator.evilNamesProto3
|
||||
import com.google.protobuf.kotlin.generator.hardKeywordsAllTypesProto3
|
||||
import proto3_unittest.TestAllTypesKt
|
||||
import proto3_unittest.TestAllTypesKt.nestedMessage
|
||||
import proto3_unittest.UnittestProto3.TestAllTypes
|
||||
@@ -54,7 +54,6 @@ import org.junit.runners.JUnit4
|
||||
|
||||
@RunWith(JUnit4::class)
|
||||
class Proto3Test {
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testGettersAndSetters() {
|
||||
testAllTypes {
|
||||
@@ -66,17 +65,11 @@ class Proto3Test {
|
||||
assertThat(optionalNestedMessage).isEqualTo(TestAllTypesKt.nestedMessage { bb = 118 })
|
||||
optionalNestedEnum = NestedEnum.BAZ
|
||||
assertThat(optionalNestedEnum).isEqualTo(NestedEnum.BAZ)
|
||||
assertThat(optionalNestedEnumValue).isEqualTo(3)
|
||||
optionalNestedEnumValue = 1
|
||||
assertThat(optionalNestedEnumValue).isEqualTo(1)
|
||||
assertThat(optionalNestedEnum).isEqualTo(NestedEnum.FOO)
|
||||
|
||||
oneofUint32 = 601
|
||||
assertThat(oneofUint32).isEqualTo(601)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testRepeatedGettersAndSetters() {
|
||||
testAllTypes {
|
||||
@@ -266,7 +259,6 @@ class Proto3Test {
|
||||
assertThat(class_ {}).isEqualTo(Class.newBuilder().build())
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testHardKeywordGettersAndSetters() {
|
||||
hardKeywordsAllTypesProto3 {
|
||||
@@ -299,7 +291,6 @@ class Proto3Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testHardKeywordHazzers() {
|
||||
hardKeywordsAllTypesProto3 {
|
||||
@@ -317,7 +308,6 @@ class Proto3Test {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CheckResult")
|
||||
@Test
|
||||
fun testHardKeywordClears() {
|
||||
hardKeywordsAllTypesProto3 {
|
||||
|
||||
@@ -33,7 +33,7 @@ syntax = "proto2";
|
||||
|
||||
package protobuf.kotlin.generator;
|
||||
|
||||
option java_package = "in.com.google.protobuf.kotlin.generator";
|
||||
option java_package = "com.google.protobuf.kotlin.generator";
|
||||
|
||||
message EvilNamesProto2 {
|
||||
optional bool initialized = 1;
|
||||
@@ -61,6 +61,7 @@ message EvilNamesProto2 {
|
||||
optional int64 boolean = 18;
|
||||
optional string sealed = 19;
|
||||
optional float interface = 20;
|
||||
optional int32 in = 21;
|
||||
optional string object = 22;
|
||||
optional string cached_size = 23;
|
||||
optional bool serialized_size = 24;
|
||||
@@ -78,6 +79,7 @@ message HardKeywordsAllTypesProto2 {
|
||||
}
|
||||
|
||||
optional int32 as = 1;
|
||||
optional string in = 2;
|
||||
optional NestedEnum break = 3;
|
||||
map<int32, int32> continue = 4;
|
||||
optional NestedMessage do = 5;
|
||||
|
||||
@@ -33,7 +33,7 @@ syntax = "proto3";
|
||||
|
||||
package protobuf.kotlin.generator;
|
||||
|
||||
option java_package = "com.google.protobuf.kotlin.generator.in";
|
||||
option java_package = "com.google.protobuf.kotlin.generator";
|
||||
|
||||
message EvilNamesProto3 {
|
||||
bool initialized = 1;
|
||||
|
||||
@@ -29,7 +29,7 @@ protobuf Java Lite runtime. If you are using Maven, include the following:
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-javalite</artifactId>
|
||||
<version>3.21.8</version>
|
||||
<version>3.21.12</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ junit_tests(
|
||||
":lite",
|
||||
"//java/core:generic_test_protos_java_proto_lite",
|
||||
"//java/core:java_test_protos_java_proto_lite",
|
||||
"//java/core:lite_test_protos_java_proto_lite",
|
||||
"//java/core:test_util_lite",
|
||||
"@maven//:com_google_truth_truth",
|
||||
"@maven//:junit_junit",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.21.8</version>
|
||||
<version>3.21.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-javalite</artifactId>
|
||||
|
||||
@@ -51,7 +51,6 @@ import com.google.protobuf.UnittestLite.TestAllTypesLite.RepeatedGroup;
|
||||
import com.google.protobuf.UnittestLite.TestAllTypesLiteOrBuilder;
|
||||
import com.google.protobuf.UnittestLite.TestHugeFieldNumbersLite;
|
||||
import com.google.protobuf.UnittestLite.TestNestedExtensionLite;
|
||||
import com.google.protobuf.testing.Proto3TestingLite.Proto3MessageLite;
|
||||
import map_lite_test.MapTestProto.TestMap;
|
||||
import map_lite_test.MapTestProto.TestMap.MessageValue;
|
||||
import protobuf_unittest.NestedExtensionLite;
|
||||
@@ -225,22 +224,6 @@ public class LiteTest {
|
||||
assertThat(((Byte) memo.get(message)).intValue()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProto3EnumListValueCopyOnWrite() {
|
||||
Proto3MessageLite.Builder builder = Proto3MessageLite.newBuilder();
|
||||
|
||||
Proto3MessageLite message = builder.build();
|
||||
builder.addFieldEnumList30Value(Proto3MessageLite.TestEnum.ONE_VALUE);
|
||||
assertThat(message.getFieldEnumList30List()).isEmpty();
|
||||
assertThat(builder.getFieldEnumList30List()).containsExactly(Proto3MessageLite.TestEnum.ONE);
|
||||
assertThat(message.getFieldEnumList30List()).isEmpty();
|
||||
Proto3MessageLite messageAfterBuild = builder.build();
|
||||
builder.clearFieldEnumList30();
|
||||
assertThat(builder.getFieldEnumList30List()).isEmpty();
|
||||
assertThat(messageAfterBuild.getFieldEnumList30List())
|
||||
.containsExactly(Proto3MessageLite.TestEnum.ONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanityCopyOnWrite() throws InvalidProtocolBufferException {
|
||||
// Since builders are implemented as a thin wrapper around a message
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.21.8</version>
|
||||
<version>3.21.12</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Protocol Buffers [Parent]</name>
|
||||
@@ -33,7 +33,7 @@
|
||||
<!-- These are relative to the submodules -->
|
||||
<protobuf.basedir>${project.basedir}/../..</protobuf.basedir>
|
||||
<protobuf.source.dir>${protobuf.basedir}/src</protobuf.source.dir>
|
||||
<protoc>${protobuf.basedir}/protoc</protoc>
|
||||
<protoc>${protobuf.source.dir}/protoc</protoc>
|
||||
<test.proto.dir>src/test/proto</test.proto.dir>
|
||||
<generated.sources.dir>${project.build.directory}/generated-sources</generated.sources.dir>
|
||||
<generated.testsources.dir>${project.build.directory}/generated-test-sources</generated.testsources.dir>
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
# Publish pre-compiled protoc artifacts
|
||||
``protoc`` is the compiler for ``.proto`` files. It generates language bindings
|
||||
for the messages and/or RPC services from ``.proto`` files.
|
||||
|
||||
Because ``protoc`` is a native executable, the scripts under this directory
|
||||
publish a ``protoc`` executable (a.k.a. artifact) to Maven repositories. The
|
||||
artifact can be used by build automation tools so that users would not need to
|
||||
compile and install ``protoc`` for their systems.
|
||||
|
||||
If you would like us to publish protoc artifact for a new platform, please
|
||||
open an issue to request it.
|
||||
|
||||
## Maven Location
|
||||
The published protoc artifacts are available on Maven here:
|
||||
|
||||
https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/
|
||||
|
||||
## Versioning
|
||||
The version of the ``protoc`` artifact must be the same as the version of the
|
||||
Protobuf project.
|
||||
|
||||
## Artifact name
|
||||
The name of a published ``protoc`` artifact is in the following format:
|
||||
``protoc-<version>-<os>-<arch>.exe``, e.g., ``protoc-3.6.1-linux-x86_64.exe``.
|
||||
|
||||
Note that artifacts for linux/macos also have the `.exe` suffix but they are
|
||||
not windows binaries.
|
||||
|
||||
## System requirement
|
||||
Install [Apache Maven](http://maven.apache.org/) if you don't have it.
|
||||
|
||||
The scripts only work under Unix-like environments, e.g., Linux, MacOSX, and
|
||||
Cygwin or MinGW for Windows. Please see ``README.md`` of the Protobuf project
|
||||
for how to set up the build environment.
|
||||
|
||||
## Tested build environments
|
||||
We have successfully built artifacts on the following environments:
|
||||
- Linux x86_32 and x86_64:
|
||||
- Centos 6.9 (within Docker 1.6.1)
|
||||
- Ubuntu 14.04.5 64-bit
|
||||
- Linux aarch_64: Cross compiled with `g++-aarch64-linux-gnu` on Ubuntu 14.04.5 64-bit
|
||||
- Mac OS X x86_32 and x86_64: Mac OS X 10.9.5
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.google</groupId>
|
||||
<artifactId>google</artifactId>
|
||||
<version>5</version>
|
||||
</parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protoc</artifactId>
|
||||
<version>3.21.6</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Protobuf Compiler</name>
|
||||
<description>
|
||||
Protobuf Compiler (protoc) is a compiler for .proto files. It generates
|
||||
language-specific code for Protobuf messages and RPC interfaces.
|
||||
</description>
|
||||
<inceptionYear>2008</inceptionYear>
|
||||
<url>https://developers.google.com/protocol-buffers/</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>BSD-3-Clause</name>
|
||||
<url>https://opensource.org/licenses/BSD-3-Clause</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<url>https://github.com/protocolbuffers/protobuf</url>
|
||||
<connection>
|
||||
scm:git:https://github.com/protocolbuffers/protobuf.git
|
||||
</connection>
|
||||
</scm>
|
||||
</project>
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.21.8</version>
|
||||
<version>3.21.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-java-util</artifactId>
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
|
||||
<name>Protocol Buffers [Util]</name>
|
||||
<description>Utilities for Protocol Buffers</description>
|
||||
<dependencies>
|
||||
{dependencies}
|
||||
</dependencies>
|
||||
|
||||
{dependencies}
|
||||
|
||||
</project>
|
||||
|
||||
@@ -101,8 +101,9 @@ public final class FieldMaskUtil {
|
||||
/**
|
||||
* Constructs a FieldMask for a list of field paths in a certain type.
|
||||
*
|
||||
* @throws IllegalArgumentException if any of the field path is not valid
|
||||
* @throws IllegalArgumentException if any of the field path is not valid.
|
||||
*/
|
||||
// TODO(xiaofeng): Consider renaming fromStrings()
|
||||
public static FieldMask fromStringList(Class<? extends Message> type, Iterable<String> paths) {
|
||||
return fromStringList(Internal.getDefaultInstance(type).getDescriptorForType(), paths);
|
||||
}
|
||||
|
||||
@@ -343,8 +343,7 @@ public final class Timestamps {
|
||||
public static Timestamp fromDate(Date date) {
|
||||
if (date instanceof java.sql.Timestamp) {
|
||||
java.sql.Timestamp sqlTimestamp = (java.sql.Timestamp) date;
|
||||
long time = sqlTimestamp.getTime();
|
||||
long integralSeconds = (time < 0 && time % 1000 != 0) ? time / 1000L - 1 : time / 1000L ; // truncate the fractional seconds
|
||||
long integralSeconds = sqlTimestamp.getTime() / 1000L; // truncate the fractional seconds
|
||||
return Timestamp.newBuilder()
|
||||
.setSeconds(integralSeconds)
|
||||
.setNanos(sqlTimestamp.getNanos())
|
||||
|
||||
@@ -75,7 +75,10 @@ public final class Values {
|
||||
* element in the iterable.
|
||||
*/
|
||||
public static Value of(Iterable<Value> values) {
|
||||
return Value.newBuilder().setListValue(ListValue.newBuilder().addAllValues(values)).build();
|
||||
Value.Builder valueBuilder = Value.newBuilder();
|
||||
ListValue.Builder listValue = valueBuilder.getListValueBuilder();
|
||||
listValue.addAllValues(values);
|
||||
return valueBuilder.build();
|
||||
}
|
||||
|
||||
private Values() {}
|
||||
|
||||
@@ -475,20 +475,6 @@ public class TimestampsTest {
|
||||
Timestamp timestamp = Timestamps.fromDate(date);
|
||||
assertThat(Timestamps.toString(timestamp)).isEqualTo("1970-01-01T00:00:01.111Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromSqlTimestamp_beforeEpoch() {
|
||||
Date date = new java.sql.Timestamp(-1111);
|
||||
Timestamp timestamp = Timestamps.fromDate(date);
|
||||
assertThat(Timestamps.toString(timestamp)).isEqualTo("1969-12-31T23:59:58.889Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromSqlTimestamp_beforeEpochWholeSecond() {
|
||||
Date date = new java.sql.Timestamp(-2000);
|
||||
Timestamp timestamp = Timestamps.fromDate(date);
|
||||
assertThat(Timestamps.toString(timestamp)).isEqualTo("1969-12-31T23:59:58Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeOperations() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user