Esempio n. 1
0
        private void ReadJar()
        {
            using var ms = new MemoryStream(RawContents);
            var archive = new ZipArchive(ms);

            foreach (var javaClass in archive.Entries
                     .Where(c => Path.GetExtension(c.Name).ToLower() == ".class")
                     .Select(e =>
            {
                //Let NBCEL parse the class file
                var reader = new ClassParser(e.Open().ReadFully(), e.Name);
                var result = reader.Parse();
                var ownJavaClass = new JavaClass(result);

                //Store the class for future use from NBCEL.
                SyntheticRepository.GetInstance().StoreClass(result);
                LoadedClassRepository.Instance.StoreClass(ownJavaClass);

                return(ownJavaClass);
            }
                             ))
            {
                Classes.Add(javaClass.FullClassName, javaClass);
            }
        }
Esempio n. 2
0
        public static JarArchive ToDataClass(this MetadataJarArchive meta)
        {
            var archive     = new JarArchive("Memory-File.jar", new byte[0]);
            var javaClasses = meta.JavaClasses.Select(c => (c.Key, c.Value.ToDataClass()));

            var repository = SyntheticRepository.GetInstance();

            foreach (var(name, clazz) in javaClasses)
            {
                repository.StoreClass(new VirtualDataClass(clazz));
                LoadedClassRepository.Instance.StoreClass(clazz);
                archive.Classes.Add(name, clazz);
            }

            return(archive);
        }