3

Possible Duplicate:
How to make eclipse “File Search” to also search inside source jars containig some text?

I have an Eclipse Java project using Maven-managed libraries. Inside those libraries, there must be a string variable/field with the value (not name) form-login.

Eclipse provides the "Java Search" functionality. It allows for searching inside application libraries (including Maven dependencies), but only for the name of a variable, not its value.

The "File Search" functionality on the other hand doesn't provide searching inside application libraries.

How can I find some string (or at least the value of some variable) in my application's used libraries?

Hacks welcome!

Community
  • 1
  • 1
Abdull
  • 26,371
  • 26
  • 130
  • 172
  • 1
    AFAIK, there is no way of doing this easily. Eclipse does not look for string constants in class files since they are often compiled away. And source attachments are not used either. The best way that I can think of is to unzip the source attachments of the relevant jars, import them into your Eclipse and search that way. A BIG pain, but I can't think of a better way. – Andrew Eisenberg Sep 11 '12 at 23:23
  • @Andrew Thanks for sharing this workaround!.. I now did it in a quite similar fashion: I knew `form-login` was a hard-coded string value somewhere inside Spring Security (*winkwink*). I cloned the Spring Security sources from Github, imported them into Eclipse as a "General Project". Then I used "File Search", "containing text: form-login", "File name patterns: *". Found the string inside class `org.springframework.security.config.Elements` . – Abdull Sep 12 '12 at 13:06

1 Answers1

1

If you are looking for a "hard-coded" value in the library, use the Maven Source setting in Eclipse to download the source of the library. Then you should be able to do your search.

If that isn't an option, then, as you may already be aware, you are not looking at finding something in the source, but something that is in memory while running. You can put a breakpoint in your software and then use a tool like YourKit to find what you are looking for.

http://www.yourkit.com/docs/11/help/inspections_mem.jsp

Granted, this is a verbose and cumbersome way to achieve the results, but it should work.

Community
  • 1
  • 1
mawcsco
  • 624
  • 6
  • 18
  • No. Your answer doesn't help. Or maybe you are using some options I am not aware of. I'm looking for the **value** of some variable, not its **name**. Downloading the Maven sources doesn't help here. Please try it for yourself: Go into a source code file of some library. Identify some variable which gets some value assigned to it. Now try "Java Search" to find that **value**. I bet "Java Search" won't list that source code file. – Abdull Sep 11 '12 at 22:03
  • @Abdull Did you read my answer? I said if it was "hard-coded": meaning that the value you are looking for would also be in the source. Your question wasn't clear enough, so I provided a second answer which will show you the value of the variable during run-time. BTW, if the value isn't in the source, there is zero reason to mention Maven and m2eclipse. Neither of these tools have anything to do with a running Java program. – mawcsco Sep 12 '12 at 05:59