SourceForge has been redesigned. Learn more.
Close

#2 ChoiceMaker compiler generates a spurious method for Holders

open
1
2010-11-15
2010-11-15
Rick Hall
No

The ChoicMaker compiler generates a spurious method, void accept(IRecordVisitor), for Holder classes. The compiler supplies a default implementation which casts a Holder object to an instance of IRecordHolder. This is guaranteed to throw a ClassCastException, because Holder classes don't implement IRecordHolder. The only reason this bug has survived is that no one ever calls the accept method on Holder objects; instead, the method is invoked on RecordHolder subclasses, which do implement IRecordHolder, and which therefore don't throw an exception.

The obvious fix is to remove the compiler code that generates this method on Holder classes, but this may be a bit more work than it seems, since the compiler reuses a lot of code to generate both Holder and RecordHolder classes.

Discussion


Log in to post a comment.