Java 8 - converting an Integer to a long compilation issue

前端 未结 2 2005
走了就别回头了
走了就别回头了 2020-12-15 10:45

I have the following abstract generic data holder in my project (simplified):

public abstract static class Value {

    E value;

    public void se         


        
相关标签:
2条回答
  • 2020-12-15 11:09

    A known Eclipse bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=440019

    Fixed in Eclipse 4.5 M3.

    0 讨论(0)
  • 2020-12-15 11:11

    According to the JLS for Java 8 this should not happen:

    5.1.2. Widening Primitive Conversion

    19 specific conversions on primitive types are called the widening primitive conversions:

    [..]

    • int to long, float, or double

    [..]

    5.1.8. Unboxing Conversion

    [..]

    • From type Integer to type int

    What should happen is an unboxing from Integer to int, and then a widening conversion to long. This is actually happening as expected in Oracle JDK (1.8.0.25).

    I believe you came across a compiler bug into your JDK. You should probably try an updated version or file a bug with the maintainers.

    0 讨论(0)
提交回复
热议问题