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] Crash when encountering a java comment at the end of a file · Issue #6014 · pmd/pmd

[Java] Crash when encountering a java comment at the end of a file #6014

New issue
Copy link
New issue
Copy link
Closed
#6016
Closed
[Java] Crash when encountering a java comment at the end of a file#6014
#6016
Copy link
Labels
a:bugPMD crashes or fails to analyse a file.good first issueA great starting point for new contributors
Milestone
7.17.0

Description

@AB-xdev
AB-xdev
opened on Aug 27, 2025
Issue body actions

Affects PMD Version: 7.16.0

Description:
PMD crashes when it encounters a comment // at the very end of a file (no line breaks).

Exception Stacktrace:

java.lang.StringIndexOutOfBoundsException: String index out of range: 2
	at net.sourceforge.pmd.lang.document.Chars.charAt(Chars.java:450)
	at net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils.isMarkdownComment(JavaAstUtils.java:801)
	at net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit.setComments(ASTCompilationUnit.java:76)
	at net.sourceforge.pmd.lang.java.ast.JavaParserImpl.CompilationUnit(JavaParserImpl.java:467)
	at net.sourceforge.pmd.lang.java.ast.JavaParser.parseImpl(JavaParser.java:57)
	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:

//

Make sure that there are no chars not even line-breaks after the comment!

NOTE: May require some java code above to actually be detected as a java class.

Steps to reproduce:

  1. Create a Java file with a // at the end as described above
  2. PMD crashes

Running PMD through: IntelliJ plugin

Activity

  1. AB-xdev
    added
    a:bugPMD crashes or fails to analyse a file.
    on Aug 27, 2025
  2. UncleOwen commented on Aug 27, 2025

    @UncleOwen
    UncleOwen
    on Aug 27, 2025
    Member
    More actions

    That must be the shortest, complete bug repro I've ever seen.

    Reacted by Alex "Blex" B, Piotrek Żygieło, Juan Martín Sotuyo Dodero and Clément Fournier
  3. UncleOwen
    added a commit that references this issue on Aug 27, 2025

    [doc] Update release notes (pmd#6014, pmd#6016)

    9ed83f1
  4. oowekyala
    added
    good first issueA great starting point for new contributors
    on Sep 1, 2025
  5. oowekyala
    closed this as completedin #6016on Sep 1, 2025
  6. oowekyala
    added a commit that references this issue on Sep 1, 2025

    [java] Fix #6014: Crash when encountering a java comment at the end o…

    This issue will close once commit e457ddd is merged into the 'main' branch.
    e457ddd
  7. adangel
    added this to the 7.17.0 milestone on Sep 5, 2025
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.good first issueA great starting point for new contributors

    Type

    No type

    Projects

    No projects

      Milestone

      • 7.17.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.