What kind of Java type is "[B"?
As the other answers state, that is a byte array.
If you want to get a string from a byte array, use the String constructor:
public void testCrypto()
{
session.beginTransaction();
// creates native SQL query
// uses native MySQL's MD5 crypto
final String pass = new String(session.createSQLQuery("SELECT MD5('somePass')")
.list().get(0));
session.getTransaction().commit();
}
It's the class name of byte[].class
. Try this:
System.out.println(byte[].class.getName());
Output (you guessed it):
[B
And if you want to access the readable name, use Class.getCanonicalName()
:
System.out.println(byte[].class.getCanonicalName());
Output:
byte[]
[B
is the encoded type name for a byte array (byte[]), which should normally only appear in type signature strings, as its not a valid type name.
That my friend is an array of bytes. In JNI, [B is used to describe an array ([
) of bytes (B
). An array of ints is [I
etc.
You can get a bit more information on field descriptors here:
JNI Types and Data Structures (Table 3-2 should be what you are looking for).