From 740e207c5f7b76ae15cbdbee0d0f7551fa5219e5 Mon Sep 17 00:00:00 2001 From: Milk <1871357815@qq.com> Date: Wed, 16 Feb 2022 15:48:53 +0800 Subject: [PATCH] handle primitive type --- app/build.gradle | 4 +++ app/proguard-rules.pro | 14 +++++++++- app/src/main/AndroidManifest.xml | 6 ++--- .../{blackreflection => app}/App.java | 2 +- .../MainActivity.java | 9 ++++--- .../SecondActivity.java | 5 ++-- .../ref/ActivityThread.java | 2 +- .../ref/AppCompatActivity.java | 2 +- .../ref/MainActivity.java | 4 +-- app/src/main/res/layout/activity_main.xml | 2 +- .../proxy/BlackReflectionInterfaceProxy.java | 16 ++++++++++++ .../BlackNullPointerException.java | 15 +++++++++++ .../blackreflection/BlackReflection.java | 26 ++++++++++++++++--- 13 files changed, 86 insertions(+), 21 deletions(-) rename app/src/main/java/top/niunaijun/{blackreflection => app}/App.java (87%) rename app/src/main/java/top/niunaijun/{blackreflection => app}/MainActivity.java (88%) rename app/src/main/java/top/niunaijun/{blackreflection => app}/SecondActivity.java (87%) rename app/src/main/java/top/niunaijun/{blackreflection => app}/ref/ActivityThread.java (95%) rename app/src/main/java/top/niunaijun/{blackreflection => app}/ref/AppCompatActivity.java (90%) rename app/src/main/java/top/niunaijun/{blackreflection => app}/ref/MainActivity.java (83%) create mode 100644 core/src/main/java/top/niunaijun/blackreflection/BlackNullPointerException.java diff --git a/app/build.gradle b/app/build.gradle index afa8b10..dee07eb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,6 +17,10 @@ android { } buildTypes { + debug { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..0a9c49f 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -18,4 +18,16 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile +-keep class top.niunaijun.blackreflection.** {*; } +-keep @top.niunaijun.blackreflection.annotation.BClass class * {*;} +-keep @top.niunaijun.blackreflection.annotation.BClassName class * {*;} +-keep @top.niunaijun.blackreflection.annotation.BClassNameNotProcess class * {*;} +-keepclasseswithmembernames class * { + @top.niunaijun.blackreflection.annotation.BField.* ; + @top.niunaijun.blackreflection.annotation.BFieldNotProcess.* ; + @top.niunaijun.blackreflection.annotation.BFieldSetNotProcess.* ; + @top.niunaijun.blackreflection.annotation.BMethod.* ; + @top.niunaijun.blackreflection.annotation.BStaticField.* ; + @top.niunaijun.blackreflection.annotation.BStaticMethod.* ; +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 86a0c37..6959b59 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,21 +3,21 @@ package="top.niunaijun.blackreflection"> - + - + \ No newline at end of file diff --git a/app/src/main/java/top/niunaijun/blackreflection/App.java b/app/src/main/java/top/niunaijun/app/App.java similarity index 87% rename from app/src/main/java/top/niunaijun/blackreflection/App.java rename to app/src/main/java/top/niunaijun/app/App.java index 03e992e..8baa2fe 100644 --- a/app/src/main/java/top/niunaijun/blackreflection/App.java +++ b/app/src/main/java/top/niunaijun/app/App.java @@ -1,4 +1,4 @@ -package top.niunaijun.blackreflection; +package top.niunaijun.app; import android.app.Application; diff --git a/app/src/main/java/top/niunaijun/blackreflection/MainActivity.java b/app/src/main/java/top/niunaijun/app/MainActivity.java similarity index 88% rename from app/src/main/java/top/niunaijun/blackreflection/MainActivity.java rename to app/src/main/java/top/niunaijun/app/MainActivity.java index a00426a..3717f44 100644 --- a/app/src/main/java/top/niunaijun/blackreflection/MainActivity.java +++ b/app/src/main/java/top/niunaijun/app/MainActivity.java @@ -1,4 +1,4 @@ -package top.niunaijun.blackreflection; +package top.niunaijun.app; import androidx.appcompat.app.AppCompatActivity; @@ -6,9 +6,10 @@ import android.os.Bundle; import android.util.Log; -import top.niunaijun.blackreflection.ref.BRActivityThread; -import top.niunaijun.blackreflection.ref.BRActivityThreadH; -import top.niunaijun.blackreflection.ref.BRMainActivity; +import top.niunaijun.app.ref.BRActivityThread; +import top.niunaijun.app.ref.BRActivityThreadH; +import top.niunaijun.app.ref.BRMainActivity; +import top.niunaijun.blackreflection.R; public class MainActivity extends AppCompatActivity { diff --git a/app/src/main/java/top/niunaijun/blackreflection/SecondActivity.java b/app/src/main/java/top/niunaijun/app/SecondActivity.java similarity index 87% rename from app/src/main/java/top/niunaijun/blackreflection/SecondActivity.java rename to app/src/main/java/top/niunaijun/app/SecondActivity.java index e72cd0f..a47a111 100644 --- a/app/src/main/java/top/niunaijun/blackreflection/SecondActivity.java +++ b/app/src/main/java/top/niunaijun/app/SecondActivity.java @@ -1,7 +1,6 @@ -package top.niunaijun.blackreflection; +package top.niunaijun.app; import android.os.Bundle; -import android.util.Log; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; @@ -9,7 +8,7 @@ import java.lang.reflect.Method; -import top.niunaijun.blackreflection.ref.BRAppCompatActivity; +import top.niunaijun.app.ref.BRAppCompatActivity; /** * Created by Milk on 2022/2/15. diff --git a/app/src/main/java/top/niunaijun/blackreflection/ref/ActivityThread.java b/app/src/main/java/top/niunaijun/app/ref/ActivityThread.java similarity index 95% rename from app/src/main/java/top/niunaijun/blackreflection/ref/ActivityThread.java rename to app/src/main/java/top/niunaijun/app/ref/ActivityThread.java index c53e38b..36d6e96 100644 --- a/app/src/main/java/top/niunaijun/blackreflection/ref/ActivityThread.java +++ b/app/src/main/java/top/niunaijun/app/ref/ActivityThread.java @@ -1,4 +1,4 @@ -package top.niunaijun.blackreflection.ref; +package top.niunaijun.app.ref; import android.content.Intent; import android.os.IBinder; diff --git a/app/src/main/java/top/niunaijun/blackreflection/ref/AppCompatActivity.java b/app/src/main/java/top/niunaijun/app/ref/AppCompatActivity.java similarity index 90% rename from app/src/main/java/top/niunaijun/blackreflection/ref/AppCompatActivity.java rename to app/src/main/java/top/niunaijun/app/ref/AppCompatActivity.java index 35be550..d7c2daf 100644 --- a/app/src/main/java/top/niunaijun/blackreflection/ref/AppCompatActivity.java +++ b/app/src/main/java/top/niunaijun/app/ref/AppCompatActivity.java @@ -1,4 +1,4 @@ -package top.niunaijun.blackreflection.ref; +package top.niunaijun.app.ref; import androidx.appcompat.app.ActionBar; diff --git a/app/src/main/java/top/niunaijun/blackreflection/ref/MainActivity.java b/app/src/main/java/top/niunaijun/app/ref/MainActivity.java similarity index 83% rename from app/src/main/java/top/niunaijun/blackreflection/ref/MainActivity.java rename to app/src/main/java/top/niunaijun/app/ref/MainActivity.java index a7d9d4c..c313ec7 100644 --- a/app/src/main/java/top/niunaijun/blackreflection/ref/MainActivity.java +++ b/app/src/main/java/top/niunaijun/app/ref/MainActivity.java @@ -1,4 +1,4 @@ -package top.niunaijun.blackreflection.ref; +package top.niunaijun.app.ref; import top.niunaijun.blackreflection.annotation.BClass; import top.niunaijun.blackreflection.annotation.BField; @@ -13,7 +13,7 @@ * しーJ * 此处无Bug */ -@BClass(top.niunaijun.blackreflection.MainActivity.class) +@BClass(top.niunaijun.app.MainActivity.class) public interface MainActivity { @BStaticField String TAGStatic(); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index e0e8e1f..d986b06 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".MainActivity"> + tools:context="top.niunaijun.app.MainActivity">