Java Library Migration Custom Tailored for embedded systems. JT Perry
Slide 2
People in the Project University of Nebraska at Omaha (UNO) Faculty Harvey Siy Victor Winter Students Az Mametjanov James T. Perry Satish Srinivasan Sandia National Laboratories (SNL) Providing the Grant People Involved Ben Farkas Jim McCoy Dom Montoya Steve Morrison Greg Wickstrom
Slide 3
The Need for Library Migration Tiny embedded systems may need to save memory and cannot hold full Libraries. Some embedded systems may have restricted functionality. These systems may then be unable to handle the code in the Libraries. (such as floating point numbers) LIBRARIESJAVA ? ? ? ? X = (int) 10.5;
Slide 4
How should libraries be edited? 1. Must remove all unsupported code. 2. While remaining syntactically correct. 3. And also, it must keep maximum functionality.
Slide 5
Concept of correct editing. (Example: remove float) 1. Must remove all unsupported code. 2. While remaining syntactically correct. 3. And also, it must keep maximum functionality.
Slide 6
Transforming Java Classes With automation There are many steps to automate such processes. One such tool is the class parser included with Suns compiler javap.
Slide 7
How do I start using javap? First you must compile the java file using javac Example: Compiling will generate a class file of the java file. Shown: Now you are able to run javap on the class name. Example:
Slide 8
What does javap produce? With no options, javap simply shows the fields and methods in the class. Without options, we do not have a clear view of the class, which is we use the -verbose option.
Slide 9
Javap -verbose Cafe Constant pool Fields and Methods (with bytecodes) Bellow are snapshots from using javap.
Slide 10
Example of javap This walk-through will be done with the java file shown on the right: After Compiling javap TinyCafe produces:
Slide 11
Example: javap -verbose TinyCafe Constant pool: We can now see how java labels methods and fields.
Slide 12
Example, continued: javap -verbose TinyCafe Constant pool: This applies to all the methods and fields in the Constant pool. Thus, all the information is stored in the comment
Slide 13
Walk-through of Transformation - Using class TransformCafe.java
Slide 14
Slide 15
Other issues. Constructor methods can be tricky. javap -verbose FunkyCafe.java
Slide 16
Other issues. Constructor methods can be tricky. javap -verbose FunkyCafe.java We see that this line is NOT within the body (between first and last line) Thus, the method is NOT dependent on this float.
Slide 17
Other issues. Constructor methods can be tricky. javap -verbose FunkyCafe2.java
Slide 18
Huge Difference same bytecodes Constructor methods can be tricky. javap verbose on FunkyCafe3.java & FunkyCafe4.java Impossible to tell? SOLUTION: Pretty Print File To Remove Confusion! ITS THE SAME!