0

How do I find all deprecated (or any other annotation) methods in a java class using clojure?

(filter #(.isAnnotationPresent % java.lang.Deprecated) (.getMethods (type java.util.Date)))

returns empty list because (type java.util.Date) returns java.lang.Class. How do I get the correct class ?

1 Answer 1

2

Just leave out the type:

(filter #(.isAnnotationPresent % java.lang.Deprecated) 
         (.getMethods java.util.Date))

now if you want to do it from string, then just do

(filter #(.isAnnotationPresent % java.lang.Deprecated) 
         (.getMethods (Class/forName "java.util.Date"))

type is used to get the type of a value, now since symbols are resolved to actual classes, the type of the symbol is a java.lang.Class

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

Comments

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.