Quantcast
Viewing all articles
Browse latest Browse all 5

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

Image may be NSFW.
Clik here to view.
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

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

Image may be NSFW.
Clik here to view.
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…

Image may be NSFW.
Clik here to view.
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()

Image may be NSFW.
Clik here to view.
Class expandable to list operations

Class expandable to list operations

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

Image may be NSFW.
Clik here to view.
Sequence diagram

Sequence diagram

Related Articles

Related Links


Viewing all articles
Browse latest Browse all 5

Trending Articles