Converting a given class (let's say, java.lang.Object) to a byte array. Is it possible?

后端 未结 4 1403
栀梦
栀梦 2021-01-13 17:13

Given that class loaders accept to take as input a byte array of a given class, returning a Class, I wonder whether it is possible to do the reverse, t

4条回答
  •  清歌不尽
    2021-01-13 17:33

    You can use ClassLoader.getResourceAsInputStream() however it is not guaranteed this will be the same bytes as that which was loaded. I don't believe the actual bytes loaded are stored anywhere.

提交回复
热议问题