Resolve class name from bytecode

后端 未结 5 595
陌清茗
陌清茗 2021-01-14 23:46

Is it possible to dig up a classes name from bytecode which is formed from the class\' source code?

The situation is this: I get a classes bytecode remotely from so

5条回答
  •  情歌与酒
    2021-01-15 00:07

    Just for completeness, in cases where the use of ASM5 library is acceptable, the following call could be used to obtain the class name from its byte representation.

    public String readClassName(final byte[] typeAsByte) {
        return new ClassReader(typeAsByte).getClassName().replace("/", ".");
    }
    

提交回复
热议问题