mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: Added quick fix tests for "MethodHandle/VarHandle type mismatch" inspection (IDEA-167318)
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
// "Use constructor 'Test(int)'" "true"
|
||||
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) {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Use constructor 'Test(int)'" "true"
|
||||
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) {}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Use constructor 'Test()'" "true"
|
||||
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 {
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Use constructor 'Test()'" "true"
|
||||
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) {}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.Object method(java.lang.Object)'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.Object method(java.lang.Object, java.lang.Object[])'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.Object method(java.lang.Object, java.lang.String)'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.Object method(java.lang.Object)'" "true"
|
||||
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;}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findGetter(Test.class, "myInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findGetter'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findGetter(Test.class, "myInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findSetter(Test.class, "myInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findSetter'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findSetter(Test.class, "myInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findStaticGetter(Test.class, "ourInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findStaticGetter'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findStaticGetter(Test.class, "ourInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'void method()'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.String method(java.lang.String)'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.String method(java.lang.String, java.lang.String[])'" "true"
|
||||
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;}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findStatic'" "true"
|
||||
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() {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findStaticSetter(Test.class, "ourInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findStaticSetter'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findStaticSetter(Test.class, "ourInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findStaticVarHandle(Test.class, "ourInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findStaticVarHandle'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findStaticVarHandle(Test.class, "ourInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findVarHandle(Test.class, "myInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findVarHandle'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findVarHandle(Test.class, "myInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'void method()'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.String method(java.lang.String)'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.String method(java.lang.String, java.lang.String[])'" "true"
|
||||
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;}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findVirtual'" "true"
|
||||
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() {}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Use constructor 'Test(int)'" "true"
|
||||
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) {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Use constructor 'Test(int)'" "true"
|
||||
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) {}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Use constructor 'Test()'" "true"
|
||||
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 {
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Use constructor 'Test()'" "true"
|
||||
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) {}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.Object method(java.lang.Object)'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.Object method(java.lang.Object, java.lang.Object[])'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.Object method(java.lang.Object, java.lang.String)'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.Object method(java.lang.Object)'" "true"
|
||||
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;}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findGetter(Test.class, "myInt", <caret>String.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findGetter'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.<caret>findStaticGetter(Test.class, "myInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findSetter(Test.class, "myInt", <caret>String.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findSetter'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.<caret>findStaticSetter(Test.class, "myInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findStaticGetter(Test.class, "ourInt", <caret>String.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findStaticGetter'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.<caret>findGetter(Test.class, "ourInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'void method()'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.String method(java.lang.String)'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.String method(java.lang.String, java.lang.String[])'" "true"
|
||||
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;}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findStatic'" "true"
|
||||
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() {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findStaticSetter(Test.class, "ourInt", <caret>String.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findStaticSetter'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.<caret>findSetter(Test.class, "ourInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findStaticVarHandle(Test.class, "ourInt", <caret>boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findStaticVarHandle'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.<caret>findVarHandle(Test.class, "ourInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public static int ourInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Change type to 'int'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.findVarHandle(Test.class, "myInt", <caret>String.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findVarHandle'" "true"
|
||||
import java.lang.invoke.*;
|
||||
|
||||
public class Main {
|
||||
void foo() throws Throwable {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
lookup.<caret>findStaticVarHandle(Test.class, "myInt", int.class);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
public int myInt;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'void method()'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.String method(java.lang.String)'" "true"
|
||||
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;}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Use method 'java.lang.String method(java.lang.String, java.lang.String[])'" "true"
|
||||
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;}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with 'findVirtual'" "true"
|
||||
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() {}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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 com.intellij.codeInsight.daemon.quickFix
|
||||
|
||||
import com.intellij.codeInspection.reflectiveAccess.JavaLangInvokeHandleSignatureInspection
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
|
||||
/**
|
||||
* @author Pavel.Dolgov
|
||||
*/
|
||||
class JavaLangInvokeHandleSignatureFixTest : LightQuickFixParameterizedTestCase() {
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor = LightCodeInsightFixtureTestCase.JAVA_9
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
enableInspectionTool(JavaLangInvokeHandleSignatureInspection())
|
||||
}
|
||||
|
||||
fun test() = doAllTests()
|
||||
|
||||
override fun getBasePath() = "/codeInsight/daemonCodeAnalyzer/quickFix/invokeHandle"
|
||||
}
|
||||
Reference in New Issue
Block a user