Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: proper way to get the class of a primitive array for reflection

I'm trying to use reflection to call a method that takes in a byte array.

I'm starting off doing:

Class myClass = anObject.getClass();
Class[] parameterTypes =
 {byte[].getClass();};

But that doesn't work (class expected, } expected) on the byte[] line. Anyone know what I should do? Cast to an Object and declare that the method takes an Object?

like image 769
jbu Avatar asked Jul 09 '09 22:07

jbu


1 Answers

Try this:

Class[] parameterTypes = new Class[] {byte[].class};
like image 66
ChssPly76 Avatar answered Sep 19 '22 00:09

ChssPly76