Merge jdk8u141-b31

Mon, 26 Jun 2017 22:36:15 -0700

author
asaha
date
Mon, 26 Jun 2017 22:36:15 -0700
changeset 3499
716e712f0db4
parent 3495
3f0ca3de4c59
parent 3498
267aa3aeedfa
child 3500
38a0884d606a
child 3506
a2c5e219eccf

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Mon Jun 26 22:24:53 2017 -0700
     1.2 +++ b/.hgtags	Mon Jun 26 22:36:15 2017 -0700
     1.3 @@ -704,6 +704,8 @@
     1.4  5162417b51bdf68b95696198181f2e662a14ff8a jdk8u131-b11
     1.5  12f40d1f41c2cea8b61d046796a753000e61196f jdk8u131-b31
     1.6  508e7f6446deede595bbdbdc6d6cf9fc1ae8e728 jdk8u131-b32
     1.7 +df2b65224ab78a312559ae3054aeb3ef73abaf9e jdk8u131-b33
     1.8 +08a21473de54fd89fd53a01351cad954f60d2652 jdk8u131-b34
     1.9  1175fac90fdbbd864f7b1f306397644d26eb9781 jdk8u141-b00
    1.10  bb163efa3276e129c69bad28299a6283b869caa3 jdk8u141-b01
    1.11  5864e3781953daa69efd54b329a358a568229268 jdk8u141-b02
     2.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Mon Jun 26 22:24:53 2017 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Mon Jun 26 22:36:15 2017 -0700
     2.3 @@ -27,6 +27,7 @@
     2.4  
     2.5  import java.util.*;
     2.6  
     2.7 +import com.sun.tools.javac.tree.TreeInfo.PosKind;
     2.8  import com.sun.tools.javac.util.*;
     2.9  import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    2.10  import com.sun.tools.javac.util.List;
    2.11 @@ -1531,12 +1532,16 @@
    2.12                                    catchallpc, 0);
    2.13                      startseg = env.info.gaps.next().intValue();
    2.14                  }
    2.15 -                code.statBegin(TreeInfo.finalizerPos(env.tree));
    2.16 +                code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.FIRST_STAT_POS));
    2.17                  code.markStatBegin();
    2.18  
    2.19                  Item excVar = makeTemp(syms.throwableType);
    2.20                  excVar.store();
    2.21                  genFinalizer(env);
    2.22 +                code.resolvePending();
    2.23 +                code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.END_POS));
    2.24 +                code.markStatBegin();
    2.25 +
    2.26                  excVar.load();
    2.27                  registerCatch(body.pos(), startseg,
    2.28                                env.info.gaps.next().intValue(),
    2.29 @@ -1550,7 +1555,7 @@
    2.30                      code.resolve(env.info.cont);
    2.31  
    2.32                      // Mark statement line number
    2.33 -                    code.statBegin(TreeInfo.finalizerPos(env.tree));
    2.34 +                    code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.FIRST_STAT_POS));
    2.35                      code.markStatBegin();
    2.36  
    2.37                      // Save return address.
     3.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Mon Jun 26 22:24:53 2017 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Mon Jun 26 22:36:15 2017 -0700
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -35,6 +35,7 @@
    3.11  import com.sun.tools.javac.tree.JCTree.*;
    3.12  import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*;
    3.13  import com.sun.tools.javac.util.*;
    3.14 +
    3.15  import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    3.16  import static com.sun.tools.javac.code.Flags.*;
    3.17  import static com.sun.tools.javac.code.TypeTag.BOT;
    3.18 @@ -611,13 +612,21 @@
    3.19          };
    3.20      }
    3.21  
    3.22 +    public enum PosKind {
    3.23 +        START_POS() { int  toPos(JCTree tree) { return TreeInfo.getStartPos(tree); } },
    3.24 +        FIRST_STAT_POS() { int  toPos(JCTree tree) { return firstStatPos(tree); } },
    3.25 +        END_POS() { int  toPos(JCTree tree) { return endPos(tree); } };
    3.26 +
    3.27 +        abstract int toPos(JCTree tree);
    3.28 +    }
    3.29 +
    3.30      /** The position of the finalizer of given try/synchronized statement.
    3.31       */
    3.32 -    public static int finalizerPos(JCTree tree) {
    3.33 +    public static int finalizerPos(JCTree tree, PosKind posKind) {
    3.34          if (tree.hasTag(TRY)) {
    3.35              JCTry t = (JCTry) tree;
    3.36              Assert.checkNonNull(t.finalizer);
    3.37 -            return firstStatPos(t.finalizer);
    3.38 +            return posKind.toPos(t.finalizer);
    3.39          } else if (tree.hasTag(SYNCHRONIZED)) {
    3.40              return endPos(((JCSynchronized) tree).body);
    3.41          } else {
     4.1 --- a/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java	Mon Jun 26 22:24:53 2017 -0700
     4.2 +++ b/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java	Mon Jun 26 22:36:15 2017 -0700
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -64,6 +64,7 @@
    4.11          {9,           21},      //System.out.println("finally");
    4.12          {10,          29},
    4.13          {9,           32},      //System.out.println("finally");
    4.14 +        {10,          41},      //}
    4.15          {11,          43},
    4.16      };
    4.17  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/tools/javac/T8180660/MissingLNTEntryForFinalizerTest.java	Mon Jun 26 22:36:15 2017 -0700
     5.3 @@ -0,0 +1,170 @@
     5.4 +/*
     5.5 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 + *
     5.8 + * This code is free software; you can redistribute it and/or modify it
     5.9 + * under the terms of the GNU General Public License version 2 only, as
    5.10 + * published by the Free Software Foundation.
    5.11 + *
    5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.15 + * version 2 for more details (a copy is included in the LICENSE file that
    5.16 + * accompanied this code).
    5.17 + *
    5.18 + * You should have received a copy of the GNU General Public License version
    5.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.21 + *
    5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.23 + * or visit www.oracle.com if you need additional information or have any
    5.24 + * questions.
    5.25 + */
    5.26 +
    5.27 +/*
    5.28 + * @test
    5.29 + * @bug 8180141
    5.30 + * @summary Missing entry in LineNumberTable for break statement that jumps out of try-finally
    5.31 + * @compile -g MissingLNTEntryForFinalizerTest.java
    5.32 + * @run main MissingLNTEntryForFinalizerTest
    5.33 + */
    5.34 +
    5.35 +import java.io.File;
    5.36 +import java.net.URI;
    5.37 +
    5.38 +import javax.tools.JavaFileObject;
    5.39 +import javax.tools.SimpleJavaFileObject;
    5.40 +
    5.41 +import com.sun.tools.classfile.*;
    5.42 +import com.sun.tools.javac.comp.Attr;
    5.43 +import com.sun.tools.javac.comp.AttrContext;
    5.44 +import com.sun.tools.javac.comp.Env;
    5.45 +import com.sun.tools.javac.file.JavacFileManager;
    5.46 +import com.sun.tools.javac.main.JavaCompiler;
    5.47 +import com.sun.tools.javac.tree.JCTree;
    5.48 +import com.sun.tools.javac.tree.JCTree.*;
    5.49 +import com.sun.tools.javac.util.Context;
    5.50 +import com.sun.tools.javac.util.List;
    5.51 +
    5.52 +import static com.sun.tools.javac.util.List.of;
    5.53 +import static com.sun.tools.javac.tree.JCTree.Tag.*;
    5.54 +
    5.55 +public class MissingLNTEntryForFinalizerTest {
    5.56 +    protected ReusableJavaCompiler tool;
    5.57 +    Context context;
    5.58 +
    5.59 +    MissingLNTEntryForFinalizerTest() {
    5.60 +        context = new Context();
    5.61 +        JavacFileManager.preRegister(context);
    5.62 +        MyAttr.preRegister(context);
    5.63 +        tool = new ReusableJavaCompiler(context);
    5.64 +    }
    5.65 +
    5.66 +    public static void main(String... args) throws Throwable {
    5.67 +        new MissingLNTEntryForFinalizerTest().test();
    5.68 +    }
    5.69 +
    5.70 +    void test() throws Throwable {
    5.71 +        JavaSource source = new JavaSource("1");
    5.72 +        tool.clear();
    5.73 +        List<JavaFileObject> inputs = of(source);
    5.74 +        try {
    5.75 +            tool.compile(inputs);
    5.76 +        } catch (Throwable ex) {
    5.77 +            throw new AssertionError(ex);
    5.78 +        }
    5.79 +        File testClasses = new File(".");
    5.80 +        File file = new File(testClasses, "Test1.class");
    5.81 +        ClassFile classFile = ClassFile.read(file);
    5.82 +        for (Method m : classFile.methods) {
    5.83 +            if (classFile.constant_pool.getUTF8Value(m.name_index).equals("foo")) {
    5.84 +                Code_attribute code = (Code_attribute)m.attributes.get(Attribute.Code);
    5.85 +                LineNumberTable_attribute lnt = (LineNumberTable_attribute)code.attributes.get(Attribute.LineNumberTable);
    5.86 +                checkLNT(lnt, MyAttr.lineNumber);
    5.87 +            }
    5.88 +        }
    5.89 +    }
    5.90 +
    5.91 +    void checkLNT(LineNumberTable_attribute lnt, int lineToCheckFor) {
    5.92 +        for (LineNumberTable_attribute.Entry e: lnt.line_number_table) {
    5.93 +            if (e.line_number == lineToCheckFor) {
    5.94 +                return;
    5.95 +            }
    5.96 +        }
    5.97 +        throw new AssertionError("seek line number not found in the LNT for method foo()");
    5.98 +    }
    5.99 +
   5.100 +    class JavaSource extends SimpleJavaFileObject {
   5.101 +        String id;
   5.102 +        String template =
   5.103 +                "import java.util.*;\n" +
   5.104 +                "class Test#Id {\n" +
   5.105 +                "    void foo() {\n" +
   5.106 +                "        List<String> l = null;\n" +
   5.107 +                "        String first = null;\n" +
   5.108 +                "        try {\n" +
   5.109 +                "            first = l.get(0);\n" +
   5.110 +                "        } finally {\n" +
   5.111 +                "            if (first != null) {\n" +
   5.112 +                "                System.out.println(\"finalizer\");\n" +
   5.113 +                "            }\n" +
   5.114 +                "        }\n" +
   5.115 +                "    }\n" +
   5.116 +                "}";
   5.117 +
   5.118 +        JavaSource(String id) {
   5.119 +            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
   5.120 +            this.id = id;
   5.121 +        }
   5.122 +
   5.123 +        @Override
   5.124 +        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
   5.125 +            return template.replace("#Id", id);
   5.126 +        }
   5.127 +    }
   5.128 +
   5.129 +    /* this class has been set up to do not depend on a fixed line number, this Attr subclass will
   5.130 +     * look for 'break' or 'continue' statements in order to find the actual line number they occupy.
   5.131 +     * This way the test can find if that line number appears in the LNT generated for a given class.
   5.132 +     */
   5.133 +    static class MyAttr extends Attr {
   5.134 +        static int lineNumber;
   5.135 +
   5.136 +        static void preRegister(Context context) {
   5.137 +            context.put(attrKey, (com.sun.tools.javac.util.Context.Factory<Attr>) c -> new MyAttr(c));
   5.138 +        }
   5.139 +
   5.140 +        MyAttr(Context context) {
   5.141 +            super(context);
   5.142 +        }
   5.143 +
   5.144 +        @Override
   5.145 +        public com.sun.tools.javac.code.Type attribStat(JCTree tree, Env<AttrContext> env) {
   5.146 +            com.sun.tools.javac.code.Type result = super.attribStat(tree, env);
   5.147 +            if (tree.hasTag(TRY)) {
   5.148 +                JCTry tryTree = (JCTry)tree;
   5.149 +                lineNumber = env.toplevel.lineMap.getLineNumber(tryTree.finalizer.endpos);
   5.150 +            }
   5.151 +            return result;
   5.152 +        }
   5.153 +    }
   5.154 +
   5.155 +    static class ReusableJavaCompiler extends JavaCompiler {
   5.156 +        ReusableJavaCompiler(Context context) {
   5.157 +            super(context);
   5.158 +        }
   5.159 +
   5.160 +        protected void checkReusable() {
   5.161 +            // do nothing
   5.162 +        }
   5.163 +
   5.164 +        @Override
   5.165 +        public void close() {
   5.166 +            //do nothing
   5.167 +        }
   5.168 +
   5.169 +        void clear() {
   5.170 +            //do nothing
   5.171 +        }
   5.172 +    }
   5.173 +}
     6.1 --- a/test/tools/javac/linenumbers/FinallyLineNumberTest.java	Mon Jun 26 22:24:53 2017 -0700
     6.2 +++ b/test/tools/javac/linenumbers/FinallyLineNumberTest.java	Mon Jun 26 22:36:15 2017 -0700
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -36,7 +36,6 @@
    6.11  import com.sun.tools.classfile.LineNumberTable_attribute;
    6.12  import com.sun.tools.classfile.LineNumberTable_attribute.Entry;
    6.13  
    6.14 -import java.io.File;
    6.15  import java.io.IOException;
    6.16  
    6.17  public class FinallyLineNumberTest {
    6.18 @@ -46,13 +45,13 @@
    6.19          if (lines == null) {
    6.20              throw new Exception("finally line number table could not be loaded");
    6.21          }
    6.22 -        if (lines.length != 4) {
    6.23 +        if (lines.length != 5) {
    6.24              // Help debug
    6.25              System.err.println("LineTable error, got lines:");
    6.26              for (Entry e : lines) {
    6.27                  System.err.println(e.line_number);
    6.28              }
    6.29 -            throw new Exception("finally line number table incorrect: length=" + lines.length + " expected length=4");
    6.30 +            throw new Exception("finally line number table incorrect: length=" + lines.length + " expected length=5");
    6.31          }
    6.32  
    6.33          // return null line, for the load null operation
    6.34 @@ -71,11 +70,17 @@
    6.35              throw new Exception("finally line number table incorrect: got=" + current + " expected=" + first);
    6.36          }
    6.37  
    6.38 -        // finally line, for when exception is thrown
    6.39 +        // for when exception is thrown
    6.40          current = lines[3].line_number;
    6.41          if (current != first + 2) {
    6.42              throw new Exception("finally line number table incorrect: got=" + current + " expected=" + (first + 2));
    6.43          }
    6.44 +
    6.45 +        // the '}' closing the finally block
    6.46 +        current = lines[4].line_number;
    6.47 +        if (current != first + 3) {
    6.48 +            throw new Exception("finally line number table incorrect: got=" + current + " expected=" + (first + 3));
    6.49 +        }
    6.50      }
    6.51  
    6.52      static Entry[] findEntries() throws IOException, ConstantPoolException {

mercurial