Esempio n. 1
0
 public override void GetObjectData(SerializationInfo info, StreamingContext context)
 {
     using (var bao = Adapt.Disposable(new ByteArrayOutputStream()))
     {
         using (var oos = Adapt.Disposable(new ObjectOutputStream(bao.Real)))
         {
             oos.Real.writeObject(Bridge.Cast <Object>(this));
             byte[] data = bao.Real.toByteArray();
             info.AddValue("exception", data);
         }
     }
 }
Esempio n. 2
0
 protected Throwable(SerializationInfo info, StreamingContext context)
 {
     byte[] data = (byte[])info.GetValue("exception", typeof(byte[]));
     using (var bai = Adapt.Disposable(new ByteArrayInputStream(data)))
     {
         using (var ois = Adapt.Disposable(new ObjectInputStream(bai.Real)))
         {
             Object exception = ois.Real.readObject();
             ((IJvmProxy)this).Copy(JNIEnv.ThreadEnv, exception.jvmHandle);
         }
     }
 }
Esempio n. 3
0
        public static void Register()
        {
            if (config.Verbose)
            {
                Console.WriteLine("clr.version         :" + RuntimeEnvironment.GetSystemVersion());
                Console.WriteLine("clr.arch            :" + ((IntPtr.Size == 8) ? "64bit" : "32bit"));
            }
            LoadClasspath();
            if (config.Verbose)
            {
                Console.WriteLine("java.home           :" + Bridge.Setup.JavaHome);
                Console.WriteLine("java.version        :" + java.lang.System.getProperty("java.version"));
                Console.WriteLine("sun.arch.data.model :" + java.lang.System.getProperty("sun.arch.data.model"));
                Console.WriteLine("");
            }

            LoadAssemblies();

            RegisterAssemblies();

            if (config.JavaClass != null)
            {
                RegisterClasses();
            }
            if (config.ClrType != null)
            {
                RegisterTypes();
            }

            foreach (Assembly assembly in generateAssemblies)
            {
                foreach (Type type in assembly.GetTypes())
                {
                    if (type.IsPublic)
                    {
                        TypeRegistration registration = new TypeRegistration();
                        registration.TypeName = type.FullName;
                        GType reg = RegisterType(type, registration);
                        reg.IsJVMGenerate      = true;
                        reg.IsSkipCLRInterface = !registration.SyncInterface;
                        reg.MergeJavaSource    = registration.MergeJavaSource;
                    }
                }
            }

            foreach (string classPath in generateCp)
            {
                if (Directory.Exists(classPath))
                {
                    string path = Path.GetFullPath(classPath);
                    foreach (string classFile in Directory.GetFiles(path, "*.class", SearchOption.AllDirectories))
                    {
                        if (!classFile.Contains("$"))
                        {
                            string name      = classFile.Substring(path.Length + 1);
                            string clazzName = name.Substring(0, name.Length - (".class".Length)).Replace('\\', '/');
                            RegisterClass(clazzName);
                        }
                    }
                }
                else if (File.Exists(classPath) && Path.GetExtension(classPath) == ".jar")
                {
                    using (var fis = Adapt.Disposable(new FileInputStream(classPath)))
                    {
                        using (var zis = Adapt.Disposable(new ZipInputStream(fis.Real)))
                        {
                            ZipEntry entry = zis.Real.getNextEntry();
                            while (entry != null)
                            {
                                string name = entry.getName();
                                if (!entry.isDirectory() && name.EndsWith(".class") && !name.Contains("$"))
                                {
                                    string clazzName = name.Substring(0, name.Length - (".class".Length));
                                    RegisterClass(clazzName);
                                }
                                entry = zis.Real.getNextEntry();
                            }
                        }
                    }
                }
            }
        }