Skip to content

Commit 9310d2e

Browse files
Breaking Change: Remove obsolete runtime internalBuildGeneratedFileFrom which was for backwards compatibility with old gencode.
Remove `sentinel.proto` and references to it. This was announced in https://protobuf.dev/news/2023-12-05/ per our Cross-Version Runtime Guarantees: https://protobuf.dev/support/cross-version-runtime-guarantee/ PiperOrigin-RevId: 597849821
1 parent e542443 commit 9310d2e

5 files changed

Lines changed: 10 additions & 803 deletions

File tree

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

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -360,50 +360,6 @@ private static FileDescriptor[] findDescriptors(
360360
return descriptors.toArray(new FileDescriptor[0]);
361361
}
362362

363-
/**
364-
* This method is for backward compatibility with generated code which passed an
365-
* InternalDescriptorAssigner.
366-
*/
367-
@Deprecated
368-
public static void internalBuildGeneratedFileFrom(
369-
final String[] descriptorDataParts,
370-
final FileDescriptor[] dependencies,
371-
final InternalDescriptorAssigner descriptorAssigner) {
372-
final byte[] descriptorBytes = latin1Cat(descriptorDataParts);
373-
374-
FileDescriptorProto proto;
375-
try {
376-
proto = FileDescriptorProto.parseFrom(descriptorBytes);
377-
} catch (InvalidProtocolBufferException e) {
378-
throw new IllegalArgumentException(
379-
"Failed to parse protocol buffer descriptor for generated code.", e);
380-
}
381-
382-
final FileDescriptor result;
383-
try {
384-
// When building descriptors for generated code, we allow unknown
385-
// dependencies by default.
386-
result = buildFrom(proto, dependencies, true);
387-
} catch (DescriptorValidationException e) {
388-
throw new IllegalArgumentException(
389-
"Invalid embedded descriptor for \"" + proto.getName() + "\".", e);
390-
}
391-
392-
final ExtensionRegistry registry = descriptorAssigner.assignDescriptors(result);
393-
394-
if (registry != null) {
395-
// We must re-parse the proto using the registry.
396-
try {
397-
proto = FileDescriptorProto.parseFrom(descriptorBytes, registry);
398-
} catch (InvalidProtocolBufferException e) {
399-
throw new IllegalArgumentException(
400-
"Failed to parse protocol buffer descriptor for generated code.", e);
401-
}
402-
403-
result.setProto(proto);
404-
}
405-
}
406-
407363
/**
408364
* This method is to be called by generated code only. It is equivalent to {@code buildFrom}
409365
* except that the {@code FileDescriptorProto} is encoded in protocol buffer wire format.
@@ -430,22 +386,6 @@ public static FileDescriptor internalBuildGeneratedFileFrom(
430386
}
431387
}
432388

433-
/**
434-
* This method is for backward compatibility with generated code which passed an
435-
* InternalDescriptorAssigner.
436-
*/
437-
@Deprecated
438-
public static void internalBuildGeneratedFileFrom(
439-
final String[] descriptorDataParts,
440-
final Class<?> descriptorOuterClass,
441-
final String[] dependencyClassNames,
442-
final String[] dependencyFileNames,
443-
final InternalDescriptorAssigner descriptorAssigner) {
444-
FileDescriptor[] dependencies =
445-
findDescriptors(descriptorOuterClass, dependencyClassNames, dependencyFileNames);
446-
internalBuildGeneratedFileFrom(descriptorDataParts, dependencies, descriptorAssigner);
447-
}
448-
449389
/**
450390
* This method is to be called by generated code only. It uses Java reflection to load the
451391
* dependencies' descriptors.
@@ -2011,6 +1951,7 @@ private void setProto(final EnumDescriptorProto proto) {
20111951
* number. In generated Java code, all values with the same number after the first become aliases
20121952
* of the first. However, they still have independent EnumValueDescriptors.
20131953
*/
1954+
@SuppressWarnings("ShouldNotSubclass")
20141955
public static final class EnumValueDescriptor extends GenericDescriptor
20151956
implements Internal.EnumLite {
20161957
static final Comparator<EnumValueDescriptor> BY_NUMBER =

ruby/src/main/java/BUILD.bazel

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
load("@rules_java//java:defs.bzl", "java_library", "java_lite_proto_library", "java_proto_library")
1+
load("@rules_java//java:defs.bzl", "java_library")
22
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
3-
load("@rules_proto//proto:defs.bzl", "proto_library")
43

54
java_library(
65
name = "protobuf_java",
@@ -21,21 +20,10 @@ java_library(
2120
],
2221
)
2322

24-
proto_library(
25-
name = "sentinel_proto",
26-
srcs = ["sentinel.proto"],
27-
)
28-
29-
java_proto_library(
30-
name = "sentinel_java_proto",
31-
deps = [":sentinel_proto"],
32-
)
33-
3423
pkg_files(
3524
name = "dist_files",
3625
srcs = glob([
3726
"**/*.java",
38-
"**/*.proto",
3927
]),
4028
strip_prefix = strip_prefix.from_root(""),
4129
visibility = ["//ruby:__pkg__"],

ruby/src/main/java/com/google/protobuf/jruby/RubyRepeatedField.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -400,35 +400,30 @@ protected int size() {
400400
}
401401

402402
private IRubyObject defaultValue(ThreadContext context) {
403-
SentinelOuterClass.Sentinel sentinel = SentinelOuterClass.Sentinel.getDefaultInstance();
404403
Object value;
405404
switch (fieldType) {
406405
case INT32:
407-
value = sentinel.getDefaultInt32();
408-
break;
409-
case INT64:
410-
value = sentinel.getDefaultInt64();
411-
break;
412406
case UINT32:
413-
value = sentinel.getDefaultUnit32();
407+
value = 0;
414408
break;
409+
case INT64:
415410
case UINT64:
416-
value = sentinel.getDefaultUint64();
411+
value = 0L;
417412
break;
418413
case FLOAT:
419-
value = sentinel.getDefaultFloat();
414+
value = 0F;
420415
break;
421416
case DOUBLE:
422-
value = sentinel.getDefaultDouble();
417+
value = 0D;
423418
break;
424419
case BOOL:
425-
value = sentinel.getDefaultBool();
420+
value = false;
426421
break;
427422
case BYTES:
428-
value = sentinel.getDefaultBytes();
423+
value = com.google.protobuf.ByteString.EMPTY;
429424
break;
430425
case STRING:
431-
value = sentinel.getDefaultString();
426+
value = "";
432427
break;
433428
case ENUM:
434429
IRubyObject defaultEnumLoc = context.runtime.newFixnum(0);

0 commit comments

Comments
 (0)