[False-positive]S1174 detected Override of finalize() with arguments

Affects Sonarqube Version:
Sonarqube version:
sonar-scanner version:

S1174: “Object.finalize()” should remain protected (versus public) when overriding

This rule detected Override of finalize() with arguments, for example: public void finalize(Foo foo),
This rule is implemented in sonar-java-plugin-!\org\sonar\java\checks\ObjectFinalizeOverridenNotPublicCheck.class,
This rule detects public void finalize by if (isFinalize(methodTree) && isPublic(methodTree)) {, but it seems that there is no check for arguments.
In the implementation of a similar rule S1111, it explicitly includes checking whether the argument is included: if (!this.isInFinalizeMethod && “finalize”.equals(methodName.name()) && methodInvocationTree.arguments().isEmpty()) {

Code Sample demonstrating the issue:

public void finalize(WritableRaster raster) {       // This line is marked as an error
	int[][] screenHits = getScreenHits();
	double logMaxHits = Math.log((double)getMaxHits());
	int width = raster.getWidth();
	int height = raster.getHeight();
	for(int x = 0; x < width; x++) {
		for(int y = 0; y < height; y++) {
			int hits = screenHits[x][y];
			double value = Math.log((double)hits)/logMaxHits;
			raster.setSample(x, y, 3, value * 255);

Expected outcome:

Running Sonarqube through:
command line


I agree, we might face false positive here.
I created a ticket (SONARJAVA-3441) to track this issue.

Thanks again for taking the time to report this issue.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.