AutumnFramework throws exceptions as allocated pointers
Closed this issue · 2 comments
GoogleCodeExporter commented
What steps will reproduce the problem?
- Grep for "throw" in the source code
What is the expected output? What do you see instead?
- You should not find any "throw new". Instead, the complete library
seems to throw all it's exceptions as pointers to std::exception sub
classes that are allocated via new.
This is Java - but *not* C++! Note, that there is no good reason for this
design decision and it contradicts all usual C++ expectations. Besides
the additional overhead to use the dynamic storage instead of static
storage (AKA stack-based) objects, client code will naturally expect
to use catch clauses of type "catch (const std::exception&)" and this
will never catch any of the thrown exceptions. Another downside of the
current apporach is that users need to delete the catched exception
to prevent memory leaks. Although not recommended, they can never prevent
memory leaks if they catch via "catch(...)" because they don't get the
exception object to delete.
The recommended fix is easy and even makes the current code shorter: Simply
replace any "throw new ..." with "throw ...", e.g. change in
ObjectType::createValue the current lines:
...
throw new CreateBeanFailedEx("ObjectType", "createValue",
"getBean[" + name + "] return NULL!");
}
throw new NonValueEx("ObjectType", "createValue",
"There is no string in vector!");
to
...
throw CreateBeanFailedEx("ObjectType", "createValue",
"getBean[" + name + "] return NULL!");
}
throw NonValueEx("ObjectType", "createValue",
"There is no string in vector!");
What version of the product are you using? On what operating system?
AutumnFramework 0.4
Original issue reported on code.google.com by daniel.k...@gmail.com
on 18 Jul 2007 at 8:16
GoogleCodeExporter commented
Original comment by sharp...@gmail.com
on 20 Jul 2007 at 10:26
- Changed state: Accepted
GoogleCodeExporter commented
Original comment by sharp...@gmail.com
on 21 Jul 2007 at 8:54
- Changed state: Verified