You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 26, 2018. It is now read-only.
Some more Scala @SidedProxy adjustments. Now properly supporting pure singletons, i.e.
object C {
@SidedProxy(...)
var proxy: P = null
}
Removed fallback, as all such singletons are properly handled by the new code now, and class implementations fall back to the code also used for plain Java mods.
// Not a singleton, look for @Instance field as a fallback.
65
+
FMLLog.log(Level.SEVERE, e, "An error occured trying to load a proxy into %s.%s. Did you declare your mod as 'class' instead of 'object'?", proxyTarget.getSimpleName(), target.getName());
66
+
thrownewLoaderException(e);
67
+
}
40
68
69
+
try
70
+
{
41
71
// Find setter function. We do it this way because we can't
42
72
// necessarily use proxyTarget.getMethod(proxy.getClass()), as
43
73
// it might be a subclass and not the exact parameter type.
44
-
// All fields are private in scala, wrapped by a getter and
74
+
// All fields are private in Scala, wrapped by a getter and
45
75
// setter named <fieldname> and <fieldname>_$eq. To those
46
76
// familiar with scala.reflect.BeanProperty: these will always
47
77
// be there, set<Fieldname> and get<Fieldname> will always
@@ -55,27 +85,84 @@ public void setProxy(Field target, Class<?> proxyTarget, Object proxy) throws Il
// Here goes nothing... if this invocation fails we'll
59
-
// just fall back to the original functionality.
88
+
// Here goes nothing...
60
89
setter.invoke(targetInstance, proxy);
61
90
return;
62
91
}
63
92
}
64
93
}
65
-
catch (ClassNotFoundExceptione)
66
-
{
67
-
FMLLog.fine("This scala class is not a singleton (scala object), falling back to old proxy setter.");
68
-
}
69
94
catch (InvocationTargetExceptione)
70
95
{
71
-
FMLLog.fine("There's a problem with this proxy's setter, falling back to old proxy setter.");
96
+
FMLLog.log(Level.SEVERE, e, "An error occured trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName());
97
+
thrownewLoaderException(e);
72
98
}
73
99
74
-
Fieldfield = proxyTarget.getField("INSTANCE");
75
-
ObjectscalaObject = field.get(null);
76
-
target.set(scalaObject, proxy);
100
+
// If we come here we could not find a setter for this proxy.
101
+
FMLLog.severe("Failed loading proxy into %s.%s, could not find setter function. Did you declare the field with 'val' instead of 'var'?", proxyTarget.getSimpleName(), target.getName());
0 commit comments