예제 #1
0
        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);
        }
예제 #2
0
        internal void EmitThrow(string dottedClassName)
        {
            TypeWrapper   exception = ClassLoaderWrapper.GetBootstrapClassLoader().LoadClassByDottedName(dottedClassName);
            MethodWrapper mw        = exception.GetMethodWrapper("<init>", "()V", false);

            mw.Link();
            mw.EmitNewobj(this);
            Emit(OpCodes.Throw);
        }
예제 #3
0
        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();
        }