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

ClassCastException: sun.awt.HeadlessToolkit cannot be cast to sun.awt.SunToolkit in headless mode

    Details

      Description

      This is basically an 8u20 mirror of JDK-8055822

      For example, the following code throws ClassCastException if run v.s. 8u20b26 (GA) with -Djava.awt.headless=true or even if DISPLAY variable is not set

      Tested on Linux

      --------------------------------------------------------------------
      import java.awt.datatransfer.DataFlavor;
      import java.awt.datatransfer.FlavorMap;
      import java.awt.datatransfer.SystemFlavorMap;
      import java.util.List;

      public class SystemFlavorMapTest {

          public static void main(String[] args) {
              FlavorMap fm = SystemFlavorMap.getDefaultFlavorMap();
              SystemFlavorMap sfm = (SystemFlavorMap)fm;
              final List<DataFlavor> flavorsForNative = sfm.getFlavorsForNative("not-for-sure/registered-before");
              System.err.println("flavorsForNative = " + flavorsForNative);
          }
      }

      --------------------------------------------------------------------

      The following tests which exist in _JCK8_

      api/java_awt/datatransfer/DataFlavor/index.html#rclass
      api/java_awt/datatransfer/SystemFlavorMap/index.html#GetF4N
      api/java_awt/datatransfer/SystemFlavorMap/index.html#SetF4N
      api/java_awt/datatransfer/SystemFlavorMap/index.html#SetN4F

      fail.

      See JCK-7303484 for the test logs

      This is likely a regression introduced by JDK-8037202


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dbessono Dmitry Bessonov
              • Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: