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] Deprecate getImage()/@Image and remove usages by UncleOwen · Pull Request #7048 · pmd/pmd

Conversation

@UncleOwen

@UncleOwen UncleOwen commented Sep 7, 2026 •
edited by adangel
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Part of #4787

Describe the PR

This PR removes the remaining uses of @Image/Node.getImage() from pmd-java.

Related issues

  • See Deprecate getImage()/@Image #4787

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)

Sorry, something went wrong.

Uh oh!

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

All reactions
UncleOwen added 2 commits September 7, 2026 14:39
@UncleOwen
Remove remaining usages of @image from XPath rules in pmd-java
c8400a4
@UncleOwen
Remove remaining usages of Node.getImage() from Java rules in pmd-java
8bb86c5
@UncleOwen
UncleOwen marked this pull request as draft September 7, 2026 19:05
@UncleOwen
Remove remaining usages of Node.getImage() from AST classes in pmd-java
0aeecfd
@UncleOwen
UncleOwen force-pushed the issue-4787-pmd-java-remove-remaining-usages-of-getImage branch from fb854d3 to 0aeecfd Compare September 7, 2026 19:11
@UncleOwen
UncleOwen marked this pull request as ready for review September 7, 2026 19:31
@pmd-actions-helper

pmd-actions-helper Bot commented Sep 7, 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-10-22 14:34:40+00:00 for 2dd4db6)

All reactions

Sorry, something went wrong.

Uh oh!

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

@UncleOwen UncleOwen changed the title [java] Work on #4787 remove remaining usages of @Image/Node.getImage() [java] Work on #4787: remove remaining usages of @Image/Node.getImage() Sep 7, 2026
UncleOwen added 2 commits September 22, 2026 20:16
@UncleOwen
Merge branch 'main' into issue-4787-pmd-java-remove-remaining-usages-…
3e8bc4b
…of-getImage

# Conflicts:
#	pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/FieldNamingConventionsRule.java
@UncleOwen
Merge branch 'main' into issue-4787-pmd-java-remove-remaining-usages-…
5c10ae4
…of-getImage
adangel
adangel reviewed Oct 19, 2026
View reviewed changes

@adangel adangel 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 for the PR!

I'd prefer, if we directly prepare the deprecation of getImage here. That means

  • we don't use the parsers setLastTokenImage anymore (which would call setImage on the node)
  • we have for all these cases in the node a proper alternative attribute and getImage returns that attribute. The parser will call the set_name_of_the_attribute setter instead of setLastTokenImage

I've tested this approach with ASTBreakStatement - there are no test failures, so I assume, we don't use break statements with labels in any sample file we have a treedump test... which means, in that case, we can directly deprecated it (note: release notes).

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTBreakStatement.java Resolved

Uh oh!

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

Comment thread pmd-java/src/main/resources/category/java/codestyle.xml Resolved

Uh oh!

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

@UncleOwen
Merge branch 'main' into issue-4787-pmd-java-remove-remaining-usages-…
cf8d9e2
…of-getImage

# Conflicts:
#	pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/SuspiciousOctalEscapeRule.java
@UncleOwen

UncleOwen commented Oct 19, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

When I wrote this PR, I didn't want to touch the parser. That's why we wouldn't be able to deprecate setImage(). But I think this PR does enable us to deprecate getImage() and the image variable. At least, as far as Java is concerned. Looking back at it, I agree that this asymmetry is confusing. Should I continue working on this PR, so we can deprecate setImage() as well?

As for making sure that getImage() still works even if deprecated: We could add an assert getImage().equals(getLabel()) in ASTBreakStatement.jjtClose().

All reactions

Sorry, something went wrong.

Uh oh!

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

@UncleOwen
UncleOwen marked this pull request as draft October 19, 2026 17:21
@UncleOwen
Assert that getImage() and the replacement return equal values.
1b41220
@UncleOwen

