FinalVariableAssignedToInCatchBlockTest.java revision 1878:3b4f92a3797f
1275970Scy/* 2275970Scy * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3275970Scy * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4275970Scy * 5275970Scy * This code is free software; you can redistribute it and/or modify it 6275970Scy * under the terms of the GNU General Public License version 2 only, as 7275970Scy * published by the Free Software Foundation. 8275970Scy * 9330567Sgordon * This code is distributed in the hope that it will be useful, but WITHOUT 10275970Scy * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11275970Scy * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12275970Scy * version 2 for more details (a copy is included in the LICENSE file that 13275970Scy * accompanied this code). 14275970Scy * 15275970Scy * You should have received a copy of the GNU General Public License version 16275970Scy * 2 along with this work; if not, write to the Free Software Foundation, 17275970Scy * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18275970Scy * 19275970Scy * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20275970Scy * or visit www.oracle.com if you need additional information or have any 21275970Scy * questions. 22275970Scy */ 23275970Scy 24275970Scy/* 25275970Scy * @test 26275970Scy * @bug 6356530 27275970Scy * @summary -Xlint:serial does not flag abstract classes with concrete methods/members 28275970Scy * @compile/fail/ref=FinalVariableAssignedToInCatchBlockTest.out -XDrawDiagnostics FinalVariableAssignedToInCatchBlockTest.java 29275970Scy */ 30275970Scy 31275970Scyimport java.io.IOException; 32275970Scy 33275970Scypublic class FinalVariableAssignedToInCatchBlockTest { 34275970Scy public void m1(int o) 35275970Scy { 36275970Scy final int i; 37275970Scy try { 38275970Scy if (o == 1) { 39275970Scy throw new IOException(); 40275970Scy } else if (o == 2) { 41275970Scy throw new InterruptedException(); 42275970Scy } else { 43275970Scy throw new Exception(); 44275970Scy } 45275970Scy } catch (IOException e) { 46275970Scy i = 1; 47275970Scy } catch (InterruptedException ie) { 48275970Scy i = 2; 49275970Scy } catch (Exception e) { 50316722Sdelphij i = 3; 51316722Sdelphij } finally { 52275970Scy i = 4; 53275970Scy } 54275970Scy } 55275970Scy 56316722Sdelphij public void m2(int o) 57316722Sdelphij { 58316722Sdelphij final int i; 59316722Sdelphij try { 60316722Sdelphij if (o == 1) { 61316722Sdelphij throw new IOException(); 62275970Scy } else if (o == 2) { 63275970Scy throw new InterruptedException(); 64275970Scy } else { 65275970Scy throw new Exception(); 66275970Scy } 67275970Scy } catch (IOException e) { 68316722Sdelphij i = 1; 69275970Scy } catch (InterruptedException ie) { 70275970Scy i = 2; 71275970Scy } catch (Exception e) { 72275970Scy i = 3; 73275970Scy } 74316722Sdelphij } 75275970Scy 76275970Scy public void m3(int o) throws Exception 77275970Scy { 78275970Scy final int i; 79275970Scy try { 80275970Scy if (o == 1) { 81275970Scy throw new IOException(); 82275970Scy } else if (o == 2) { 83275970Scy throw new InterruptedException(); 84275970Scy } else { 85275970Scy throw new Exception(); 86275970Scy } 87275970Scy } catch (IOException e) { 88275970Scy i = 1; 89275970Scy } catch (InterruptedException ie) { 90275970Scy i = 2; 91275970Scy } 92275970Scy i = 3; 93275970Scy } 94275970Scy} 95275970Scy