mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +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() {}
|
||||
}
|
||||
Reference in New Issue
Block a user