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 — [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 · Issue #7240 · pmd/pmd

[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

New issue
Copy link
New issue
Copy link
Closed
#7244
Closed
[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
#7244
Copy link
Labels
a:bugPMD crashes or fails to analyse a file.
Milestone
7.30.0

Description

@a-inoue0426
a-inoue0426
opened on Oct 26, 2026
Issue body actions

Affects PMD Version: 7.28.0

Description:

Java allows Unicode letters in identifiers (JLS §3.8), so class names that contain non-ASCII letters (e.g. Japanese) compile fine with javac. However, when a source file has a single-type import of such a class, PMD fails while building the symbol table with IllegalArgumentException: Not a Java binary name.

PMD reports this as a processing error and applies no rules to that file at all. As a result, every violation in that file is missed, not just ones related to the import. In the sample below, the file that imports Sample注文IF reports nothing, while the same code importing SampleOrderIF reports the expected UnusedLocalVariable violation.

With unmodified PMD 7.28.0, the error occurs both with and without an auxclasspath.

The cause is the patterns in net.sourceforge.pmd.util.AssertionUtil. They use \w, which only matches [a-zA-Z_0-9] in Java regex unless Pattern.UNICODE_CHARACTER_CLASS is set:

private static final Pattern BINARY_NAME_PATTERN = Pattern.compile("[\\w$]+(?:\\.[\\w$]+)*(?:\\[])*");

PACKAGE_PATTERN and BINARY_NAME_NO_ARRAY use the same character class.

Adding Pattern.UNICODE_CHARACTER_CLASS to these three patterns fixes the issue. I compiled AssertionUtil.java from the 7.28.0 sources with only this change, put it before pmd-core-7.28.0.jar on the classpath of the Ant task, and ran the sample below again. ImportsNonAsciiName.java then reports UnusedLocalVariable at line 8 and no processing error, the same as ImportsAsciiName.java. I checked this both without an auxclasspath and with the compiled sample classes on the auxclasspath. I did not run PMD's own test suite. (Checking characters with Character.isJavaIdentifierStart / Character.isJavaIdentifierPart would be another option.)

The change I tested (pmd-core/src/main/java/net/sourceforge/pmd/util/AssertionUtil.java):

-    private static final Pattern PACKAGE_PATTERN = Pattern.compile("[\\w$]+(\\.[\\w$]+)*|");
-    private static final Pattern BINARY_NAME_PATTERN = Pattern.compile("[\\w$]+(?:\\.[\\w$]+)*(?:\\[])*");
-    private static final Pattern BINARY_NAME_NO_ARRAY = Pattern.compile("[\\w$]++(?:\\.[\\w$]++)*");
+    private static final Pattern PACKAGE_PATTERN = Pattern.compile("[\\w$]+(\\.[\\w$]+)*|", Pattern.UNICODE_CHARACTER_CLASS);
+    private static final Pattern BINARY_NAME_PATTERN = Pattern.compile("[\\w$]+(?:\\.[\\w$]+)*(?:\\[])*", Pattern.UNICODE_CHARACTER_CLASS);
+    private static final Pattern BINARY_NAME_NO_ARRAY = Pattern.compile("[\\w$]++(?:\\.[\\w$]++)*", Pattern.UNICODE_CHARACTER_CLASS);

Exception Stacktrace:

java.lang.IllegalArgumentException: Not a Java binary name 'demo.caller.Sample注文IF'
	at net.sourceforge.pmd.util.AssertionUtil.assertValidJavaBinaryName(AssertionUtil.java:85)
	at net.sourceforge.pmd.lang.java.symbols.internal.asm.AsmSymbolResolver.resolveClassFromBinaryName(AsmSymbolResolver.java:57)
	at net.sourceforge.pmd.lang.java.symbols.SymbolResolver$1.resolveClassFromBinaryName(SymbolResolver.java:84)
	at net.sourceforge.pmd.lang.java.symbols.SymbolResolver.resolveClassFromCanonicalName(SymbolResolver.java:48)
	at net.sourceforge.pmd.lang.java.internal.JavaAstProcessor.findSymbolCannotFail(JavaAstProcessor.java:85)
	at net.sourceforge.pmd.lang.java.symbols.table.internal.SymTableFactory.fillSingleImports(SymTableFactory.java:298)
	at net.sourceforge.pmd.lang.java.symbols.table.internal.SymTableFactory.singleImportsSymbolTable(SymTableFactory.java:270)
	at net.sourceforge.pmd.lang.java.symbols.table.internal.SymbolTableResolver$MyVisitor.visit(SymbolTableResolver.java:247)
	at net.sourceforge.pmd.lang.java.symbols.table.internal.SymbolTableResolver$MyVisitor.visit(SymbolTableResolver.java:160)
	at net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit.acceptVisitor(ASTCompilationUnit.java:108)
	at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.acceptVisitor(AbstractJavaNode.java:38)
	at net.sourceforge.pmd.lang.java.symbols.table.internal.SymbolTableResolver$MyVisitor.traverse(SymbolTableResolver.java:186)
	at net.sourceforge.pmd.lang.java.symbols.table.internal.SymbolTableResolver.traverse(SymbolTableResolver.java:105)
	at net.sourceforge.pmd.lang.java.internal.JavaAstProcessor.lambda$process$1(JavaAstProcessor.java:136)
	at net.sourceforge.pmd.benchmark.TimeTracker.bench(TimeTracker.java:163)
	at net.sourceforge.pmd.lang.java.internal.JavaAstProcessor.process(JavaAstProcessor.java:136)
	at net.sourceforge.pmd.lang.java.internal.JavaAstProcessor.process(JavaAstProcessor.java:177)
	at net.sourceforge.pmd.lang.java.internal.JavaAstProcessor.process(JavaAstProcessor.java:161)
	at net.sourceforge.pmd.lang.java.ast.JavaParser.parseImpl(JavaParser.java:70)
	at net.sourceforge.pmd.lang.java.ast.JavaParser.parseImpl(JavaParser.java:25)
	at net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeParserAdapter.parse(JjtreeParserAdapter.java:36)
	at net.sourceforge.pmd.lang.impl.PmdRunnable.parse(PmdRunnable.java:112)
	at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource(PmdRunnable.java:132)
	at net.sourceforge.pmd.lang.impl.PmdRunnable.run(PmdRunnable.java:80)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Code Sample demonstrating the issue:

src/demo/caller/Sample注文IF.java

package demo.caller;

public class Sample注文IF {
}

src/demo/caller/SampleOrderIF.java

package demo.caller;

public class SampleOrderIF {
}

src/demo/ImportsNonAsciiName.java

package demo;

import demo.caller.Sample注文IF;

public class ImportsNonAsciiName {

	public Sample注文IF create() {
		int count = 1;
		return new Sample注文IF();
	}
}

src/demo/ImportsAsciiName.java

package demo;

import demo.caller.SampleOrderIF;

public class ImportsAsciiName {

	public SampleOrderIF create() {
		int count = 1;
		return new SampleOrderIF();
	}
}

All files are UTF-8 and compile with javac -encoding UTF-8.

Steps to reproduce:

  1. Save the four files above under src/, and the following build.xml next to src/ (set pmd.lib to the lib directory of PMD 7.28.0).
<project name="pmd-demo" default="run">
	<property name="pmd.lib" value="path/to/pmd-bin-7.28.0/lib"/>
	<target name="run">
		<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
			<classpath><fileset dir="${pmd.lib}" includes="*.jar"/></classpath>
		</taskdef>
		<pmd rulesetfiles="category/java/bestpractices.xml/UnusedLocalVariable" encoding="UTF-8" failOnError="false" failOnRuleViolation="false">
			<sourceLanguage name="java" version="21"/>
			<formatter type="xml" toFile="result.xml"/>
			<fileset dir="src" includes="demo/Imports*.java"/>
		</pmd>
	</target>
</project>
  1. Run ant.
  2. Look at result.xml.

Actual result:

  • ImportsAsciiName.java: UnusedLocalVariable at line 8.
  • ImportsNonAsciiName.java: no violations; only the processing error above.

Expected result: ImportsNonAsciiName.java should also report UnusedLocalVariable at line 8.

Running PMD through: Ant

Ant 1.10.14, JDK 21.0.2 (Eclipse Temurin), Windows 11.

Activity

  1. a-inoue0426
    added
    a:bugPMD crashes or fails to analyse a file.
    on Oct 26, 2026
  2. xubenqiang
    added 2 commits that reference this issue on Oct 30, 2026

    docs: add release notes entry for pmd#7240

    d9dfb2d

    [core] Allow non-ASCII binary names in AssertionUtil checks (pmd#7240)

    b7b30d3
  3. UncleOwen
    added this to the 7.30.0 milestone on Nov 8, 2026
  4. UncleOwen
    added a commit that references this issue on Nov 8, 2026

    [core] Accept non-ASCII letters in Java binary and package names (#7244)

    d3e2ec7
  5. UncleOwen
    closed this as completedin #7244on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:bugPMD crashes or fails to analyse a file.

    Type

    No type

    Projects

    No projects

      Milestone

      • 7.30.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.