From 67ee1285ea303a7c5cd61cc90122b1a712fba6e7 Mon Sep 17 00:00:00 2001 From: Milk <1871357815@qq.com> Date: Sat, 19 Feb 2022 11:19:48 +0800 Subject: [PATCH] changed generate method name --- .../main/java/top/niunaijun/app/MainActivity.java | 6 +++--- .../proxy/BlackReflectionInterfaceProxy.java | 6 +++--- .../niunaijun/blackreflection/BlackReflection.java | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/top/niunaijun/app/MainActivity.java b/app/src/main/java/top/niunaijun/app/MainActivity.java index 92cb947..0d9169d 100644 --- a/app/src/main/java/top/niunaijun/app/MainActivity.java +++ b/app/src/main/java/top/niunaijun/app/MainActivity.java @@ -48,19 +48,19 @@ protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "============================"); // checkField - Field field = BRTestReflection.get()._checkfakeField(); + Field field = BRTestReflection.get()._check_fakeField(); Log.d(TAG, "checkField: " + field); Log.d(TAG, "============================"); // setContextField - BRTestReflection.get(testReflection)._setmContextValue(contextValue + " changed"); + BRTestReflection.get(testReflection)._set_mContextValue(contextValue + " changed"); Log.d(TAG, "mContextValue: " + BRTestReflection.get(testReflection).mContextValue()); Log.d(TAG, "============================"); // setStaticField - BRTestReflection.get()._setsStaticValue(staticValue + " changed"); + BRTestReflection.get()._set_sStaticValue(staticValue + " changed"); Log.d(TAG, "sStaticValue: " + BRTestReflection.get().sStaticValue()); Log.d(TAG, "============================"); diff --git a/compiler/src/main/java/top/niunaijun/blackreflection/proxy/BlackReflectionInterfaceProxy.java b/compiler/src/main/java/top/niunaijun/blackreflection/proxy/BlackReflectionInterfaceProxy.java index 08c186c..5ee5651 100644 --- a/compiler/src/main/java/top/niunaijun/blackreflection/proxy/BlackReflectionInterfaceProxy.java +++ b/compiler/src/main/java/top/niunaijun/blackreflection/proxy/BlackReflectionInterfaceProxy.java @@ -119,7 +119,7 @@ public JavaFile generateInterfaceCode() { } private MethodSpec generateFieldSet(BlackReflectionInterfaceInfo reflection) { - MethodSpec.Builder method = MethodSpec.methodBuilder("_set" + reflection.getExecutableElement().getSimpleName().toString()) + MethodSpec.Builder method = MethodSpec.methodBuilder("_set_" + reflection.getExecutableElement().getSimpleName().toString()) .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT) .addParameter(ClassName.get("java.lang", "Object"), "value", Modifier.FINAL) .addAnnotation(AnnotationSpec.builder(BFieldSetNotProcess.class).build()); @@ -127,7 +127,7 @@ private MethodSpec generateFieldSet(BlackReflectionInterfaceInfo reflection) { } private MethodSpec generateFieldCheck(BlackReflectionInterfaceInfo reflection) { - MethodSpec.Builder method = MethodSpec.methodBuilder("_check" + reflection.getExecutableElement().getSimpleName().toString()) + MethodSpec.Builder method = MethodSpec.methodBuilder("_check_" + reflection.getExecutableElement().getSimpleName().toString()) .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT) .addAnnotation(AnnotationSpec.builder(BFieldCheckNotProcess.class).build()) .returns(Field.class); @@ -135,7 +135,7 @@ private MethodSpec generateFieldCheck(BlackReflectionInterfaceInfo reflection) { } private MethodSpec generateMethodCheck(BlackReflectionInterfaceInfo reflection, List parameterSpecs) { - MethodSpec.Builder method = MethodSpec.methodBuilder("_check" + reflection.getExecutableElement().getSimpleName().toString()) + MethodSpec.Builder method = MethodSpec.methodBuilder("_check_" + reflection.getExecutableElement().getSimpleName().toString()) .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT) .addAnnotation(AnnotationSpec.builder(BMethodCheckNotProcess.class).build()) .returns(Method.class); diff --git a/core/src/main/java/top/niunaijun/blackreflection/BlackReflection.java b/core/src/main/java/top/niunaijun/blackreflection/BlackReflection.java index 2bcfa50..f51d82c 100644 --- a/core/src/main/java/top/niunaijun/blackreflection/BlackReflection.java +++ b/core/src/main/java/top/niunaijun/blackreflection/BlackReflection.java @@ -96,8 +96,8 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl // void BFieldSetNotProcess bFieldSetNotProcess = method.getAnnotation(BFieldSetNotProcess.class); if (bFieldSetNotProcess != null) { - // startsWith "_set" - name = name.substring("_set".length()); + // startsWith "_set_" + name = name.substring("_set_".length()); Reflector on = Reflector.on(aClass).field(name); if (isStatic) { on.set(args[0]); @@ -113,8 +113,8 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl // check field BFieldCheckNotProcess bFieldCheckNotProcess = method.getAnnotation(BFieldCheckNotProcess.class); if (bFieldCheckNotProcess != null) { - // startsWith "check" - name = name.substring("_check".length()); + // startsWith "_check_" + name = name.substring("_check_".length()); Reflector on = Reflector.on(aClass).field(name); return on.getField(); } @@ -124,8 +124,8 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl // check method BMethodCheckNotProcess bMethodCheckNotProcess = method.getAnnotation(BMethodCheckNotProcess.class); if (bMethodCheckNotProcess != null) { - // startsWith "_check" - name = name.substring("_check".length()); + // startsWith "_check_" + name = name.substring("_check_".length()); Reflector on = Reflector.on(aClass).method(name, paramClass); return on.getMethod(); }