Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-5411

withAction() cannot accept anonymous class, please convert it to Lambda syntax

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • 10.0.0
    • 10.0.0.FL
    • None

      Steps to Reproduce

      1. compile IssueRichlet in Java 1.8
      2. run it in Java 15 or above with zk zul and stateless 10.0.0.FL.20230220
      3. visit the page of Richlet

      Current Result

      java.lang.IllegalArgumentException: withAction() cannot accept anonymous class, please convert it to Lambda syntax.
      at org.zkoss.stateless.sul.IComponent.checkActions(IComponent.java:421)
      at org.zkoss.stateless.sul.ImmutableITextbox.validate(ImmutableITextbox.java:4636)
      at org.zkoss.stateless.sul.ImmutableITextbox.withAction(ImmutableITextbox.java:1307)
      at org.zkoss.stateless.sul.ImmutableITextbox.withAction(ImmutableITextbox.java:27)
      at org.zkoss.stateless.sul.IComponent.withAction(IComponent.java:314)
      at org.zkoss.zephyr.demo.richlet.IssueRichlet.index(IssueRichlet.java:21)

      Expected Result

      no error

      Debug Information

      1. getCanonicalName() returns null when running in a different version Java from the java version I use to compile the code
      2.

      public interface ActionHandler extends Serializable {
      ...
      	default SerializedLambda serialized() {
      		try {
      			return LOADED_LAMBDA_CACHE.computeIfAbsent(getClass().getCanonicalName(), (ignore) -> {..}
      

      simulated case

      Steps to Reproduce

      1. compile MyClassTest and its dependent in java 1.8
      2. run MyClassTest in java 15 or above
      java test.MyClassTest

      Current Result

      getCanonicalName() returns null

      Debug info

      • compile in java 11 also can reproduce this bug
      • because since Java 15, method references and lambdas (or rather, invokedynamic) are now implemented using hidden classes, at least in the OpenJDK. In short, hidden classes are classes that are defined dynamically at runtime, using Lookup.defineHiddenClass, has no binary name, and does not need a class loader to be loaded.

        1. MyClass.java
          0.3 kB
        2. MyClassTest.java
          0.2 kB
        3. MyInterface.java
          0.3 kB
        4. IssueRichlet.java
          0.9 kB

            jumperchen jumperchen
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: