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

Compiler doesn't recognize correct Generics

XMLWordPrintable

    • x86_64
    • windows_10

      A DESCRIPTION OF THE PROBLEM :
      The compiler doesnt recognize my logically correct generic wildcard.

      REGRESSION : Last worked in version 12.0.2

      ACTUAL -
      Compiler Output:
      ```
      Information:Kotlin: kotlinc-jvm 1.3.21 (JRE 12.0.2+10)
      Information:java: Errors occurred while compiling module 'CrystalShard.api'
      Information:javac 12.0.2 was used to compile java sources
      Information:31.08.2019 15:20 - Build completed with 1 error and 0 warnings in 7 s 606 ms
      A:\Workspaces\CrystalShard\api\src\main\java\de\kaleidox\crystalshard\core\api\gateway\Gateway.java
          Error:Error:line (11)java: type argument de.kaleidox.crystalshard.core.api.gateway.GatewayListener is not within bounds of type-variable AL
      A:\Workspaces\CrystalShard\api\src\main\java\de\kaleidox\crystalshard\util\Util.java
          Information:Information:java: /A:/Workspaces/CrystalShard/api/src/main/java/de/kaleidox/crystalshard/util/Util.java uses unchecked or unsafe operations.
          Information:Information:java: Recompile with -Xlint:unchecked for details.
      ```

      ---------- BEGIN SOURCE ----------
      package de.kaleidox.crystalshard.core.api.gateway;

      import java.util.Collection;
      import java.util.concurrent.CompletableFuture;

      import de.kaleidox.crystalshard.api.listener.AttachableListener;
      import de.kaleidox.crystalshard.api.listener.Listener;
      import de.kaleidox.crystalshard.api.listener.ListenerManager;
      import de.kaleidox.crystalshard.core.api.gateway.event.GatewayEvent;

      public interface Gateway extends ListenerAttachable<Gateway, GatewayListener /* this declaration does not compile with error:
          Error:Error:line (11)java: type argument de.kaleidox.crystalshard.core.api.gateway.GatewayListener is not within bounds of type-variable AL
       */> {
          CompletableFuture<Void> sendRequest(OpCode code, String payload);
      }


      interface GatewayListener<E extends GatewayEvent> extends AttachableListener<Gateway>, Listener {
      }

      interface ListenerAttachable<S, AL extends AttachableListener<S> & Listener> {
          <TL extends AL> ListenerManager<TL> attachListener(TL listener);

          <TL extends AL> boolean detachListener(TL listener);

          Collection<ListenerManager<? extends AL>> getAttachedListenerManagers();

          default <TL extends AL> boolean detachListener(ListenerManager<TL> listenerManager) {
              return detachListener(listenerManager.getListener());
          }

          default int detachAllListeners() {
              int c = 0;

              for (ListenerManager<? extends AL> attachedListenerManager : getAttachedListenerManagers())
                  if (detachListener(attachedListenerManager))
                      c++;

              return c;
          }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


            fmatte Fairoz Matte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: