Closed rnveach closed 1 year ago
What about jdk compiler output on no super ?
Removing default constructor results in:
$ javac --version
javac 11.0.17
$ javac TestClass.java
TestClass.java:1: error: unreported exception Exception in default constructor
public class TestClass
^
1 error
Is it enough for check to detect "throws" ? To skip violation
I am closing this. I thought it was reporting the constructor, but its just reporting the super()
call. It has been determined it can be removed and the violation goes away. My bad.
$ cat TestClass.java
public class Test extends Base {
public Test() throws Exception {
}
}
class Base {
public Base() {
}
}
$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<module name="TreeWalker">
<module name="com.github.sevntu.checkstyle.checks.coding.UselessSuperCtorCallCheck" />
</module>
</module>
$ java -jar checkstyle-10.0-sevntu-1.42.0-all.jar -c TestConfig.xml TestClass.java
Starting audit...
Audit done.
Eclipse complains with
Default constructor cannot handle exception type Exception thrown by implicit super constructor. Must define an explicit constructor
if I don't addTest
constructor.