コード例 #1
0
        public void CacheClassBytes(FileInfo jar)
        {
            // experimental..
            try
            {
                Console.WriteLine(".cache: " + jar.FullName);

                var zip = default(ZipInputStream);


                zip = new ZipInputStream(new jvm::java.io.FileInputStream(jar.FullName));


                var Current = zip.getNextEntry();

                while (Current != null)
                {
                    var Name = Current.getName();

                    if (Name.EndsWith(".class"))
                    {
                        var TypeName = Name.Substring(0, Name.Length - ".class".Length).Replace("/", ".");

                        if (TypeName.StartsWith("java."))
                        {
                            // we cannot use ClassLoader to load such class anyhow..
                            // what we probably would need is a JVM parser now...
                        }
                        else
                        {
                            var Memory = zip.ReadToMemoryStream();

                            this.ClassBytes[TypeName] = Memory.ToArray();
                        }
                    }

                    Current = zip.getNextEntry();
                }
            }
            catch (jvm::csharp.ThrowableException cc)
            {
                Console.WriteLine("error @CacheClassBytes: " + cc);

                throw new InvalidOperationException();
            }
        }
コード例 #2
0
        public void CacheClassBytes(FileInfo jar)
        {
            // experimental..
            try
            {
                Console.WriteLine(".cache: " + jar.FullName);

                var zip = default(ZipInputStream);


                zip = new ZipInputStream(new jvm::java.io.FileInputStream(jar.FullName));


                var Current = zip.getNextEntry();

                while (Current != null)
                {
                    var Name = Current.getName();

                    if (Name.EndsWith(".class"))
                    {
                        var TypeName = Name.Substring(0, Name.Length - ".class".Length).Replace("/", ".");

                        if (TypeName.StartsWith("java."))
                        {
                            // we cannot use ClassLoader to load such class anyhow..
                            // what we probably would need is a JVM parser now...
                        }
                        else
                        {
                            var Memory = zip.ReadToMemoryStream();

                            this.ClassBytes[TypeName] = Memory.ToArray();
                        }
                    }

                    Current = zip.getNextEntry();
                }

            }
            catch (jvm::csharp.ThrowableException cc)
            {
                Console.WriteLine("error @CacheClassBytes: " + cc);

                throw new InvalidOperationException();
            }
        }