You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2022/03/30 16:34:00 UTC
[jira] [Commented] (GEODE-10136) FunctionServiceBase tests fail because lambda classes have no canonical name on JDK 17
[ https://issues.apache.org/jira/browse/GEODE-10136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17514806#comment-17514806 ]
ASF subversion and git services commented on GEODE-10136:
---------------------------------------------------------
Commit 31a2e8eae470fe99b69127ffbfa46738a7190030 in geode's branch refs/heads/develop from Dale Emery
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=31a2e8e ]
GEODE-10136: Make Function.getId() handle null canonical name (#7505)
PROBLEM
The default implementation of `Function.getId()` returns the canonical
name of the function's class. But:
- On all JDKs, an anonymous class has no canonical name.
- Starting with JDK 15, a hidden class (such as the class of a lambda
expression) has no canonical name.
Given that `Function` is annotated as a functional interface, it is
problematic that its default `getId()` returns `null` for functions
created as anonymous classes and (on JDK 15+) via lambda expressions.
SOLUTION
Change `Function.getId()` to return its class's name if the class has no
canonical name.
> FunctionServiceBase tests fail because lambda classes have no canonical name on JDK 17
> --------------------------------------------------------------------------------------
>
> Key: GEODE-10136
> URL: https://issues.apache.org/jira/browse/GEODE-10136
> Project: Geode
> Issue Type: Improvement
> Components: functions, tests
> Affects Versions: 1.15.0
> Reporter: Dale Emery
> Assignee: Dale Emery
> Priority: Major
> Labels: Java17, pull-request-available
>
> {{FunctionServiceBase}} tests fail on JDK 17.
> Here are the relevant factors:
> - {{FunctionServiceBase}} uses lambda expressions to create the function objects used to test the function service.
> - The objects that represent these lambda expressions use the default implementation of all {{Function}} methods other than {{execute(FunctionContext)}}.
> - The default implementation of {{getId()}} returns the canonical name of the function object's class.
> - In JDK 17, the class of a lambda expression has no canonical name.
> - The product classes {{AbstractExecution}} and {{DistributedRegionFunctionExecutor}} both throw exceptions if the given function reports its ID as {{null}}.
> The tests can be fixed by replacing the lambda expressions with uses of a class that returns a non-{{null}} ID.
> This may be a product issue. Given that {{Function}} is explicitly annotated as a {{@FunctionalInterface}}:
> - It is clearly intended to be used with lambda expressions, yet on JDK 17 it cannot be used with lamda expressions.
> - It would be reasonable to expect that an anonymous class that extends `Function` could safely use the default implementation of {{getId()}}, yet anonymous classes have no canonical names on any JDK.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)