http://qs321.pair.com?node_id=172272


in reply to Java Decompilation in Perl

...actually the answer may be easier than this.

Decompilers are fine, and without this being legal advice, I find (as a human) nothing provocative in digging through class files to expose the data that is being presented. If your purpose is to access the data (which they have given you relative to a contractual obligation), the means by which you gain access to the data are probably your own business.

"But," (as Vincent Vega said,) "that don't matter, cause check this out..."

Java classes expose their details through a process known as reflection and introspection. Even if your vendor has obfuscated the class files, the encapsulated data you are trying to gather is probably quite accessible through this mechanism.

The purpose of reflection is to allow java classes to be used in environments other than more java code. What that means is that we want to be able to manipulate java objects from scripting environments, from tool builders and from other places that don't have us writing more code to use our object. (In fact, a lot of the java "instant application makers" take advantage of this fact.)

What it means to us here is that we can use the reflection API to query the objects about their characteristics, even if we don't have the original source. This is how decompilers do their thing.

It sounds like you are trying to get at the data held in the various objects with your own code, and again, I don't see any "reverse engineering" implications in this, any more than if you wrote some code to extract the plain text content of a PDF file or a Word document. (But you should ask an attorney to be safe.)

What I can't tell you is how to write code in Perl that will allow you to introspect the class files. (I would do that work in Java myself.) I believe (from a glimpse of related discussions) that this may be possible. It certainly is relatively easy to write a little Java that will extract the information you want.

And it may prove to be instructive as you contemplate how you might do it in Perl. If you take a look at the details of object introspection in Java and discover how you would do this, you may be able to relate that to something that you would do in Perl to accomplish the same effect.

Thanks for your questions BTW, this will stimulate me to engage in the long overdue reading about the current state of interfacing Perl with Java.

---v