Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8152624

Collections.sort worked in previous Java versions, but not working in Java 8

XMLWordPrintable

      FULL PRODUCT VERSION :
      Openjdk version "1.8.0_71"
      OpenJDK Runtime Environment (build 1.8.0_71-b15)
      OpenJDK 64-Bit Server VM (build 25.71-b15, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      OS Version: 2.6.32-573.18.1.el6.x86_64
      OS Architecture: amd64

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Using Apache Tomcat/6.0.24 JVM Version 1.8.0_71-b15

      A DESCRIPTION OF THE PROBLEM :

      The Collections.sort method is used in several JSP pages and worked until upgrading to Java 8.

      REGRESSION. Last worked in version 7u80

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.7.0_95"
      Java(TM) SE Runtime Environment (build 1.7.0_95-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 24.95-b01, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      To test, we copied the simple code from this site: http://www.java-examples.com/sort-elements-java-arraylist-example into a JSP, but got the same results

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Collections.sort(myArrayList) should sort the arraylist without error.

      ACTUAL -
      An error occurred at line: 34 in the jsp file: /index-test.jsp
      The type java.util.Comparator cannot be resolved. It is indirectly referenced from required .class files

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      type Exception report

      message

      description The server encountered an internal error () that prevented it from fulfilling this request.

      exception
      org.apache.jasper.JasperException: Unable to compile class for JSP:

      An error occurred at line: 20 in the jsp file: /index-test.jsp
      The type java.util.Comparator cannot be resolved. It is indirectly referenced from required .class files
      17: al_systems.add("ant");
      18:
      19: //Collections.sort(al_systems, String.CASE_INSENSITIVE_ORDER);
      20: Collections.sort(al_systems);
      21:
      22: for(int i = 0; i < al_systems.size(); i++)
      23: {


      Stacktrace:
      org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
      org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
      org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
      </head>

      <%@ page import="java.util.*" %>


      <%

      ArrayList al_systems = new ArrayList();

      try
      {
      al_systems.add("cat");
      al_systems.add("bat");
      al_systems.add("ant");

      //Collections.sort(al_systems, String.CASE_INSENSITIVE_ORDER);
      Collections.sort(al_systems);

      for(int i = 0; i < al_systems.size(); i++)
      {
      out.print(al_systems.get(i) + "<br><br>");
      }
      }


      catch(Exception e)
      {
      out.println("Error message: " + e.getMessage());
      }




      %>

      </body>

      testing 123...

      </html>
      ---------- END SOURCE ----------

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: