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 2022/09/07 05:55:48 UTC

[GitHub] [netbeans] MegJayan opened a new pull request, #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

MegJayan opened a new pull request, #4592:
URL: https://github.com/apache/netbeans/pull/4592

   Provide hints for converting thread pools(newFixedThreadPool, newCachedThreadPool) to virtual thread pool executor.
   When ThreadFactory is passed as argument to , then only a hint suggestion for converting the thread pool to newThreadPerTaskExecutor is provided. Code is not directly rewritten in this case.
   
   


-- 
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 diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r988543268


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   what do you think about `hintKind = Hint.Kind.INSPECTION, severity = Severity.HINT`, would this be also ok?
   
   advantage:
    - it can be used as inspection too
    - it remains current-line-only just like with `hintKind = ACTION`
   
   actions won't be listed in the source->inspect and refactor->inspect and transform dialogs and the user can't change the setting from current-line to warning since the combo box is disabled. (i could be wrong but thats how it was when I tested it)



-- 
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 diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r982841116


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   this could return a rewrite fix, otherwise it will just mark the line and do nothing.
   something like:
   
   ```java
   Fix fix = JavaFixUtilities.rewriteFix(ctx, "converts to VT msg", ctx.getPath(), "java.util.concurrent.Executors.newThreadPerTaskExecutor($factory)");
   ```
   and...
   ```java
   Fix fix = JavaFixUtilities.rewriteFix(ctx, "converts to VT msg", ctx.getPath(), "java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor()");
   ```



-- 
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] lahodaj commented on a diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
lahodaj commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r974237529


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToVT.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import com.sun.source.tree.AssignmentTree;
+import com.sun.source.tree.ExpressionStatementTree;
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.MemberSelectTree;
+import com.sun.source.tree.MethodInvocationTree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.TreePath;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.api.java.source.CompilationInfo;
+import org.netbeans.api.java.source.WorkingCopy;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.JavaFix;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_ConvertToVT=Convert to Virtual Thread Executor",
+    "DESC_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToVT=Convert to Virtual Thread Executor",
+    "FIX_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToThreadPerTask=Convert to newThreadPerTask executor"
+})
+@Hint(displayName = "#DN_ConvertToVT", description = "#DESC_ConvertToVT", category = "rules15",
+        minSourceVersion = "19")
+public class ConvertToVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "$var = $expr2.$meth1($var1$);"),

Review Comment:
   I'm afraid the hint is written in a way that is not ideal. Using `$expr2.$meth1`, and then checking inside the hint whether or not is error prone and relatively slow.
   
   Doing something like:
   ```
   @TriggerPattern(value="java.util.concurrent.Executors.newFixedThreadPool($size)" /*maybe a Constraint requiring that $size is an `int`*/)
   @TriggerPattern(value="java.util.concurrent.Executors.newFixedThreadPool($size, $factory)" /*maybe a Constraint requiring that $size is an `int` and $factory is a ThreadFactory*/)
   ```
   
   would avoid a lot of corner case states in the hint. (Patterns are meant to be cheap, so even some duplication should not be a problem, but if it is important to verify that the result is assigned into a variable, checking the enclosing AST node  in the hint might be more viable.) In this case, saying `java.util.concurrent.Executors.newFixedThreadPool` will tell the framework to not call the hint at all unless the `newFixedThreadPool` method on `java.util.concurrent.Executors` is called, which should be much faster (the framework should be able to eliminate non-matching patterns fairly quickly).



##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToVT.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import com.sun.source.tree.AssignmentTree;
+import com.sun.source.tree.ExpressionStatementTree;
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.MemberSelectTree;
+import com.sun.source.tree.MethodInvocationTree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.TreePath;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.api.java.source.CompilationInfo;
+import org.netbeans.api.java.source.WorkingCopy;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.JavaFix;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_ConvertToVT=Convert to Virtual Thread Executor",
+    "DESC_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToVT=Convert to Virtual Thread Executor",
+    "FIX_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToThreadPerTask=Convert to newThreadPerTask executor"
+})
+@Hint(displayName = "#DN_ConvertToVT", description = "#DESC_ConvertToVT", category = "rules15",
+        minSourceVersion = "19")
+public class ConvertToVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "$var = $expr2.$meth1($var1$);"),
+        @TriggerPattern(value = "$type $var = $expr2.$meth1($var1$);")
+    })
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        List<String> methList = Arrays.asList("newFixedThreadPool", "newCachedThreadPool");
+        String expr = ctx.getInfo().getTrees().getElement(ctx.getVariables().get("$expr2")).getSimpleName().toString();

Review Comment:
   Please note that `Trees.getElement` may, in general, return `null`.



##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToVT.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import com.sun.source.tree.AssignmentTree;
+import com.sun.source.tree.ExpressionStatementTree;
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.MemberSelectTree;
+import com.sun.source.tree.MethodInvocationTree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.TreePath;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.api.java.source.CompilationInfo;
+import org.netbeans.api.java.source.WorkingCopy;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.JavaFix;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_ConvertToVT=Convert to Virtual Thread Executor",
+    "DESC_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToVT=Convert to Virtual Thread Executor",
+    "FIX_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToThreadPerTask=Convert to newThreadPerTask executor"
+})
+@Hint(displayName = "#DN_ConvertToVT", description = "#DESC_ConvertToVT", category = "rules15",
+        minSourceVersion = "19")
+public class ConvertToVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "$var = $expr2.$meth1($var1$);"),
+        @TriggerPattern(value = "$type $var = $expr2.$meth1($var1$);")
+    })
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        List<String> methList = Arrays.asList("newFixedThreadPool", "newCachedThreadPool");
+        String expr = ctx.getInfo().getTrees().getElement(ctx.getVariables().get("$expr2")).getSimpleName().toString();
+        String method = ctx.getVariableNames().get("$meth1");
+        Collection<? extends TreePath> treePaths = ctx.getMultiVariables().get("$var1$");
+        boolean factory = false;
+        for (TreePath treePath : treePaths) {
+            if (treePath.getLeaf() instanceof IdentifierTree) {
+                factory = true;
+            }
+        }
+        if (expr.equals("Executors") && methList.contains(method)) {

Review Comment:
   Note that matching simple names is usually not very reliable. The user may have `Executors` class in their own package, and we probably should not be rewriting those.



##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToVT.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import com.sun.source.tree.AssignmentTree;
+import com.sun.source.tree.ExpressionStatementTree;
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.MemberSelectTree;
+import com.sun.source.tree.MethodInvocationTree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.TreePath;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.api.java.source.CompilationInfo;
+import org.netbeans.api.java.source.WorkingCopy;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.JavaFix;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_ConvertToVT=Convert to Virtual Thread Executor",
+    "DESC_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToVT=Convert to Virtual Thread Executor",
+    "FIX_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToThreadPerTask=Convert to newThreadPerTask executor"
+})
+@Hint(displayName = "#DN_ConvertToVT", description = "#DESC_ConvertToVT", category = "rules15",
+        minSourceVersion = "19")
+public class ConvertToVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "$var = $expr2.$meth1($var1$);"),
+        @TriggerPattern(value = "$type $var = $expr2.$meth1($var1$);")
+    })
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        List<String> methList = Arrays.asList("newFixedThreadPool", "newCachedThreadPool");
+        String expr = ctx.getInfo().getTrees().getElement(ctx.getVariables().get("$expr2")).getSimpleName().toString();
+        String method = ctx.getVariableNames().get("$meth1");
+        Collection<? extends TreePath> treePaths = ctx.getMultiVariables().get("$var1$");
+        boolean factory = false;
+        for (TreePath treePath : treePaths) {
+            if (treePath.getLeaf() instanceof IdentifierTree) {

Review Comment:
   Not sure why `IdentifierTree` is important here - I can imagine cases like:
   `Executors.newFixedThreadPool(size)`, which will contain and identifier, and cases like:
   `Executors.newFixedThreadPool(1, new ThreadFactory() {...})`, which will not.
   
   I think that matching based on the specific method overload would be better.
   
   Also, checking `Tree`s, `Element`s or `TypeMirror`s using `instanceof` is not completely reliable, I'm afraid.



##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToVT.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import com.sun.source.tree.AssignmentTree;
+import com.sun.source.tree.ExpressionStatementTree;
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.MemberSelectTree;
+import com.sun.source.tree.MethodInvocationTree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.TreePath;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.api.java.source.CompilationInfo;
+import org.netbeans.api.java.source.WorkingCopy;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.JavaFix;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_ConvertToVT=Convert to Virtual Thread Executor",
+    "DESC_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToVT=Convert to Virtual Thread Executor",
+    "FIX_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToThreadPerTask=Convert to newThreadPerTask executor"
+})
+@Hint(displayName = "#DN_ConvertToVT", description = "#DESC_ConvertToVT", category = "rules15",
+        minSourceVersion = "19")
+public class ConvertToVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "$var = $expr2.$meth1($var1$);"),
+        @TriggerPattern(value = "$type $var = $expr2.$meth1($var1$);")
+    })
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        List<String> methList = Arrays.asList("newFixedThreadPool", "newCachedThreadPool");
+        String expr = ctx.getInfo().getTrees().getElement(ctx.getVariables().get("$expr2")).getSimpleName().toString();
+        String method = ctx.getVariableNames().get("$meth1");
+        Collection<? extends TreePath> treePaths = ctx.getMultiVariables().get("$var1$");
+        boolean factory = false;
+        for (TreePath treePath : treePaths) {
+            if (treePath.getLeaf() instanceof IdentifierTree) {
+                factory = true;
+            }
+        }
+        if (expr.equals("Executors") && methList.contains(method)) {
+            Fix fix = new FixImpl(ctx.getInfo(), ctx.getPath(), factory).toEditorFix();
+            if (factory) {
+                return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_ConvertToThreadPerTask(), fix);
+            } else {
+                return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_ConvertToVT(), fix);
+            }
+        }
+        return null;
+    }
+
+    private static final class FixImpl extends JavaFix {
+
+        boolean factory;
+
+        public FixImpl(CompilationInfo info, TreePath main, boolean factory) {
+            super(info, main);
+            this.factory = factory;
+        }
+
+        @Override
+        protected String getText() {
+            if (!factory) {
+                return Bundle.FIX_ConvertToVT();
+            } else {
+                return Bundle.ERR_ConvertToThreadPerTask();
+            }
+        }
+
+        @Override
+        protected void performRewrite(TransformationContext ctx) throws Exception {
+            if (!factory) {
+                WorkingCopy wc = ctx.getWorkingCopy();

Review Comment:
   FWIW, there is:
   `org.netbeans.spi.java.hints.JavaFixUtilities.rewriteFix` which allows to specify the re-write in a textual form. E.g.:
   `$var = $expr2.newVirtualThreadPerTaskExecutor($var1$);` (or, better: `java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor()`, if the first suggestion is adopted.)



##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToVT.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import com.sun.source.tree.AssignmentTree;
+import com.sun.source.tree.ExpressionStatementTree;
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.MemberSelectTree;
+import com.sun.source.tree.MethodInvocationTree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.TreePath;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.api.java.source.CompilationInfo;
+import org.netbeans.api.java.source.WorkingCopy;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.JavaFix;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_ConvertToVT=Convert to Virtual Thread Executor",
+    "DESC_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToVT=Convert to Virtual Thread Executor",
+    "FIX_ConvertToVT=Convert to Virtual Thread Executor",
+    "ERR_ConvertToThreadPerTask=Convert to newThreadPerTask executor"
+})
+@Hint(displayName = "#DN_ConvertToVT", description = "#DESC_ConvertToVT", category = "rules15",
+        minSourceVersion = "19")
+public class ConvertToVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "$var = $expr2.$meth1($var1$);"),
+        @TriggerPattern(value = "$type $var = $expr2.$meth1($var1$);")
+    })
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        List<String> methList = Arrays.asList("newFixedThreadPool", "newCachedThreadPool");
+        String expr = ctx.getInfo().getTrees().getElement(ctx.getVariables().get("$expr2")).getSimpleName().toString();
+        String method = ctx.getVariableNames().get("$meth1");
+        Collection<? extends TreePath> treePaths = ctx.getMultiVariables().get("$var1$");
+        boolean factory = false;
+        for (TreePath treePath : treePaths) {
+            if (treePath.getLeaf() instanceof IdentifierTree) {
+                factory = true;
+            }
+        }
+        if (expr.equals("Executors") && methList.contains(method)) {
+            Fix fix = new FixImpl(ctx.getInfo(), ctx.getPath(), factory).toEditorFix();
+            if (factory) {
+                return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_ConvertToThreadPerTask(), fix);

Review Comment:
   As far as I can tell, the fix is not doing anything for `factory==true`, so maybe it should not be used at all? It is OK to have a warning if we don't/can't have a fix, but showing a fix to the user that then doing nothing feels confusing.



-- 
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] singh-akhilesh merged pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
singh-akhilesh merged PR #4592:
URL: https://github.com/apache/netbeans/pull/4592


