Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
R
RatelApi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ratel
RatelApi
Commits
71f821e4
Commit
71f821e4
authored
Apr 14, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
双段反射支持更多接口
parent
cc4e32ab
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
FreeReflection.java
...main/java/com/virjar/ratel/api/rposed/FreeReflection.java
+33
-0
RposedHelpers.java
src/main/java/com/virjar/ratel/api/rposed/RposedHelpers.java
+4
-2
No files found.
src/main/java/com/virjar/ratel/api/rposed/FreeReflection.java
View file @
71f821e4
...
...
@@ -19,6 +19,10 @@ public class FreeReflection {
private
static
Method
getDeclaredConstructorMethod
=
null
;
private
static
Method
getDeclaredConstructorsMethod
=
null
;
private
static
Method
getDeclaredMethodsMethod
=
null
;
private
static
Method
getDeclaredFieldsMethod
=
null
;
static
{
...
...
@@ -32,6 +36,12 @@ public class FreeReflection {
getFiledMethod
=
Class
.
class
.
getDeclaredMethod
(
"getDeclaredField"
,
String
.
class
);
getDeclaredConstructorMethod
=
Class
.
class
.
getDeclaredMethod
(
"getDeclaredConstructor"
,
Class
[].
class
);
getDeclaredFieldsMethod
=
Class
.
class
.
getDeclaredMethod
(
"getDeclaredFields"
);
//java.lang.Class.getDeclaredConstructors
getDeclaredConstructorsMethod
=
Class
.
class
.
getDeclaredMethod
(
"getDeclaredConstructors"
);
getDeclaredMethodsMethod
=
Class
.
class
.
getDeclaredMethod
(
"getDeclaredMethods"
);
}
catch
(
Throwable
t
)
{
throw
new
RuntimeException
(
t
);
}
...
...
@@ -52,6 +62,16 @@ public class FreeReflection {
return
clazz
.
getDeclaredMethod
(
methodName
,
parameterTypes
);
}
public
static
Method
[]
getDeclaredMethods
(
Class
<?>
clazz
)
throws
SecurityException
{
if
(
use
())
{
try
{
return
(
Method
[])
getDeclaredMethodsMethod
.
invoke
(
clazz
);
}
catch
(
Throwable
e
)
{
//ignore
}
}
return
clazz
.
getDeclaredMethods
();
}
public
static
Constructor
<?>
getDeclaredConstructor
(
Class
<?>
clazz
,
Class
<?>...
parameterTypes
)
throws
NoSuchMethodException
{
if
(
use
())
{
...
...
@@ -64,6 +84,19 @@ public class FreeReflection {
return
clazz
.
getDeclaredConstructor
(
parameterTypes
);
}
public
static
Constructor
<?>[]
getDeclaredConstructors
(
Class
<?>
clazz
)
throws
SecurityException
{
if
(
use
())
{
try
{
return
(
Constructor
<?>[])
getDeclaredConstructorsMethod
.
invoke
(
clazz
);
}
catch
(
Throwable
e
)
{
//ignore
e
.
printStackTrace
();
}
}
return
clazz
.
getDeclaredConstructors
();
}
public
static
Field
getDeclaredField
(
Class
<?>
clazz
,
String
field
)
throws
NoSuchFieldException
{
if
(
use
())
{
try
{
...
...
src/main/java/com/virjar/ratel/api/rposed/RposedHelpers.java
View file @
71f821e4
...
...
@@ -425,7 +425,8 @@ public final class RposedHelpers {
Class
<?>
clz
=
clazz
;
boolean
considerPrivateMethods
=
true
;
do
{
for
(
Method
method
:
clz
.
getDeclaredMethods
())
{
for
(
Method
method
:
FreeReflection
.
getDeclaredMethods
(
clz
))
{
//for (Method method : clz.getDeclaredMethods()) {
// don't consider private methods of superclasses
if
(!
considerPrivateMethods
&&
Modifier
.
isPrivate
(
method
.
getModifiers
()))
continue
;
...
...
@@ -664,7 +665,8 @@ public final class RposedHelpers {
}
Constructor
<?>
bestMatch
=
null
;
Constructor
<?>[]
constructors
=
clazz
.
getDeclaredConstructors
();
// Constructor<?>[] constructors = clazz.getDeclaredConstructors();
Constructor
<?>[]
constructors
=
FreeReflection
.
getDeclaredConstructors
(
clazz
);
for
(
Constructor
<?>
constructor
:
constructors
)
{
// compare name and parameters
if
(
ClassUtils
.
isAssignable
(
parameterTypes
,
constructor
.
getParameterTypes
(),
true
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment