-
Bug
-
Resolution: Fixed
-
P3
-
9
-
None
-
b81
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8142260 | emb-9 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | team |
JDK-8140972 | 8u91 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | b01 |
JDK-8134880 | 8u72 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | b01 |
JDK-8147340 | emb-8u91 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | b01 |
Currently we link invocations of @FunctionalInterface methods with an "instanceof <declaring interface>" guard. This seems like a nice stable linkage but can produce weird behavior with classes that implement multiple functional interfaces. Currently, the functional method of the first functional interface of the latest-linked object will dominate earlier-linked ones in that call site. To illustrate:
var fc = new (Java.extend(java.util.function.Function, java.util.function.Consumer))({
apply: function(x) { print("fc invoked as a function") },
accept: function(x) { print("fc invoked as a consumer") }
});
var c = new java.util.function.Consumer(function(x) { print("c invoked as a consumer") });
for each(x in [fc, c, fc]) { x(null); }
prints:
fc invoked as a function
c invoked as a consumer
fc invoked as a consumer
var fc = new (Java.extend(java.util.function.Function, java.util.function.Consumer))({
apply: function(x) { print("fc invoked as a function") },
accept: function(x) { print("fc invoked as a consumer") }
});
var c = new java.util.function.Consumer(function(x) { print("c invoked as a consumer") });
for each(x in [fc, c, fc]) { x(null); }
prints:
fc invoked as a function
c invoked as a consumer
fc invoked as a consumer
- backported by
-
JDK-8134880 Surprising behavior with more than one functional interface on a class
-
- Resolved
-
-
JDK-8140972 Surprising behavior with more than one functional interface on a class
-
- Resolved
-
-
JDK-8142260 Surprising behavior with more than one functional interface on a class
-
- Resolved
-
-
JDK-8147340 Surprising behavior with more than one functional interface on a class
-
- Resolved
-
- relates to
-
JDK-8068903 Can't invoke vararg @FunctionalInterface methods
-
- Resolved
-