Note that there are some explanatory texts on larger screens.

plurals
  1. POjavax:javaee-api-6.0 contains non-abstract classes with no method body
    text
    copied!<p>I am fairly new to Java EE and when I look into the compiled code (I could not find the source code for javax:javaee-api-6.0), I notice this class.</p> <pre><code>package javax.servlet; import java.util.EventObject; public class ServletContextEvent extends EventObject { public ServletContextEvent(ServletContext paramServletContext); public ServletContext getServletContext(); } </code></pre> <p>However, the same class in javax:javaee-api-7.0 is this.</p> <pre><code>package javax.servlet; import java.util.EventObject; public class ServletContextEvent extends EventObject { private static final long serialVersionUID = -7501701636134222423L; public ServletContextEvent(ServletContext source) { super(source); } public ServletContext getServletContext() { return (ServletContext)super.getSource(); } } </code></pre> <p>The also happens to ServletException in the same package (there might be more, as I didn't go through each of them). </p> <p>Assuming Java Decompiler gave me what the source code looks like, from a pure java grammar point of view, I can't understand why the 6.0 classes are not abstract (or, not interfaces).</p> <p><strong>Question 1.</strong> Why are the classes in 6.0 not abstract or interfaces?</p> <p><strong>Question 2.</strong> Why is the implementation changed in 7.0? Did people realize the 6.0 version would cause trouble when you compile code with javaee-api? </p> <p>The reason I ask is because I actually got compile errors when using javaee-web-api (which has similar classes as javaee-api, see <a href="https://stackoverflow.com/q/16789020/842860">this</a>) in Intellij IDEA (12.1.4). The error looks like this:</p> <pre><code>Internal error: (java.lang.ClassFormatError) Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletContextEvent </code></pre> <p>So <strong>Question 3.</strong> Is there a way to avoid this in Intellij IDEA?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload