diff -r 71e344b8e2c2 -r 7220be8747f0 src/share/classes/com/sun/tools/javac/tree/TreeInfo.java --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Fri May 05 06:07:27 2017 -0700 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Jun 07 00:04:12 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import com.sun.tools.javac.tree.JCTree.*; import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*; import com.sun.tools.javac.util.*; + import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.TypeTag.BOT; @@ -611,13 +612,21 @@ }; } + public enum PosKind { + START_POS() { int toPos(JCTree tree) { return TreeInfo.getStartPos(tree); } }, + FIRST_STAT_POS() { int toPos(JCTree tree) { return firstStatPos(tree); } }, + END_POS() { int toPos(JCTree tree) { return endPos(tree); } }; + + abstract int toPos(JCTree tree); + } + /** The position of the finalizer of given try/synchronized statement. */ - public static int finalizerPos(JCTree tree) { + public static int finalizerPos(JCTree tree, PosKind posKind) { if (tree.hasTag(TRY)) { JCTry t = (JCTry) tree; Assert.checkNonNull(t.finalizer); - return firstStatPos(t.finalizer); + return posKind.toPos(t.finalizer); } else if (tree.hasTag(SYNCHRONIZED)) { return endPos(((JCSynchronized) tree).body); } else {