I am using the java.security package to verify some digital signatures. Basically I am calling the verify method of the Signature class. I want to understand the internal logic of the verify method. Therefore I have extracted the Signature.class from the rt.jar, decompiled it and then put it in proper package structure in my eclipse project. However, it is not compiling and complaining about "cannot resolve" errors. I am fixing them one by one by decompiling other inbuilt java classes but this seems to be endless. Is this the correct approach to debug in-built java api's or is there some other recommended approach ?
3 Answers
Did you see the java.security.debug flag?
... if you wish to monitor security access, you can set the java.security.debug System property. To see a list of all debugging options, use the help setting, the all setting allows you to see everything:
java -Djava.security.debug=help foo
all turn on all debugging
access print all checkPermission results
jar jar verification
policy loading and granting
scl permissions SecureClassLoader assigns
The following can be used with access:
stack include stack trace
domain dumps all domains in context
failure before throwing exception, dump stack
and domain that didn't have permission
Comments
Is this the correct approach to debug in-built java api's or is there some other recommended approach ?
I'd added source of the API using attach source into the eclipse and use the default debugger to debug the app
3 Comments
user496934
This is exactly what I'm doing..I am decompiling and adding the source code of that API in my project. But it is giving other errors and when I fix those it is still giving new ones. So I was asking if there is any alternative approach.
Jigar Joshi
No this isn't what you are doing. I am asking to take the source of jdk from src.zip as commented above without decompiling it. attach it to eclipse add the break point and start the project to debug
atrain
Jigar is correct. If you are using open source projects, just download the source to a location on your local box. Attach the source to the JARs inside Eclipse, and you can then step through code to see what is actually going on. I've done this to great success with Hibernate.