Technology for reading Java source code in Eclipse


You will have the opportunity to read the source code written by other members of the project, read the source code to investigate the framework you are using, and read the source code in various situations.

In such a case, there are several approaches to use the IDE's functions, improve the sense of hitting, train the keyboard operation to be faster, and so on.

In this article, we will focus on using the functions of the IDE from among those approaches, and introduce the functions that are useful for reading the source code when the language is Java and the IDE uses Eclipse.

Read Java source code in Eclipse

For the sake of clarity, some screenshots are posted, but the source code shown there is from a database access library called Doma. (Completely my hobby)

Also, since my body is cursed by Eclipse, I will write about the features of Eclipse, but I think there are similar ones in other IDEs. So, if you are using another IDE, I would be grateful if you could write an article saying "This IDE should do this".

Jump to definition

First of all, from the basics. If you are reading the source code and want to jump from the code calling the method to the point where the method is defined, place the cursor on the code calling the method and press F3.

  1. Place the cursor on
    <img width = "212" alt = "Screenshot 2017-12-09 12.18.29.png " src = "" /0/19129/029b3929-3386-a774-448f-3174aad83b85.png ">
  2. Press F3
    <img width =" 374 "alt =" Screenshot 2017-12-09 12.18.45.png "src =" https://qiita-image-store.s3.amazonaws. com / 0/19129 / d7bc5f85-f586-d8b7-5849-b819cfd1ddfc.png ">

If you read a specific process from the beginning, you will often jump to the method definition, so I think it is a function that you often use.

Jump to the method definition of the interface implementation class

If you jump to the method definition with F3, there may be no implementation in the interface beyond that.

  1. When you jump to the method definition with F3 ...
    <img width =" 372 "alt =" Screenshot 2017-12-09 13.20.31.png "src =" https: // qiita-image ">
  2. There is no implementation in the interface!
    <img width = "194" alt = "Screenshot 2017-12-09 13.20.41.png " src = "" -6505-80af-60c0-08fbd644155d.png ">

In that case, place the cursor on the method call code and press Command + T. Then, a list of classes that implement the method will be displayed, so this is it! Select the class you think you want and jump to the method definition.

  1. Place the cursor on the method call code
    <img width = "372" alt = "Screenshot 2017-12-09 13.20.31.png " src = "https://qiita-image-store.s3" ">
  2. Press Command + T
    <img width =" 415 "alt =" Screenshot 2017-12-09 13.21.11.png "src =" https://qiita-image-store.s3. ">
  3. You can jump to the method definition by selecting the implementation class.
    <img width = "239" alt = "Screenshot 2017-12-09 13.21.19.png " src = "https://qiita-image-store" ">

In this example, only one class is shown, but in some cases many implementation classes are shown. Among them, this is it! Choosing a class that seems like it requires knowledge and sense, but training them is another story, so I will omit it.

Find the method call location

You may want to know where a method is called from, such as when investigating the impact of specification changes. In that case, hover over the method definition you want to investigate and press Control + alt + H. Then you will see a list of places that are calling that method.

スクリーンショット 2017-12-09 13.23.49.png

If you press the triangle mark to the left of each item in the list of call points, the call points of that method will be displayed in a list.

スクリーンショット 2017-12-09 14.23.40.png

That way you can go back and forth in the calling hierarchy.

Search for class references

Place the cursor on the class and press Command + Shift + G. Then, the places that refer to that class will be listed.

スクリーンショット 2017-12-09 14.30.19.png

If the class is referenced as a field, the field name will be displayed, and if it is referenced as an argument / local variable, the constructor name or method name will be displayed in the search results.

This feature was needed when I read a framework of a reasonable size, such as Spring Boot.

Other frequently used search functions

Other than these, I often use type search and resource search.

In my case, I think these are used more often when writing the source code than when reading the source code.

Tools other than Eclipse

