Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impossible cast in spi/db/TypeInfo.java #597

Closed
Tomas-Kraus opened this issue Jun 2, 2022 · 0 comments · Fixed by #614
Closed

impossible cast in spi/db/TypeInfo.java #597

Tomas-Kraus opened this issue Jun 2, 2022 · 0 comments · Fixed by #614

Comments

@Tomas-Kraus
Copy link
Member

Previously tracked via: https://bugs.openjdk.java.net/browse/JDK-8182558

My colleagues Marsela Sulku and Maria Sam are working on detecting errors with new errorprone checks and have found one impossible cast in openjdk:

Method jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/spi/db/TypeInfo.java#getItemType contains
if (type instanceof Class && ((Class)type).isArray() && !byte[].class.equals(type)) {
Type componentType = ((Class)type).getComponentType();
Type genericComponentType = null;
if (genericType!= null && genericType instanceof GenericArrayType) {
GenericArrayType arrayType = (GenericArrayType) type;
genericComponentType = arrayType.getGenericComponentType();
componentType = arrayType.getGenericComponentType();
}

The cast to (GenericArrayType) cannot succeed because type is already a Class. (Probably this code has never worked or been tested)

It's very likely that this is a typo for:

--- a/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/spi/db/TypeInfo.java
+++ b/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/spi/db/TypeInfo.java
@@ -177,7 +177,7 @@
Type componentType = ((Class)type).getComponentType();
Type genericComponentType = null;
if (genericType!= null && genericType instanceof GenericArrayType) {

  • GenericArrayType arrayType = (GenericArrayType) type;
  • GenericArrayType arrayType = (GenericArrayType) genericType;
    genericComponentType = arrayType.getGenericComponentType();
    componentType = arrayType.getGenericComponentType();
    }

Source: javaee/metro-jax-ws#1223
Author: LanceAndersen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant