Skip to content

Commit 215388d

Browse files
committed
Fixed invocation bug
1 parent 48fe2c6 commit 215388d

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

binder/src/main/java/devmike/jade/com/binder/JadeSharedPreference.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@ public object JadeSharedPreference {
1414
private var bindingClass: Class<*>? =null
1515

1616
fun <T : Any> plug(targetClas: T, context: Context) : JadeSharedPreference{
17-
18-
this.bindingClass = targetClas.javaClass.classLoader?.loadClass( "${targetClas::class.java.`package`.name}.JSP"
19-
+ targetClas::class.simpleName)
17+
val className: String ="${targetClas::class.java.`package`.name}.JSP$targetClas::class.simpleName"
18+
this.bindingClass = targetClas.javaClass.classLoader?.loadClass( className)
2019
val method = bindingClass?.getMethod("plug", Context::class.java, Any::class.java)
2120

2221
this.bindingClassNewInstance =bindingClass?.newInstance()
2322
try {
2423
method?.invoke(bindingClassNewInstance, context, targetClas)
2524

26-
}catch (uip: UninitializedPropertyAccessException){
27-
throw NullPointerException("@SharedPref() is missing in your constructor")
25+
}catch (ite: InvocationTargetException){
26+
if(ite is NoSuchMethodException) {
27+
throw NullPointerException("${method.toString()} does not exist")
28+
}else if (ite is ClassNotFoundException){
29+
throw NullPointerException("$className was not generated. Please fix the error and try again!")
30+
}
2831
}
2932

3033
return this

0 commit comments

Comments
 (0)