Fix for SuperClone and SuperFinalize checks reporting violations on
native methods, #1367
This commit is contained in:
parent
0516374351
commit
068a1b4533
|
|
@ -229,7 +229,9 @@ public abstract class AbstractSuperCheck
|
|||
}
|
||||
final DetailAST nameAST = ast.findFirstToken(TokenTypes.IDENT);
|
||||
final String name = nameAST.getText();
|
||||
if (!getMethodName().equals(name)) {
|
||||
final DetailAST modifiersAST = ast.findFirstToken(TokenTypes.MODIFIERS);
|
||||
if (!getMethodName().equals(name)
|
||||
|| modifiersAST.branchContains(TokenTypes.LITERAL_NATIVE)) {
|
||||
return false;
|
||||
}
|
||||
final DetailAST params = ast.findFirstToken(TokenTypes.PARAMETERS);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ package com.puppycrawl.tools.checkstyle.checks.coding;
|
|||
/**
|
||||
* <p>
|
||||
* Checks that an overriding clone() method invokes super.clone().
|
||||
* Does not check native methods, as they have no possible java defined implementation.
|
||||
* </p>
|
||||
* <p>
|
||||
* Reference:<a
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ package com.puppycrawl.tools.checkstyle.checks.coding;
|
|||
/**
|
||||
* <p>
|
||||
* Checks that an overriding finalize() method invokes super.finalize().
|
||||
* Does not check native methods, as they have no possible java defined implementation.
|
||||
* </p>
|
||||
* <p>
|
||||
* Reference:<a
|
||||
|
|
|
|||
|
|
@ -93,3 +93,7 @@ class AnotherClass {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class NativeTest {
|
||||
public native Object clone();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,3 +51,7 @@ class MyClassWithGenericSuperMethod1
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
class TestNative {
|
||||
public native void finalize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1564,8 +1564,9 @@ if ("something".equals(x))
|
|||
<section name="SuperClone">
|
||||
<subsection name="Description">
|
||||
<p>
|
||||
Checks that an overriding <code>clone()</code> method
|
||||
invokes <code>super.clone()</code>.
|
||||
Checks that an overriding <code>clone()</code> method invokes
|
||||
<code>super.clone()</code>. Does not check native methods, as
|
||||
they have no possible java defined implementation.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
@ -1599,8 +1600,9 @@ if ("something".equals(x))
|
|||
<section name="SuperFinalize">
|
||||
<subsection name="Description">
|
||||
<p>
|
||||
Checks that an overriding <code>finalize()</code>
|
||||
method invokes <code>super.finalize()</code>.
|
||||
Checks that an overriding <code>finalize()</code> method invokes
|
||||
<code>super.finalize()</code>. Does not check native methods, as
|
||||
they have no possible java defined implementation.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
|
|||
Loading…
Reference in New Issue