Changeset 3938


Ignore:
Timestamp:
Nov 8, 2007, 9:23:30 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #818: JarClassLoader? doesn't load classes correctly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4-stable/src/core/net/sf/basedb/util/JarClassLoader.java

    r3679 r3938  
    310310      }
    311311      in = jarFile.getInputStream(jarEntry);
    312       byte[] b = new byte[(int)jarEntry.getSize()];
    313       in.read(b, 0, b.length);
     312      int classSize = (int)jarEntry.getSize();
     313      byte[] b = new byte[classSize];
     314      int totalRead = 0;
     315      while (totalRead < classSize)
     316      {
     317        int numRead = in.read(b, totalRead, b.length - totalRead);
     318        if (numRead == -1) break;
     319        totalRead += numRead;
     320      }
     321      if (totalRead != classSize)
     322      {
     323        throw new ClassFormatError("Could not read the complete class for " +
     324          name + ": " + totalRead + " bytes; expected " + classSize + " bytes");
     325      }
    314326      return b;
    315327    }
Note: See TracChangeset for help on using the changeset viewer.