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

StringTemplate.Processor: processor type cannot be a raw type: <any>

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      debian sid
      Linux ws0 5.18.0-3-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.14-1 (2022-07-23) x86_64 GNU/Linux
      openjdk version "21.0.2" 2024-01-16
      OpenJDK Runtime Environment (build 21.0.2+13-Debian-2)
      OpenJDK 64-Bit Server VM (build 21.0.2+13-Debian-2, mixed mode, sharing)


      A DESCRIPTION OF THE PROBLEM :
      StringTemplate.Processor as parameter of generic lambda causes compilation error.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Source code attached

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      compiled successfuly
      ACTUAL -
      compilation error: processor type cannot be a raw type: <any>

      ---------- BEGIN SOURCE ----------
      public class ProcessorTest {
          interface Action<T> {
              T act(B b);
          }

          static <T> T with(Action<T> action) {
              return null;
          }

          class B implements StringTemplate.Processor<String, RuntimeException> {
              @Override public String process(StringTemplate stringTemplate) throws RuntimeException {
                  return "";
              }
          }

          void test() {
              var x1 = with(b -> {
                  // ProcessorTest.java:25: error: processor type cannot be a raw type: <any>
                  return b."aaa";
              });

              // workaround
              var x2 = with((B b) -> {
                  // ProcessorTest.java:25: error: processor type cannot be a raw type: <any>
                  return b."aaa";
              });
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Typecasting the lambda parameter solves the problem

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: