Skip to content

Commit 6e8a7a2

Browse files
l46kokcopybara-github
authored andcommitted
Internal Changes
PiperOrigin-RevId: 834975953
1 parent efba831 commit 6e8a7a2

File tree

62 files changed

+1603
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1603
-622
lines changed

bundle/src/main/java/dev/cel/bundle/CelBuilder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ public interface CelBuilder {
197197
* provider will be used first before falling back to the built-in {@link
198198
* dev.cel.common.values.ProtoMessageValueProvider} for resolving protobuf messages.
199199
*
200-
* <p>Note that {@link CelOptions#enableCelValue()} must be enabled or this method will be a
201-
* no-op.
200+
* <p>Note that this option is only supported for planner-based runtime.
202201
*/
203202
@CanIgnoreReturnValue
204203
CelBuilder setValueProvider(CelValueProvider celValueProvider);

bundle/src/test/java/dev/cel/bundle/CelImplTest.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -556,24 +556,6 @@ public void program_withVars() throws Exception {
556556
assertThat(program.eval(ImmutableMap.of("variable", "hello"))).isEqualTo(true);
557557
}
558558

559-
@Test
560-
public void program_withCelValue() throws Exception {
561-
Cel cel =
562-
standardCelBuilderWithMacros()
563-
.setOptions(CelOptions.current().enableCelValue(true).build())
564-
.addDeclarations(
565-
Decl.newBuilder()
566-
.setName("variable")
567-
.setIdent(IdentDecl.newBuilder().setType(CelProtoTypes.STRING))
568-
.build())
569-
.setResultType(SimpleType.BOOL)
570-
.build();
571-
572-
CelRuntime.Program program = cel.createProgram(cel.compile("variable == 'hello'").getAst());
573-
574-
assertThat(program.eval(ImmutableMap.of("variable", "hello"))).isEqualTo(true);
575-
}
576-
577559
@Test
578560
public void program_withProtoVars() throws Exception {
579561
Cel cel =
@@ -1419,26 +1401,6 @@ public void programAdvanceEvaluation_nestedSelect() throws Exception {
14191401
.isEqualTo(CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("com.google.a")));
14201402
}
14211403

1422-
@Test
1423-
public void programAdvanceEvaluation_nestedSelect_withCelValue() throws Exception {
1424-
Cel cel =
1425-
standardCelBuilderWithMacros()
1426-
.setOptions(
1427-
CelOptions.current().enableUnknownTracking(true).enableCelValue(true).build())
1428-
.addVar("com", MapType.create(SimpleType.STRING, SimpleType.DYN))
1429-
.addFunctionBindings()
1430-
.setResultType(SimpleType.BOOL)
1431-
.build();
1432-
CelRuntime.Program program = cel.createProgram(cel.compile("com.google.a || false").getAst());
1433-
1434-
assertThat(
1435-
program.advanceEvaluation(
1436-
UnknownContext.create(
1437-
fromMap(ImmutableMap.of()),
1438-
ImmutableList.of(CelAttributePattern.fromQualifiedIdentifier("com.google.a")))))
1439-
.isEqualTo(CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("com.google.a")));
1440-
}
1441-
14421404
@Test
14431405
public void programAdvanceEvaluation_argumentMergeErrorPriority() throws Exception {
14441406
Cel cel =

common/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ java_library(
2222
exports = ["//common/src/main/java/dev/cel/common:container"],
2323
)
2424

25+
cel_android_library(
26+
name = "container_android",
27+
exports = ["//common/src/main/java/dev/cel/common:container_android"],
28+
)
29+
2530
java_library(
2631
name = "proto_ast",
2732
exports = ["//common/src/main/java/dev/cel/common:proto_ast"],

common/exceptions/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ java_library(
5353
exports = ["//common/src/main/java/dev/cel/common/exceptions:iteration_budget_exceeded"],
5454
)
5555

56+
java_library(
57+
name = "duplicate_key",
58+
# used_by_android
59+
exports = ["//common/src/main/java/dev/cel/common/exceptions:duplicate_key"],
60+
)
61+
5662
java_library(
5763
name = "overload_not_found",
5864
# used_by_android

common/src/main/java/dev/cel/common/BUILD.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,18 @@ java_library(
341341
],
342342
)
343343

344+
cel_android_library(
345+
name = "container_android",
346+
srcs = ["CelContainer.java"],
347+
tags = [
348+
],
349+
deps = [
350+
"//:auto_value",
351+
"@maven//:com_google_errorprone_error_prone_annotations",
352+
"@maven_android//:com_google_guava_guava",
353+
],
354+
)
355+
344356
java_library(
345357
name = "operator",
346358
srcs = ["Operator.java"],

common/src/main/java/dev/cel/common/CelOptions.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.google.auto.value.AutoValue;
1818
import com.google.errorprone.annotations.CheckReturnValue;
1919
import com.google.errorprone.annotations.Immutable;
20-
import dev.cel.common.annotations.Beta;
2120

2221
/**
2322
* Options to configure how the CEL parser, type-checker, and evaluator behave.
@@ -105,8 +104,6 @@ public enum ProtoUnsetFieldOptions {
105104

106105
public abstract boolean enableUnknownTracking();
107106

108-
public abstract boolean enableCelValue();
109-
110107
public abstract int comprehensionMaxIterations();
111108

112109
public abstract boolean evaluateCanonicalTypesToNativeValues();
@@ -162,7 +159,6 @@ public static Builder newBuilder() {
162159
.errorOnDuplicateMapKeys(false)
163160
.resolveTypeDependencies(true)
164161
.enableUnknownTracking(false)
165-
.enableCelValue(false)
166162
.comprehensionMaxIterations(-1)
167163
.unwrapWellKnownTypesOnFunctionDispatch(true)
168164
.fromProtoUnsetFieldOption(ProtoUnsetFieldOptions.BIND_DEFAULT)
@@ -432,16 +428,6 @@ public abstract static class Builder {
432428
*/
433429
public abstract Builder enableUnknownTracking(boolean value);
434430

435-
/**
436-
* Enables the usage of {@code CelValue} for the runtime. It is a native value representation of
437-
* CEL that wraps Java native objects, and comes with extended capabilities, such as allowing
438-
* value constructs not understood by CEL (ex: POJOs).
439-
*
440-
* <p>Warning: This option is experimental.
441-
*/
442-
@Beta
443-
public abstract Builder enableCelValue(boolean value);
444-
445431
/**
446432
* Limit the total number of iterations permitted within comprehension loops.
447433
*

common/src/main/java/dev/cel/common/exceptions/BUILD.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@ java_library(
111111
],
112112
)
113113

114+
java_library(
115+
name = "duplicate_key",
116+
srcs = ["CelDuplicateKeyException.java"],
117+
# used_by_android
118+
tags = [
119+
],
120+
deps = [
121+
":runtime_exception",
122+
"//common:error_codes",
123+
"//common/annotations",
124+
],
125+
)
126+
114127
java_library(
115128
name = "overload_not_found",
116129
srcs = ["CelOverloadNotFoundException.java"],
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2026 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package dev.cel.common.exceptions;
16+
17+
import dev.cel.common.CelErrorCode;
18+
import dev.cel.common.annotations.Internal;
19+
20+
/** Indicates an attempt to create a map using duplicate keys. */
21+
@Internal
22+
public final class CelDuplicateKeyException extends CelRuntimeException {
23+
24+
public static CelDuplicateKeyException of(Object key) {
25+
return new CelDuplicateKeyException(String.format("duplicate map key [%s]", key));
26+
}
27+
28+
private CelDuplicateKeyException(String message) {
29+
super(message, CelErrorCode.DUPLICATE_ATTRIBUTE);
30+
}
31+
}

common/src/main/java/dev/cel/common/types/BUILD.bazel

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,32 @@ java_library(
183183
],
184184
)
185185

186+
java_library(
187+
name = "message_lite_type_provider",
188+
srcs = [
189+
"ProtoMessageLiteTypeProvider.java",
190+
],
191+
tags = [
192+
],
193+
deps = [
194+
"//common/types",
195+
"//common/types:type_providers",
196+
"//protobuf:cel_lite_descriptor",
197+
"@maven//:com_google_guava_guava",
198+
],
199+
)
200+
201+
cel_android_library(
202+
name = "message_lite_type_provider_android",
203+
srcs = [
204+
"ProtoMessageLiteTypeProvider.java",
205+
],
206+
tags = [
207+
],
208+
deps = [
209+
],
210+
)
211+
186212
java_library(
187213
name = "default_type_provider",
188214
srcs = [
@@ -197,6 +223,20 @@ java_library(
197223
],
198224
)
199225

226+
cel_android_library(
227+
name = "default_type_provider_android",
228+
srcs = [
229+
"DefaultTypeProvider.java",
230+
],
231+
tags = [
232+
],
233+
deps = [
234+
"//common/types:type_providers_android",
235+
"//common/types:types_android",
236+
"@maven_android//:com_google_guava_guava",
237+
],
238+
)
239+
200240
cel_android_library(
201241
name = "cel_types_android",
202242
srcs = ["CelTypes.java"],

common/src/main/java/dev/cel/common/types/DefaultTypeProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717
import com.google.common.collect.ImmutableCollection;
1818
import com.google.common.collect.ImmutableMap;
19+
import com.google.errorprone.annotations.Immutable;
1920
import java.util.Optional;
2021

2122
/** {@code DefaultTypeProvider} is a registry of common CEL types. */
23+
@Immutable
2224
public class DefaultTypeProvider implements CelTypeProvider {
2325

2426
private static final DefaultTypeProvider INSTANCE = new DefaultTypeProvider();

0 commit comments

Comments
 (0)