Skip to content

Commit 892e0d5

Browse files
Fix handling of optional dependencies in java generator.
Java reflection is used to fail smoothly when the extensions aren't found in the classpath. PiperOrigin-RevId: 805477788
1 parent d365736 commit 892e0d5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎java/core/src/test/java/com/google/protobuf/ImportOptionTest.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public void testImportOption() throws Exception {
2626
UnknownFieldSet unknownFieldsMessage = messageDescriptor.getOptions().getUnknownFields();
2727
UnknownFieldSet unknownFieldsField = fieldDescriptor.getOptions().getUnknownFields();
2828

29+
// Using the extension ensures UnittestCustomOptions is linked in and referenced
2930
assertThat(fileDescriptor.getOptions().getExtension(UnittestCustomOptions.fileOpt1))
3031
.isEqualTo(1);
3132
assertThat(messageDescriptor.getOptions().getExtension(UnittestCustomOptions.messageOpt1))
@@ -34,7 +35,7 @@ public void testImportOption() throws Exception {
3435
.isEqualTo(3);
3536

3637
// TODO: Since `option_deps` are treated as `deps` in Bazel 7, the unknown
37-
// fields are not empty. Once we drop Bazel 7 support we can test that these are filled with
38+
// fields will be empty. Once we drop Bazel 7 support we can test that these are filled with
3839
// unknown fields.
3940
assertThat(unknownFieldsFile.asMap().size()).isAtMost(1);
4041
assertThat(unknownFieldsMessage.asMap().size()).isAtMost(1);

0 commit comments

Comments
 (0)