1.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Tue May 23 08:07:26 2017 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Jun 07 00:04:12 2017 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -35,6 +35,7 @@ 1.11 import com.sun.tools.javac.tree.JCTree.*; 1.12 import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*; 1.13 import com.sun.tools.javac.util.*; 1.14 + 1.15 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 1.16 import static com.sun.tools.javac.code.Flags.*; 1.17 import static com.sun.tools.javac.code.TypeTag.BOT; 1.18 @@ -611,13 +612,21 @@ 1.19 }; 1.20 } 1.21 1.22 + public enum PosKind { 1.23 + START_POS() { int toPos(JCTree tree) { return TreeInfo.getStartPos(tree); } }, 1.24 + FIRST_STAT_POS() { int toPos(JCTree tree) { return firstStatPos(tree); } }, 1.25 + END_POS() { int toPos(JCTree tree) { return endPos(tree); } }; 1.26 + 1.27 + abstract int toPos(JCTree tree); 1.28 + } 1.29 + 1.30 /** The position of the finalizer of given try/synchronized statement. 1.31 */ 1.32 - public static int finalizerPos(JCTree tree) { 1.33 + public static int finalizerPos(JCTree tree, PosKind posKind) { 1.34 if (tree.hasTag(TRY)) { 1.35 JCTry t = (JCTry) tree; 1.36 Assert.checkNonNull(t.finalizer); 1.37 - return firstStatPos(t.finalizer); 1.38 + return posKind.toPos(t.finalizer); 1.39 } else if (tree.hasTag(SYNCHRONIZED)) { 1.40 return endPos(((JCSynchronized) tree).body); 1.41 } else {