Java: "duplicated blocks of code" rule for native methods

Sonar Cloud considers native Java methods as duplicated blocks but actually they aren’t.
In our case, native methods have the same signature on the Java side but different implementations on the native side.

Please see the example by the following link.

Hi Oleg,

I agree, SonarCloud should not include native method declarations in its copy & paste detection. I created this ticket SONARJAVA-3387.

Thank for this valuable feedback,

Hi Oleg,

Because we may not fix this problem in a near future, as a workaround, you should configure sonar.cpd.exclusions to exclude files containing native methods.