July 30, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Java Language Integrity & Security: Uncovering Bytecodes

  • March 5, 2007
  • By Matt Weisfeld
  • Send Email »
  • More Articles »

Compiling the Disassembled

One of the interesting questions is whether or not this disassembled code can actually be compiled and used. The easiest way to test this is to use it and compile it. The code, incorporating the resultant code from javap, is shown in Listing 7.

Listing 7: The Employee Class (the disassembled source code)

public class Performance {

   public static void main(String[] args) {

      System.out.println("Performance Example");

      Employee joe = new Employee();

   }
}
public class Employee extends java.lang.Object{
   private int employeeNumber;
   public Employee();
}

The answer to that questions is no—at least not directly. The javap application (at least with the -private option) seems to have provided only the signature of the method—not the body.



Click here for a larger image.

Figure 12: Compiled the disassemble Employee source.

If you do add a method body as seen in Listing 8, the dissembled code will work; but, this is cheating. What is the point of disassembling the code if you can't compile it directly? This is a question you will explore in the next article.

Listing 8: The Employee Class (the disassembled source code)

public class Performance {

   public static void main(String[] args) {

      System.out.println("Performance Example");

      Employee joe = new Employee();

   }
}
public class Employee extends java.lang.Object{
   private int employeeNumber;
   public Employee() { };
}

Conclusion

In this article, you began to explore how a class file is designed and how you can disassemble it. Although there are a few applications of the process that can assist the professional developer, it is often a very good mechanism for instructional purposes. Understanding what goes on under the hood of an application is a beneficial process. At a more detailed level, this exercise provides the framework for the Java Virtual Machine.

In next month's article, you will delve more deeply into understanding how the structure of bytecodes can help in the construction and testing phases of the software development process and how it affects the performance and security of an application.

References

About the Author

Matt Weisfeld is a faculty member at Cuyahoga Community College (Tri-C) in Cleveland, Ohio. Matt is a member of the Information Technology department, teaching programming languages such as C++, Java, C#, and .NET as well as various Web technologies. Prior to joining Tri-C, Matt spent 20 years in the information technology industry gaining experience in software development, project management, business development, corporate training, and part-time teaching. Matt holds an MS in computer science and an MBA in project management. Besides The Object-Oriented Thought Process, which is now in its second edition, Matt has published two other computer books, and more than a dozen articles in magazines and journals such as Dr. Dobb's Journal, The C/C++ Users Journal, Software Development Magazine, Java Report, and the international journal Project Management. Matt has presented at conferences throughout the United States and Canada.





Page 4 of 4



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel