Sandy Zhang
9f001a9658
Fix descriptor to access type via getType() s.t. messages using delimited encoding are consistently treated as groups for Java lite.
...
This should fix InvalidWireTypeException in the case of getLiteType() not treating messages with delimited encoding as groups: http://shortn/_2TEPuwIj6P
getJavaType() and needsUtf8Check() changes are no-ops since the type is the same regardless, but these are updated for consistency.
PiperOrigin-RevId: 612972996
9 months ago
Protobuf Team Bot
0070ac1188
Make UnsafeByteOperations stable; removing experimental annotation.
...
PiperOrigin-RevId: 610787227
9 months ago
Sandy Zhang
8a17f5ddeb
Resolve features directly in setProto instead of temporarily setting to null.
...
Avoid potential races with other threads reading features that do not share a lock while features are temporarily null.
Special handling for proto1 mutable should not actually be needed, since setProto doesn't update dependency protos.
PiperOrigin-RevId: 610783483
9 months ago
Sandy Zhang
eb10ebd169
Fix features inheritance of oneof fields and extensions and fix/move unit tests to actually run.
...
JUnit4 does not support nested tests so these weren't running. Fixes setup problems and test logic. Oneof fields now inherit from their oneof, and top-level extensions inherit from top-level file when parent descriptor is null.
PiperOrigin-RevId: 609840087
9 months ago
Protobuf Team Bot
5d876c9fec
Point to released versions in Java Protobuf (lite) READMEs instead of the the next, unreleased version.
...
https://github.com/protocolbuffers/protobuf/issues/15878
PiperOrigin-RevId: 609488730
9 months ago
Protobuf Team Bot
976a6eb6a4
Rolling back while figuring out why some tests failed.
...
PiperOrigin-RevId: 607458035
9 months ago
Protobuf Team Bot
1f9b71e9dd
Check if the number of seconds is valid for a timestamp before creating a
...
normalized timestamp.
Without this change, an input of `9223372036854775807, 2` leads to a java.lang.ArithmeticException: overflow.
PiperOrigin-RevId: 607359958
9 months ago
Ian Baker
89bea36856
Document that `Timestamps.parse` might emit zero fractional digits
...
PiperOrigin-RevId: 606870523
10 months ago
aiuto
3ab1276bbb
Update Bazel references to rules_pkg to the supported file locations. ( #15780 )
...
WIP: I want to see this pass CI first.
Fixes : #15779
3 scripted transforms:
```
-load("@rules_pkg//:mappings.bzl", ...)
+load("@rules_pkg//pkg:mappings.bzl", ...)
```
```
-load("@rules_pkg//:pkg.bzl", "pkg_tar")
+load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
```
```
-load("@rules_pkg//:pkg.bzl", "pkg_zip")
+load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
```
Closes #15780
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/15780 from aiuto:rules_pkg a630276341
PiperOrigin-RevId: 606641398
10 months ago
Jiri Pechanec
c98bdc2bdc
Add missing generated file ( #15693 )
...
The proto file is required for Java test. Otherwise it fails with
```
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:testCompile (default-testCompile) on project protobuf-java: Compilation failure: Compilation failure:
[ERROR] /tmp/protocolbuffers-protobuf-3.25.2/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java:[46,25] cannot find symbol
[ERROR] symbol: class UnittestRetention
[ERROR] location: package protobuf_unittest
[ERROR] /tmp/protocolbuffers-protobuf-3.25.2/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java:[550,27] cannot find symbol
[ERROR] symbol: variable UnittestRetention
[ERROR] location: class com.google.protobuf.DescriptorsTest
[ERROR] /tmp/protocolbuffers-protobuf-3.25.2/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java:[551,37] cannot find symbol
[ERROR] symbol: variable UnittestRetention
[ERROR] location: class com.google.protobuf.DescriptorsTest
[ERROR] /tmp/protocolbuffers-protobuf-3.25.2/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java:[552,37] cannot find symbol
[ERROR] symbol: variable UnittestRetention
[ERROR] location: class com.google.protobuf.DescriptorsTest
[ERROR] /tmp/protocolbuffers-protobuf-3.25.2/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java:[553,37] cannot find symbol
[ERROR] symbol: variable UnittestRetention
[ERROR] location: class com.google.protobuf.DescriptorsTest
[ERROR] -> [Help 1]
```
Closes #15693
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/15693 from jpechane:add-missing-file 9293fabf1f
PiperOrigin-RevId: 604518500
10 months ago
Luke Sandberg
5d4fd7ef84
Clarify docs on MapFieldReflectionAccessorInternal and add tests for the mutability of lists returned from `getAllFields()`
...
PiperOrigin-RevId: 604508075
10 months ago
Chris Kennelly
34a04c1fd5
Remove lazy=true from repeated fields.
...
This is currently a no-op in protoc.
PiperOrigin-RevId: 604457261
10 months ago
Protobuf Team Bot
2699579875
Breaking change: Remove the deprecated always_print_primitive_fields option from Java, Python and C++ JSON parsers.
...
The replacement always_print_without_presence_fields should be used instead, which is very similar but has consistent handling of optional fields by not affecting them.
PiperOrigin-RevId: 604381178
10 months ago
Protobuf Team Bot
986d691d77
use "proto3_optional" option as signal that a field has presence.
...
This is technically redundant with the synthetic oneof container, but simplifies some tooling.
PiperOrigin-RevId: 604368850
10 months ago
Protobuf Team Bot
7d43131a0a
Rename the 'includingDefaultValueWithoutPresenceFields' and 'always_print_without_presence_fields' to 'alwaysPrintFieldsWithNoPresence' in the Cpp, Py and Java JSON serializers for consistency.
...
PiperOrigin-RevId: 604292220
10 months ago
Sandy Zhang
2faa9d1a5f
Force descriptor initialization of dependencies *before* internalUpdateFileDescriptor().
...
This fixes an edge-case where EnumDescriptor for a custom option may be unresolved if used in the same file, since adding the field to ExtensionRegistry doesn't trigger its static init block if the Enum is imported from a dependency.
Also renames feature resolution methods exposed from gencode. Private resolveAllFeaturesInternal() method may be renamed back to resolveAllFeatures() in a followup change.
PiperOrigin-RevId: 603852391
10 months ago
Sandy Zhang
9252b64ef3
Automated rollback of commit 0ee34d35de
.
...
PiperOrigin-RevId: 603802046
10 months ago
Protobuf Team Bot
3924ea28cc
Automated rollback of commit 531d4372f4
.
...
PiperOrigin-RevId: 603728275
10 months ago
lowasser
0ee34d35de
Simplify (and optimize) Descriptors.FileDescriptor.latin1Cat.
...
PiperOrigin-RevId: 603529248
10 months ago
Protobuf Team Bot
d111589bc0
Add a new 'includingDefaultValueWithoutPresenceFields' option to the Java parser which is intended to replace the current 'includingDefaultValueFields'.
...
The old flag accidentally had inconsistent behavior between proto2 optional and proto3 optional fields, the new flag treats them consistently (and is consistent with the preexisting behavior of the Go JSON serializer).
includingDefaultValueFields is now deprecated and will be removed in an upcoming release.
PiperOrigin-RevId: 603449195
10 months ago
Protobuf Team Bot
44ec9d9e86
Automated rollback of commit 58baeb4c3b
.
...
PiperOrigin-RevId: 602770552
10 months ago
Luke Sandberg
531d4372f4
Internal change
...
PiperOrigin-RevId: 602736730
10 months ago
Protobuf Team Bot
58baeb4c3b
Add a new 'includingDefaultValueWithoutPresenceFields' option to the Java parser which is intended to replace the current 'includingDefaultValueFields'.
...
The old flag accidentally had inconsistent behavior between proto2 optional and proto3 optional fields, the new flag treats them consistently (and is consistent with the preexisting behavior of the Go JSON serializer).
PiperOrigin-RevId: 602711486
10 months ago
Sandy Zhang
85938aa654
Update internalUpdateFileDescriptor() to synchronize setProto() and resolveAllFeatures() to avoid data races.
...
PiperOrigin-RevId: 601628994
10 months ago
Dennis Shao
9146ce6ddb
Updating version.json and repo version numbers to: 27-dev ( #15590 )
...
Closes #15590
PiperOrigin-RevId: 601468713
10 months ago
Sandy Zhang
17729cc5e5
Call ExtensionRegistry.add for JavaFeaturesProto.java directly.
...
PiperOrigin-RevId: 601200193
10 months ago
Protobuf Team Bot
6f86726f26
Rollback version validations in Protobuf Java Lite.
...
PiperOrigin-RevId: 601122259
10 months ago
Sandy Zhang
303239d74d
Drop Protobuf support for Android KitKat per EOL and add existing minimum Java 1.8 in Maven pom.xmls
...
See https://android-developers.googleblog.com/2023/07/google-play-services-discontinuing-updates-for-kitkat.html for more details on Android KitKat EOL.
PiperOrigin-RevId: 600609333
10 months ago
Protobuf Team Bot
659b3e7102
Internal changes.
...
PiperOrigin-RevId: 600609161
10 months ago
Protobuf Team Bot
787447430f
Breaking Change: Remove unused helper methods for creating new mutable arraylists.
...
PiperOrigin-RevId: 600581644
10 months ago
Sandy Zhang
35a6730e61
Add private constructor for JavaEditionDefaults template
...
PiperOrigin-RevId: 600548126
10 months ago
Sandy Zhang
882e7843de
Mark descriptor features as volatile to avoid data races in double-checked locking
...
PiperOrigin-RevId: 600547519
10 months ago
Protobuf Team Bot
8b92099937
Checks that only lite or full binding could exist in a process.
...
PiperOrigin-RevId: 600537100
10 months ago
Sandy Zhang
65c65c2d04
Breaking Change: Use Editions features in Java full runtimes.
...
This change breaks compatibility with old generated code from previous major versions per the Cross Version Runtime policy: https://protobuf.dev/support/cross-version-runtime-guarantee . This includes old gencode from <4.26.x, which does not resolve features.
See https://protobuf.dev/news/2023-12-05/
PiperOrigin-RevId: 600487923
10 months ago
Protobuf Team Bot
c0d08bdcad
Breaking Change: Stop generating the "newInstance" method. This is not used anymore.
...
PiperOrigin-RevId: 600123108
10 months ago
Protobuf Team Bot
adacf6d0e1
Use char indexOf rather than String, which can have a fast path implementation
...
PiperOrigin-RevId: 599529561
10 months ago
Protobuf Team Bot
979c39178b
Format CodedInputStream & Test
...
PiperOrigin-RevId: 599528929
10 months ago
Joshua Haberman
9188b39fb7
Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full.
...
PiperOrigin-RevId: 599218886
10 months ago
Protobuf Team Bot
854ca49520
Internal versioning changes.
...
PiperOrigin-RevId: 598625150
11 months ago
Protobuf Team Bot
3b9bd6db71
Breaking Change: Remove unused overload of AbstractMessageLite.addAll that worked on a Collection instead of a List.
...
PiperOrigin-RevId: 597869849
11 months ago
Protobuf Team Bot
9310d2e817
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
11 months ago
Sandy Zhang
519284a559
Remove LegacyDescriptorsUtil.java and JRuby's use of legacy descriptor APIs
...
This is not a breaking change since this has not been released yet.
PiperOrigin-RevId: 597824548
11 months ago
Protobuf Team Bot
94a2a44851
Breaking Change: remove unnecessary overloads of methods:
...
hasExtension
getExtensionCount
getExtension
PiperOrigin-RevId: 597702196
11 months ago
Protobuf Team Bot
5df0387224
Breaking Change: The base class for generated messages will be
...
GeneratedMessage, not GeneratedMessageV3.
Please rerun protoc on your .proto files to regenerate the binding code.
https://protobuf.dev/news/2023-12-05/
https://protobuf.dev/support/cross-version-runtime-guarantee/
To fix source compatibility with surrounding code make these replacements:
GeneratedMessageV3 --> GeneratedMessage
SingleFieldBuilderV3 --> SingleFieldBuilder
RepeatedFieldBuilderV3 --> RepeatedFieldBuilder
PiperOrigin-RevId: 597642289
11 months ago
Sandy Zhang
63623a688c
Remove public access to Java Edition APIs e.g. getEdition(), getEditionName().
...
Editions should not be used to make semantic decisions -- specific helpers (e.g. FieldDescriptor.hasPresence()) should be used instead. FileDescriptorProto can be used to access editions for *non semantic* purposes, incl. with ProtoFileUti.
These APIs have not been released yet and are thus non-breaking.
PiperOrigin-RevId: 597362543
11 months ago
Sandy Zhang
592ee9b192
Update to call descriptor outer class's getDescriptor() method instead of accessing internal descriptor variable directly.
...
PiperOrigin-RevId: 597355223
11 months ago
Adam Cozzette
4ec9170bcd
Fix layering check for usage of gtest
...
To satisfy the layering check, we need to depend on :gtest for the headers, in
addition to :gtest_main which provides the main() function.
There are a bunch of formatting changes as a side effect of this, but they
should be harmless.
PiperOrigin-RevId: 594318263
11 months ago
Protobuf Team Bot
b10d3f93b6
Avoid interface calls in hot loop
...
Before, every charAt would emit (on android):
```
0x00002104 adrp x17, #+0x1000 (addr 0x3000)
0x00002108 ldr w17, [x17, #20 ]
0x0000210c ldr x0, [x0, #128 ]
0x00002110 ldr x0, [x0, #328 ]
0x00002114 ldr lr, [x0, #24 ]
0x00002118 blr lr <-- Call into String.charAt(int)
```
Now, it emits the inlined implementation of charAt (branch is for possibly compressed strings):
```
0x000020b4 ldur w16, [x4, #-8]
0x000020b8 tbnz w16, #0 , #+0xc (addr 0x20c4)
0x000020bc ldrb w4, [x4, x0]
0x000020c0 b #+0x8 (addr 0x20c8)
0x000020c4 ldrh w4, [x4, x0, lsl #1 ]
```
PiperOrigin-RevId: 591147406
12 months ago
Protobuf Team Bot
220415ddfb
Swap order of masks when assigning bytes to byte[] elements.
...
Masking a byte by 0xFF does nothing, and the optimizer can see that. I don't think these 0xFF masks do anything in java... but they're in a lot of places so if we remove them entirely it'll be in another CL.
Before (android):
```
ldr w3, [x1, #12 ]
and w4, w2, #0x7f
orr w4, w4, #0x80
add w5, w3, #0x1 (1)
sxtb w4, w4
```
after:
```
ldr w3, [x1, #12 ]
orr w4, w2, #0x80
add w5, w3, #0x1 (1)
sxtb w4, w4
```
PiperOrigin-RevId: 591117756
12 months ago
Protobuf Team Bot
0a2f7757e3
Branch-free varint size calculation. On android art, compiles to:
...
```
int com.google.android.test.Outer.computeUInt32SizeNoTag(int) [24 bytes]
0x000024d0 mov w0, #0x160
0x000024d4 clz w1, w1
0x000024d8 add w1, w1, w1, lsl #3
0x000024dc sub w0, w0, w1
0x000024e0 lsr w0, w0, #6
0x000024e4 ret
```
versus existing:
```
int com.google.android.test.Outer.computeUInt32SizeNoTag(int) [72 bytes]
0x000022a0 and w0, w1, #0xffffff80
0x000022a4 cbnz w0, #+0xc (addr 0x22b0)
0x000022a8 mov w0, #0x1
0x000022ac b #+0x38 (addr 0x22e4)
0x000022b0 and w0, w1, #0xffffc000
0x000022b4 cbnz w0, #+0xc (addr 0x22c0)
0x000022b8 mov w0, #0x2
0x000022bc b #+0x28 (addr 0x22e4)
0x000022c0 and w0, w1, #0xffe00000
0x000022c4 cbnz w0, #+0xc (addr 0x22d0)
0x000022c8 mov w0, #0x3
0x000022cc b #+0x18 (addr 0x22e4)
0x000022d0 mov w2, #0x5
0x000022d4 mov w0, #0x4
0x000022d8 and w1, w1, #0xf0000000
0x000022dc cmp w1, #0x0 (0)
0x000022e0 csel w0, w2, w0, ne
0x000022e4 ret
```
PiperOrigin-RevId: 591113652
12 months ago