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

sun.misc.Unsafe accessible in Sling Starter 12

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • Starter 12
    • Starter 12
    • Starter
    • None
    • Sling-Starter 12-SNAPSHOT (commit addb8f7b) with JDK 11 and 13 on MacOS, JDK 11 on an x86_64 Linux

    Description

      We are having some trouble running our application on the current Sling Starter 12 snapshot since we are using ehache 3, which uses sun.misc.Unsafe internally. This works with Sling Starter 11, but since Sling Starter changed to the feature launcher, this class seems to have disappeared from the classpath: the class loading of ehcache classes fails with a java.lang.NoClassDefFoundError: sun/misc/Unsafe

      I tried to add command line arguments
      --add-modules=jdk.unsupported
      and
      --add-opens=jdk.unsupported/sun.misc=ALL-UNNAMED
      to the launcher command line, as I've seen that suggested on the net for similar problems, but it didn't help.
      In fact, this doesn't seem to be the problem: even without those flags the jdk.unsupported module does export sun.misc:

      module

      { name: jdk.unsupported@11.0.6, [mandated java.base], exports: [com.sun.nio.file, sun.misc, sun.reflect], opens: [sun.misc, sun.reflect] }

      So it seems the module is loaded, but not used to load the class.

      The easiest way to reproduce the problem is to add this to some JSP:
      <%
      Class clazz = sun.misc.Unsafe.class;
      %>
      In case that matters: I tried JDK 11 and 13 on MacOS, as well as JDK 11 on an x86_64 Linux.
      This works on Sling Starter 11, but not the current 12 snapshot.

      The workaround to add
      -D org.osgi.framework.system.packages.extra=sun.misc
      to the command line, which was thankfully suggested in the mailing list, does work. But I feel it is not a particularily clean solution. It also does something else than what happens on Sling Starter 11 : now the sun.misc package is listed in the exports list of the felix framework bundle
      http://localhost:9090/system/console/bundles/0 . Not sure whether this is good or bad.

      Attachments

        Issue Links

          Activity

            People

              rombert Robert Munteanu
              hanspeterstoerr Hans-Peter Stoerr
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 20m
                  1h 20m