Commit graph

212 commits

Author SHA1 Message Date
Protobuf Team Bot
87f20a9cf9 More cleary document that Lite is targeting mobile client rather than server use.
PiperOrigin-RevId: 900254126
2026-04-15 11:11:02 -07:00
Protobuf Team Bot
5bfc1a239d Make Java lite equals much more efficient for oneofs.
This fixes https://github.com/protocolbuffers/protobuf/issues/26058

Mechanically, this adds tracking to MessageSchema in the intArray to include bufferIndex offsets of one member of each oneof in a message. Then in the equals function, when iterating all fields, we skip the oneof fields and do a supplemental pass over the intArray to cover the representative members of the oneofs.

In the course of adding this, I noticed we no longer needed the intArray to track repeated fields so I removed that. This means that this change is likely a net improvement in memory usage for MessageSchemas too as the number of oneofs in the universe of proto is likely much smaller than the number of repeated fields.

PiperOrigin-RevId: 877446720
2026-03-02 09:55:44 -08:00
Mark Hansen
6f67f26c40 Extract slow path function for schemaFor
schemaFor is a very hot method, called for every message we process. We only fall through to creating the schema the first time for each class, thereafter, the hot path is just getting from the ConcurrentHashMap.

Avoid R8 inlining the slow (less common) path of schemaFor. The inlining blows up the stack frame size and slows down the hot path.

PiperOrigin-RevId: 874384247
2026-02-23 22:37:59 -08:00
Protobuf Team Bot
20b2cd7623 Use StandardCharsets.UTF_8 instead of an Internal.UTF_8 variable.
This is a functional no-op but has fringe benefits.

Having having the constant in the Internal class makes it a static init property which has some small but undesirable implications. The specific prompt of making this change is that it was discovered that when appreduce is inline-eliminating an Internal.checkNotNull it still needs to emit the bytecode ensure that this static init is run, as the static init is an observable side effect of calling that method. The only actual side effect that this could have is if these threw an exception, which would actually be _extremely bad_ if it ever actually happened in reality, but never will throw with these particular string literals that we use, so slightly bloating bytecode just to maintain a "would break everything if its not a no-op" feels bad.

StandardCharsets was added in Java 7, and so this was not available to use when this design was initially set up.

PiperOrigin-RevId: 872430237
2026-02-19 09:18:01 -08:00
Protobuf Team Bot
e3e3e5fe56 Fix CodedInputStream streaming fixed-size reads for very small buffers
StreamDecoder now uses a minimum buffer size of 8 to ensure all fixed-width reads can be handled using the buffer. New tests are added to verify this behavior.

While here, create a test-only variant of ByteArrayInputStream that retains the same semantics as InputStream.read(byte[],int,int) for better test fidelity.

PiperOrigin-RevId: 868144899
2026-02-10 07:53:57 -08:00
Sandy Zhang
7beda33399 Clean up dead dist_files targets.
PiperOrigin-RevId: 851412528
2026-01-02 12:19:11 -08:00
Protobuf Team Bot
c224a3606f Use Locale.ROOT for all of our formatted error messages.
PiperOrigin-RevId: 846398642
2025-12-18 13:45:47 -08:00
Liam Miller-Cushon
77c47e9550 Automated Code Change
PiperOrigin-RevId: 830466970
2025-11-10 09:04:31 -08:00
Protobuf Team Bot
c4fa6e5293 Expose lite runtime as //java/lite:lite_nowkt
Since 079be27925, LITE_SRCS has been separated from the core and lite targets, but end users may still need to access the runtime in some cases.

Context: https://github.com/bazelbuild/bazel/pull/26477/files#diff-3053677e4333a96b20ed76c662bca07fb2e1ce059479170139209356787da09cL111
PiperOrigin-RevId: 783439169
2025-07-15 12:57:03 -07:00
Sandy Zhang
4c7b7a971c Restore custom protobuf maven namespaces to avoid polluting main maven namespace for non-dev dependencies as well.
Fixes #20674

PiperOrigin-RevId: 738081837
2025-03-18 11:31:17 -07:00
Protobuf Team Bot
28de0ebcdd Run buildifier
Adds missing loads for Java rules.
Remove unused loads.
Some other minor fixes.

PiperOrigin-RevId: 728701378
2025-02-19 09:27:02 -08:00
Adam Cozzette
0d42a969e3 Replace protobuf_unittest package with proto2_unittest
For historical reasons, our internal copy of the codebase uses
`proto2_unittest` while the open source one uses `protobuf_unittest`. This adds
a lot of friction to syncing between the two, and there's no great reason to
keep maintaining this difference, so let's just go with `proto2_unittest`.

