This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
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 ]