1

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 ?

1
  • 4
    Why are you decompiling the class file? you can just get the real file from the src.zip that comes with your installation of Java. Commented Aug 17, 2011 at 12:49

3 Answers 3

1

You can attach the JDK sources in Eclipse: There should be a src.jar in your JDK installation. That way you can conveniently browse and debug them. Does not include some of the javax and com.sun classes, but it is a start.

Re-compiling and replacing JDK classes is very difficult.

Sign up to request clarification or add additional context in comments.

Comments

1

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

0

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

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.
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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.