Skip to content

Commit de61328

Browse files
author
Vicente Romero
committed
8225559: assertion error at TransTypes.visitApply
Reviewed-by: sadayapalam, jlahoda
1 parent 82bfc5d commit de61328

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public JCTree visitNewClass(NewClassTree node, Void p) {
157157
JCExpression clazz = copy(t.clazz, p);
158158
List<JCExpression> args = copy(t.args, p);
159159
JCClassDecl def = null;
160-
return make.at(t.pos).SpeculativeNewClass(encl, typeargs, clazz, args, def, t.def != null);
160+
return make.at(t.pos).SpeculativeNewClass(encl, typeargs, clazz, args, def, t.def != null || t.classDeclRemoved());
161161
} else {
162162
return super.visitNewClass(node, p);
163163
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8225559
27+
* @summary assertion error at TransTypes.visitApply
28+
* @compile ProtectedConstructorTest.java
29+
*/
30+
31+
import pkg.Bar;
32+
import java.util.List;
33+
import java.util.concurrent.CompletableFuture;
34+
import java.util.function.Supplier;
35+
36+
class ProtectedConstructorTest {
37+
public void foo() {
38+
supply(getSupplier(new Bar<>(){}));
39+
CompletableFuture<List<String>> completableFuture = getCompletableFuture(getSupplier(new Bar<>(){}));
40+
completableFuture = getCompletableFuture(() -> getList(null, new Bar<>() {}));
41+
}
42+
43+
static <U> Supplier<U> getSupplier(Bar<U> t) {
44+
return null;
45+
}
46+
47+
static <U> void supply(Supplier<U> supplier) {}
48+
static <U> CompletableFuture<U> getCompletableFuture(Supplier<U> supplier) { return null; }
49+
<T> List<T> getList(final Supplier<List<T>> supplier, Bar<T> t) { return null; }
50+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
package pkg;
25+
26+
public abstract class Bar<T> {
27+
protected Bar() {}
28+
protected Bar(Class<?> c) {}
29+
}

0 commit comments

Comments
 (0)