Menu

#681 CloneMethodMustImplementCloneable ignore inheritence

PMD-Backlog
closed
pmd (543)
PMD
1-Blocker
Bug
2016-12-08
2007-06-07
gmeroz
No

CloneMethodMustImplementCloneable trigger an error when extending a class which implements Clonable.

example:

public class MyAbstractClass implements Cloneable{
}

public class MyClonableClass extends MyAbstractClass{

protected Object clone() throws  CloneNotSupportedException {
    return super.clone();
}

}

Discussion

  • Allan Caplan

    Allan Caplan - 2007-07-04

    Logged In: YES
    user_id=1127445
    Originator: NO

    This can be addressed with the type resolution framework.

     
  • suvishal

    suvishal - 2007-09-06

    Logged In: YES
    user_id=1879633
    Originator: NO

    Looks like this is still a issue. This rule reporting vioations incorrectly. I have latest stable version 4.0

     
  • Romain PELISSE

    Romain PELISSE - 2007-09-06

    Logged In: YES
    user_id=1679130
    Originator: NO

    Yes it still an issue, i believe Allan Caplan whish to fix it with the new type resolution framework, but he probably not have the time yet... We'll try to close this issue next release.

    Thanks for the report.

     
  • Allan Caplan

    Allan Caplan - 2007-09-06

    Logged In: YES
    user_id=1127445
    Originator: NO

    In 4.0 release you can use the typeresolution ruleset - it has a CloneMethodMustImplementCloneable rule which will do what you want.

    I'll be merging it and removing the type resolution ruleset shortly

     
  • suvishal

    suvishal - 2007-09-06

    Logged In: YES
    user_id=1879633
    Originator: NO

    I am sorry i did'nt realise this bug is for XPath rule 'CloneMethodMustImplementCloneable' i thought this is for type resolution and java rule 'CloneMethodMustImplementCloneable'. Any way type resolution rule 'CloneMethodMustImplementCloneable' is also incorrectly reporting violation even though super class is implementing Cloneable interface. I have configured typeResolution attribute to true in rule config file. I am not sure if this is the correct platform to report but any way i am doing it sorry for that.

     
  • Juan Sotuyo

    Juan Sotuyo - 2016-12-08
    • status: open --> closed
    • Module: --> PMD
    • Priority: 5 --> 1-Blocker
    • Type: --> Bug
    • Affects version: -->
    • Ruleset / Rule: -->
     
  • Juan Sotuyo

    Juan Sotuyo - 2016-12-08

    As stated, this one is fixed with the typeresolution-CloneMethodMustImplementCloneable rule.

     

Log in to post a comment.

MongoDB Logo MongoDB