/** * Reads a class definition from a stream. * * @param stream The stream from which the class is to be read. * Must not be <code>null</code>. * @param classname The name of the class in the stream. * Must not be <code>null</code>. * * @return the Class object read from the stream. * * @exception IOException if there is a problem reading the class from the * stream. * @exception SecurityException if there is a security problem while * reading the class from the stream. */ private Class getClassFromStream(InputStream stream, String classname) throws IOException, SecurityException { ByteArrayOutputStream baos= new ByteArrayOutputStream(); int bytesRead; byte[] buffer= new byte[BUFFER_SIZE]; while ((bytesRead= stream.read(buffer, 0, BUFFER_SIZE)) != -1) { baos.write(buffer, 0, bytesRead); } byte[] classData= baos.toByteArray(); return defineClassFromData(classData, classname); }
byte[] bs= bytecodes.get(classname); if (bs != null) theClass= defineClassFromData(bs, classname);