mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
Java: Improved inspection "MethodHandle/VarHandle type mismatch" - show candidates for replacement of method/constructor in a separate pop-up menu (IDEA-167318)
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findConstructor(Test.class, MethodType.methodType(void.class, int.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public Test() {}
|
||||
public Test(int a) {}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findConstructor(Test.class, MethodType.methodType(void.class, int.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public Test(int a) {}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findConstructor(Test.class, MethodType.methodType(void.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findConstructor(Test.class, MethodType.methodType(void.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public Test() {}
|
||||
public Test(int a) {}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", MethodType.methodType(Object.class, Object.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public <T> T method(T a) {return null;}
|
||||
public <T> T method(T a, T... b) {return null;}
|
||||
public <T> T method(T a, String b) {return null;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", MethodType.methodType(Object.class, Object.class, Object[].class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public <T> T method(T a) {return null;}
|
||||
public <T> T method(T a, T... b) {return null;}
|
||||
public <T> T method(T a, String b) {return null;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", MethodType.methodType(Object.class, Object.class, String.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public <T> T method(T a) {return null;}
|
||||
public <T> T method(T a, T... b) {return null;}
|
||||
public <T> T method(T a, String b) {return null;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", MethodType.methodType(Object.class, Object.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public <T> T method(T a) {return null;}
|
||||
public <T> T method(T a, T... b) {return null;}
|
||||
public <T> T method(T a, String b) {return null;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findStatic(Test.class, "method", MethodType.methodType(void.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static void method() {}
|
||||
public static String method(String a) {return a;}
|
||||
public static String method(String a, String... b) {return a;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findStatic(Test.class, "method", MethodType.methodType(String.class, String.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static void method() {}
|
||||
public static String method(String a) {return a;}
|
||||
public static String method(String a, String... b) {return a;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findStatic(Test.class, "method", MethodType.methodType(String.class, String.class, String[].class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static void method() {}
|
||||
public static String method(String a) {return a;}
|
||||
public static String method(String a, String... b) {return a;}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findStatic(Test.class, "method", MethodType.methodType(void.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static void method() {}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findVirtual(Test.class, "method", MethodType.methodType(void.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void method() {}
|
||||
public String method(String a) {return a;}
|
||||
public String method(String a, String... b) {return a;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", MethodType.methodType(String.class, String.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void method() {}
|
||||
public String method(String a) {return a;}
|
||||
public String method(String a, String... b) {return a;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", MethodType.methodType(String.class, String.class, String[].class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void method() {}
|
||||
public String method(String a) {return a;}
|
||||
public String method(String a, String... b) {return a;}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findVirtual(Test.class, "method", MethodType.methodType(void.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void method() {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findConstructor(Test.class, <caret>MethodType.methodType(void.class, String.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public Test() {}
|
||||
public Test(int a) {}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findConstructor(Test.class, <caret>MethodType.methodType(void.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public Test(int a) {}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findConstructor(Test.class, <caret>MethodType.methodType(void.class, String.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findConstructor(Test.class, <caret>MethodType.methodType(void.class, String.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public Test() {}
|
||||
public Test(int a) {}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", <caret>MethodType.genericMethodType(2));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public <T> T method(T a) {return null;}
|
||||
public <T> T method(T a, T... b) {return null;}
|
||||
public <T> T method(T a, String b) {return null;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", <caret>MethodType.genericMethodType(2));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public <T> T method(T a) {return null;}
|
||||
public <T> T method(T a, T... b) {return null;}
|
||||
public <T> T method(T a, String b) {return null;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", <caret>MethodType.genericMethodType(2));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public <T> T method(T a) {return null;}
|
||||
public <T> T method(T a, T... b) {return null;}
|
||||
public <T> T method(T a, String b) {return null;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", <caret>MethodType.genericMethodType(0, true));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public <T> T method(T a) {return null;}
|
||||
public <T> T method(T a, T... b) {return null;}
|
||||
public <T> T method(T a, String b) {return null;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findStatic(Test.class, "method", <caret>MethodType.methodType(String.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static void method() {}
|
||||
public static String method(String a) {return a;}
|
||||
public static String method(String a, String... b) {return a;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findStatic(Test.class, "method", <caret>MethodType.methodType(void.class, void.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static void method() {}
|
||||
public static String method(String a) {return a;}
|
||||
public static String method(String a, String... b) {return a;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findStatic(Test.class, "method", <caret>MethodType.methodType(String.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static void method() {}
|
||||
public static String method(String a) {return a;}
|
||||
public static String method(String a, String... b) {return a;}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.<caret>findVirtual(Test.class, "method", MethodType.methodType(void.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static void method() {}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findVirtual(Test.class, "method", <caret>MethodType.methodType(String.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void method() {}
|
||||
public String method(String a) {return a;}
|
||||
public String method(String a, String... b) {return a;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", <caret>MethodType.methodType(void.class, void.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void method() {}
|
||||
public String method(String a) {return a;}
|
||||
public String method(String a, String... b) {return a;}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
class Main {
|
||||
void foo() throws Exception {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
l.findVirtual(Test.class, "method", <caret>MethodType.methodType(String.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void method() {}
|
||||
public String method(String a) {return a;}
|
||||
public String method(String a, String... b) {return a;}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.<caret>findStatic(Test.class, "method", MethodType.methodType(void.class));
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public void method() {}
|
||||
}
|
||||
Reference in New Issue
Block a user