-- 
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 diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r982841116


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   this could return a rewrite fix, otherwise it will just mark the line and do nothing.
   something like:
   ```java
   Fix fix = JavaFixUtilities.rewriteFix(ctx, "converts to VT msg", ctx.getPath(), "java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor()");
   ```
   for the else branch at least. If the user provides a thread factory we can't really provide a suggestion.



-- 
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 diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r988543268


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   what do you think about `hintKind = Hint.Kind.INSPECTION, severity = Severity.HINT`, would this be also ok?
   
   advantage:
    - it can be used as inspection too
    - it remains current-line-only just like with `hintKind = ACTION`
   
   actions won't be listed in the source->inspect and refactor->inspect and transform dialogs and the user can't change the setting from current-line to warning since the combo box is disabled.



-- 
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 diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r988543268


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   what do you think about `hintKind = Hint.Kind.INSPECTION, severity = Severity.HINT`, would this be also ok?
   
   advantage:
    - it can be used as inspection too
    - it remains current-line-only just like with `hintKind = ACTION` (but user can change it)
   
   actions won't be listed in the source->inspect and refactor->inspect and transform dialogs and the user can't change the setting from current-line to warning since the combo box is disabled. (i could be wrong but thats how it was when I tested it)



-- 
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] arvindaprameya commented on pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
arvindaprameya commented on PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#issuecomment-1262131289

   Based on the comments we have now changed to give hints for the new feature of VT thats available. 
   Instead of converting the code. So no more automatic conversion.Hope this clarifies.


-- 
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] neilcsmith-net commented on pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#issuecomment-1262069916

   > VTs are great and I am all for using new features and having code transformations which help with migration but maybe _not enabled by default_
   
   Emphasis mine, but yes, agree, IMO should not be enabled by default, for now at least.


-- 
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 diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r988543268


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   what do you think about `hintKind = Hint.Kind.INSPECTION, severity = Severity.HINT`, would this be also ok?
   
   advantage:
    - it can be used as inspection too
    - it remains current-line-only just like with `hintKind = ACTION` (but user can change it)
   
   actions won't be listed in the `source->inspect` and `refactor->inspect and transform` dialogs and the user can't change the setting from current-line to warning since the combo box is disabled. (i could be wrong but thats how it was when I tested it)



-- 
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 diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r985187786


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   sorry for the delay.
   
   I believe this could be definitively useful as refactor-and-transform inspection. A dev can inspect a project and check if there are pools which can be moved to VTs on a case by case basis. If the code rule can convert the easy cases to the VT executor - why not (the difficult cases would be only marked without a transformation).
   
   I just don't think it should be enabled by default, because light bulbs can be perceived as something you should fix. But if a dev enables the hint manually, the situation is different since the choice has been already made.
   
   Those are just my thoughts, I don't have a strong opinion on it.



