Skip to content

Commit

Permalink
Added method async() for the purpose of 'Call the method asynchronously'
Browse files Browse the repository at this point in the history
  • Loading branch information
zeshaoaaa committed Jul 15, 2019
1 parent 73a65c0 commit c1ff666
Show file tree
Hide file tree
Showing 10 changed files with 604 additions and 451 deletions.
12 changes: 10 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.40'
}

kotlin {
experimental {
coroutines "enable"
}
}

group 'com.github.zeshaoaaa'
version '0.1.4'
version '0.1.5'

sourceCompatibility = 1.8

Expand All @@ -20,7 +26,9 @@ repositories {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testCompile group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.12'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-M2'


// Libraries that use for distribution
// implementation "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3"
Expand Down
27 changes: 25 additions & 2 deletions src/main/kotlin/okreflect/MethodGetter.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package okreflect

import okreflect.OkReflect.Companion.accessible
import java.lang.invoke.MethodHandle
import java.lang.invoke.MethodHandles
import java.lang.reflect.*
Expand All @@ -12,7 +11,6 @@ class MethodGetter {

companion object {


/**
* Get the constructor of the class.
*/
Expand Down Expand Up @@ -175,6 +173,29 @@ class MethodGetter {
} else return declared
}

/**
* Change the accessibility of the methods and constructors.
*/
fun <T : AccessibleObject> accessible(accessible: T): T {
if (accessible is Member && isPublic(accessible)) {
return accessible
}

if (!accessible.isAccessible) {
accessible.isAccessible = true
}

return accessible
}

/**
* This method will return whether the Member is public or not.
*/
private fun isPublic(accessible: Member): Boolean {
return Modifier.isPublic(accessible.modifiers) &&
Modifier.isPublic(accessible.declaringClass.modifiers)
}

}


Expand All @@ -184,4 +205,6 @@ class MethodGetter {





}
Loading

0 comments on commit c1ff666

Please sign in to comment.