Skip to content

Wrong auxclasspath if project is stored outside of workspace #96

New issue

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

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

Already on GitHub? # to your account

Closed
demonfiddler opened this issue Aug 22, 2017 · 5 comments
Closed

Wrong auxclasspath if project is stored outside of workspace #96

demonfiddler opened this issue Aug 22, 2017 · 5 comments
Labels
Milestone

Comments

@demonfiddler
Copy link

Rule Set: Type Resolution

Description: The CloneMethodMustImplementCloneable rule can erroneously report a violation when the class in question extends one that does implement Cloneable.

Code Sample demonstrating the issue:

class MyArrayList<T> extends ArrayList<T> {
	// PMD.CloneMethodMustImplementCloneable incorrectly flags this method as a violation.
	@Override
	public Object clone() {
		throw new UnsupportedOperationException();
	}
}

Running PMD through: Eclipse

@jsotuyod jsotuyod changed the title [Java] CloneMethodMustImplementCloneable doesn't check inherited implementation of Cloneable [java] CloneMethodMustImplementCloneable doesn't check inherited implementation of Cloneable Aug 22, 2017
@jsotuyod
Copy link
Member

@demonfiddler thanks for the report! Just to be sure, but are you certain you are using the rule from java-typeresolution/CloneMethodMustImplementCloneable and not the one from java-clone/CloneMethodMustImplementCloneable?

The rules are called the same, but them being different rulesets mean they have different implementations. The one from the clone ruleset will for certain reproduce this issue, the one from typeresolution ruleset shouldn't (as long as the auxclasspath is properly filled).

If you are using the one from typeresolution, are you certain you are passing the auxclasspath info? In Maven this is done through the typeResolution configuration attribute (defaults to true in the plugin 3.8, but used to be false). For CLI you need to set it manually through the -auxclasspath parameter.

For Eclipse I'm not certain it is properly populated by default, it should if it's not. @adangel can probably tell.

@demonfiddler
Copy link
Author

demonfiddler commented Aug 29, 2017

@jsotuyod thanks for the detailed response. Yes, this was definitely occurring with the version in the typeresolution ruleset. I believed I was seeing the same problem when invoking PMD from both Eclipse and Maven but for reasons I've not yet fathomed the Eclipse PMD builder seems to have stopped reporting any PMD issues at all on this particular project and right now I'm no longer seeing it from either. I hope I haven't raised a false alarm. Will post again when I've done a deeper investigation.

UPDATE: I have been able to reproduce this in Eclipse but not Maven - with the attached sample project Eclipse shows four PMD warnings (including CloneMethodMustImplementCloneable) but the Maven build, using the same ruleset, shows only three PMD warnings (excluding CloneMethodMustImplementCloneable). So it might be a problem with the PMD Eclipse plug-in.
maven-experiments.zip

@jsotuyod
Copy link
Member

@demonfiddler I'm just noticing the updated comment. Good to hear.

This is possibly an Eclipse plugin issue, not providing a complete auxclasspath. Just to be sure 'though, which PMD plugin are you using? As far as I know there are 2 plugins:

  1. https://github.com/acanda/eclipse-pmd
  2. https://github.com/pmd/pmd-eclipse-plugin

Thanks in advanced

@demonfiddler
Copy link
Author

@jsotuyod I'm using #2, pmd-eclipse-plugin. (Fairly sure about that, will check tomorrow when I'm back in the office.)

@jsotuyod jsotuyod transferred this issue from pmd/pmd Apr 12, 2019
@adangel adangel changed the title [java] CloneMethodMustImplementCloneable doesn't check inherited implementation of Cloneable Wrong auxclasspath if project is stored outside of workspace Apr 13, 2019
@adangel adangel added the bug label Apr 13, 2019
@adangel adangel added this to the 4.2.1 milestone Apr 13, 2019
@adangel
Copy link
Member

adangel commented Apr 13, 2019

When the project was stored outside of the workspace (e.g. when the project is imported, but not copied into the workspace), then the paths for the auxclasspath where wrong - they were always relative to the workspace location.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants