Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-1809

Eclipse compiler used in commons.compiler causes "Illegal type in constant pool" with enums

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Commons Compiler 2.0.0
    • Commons Compiler 2.0.0
    • Commons
    • None

    Description

      According to [0] the eclipse compiler can't handle enums in certain environments.

      The trunk org.apache.sling.commons.compiler bundle embeds (eclipse-jdt) core-3.3.0-v_771.jar which exposes this issue.

      According to [0] the issue should be fixed in v3.5.2, but the central Maven repository does not provide a more recent version than the one we currently use.

      To reproduce the problem, install the compiler and java scripting bundle and create a scripted java servlet that uses enums (example below), at runtime this causes:

      java.lang.VerifyError:
      (class: enumtest/EnumTest, method: valueOf signature: (Ljava/lang/String;)Lenumtest/EnumTest
      Illegal type in constant pool

      [0] https://bugs.eclipse.org/bugs/show_bug.cgi?id=291985

      Here's the example servlet, store in /apps/JavaScriptingTest2/JavaScriptingTest2.java and use "JavaScriptingTest2" resource type:

      package apps.JavaScriptingTest2;

      import javax.servlet.http.*;
      import java.io.IOException;

      public class JavaScriptingTest2 extends HttpServlet {

      static enum EnumTest

      { FOO, BAR }

      ;

      public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException

      { resp.getWriter().write("FOO=" + EnumTest.FOO); }

      }

      Attachments

        Issue Links

          Activity

            People

              cziegeler Carsten Ziegeler
              bdelacretaz Bertrand Delacretaz
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: