C
Chris Ebenezer
I have some code like this:
package somepackage;
public abstract class StateMachine<T> {
protected abstract class FooState extends State {
protected final void stateEnter() throws StateChangeException {
enter();
}
protected void enter() throws StateChangeException {
}
}
protected abstract class State {
abstract void stateEnter() throws StateChangeException;
}
protected class StateChangeException extends Exception {
}
}
The compiler with eclipse seems to handle it fine. The JDK1.5 compiler
spits out the error:
unreported exception somepackage.StateMachine.StateChangeException; must
be caught or declared to be thrown
For the line where 'enter()' is being called in FooState.
I've tried various combinations of qualifiying the exception class (as
StateMachine.StateChangeException) - and can, when this is qualified
everywhere get eclipse and the JDK to compile it.
However, there appears to be no way of then extending a specific non
generic version of this class and overloading 'State' without having
this error reappear at other levels. Qualifying the names at this level
breaks either compiling via the JDK or Eclipse, or both.
E.g:
class BarStateMachine extends StateMachine<Bar> {
public abstract class BarState extends State {
protected BarState() {
}
protected final void stateEnter() throws StateChangeException
{
enter();
}
protected void enter() throws StateMachine.StateChangeException
{
}
protected abstract State methodOne();
}
}
Can't be compiled - no matter what combination of qualification of the
exception name that I try.
package somepackage;
public abstract class StateMachine<T> {
protected abstract class FooState extends State {
protected final void stateEnter() throws StateChangeException {
enter();
}
protected void enter() throws StateChangeException {
}
}
protected abstract class State {
abstract void stateEnter() throws StateChangeException;
}
protected class StateChangeException extends Exception {
}
}
The compiler with eclipse seems to handle it fine. The JDK1.5 compiler
spits out the error:
unreported exception somepackage.StateMachine.StateChangeException; must
be caught or declared to be thrown
For the line where 'enter()' is being called in FooState.
I've tried various combinations of qualifiying the exception class (as
StateMachine.StateChangeException) - and can, when this is qualified
everywhere get eclipse and the JDK to compile it.
However, there appears to be no way of then extending a specific non
generic version of this class and overloading 'State' without having
this error reappear at other levels. Qualifying the names at this level
breaks either compiling via the JDK or Eclipse, or both.
E.g:
class BarStateMachine extends StateMachine<Bar> {
public abstract class BarState extends State {
protected BarState() {
}
protected final void stateEnter() throws StateChangeException
{
enter();
}
protected void enter() throws StateMachine.StateChangeException
{
}
protected abstract State methodOne();
}
}
Can't be compiled - no matter what combination of qualification of the
exception name that I try.