Mike Kruskal
dc484c131e
Fix has_presence to account for proto3 extensions in Java.
...
PiperOrigin-RevId: 613373080
9 months ago
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
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
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
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
Luke Sandberg
531d4372f4
Internal change
...
PiperOrigin-RevId: 602736730
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
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
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
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
Sandy Zhang
e555bd23d0
Breaking change: Remove deprecated runtime methods for compatibility with old v2.x.x gencode.
...
These methods were deprecated as of 3.0.0 and were originally added for compatibility with gencode from old major versions (v2.x.x.) which are long out of our Cross Version Runtime Guarantees: https://protobuf.dev/support/cross-version-runtime-guarantee/
PiperOrigin-RevId: 587099512
1 year ago
Sandy Zhang
dfb8a4c3f7
Breaking change: Remove deprecated TextFormat print methods. These should be replaced by corresponding TextFormat.printer() methods.
...
These methods have been deprecated as of v3.9.0 (09cab821a9
).
PiperOrigin-RevId: 587088638
1 year ago
Protobuf Team Bot
fedcd62136
Prepare methods in RuntimeVersion for Protobuf Java cross-domain version validation. No changes to Protobuf Java gencode yet.
...
PiperOrigin-RevId: 587025016
1 year ago
Protobuf Team Bot
c8e01607ae
Support pretty printing proto2 Extensions inside of proto3 Anys in TextFormat.Printer.
...
In Java, in order to include Extensions inside a proto message, the ExtensionRegistry for the extensions must be included during deserialization, otherwise they are treated as unknown fields.
This change adds support for providing an ExtensionRegistry for TextFormat.Printer which is then used during Any deserialization.
PiperOrigin-RevId: 586807633
1 year ago
Sandy Zhang
1aeacd4f4e
Breaking change: Lock down visibility for descriptor syntax APIs.
...
Users should migrate to corresponding feature accessors (e.g. FieldDescriptor.hasPresence, EnumDescriptor.isClosed) instead of deriving these based on syntax, which will break after under Editions (https://protobuf.dev/editions/overview/ )
PiperOrigin-RevId: 586518687
1 year ago
Sandy Zhang
80337cb884
Automated rollback of commit 30b6251dea
.
...
PiperOrigin-RevId: 586513152
1 year ago
Protobuf Team Bot
a2f92689da
Protobuf Java Cross-version validation in OSS.
...
PiperOrigin-RevId: 585139332
1 year ago
Protobuf Team Bot
318d310e64
Create `RuntimeVersion.java` that is updated with releases to prepare version check.
...
PiperOrigin-RevId: 584346836
1 year ago
Protobuf Team Bot
81607b267c
Fix FieldSet to not load lazy fields when the fields map is cloned. In particular, if MessageSet.Builder has build() called on it, but is then later further modified, we don't need to pre-load all lazy fields during this later modification.
...
PiperOrigin-RevId: 581941605
1 year ago
Protobuf Team Bot
2ec703fcc1
Preserve lazy fields when merging FieldSets. In particular, when calling toBuilder() on a MessageSet with lazily-parsed extensions, don't eagerly parse all extensions.
...
PiperOrigin-RevId: 580492290
1 year ago
Sandy Zhang
0f1ab75dbe
Add empty feature resolution method for FileDescriptor to Java runtime.
...
PiperOrigin-RevId: 579981476
1 year ago