On Mon, 21 Dec 2020 11:32:28 GMT, Pavel Rappo <pra...@openjdk.org> wrote:
>> Hi all, >> >> According to the document of >> [SafeVarargs](https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/SafeVarargs.html). >> >>> Compilers are encouraged to issue warnings when this annotation type is >>> applied to a method or constructor declaration where: >> >>> The body of the method or constructor declaration performs potentially >>> unsafe operations, such as an assignment to an element of the variable >>> arity parameter's array that generates an unchecked warning. >> >> The `SafeVarargs` may not suppress the warning of this assignment and the >> `SuppressWarnings` may be necessary. >> >> If you still think it is the bug of compiler. I suggest that you move the >> bug discussion to the compiler-...@openjdk.java.net to solve the bug as soon >> as possible. > > This message is purely informational: I may have found a JBS comment that > provides historical context for that "this method is likely to run > significantly faster under most implementations" phrase. Here: > https://bugs.openjdk.java.net/browse/JDK-4822887?focusedCommentId=12241154&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-12241154 @pavelrappo the problem is that people still believe this message and use this utility method widely: see e.g. https://github.com/spring-projects/spring-framework/pull/23478 They expect it to improve performance, but in fact it degradates. Also for some cases it degrade dramatically, e.g. when instead of `ArrayList` `COWArrayList` comes as argument @pavelrappo also see this not very old comment: https://github.com/spring-projects/spring-framework/pull/24636#pullrequestreview-370684078 ------------- PR: https://git.openjdk.java.net/jdk/pull/1764