public virtual global::System.Object getDeclaredMethods() { //XMLVM_BEGIN_WRAPPER[java.lang.Class: java.lang.reflect.Method[] getDeclaredMethods()] org.xmlvm._nTIB tib = (org.xmlvm._nTIB) this._ftib; global::System.Type nativeType = tib.getNativeType(); global::System.Reflection.BindingFlags bindingFlags = global::System.Reflection.BindingFlags.DeclaredOnly | global::System.Reflection.BindingFlags.Static | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic; global::System.Reflection.MethodInfo[] methodInfos = nativeType.GetMethods(bindingFlags); global::System.Collections.Generic.IList <java.lang.reflect.Method> jMethods = new global::System.Collections.Generic.List <java.lang.reflect.Method>(); foreach (global::System.Reflection.MethodInfo nativeMethodInfo in methodInfos) { java.lang.reflect.Method jMethod = org.xmlvm._nMemberInfoAdapter <global::System.Reflection.MethodInfo, java.lang.reflect.Method._nImpl> .getJavaClient(nativeMethodInfo); jMethods.Add(jMethod); } java.lang.reflect.Method[] jMethodArray = new java.lang.reflect.Method[jMethods.Count]; jMethods.CopyTo(jMethodArray, 0); return(new org.xmlvm._nArrayAdapter <object>(jMethodArray)); //XMLVM_END_WRAPPER[java.lang.Class: java.lang.reflect.Method[] getDeclaredMethods()] }
void ChangeToSSLSocket() { #if TARGET_JVM java.lang.Class c = vmw.common.TypeUtils.ToClass(smtp.Stream); java.lang.reflect.Method m = c.getMethod("ChangeToSSLSocket", null); m.invoke(smtp.Stream, new object[] {}); #else // Load Mono.Security.dll Assembly a; try { a = Assembly.Load(Consts.AssemblyMono_Security); } catch (System.IO.FileNotFoundException) { throw new SmtpException("Cannot load Mono.Security.dll"); } Type tSslClientStream = a.GetType("Mono.Security.Protocol.Tls.SslClientStream"); object[] consArgs = new object[4]; consArgs[0] = smtp.Stream; consArgs[1] = server; consArgs[2] = true; Type tSecurityProtocolType = a.GetType("Mono.Security.Protocol.Tls.SecurityProtocolType"); int nSsl3Val = (int)Enum.Parse(tSecurityProtocolType, "Ssl3"); int nTlsVal = (int)Enum.Parse(tSecurityProtocolType, "Tls"); consArgs[3] = Enum.ToObject(tSecurityProtocolType, nSsl3Val | nTlsVal); object objSslClientStream = Activator.CreateInstance(tSslClientStream, consArgs); if (objSslClientStream != null) { smtp = new SmtpStream((Stream)objSslClientStream); } #endif }
public static void runScript(java.lang.Class clazz) { java.lang.reflect.Method runMethod = clazz.getMethod("run", new java.lang.Class[] { }); Object obj = clazz.newInstance(); runMethod.invoke(obj, new object[] {}); }
protected override string DetermineCallingFunction() { System.Exception e = new System.Exception (); java.lang.Class c = vmw.common.TypeUtils.ToClass (e); java.lang.reflect.Method m = c.getMethod ("getStackTrace", new java.lang.Class [0]); java.lang.StackTraceElement [] els = (java.lang.StackTraceElement []) m.invoke (e, new object [0]); java.lang.StackTraceElement el = els [4]; return el.getClassName () + "." + _ownerClass + "." + el.getMethodName (); }
public static object DynamicInvokevirtual(object obj, RuntimeTypeHandle type, string clazz, string name, string sig, object[] args, [email protected] callerID) { Profiler.Count("DynamicInvokevirtual"); MethodWrapper mw = GetMethodWrapper(obj, type, clazz, name, sig, false); java.lang.reflect.Method m = (java.lang.reflect.Method)mw.ToMethodOrConstructor(false); object val = m.invoke(obj, BoxArgs(mw, args), callerID); if (mw.ReturnType.IsPrimitive && mw.ReturnType != PrimitiveTypeWrapper.VOID) { val = JVM.Unbox(val); } return(val); }
#pragma warning disable 0436 static java.lang.Class IsGetMethod(java.lang.reflect.Method javaMethod, string propertyName, Type propertyType) { if (javaMethod.getName() == "get_" + propertyName) { javaMethod.setAccessible(true); var returnClass = javaMethod.getReturnType(); if (object.ReferenceEquals(propertyType, null) || object.ReferenceEquals(propertyType, system.RuntimeType.GetType(returnClass))) { return(returnClass); } } return(null); }
static java.lang.Class IsSetMethod(java.lang.reflect.Method javaMethod, string propertyName, Type propertyType) { if (javaMethod.getName() == "set_" + propertyName) { javaMethod.setAccessible(true); var paramClasses = javaMethod.getParameterTypes(); if (paramClasses.Length == 1) { var paramClass = paramClasses[0]; if (object.ReferenceEquals(propertyType, null) || object.ReferenceEquals(propertyType, system.RuntimeType.GetType(paramClass))) { return(paramClass); } } } return(null); }
#pragma warning disable 0436 static bool CompareParameters(java.lang.reflect.Method javaMethod, Type[] types) { if (types == null) { return(true); } var paramTypes = javaMethod.getParameterTypes(); if (types.Length != paramTypes.Length) { return(false); } for (int i = 0; i < paramTypes.Length; i++) { if (!object.ReferenceEquals( types[i], system.RuntimeType.GetType(paramTypes[i]))) { return(false); } } return(true); }
// Generating method code for addSymbol public virtual void AddSymbol(net.sourceforge.htmlunit.corejs.javascript.Symbol symbol, java.lang.reflect.Method method) { WObj.addSymbol(symbol, method); }
// // constructor // #pragma warning disable 0436 private RuntimeMethodInfo(java.lang.reflect.Method javaMethod, int modifiers, system.RuntimeType reflectedType, string originalName, string strippedName) #pragma warning restore 0436 { this.JavaMethod = javaMethod; this.reflectedType = reflectedType; this.originalName = originalName; this.strippedName = strippedName; if (modifiers == -1) // if called from MakeGenericMethod { return; } // analyze the method and the declaring type in order to decide what // type of a generic method this is. the general idea is: // if the method takes more generic parameters, than the number of // arguments in the type, then it is a generic method definition. int originalNameLen = originalName.Length; char lastChar = (originalNameLen > 0) ? originalName[originalNameLen - 1] : (char)0; // the actual suffix character is configured in CilMain.cs if (lastChar == '\u00A1' || lastChar == '!') // U+00A1 Inverted Exclamation Mark { if ((modifiers & java.lang.reflect.Modifier.STATIC) == 0) { // if an instance method takes any type arguments at all, // then it must be a generic method definition genericFlags |= flgGenericMethod | flgGenericMethodDefinition | flgContainsGenericParameters; } else { // count the number of type arguments in the declaring type var typeArgsInType = reflectedType.GetGenericArguments(); int numTypeArgsInType = typeArgsInType.Length; // count the number of type parameters in the method signature int numTypeArgsInMethod = 0; var paramTypes = javaMethod.getParameterTypes(); int paramIndex = paramTypes.Length; while (paramIndex-- > 0) { var paramType = paramTypes[paramIndex]; if (paramType != (java.lang.Class) typeof(System.Type)) { break; } numTypeArgsInMethod++; } if (numTypeArgsInMethod == numTypeArgsInType) { // a static method that takes a number of type parameters // equal to the number of arguments in the declaring type. // this means it is not a generic method, but it may not // be invokable, if the declaring type is not concrete. if (reflectedType.ContainsGenericParameters) { genericFlags |= flgContainsGenericParameters; } else if (reflectedType.IsGenericType) { genericFlags |= flgCombineGenericArguments; } } else if (numTypeArgsInMethod > numTypeArgsInType) { // a static method that takes more parameters than the // declaring type, i.e. it is a generic method definition. genericFlags |= flgGenericMethod | flgGenericMethodDefinition | flgContainsGenericParameters; } else { throw new TypeLoadException(originalName); } } } else { // a method that does not take any type argument may still be // not invokable, if the reflected type is not a concrete type. // note that this is true only for instance methods, as static // methods in a generic type will always take type arguments. if ((modifiers & java.lang.reflect.Modifier.STATIC) == 0) { if (reflectedType.ContainsGenericParameters) { genericFlags |= flgContainsGenericParameters; } else if (reflectedType.IsGenericType) { genericFlags |= flgCombineGenericArguments; } } } }
/*public static void WriteLine(string format, object arg0) * => [email protected](System.String.Format(format, arg0)); * * public static void WriteLine(string format, object arg0, object arg1) * => [email protected](System.String.Format(format, arg0, arg1));*/ // // Console application runner // public static void main(string[] args) { try { if (args == null || args.Length == 0) { throw new System.ArgumentException("must specify main class name"); } var cls = java.lang.Class.forName(args[0]); if (cls == null) { throw new System.ArgumentException("main class not found"); } #pragma warning disable 0436 java.lang.reflect.Method meth = null; var parameters = new java.lang.Class[1] { (java.lang.Class) typeof(string[]) }; try { meth = (java.lang.reflect.Method)(object) cls.getDeclaredMethod("Main", parameters); } catch (java.lang.NoSuchMethodException) { try { meth = (java.lang.reflect.Method)(object) cls.getDeclaredMethod("main", parameters); } catch (java.lang.NoSuchMethodException e) { throw new System.ArgumentException("main method not found", e); } } #pragma warning restore 0436 var n = args.Length; var newArgs = new string[n - 1]; for (int i = 1; i < n; i++) { newArgs[i - 1] = args[i]; } object result = null; try { result = meth.invoke(null, new object[] { newArgs }); } catch (java.lang.IllegalAccessException) { meth.setAccessible(true); result = meth.invoke(null, new object[] { newArgs }); } if (result is java.lang.Integer intResult) { var exitCode = intResult.intValue(); if (exitCode != 0) { java.lang.System.exit(exitCode); } } } catch (System.Exception exception) { var exc = exception; for (;;) { Console.WriteLine("Exception " + ((java.lang.Object)(object) exc).getClass() + "\nMessage: " + exc.Message //((java.lang.Throwable) exc).getMessage() + "\n" + exc.StackTrace); if ((exc = exc.InnerException) == null) { break; } Console.Write("Caused by Inner "); } java.lang.System.exit(-1); } }
// // GetMethod (called by system.RuntimeType.GetPropertyImpl) // public static PropertyInfo GetProperty(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers, RuntimeType initialType) { ThrowHelper.ThrowIfNull(name); if (types != null && types.Length != 0) // if indexed property { throw new PlatformNotSupportedException(); } #pragma warning disable 0436 java.lang.reflect.Method getMethod = null; java.lang.Class getClass = null; java.lang.reflect.Method setMethod = null; java.lang.Class setClass = null; #pragma warning restore 0436 BindingFlagsIterator.Run(bindingAttr & ~BindingFlags.GetProperty, initialType, MemberTypes.Method, (javaAccessibleObject) => { #pragma warning disable 0436 var javaMethod = (java.lang.reflect.Method)javaAccessibleObject; #pragma warning restore 0436 var cls = IsGetMethod(javaMethod, name, returnType); if (cls != null) { getMethod = javaMethod; getClass = cls; } else { cls = IsSetMethod(javaMethod, name, returnType); if (cls != null) { setMethod = javaMethod; setClass = cls; } } return(true); }); if (getClass != null) { if (setClass != null && setClass != getClass) { setMethod = null; } } else if (setClass != null) { getClass = setClass; } else // neither get nor set methods { return(null); } return(new RuntimePropertyInfo(getMethod, setMethod, getClass, initialType));
public object invoke(object proxy, java.lang.reflect.Method method, object[] args) { return(vinvoke(proxy, method, args)); }
// Generating method code for addFunction public virtual void AddFunction(java.lang.reflect.Method method) { WObj.addFunction(method); }
public virtual global::System.Object getDeclaredMethods(){ //XMLVM_BEGIN_WRAPPER[java.lang.Class: java.lang.reflect.Method[] getDeclaredMethods()] org.xmlvm._nTIB tib = (org.xmlvm._nTIB) this._ftib; global::System.Type nativeType = tib.getNativeType(); //global::System.Reflection.BindingFlags bindingFlags // = global::System.Reflection.BindingFlags.DeclaredOnly // | global::System.Reflection.BindingFlags.Static // | global::System.Reflection.BindingFlags.Instance // | global::System.Reflection.BindingFlags.Public // | global::System.Reflection.BindingFlags.NonPublic; global::System.Collections.Generic.IEnumerable<MethodInfo> methodInfosArray = nativeType.GetTypeInfo().DeclaredMethods; //global::System.Reflection.MethodInfo[] methodInfos // = nativeType.GetMethods(bindingFlags); global::System.Collections.Generic.IList<java.lang.reflect.Method> jMethods = new global::System.Collections.Generic.List<java.lang.reflect.Method>(); foreach (global::System.Reflection.MethodInfo nativeMethodInfo in methodInfosArray) { java.lang.reflect.Method jMethod = org.xmlvm._nMemberInfoAdapter<global::System.Reflection.MethodInfo, java.lang.reflect.Method._nImpl>.getJavaClient(nativeMethodInfo); jMethods.Add(jMethod); } java.lang.reflect.Method[] jMethodArray = new java.lang.reflect.Method[jMethods.Count]; jMethods.CopyTo(jMethodArray, 0); return new org.xmlvm._nArrayAdapter<object>(jMethodArray); //XMLVM_END_WRAPPER[java.lang.Class: java.lang.reflect.Method[] getDeclaredMethods()] }
// Generating method code for addStaticFunction public virtual void AddStaticFunction(string name, java.lang.reflect.Method method) { WObj.addStaticFunction(name, method); }
// Generating method code for addProperty public virtual void AddProperty(string name, java.lang.reflect.Method getter, java.lang.reflect.Method setter) { WObj.addProperty(name, getter, setter); }
private void AddMembers(String p, Symbol s, java.lang.Class ci, List <object> exceptFor, int maxDepth) { Package pkg = CurrentPackage(); String ns = ci.getName(); if (!useClassname(ns)) { return; } WriteLine("; importing " + p + " as " + ns); java.lang.reflect.Field[] fi = ci.getFields(); for (int i = 0; i < fi.Length; i++) { java.lang.reflect.Field f = fi[i]; f.setAccessible(true); String fname = ("" + p + "." + f.getName()).ToUpper(); Symbol old = pkg.findAccessibleSymbol(fname); if (old != null) { // fname = ("" + p + "%" + f.getName()).ToUpper() + ""; // old = pkg.findAccessibleSymbol(fname); } bool needsClear = false; if (old == null) { old = pkg.intern(new SimpleString(fname)); needsClear = true; // WriteLine(";;; skip field " + fname + " for " + f); // continue; } WriteLine(";;; field " + fname + " for " + f); Symbol sfm = Intern(fname, null, exceptFor, f.getType(), maxDepth - 1);// IkvmSite.fieldToInstanceSymbol(fname, pkg, s, f); if (needsClear) { sfm.setSymbolValue(null); } if (maxDepth > 0) { exceptFor.Add(f); AddMembers(fname, sfm, f.getType(), exceptFor, maxDepth - 1); } else { if (false && !exceptFor.Contains(f)) { exceptFor.Add(f); AddMembers(fname, sfm, ikvm.runtime.Util.getInstanceTypeFromClass(f.getType()), exceptFor, maxDepth - 1); } } } java.lang.reflect.Method[] mi = ci.getDeclaredMethods(); if (false) { for (int i = 0; i < mi.Length; i++) { java.lang.reflect.Method m = mi[i]; String fname = ("" + p + "." + m.getName()).ToUpper() + ""; Symbol old = pkg.findAccessibleSymbol(fname); if (old != null) { fname = ("" + p + "/" + m.getName()).ToUpper() + ""; old = pkg.findAccessibleSymbol(fname); } if (old != null) { fname = ("" + p + "//" + m.getName()).ToUpper() + ""; old = pkg.findAccessibleSymbol(fname); } if (old != null) { WriteLine(";;; skip method " + fname + " for " + m); continue; } WriteLine(";;; method " + p + " as " + fname + " to " + m); //LispObject sfm = IkvmSite.methodToInstanceSymbol(fname, pkg, s, m); } } }