示例

public static void main( String[] args ) {
int number = 0;
try {
number = Integer.parseInt( args[ 0 ] );
} finally {
System.out.println( "finally clause" ); //$NON-NLS-1$
if ( number == 0 ) {
throw new IllegalArgumentException( "Bad argument" ); //$NON-NLS-1$
}
}
}

解决方案
throw 语句移到 finally 块的外部。

public static void main( String[] args ) {
int number = 0;
try {
number = Integer.parseInt( args[ 0 ] );
} finally {
System.out.println( "finally clause" ); //$NON-NLS-1$
}

if ( number == 0 ) {
throw new IllegalArgumentException( "Bad argument" ); //$NON-NLS-1$
}
}