为什么 float 和 double lambda 参数仅限于 float value set,double value set?

Why are float and double lambda parameters restricted to the float value set, double value set?

阅读 Java 语言规范,Java SE 8 版,我在§15.27.1 Lambda 参数中看到了一些有趣的东西:

A lambda parameter of type float always contains an element of the float value set (§4.2.3); similarly, a lambda parameter of type double always contains an element of the double value set. It is not permitted for a lambda parameter of type float to contain an element of the float-extended-exponent value set that is not also an element of the float value set, nor for a lambda parameter of type double to contain an element of the double-extended-exponent value set that is not also an element of the double value set.

这似乎暗示 VM 将首先通过 lambda 表达式之前的值集转换将扩展精度 floatdouble 值映射到(非扩展)float 或 double 值集或 lambda 体被​​评估。然而,该规范没有要求对 lambda 的评估是 FP 严格的,并且似乎不可能制作“strictfp lambda expression/body”。

我想这意味着以下两个语句并不严格等价:

doubleStream.map((operand) -> operand + 2.);

doubleStream.map(new DoubleUnaryOperator() {
    @Override
    public double applyAsDouble(double operand) {
        return operand + 2.;
    }
});

这是正确的吗?

JLS 要求 floatdouble lambda 参数的值分别在 float 值集或 double 值集内的原因是什么?

阅读 JSR-335 的最终草案,Lambda 规范的 B 部分在 "A lambda parameter of type float" 段落之后提到:

The previous seven paragraphs are derived from 8.4.1 "Formal Parameters."

事实证明,§8.4.1 形式参数包含一个措辞相似的段落,涉及方法和构造函数的参数:

A method or constructor parameter of type float always contains an element of the float value set (§4.2.3); similarly, a method or constructor parameter of type double always contains an element of the double value set. It is not permitted for a method or constructor parameter of type float to contain an element of the float-extended-exponent value set that is not also an element of the float value set, nor for a method parameter of type double to contain an element of the double-extended-exponent value set that is not also an element of the double value set.

我一直查到JLS 2,发现这段一直都在。

因此,问题中的两个陈述实际上是等价的。