ammachado commented on code in PR #28651:
URL: https://github.com/apache/camel/pull/28651#discussion_r4408705856
##########
core/camel-base/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java:
##########
@@ -30,6 +30,14 @@
*/
public class EnumTypeConverter extends TypeConverterSupport implements
CamelContextAware {
+ // getEnumConstants returns a new copy of the constants on every call
+ private static final ClassValue<Enum<?>[]> ENUM_CONSTANTS = new
ClassValue<>() {
+ @Override
+ protected Enum<?>[] computeValue(Class<?> type) {
+ return (Enum<?>[]) type.getEnumConstants();
+ }
Review Comment:
This cast does not produce an unchecked warning, so the annotation would not
suppress anything. `Enum<?>[]` is a reifiable type (an unbounded wildcard), so
the cast from `getEnumConstants()` is checked at runtime. The removed
annotation was for the old cast `(Class<Enum<?>>) type`, which is not
reifiable. Compiling both with `javac -Xlint:all` (JDK 25) reports only the old
one:
```
warning: [unchecked] unchecked cast
static Object old(Class<?> type) { return (Class<Enum<?>>) type; }
required: Class<Enum<?>>
found: Class<CAP#1>
```
and nothing for `return (Enum<?>[]) type.getEnumConstants();`. So I left it
as is.
_Claude Code on behalf of Adriano Machado (@ammachado)_
_This was generated by an AI agent and may contain inaccuracies. Please
verify before relying on it._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]