Other than Eclipse, there are other tools that can help you read the source code. Here, I will only give a brief introduction as a bonus.


I often use git grep and git ls-files. git grep often uses the -i option and the --name-only option together.

Large projects, such as the Spring Framework, are often git grep to import into Eclipse for search.


unite.vim is a Vim plugin that allows you to search various things such as files and buffers as data sources. It's extremely convenient, but I'm having a little trouble because it doesn't work on my company's PC. I have to do something ...

By the way, unite.vim is in maintenance mode, and the successor is denite.nvim. I have to change ...

in conclusion

I introduced the functions that are useful for reading the source code using Java and Eclipse as the subject, but how was it? As mentioned earlier, I think that other IDEs have similar functions (or more convenient functions), so please check the manual of your IDE or ask the experts around you.

This time I wrote the features of Eclipse specifically, but I hope I can announce at another time the mindset of reading the source code and other approaches that can be taken to read the source code quickly. I am.

Then everyone, have a good source code reading life!

Recommended Posts

Technology for reading Java source code in Eclipse
Technology for reading source code (cheat sheet)
Java source code reading java.lang.Math class
Enable code completion in Eclipse for Mac
Comments in Java source
Sample source code for finding the least common multiple of multiple values in Java
When entering eclipse Java source code, auto activation triggers
Null-safe program in Java (Eclipse)
Java in Visual Studio Code
Write Java8-like code in Java8
First Java development in Eclipse
[Java] Tips for writing source
When reading the source code
Create QR code for Google Authenticator using ZXing in Java
Eclipse installation and code completion enhancements (Mac for Java development)
Java Spring environment in vs Code
[For beginners] Run Selenium in Java
[OpenCV3.2.0] Eclipse (Java) settings (for Mac)
Try running Selenuim 3.141.59 in eclipse (java)
Hello World in java in eclipse now
Pre-written source code for the activity
Settings for SSL debugging in Java
JPA (Java Persistence API) in Eclipse
Basic structure of Java source code
First steps for deep learning in Java
Key points for introducing gRPC in Java
[JAWS-UG CLI] CodeBuild: # 1 Creating Source Code (Java)
[Java] for Each and sorted in Lambda
Sample code collection for Azure Java development
[Java] Set AdoptOpen JDK in STS (Eclipse)
Play Framework 2.6 (Java) environment construction in Eclipse
Convenient plugin for Eclipse JAVA development: Decompiler
All same hash code string in Java
[Java] Flow from source code to execution
[Mac] Install Java in Visual Studio Code
Reading and writing gzip files in Java
[For beginners] How to debug in Eclipse
[Java] Eclipse shortcuts that make sense when you go back and forth between source code in a project
Technology excerpt that can be used for creating EC sites in Java training
View used to execute Java code during debugging in Eclipse is Debug Shell
[For beginners] I tried using DBUnit in Eclipse
Eclipse Pleiades All in One for Mac released
Add --enable-preview option in Java in Visual Studio Code
ChatWork4j for using the ChatWork API in Java
How to color code console output in Eclipse
[For beginners] I tried using JUnit 5 in Eclipse
[Java] API creation using Jerjey (Jax-rs) in eclipse
Static code analysis with Checkstyle in Java + Gradle
Code to escape a JSON string in Java
Prepare for log output using log4j in Eclipse.
Solution for NetBeans 8.2 not working in Java 9 environment
Try using Sourcetrail (win version) in Java code
Try using Sourcetrail (macOS version) in Java code
[AtCoder Problem-ABC001] C-Do wind observation in Java [Code]
Make a snippet for Thymeleaf in VS Code
Set pop-up display for Java language in vim.
Processing for reading / refreshing / updating data in TableView
Generate Java client code for Salesforce SOAP API
[Java beginner's anguish] Hard-to-test code implemented in Junit
[Mac] Install Java in Visual Studio Code (VS Code)
Compare PDF output in Java for snapshot testing