diff --git a/rewrite-groovy/src/main/java/org/openrewrite/groovy/GroovyTypeMapping.java b/rewrite-groovy/src/main/java/org/openrewrite/groovy/GroovyTypeMapping.java index 872160fa148..882943a2fb6 100644 --- a/rewrite-groovy/src/main/java/org/openrewrite/groovy/GroovyTypeMapping.java +++ b/rewrite-groovy/src/main/java/org/openrewrite/groovy/GroovyTypeMapping.java @@ -244,7 +244,7 @@ private JavaType genericType(GenericsType g, String signature) { } } - List thrownExceptions = null; + List thrownExceptions = null; if(node.getExceptions() != null) { for (ClassNode e : node.getExceptions()) { thrownExceptions = new ArrayList<>(node.getExceptions().length); diff --git a/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11TypeMapping.java b/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11TypeMapping.java index d0b90bea744..00ba35afbd5 100644 --- a/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11TypeMapping.java +++ b/rewrite-java-11/src/main/java/org/openrewrite/java/isolated/ReloadableJava11TypeMapping.java @@ -492,7 +492,7 @@ public JavaType.Primitive primitive(TypeTag tag) { JavaType returnType = null; List parameterTypes = null; - List exceptionTypes = null; + List exceptionTypes = null; if (selectType instanceof Type.MethodType) { Type.MethodType methodType = (Type.MethodType) selectType; @@ -512,20 +512,8 @@ public JavaType.Primitive primitive(TypeTag tag) { if (!methodType.thrown.isEmpty()) { exceptionTypes = new ArrayList<>(methodType.thrown.size()); for (Type exceptionType : methodType.thrown) { - JavaType.FullyQualified javaType = TypeUtils.asFullyQualified(type(exceptionType)); - if (javaType == null) { - // if the type cannot be resolved to a class (it might not be on the classpath, or it might have - // been mapped to cyclic) - if (exceptionType instanceof Type.ClassType) { - Symbol.ClassSymbol sym = (Symbol.ClassSymbol) exceptionType.tsym; - javaType = new JavaType.Class(null, Flag.Public.getBitMask(), sym.flatName().toString(), JavaType.Class.Kind.Class, - null, null, null, null, null, null, null); - } - } - if (javaType != null) { - // if the exception type is not resolved, it is not added to the list of exceptions - exceptionTypes.add(javaType); - } + JavaType javaType = type(exceptionType); + exceptionTypes.add(javaType); } } } else if (selectType instanceof Type.UnknownType) { @@ -603,7 +591,7 @@ public JavaType.Primitive primitive(TypeTag tag) { ((Type.ForAll) methodSymbol.type).qtype : methodSymbol.type; - List exceptionTypes = null; + List exceptionTypes = null; Type selectType = methodSymbol.type; if (selectType instanceof Type.ForAll) { @@ -615,20 +603,8 @@ public JavaType.Primitive primitive(TypeTag tag) { if (!methodType.thrown.isEmpty()) { exceptionTypes = new ArrayList<>(methodType.thrown.size()); for (Type exceptionType : methodType.thrown) { - JavaType.FullyQualified javaType = TypeUtils.asFullyQualified(type(exceptionType)); - if (javaType == null) { - // if the type cannot be resolved to a class (it might not be on the classpath, or it might have - // been mapped to cyclic) - if (exceptionType instanceof Type.ClassType) { - Symbol.ClassSymbol sym = (Symbol.ClassSymbol) exceptionType.tsym; - javaType = new JavaType.Class(null, Flag.Public.getBitMask(), sym.flatName().toString(), JavaType.Class.Kind.Class, - null, null, null, null, null, null, null); - } - } - if (javaType != null) { - // if the exception type is not resolved, it is not added to the list of exceptions - exceptionTypes.add(javaType); - } + JavaType javaType = type(exceptionType); + exceptionTypes.add(javaType); } } } diff --git a/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17TypeMapping.java b/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17TypeMapping.java index 7d5ad9da3f6..d3a1ee1c9a7 100644 --- a/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17TypeMapping.java +++ b/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17TypeMapping.java @@ -500,7 +500,7 @@ public JavaType.Primitive primitive(TypeTag tag) { JavaType returnType = null; List parameterTypes = null; - List exceptionTypes = null; + List exceptionTypes = null; if (selectType instanceof Type.MethodType) { Type.MethodType methodType = (Type.MethodType) selectType; @@ -520,20 +520,8 @@ public JavaType.Primitive primitive(TypeTag tag) { if (!methodType.thrown.isEmpty()) { exceptionTypes = new ArrayList<>(methodType.thrown.size()); for (Type exceptionType : methodType.thrown) { - JavaType.FullyQualified javaType = TypeUtils.asFullyQualified(type(exceptionType)); - if (javaType == null) { - // if the type cannot be resolved to a class (it might not be on the classpath, or it might have - // been mapped to cyclic) - if (exceptionType instanceof Type.ClassType) { - Symbol.ClassSymbol sym = (Symbol.ClassSymbol) exceptionType.tsym; - javaType = new JavaType.Class(null, Flag.Public.getBitMask(), sym.flatName().toString(), JavaType.Class.Kind.Class, - null, null, null, null, null, null, null); - } - } - if (javaType != null) { - // if the exception type is not resolved, it is not added to the list of exceptions - exceptionTypes.add(javaType); - } + JavaType javaType = type(exceptionType); + exceptionTypes.add(javaType); } } } else if (selectType instanceof Type.UnknownType) { @@ -590,7 +578,7 @@ public JavaType.Primitive primitive(TypeTag tag) { } else { try { defaultValues = Collections.singletonList(methodSymbol.getDefaultValue().getValue().toString()); - } catch(UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { // not all Attribute implementations define `getValue()` } } @@ -611,7 +599,7 @@ public JavaType.Primitive primitive(TypeTag tag) { ((Type.ForAll) methodSymbol.type).qtype : methodSymbol.type; - List exceptionTypes = null; + List exceptionTypes = null; Type selectType = methodSymbol.type; if (selectType instanceof Type.ForAll) { @@ -623,20 +611,8 @@ public JavaType.Primitive primitive(TypeTag tag) { if (!methodType.thrown.isEmpty()) { exceptionTypes = new ArrayList<>(methodType.thrown.size()); for (Type exceptionType : methodType.thrown) { - JavaType.FullyQualified javaType = TypeUtils.asFullyQualified(type(exceptionType)); - if (javaType == null) { - // if the type cannot be resolved to a class (it might not be on the classpath, or it might have - // been mapped to cyclic) - if (exceptionType instanceof Type.ClassType) { - Symbol.ClassSymbol sym = (Symbol.ClassSymbol) exceptionType.tsym; - javaType = new JavaType.Class(null, Flag.Public.getBitMask(), sym.flatName().toString(), JavaType.Class.Kind.Class, - null, null, null, null, null, null, null); - } - } - if (javaType != null) { - // if the exception type is not resolved, it is not added to the list of exceptions - exceptionTypes.add(javaType); - } + JavaType javaType = type(exceptionType); + exceptionTypes.add(javaType); } } } diff --git a/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21TypeMapping.java b/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21TypeMapping.java index 10d9b202c6f..bde8ecb7573 100644 --- a/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21TypeMapping.java +++ b/rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21TypeMapping.java @@ -511,7 +511,7 @@ public JavaType.Primitive primitive(TypeTag tag) { JavaType returnType = null; List parameterTypes = null; - List exceptionTypes = null; + List exceptionTypes = null; if (selectType instanceof Type.MethodType) { Type.MethodType methodType = (Type.MethodType) selectType; @@ -531,20 +531,8 @@ public JavaType.Primitive primitive(TypeTag tag) { if (!methodType.thrown.isEmpty()) { exceptionTypes = new ArrayList<>(methodType.thrown.size()); for (Type exceptionType : methodType.thrown) { - JavaType.FullyQualified javaType = TypeUtils.asFullyQualified(type(exceptionType)); - if (javaType == null) { - // if the type cannot be resolved to a class (it might not be on the classpath, or it might have - // been mapped to cyclic) - if (exceptionType instanceof Type.ClassType) { - Symbol.ClassSymbol sym = (Symbol.ClassSymbol) exceptionType.tsym; - javaType = new JavaType.Class(null, Flag.Public.getBitMask(), sym.flatName().toString(), JavaType.Class.Kind.Class, - null, null, null, null, null, null, null); - } - } - if (javaType != null) { - // if the exception type is not resolved, it is not added to the list of exceptions - exceptionTypes.add(javaType); - } + JavaType javaType = type(exceptionType); + exceptionTypes.add(javaType); } } } else if (selectType instanceof Type.UnknownType) { @@ -622,7 +610,7 @@ public JavaType.Primitive primitive(TypeTag tag) { ((Type.ForAll) methodSymbol.type).qtype : methodSymbol.type; - List exceptionTypes = null; + List exceptionTypes = null; Type selectType = methodSymbol.type; if (selectType instanceof Type.ForAll) { @@ -634,20 +622,8 @@ public JavaType.Primitive primitive(TypeTag tag) { if (!methodType.thrown.isEmpty()) { exceptionTypes = new ArrayList<>(methodType.thrown.size()); for (Type exceptionType : methodType.thrown) { - JavaType.FullyQualified javaType = TypeUtils.asFullyQualified(type(exceptionType)); - if (javaType == null) { - // if the type cannot be resolved to a class (it might not be on the classpath, or it might have - // been mapped to cyclic) - if (exceptionType instanceof Type.ClassType) { - Symbol.ClassSymbol sym = (Symbol.ClassSymbol) exceptionType.tsym; - javaType = new JavaType.Class(null, Flag.Public.getBitMask(), sym.flatName().toString(), JavaType.Class.Kind.Class, - null, null, null, null, null, null, null); - } - } - if (javaType != null) { - // if the exception type is not resolved, it is not added to the list of exceptions - exceptionTypes.add(javaType); - } + JavaType javaType = type(exceptionType); + exceptionTypes.add(javaType); } } } diff --git a/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8TypeMapping.java b/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8TypeMapping.java index 988b0920206..9beaba2727b 100644 --- a/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8TypeMapping.java +++ b/rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8TypeMapping.java @@ -494,7 +494,7 @@ public JavaType.Primitive primitive(TypeTag tag) { JavaType returnType = null; List parameterTypes = null; - List exceptionTypes = null; + List exceptionTypes = null; if (selectType instanceof Type.MethodType) { Type.MethodType methodType = (Type.MethodType) selectType; @@ -514,20 +514,8 @@ public JavaType.Primitive primitive(TypeTag tag) { if (!methodType.thrown.isEmpty()) { exceptionTypes = new ArrayList<>(methodType.thrown.size()); for (Type exceptionType : methodType.thrown) { - JavaType.FullyQualified javaType = TypeUtils.asFullyQualified(type(exceptionType)); - if (javaType == null) { - // if the type cannot be resolved to a class (it might not be on the classpath, or it might have - // been mapped to cyclic) - if (exceptionType instanceof Type.ClassType) { - Symbol.ClassSymbol sym = (Symbol.ClassSymbol) exceptionType.tsym; - javaType = new JavaType.Class(null, Flag.Public.getBitMask(), sym.flatName().toString(), JavaType.Class.Kind.Class, - null, null, null, null, null, null, null); - } - } - if (javaType != null) { - // if the exception type is not resolved, it is not added to the list of exceptions - exceptionTypes.add(javaType); - } + JavaType javaType = type(exceptionType); + exceptionTypes.add(javaType); } } } else if (selectType instanceof Type.UnknownType) { @@ -604,7 +592,7 @@ public JavaType.Primitive primitive(TypeTag tag) { ((Type.ForAll) methodSymbol.type).qtype : methodSymbol.type; - List exceptionTypes = null; + List exceptionTypes = null; Type selectType = methodSymbol.type; if (selectType instanceof Type.ForAll) { @@ -616,20 +604,8 @@ public JavaType.Primitive primitive(TypeTag tag) { if (!methodType.thrown.isEmpty()) { exceptionTypes = new ArrayList<>(methodType.thrown.size()); for (Type exceptionType : methodType.thrown) { - JavaType.FullyQualified javaType = TypeUtils.asFullyQualified(type(exceptionType)); - if (javaType == null) { - // if the type cannot be resolved to a class (it might not be on the classpath, or it might have - // been mapped to cyclic) - if (exceptionType instanceof Type.ClassType) { - Symbol.ClassSymbol sym = (Symbol.ClassSymbol) exceptionType.tsym; - javaType = new JavaType.Class(null, Flag.Public.getBitMask(), sym.flatName().toString(), JavaType.Class.Kind.Class, - null, null, null, null, null, null, null); - } - } - if (javaType != null) { - // if the exception type is not resolved, it is not added to the list of exceptions - exceptionTypes.add(javaType); - } + JavaType javaType = type(exceptionType); + exceptionTypes.add(javaType); } } } diff --git a/rewrite-java-test/src/main/java/org/openrewrite/java/JavaTypeMappingTest.java b/rewrite-java-test/src/main/java/org/openrewrite/java/JavaTypeMappingTest.java index 3783a9365cf..2eba1ba1e0f 100644 --- a/rewrite-java-test/src/main/java/org/openrewrite/java/JavaTypeMappingTest.java +++ b/rewrite-java-test/src/main/java/org/openrewrite/java/JavaTypeMappingTest.java @@ -53,6 +53,16 @@ default JavaType firstMethodParameter(String methodName) { return methodType(methodName).getParameterTypes().get(0); } + @Test + default void declaringTypeRefersToParameterizedClass() { + JavaType.FullyQualified declaringType = methodType("nameShadow").getDeclaringType(); + assertThat(declaringType.getTypeParameters()) + .describedAs("If it points to the raw class, " + + "method level name shadowing of generic " + + "type variables cannot be detected.") + .isNotEmpty(); + } + @Test default void javaLangObjectHasNoSupertype() { assertThat(goatType().getSupertype().getSupertype()).isNull(); @@ -242,4 +252,18 @@ default void recursiveIntersection() { JavaType.GenericTypeVariable clazz = TypeUtils.asGeneric(firstMethodParameter("recursiveIntersection")); assertThat(clazz.toString()).isEqualTo("Generic{U extends org.openrewrite.java.JavaTypeGoat$Extension & org.openrewrite.java.Intersection}"); } + + @Test + default void throwsGenericExceptions() { + JavaType.Method method = methodType("throwsGenericException"); + JavaType ex = method.getThrownExceptions().get(0); + + assertThat(ex).isInstanceOf(JavaType.GenericTypeVariable.class); + + JavaType.GenericTypeVariable generic = (JavaType.GenericTypeVariable) ex; + assertThat(generic.getName()).isEqualTo("T"); + assertThat(generic.getVariance()).isEqualTo(COVARIANT); + assertThat(TypeUtils.asFullyQualified(generic.getBounds().get(0)) + .getFullyQualifiedName()).isEqualTo("java.io.FileNotFoundException"); + } } diff --git a/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTemplateTest6Test.java b/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTemplateTest6Test.java index b6dd28e6764..4b8cdb9d754 100644 --- a/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTemplateTest6Test.java +++ b/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTemplateTest6Test.java @@ -255,7 +255,9 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex })).afterRecipe(run -> { J.CompilationUnit cu = (J.CompilationUnit) run.getChangeset().getAllResults().get(0).getAfter(); J.MethodDeclaration testMethodDecl = (J.MethodDeclaration) cu.getClasses().get(0).getBody().getStatements().get(0); - assertThat(testMethodDecl.getMethodType().getThrownExceptions().stream().map(JavaType.FullyQualified::getFullyQualifiedName)) + assertThat(testMethodDecl.getMethodType().getThrownExceptions().stream() + .map(JavaType.FullyQualified.class::cast) + .map(JavaType.FullyQualified::getFullyQualifiedName)) .containsExactly("java.lang.Exception"); }), java( diff --git a/rewrite-java/src/main/java/org/openrewrite/java/JavaTypeVisitor.java b/rewrite-java/src/main/java/org/openrewrite/java/JavaTypeVisitor.java index f06a3501ec4..29ddbf14870 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/JavaTypeVisitor.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/JavaTypeVisitor.java @@ -148,7 +148,7 @@ public JavaType visitMethod(JavaType.Method method, P p) { m = m.withDeclaringType((JavaType.FullyQualified) visit(m.getDeclaringType(), p)); m = m.withReturnType(visit(m.getReturnType(), p)); m = m.withParameterTypes(ListUtils.map(m.getParameterTypes(), pt -> visit(pt, p))); - m = m.withThrownExceptions(ListUtils.map(m.getThrownExceptions(), t -> (JavaType.FullyQualified) visit(t, p))); + m = m.withThrownExceptions(ListUtils.map(m.getThrownExceptions(), t -> visit(t, p))); m = m.withAnnotations(ListUtils.map(m.getAnnotations(), a -> (JavaType.FullyQualified) visit(a, p))); return m; } diff --git a/rewrite-java/src/main/java/org/openrewrite/java/UnsafeJavaTypeVisitor.java b/rewrite-java/src/main/java/org/openrewrite/java/UnsafeJavaTypeVisitor.java index 8eee53b3624..a28e6547241 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/UnsafeJavaTypeVisitor.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/UnsafeJavaTypeVisitor.java @@ -69,7 +69,7 @@ public JavaType visitMethod(JavaType.Method method, P p) { (JavaType.FullyQualified) visit(method.getDeclaringType(), p), visit(method.getReturnType(), p), mapInPlace(method.getParameterTypes().toArray(EMPTY_JAVA_TYPE_ARRAY), pt -> visit(pt, p)), - mapInPlace(method.getThrownExceptions().toArray(EMPTY_FULLY_QUALIFIED_ARRAY), t -> (JavaType.FullyQualified) visit(t, p)), + mapInPlace(method.getThrownExceptions().toArray(EMPTY_JAVA_TYPE_ARRAY), t -> visit(t, p)), mapInPlace(method.getAnnotations().toArray(EMPTY_FULLY_QUALIFIED_ARRAY), a -> (JavaType.FullyQualified) visit(a, p)) ); } diff --git a/rewrite-java/src/main/java/org/openrewrite/java/internal/JavaReflectionTypeMapping.java b/rewrite-java/src/main/java/org/openrewrite/java/internal/JavaReflectionTypeMapping.java index 440217560b4..ef7ee8de348 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/internal/JavaReflectionTypeMapping.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/internal/JavaReflectionTypeMapping.java @@ -345,7 +345,7 @@ private JavaType.Method method(Constructor method, JavaType.FullyQualified de ); typeCache.put(signature, mappedMethod); - List thrownExceptions = null; + List thrownExceptions = null; if (method.getExceptionTypes().length > 0) { thrownExceptions = new ArrayList<>(method.getExceptionTypes().length); for (Class e : method.getExceptionTypes()) { @@ -451,12 +451,11 @@ private JavaType.Method method(Method method, JavaType.FullyQualified declaringT ); typeCache.put(signature, mappedMethod); - List thrownExceptions = null; + List thrownExceptions = null; if (method.getExceptionTypes().length > 0) { thrownExceptions = new ArrayList<>(method.getExceptionTypes().length); - for (Class e : method.getExceptionTypes()) { - JavaType.FullyQualified fullyQualified = (JavaType.FullyQualified) type(e); - thrownExceptions.add(fullyQualified); + for (Type e : method.getGenericExceptionTypes()) { + thrownExceptions.add(type(e)); } } diff --git a/rewrite-java/src/main/java/org/openrewrite/java/internal/template/JavaTemplateJavaExtension.java b/rewrite-java/src/main/java/org/openrewrite/java/internal/template/JavaTemplateJavaExtension.java index cfd9b9ea548..476aeaa2e03 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/internal/template/JavaTemplateJavaExtension.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/internal/template/JavaTemplateJavaExtension.java @@ -354,11 +354,11 @@ public J visitMethodDeclaration(J.MethodDeclaration method, Integer p) { // Update method type information to reflect the new checked exceptions JavaType.Method type = m.getMethodType(); if (type != null) { - List newThrows = new ArrayList<>(); + List newThrows = new ArrayList<>(); List throws_ = (m.getThrows() == null) ? emptyList() : m.getThrows(); for (NameTree t : throws_) { J.Identifier exceptionIdent = (J.Identifier) t; - newThrows.add((JavaType.FullyQualified) exceptionIdent.getType()); + newThrows.add(exceptionIdent.getType()); } type = type.withThrownExceptions(newThrows); } diff --git a/rewrite-java/src/main/java/org/openrewrite/java/tree/JavaType.java b/rewrite-java/src/main/java/org/openrewrite/java/tree/JavaType.java index 171a6a2198e..95d936ff2df 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/tree/JavaType.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/tree/JavaType.java @@ -323,16 +323,16 @@ public String getPackageName() { public boolean isAssignableTo(String fullyQualifiedName) { return TypeUtils.fullyQualifiedNamesAreEqual(getFullyQualifiedName(), fullyQualifiedName) || - getInterfaces().stream().anyMatch(anInterface -> anInterface.isAssignableTo(fullyQualifiedName)) || - (getSupertype() != null && getSupertype().isAssignableTo(fullyQualifiedName)); + getInterfaces().stream().anyMatch(anInterface -> anInterface.isAssignableTo(fullyQualifiedName)) || + (getSupertype() != null && getSupertype().isAssignableTo(fullyQualifiedName)); } public boolean isAssignableFrom(@Nullable JavaType type) { if (type instanceof FullyQualified) { FullyQualified clazz = (FullyQualified) type; return TypeUtils.fullyQualifiedNamesAreEqual(getFullyQualifiedName(), clazz.getFullyQualifiedName()) || - isAssignableFrom(clazz.getSupertype()) || - clazz.getInterfaces().stream().anyMatch(this::isAssignableFrom); + isAssignableFrom(clazz.getSupertype()) || + clazz.getInterfaces().stream().anyMatch(this::isAssignableFrom); } else if (type instanceof GenericTypeVariable) { GenericTypeVariable generic = (GenericTypeVariable) type; for (JavaType bound : generic.getBounds()) { @@ -576,7 +576,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; Class aClass = (Class) o; return TypeUtils.fullyQualifiedNamesAreEqual(fullyQualifiedName, aClass.fullyQualifiedName) && - (typeParameters == null && aClass.typeParameters == null || typeParameters != null && Arrays.equals(typeParameters, aClass.typeParameters)); + (typeParameters == null && aClass.typeParameters == null || typeParameters != null && Arrays.equals(typeParameters, aClass.typeParameters)); } @Override @@ -853,7 +853,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; GenericTypeVariable that = (GenericTypeVariable) o; return name.equals(that.name) && variance == that.variance && - (variance == Variance.INVARIANT && bounds == null && that.bounds == null || bounds != null && Arrays.equals(bounds, that.bounds)); + (variance == Variance.INVARIANT && bounds == null && that.bounds == null || bounds != null && Arrays.equals(bounds, that.bounds)); } @Override @@ -1106,7 +1106,7 @@ class Method implements JavaType { JavaType @Nullable [] parameterTypes; @NonFinal - FullyQualified @Nullable [] thrownExceptions; + JavaType @Nullable [] thrownExceptions; @NonFinal FullyQualified @Nullable [] annotations; @@ -1118,7 +1118,7 @@ class Method implements JavaType { public Method(@Nullable Integer managedReference, long flagsBitMap, @Nullable FullyQualified declaringType, String name, @Nullable JavaType returnType, @Nullable List parameterNames, - @Nullable List parameterTypes, @Nullable List thrownExceptions, + @Nullable List parameterTypes, @Nullable List thrownExceptions, @Nullable List annotations) { this(managedReference, flagsBitMap, declaringType, name, returnType, parameterNames, parameterTypes, thrownExceptions, annotations, null); @@ -1126,7 +1126,7 @@ public Method(@Nullable Integer managedReference, long flagsBitMap, @Nullable Fu public Method(@Nullable Integer managedReference, long flagsBitMap, @Nullable FullyQualified declaringType, String name, @Nullable JavaType returnType, @Nullable List parameterNames, - @Nullable List parameterTypes, @Nullable List thrownExceptions, + @Nullable List parameterTypes, @Nullable List thrownExceptions, @Nullable List annotations, @Nullable List defaultValue) { this( managedReference, @@ -1144,7 +1144,7 @@ public Method(@Nullable Integer managedReference, long flagsBitMap, @Nullable Fu public Method(@Nullable Integer managedReference, long flagsBitMap, @Nullable FullyQualified declaringType, String name, @Nullable JavaType returnType, String @Nullable [] parameterNames, - JavaType @Nullable [] parameterTypes, FullyQualified @Nullable [] thrownExceptions, + JavaType @Nullable [] parameterTypes, JavaType @Nullable [] thrownExceptions, FullyQualified @Nullable [] annotations, @Nullable List defaultValue) { this.managedReference = managedReference; this.flagsBitMap = flagsBitMap & Flag.VALID_FLAGS; @@ -1171,12 +1171,12 @@ public Method unsafeSetManagedReference(Integer id) { public Method unsafeSet(@Nullable FullyQualified declaringType, @Nullable JavaType returnType, @Nullable List parameterTypes, - @Nullable List thrownExceptions, + @Nullable List thrownExceptions, @Nullable List annotations) { this.declaringType = unknownIfNull(declaringType); this.returnType = unknownIfNull(returnType); this.parameterTypes = arrayOrNullIfEmpty(parameterTypes, EMPTY_JAVA_TYPE_ARRAY); - this.thrownExceptions = arrayOrNullIfEmpty(thrownExceptions, EMPTY_FULLY_QUALIFIED_ARRAY); + this.thrownExceptions = arrayOrNullIfEmpty(thrownExceptions, EMPTY_JAVA_TYPE_ARRAY); this.annotations = arrayOrNullIfEmpty(annotations, EMPTY_FULLY_QUALIFIED_ARRAY); return this; } @@ -1184,7 +1184,7 @@ public Method unsafeSet(@Nullable FullyQualified declaringType, public Method unsafeSet(@Nullable FullyQualified declaringType, @Nullable JavaType returnType, JavaType @Nullable [] parameterTypes, - FullyQualified @Nullable [] thrownExceptions, + JavaType @Nullable [] thrownExceptions, FullyQualified @Nullable [] annotations) { this.declaringType = unknownIfNull(declaringType); this.returnType = unknownIfNull(returnType); @@ -1312,12 +1312,12 @@ public Method withParameterTypes(@Nullable List parameterTypes) { this.parameterNames, parameterTypesArray, this.thrownExceptions, this.annotations, this.defaultValue); } - public List getThrownExceptions() { + public List getThrownExceptions() { return thrownExceptions == null ? emptyList() : Arrays.asList(thrownExceptions); } - public Method withThrownExceptions(@Nullable List thrownExceptions) { - FullyQualified[] thrownExceptionsArray = arrayOrNullIfEmpty(thrownExceptions, EMPTY_FULLY_QUALIFIED_ARRAY); + public Method withThrownExceptions(@Nullable List thrownExceptions) { + JavaType[] thrownExceptionsArray = arrayOrNullIfEmpty(thrownExceptions, EMPTY_JAVA_TYPE_ARRAY); if (Arrays.equals(thrownExceptionsArray, this.thrownExceptions)) { return this; } @@ -1356,9 +1356,9 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; Method method = (Method) o; return Objects.equals(declaringType, method.declaringType) && - name.equals(method.name) && - Objects.equals(returnType, method.returnType) && - Arrays.equals(parameterTypes, method.parameterTypes); + name.equals(method.name) && + Objects.equals(returnType, method.returnType) && + Arrays.equals(parameterTypes, method.parameterTypes); } @Override