Skip to content

Commit

Permalink
fix(java): fix reserved keyword conflict (#1819)
Browse files Browse the repository at this point in the history
## 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.
-->
  • Loading branch information
chaokunyang authored Aug 27, 2024
1 parent 8d5f8f3 commit 2f64ade
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public void testNewName() {
}
}

@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();
Expand Down

0 comments on commit 2f64ade

Please sign in to comment.