views:

424

answers:

1

I have a Java production system with IBM JVM running on Linux.
A customer reports the following exception printed to the log:
java.lang.ClassCastException: [B incompatible with java.lang.String
When trying to cast the individual attributes returned from: javax.naming.directory.InitialDirContext(...)
From this exception I can't figure out what is the type that could not be converted to String. What is "B"?

Normally, I know that a class cast error message should look something like this:
java.lang.ClassCastException: java.lang.Integer incompatible with java.lang.String
But as you can see it's not the case in the first printout.
I thought that there might be an actual class named B, but I could find one under javax.naming...
Is there a name obfuscation going on here?
I now plan to send the customer a version that will print out the class of the instance before trying to cast to string:
i.getClass().getCanonicalName()
But these ping pongs take a week, if you have an idea and could help me out before that, that would be super!

+3  A: 

[B is an array of byte (i.e. a byte[]). Note that the [ is a part of the name.

See the API for Class.getName() for the rules on how those names are produced.

Joachim Sauer