Bug 38526 - RuntimeException: Couldn't instantiate the class for type with id 0
Summary: RuntimeException: Couldn't instantiate the class for type with id 0
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: 3.0-dev
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2006-02-06 06:03 UTC by Trejkaz (pen name)
Modified: 2007-05-29 01:42 UTC (History)
0 users

PPT file exhibiting the problem. (62.00 KB, application/octet-stream)
2006-02-06 06:05 UTC, Trejkaz (pen name)

Note You need to log in before you can comment on or make changes to this bug.
Description Trejkaz (pen name) 2006-02-06 06:03:50 UTC
On latest version in SVN, constructing an HSLFSlideShow on a certain slide show,
I get the following error:

java.lang.RuntimeException: Couldn't instantiate the class for type with id 0 on
class class org.apache.poi.hslf.record.UnknownRecordPlaceholder :
Cause was : java.lang.ArrayIndexOutOfBoundsException
        at org.apache.poi.hslf.record.Record.createRecordForType(Record.java:158)
        at org.apache.poi.hslf.record.Record.findChildRecords(Record.java:109)
        at org.apache.poi.hslf.HSLFSlideShow.readFIB(HSLFSlideShow.java:174)
        at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlideShow.java:103)
Comment 1 Trejkaz (pen name) 2006-02-06 06:05:14 UTC
Created attachment 17600 [details]
PPT file exhibiting the problem.

Here's the file in question.  It opens in Office and OpenOffice, looks to be
pretty innocent but breaks in HSLF for some reason.
Comment 2 Nick Burch 2006-02-06 13:59:22 UTC
Following the normal slide records, that PPT file than has 63 records of type 0.
The first 62 are of zero length (so just the 8 byte record header), and the
final one is 251658240 bytes big!

I'm happy to code up something to ignore the empty records of type 0. I'm less
happy about the whacking great record

How did you go about creating this file, and is there anything special about it?
Comment 3 Nick Burch 2006-02-06 14:04:30 UTC
On closer inspection, that last record claims to be ~250mb in size, as part of a
62kb file! Something is corrupt somewhere in that PPT file, but I'll see if I
can come up with a sensible way to handle documents with corruption like that.
Comment 4 Nick Burch 2006-02-06 14:14:02 UTC
OK, SVN now has a fix. If a record claims to be larger than the available data,
it will be silently ignored. I can now process that file fine with HSLF.

Note - if you open a corrupt file like this, and write it back out again, it
will be changed! (The corrupt record will be discarded)
Comment 5 Trejkaz (pen name) 2006-02-07 00:19:44 UTC
Ah, so it was corrupt... I was wondering about that, because even OpenOffice
opened it silently.  I actually got the PPT file out of a large set of PPT files
created by other people, so it's impossible to know exactly which versions they
used and what sort of shenanigans went on. :-)
Comment 6 Trejkaz (pen name) 2006-02-07 00:58:26 UTC
Darn.  This does prevent the error being thrown, but now getTextRuns() returns
no text.  OpenOffice can show the text, so there must be something that can be
done to retrieve it.

Feel free to re-close this if it looks like it's completely impossible to get
out because of that corrupt record.
Comment 7 Yegor Kozlov 2007-05-29 01:42:15 UTC
Fixed, though it wasn't trivial.
In the attached file root-level records were not continuous and some of them
were skipped with the "Skipping record of type 0 at position ..." message in
As the result, the wrong Slide record was selected with no text runs.
Should work fine now.