Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
/ jdk21 Public archive

Commit

Permalink
8312814: Compiler crash when template processor type is a captured wi…
Browse files Browse the repository at this point in the history
…ldcard

Reviewed-by: jjg, vromero
Backport-of: f14245b3880ff735ae231b4c7d2c6b6907c5f7d4
  • Loading branch information
Jim Laskey committed Aug 9, 2023
1 parent 01a5df6 commit a073530
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ else if (tree.sym.kind == VAR) {
}

public void visitStringTemplate(JCStringTemplate tree) {
tree.processor = translate(tree.processor, erasure(tree.processor.type));
tree.expressions = tree.expressions.stream()
.map(e -> translate(e, erasure(e.type))).collect(List.collector());
tree.type = erasure(tree.type);
Expand Down
39 changes: 39 additions & 0 deletions test/langtools/tools/javac/template/T8312814.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2023, 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 T8312814
* @summary Verify proper behavior of TransType w.r.t. templated Strings
* @enablePreview
* @compile T8312814.java
*/


import java.util.List;

public class T8312814 {
void x(List<? extends StringTemplate.Processor<String, RuntimeException>> list) {
list.get(0)."";
}
}

1 comment on commit a073530

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.