static ProxyGenerator() { ClassLoaderWrapper bootClassLoader = ClassLoaderWrapper.GetBootstrapClassLoader(); proxyClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.Proxy"); errorClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.Error"); runtimeExceptionClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.RuntimeException"); undeclaredThrowableExceptionConstructor = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.UndeclaredThrowableException").GetMethodWrapper("<init>", "(Ljava.lang.Throwable;)V", false); undeclaredThrowableExceptionConstructor.Link(); invocationHandlerField = proxyClass.GetFieldWrapper("h", "Ljava.lang.reflect.InvocationHandler;"); invocationHandlerField.Link(); javaLangReflectMethod = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.Method"); javaLangNoSuchMethodException = bootClassLoader.LoadClassByDottedNameFast("java.lang.NoSuchMethodException"); javaLangNoClassDefFoundErrorConstructor = bootClassLoader.LoadClassByDottedNameFast("java.lang.NoClassDefFoundError").GetMethodWrapper("<init>", "(Ljava.lang.String;)V", false); javaLangNoClassDefFoundErrorConstructor.Link(); javaLangThrowable_getMessage = bootClassLoader.LoadClassByDottedNameFast("java.lang.Throwable").GetMethodWrapper("getMessage", "()Ljava.lang.String;", false); javaLangThrowable_getMessage.Link(); javaLangClass_getMethod = CoreClasses.java.lang.Class.Wrapper.GetMethodWrapper("getMethod", "(Ljava.lang.String;[Ljava.lang.Class;)Ljava.lang.reflect.Method;", false); javaLangClass_getMethod.Link(); invocationHandlerClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.InvocationHandler"); invokeMethod = invocationHandlerClass.GetMethodWrapper("invoke", "(Ljava.lang.Object;Ljava.lang.reflect.Method;[Ljava.lang.Object;)Ljava.lang.Object;", false); proxyConstructor = proxyClass.GetMethodWrapper("<init>", "(Ljava.lang.reflect.InvocationHandler;)V", false); proxyConstructor.Link(); hashCodeMethod = CoreClasses.java.lang.Object.Wrapper.GetMethodWrapper("hashCode", "()I", false); equalsMethod = CoreClasses.java.lang.Object.Wrapper.GetMethodWrapper("equals", "(Ljava.lang.Object;)Z", false); toStringMethod = CoreClasses.java.lang.Object.Wrapper.GetMethodWrapper("toString", "()Ljava.lang.String;", false); }
internal static TypeWrapper LoadClassNoThrow(ClassLoaderWrapper classLoader, string name) { try { TypeWrapper wrapper = classLoader.LoadClassByDottedNameFast(name); if (wrapper == null) { string elementTypeName = name; if (elementTypeName.StartsWith("[")) { int skip = 1; while (elementTypeName[skip++] == '[') { ; } elementTypeName = elementTypeName.Substring(skip, elementTypeName.Length - skip - 1); } #if STATIC_COMPILER classLoader.IssueMessage(Message.ClassNotFound, elementTypeName); #else Tracer.Error(Tracer.ClassLoading, "Class not found: {0}", elementTypeName); #endif wrapper = new UnloadableTypeWrapper(name); } return(wrapper); } catch (RetargetableJavaException x) { // HACK keep the compiler from warning about unused local GC.KeepAlive(x); #if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR && !NOEMIT if (Tracer.ClassLoading.TraceError) { java.lang.ClassLoader cl = (java.lang.ClassLoader)classLoader.GetJavaClassLoader(); if (cl != null) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); string sep = ""; while (cl != null) { sb.Append(sep).Append(cl); sep = " -> "; cl = cl.getParent(); } Tracer.Error(Tracer.ClassLoading, "ClassLoader chain: {0}", sb); } Exception m = ikvm.runtime.Util.mapException(x.ToJava()); Tracer.Error(Tracer.ClassLoading, m.ToString() + Environment.NewLine + m.StackTrace); } #endif // !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR return(new UnloadableTypeWrapper(name)); } }
static Boxer() { ClassLoaderWrapper bootClassLoader = ClassLoaderWrapper.GetBootstrapClassLoader(); javaLangByte = bootClassLoader.LoadClassByDottedNameFast("java.lang.Byte"); byteValue = javaLangByte.GetMethodWrapper("byteValue", "()B", false); byteValue.Link(); valueOfByte = javaLangByte.GetMethodWrapper("valueOf", "(B)Ljava.lang.Byte;", false); valueOfByte.Link(); javaLangBoolean = bootClassLoader.LoadClassByDottedNameFast("java.lang.Boolean"); booleanValue = javaLangBoolean.GetMethodWrapper("booleanValue", "()Z", false); booleanValue.Link(); valueOfBoolean = javaLangBoolean.GetMethodWrapper("valueOf", "(Z)Ljava.lang.Boolean;", false); valueOfBoolean.Link(); javaLangShort = bootClassLoader.LoadClassByDottedNameFast("java.lang.Short"); shortValue = javaLangShort.GetMethodWrapper("shortValue", "()S", false); shortValue.Link(); valueOfShort = javaLangShort.GetMethodWrapper("valueOf", "(S)Ljava.lang.Short;", false); valueOfShort.Link(); javaLangCharacter = bootClassLoader.LoadClassByDottedNameFast("java.lang.Character"); charValue = javaLangCharacter.GetMethodWrapper("charValue", "()C", false); charValue.Link(); valueOfCharacter = javaLangCharacter.GetMethodWrapper("valueOf", "(C)Ljava.lang.Character;", false); valueOfCharacter.Link(); javaLangInteger = bootClassLoader.LoadClassByDottedNameFast("java.lang.Integer"); intValue = javaLangInteger.GetMethodWrapper("intValue", "()I", false); intValue.Link(); valueOfInteger = javaLangInteger.GetMethodWrapper("valueOf", "(I)Ljava.lang.Integer;", false); valueOfInteger.Link(); javaLangFloat = bootClassLoader.LoadClassByDottedNameFast("java.lang.Float"); floatValue = javaLangFloat.GetMethodWrapper("floatValue", "()F", false); floatValue.Link(); valueOfFloat = javaLangFloat.GetMethodWrapper("valueOf", "(F)Ljava.lang.Float;", false); valueOfFloat.Link(); javaLangLong = bootClassLoader.LoadClassByDottedNameFast("java.lang.Long"); longValue = javaLangLong.GetMethodWrapper("longValue", "()J", false); longValue.Link(); valueOfLong = javaLangLong.GetMethodWrapper("valueOf", "(J)Ljava.lang.Long;", false); valueOfLong.Link(); javaLangDouble = bootClassLoader.LoadClassByDottedNameFast("java.lang.Double"); doubleValue = javaLangDouble.GetMethodWrapper("doubleValue", "()D", false); doubleValue.Link(); valueOfDouble = javaLangDouble.GetMethodWrapper("valueOf", "(D)Ljava.lang.Double;", false); valueOfDouble.Link(); }
internal static TypeWrapper LoadClassNoThrow(ClassLoaderWrapper classLoader, string name) { try { TypeWrapper wrapper = classLoader.LoadClassByDottedNameFast(name); if (wrapper == null) { Tracer.Error(Tracer.ClassLoading, "Class not found: {0}", name); wrapper = new UnloadableTypeWrapper(name); } return(wrapper); } catch (RetargetableJavaException x) { // HACK keep the compiler from warning about unused local GC.KeepAlive(x); #if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR if (Tracer.ClassLoading.TraceError) { java.lang.ClassLoader cl = (java.lang.ClassLoader)classLoader.GetJavaClassLoader(); if (cl != null) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); string sep = ""; while (cl != null) { sb.Append(sep).Append(cl); sep = " -> "; cl = cl.getParent(); } Tracer.Error(Tracer.ClassLoading, "ClassLoader chain: {0}", sb); } Exception m = ikvm.runtime.Util.mapException(x.ToJava()); Tracer.Error(Tracer.ClassLoading, m.ToString() + Environment.NewLine + m.StackTrace); } #endif // !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR return(new UnloadableTypeWrapper(name)); } }