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 5f3295c40a7..d0b90bea744 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 @@ -579,7 +579,11 @@ public JavaType.Primitive primitive(TypeTag tag) { .map(attr -> attr.getValue().toString()) .collect(Collectors.toList()); } else { - defaultValues = Collections.singletonList(methodSymbol.getDefaultValue().getValue().toString()); + try { + defaultValues = Collections.singletonList(methodSymbol.getDefaultValue().getValue().toString()); + } catch(UnsupportedOperationException e) { + // not all Attribute implementations define `getValue()` + } } } JavaType.Method method = new JavaType.Method( 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 b7c7ff483ff..7d5ad9da3f6 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 @@ -588,7 +588,11 @@ public JavaType.Primitive primitive(TypeTag tag) { .map(attr -> attr.getValue().toString()) .collect(Collectors.toList()); } else { - defaultValues = Collections.singletonList(methodSymbol.getDefaultValue().getValue().toString()); + try { + defaultValues = Collections.singletonList(methodSymbol.getDefaultValue().getValue().toString()); + } catch(UnsupportedOperationException e) { + // not all Attribute implementations define `getValue()` + } } } JavaType.Method method = new JavaType.Method( 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 f55a32132b8..10d9b202c6f 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 @@ -599,7 +599,11 @@ public JavaType.Primitive primitive(TypeTag tag) { .map(attr -> attr.getValue().toString()) .collect(Collectors.toList()); } else { - defaultValues = Collections.singletonList(methodSymbol.getDefaultValue().getValue().toString()); + try { + defaultValues = Collections.singletonList(methodSymbol.getDefaultValue().getValue().toString()); + } catch(UnsupportedOperationException e) { + // not all Attribute implementations define `getValue()` + } } } JavaType.Method method = new JavaType.Method( 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 0d8408dd026..988b0920206 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 @@ -581,7 +581,11 @@ public JavaType.Primitive primitive(TypeTag tag) { .map(attr -> attr.getValue().toString()) .collect(Collectors.toList()); } else { - defaultValues = Collections.singletonList(methodSymbol.getDefaultValue().getValue().toString()); + try { + defaultValues = Collections.singletonList(methodSymbol.getDefaultValue().getValue().toString()); + } catch(UnsupportedOperationException e) { + // not all Attribute implementations define `getValue()` + } } } JavaType.Method method = new JavaType.Method(