Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeTestUtil.isA confuses type Character from same package with java.lang.Character #4690

Closed
Luro02 opened this issue Sep 27, 2023 · 2 comments
Labels
a:bug PMD crashes or fails to analyse a file.

Comments

@Luro02
Copy link

Luro02 commented Sep 27, 2023

Affects PMD Version: 7.0.0-rc3

Description:

TypeTestUtil.isA is used by PrimitiveWrapperInstantiationRule to check if a type is a primitive like a Character. The implementation is not correct, because with this code:

src/Character.java

public class Character {
    public Character(String string, Integer integer) {}
}

src/Test.java

public class Test {
    public void execute() {
        Character character = new Character("a", 1);
    }
}

the lint reports the new Character line, which is wrong. The code does compile and the constructor does not exist in java.lang.Character.

@Luro02 Luro02 added the a:bug PMD crashes or fails to analyse a file. label Sep 27, 2023
@jsotuyod
Copy link
Member

jsotuyod commented Sep 27, 2023

@Luro02 how are you running PMD? This seems to be caused simply because you are not setting the auxclasspath properly https://docs.pmd-code.org/latest/pmd_languages_configuration.html#java-language-properties

Lacking the auxclasspath, it can't tell which classes are available beyond the JRE

@Luro02
Copy link
Author

Luro02 commented Sep 27, 2023

I did not set that, seems to have been the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file.
Projects
None yet
Development

No branches or pull requests

2 participants