changeset 3657:c313dc636115

8163027: AssertionError while compiling a program that uses try with resources. Reviewed-by: vromero
author sadayapalam
date Wed, 21 Sep 2016 05:26:26 +0530
parents 238ab021ff4d
children 7f3b6ce62ea7
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java test/tools/javac/TryWithResources/TwrAndTypeVariables2Test.java
diffstat 3 files changed, 49 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Sep 20 12:12:18 2016 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Sep 21 05:26:26 2016 +0530
@@ -1451,7 +1451,7 @@
             try {
                 close = rs.resolveQualifiedMethod(pos,
                         env,
-                        resource,
+                        types.skipTypeVars(resource, false),
                         names.close,
                         List.<Type>nil(),
                         List.<Type>nil());
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Tue Sep 20 12:12:18 2016 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Wed Sep 21 05:26:26 2016 +0530
@@ -1098,7 +1098,7 @@
                     if (types.asSuper(sup, syms.autoCloseableType.tsym) != null) {
                         Symbol closeMethod = rs.resolveQualifiedMethod(tree,
                                 attrEnv,
-                                sup,
+                                types.skipTypeVars(sup, false),
                                 names.close,
                                 List.<Type>nil(),
                                 List.<Type>nil());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/TryWithResources/TwrAndTypeVariables2Test.java	Wed Sep 21 05:26:26 2016 +0530
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8163027
+ * @summary AssertionError while compiling program that uses try with resources
+ * @compile TwrAndTypeVariables2Test.java
+ */
+
+abstract class TwrAndTypeVariables2Test_01 implements AutoCloseable {
+    @Override
+    public void close() {
+    }
+    public boolean close(long timeout) {
+        return true;
+    }
+}
+
+public abstract class TwrAndTypeVariables2Test<C extends TwrAndTypeVariables2Test_01> {
+    abstract C newCloseable();
+
+    void m() throws Exception{
+        try(C p= newCloseable()){
+        }
+    }
+}