/**
   * Look up the byte code definition of the named class.
   *
   * <p>Created: Mar 30, 2004
   *
   * @param className
   * @return - byte code for the class definition.
   */
  private byte[] lookupClassData(String className) {

    if (isJar(moduleParentLocator)) {
      String fileName;
      if (LECCMachineConfiguration.generateBytecode()) {
        fileName = className.replace('.', '/') + COMPRESSED_CLASS_FILE_EXTENSION;
      } else {
        fileName = className.replace('.', '/') + CLASS_FILE_EXTENSION;
      }
      return loadJarData((ProgramResourceLocator.File) moduleParentLocator, fileName);

    } else {

      ProgramResourceLocator.File fileLocator;
      if (LECCMachineConfiguration.generateBytecode()) {
        String extension =
            className.substring(className.lastIndexOf('.') + 1)
                + CALClassLoader.COMPRESSED_CLASS_FILE_EXTENSION;
        fileLocator = ((ProgramResourceLocator.Folder) moduleParentLocator).extendFile(extension);
      } else {
        String extension =
            className.substring(className.lastIndexOf('.') + 1)
                + CALClassLoader.CLASS_FILE_EXTENSION;
        fileLocator = ((ProgramResourceLocator.Folder) moduleParentLocator).extendFile(extension);
      }

      byte[] fileData = loadFileData(fileLocator);
      if (LECCMachineConfiguration.generateBytecode()) {
        if (fileData == null) {
          return null;
        }

        // uncompress the data..
        inflater.reset();
        inflater.setInput(fileData);

        // Reusing this baos should be ok, since its only other use is in loadFileData(), which
        // we've finished calling.
        ByteArrayOutputStream baos = threadLocalByteArrayOutputStream.get();
        baos.reset();

        try {
          // Reusing this bytearray should be ok, since its only other use is in loadFileData(),
          // which we've finished calling.
          byte[] buf = threadLocalByteArray.get();
          while (!inflater.finished()) {
            int len = inflater.inflate(buf);
            baos.write(buf, 0, len);
          }

        } catch (DataFormatException e) {
          // Can't read the compressed class..

          // return null;
          throw new IllegalStateException("Can't read compressed class: " + className);
        }

        return baos.toByteArray();

        // Not necessary to close the ByteArrayOutputStream.

      } else {
        // Source generator.
        return fileData;
      }
    }
  }