]> source.dussan.org Git - aspectj.git/commitdiff
UnresolvedType: fix JVM signature conversion
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Tue, 17 Jan 2023 13:49:54 +0000 (14:49 +0100)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Fri, 12 Apr 2024 12:19:06 +0000 (14:19 +0200)
Fixes #211. Previously, '?' was not converted to '*' in
UnresolvedType.nameToSignature, but kept as-is. That is why - falsely -
it was necessary to handle the '?' case in UnresolvedType.forSignature
at all, reading this kind of bogus signature and creating a type for it
in TypeFactory.createTypeFromSignature. This, ironically, led to correct
JVM generic type signatures containing '*' not being handled at all.

The conversion should now work correctly both ways.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
org.aspectj.matcher/src/main/java/org/aspectj/weaver/TypeFactory.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/UnresolvedType.java

index 3d4c0d46dbbdde6e2b3837e03f580963b2086c56..c5326b80e945dbb702ffee419e046525ee21c648 100644 (file)
@@ -152,7 +152,7 @@ public class TypeFactory {
                                return new UnresolvedType(signature, signatureErasure, typeParams);
                        }
                        // can't replace above with convertSigToType - leads to stackoverflow
-               } else if ((firstChar == '?' || firstChar == '*') && signature.length()==1) {
+               } else if (firstChar == '*' && signature.length()==1) {
                        return WildcardedUnresolvedType.QUESTIONMARK;
                } else if (firstChar == '+') {
                        // ? extends ...
index d0611868fde45f403da86b78b127ac394643f178..37780023c56465bfc7e1c3b8a95c0a4c5950733f 100644 (file)
@@ -418,7 +418,7 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement {
                        return TypeFactory.createTypeFromSignature(signature);
                case '-':
                        return TypeFactory.createTypeFromSignature(signature);
-               case '?':
+               case '*':
                        return TypeFactory.createTypeFromSignature(signature);
                case 'T':
                        return TypeFactory.createTypeFromSignature(signature);
@@ -746,7 +746,7 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement {
                                return "C";
                        }
                        if (name.equals("?")) {
-                               return name;
+                               return "*";
                        }
                }
                if (len == 0) {