Closed GoogleCodeExporter closed 9 years ago
Sorry, we don't see this happen within the next two years, closing the issue.
- Should it do this for all methods?
- Should we add 'throws' clauses to all methods?
- If the code in one of the methods doesn't actually declare to throw an
exception, how do we handle that? Generate a compiler error?
All in all, too much is unclear, it is hard to make it easy to understand, and
it doesn't add quite a lot. I personally only encountered this when
implementing RMI, but that's something from the past, isn't it?
Original comment by r.spilker
on 5 Aug 2013 at 7:47
- Should it do this for all methods?
Yes. I mean all methods should be delegated, and those who throw exceptions
should be surrounded with the ty-catch clause.
- Should we add 'throws' clauses to all methods?
No, only those which throw the given exceptions
- If the code in one of the methods doesn't actually declare to throw an
exception, how do we handle that? Generate a compiler error?
No, just use the standard delgation mechanism, without adding try-catch
encapsulation
Scenario: here is the code of the delegate object
Class DelegateObject
{
public Object someMethod(String someParam) throws PersistenceException, OtherException
{
//stuff ...
}
public Object someMethod2(String someParam)
{
//stuff ...
}
public Object someMethod3(String someParam) throws MyException
{
//stuff ...
}
}
The generated code would be:
class someClass{
private DelegateObject delegateObject;
public Object someMethod(String someParam) throws BusinessException {
try {
return delegateObject.someMethod(someParam);
}
catch (PersistenceException e) {
throw new BusinessException(e);
}
catch (OtherException e) {
throw new BusinessException(e);
}
}
public Object someMethod2(String someParam){
return delegateObject.someMethod2(someParam);
}
public Object someMethod3(String someParam) throws MyException{
return delegateObject.someMethod3(someParam);
}
}
Original comment by alexis.i...@gmail.com
on 6 Aug 2013 at 2:14
Original issue reported on code.google.com by
alexis.i...@gmail.com
on 24 Jul 2013 at 1:55