Hello all, I am trying to load class files within a jar file. The program extracts and iterates through all the ZipEntrys. For each ZipEntry i obtain the InputStream and read in the contents of each class file in to a byte array. I've made a ClassLoader which relaxes the access rights to the define method which take an array of bytes: Class defineClass(String name, byte data, int start, int end); However only certain classes correctly return a Class objects. The majority of class files i try to read in this manner throws a ClassFormatException with one if the following messages: Illegal constant pool type Illegal UTF8 string in constant pool Illegal constant pool index Arguments can't fit into locals any ideas?
posted 11 years ago
you've probably done sth like: inputStreamInstance.read(byte b) like me... This is what you should do: new DataInputStream(inputStreamInstance).readFully(byte b) I don't really know why because the apidoc for both methods looks the same. But it works! [ May 06, 2004: Message edited by: sander hautvast ]