public DotnetBaseClassFieldExtractor(Class clazz, string fieldName) : base(null, null) { Type type = null; foreach (Assembly assem in AppDomain.CurrentDomain.GetAssemblies()) { type = assem.GetType(clazz.getName().Replace("cli.", "")); if(type != null) break; } this.fieldName = fieldName; FieldInfo[] info = type.GetFields(); string fieldType = type.GetProperty(fieldName).PropertyType.FullName; //string originalClassName = clazz.getName().Replace('.', '/'); //string className = CSClassFieldExtractorFactory.BASE_PACKAGE + "/" + originalClassName + "$" + fieldName; try { //this.index = getIndex(type, fieldName); this.index = FieldIndexGenerator.getIndex(); this.fieldType = type.GetProperty(fieldName).PropertyType; this.objectType = DotnetClassFieldExtractorFactory.getClassObjectType( this.fieldType ); } catch ( System.Exception e ) { throw new RuntimeDroolsException( e ); } }
public override java.lang.Class[] getClasses(java.lang.Class requiredInterface) { //Console.WriteLine("looking up " + requiredInterface.getName()); List <Class> returnClasses = new List <Class>(); Type requiredType = Type.GetType(requiredInterface.getName() + ", liquibase-core"); if (requiredType == null) { Console.WriteLine("could not find required type for " + requiredInterface.getName()); return(new java.lang.Class[0]); } Assembly assembly = Assembly.GetExecutingAssembly(); foreach (Type type in assembly.GetTypes()) { //if (type.AssemblyQualifiedName.Contains("LiquiBase")) { // Console.WriteLine("type: " + type); //} if (!type.IsInterface && !type.IsAbstract && requiredType.IsAssignableFrom(type)) { //Console.WriteLine("Adding class " + type.AssemblyQualifiedName); returnClasses.Add(Class.forName(type.AssemblyQualifiedName)); } } foreach (AssemblyName refAsm in assembly.GetReferencedAssemblies()) { foreach (Type type in Assembly.Load(refAsm).GetTypes()) { //if (type.AssemblyQualifiedName.Contains("LiquiBase")) { // Console.WriteLine("type: " + type); //} if (!type.IsInterface && !type.IsAbstract && requiredType.IsAssignableFrom(type)) { //Console.WriteLine("Adding class " + type.AssemblyQualifiedName); returnClasses.Add(Class.forName(type.AssemblyQualifiedName)); } } } return(returnClasses.ToArray()); }
public static Test testFromSuiteMethod(Class klass) { InvocationTargetException invocationTargetException; try { Method method = klass.getMethod("suite", new Class[0], SuiteMethod.__\u003CGetCallerID\u003E()); if (Modifier.isStatic(method.getModifiers())) return (Test) method.invoke((object) null, new object[0], SuiteMethod.__\u003CGetCallerID\u003E()); string str = new StringBuilder().append(klass.getName()).append(".suite() must be static").toString(); Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new Exception(str); } catch (InvocationTargetException ex) { int num = 1; invocationTargetException = (InvocationTargetException) ByteCodeHelper.MapException<InvocationTargetException>((Exception) ex, (ByteCodeHelper.MapFlags) num); } throw Throwable.__\u003Cunmap\u003E(invocationTargetException.getCause()); }
public static Description createTestDescription(Class clazz, string name, params Annotation[] annotations) { string str1 = "%s(%s)"; object[] objArray = new object[2]; int index1 = 0; string str2 = name; objArray[index1] = (object) str2; int index2 = 1; string name1 = clazz.getName(); objArray[index2] = (object) name1; return new Description(String.format(str1, objArray), annotations); }
public static Description createSuiteDescription(Class testClass) { return new Description(testClass.getName(), testClass.getAnnotations()); }
public static Test createTest(Class theClass, string name) { Constructor testConstructor; try { testConstructor = TestSuite.getTestConstructor(theClass); goto label_3; } catch (NoSuchMethodException ex) { } return TestSuite.warning(new StringBuilder().append("Class ").append(theClass.getName()).append(" has no public constructor TestCase(String name) or TestCase()").toString()); label_3: object obj; InstantiationException instantiationException1; InvocationTargetException invocationTargetException1; IllegalAccessException illegalAccessException1; try { try { try { if (testConstructor.getParameterTypes().Length == 0) { obj = testConstructor.newInstance(new object[0], TestSuite.__\u003CGetCallerID\u003E()); if (obj is TestCase) { ((TestCase) obj).setName(name); goto label_13; } else goto label_13; } else { Constructor constructor = testConstructor; object[] objArray = new object[1]; int index = 0; string str = name; objArray[index] = (object) str; CallerID callerId = TestSuite.__\u003CGetCallerID\u003E(); obj = constructor.newInstance(objArray, callerId); goto label_13; } } catch (InstantiationException ex) { int num = 1; instantiationException1 = (InstantiationException) ByteCodeHelper.MapException<InstantiationException>((Exception) ex, (ByteCodeHelper.MapFlags) num); } } catch (InvocationTargetException ex) { int num = 1; invocationTargetException1 = (InvocationTargetException) ByteCodeHelper.MapException<InvocationTargetException>((Exception) ex, (ByteCodeHelper.MapFlags) num); goto label_11; } } catch (IllegalAccessException ex) { int num = 1; illegalAccessException1 = (IllegalAccessException) ByteCodeHelper.MapException<IllegalAccessException>((Exception) ex, (ByteCodeHelper.MapFlags) num); goto label_12; } InstantiationException instantiationException2 = instantiationException1; return TestSuite.warning(new StringBuilder().append("Cannot instantiate test case: ").append(name).append(" (").append(TestSuite.exceptionToString((Exception) instantiationException2)).append(")").toString()); label_11: InvocationTargetException invocationTargetException2 = invocationTargetException1; return TestSuite.warning(new StringBuilder().append("Exception in constructor: ").append(name).append(" (").append(TestSuite.exceptionToString(invocationTargetException2.getTargetException())).append(")").toString()); label_12: IllegalAccessException illegalAccessException2 = illegalAccessException1; return TestSuite.warning(new StringBuilder().append("Cannot access test case: ").append(name).append(" (").append(TestSuite.exceptionToString((Exception) illegalAccessException2)).append(")").toString()); label_13: return (Test) obj; }
public static string getCPPTypeName(Class type) { if (type == ClassLiteral<Buffer>.Value || type == ClassLiteral<Pointer>.Value) return "void*"; if (type == ClassLiteral<byte[]>.Value || type == ClassLiteral<ByteBuffer>.Value || type == ClassLiteral<BytePointer>.Value) return "signed char*"; if (type == ClassLiteral<short[]>.Value || type == ClassLiteral<ShortBuffer>.Value || type == ClassLiteral<ShortPointer>.Value) return "short*"; if (type == ClassLiteral<int[]>.Value || type == ClassLiteral<IntBuffer>.Value || type == ClassLiteral<IntPointer>.Value) return "int*"; if (type == ClassLiteral<long[]>.Value || type == ClassLiteral<LongBuffer>.Value || type == ClassLiteral<LongPointer>.Value) return "jlong*"; if (type == ClassLiteral<float[]>.Value || type == ClassLiteral<FloatBuffer>.Value || type == ClassLiteral<FloatPointer>.Value) return "float*"; if (type == ClassLiteral<double[]>.Value || type == ClassLiteral<DoubleBuffer>.Value || type == ClassLiteral<DoublePointer>.Value) return "double*"; if (type == ClassLiteral<char[]>.Value || type == ClassLiteral<CharBuffer>.Value || type == ClassLiteral<CharPointer>.Value) return "unsigned short*"; if (type == ClassLiteral<PointerPointer>.Value) return "void**"; if (type == ClassLiteral<String>.Value) return "const char*"; if (type == Byte.TYPE) return "signed char"; if (type == Character.TYPE) return "unsigned short"; if (type == Long.TYPE) return "jlong"; if (type == Boolean.TYPE) return "unsigned char"; if (type.isPrimitive()) return type.getName(); else if (((Class) ClassLiteral<FunctionPointer>.Value).isAssignableFrom(type)) { return new StringBuilder().append("JavaCPP_").append(Generator.mangle(type.getName())).append("*").toString(); } else { string str1 = ""; for (; type != null; type = type.getDeclaringClass()) { Namespace @namespace = (Namespace) type.getAnnotation((Class) ClassLiteral<Namespace>.Value); string str2 = @namespace == null ? "" : @namespace.value(); if (((Class) ClassLiteral<Pointer>.Value).isAssignableFrom(type)) { Name name1 = (Name) type.getAnnotation((Class) ClassLiteral<Name>.Value); string str3; if (name1 == null) { string name2 = type.getName(); str3 = String.instancehelper_substring(name2, String.instancehelper_lastIndexOf(name2, "$") + 1); } else str3 = name1.value(); str2 = String.instancehelper_length(str2) != 0 ? new StringBuilder().append(str2).append("::").append(str3).toString() : str3; } if (String.instancehelper_length(str1) == 0) str1 = str2; else if (String.instancehelper_length(str2) > 0) str1 = new StringBuilder().append(str2).append("::").append(str1).toString(); } return new StringBuilder().append(str1).append("*").toString(); } }
public static string getSignature(Class type) { if (type == Byte.TYPE) return "B"; if (type == Short.TYPE) return "S"; if (type == Integer.TYPE) return "I"; if (type == Long.TYPE) return "J"; if (type == Float.TYPE) return "F"; if (type == Double.TYPE) return "D"; if (type == Boolean.TYPE) return "Z"; if (type == Character.TYPE) return "C"; if (type == Void.TYPE) return "V"; if (type.isArray()) { string name = type.getName(); string str = "."; object obj1 = (object) "/"; object obj2 = (object) str; CharSequence charSequence1; charSequence1.__\u003Cref\u003E = (__Null) obj2; CharSequence charSequence2 = charSequence1; object obj3 = obj1; charSequence1.__\u003Cref\u003E = (__Null) obj3; CharSequence charSequence3 = charSequence1; return String.instancehelper_replace(name, charSequence2, charSequence3); } else { StringBuilder stringBuilder = new StringBuilder().append("L"); string name = type.getName(); string str1 = "."; object obj1 = (object) "/"; object obj2 = (object) str1; CharSequence charSequence1; charSequence1.__\u003Cref\u003E = (__Null) obj2; CharSequence charSequence2 = charSequence1; object obj3 = obj1; charSequence1.__\u003Cref\u003E = (__Null) obj3; CharSequence charSequence3 = charSequence1; string str2 = String.instancehelper_replace(name, charSequence2, charSequence3); return stringBuilder.append(str2).append(";").toString(); } }
public static string load(Class cls) { if (!Loader.loadLibraries) return (string) null; string str1 = cls.getName(); int num1 = String.instancehelper_indexOf(str1, 36); if (num1 > 0) str1 = String.instancehelper_substring(str1, 0, num1); ClassNotFoundException notFoundException1; try { cls = Class.forName(str1, Loader.__\u003CGetCallerID\u003E()); goto label_7; } catch (ClassNotFoundException ex) { int num2 = 1; notFoundException1 = (ClassNotFoundException) ByteCodeHelper.MapException<ClassNotFoundException>((Exception) ex, (ByteCodeHelper.MapFlags) num2); } ClassNotFoundException notFoundException2 = notFoundException1; NoClassDefFoundError classDefFoundError = new NoClassDefFoundError(Throwable.instancehelper_toString((Exception) notFoundException2)); Throwable.instancehelper_initCause((Exception) classDefFoundError, (Exception) notFoundException2); throw Throwable.__\u003Cunmap\u003E((Exception) classDefFoundError); label_7: string str2 = (string) Loader.loadedLibraries.get((object) cls); if (str2 != null) return str2; Properties properties = (Properties) ((Hashtable) Loader.getProperties()).clone(); Loader.appendProperties(properties, cls); string property1 = properties.getProperty("path.separator"); string str3 = properties.getProperty("platform.root"); if (str3 != null && !String.instancehelper_endsWith(str3, (string) File.separator)) str3 = new StringBuilder().append(str3).append((string) File.separator).toString(); string property2 = properties.getProperty("loader.preloadpath"); string property3 = properties.getProperty("loader.preload"); if (property2 != null && property3 != null) { string[] paths = String.instancehelper_split(property2, property1); if (str3 != null) { for (int index = 0; index < paths.Length; ++index) { File.__\u003Cclinit\u003E(); if (!new File(paths[index]).isAbsolute()) paths[index] = new StringBuilder().append(str3).append(paths[index]).toString(); } } Loader.preload(paths, String.instancehelper_split(property3, property1)); } File file = (File) null; string libraryName; string str4; string str5; UnsatisfiedLinkError unsatisfiedLinkError1; IOException ioException1; // ISSUE: fault handler try { try { libraryName = Loader.getLibraryName(cls); string prefix = new StringBuilder().append(properties.getProperty("library.prefix")).append(libraryName).toString(); string property4 = properties.getProperty("library.suffix"); string name = new StringBuilder().append(properties.getProperty("platform.name")).append('/').append(prefix).append(property4).toString(); file = Loader.extractResource(cls, name, (File) null, prefix, property4); if (file != null) { str4 = file.getAbsolutePath(); System.load(str4, Loader.__\u003CGetCallerID\u003E()); Loader.loadedLibraries.put((object) cls, (object) str4); str5 = str4; goto label_31; } else goto label_34; } catch (Exception ex) { int num2 = 0; M0 m0 = ByteCodeHelper.MapException<UnsatisfiedLinkError>(ex, (ByteCodeHelper.MapFlags) num2); if (m0 == null) throw; else unsatisfiedLinkError1 = (UnsatisfiedLinkError) m0; } } catch (IOException ex) { int num2 = 1; ioException1 = (IOException) ByteCodeHelper.MapException<IOException>((Exception) ex, (ByteCodeHelper.MapFlags) num2); goto label_30; } __fault { if (file != null) file.deleteOnExit(); } UnsatisfiedLinkError unsatisfiedLinkError2 = unsatisfiedLinkError1; goto label_47; label_30: IOException ioException2 = ioException1; goto label_54; label_31: if (file != null) file.deleteOnExit(); return str5; label_34: UnsatisfiedLinkError unsatisfiedLinkError3; IOException ioException3; // ISSUE: fault handler try { try { System.loadLibrary(libraryName, Loader.__\u003CGetCallerID\u003E()); Loader.loadedLibraries.put((object) cls, (object) libraryName); str4 = libraryName; goto label_44; } catch (Exception ex) { int num2 = 0; M0 m0 = ByteCodeHelper.MapException<UnsatisfiedLinkError>(ex, (ByteCodeHelper.MapFlags) num2); if (m0 == null) throw; else unsatisfiedLinkError3 = (UnsatisfiedLinkError) m0; } } catch (IOException ex) { int num2 = 1; ioException3 = (IOException) ByteCodeHelper.MapException<IOException>((Exception) ex, (ByteCodeHelper.MapFlags) num2); goto label_43; } __fault { if (file != null) file.deleteOnExit(); } unsatisfiedLinkError2 = unsatisfiedLinkError3; goto label_47; label_43: ioException2 = ioException3; goto label_54; label_44: if (file != null) file.deleteOnExit(); return str4; label_47: UnsatisfiedLinkError unsatisfiedLinkError4 = unsatisfiedLinkError2; // ISSUE: fault handler try { UnsatisfiedLinkError unsatisfiedLinkError5 = unsatisfiedLinkError4; if (file != null) file.delete(); throw Throwable.__\u003Cunmap\u003E((Exception) unsatisfiedLinkError5); } __fault { if (file != null) file.deleteOnExit(); } label_54: IOException ioException4 = ioException2; // ISSUE: fault handler try { IOException ioException5 = ioException4; if (file != null) file.delete(); UnsatisfiedLinkError unsatisfiedLinkError5 = new UnsatisfiedLinkError(Throwable.instancehelper_toString((Exception) ioException5)); Throwable.instancehelper_initCause((Exception) unsatisfiedLinkError5, (Exception) ioException5); throw Throwable.__\u003Cunmap\u003E((Exception) unsatisfiedLinkError5); } __fault { if (file != null) file.deleteOnExit(); } }
internal static GType RegisterClass(Class clazz, TypeRegistration registration) { if (knownClasses.ContainsKey(clazz)) { GType known = knownClasses[clazz]; if (registration != null) { known.Registration = registration; } return known; } var res = new GType(); if (clazz.isArray()) { res.ArrayElement = RegisterClass(clazz.getComponentType(), null); res.IsArray = true; string array = "[]"; Class comp = clazz.getComponentType(); while (comp.isArray()) { array += "[]"; comp = comp.getComponentType(); } res.LowerName = ((string) comp.getName()).ToLowerInvariant() + array; } else { res.LowerName = ((string) clazz.getName()).ToLowerInvariant(); } res.Attributes = 0; var classModifiers = (ModifierFlags) clazz.getModifiers(); if ((classModifiers & ModifierFlags.Abstract) != 0) { res.IsAbstract = true; res.Attributes |= TypeAttributes.Abstract; } if ((classModifiers & ModifierFlags.Final) != 0) { res.IsFinal = true; } if ((classModifiers & ModifierFlags.Public) != 0) { res.Attributes |= TypeAttributes.Public; } else if ((classModifiers & ModifierFlags.Private) != 0) { res.Attributes |= TypeAttributes.NotPublic; } //TODO internal ? if (knownNames.ContainsKey(res.LowerName)) { res = knownNames[res.LowerName]; } if (res.Registration == null && registration != null) { res.Registration = registration; } res.JVMType = clazz; res.JVMFullName = clazz.getName(); if (res.IsArray) { string array = "[]"; Class comp = clazz.getComponentType(); while (comp.isArray()) { array += "[]"; comp = comp.getComponentType(); } res.JVMFullName = comp.getName() + array; } else { res.JVMFullName = clazz.getName(); } res.IsJVMType = true; res.IsPrimitive = clazz.isPrimitive(); res.IsException = Throwable._class.isAssignableFrom(clazz); res.IsInterface = clazz.isInterface(); res.IsCLRProxy = clrProxyClass != null && clrProxyClass.isAssignableFrom(clazz); if (!res.IsCLRProxy) { res.IsJVMRealType = true; } Class superclass = clazz.getSuperclass(); var isBaseClassPublic = superclass == null || ((ModifierFlags)superclass.getModifiers() & ModifierFlags.Public) != 0; if (superclass != null && res.Base == null && clazz != Object._class && clazz != Throwable._class && res.JVMFullName != "system.Object" && res.JVMFullName != "system.Exception" && isBaseClassPublic) { res.Base = RegisterClass(superclass); } List<Class> interfaces = new List<Class>(clazz.getInterfaces()); if (!isBaseClassPublic) { interfaces.AddRange(superclass.getInterfaces()); res.Base = RegisterClass(superclass.getSuperclass()); } foreach (Class ifc in interfaces) { GType gifc = RegisterClass(ifc); if (!res.Interfaces.Contains(gifc)) { if (res.IsInterface && res.Base == null) { res.Base = gifc; } res.Interfaces.Add(gifc); res.AllInterfaces.Add(gifc); } } Register(res); return res; }
public static LogContext createContext(Class context) { return Log.createContext(context.getName()); }