PiperOrigin-RevId: 721951543
2025-01-31 17:06:33 -08:00
Joe Schafer
44660b306a Rename maven to protobuf_maven in MODULE.bazel (#18641)
The default name for the rules_jvm_external.maven rule is "maven". When not set, it defaults to "maven". For root modules also using rules_jvm_external, the name clash causes a warning:

```
DEBUG: $TMP/external/rules_jvm_external~/private/extensions/maven.bzl:154:14:
The maven repository 'maven' is used in two different bazel modules,
originally in '<my_workspace>' and now in 'protobuf'
```

Summarizing @shs96c in [1]:

> The common maven repo name allows rulesets to contribute to the user's JARs.
> However, this implies that maven is for the end user, not for transitive
> dependencies. If a ruleset needs private dependencies, it should use a custom
> namespace rather than the maven namespace.

Since protobuf is not contributing to user's JARs, we'll use a custom namespace. There's precedent for using a custom namespace for library modules:

- rules_jvm_external uses `rules_jvm_external_deps` instead of `maven`.
- rules_kotlin uses `kotlin_rules_maven` instead of `maven`.

[1]: https://github.com/bazel-contrib/rules_jvm_external/issues/916#issuecomment-1645527584

Fixes #16839.

Closes #18641

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/18641 from jschaf:joe/protobuf-maven bd2c62f311
PiperOrigin-RevId: 684625084
2024-10-10 17:02:43 -07:00
Protobuf Team Bot
a037f28ff8 Add recursion check when parsing unknown fields in Java.
PiperOrigin-RevId: 676061746
2024-09-18 11:32:17 -07:00
Protobuf Team Bot
939338d225 Internal change
PiperOrigin-RevId: 663919912
2024-08-16 17:00:36 -07:00
Deanna Garcia
f5ffaf9063 Remove unused pom.xml files.
We mostly use generated pom files in our release currently, so we can delete all the files that aren't used and the tools to update them.

Note, java/bom/pom.xml java/pom.xml and java/protoc/pom.xml are all still used at release and java/kotlin/pom.xml is used for documentation so all of those need to stay for now.

PiperOrigin-RevId: 659664012
2024-08-05 13:41:00 -07:00
Protobuf Team Bot
cc8b3483a5 Internal change
PiperOrigin-RevId: 653615736
2024-07-18 07:45:22 -07:00
zhangskz
8e60d9f166 Updating version.json and repo version numbers to: 29.0-dev (#17432)
NOTE: This should be reviewed and imported via Copybara per the normal PR review process.

Closes #17432

PiperOrigin-RevId: 652511521
2024-07-15 09:50:38 -07:00
Protobuf Team Bot
fefec68753 Internal changes/optimizations
PiperOrigin-RevId: 632294209
2024-05-09 15:54:16 -07:00
Protobuf Team Bot
f597991857 Return the default instance when parsing from an empty byte[].
PiperOrigin-RevId: 631213831
2024-05-06 16:05:29 -07:00
Mike Kruskal
95877d8569 Updating version.json and repo version numbers to: 28-dev (#16555)
Closes #16555

PiperOrigin-RevId: 626081638
2024-04-18 10:47:14 -07:00
Mike Kruskal
ea81024ddf Refactor editions infrastructure to a top-level directory.
The only public target here is the edition defaults helper macro, which can be used by external runtimes and plugins.  None of this code is C++-specific though, and should be organized higher up.  Appropriate aliases are also placed at the top level for public targets

PiperOrigin-RevId: 625392504
2024-04-16 11:13:19 -07:00
Protobuf Team Bot
21d75f861c Remove references to rules_proto
They are not needed after the rules are move into protobuf repo.
Except for the reference to toolchain type, which is currently in rules_proto and can be moved after the implementation is moved into protobuf repo.

PiperOrigin-RevId: 622176865
2024-04-05 07:50:25 -07:00
Sandy Zhang
274bc7f26f Move java_features.proto to java/core/srce/main/resources
This also fixes maven to package this correctly as google/protobuf/java_features.proto (same dir as WKT/descriptor.proto) instead of com/google/protobuf/java_features.proto.

Fixes https://github.com/protocolbuffers/protobuf/issues/16155

PiperOrigin-RevId: 619015714
2024-03-25 18:01:21 -07:00
Sandy Zhang
500c953d10 Enable editions support for Java Lite.
java_features.proto and descriptor.proto should now both be included in the Java Lite and Kotlin Lite maven releases.

Fixes https://github.com/protocolbuffers/protobuf/issues/7331

PiperOrigin-RevId: 618251348
2024-03-22 12:13:06 -07:00
Sam Gammon
742ddf1155 fix(java): fixup test codegen for maven build (#16176)
## Summary

Fixes and closes protocolbuffers/protobuf#16170 by adding missing test-gen mappings and exclusions. Recent [changes](https://github.com/protocolbuffers/protobuf/pull/15362) to Protocol Buffers, along with the addition of the _Editions_ feature, have evolved ahead of Maven; running the build on `main` shows build errors related to the testsuite.

## Changelog

- fix: missing test-gen mappings
- fix: missing test exclusions

Closes #16176

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/16176 from sgammon:fix/issue-16170 2be118cf9a
PiperOrigin-RevId: 616310039
2024-03-15 19:33:32 -07:00
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
2024-02-13 09:08:42 -08:00
Dennis Shao
9146ce6ddb Updating version.json and repo version numbers to: 27-dev (#15590)
Closes #15590

PiperOrigin-RevId: 601468713
2024-01-25 09:18:51 -08:00
Protobuf Team Bot
6f86726f26 Rollback version validations in Protobuf Java Lite.
PiperOrigin-RevId: 601122259
2024-01-24 08:05:00 -08:00
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
2024-01-11 13:46:48 -08:00
Protobuf Team Bot
a2f92689da Protobuf Java Cross-version validation in OSS.
PiperOrigin-RevId: 585139332
2023-11-24 13:27:33 -08:00
Protobuf Team Bot
318d310e64 Create RuntimeVersion.java that is updated with releases to prepare version check.
PiperOrigin-RevId: 584346836
2023-11-21 09:27:04 -08:00
Jie Luo
1231af10c7 merge 25.x to main (#14617)
Closes #14617

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/14617 from anandolee:25.x ac86c5ef32
PiperOrigin-RevId: 578996979
2023-11-02 15:29:36 -07:00
Protobuf Team Bot
3ea774370a Internal change
PiperOrigin-RevId: 578944754
2023-11-02 13:34:12 -07:00
Protobuf Team Bot
6b5d8db01f Updating version.json and repo version numbers to: 25.0 2023-11-01 13:03:44 -07:00
Protobuf Team Bot
ba1aab2baf Updating version.json and repo version numbers to: 25.0-rc2 2023-10-18 09:57:30 -07:00
Protobuf Team Bot
896f3d8ced Updating version.json and repo version numbers to: 25.0-rc1 2023-10-16 12:36:52 -07:00
Sandy Zhang
81068e8e8c Internal change
PiperOrigin-RevId: 566426899
2023-09-18 15:17:56 -07:00
Joshua Haberman
40d69fd51f Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full.
PiperOrigin-RevId: 563953121
2023-09-09 00:12:07 -07:00
ericsalo
843b74e601 Main 202308091812 (#13489)
Closes #13489

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13489 from protocolbuffers:main-202308091812 e729f0bf5a
PiperOrigin-RevId: 555301642
2023-08-09 16:02:04 -07:00
Protobuf Team Bot
aba9a7f1a3 Internal change
PiperOrigin-RevId: 555251853
2023-08-09 13:09:58 -07:00
Protobuf Team Bot
093e258a71 Updating version.json and repo version numbers to: 24.0 2023-08-08 10:26:14 -07:00
Protobuf Team Bot
3487ae0c01 Updating version.json and repo version numbers to: 24.0-rc3 2023-08-01 10:27:01 -07:00
Protobuf Team Bot
034ec9d9f6 Updating version.json and repo version numbers to: 24.0-rc2 2023-07-18 11:50:33 -07:00
Protobuf Team Bot
05835e374d Updating version.json and repo version numbers to: 24.0-rc1 2023-07-11 14:54:12 -07:00
deannagarcia
0e23f18865 Merge to main after 23.0 release (#12721)
Closes #12721

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12721 from protocolbuffers:main-202305082101 36482b4c68
PiperOrigin-RevId: 530664393
2023-05-09 11:28:29 -07:00
Protobuf Team Bot
67d9ea87f3 Internal change
PiperOrigin-RevId: 530619366
2023-05-09 09:27:53 -07:00
Protobuf Team Bot
6e511679de Updating version.json and repo version numbers to: 23.0 2023-05-08 09:48:50 -07:00
Protobuf Team Bot
d8f44cc2fb Updating version.json and repo version numbers to: 23.0-rc3 2023-05-05 09:17:00 -07:00
Protobuf Team Bot
51f51ac4ef Updating version.json and repo version numbers to: 23.0-rc2 2023-04-28 10:25:19 -07:00