How is ArrayOutOfBoundsException possible in String.valueOf(int)?

后端 未结 3 897
無奈伤痛
無奈伤痛 2021-02-05 03:30

Why does this code sometimes produce ArrayOutOfBoundsException? How is that even possible for String.valueOf(int)?

public static String ipToString(B         


        
3条回答
  •  礼貌的吻别
    2021-02-05 03:44

    This is a JIT compiler bug that has been introduced in JDK 8u20 as a side-effect of another fix:
    JDK-8042786

    The problem is related to auto-boxing elimination optimization.
    The work-around is to switch the optimization off by -XX:-EliminateAutoBox JVM flag

    Looks like the problem also exists in the most recent JDK 9 source base.
    I've submitted the bug report: https://bugs.openjdk.java.net/browse/JDK-8058847 with 100% reproducible minimal test case included.

提交回复
热议问题