From be820fb0bb1ef2993686df891c6a53aaefd3756e Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Fri, 23 Aug 2024 22:24:10 +0200 Subject: [PATCH] Fix `ReloadableJavaXyTypeSignatureBuilder` The change in the recent PR #4427 was a bit overly cautious. We should be able to use `?` as the name in the signature for all captured types. --- .../isolated/ReloadableJava11TypeSignatureBuilder.java | 8 +------- .../isolated/ReloadableJava17TypeSignatureBuilder.java | 8 +------- .../isolated/ReloadableJava21TypeSignatureBuilder.java | 8 +------- .../java/ReloadableJava8TypeSignatureBuilder.java | 8 +------- 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11TypeSignatureBuilder.java b/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11TypeSignatureBuilder.java index ad236877d51..8dc3170518e 100644 --- a/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11TypeSignatureBuilder.java +++ b/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11TypeSignatureBuilder.java @@ -15,7 +15,6 @@ */ package org.openrewrite.java.isolated; -import com.sun.tools.javac.code.BoundKind; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.TypeTag; @@ -141,12 +140,7 @@ public String classSignature(Object type) { @Override public String genericSignature(Object type) { Type.TypeVar generic = (Type.TypeVar) type; - String name; - if (generic instanceof Type.CapturedType && ((Type.CapturedType) generic).wildcard.kind == BoundKind.UNBOUND) { - name = "?"; - } else { - name = generic.tsym.name.toString(); - } + String name = generic instanceof Type.CapturedType ? "?" : generic.tsym.name.toString(); if (typeVariableNameStack == null) { typeVariableNameStack = new HashSet<>(); diff --git a/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17TypeSignatureBuilder.java b/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17TypeSignatureBuilder.java index 4e232e1856e..06610776d12 100644 --- a/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17TypeSignatureBuilder.java +++ b/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17TypeSignatureBuilder.java @@ -15,7 +15,6 @@ */ package org.openrewrite.java.isolated; -import com.sun.tools.javac.code.BoundKind; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.TypeTag; @@ -141,12 +140,7 @@ public String classSignature(Object type) { @Override public String genericSignature(Object type) { Type.TypeVar generic = (Type.TypeVar) type; - String name; - if (generic instanceof Type.CapturedType && ((Type.CapturedType) generic).wildcard.kind == BoundKind.UNBOUND) { - name = "?"; - } else { - name = generic.tsym.name.toString(); - } + String name = generic instanceof Type.CapturedType ? "?" : generic.tsym.name.toString(); if (typeVariableNameStack == null) { typeVariableNameStack = new HashSet<>(); diff --git a/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21TypeSignatureBuilder.java b/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21TypeSignatureBuilder.java index 6ae0e842497..77802291ed9 100644 --- a/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21TypeSignatureBuilder.java +++ b/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21TypeSignatureBuilder.java @@ -15,7 +15,6 @@ */ package org.openrewrite.java.isolated; -import com.sun.tools.javac.code.BoundKind; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.TypeTag; @@ -141,12 +140,7 @@ public String classSignature(Object type) { @Override public String genericSignature(Object type) { Type.TypeVar generic = (Type.TypeVar) type; - String name; - if (generic instanceof Type.CapturedType && ((Type.CapturedType) generic).wildcard.kind == BoundKind.UNBOUND) { - name = "?"; - } else { - name = generic.tsym.name.toString(); - } + String name = generic instanceof Type.CapturedType ? "?" : generic.tsym.name.toString(); if (typeVariableNameStack == null) { typeVariableNameStack = new HashSet<>(); diff --git a/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8TypeSignatureBuilder.java b/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8TypeSignatureBuilder.java index dc92ba8f0d3..3fa76d17f42 100644 --- a/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8TypeSignatureBuilder.java +++ b/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8TypeSignatureBuilder.java @@ -15,7 +15,6 @@ */ package org.openrewrite.java; -import com.sun.tools.javac.code.BoundKind; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.TypeTag; @@ -140,12 +139,7 @@ public String classSignature(Object type) { @Override public String genericSignature(Object type) { Type.TypeVar generic = (Type.TypeVar) type; - String name; - if (generic instanceof Type.CapturedType && ((Type.CapturedType) generic).wildcard.kind == BoundKind.UNBOUND) { - name = "?"; - } else { - name = generic.tsym.name.toString(); - } + String name = generic instanceof Type.CapturedType ? "?" : generic.tsym.name.toString(); if (typeVariableNameStack == null) { typeVariableNameStack = new HashSet<>();