-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
19
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
Calling super in a method gives the following error "Constructor call must be the first statement in a constructor"
REGRESSION : Last worked in version 17.0.6
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
see attached maven project
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no error
ACTUAL -
[JavaSuperConstructorBug]$ ./build
java full version "19.0.2+7-44"
Picked up JAVA_TOOL_OPTIONS: -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< uk.geekgramps.javabug:servlet >--------------------
[INFO] Building Java Super Bug 1.0.
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ servlet ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/martinwest/workspaces/golfapps3/JavaSuperConstructorBug/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ servlet ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 2 source files to /Users/martinwest/workspaces/golfapps3/JavaSuperConstructorBug/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/martinwest/workspaces/golfapps3/JavaSuperConstructorBug/src/main/java/servlet/ContextListener.java:[21,22] call to super must be first statement in constructor
[ERROR] /Users/martinwest/workspaces/golfapps3/JavaSuperConstructorBug/src/main/java/servlet/ContextListener.java:[21,17] constructor AbstractDBContextListener in class servlet.AbstractDBContextListener cannot be applied to given types;
required: no arguments
found: jakarta.servlet.ServletContextEvent
reason: actual and formal argument lists differ in length
---------- BEGIN SOURCE ----------
package servlet;
import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.annotation.WebListener;
/**
*
* http://tomcat.apache.org/tomcat-8.5-doc/jndi-resources-howto.html
* java.naming.factory.url.pkgs=org.apache.catalina.util.naming
*
* @author martinwest
*
*/
@WebListener
public class ContextListener extends AbstractDBContextListener {
@Override
public void contextInitialized(ServletContextEvent sce ) {
super(sce);
}
@Override
public void contextDestroyed(ServletContextEvent arg0) {
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Havent found one yet
FREQUENCY : always
Calling super in a method gives the following error "Constructor call must be the first statement in a constructor"
REGRESSION : Last worked in version 17.0.6
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
see attached maven project
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no error
ACTUAL -
[JavaSuperConstructorBug]$ ./build
java full version "19.0.2+7-44"
Picked up JAVA_TOOL_OPTIONS: -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< uk.geekgramps.javabug:servlet >--------------------
[INFO] Building Java Super Bug 1.0.
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ servlet ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/martinwest/workspaces/golfapps3/JavaSuperConstructorBug/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ servlet ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 2 source files to /Users/martinwest/workspaces/golfapps3/JavaSuperConstructorBug/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/martinwest/workspaces/golfapps3/JavaSuperConstructorBug/src/main/java/servlet/ContextListener.java:[21,22] call to super must be first statement in constructor
[ERROR] /Users/martinwest/workspaces/golfapps3/JavaSuperConstructorBug/src/main/java/servlet/ContextListener.java:[21,17] constructor AbstractDBContextListener in class servlet.AbstractDBContextListener cannot be applied to given types;
required: no arguments
found: jakarta.servlet.ServletContextEvent
reason: actual and formal argument lists differ in length
---------- BEGIN SOURCE ----------
package servlet;
import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.annotation.WebListener;
/**
*
* http://tomcat.apache.org/tomcat-8.5-doc/jndi-resources-howto.html
* java.naming.factory.url.pkgs=org.apache.catalina.util.naming
*
* @author martinwest
*
*/
@WebListener
public class ContextListener extends AbstractDBContextListener {
@Override
public void contextInitialized(ServletContextEvent sce ) {
super(sce);
}
@Override
public void contextDestroyed(ServletContextEvent arg0) {
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Havent found one yet
FREQUENCY : always