Enhanced for loop compiling fine for JDK 8 but not 7

后端 未结 6 1080
Happy的楠姐
Happy的楠姐 2021-01-03 18:36

Consider the following code snippet, I stumpled upon after some refactoring, when checkin why the build server reported a broken build but it was fine in my IDE:

<         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-03 18:56

    Your build server may be compiling using a different jdk than your local machine. (Not just a different version number, but a completely different implementation.) Eclipse is one that uses its own compiler, I believe to facilitate its code hot-swapping.

    Using the same name for the collection and the element ought to raise problems anywhere, but I have heard of and occasionally noticed Eclipse tolerating things that the Sun/Oracle JDK won't.

提交回复
热议问题