-- 
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] MegJayan commented on a diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
MegJayan commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r983386169


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   I understand your point. One of the reasons why we decided to give the hint was so that user is notified of  the support of virtual threads and he/she can take a call on whether to modify the current code to use virtual threads depending on the use case. This is why we are providing just the suggestion without rewriting the code.
   
   In the initial commit there was rewrite logic as well, but after the first round of discussion, it was decided just to go with hints and not rewrite anything as there could be multiple corner cases like Executors.newFixedThreadPool(1) [as mentioned by @lahodaj  [here](https://github.com/apache/netbeans/pull/4592#pullrequestreview-1112236691)] which probably should not be rewritten.
   This is the background. Please let me know your thoughts. If you think its best not to provide hints, I can update accordingly.
   



-- 
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] MegJayan commented on a diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
MegJayan commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r991078740


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   @mbien : I think it should be ok to modify the hintKind to INSPECTION. It will be listed in source-> inspect. But as per the previous conclusion we dont provide any fix for conversion to virtual threads. So refactor-> inspect and transform will not work for transformation.



-- 
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] MegJayan commented on a diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
MegJayan commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r991841344


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   I have updated the PR changing hintKind to INSPECTION. Since transformation is not available, it shows the below msg on clicking Inspect and Transform:
   No fix for: Can Use Virtual Thread Executor at JavaApplication2.java:21
   I think this conveys to the user that transformation isnt available and this should be ok.
   



-- 
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 diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r982841116


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   this could return a rewrite fix, otherwise it will just mark the line and do nothing.
   something like:
   ```java
   Fix fix = JavaFixUtilities.rewriteFix(ctx, "converts to VT msg", ctx.getPath(), "java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor()");
   ```
   for the else branch at least. If the user provides a thread factory we don#t really can provide a suggestion.



-- 
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 diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r991148069


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   @MegJayan right, there would be no transformation offered if its used via inspect and transform. But it would be current-line-only just like an action (but also configurable by the user) with the added benefit of it being usable as an inspection too (which I imagine could be super useful in some situations).
   
   I don't know how to hide hints from the transformation dialog if they don't offer fixes. Maybe a third kind `{ACTION, INSPECTION, TRANSFORMATION}` would be required 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 diff in pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#discussion_r992143103


##########
java/java.hints/src/org/netbeans/modules/java/hints/jdk/CanUseVT.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.hints.jdk;
+
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.modules.java.hints.errors.Utilities;
+import org.netbeans.spi.editor.hints.ErrorDescription;
+import org.netbeans.spi.editor.hints.Fix;
+import org.netbeans.spi.java.hints.ConstraintVariableType;
+import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
+import org.netbeans.spi.java.hints.Hint;
+import org.netbeans.spi.java.hints.HintContext;
+import org.netbeans.spi.java.hints.TriggerPattern;
+import org.netbeans.spi.java.hints.TriggerPatterns;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author mjayan
+ */
+@NbBundle.Messages({
+    "DN_CanUseVT=Can use Virtual Threads",
+    "DESC_CanUseVT=Can use virtual threads if workload is not CPU bound or number of concurrent tasks is high",
+    "ERR_CanUseVT=Can Use Virtual Thread Executor",
+    "ERR_CanUseThreadPerTask=Can Use Executors.newThreadPerTaskExecutor"
+})
+@Hint(displayName = "#DN_CanUseVT", description = "#DESC_CanUseVT", category = "rules15",
+        minSourceVersion = "19")
+public class CanUseVT {
+
+    private static final int VT_PREVIEW_JDK_VERSION = 19;
+
+    @TriggerPatterns({
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size)", constraints = @ConstraintVariableType(variable = "$size", type = "int")),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newFixedThreadPool($size, $factory)", constraints = {
+            @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"),
+            @ConstraintVariableType(variable = "$size", type = "int")}),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool()"),
+        @TriggerPattern(value = "java.util.concurrent.Executors.newCachedThreadPool($factory)", constraints
+                = @ConstraintVariableType(variable = "$factory", type = "java.util.concurrent.ThreadFactory"))})
+    public static ErrorDescription compute(HintContext ctx) {
+        if (Utilities.isJDKVersionLower(VT_PREVIEW_JDK_VERSION) && !CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview")) {
+            return null;
+        }
+        if (ctx.getVariables().get("$factory") != null) {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseThreadPerTask(), new Fix[0]);
+        } else {
+            return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_CanUseVT(), new Fix[0]);
+        }

Review Comment:
   thank you @MegJayan for your patience. I am looking forward to use the new inspection/hint to find candidates for VTs.



-- 
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] neilcsmith-net commented on pull request #4592: Provide hints for conversion to Virtual thread executor when thread pools are used

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on PR #4592:
URL: https://github.com/apache/netbeans/pull/4592#issuecomment-1282155031

   @singh-akhilesh please make sure there's a milestone set when merging, 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