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

TrayIcon does NOT derive from java.awt.Component but native code tries to anyway

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Win10 / JDK 19

      A DESCRIPTION OF THE PROBLEM :
      In the awt_TrayIcon.cpp source code a MouseEvent is created calling constructor and passing arg1 a TrayIcon object which is cast to a java.awt.Component.
      TrayIcon is NOT derived from Component and this causes Cast exception to be thrown in GraalVM.
      See code below:
      https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp#L540

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Any simple app that uses SystemTray in Windows.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No Exception.
      ACTUAL -
      Exception in thread "AWT-Windows": java.lang.ClassCastException
      java.lang.ClassCastException: java.awt.TrayIcon cannot be cast to java.awt.Component

      ---------- BEGIN SOURCE ----------
      https://docs.oracle.com/javase/tutorial/uiswing/misc/systemtray.html
      ---------- END SOURCE ----------

      FREQUENCY : always


            pnarayanaswa Praveen Narayanaswamy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: