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

incorrect compiler warning "potentially ambiguous"

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 8u25
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 Ultimate 64bit

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      This is a compiler issue new to 1.8.0_25. The code compiled fine with the previous version. The previous version directory was 1.7.0_25 although later versions had been installed.

      A DESCRIPTION OF THE PROBLEM :
      when compiling code the compiler produces some incorrect warnings.

      warnings of "potentially ambiguous" are produced on overloads that have different objects as arguments so there is no way it could be ambiguous.

      I have yet to determine if any of these warnings cause the compiler to not compile any classes.

      My project seems to run ok.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      no warnings at all.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      .\com\a\event\EventMulticaster.java:46: warning: [overloads] add(ActionListener,ActionListener) in EventMulticaster is potentially ambiguous with add(SettingListener,SettingListener) in EventMulticaster
       public static ActionListener add(ActionListener _a,ActionListener _b)
                                    ^
      .\com\a\event\EventMulticaster.java:50: warning: [overloads] remove(ActionListener,ActionListener) in EventMulticaster is potentially ambiguous with remove(SettingListener,SettingListener) in EventMulticaster
       public static ActionListener remove(ActionListener _l,ActionListener _oldl)
                                    ^
      .\com\a\event\EventMulticaster.java:62: warning: [overloads] add(AtomListener,AtomListener) in EventMulticaster is potentially ambiguous with add(MouseWheelListener,MouseWheelListener) in EventMulticaster
       public static AtomListener add(AtomListener _a,AtomListener _b)
                                  ^
      .\com\arxary\event\EventMulticaster.java:66: warning: [overloads] remove(AtomListener,AtomListener) in EventMulticaster is potentially ambiguous with remove(MouseWheelListener,MouseWheelListener) in EventMulticaster
       public static AtomListener remove(AtomListener _l,AtomListener _oldl)
                                  ^
      4 warnings



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Listed are 2 listeners that are listed in the error message. I have about 20 listeners so I believe the compiler stopped upon the 2nd same error.

      CODE...

      package com.a.event;
      public interface AtomListener extends EventListener
       {
       public void atomCreated(AtomEvent _e);
       }

      package com.a.event;
      public interface SettingListener extends EventListener
       {
       public void settingApplied(SettingEvent _e);
       }



      EXCERPT FROM EVENT MULTICASTER...

       public static ActionListener add(ActionListener _a,ActionListener _b)
        {
        return (ActionListener)addInternal(_a,_b);
        }
       public static ActionListener remove(ActionListener _l,ActionListener _oldl)
        {
        return (ActionListener)removeInternal(_l,_oldl);
        }
       public void actionPerformed(ActionEvent _e)
        {
        ((ActionListener)a).actionPerformed(_e);
        ((ActionListener)b).actionPerformed(_e);
        }
       public static AtomListener add(AtomListener _a,AtomListener _b)
        {
        return (AtomListener)addInternal(_a,_b);
        }
       public static AtomListener remove(AtomListener _l,AtomListener _oldl)
        {
        return (AtomListener)removeInternal(_l,_oldl);
        }
       public void atomCreated(AtomEvent _e)
        {
        ((AtomListener)a).atomCreated(_e);
        ((AtomListener)b).atomCreated(_e);
        }


      as you can see the arguments for the overloads are completely different yet still raises a "potentially ambiguous" warning.

      This code compiled fine without warnings before I upgraded to 1.8.0_25

      The directory for my previous version was 1.7.0_25 although later updates had been installed.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      no workaround.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: