-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
77 changed files
with
1,606 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.idea/ | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
AnalyzeSoPlugin/gradle.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 14 additions & 13 deletions
27
AnalyzeSoPlugin/src/main/kotlin/com.mainli.plugin/AnalyzeSoPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.mainli.demo; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.Method; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public class AA { | ||
private static volatile boolean kotlin_class_klass_error; | ||
private static volatile Constructor kotlin_kclass_constructor; | ||
private static volatile Method kotlin_kclass_getConstructors; | ||
private static volatile Method kotlin_kfunction_getParameters; | ||
private static volatile Method kotlin_kparameter_getName; | ||
private static boolean kotlin_error; | ||
|
||
public static String[] getKoltinConstructorParameters(Class clazz) { | ||
if (kotlin_kclass_constructor == null && !kotlin_class_klass_error) { | ||
try { | ||
Class class_kotlin_kclass = Class.forName("kotlin.reflect.jvm.internal.KClassImpl"); | ||
kotlin_kclass_constructor = class_kotlin_kclass.getConstructor(Class.class); | ||
kotlin_kclass_getConstructors = class_kotlin_kclass.getMethod("getConstructors"); | ||
|
||
Class class_kotlin_kfunction = Class.forName("kotlin.reflect.KFunction"); | ||
kotlin_kfunction_getParameters = class_kotlin_kfunction.getMethod("getParameters"); | ||
|
||
Class class_kotlinn_kparameter = Class.forName("kotlin.reflect.KParameter"); | ||
kotlin_kparameter_getName = class_kotlinn_kparameter.getMethod("getName"); | ||
} catch (Throwable e) { | ||
kotlin_class_klass_error = true; | ||
} | ||
} | ||
|
||
if (kotlin_kclass_constructor == null) { | ||
return null; | ||
} | ||
|
||
if (kotlin_error) { | ||
return null; | ||
} | ||
|
||
try { | ||
Object constructor = null; | ||
Object kclassImpl = kotlin_kclass_constructor.newInstance(clazz); | ||
Iterable it = (Iterable) kotlin_kclass_getConstructors.invoke(kclassImpl); | ||
for (Iterator iterator = it.iterator(); iterator.hasNext(); iterator.hasNext()) { | ||
Object item = iterator.next(); | ||
List parameters = (List) kotlin_kfunction_getParameters.invoke(item); | ||
if (constructor != null && parameters.size() == 0) { | ||
continue; | ||
} | ||
constructor = item; | ||
} | ||
|
||
List parameters = (List) kotlin_kfunction_getParameters.invoke(constructor); | ||
String[] names = new String[parameters.size()]; | ||
for (int i = 0; i < parameters.size(); i++) { | ||
Object param = parameters.get(i); | ||
names[i] = (String) kotlin_kparameter_getName.invoke(param); | ||
} | ||
return names; | ||
} catch (Throwable e) { | ||
kotlin_error = true; | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.mainli.demo | ||
|
||
import android.util.Log | ||
|
||
|
||
data class BB(val string: String, val int: Int) {} | ||
|
||
fun aa() { | ||
val koltinConstructorParameters = | ||
AA.getKoltinConstructorParameters(MyIotApplianceListPayload::class.java) | ||
Log.println(Log.WARN, "Mainli", "aa: ${koltinConstructorParameters}") | ||
} |
Oops, something went wrong.