Skip to content

Commit ce5174a

Browse files
authored
Merge pull request #18798 from protocolbuffers/gberg-cp-28
Fix compatibility issues with 3.22 gencode
2 parents fe3bb07 + 3b62d78 commit ce5174a

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java

+45
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
import com.google.protobuf.Descriptors.Descriptor;
1111
import com.google.protobuf.Descriptors.FieldDescriptor;
1212
import com.google.protobuf.Descriptors.OneofDescriptor;
13+
import com.google.protobuf.Internal.BooleanList;
14+
import com.google.protobuf.Internal.DoubleList;
15+
import com.google.protobuf.Internal.FloatList;
16+
import com.google.protobuf.Internal.IntList;
17+
import com.google.protobuf.Internal.LongList;
1318
import java.util.List;
1419

1520
/**
@@ -36,6 +41,46 @@ protected GeneratedMessageV3(Builder<?> builder) {
3641
super(builder);
3742
}
3843

44+
/* @deprecated This method is deprecated, and slated for removal in the next Java breaking change
45+
* (5.x). Users should update gencode to >= 4.26.x which uses makeMutableCopy() instead.
46+
*/
47+
@Deprecated
48+
protected static IntList mutableCopy(IntList list) {
49+
return makeMutableCopy(list);
50+
}
51+
52+
/* @deprecated This method is deprecated, and slated for removal in the next Java breaking change
53+
* (5.x). Users should update gencode to >= 4.26.x which uses makeMutableCopy() instead.
54+
*/
55+
@Deprecated
56+
protected static LongList mutableCopy(LongList list) {
57+
return makeMutableCopy(list);
58+
}
59+
60+
/* @deprecated This method is deprecated, and slated for removal in the next Java breaking change
61+
* (5.x). Users should update gencode to >= 4.26.x which uses makeMutableCopy() instead.
62+
*/
63+
@Deprecated
64+
protected static FloatList mutableCopy(FloatList list) {
65+
return makeMutableCopy(list);
66+
}
67+
68+
/* @deprecated This method is deprecated, and slated for removal in the next Java breaking change
69+
* (5.x). Users should update gencode to >= 4.26.x which uses makeMutableCopy() instead.
70+
*/
71+
@Deprecated
72+
protected static DoubleList mutableCopy(DoubleList list) {
73+
return makeMutableCopy(list);
74+
}
75+
76+
/* @deprecated This method is deprecated, and slated for removal in the next Java breaking change
77+
* (5.x). Users should update gencode to >= 4.26.x which uses makeMutableCopy() instead.
78+
*/
79+
@Deprecated
80+
protected static BooleanList mutableCopy(BooleanList list) {
81+
return makeMutableCopy(list);
82+
}
83+
3984
/* Overrides abstract GeneratedMessage.internalGetFieldAccessorTable().
4085
*
4186
* @deprecated This method is deprecated, and slated for removal in the next Java breaking change

java/util/src/main/java/com/google/protobuf/util/JsonFormat.java

+29
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,35 @@ public Printer usingTypeRegistry(com.google.protobuf.TypeRegistry registry) {
178178
sortingMapKeys);
179179
}
180180

181+
/**
182+
* Creates a new {@link Printer} that will always print fields unless they are a message type or
183+
* in a oneof.
184+
*
185+
* <p>Note that this does print Proto2 Optional but does not print Proto3 Optional fields, as
186+
* the latter is represented using a synthetic oneof.
187+
*
188+
* <p>The new Printer clones all other configurations from the current {@link Printer}.
189+
*
190+
* @deprecated This method is deprecated, and slated for removal in the next Java breaking
191+
* change (5.x). Prefer {@link #alwaysPrintFieldsWithNoPresence}
192+
*/
193+
@Deprecated
194+
public Printer includingDefaultValueFields() {
195+
if (shouldPrintDefaults != ShouldPrintDefaults.ONLY_IF_PRESENT) {
196+
throw new IllegalStateException(
197+
"JsonFormat includingDefaultValueFields has already been set.");
198+
}
199+
return new Printer(
200+
registry,
201+
oldRegistry,
202+
ShouldPrintDefaults.ALWAYS_PRINT_EXCEPT_MESSAGES_AND_ONEOFS,
203+
ImmutableSet.of(),
204+
preservingProtoFieldNames,
205+
omittingInsignificantWhitespace,
206+
printingEnumsAsInts,
207+
sortingMapKeys);
208+
}
209+
181210
/**
182211
* Creates a new {@link Printer} that will also print default-valued fields if their
183212
* FieldDescriptors are found in the supplied set. Empty repeated fields and map fields will be

0 commit comments

Comments
 (0)