{"id":24102,"date":"2011-04-08T06:55:39","date_gmt":"2011-04-08T11:55:39","guid":{"rendered":"https:\/\/blogs.jetbrains.com\/idea\/?p=4820"},"modified":"2011-04-08T06:55:39","modified_gmt":"2011-04-08T11:55:39","slug":"java-7-safevarargs","status":"publish","type":"idea","link":"https:\/\/blog.jetbrains.com\/en\/idea\/2011\/04\/java-7-safevarargs","title":{"rendered":"Java 7. @SafeVarargs"},"content":{"rendered":"<p>Java 7 provides a way to remove a compiler warning about generics vararg invocation. With Java 7 you can annotate your vararg method with <code>SafeVararg<\/code> annotation and your clients won&#8217;t get these nasty warnings any more. <strong><a href=\"http:\/\/confluence.jetbrains.net\/display\/IDEADEV\/IDEA+10.5+EAP\" target=\"_blank\" rel=\"noopener\">IntelliJ IDEA 10.5<\/a><\/strong> will help you to perform this migration. It will find for you all the places where <code>@SafeVarargs<\/code> annotation is applicable and suggest you to add this annotation. Of course, it will also check if existing <code>@SafeVarargs<\/code> annotations are applicable.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-4821\" title=\"safevarargsquickfix\" width=\"1600\" height=\"210\" src=\"http:\/\/blogs.jetbrains.com\/idea\/wp-content\/uploads\/2011\/03\/safevarargsquickfix.png\" alt=\"\"  \/><\/a><\/p>\n<p>Suppose you have annotated your method with <code>@SafeVararg<\/code> but already have suppressions for unchecked warning in client&#8217;s code:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-4822 aligncenter\" title=\"safevarargs_redundantsuppressions\" src=\"http:\/\/blogs.jetbrains.com\/idea\/wp-content\/uploads\/2011\/03\/safevarargs_redundantsuppressions.png\" alt=\"\" width=\"473\" height=\"360\" \/><\/p>\n<p>Since its version 6 IntelliJ IDEA contains an inspection to find redundant suppressions (available in batch mode only). Now you can use it to remove all suppressions which are garbage in your code. It will carefully check that these unchecked warnings were caused by generics vararg invocation and suggest you to remove all such suppressions. Simply run the &#8216;Redundant Suppression&#8217; inspection (<strong>Ctrl-Alt-Shift-I<\/strong>).<br \/>\n<img decoding=\"async\" class=\"aligncenter size-full wp-image-4825\" title=\"redundantsupppress\" width=\"1600\" height=\"120\" src=\"http:\/\/blogs.jetbrains.com\/idea\/wp-content\/uploads\/2011\/03\/redundantsupppress.png\" alt=\"\" \/><\/p>\n<p>All you need to do is to install Java 7 and setup language level to 7.<\/p>\n<p><a href=\"http:\/\/confluence.jetbrains.net\/display\/IDEADEV\/IDEA+10.5+EAP\" target=\"_blank\" rel=\"noopener\">Download IntelliJ IDEA 10.5 EAP,<\/a> try the new described features and let us know what you think.<\/p>\n","protected":false},"author":150,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","categories":[808],"tags":[991,3099],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/en\/wp-json\/wp\/v2\/idea\/24102"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/en\/wp-json\/wp\/v2\/idea"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/en\/wp-json\/wp\/v2\/types\/idea"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/en\/wp-json\/wp\/v2\/users\/150"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/en\/wp-json\/wp\/v2\/comments?post=24102"}],"version-history":[{"count":0,"href":"https:\/\/blog.jetbrains.com\/en\/wp-json\/wp\/v2\/idea\/24102\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/en\/wp-json\/wp\/v2\/media?parent=24102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/en\/wp-json\/wp\/v2\/categories?post=24102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/en\/wp-json\/wp\/v2\/tags?post=24102"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/en\/wp-json\/wp\/v2\/cross-post-tag?post=24102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}