How do you retrieve byte code from nested jar files?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Nathan_Gulley
Posted On:   Wednesday, May 1, 2002 09:18 AM

Hello JGurus, I am trying to retrieve the byte code of classes that are nested 1,2,...n levels deep inside of nested jar, ear and war files. However, I run into problems when trying to retrieve data from compressed nested jar, ear and war files. The clasfile data gets truncated or entries are not listed. The problem dissappears when I use jar files that are not compressed. I discovered that when I run the following code on a jar that contains compressed entries, I can retrieve the compressed size of all jar entries that are not inside of nested jars. However if a jar entry is nested, I always get –1 as the compression size.    More>>


Hello JGurus,





I am trying to retrieve the byte code of classes that are nested 1,2,...n levels deep inside of nested jar, ear and war files.





However, I run into problems when trying to retrieve data from compressed nested jar, ear and war files. The clasfile data gets truncated or entries are not listed. The problem
dissappears when I use jar files that are not compressed.





I discovered that when I run the following code on a jar that contains compressed entries, I can retrieve the compressed size of all jar entries that are not inside of nested jars. However if a jar entry is nested, I always get –1 as the compression size.




			
JarFile jarFile = new JarFile("myapp.ear");
JarEntry entry1 = jarFile.getJarEntry("myapp.war");

// always correct size compressed/ not compressed
int size1 = entry1.getCompressedSize();

JarInputStream(jarFile.getInputStream(entry))
JarEntry entry2 = inputStream.getNextJarEntry();

// always -1 if compressed
int size2 = entry2.getCompressedSize();




I figure whether the nested entries are compressed or not, the right size should be returned. Is this a bug in the java API or is there a better way to go about retrieving the byte code of classes that are nested 1,2,...n levels deep inside of nested jar, ear and war files?





Nathan
natebox@yahoo.com

   <<Less
About | Sitemap | Contact