When Reversing Java Code to Sequence Diagram, Why Can’t I Select an Operation?

When reversing Java code to sequence diagram, sometimes you may not be able to specify a method for conversion. In the window, somehow the class (to which the method belongs) can’t seem to be expanded to list anything and therefore the method is nowhere to be selected. What happens?

When you do run into this problem, you’d probably see something similar below. At the point of being asked to select an operation, the java classes are not expandable ( i.e. no leading ‘+’ signs ).

Class unexpandable to list operations

Class unexpandable to list operations

Why?

The Java source path is incorrectly set.

As an example, let’s say we are reversing Java code of method createNewFile() in Java class File.java which is packaged in  java.io.

In the Windows Explorer, the source code file File.java appears living in C:\src\java\io

where File.java is stored

where File.java is stored

Back in the source code file File.java, we can see that the package line defines the class to be in package \java\io\

Organization of Java package

Organization of Java package

When we specified the Java source path to be C:\src\java , we were asking the program to look for File.java in C:\src\java\java\io  (which doesn’t exist).

i.e. The program begins at C:\src\java and from there, goes to \java\io

Instead, we should specify the Java source path to be C:\src in this case so that the program will look for File.java in the path C:\src\java\io

i.e. beginning at C:\src and then going down to \java\io

Steps to Fix It

  1. Click < Back to return to the Java Source section.
  2. Remove the incorrect Java source by selecting it and clicking Remove.
  3. Add a new java source for C:\src by clicking Add Source Folder…

Specify a new java source

Specify a new java source 

After fixing the Java source path, the operations should now be available for selection under their corresponding Java classes ( with leading ‘+’ signs ).

e.g. createNewFile()

Class expandable to list operations

Class expandable to list operations

Upon completion of the conversion, you should be able to see the sequence diagram.

Sequence diagram

Sequence diagram

Related Articles

Related Links

1651 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply