You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/09/13 13:11:58 UTC

[GitHub] [netbeans] mbien opened a new pull request #3166: Updated Collection.toArray() refactoring

mbien opened a new pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166


   The performance inspection currently advises to refactor `col.toArray(new T[0])` into `col.toArray(new T[col.size])` which is exactly the wrong way around for modern Java[1].
   
   Updated it to refactor to `T[]::new` on JDK 11+ and `new T[0]` for older JDKs (determined by the project src lvl).
   
   
   [1] https://shipilev.net/blog/2016/arrays-wisdom-ancients/#_conclusion


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] jlahoda commented on a change in pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
jlahoda commented on a change in pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#discussion_r719963605



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/Tiny.java
##########
@@ -337,11 +353,24 @@ public static ErrorDescription collectionsToArray(HintContext ctx) {
         Fix[] fixes;
 
         if (pureMemberSelect) {
-            String fixDisplayName = NbBundle.getMessage(Tiny.class, "FIX_Tiny_collectionsToArray");
 
-            fixes = new Fix[] {
-                JavaFixUtilities.rewriteFix(ctx, fixDisplayName, ctx.getPath(), "$collection.toArray(new $clazz[$collection.size()])")
-            };
+            SourceVersion version = ctx.getInfo().getSourceVersion();
+            TreePath type = ctx.getVariables().get("$clazz");
+            String typeName = type.getLeaf().toString();
+            
+            if (Integer.parseInt(version.name().substring(version.name().indexOf('_')+1)) >= 11) {

Review comment:
       Use of `SourceVersion`/`CompilationInfo.getSourceVersion()` is correct, but `SourceVersion` is `Comparable`, so can be compared without integer tricks. Please see method `unnecessaryTempFromString` in this class for an example.

##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/Tiny.java
##########
@@ -314,15 +323,22 @@ private static ErrorDescription enumHint(HintContext ctx, String baseName, Strin
     @Hint(displayName = "#DN_org.netbeans.modules.java.hints.perf.Tiny.collectionsToArray",
           description = "#DESC_org.netbeans.modules.java.hints.perf.Tiny.collectionsToArray",
           category="performance",
-          enabled=false,
+          enabled=true,
           suppressWarnings="CollectionsToArray")
-    @TriggerPattern(value = "$collection.toArray(new $clazz[0])",
-                    constraints=@ConstraintVariableType(variable="$collection",
-                                                        type="java.util.Collection"))
+    @TriggerPatterns({
+        @TriggerPattern(value = "$collection.toArray(new $clazz[$collection.size()])",
+                        constraints = @ConstraintVariableType(variable="$collection", type="java.util.Collection")),
+        @TriggerPattern(value = "$collection.toArray(new $clazz[0])",

Review comment:
       The two patterns with `$clazz[0]` and `$clazz[]{}` should not be needed, correct? (And if only the `$collection.size()` pattern would remain, there probably would be no need for `isNewArrayWithSize`? Or do I miss something?)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on pull request #3166: Updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
mbien commented on pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#issuecomment-918701806


   travis failures seem unrelated on this one too


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#discussion_r720146617



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/Tiny.java
##########
@@ -337,11 +353,24 @@ public static ErrorDescription collectionsToArray(HintContext ctx) {
         Fix[] fixes;
 
         if (pureMemberSelect) {
-            String fixDisplayName = NbBundle.getMessage(Tiny.class, "FIX_Tiny_collectionsToArray");
 
-            fixes = new Fix[] {
-                JavaFixUtilities.rewriteFix(ctx, fixDisplayName, ctx.getPath(), "$collection.toArray(new $clazz[$collection.size()])")
-            };
+            SourceVersion version = ctx.getInfo().getSourceVersion();
+            TreePath type = ctx.getVariables().get("$clazz");
+            String typeName = type.getLeaf().toString();
+            
+            if (Integer.parseInt(version.name().substring(version.name().indexOf('_')+1)) >= 11) {

Review comment:
       can i compare against 11 if NB is running on <11 without nb-javac? SourceVersion is part of the JDK if i see this correctly - the enum would not be there.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#discussion_r730111697



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/Tiny.java
##########
@@ -337,11 +353,24 @@ public static ErrorDescription collectionsToArray(HintContext ctx) {
         Fix[] fixes;
 
         if (pureMemberSelect) {
-            String fixDisplayName = NbBundle.getMessage(Tiny.class, "FIX_Tiny_collectionsToArray");
 
-            fixes = new Fix[] {
-                JavaFixUtilities.rewriteFix(ctx, fixDisplayName, ctx.getPath(), "$collection.toArray(new $clazz[$collection.size()])")
-            };
+            SourceVersion version = ctx.getInfo().getSourceVersion();
+            TreePath type = ctx.getVariables().get("$clazz");
+            String typeName = type.getLeaf().toString();
+            
+            if (Integer.parseInt(version.name().substring(version.name().indexOf('_')+1)) >= 11) {

Review comment:
       i interpret the silence as "maybe" :) so I changed it to the suggested approach (using a constant) in 56cf1c5b4d9b770b7fe39a34be373c0d0165ae58




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#discussion_r728086391



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/Tiny.java
##########
@@ -337,11 +353,24 @@ public static ErrorDescription collectionsToArray(HintContext ctx) {
         Fix[] fixes;
 
         if (pureMemberSelect) {
-            String fixDisplayName = NbBundle.getMessage(Tiny.class, "FIX_Tiny_collectionsToArray");
 
-            fixes = new Fix[] {
-                JavaFixUtilities.rewriteFix(ctx, fixDisplayName, ctx.getPath(), "$collection.toArray(new $clazz[$collection.size()])")
-            };
+            SourceVersion version = ctx.getInfo().getSourceVersion();
+            TreePath type = ctx.getVariables().get("$clazz");
+            String typeName = type.getLeaf().toString();
+            
+            if (Integer.parseInt(version.name().substring(version.name().indexOf('_')+1)) >= 11) {

Review comment:
       @jlahoda ping




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing merged pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
matthiasblaesing merged pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] jlahoda commented on a change in pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
jlahoda commented on a change in pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#discussion_r720797216



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/Tiny.java
##########
@@ -337,11 +353,24 @@ public static ErrorDescription collectionsToArray(HintContext ctx) {
         Fix[] fixes;
 
         if (pureMemberSelect) {
-            String fixDisplayName = NbBundle.getMessage(Tiny.class, "FIX_Tiny_collectionsToArray");
 
-            fixes = new Fix[] {
-                JavaFixUtilities.rewriteFix(ctx, fixDisplayName, ctx.getPath(), "$collection.toArray(new $clazz[$collection.size()])")
-            };
+            SourceVersion version = ctx.getInfo().getSourceVersion();
+            TreePath type = ctx.getVariables().get("$clazz");
+            String typeName = type.getLeaf().toString();
+            
+            if (Integer.parseInt(version.name().substring(version.name().indexOf('_')+1)) >= 11) {

Review comment:
       Right again, but I think I'd still somewhat prefer to compare SourceVersions than play integer tricks. I'd try to create a static final field, initialize to SourceVersion.RELEASE_11 if it exists (`SourceVersion.valueOf("RELEASE_11")`), or null. Hopefully easier to find when we can depend on the new API.
   
   Thanks.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#discussion_r720142289



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/Tiny.java
##########
@@ -314,15 +323,22 @@ private static ErrorDescription enumHint(HintContext ctx, String baseName, Strin
     @Hint(displayName = "#DN_org.netbeans.modules.java.hints.perf.Tiny.collectionsToArray",
           description = "#DESC_org.netbeans.modules.java.hints.perf.Tiny.collectionsToArray",
           category="performance",
-          enabled=false,
+          enabled=true,
           suppressWarnings="CollectionsToArray")
-    @TriggerPattern(value = "$collection.toArray(new $clazz[0])",
-                    constraints=@ConstraintVariableType(variable="$collection",
-                                                        type="java.util.Collection"))
+    @TriggerPatterns({
+        @TriggerPattern(value = "$collection.toArray(new $clazz[$collection.size()])",
+                        constraints = @ConstraintVariableType(variable="$collection", type="java.util.Collection")),
+        @TriggerPattern(value = "$collection.toArray(new $clazz[0])",

Review comment:
       the thought process was as follows:
   `list.toArray(String[]::new)` is cleaner and less hacky than 
   `list.toArray(new String[0])` which looks like sub optimal code for some (although both have identical performance on modern JVMs - see updated PR text). IDEs also advised against it for a long time. Someone might add col.size() again not knowing the details and we are where we started.
   
   The same inspection can be used to refactor from array-with-zero to array-with-new if the source lvl allows it, which should be best practice for 11+.
   
   on 8 it refactors `new String[list.size()]` to `new String[0]`,
   on 11+ it refactors both `new String[0]` and `new String[list.size()]` to `list.toArray(String[]::new)`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#discussion_r720148517



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/Tiny.java
##########
@@ -337,11 +353,24 @@ public static ErrorDescription collectionsToArray(HintContext ctx) {
         Fix[] fixes;
 
         if (pureMemberSelect) {
-            String fixDisplayName = NbBundle.getMessage(Tiny.class, "FIX_Tiny_collectionsToArray");
 
-            fixes = new Fix[] {
-                JavaFixUtilities.rewriteFix(ctx, fixDisplayName, ctx.getPath(), "$collection.toArray(new $clazz[$collection.size()])")
-            };
+            SourceVersion version = ctx.getInfo().getSourceVersion();
+            TreePath type = ctx.getVariables().get("$clazz");
+            String typeName = type.getLeaf().toString();
+            
+            if (Integer.parseInt(version.name().substring(version.name().indexOf('_')+1)) >= 11) {

Review comment:
       unnecessaryTempFromString compares against 5 which doesn't have the same problem since 8 is minimum required JDK version for NB.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#discussion_r720820460



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/Tiny.java
##########
@@ -337,11 +353,24 @@ public static ErrorDescription collectionsToArray(HintContext ctx) {
         Fix[] fixes;
 
         if (pureMemberSelect) {
-            String fixDisplayName = NbBundle.getMessage(Tiny.class, "FIX_Tiny_collectionsToArray");
 
-            fixes = new Fix[] {
-                JavaFixUtilities.rewriteFix(ctx, fixDisplayName, ctx.getPath(), "$collection.toArray(new $clazz[$collection.size()])")
-            };
+            SourceVersion version = ctx.getInfo().getSourceVersion();
+            TreePath type = ctx.getVariables().get("$clazz");
+            String typeName = type.getLeaf().toString();
+            
+            if (Integer.parseInt(version.name().substring(version.name().indexOf('_')+1)) >= 11) {

Review comment:
       I implemented it here locally, but i gotta say it still looks very hacky. Esp the 
   `MODEL_VERSION_11 != null && MODEL_VERSION_11.compareTo(version) >= 0
   The main issue i see is that it will spread, other hints would have to keep doing the same thing, there is no nice way to make utility method out of this, to keep the ugly part in one place.
   
   I am glad that `Runtime.Version` uses ints to represent the feature version since this shows that enums are a bad idea for things like that (many other projects ran into the same trap).
   
   what we actually want to write is
   ```
   version.supports(11)
   ```
   or even better
   ```
   version.feature() >= 11
   ```
   Thats it, no time traveling needed to figure out potential future enums.
   
   what would you say to a reusable utility like:
    ```
       public static boolean supports(SourceVersion model, int featureVersionToCheck) {
           return model.ordinal() >= featureVersionToCheck;
       }
   ```
   This should be forward compatible for a long time, until JDK hopefully adds `version.feature()` to make it compatible with their own Runtime.version().feature() before breaking the enum ordering.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
mbien commented on pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#issuecomment-944948829


   regarding the version comparison discussion:
   there is a chance of the JDK getting a convenience method to convert from SourceVersion to Runtime.Version. This would allow NB to get rid of the enum init rituals some time in future. https://github.com/openjdk/jdk/pull/5973


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#issuecomment-948970053


   Lets get this in - it was reviewed and review comments were addressed to my understanding.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] jlahoda commented on a change in pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
jlahoda commented on a change in pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#discussion_r720796986



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/Tiny.java
##########
@@ -314,15 +323,22 @@ private static ErrorDescription enumHint(HintContext ctx, String baseName, Strin
     @Hint(displayName = "#DN_org.netbeans.modules.java.hints.perf.Tiny.collectionsToArray",
           description = "#DESC_org.netbeans.modules.java.hints.perf.Tiny.collectionsToArray",
           category="performance",
-          enabled=false,
+          enabled=true,
           suppressWarnings="CollectionsToArray")
-    @TriggerPattern(value = "$collection.toArray(new $clazz[0])",
-                    constraints=@ConstraintVariableType(variable="$collection",
-                                                        type="java.util.Collection"))
+    @TriggerPatterns({
+        @TriggerPattern(value = "$collection.toArray(new $clazz[$collection.size()])",
+                        constraints = @ConstraintVariableType(variable="$collection", type="java.util.Collection")),
+        @TriggerPattern(value = "$collection.toArray(new $clazz[0])",

Review comment:
       Right, sorry. The check is fine (we could split the checks into two method, but then the hint would need to be defined in a class not a method, so we would need to reorganize things here, and there's probably not a good reason for that).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3166: [jackpot] updated Collection.toArray() refactoring

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3166:
URL: https://github.com/apache/netbeans/pull/3166#discussion_r728086391



##########
File path: java/java.hints/src/org/netbeans/modules/java/hints/perf/Tiny.java
##########
@@ -337,11 +353,24 @@ public static ErrorDescription collectionsToArray(HintContext ctx) {
         Fix[] fixes;
 
         if (pureMemberSelect) {
-            String fixDisplayName = NbBundle.getMessage(Tiny.class, "FIX_Tiny_collectionsToArray");
 
-            fixes = new Fix[] {
-                JavaFixUtilities.rewriteFix(ctx, fixDisplayName, ctx.getPath(), "$collection.toArray(new $clazz[$collection.size()])")
-            };
+            SourceVersion version = ctx.getInfo().getSourceVersion();
+            TreePath type = ctx.getVariables().get("$clazz");
+            String typeName = type.getLeaf().toString();
+            
+            if (Integer.parseInt(version.name().substring(version.name().indexOf('_')+1)) >= 11) {

Review comment:
       @jlahoda ping




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists