GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [core] Fix #7240: Accept non-ASCII letters in Java binary and package names by xubenqiang · Pull Request #7244 · pmd/pmd

Conversation

@xubenqiang

@xubenqiang xubenqiang commented Oct 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Describe the PR

PMD reports a processing error and skips the whole file when it imports a class whose name contains non-ASCII letters, e.g. import bar.Sample注文IF;, with IllegalArgumentException: Not a Java binary name. Java allows Unicode letters in identifiers (JLS §3.8), so such sources compile and should be analyzable.

The cause is in pmd-core's AssertionUtil: the three name patterns use \w, which only matches ASCII word characters unless Pattern.UNICODE_CHARACTER_CLASS is set. PACKAGE_PATTERN, BINARY_NAME_PATTERN and BINARY_NAME_NO_ARRAY now compile with that flag, so non-ASCII identifiers pass the sanity checks in TypeSystem, SymTableFactory and friends.

Related issues

  • Fix [java] "Not a Java binary name" when importing a class with non-ASCII (e.g. Japanese) letters in its name; the whole file is skipped #7240

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

Verification

mvn -pl pmd-core test -Dtest=AssertionUtilTest \
    -Dmaven.javadoc.skip -Dcheckstyle.skip -Dpmd.skip -Djacoco.skip -Dspotbugs.skip
# Tests run: 3, Failures: 0, Errors: 0
  • Red check with the AssertionUtil change stashed: 2 of the 3 tests fail with IllegalArgumentException: Not a Java binary name 'Sample注文IF' and expected: <true> but was: <false> for the package name — the reported error.
  • The new test covers binary names with and without array suffixes, a non-ASCII package name, and that names that are not identifiers ("Sample 注文", "Sample注文IF;", "com. example") are still rejected.
  • The pmd-java module builds too, once the JVM uses UTF-8: on this Windows machine the default charset is cp936, and the JavaCC-generated sources failed to compile until -Dfile.encoding=UTF-8 was set (no LANG needed). mvn -pl pmd-java -am install -DskipTests -> BUILD SUCCESS. A PMD run on a source that imports bar.Sample注文IF (class on the auxclasspath) reports 0 processing errors; the failing path before the change is covered by the unit test above, which fails on the unfixed AssertionUtil.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI balanced review requested due to automatic review settings October 26, 2026 11:52
Copilot AI reviewed Oct 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pmd-actions-helper

pmd-actions-helper Bot commented Oct 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-11-08 21:46:15+00:00 for 32b9389)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zbynek
zbynek requested a balanced review from Copilot October 26, 2026 18:35
Copilot started reviewing on behalf of zbynek October 26, 2026 18:36
View session
Copilot AI reviewed Oct 26, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The fix is correct but is missing the customary docs/pages/release_notes.md "Fixed Issues" entry for #7240 expected by the project's convention.

No open issues 🎉

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@zbynek

zbynek commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Technically this allows class names that are not valid in Java (e.g. ⓕ matches \w, but can't be used in identifiers). On the other hand these assertions should be just simple sanity checks and Java compiler will pick those subtle differences, so this should be OK.

Building that module in this environment fails while compiling the JavaCC-generated JavaTokenKinds.java (the generated source is written with the platform encoding, so the compiler sees invalid characters on this machine).

Can you maybe explain which characters are wrong / what environment variables are affecting that? A build with LANG=C.UTF-8 LC_ALL=C.UTF-8 should pass for all modules.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xubenqiang

xubenqiang commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. On the encoding question: it was the JVM's default charset, not LANG. This machine is Windows with a cp936 default charset, and the JavaCC-generated JavaTokenKinds.java contains characters that the compiler then mis-decodes ("illegal character"), so the module failed before compiling anything of mine. With the JVM told to use UTF-8 and the stale generation stamp removed so JavaCC actually regenerates, the module builds:

set JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8
mvn -pl pmd-java -am install -DskipTests -Dmaven.javadoc.skip -Dcheckstyle.skip -Dpmd.skip -Djacoco.skip -Dspotbugs.skip
# BUILD SUCCESS

So LANG=C.UTF-8 isn't needed on Windows; -Dfile.encoding=UTF-8 is what mattered. My earlier note about not being able to build pmd-java was wrong in the sense that it's fixable, and I've corrected it in the PR description.

On the pattern: agreed that this stays a sanity check. \w with UNICODE_CHARACTER_CLASS also accepts ⓕ-style code points, and as you say the compiler is the real authority for those. If you'd rather keep the assertion ASCII-only and instead widen only for the common non-ASCII identifier characters, I can switch to an explicit \p{javaJavaIdentifierPart}-based pattern with []/$ handling — say the word and I'll adjust.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zbynek
zbynek approved these changes Oct 28, 2026
View reviewed changes
@xubenqiang
[core] Allow non-ASCII binary names in AssertionUtil checks (pmd#7240)
b7b30d3
PACKAGE_PATTERN, BINARY_NAME_PATTERN and BINARY_NAME_NO_ARRAY matched with \w,
which only covers ASCII unless Pattern.UNICODE_CHARACTER_CLASS is set. A source
file that imports a class with a non-ASCII name (e.g. bar.Sample注文IF) failed the
sanity check with IllegalArgumentException: Not a Java binary name, so PMD skipped
the whole file.

Compile the three patterns with UNICODE_CHARACTER_CLASS and add a regression test
for binary names with and without array suffixes plus a non-ASCII package name.
@xubenqiang
xubenqiang force-pushed the core-unicode-binary-names branch from d9dfb2d to b7b30d3 Compare October 30, 2026 16:23
UncleOwen added 2 commits November 8, 2026 22:23
@UncleOwen
Merge branch 'main' into fork/xubenqiang/core-unicode-binary-names
2cba995
@UncleOwen
[docs] Update release notes
32b9389
@UncleOwen UncleOwen added this to the 7.30.0 milestone Nov 8, 2026
UncleOwen
UncleOwen approved these changes Nov 8, 2026
View reviewed changes

@UncleOwen UncleOwen left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

And by the way, Copilot is wrong. There is no need for a submitter to update the release notes. Most LLMs get that part wrong anyway.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@UncleOwen
UncleOwen merged commit d3e2ec7 into pmd:main Nov 8, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel changed the title [core] Accept non-ASCII letters in Java binary and package names [core] Fix #7240: Accept non-ASCII letters in Java binary and package names Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@zbynek zbynek zbynek approved these changes
@UncleOwen UncleOwen UncleOwen approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

7.30.0

Development

Successfully merging this pull request may close these issues.

[java] "Not a Java binary name" when importing a class with non-ASCII (e.g. Japanese) letters in its name; the whole file is skipped

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@xubenqiang @zbynek @UncleOwen
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.