private static void RegisterInterfaceProxy(Type proxyType, ref RegistryRecord record) { JavaProxyAttribute javaProxyAttribute = GetJavaProxyAttribute(proxyType); if (javaProxyAttribute == null) { return; } Type interfaceType = javaProxyAttribute.InterfaceType; if (interfaceType == null) { throw new JNIException("Can't initialize " + proxyType); } RegisterProxy(proxyType, interfaceType, ref record); record.CLRStatic = javaProxyAttribute.StaticType; knownCLR[record.CLRStatic] = record; }
private void RegisterProxy(Type proxyType, JavaProxyAttribute javaProxyAttribute) { Debug.Assert(proxyType != null); if (javaProxyAttribute == null) { javaProxyAttribute = WrapperHelpers.GetJavaProxyAttribute(proxyType); if (javaProxyAttribute == null) throw new InvalidJavaProxyException(proxyType, "Could not find 'JavaProxyAttribute'."); } var internalClassName = javaProxyAttribute.ClassName; if (_classNameToProxyType.ContainsKey(internalClassName)) throw new InvalidJavaProxyException(proxyType, $"Found duplicate proxy for Java class '{internalClassName}'."); if (string.IsNullOrWhiteSpace(internalClassName)) throw new InvalidJavaProxyException(proxyType, "Missing 'JavaProxyAttribute.ClassName' property."); if (!typeof(IJavaObject).IsAssignableFrom(proxyType)) throw new InvalidJavaProxyException(proxyType, "Proxy types must implement 'IJavaObject'."); if (!proxyType.IsInterface) { if (!typeof(java.lang.Object).IsAssignableFrom(proxyType) && !typeof(Throwable).IsAssignableFrom(proxyType)) throw new InvalidJavaProxyException(proxyType, "Proxy types must inherit from 'java.lang.Object' or 'java.lang.Throwable'."); } ValidateGenericTypeParameters(proxyType); _classNameToProxyType[internalClassName] = proxyType; _proxyTypeToClassNameMap[proxyType] = internalClassName; }