This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fury.git
The following commit(s) were added to refs/heads/main by this push:
new 2f64ade0 fix(java): fix reserved keyword conflict (#1819)
2f64ade0 is described below
commit 2f64ade0944193d108fda7fee6fe23a7fe308968
Author: Shawn Yang <[email protected]>
AuthorDate: Tue Aug 27 18:33:17 2024 +0800
fix(java): fix reserved keyword conflict (#1819)
## What does this PR do?
<!-- Describe the purpose of this PR. -->
## Related issues
Closes #1818
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fury/issues/new/choose) describing the
need to do so and update the document if necessary.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
---
.../src/main/java/org/apache/fury/codegen/CodegenContext.java | 2 +-
.../src/test/java/org/apache/fury/codegen/CodegenContextTest.java | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git
a/java/fury-core/src/main/java/org/apache/fury/codegen/CodegenContext.java
b/java/fury-core/src/main/java/org/apache/fury/codegen/CodegenContext.java
index 69c4fe7a..d6568d46 100644
--- a/java/fury-core/src/main/java/org/apache/fury/codegen/CodegenContext.java
+++ b/java/fury-core/src/main/java/org/apache/fury/codegen/CodegenContext.java
@@ -124,7 +124,7 @@ public class CodegenContext {
private static Map<String, Map<String, Boolean>> nameConflicts = new
ConcurrentHashMap<>();
Map<String, Long> newValNameIds = new HashMap<>();
- Set<String> valNames = new HashSet<>();
+ Set<String> valNames = new HashSet<>(JAVA_RESERVED_WORDS);
/**
* State used for expression elimination/reuse.
diff --git
a/java/fury-core/src/test/java/org/apache/fury/codegen/CodegenContextTest.java
b/java/fury-core/src/test/java/org/apache/fury/codegen/CodegenContextTest.java
index feaf22b2..1b748bbc 100644
---
a/java/fury-core/src/test/java/org/apache/fury/codegen/CodegenContextTest.java
+++
b/java/fury-core/src/test/java/org/apache/fury/codegen/CodegenContextTest.java
@@ -82,6 +82,12 @@ public class CodegenContextTest {
}
}
+ @Test
+ public void testNewNameKeywordConflict() {
+ Assert.assertNotEquals(new CodegenContext().newName("default"), "default");
+ Assert.assertNotEquals(new CodegenContext().newNames("default", "abc")[0],
"default");
+ }
+
@Test
public void testAddStaticField() {
CodegenContext ctx = new CodegenContext();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]