Fix object instance field name
This commit is contained in:
parent
144cc8bac5
commit
3c23a62aad
|
@ -30,11 +30,11 @@ public class KotlinAdapter : ILanguageAdapter {
|
||||||
|
|
||||||
override fun setProxy(target: Field, proxyTarget: Class<*>, proxy: Any) {
|
override fun setProxy(target: Field, proxyTarget: Class<*>, proxy: Any) {
|
||||||
log.debug("Setting proxy: {}.{} -> {}", target.getDeclaringClass().getSimpleName(), target.getName(), proxy)
|
log.debug("Setting proxy: {}.{} -> {}", target.getDeclaringClass().getSimpleName(), target.getName(), proxy)
|
||||||
if (proxyTarget.getFields().any { x -> x.getName().equals("INSTANCE$") }) {
|
if (proxyTarget.getFields().any { x -> x.getName().equals("INSTANCE") }) {
|
||||||
// Singleton
|
// Singleton
|
||||||
try {
|
try {
|
||||||
log.debug("Setting proxy on INSTANCE$; singleton target.")
|
log.debug("Setting proxy on INSTANCE; singleton target.")
|
||||||
val obj = proxyTarget.getField("INSTANCE$").get(null)
|
val obj = proxyTarget.getField("INSTANCE").get(null)
|
||||||
target.set(obj, proxy)
|
target.set(obj, proxy)
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
throw KotlinAdapterException(ex)
|
throw KotlinAdapterException(ex)
|
||||||
|
@ -49,10 +49,10 @@ public class KotlinAdapter : ILanguageAdapter {
|
||||||
log.debug("FML has asked for {} to be constructed...", objectClass.getSimpleName())
|
log.debug("FML has asked for {} to be constructed...", objectClass.getSimpleName())
|
||||||
try {
|
try {
|
||||||
// Try looking for an object type
|
// Try looking for an object type
|
||||||
val f = objectClass.getField("INSTANCE$")
|
val f = objectClass.getField("INSTANCE")
|
||||||
val obj = f.get(null)
|
val obj = f.get(null)
|
||||||
if (obj == null) throw NullPointerException()
|
if (obj == null) throw NullPointerException()
|
||||||
log.debug("Found an object INSTANCE$ reference in {}, using that. ({})", objectClass.getSimpleName(), obj)
|
log.debug("Found an object INSTANCE reference in {}, using that. ({})", objectClass.getSimpleName(), obj)
|
||||||
return obj
|
return obj
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
// Try looking for a class type
|
// Try looking for a class type
|
||||||
|
|
Loading…
Reference in New Issue