[java:s1943] FP when calling super constructor of Reader/PrintStream

Qube: Community 9.9

I have a PrintStream extension. But this will apply to all Readers as well.

  public class MyPS extends PrintStream
      public MyPS(String fileName) throws FileNotFoundException
          super(filename); // FP

The rule notifies the super constructor call. I don’t think, it should do that.

Hi Marvin, thank you for your input, but I would need a little bit more context on why you think the rule should behave differently to understand where you are coming from.

To me, the rule is correctly reporting the usage of a constructor that under the hood relies on the default system encoding, which could lead to issues that are hard to diagnose and reproduce.

Let me know what you think about it,


I think, all Readers/Writers should behave the same. If I write an extension and simply ass through all constructors, the wrong usage is not where I pass through the constructor for default behavior and equipment, but where this constructor is called from regular code.

Let’s think about code, that reflectively constructs Readers or Writers. The wrong behavior is certainly where the reflective constructor call references the wong constructor. But it will fail, if you put a Reader/Writer under the configuration, that skips theses constructors.

To put it in a nutshell, Readers and writers have these constructors. And as long as they have them, they should all do the same. And this rule should not force me to produce asymmetric code.