UncleOwen commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Hmmm, maybe jjtClose is too early.

All reactions

Sorry, something went wrong.

Uh oh!

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

@adangel
Revert "Assert that getImage() and the replacement return equal values."
eb3b6af
This reverts commit 1b41220.
@adangel adangel self-assigned this Oct 22, 2026
adangel added 12 commits October 22, 2026 10:31
@adangel
ASTConstructorDeclaration: Prepare deprecation @image
3465789
@adangel
ASTAmbiguousName: Prepare deprecation @image
0951cce
@adangel
ASTBreakStatement: Deprecate @image
7ed9a77
@adangel
ASTContinueStatement: Deprecate @image
9a4c770
@adangel
ASTFieldAccess: Prepare deprecation @image
86f528c
@adangel
ASTImportDeclaration: Deprecate @image
167f3ff
@adangel
ASTLabeledStatement: Deprecate @image
e42b89d
@adangel
ASTMemberValuePair: Prepare deprecation @image
985984b
@adangel
ASTMethodCall: Prepare deprecation @image
bcd2510
@adangel
ASTPackageDeclaration: Deprecate @image
5acf254
@adangel
ASTTypeParameter: Prepare deprecation @image
b0dc0cf
@adangel
ASTVariableAccess: Prepare deprecation @image
9fd11cd
@adangel
Merge branch 'main' into pr-7048
8d24538
@adangel adangel mentioned this pull request Oct 22, 2026
Deprecate getImage()/@Image #4787
Open
adangel added 2 commits October 22, 2026 13:01
@adangel
Fix checkstyle, unused import
520f058
@adangel
Deprecate @image attributes, update tree dump tests
f90b13d
@adangel adangel changed the title [java] Work on #4787: remove remaining usages of @Image/Node.getImage() [java] Deprecate getImage()/@Image and remove usages Oct 22, 2026
adangel added 2 commits October 22, 2026 15:35
@adangel
Release notes
ac400de
@adangel
Merge branch 'main' into pr-7048
2dd4db6
@adangel adangel added the is:deprecation The main focus is deprecating public APIs or rules, eg to make them internal, or removing them label Oct 22, 2026
@adangel adangel added this to the 7.29.0 milestone Oct 22, 2026
@adangel

adangel commented Oct 22, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Hmmm, maybe jjtClose is too early.

I've continued and finished this PR. I've decided to not use assert in jjtClose and just have unit tests, to verify image attribute.

Note: This is only a first step towards #4787 . I've outlined there the next steps for java:

  • Deprecate @Image of: ASTCompactConstructorDeclaration, ASTEnumConstant, ASTInfixExpression, ASTStringLiteral (and all other subtypes of AbstractLiteral - last usage of setImage)
  • Deprecate @Image of remaining nodes (inherited through AbstractJjtreeNode). Deprecation in AbstractJavaNode. In theory, this should not affect any more nodes, because setImage is not used anymore.

If the build looks fine, I'm going to merge this for 7.29.0.

All reactions

Sorry, something went wrong.

Uh oh!

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

@adangel
adangel marked this pull request as ready for review October 22, 2026 14:06
@adangel
adangel merged commit 803bccb into pmd:main Oct 23, 2026
13 checks passed

Uh oh!

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

@UncleOwen
UncleOwen deleted the issue-4787-pmd-java-remove-remaining-usages-of-getImage branch October 23, 2026 14:04
@UncleOwen UncleOwen mentioned this pull request Nov 14, 2026
[java] Follow-Up on #7048: Add tests to AvoidDuplicateLiterals.xml, PrimitiveWrapperInstantiation.xml and SuspiciousOctalEscape.xml #7353
Open
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adangel adangel adangel left review comments

Uh oh!

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

Assignees

@adangel adangel

Labels

is:deprecation The main focus is deprecating public APIs or rules, eg to make them internal, or removing them

Projects

None yet

Milestone

7.29.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

@UncleOwen @adangel
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.