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

Unnamed variable in functional interface doesn't work

    XMLWordPrintable

Details

    • generic
    • generic

    Description

      A DESCRIPTION OF THE PROBLEM :
      When trying to use an unnamed variable as functional interface, the compile reports no error, but I can't run the application.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      java.lang.reflect.InvocationHandler invocationHandler = (_, method, args) -> method.invoke(someObject, args)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Working application or compilation error.
      ACTUAL -
      Compilation works, but the application fails to start with the following error:
      Caused by: java.lang.ClassFormatError: Illegal field name "" in class de/porsche/digitalsupport/featureflags/FeatureFlagFactoryBean
      at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
      at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
      at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
      at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
      at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
      at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3578)
      at java.base/java.lang.Class.getDeclaredMethods(Class.java:2676)
      at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:465)
      ... 99 more

      CUSTOMER SUBMITTED WORKAROUND :
      java.lang.reflect.InvocationHandler invocationHandler = (obj, method, args) -> method.invoke(someObject, args)

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              tongwan Andrew Wang
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: