Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a BCEL JavaClass object from arbitrary .class file

I'm playing around with BCEL. I'm not using it to generate bytecode, but instead I'm trying to inspect the structure of existing compiled classes.

I need to be able to point to an arbitrary .class file anywhere on my hard drive and load a JavaClass object based on that. Ideally I'd like to avoid having to add the given class to my classpath.

like image 476
Mike Deck Avatar asked Dec 07 '22 09:12

Mike Deck


1 Answers

The straightforward way is to create a ClassParser with the file name and call parse(). Alternatively you can use SyntheticRepository and supply a classpath (that is not your classpath, IYSWIM).

like image 81
Tom Hawtin - tackline Avatar answered Dec 09 '22 23:12

Tom Hawtin - tackline