harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liqian yu <yuliq...@gmail.com>
Subject My proposal for "Smallest classes set for customer application "
Date Thu, 02 Apr 2009 15:34:13 GMT
*Abstract:*

   In my proposal, I proposed a framework based on* class dependency*  and *The
Level Traversal Generation Algorithm* to generate the smallest classes
enclosure for an application to run.



*Introduction:*

   Usually when a Java application is running, lots of the its runtime
resources are not required and the resources which are not required reduce
the effiency. So it is very useful to select the smallest resources set for
an application to run. Our goal is to develop an automatic tool to select
the smallest resources set according to an application.

   In my proposal, I proposed a framework based on *class dependency*  and *The
Level Traversal Generation Algorithm* to generate the smallest classes
enclosure for an application to run. Detailly my proposal contains five
sections: The first section is to analysis the requirements of class
dependency , also I will describe The Level Traversal Generation Algorithm
briefly. The second section is to talk about the design issues of the
tool.In this section, I will first give the Interface of the tool, then I
will give the pseudocode of the main procedures. The third section is to
talk about some challenges and my possible solutions.For example, how to
select the required resource files and database connectors. The fourth
section lists the schedule of this project. The last section I will show why
I’m qualified for this project.



*Analysis:*

   When an application is to run, it starts from the main class.So we can
first apply static analysis techniques for analysing the class dependency,
then scan the main class according to the information of the class
dependency to generate the smallest classes enclosure the main class needs.

   In this section, I will give the detailed requirements of class
dependency. Then I will describe The Level Traversal Generation Algorithm.



*(1)  The requirements of class dependency:*

First we need to define the class dependency rules. We say class A depends
on class B if they satisfy the following seven situations:

(a)  Class A is the inherited class of B;

(b)  Class A implements the interface B;

(c)  Class A contains fields with type of B;

(d)  Class A invokes methods defined in B;

(e)  Class A defines methods with return type of B;

(f)  Class A defines methods with parameter type of B;

(g)  Class A defines methods in which local instance variables with type of
B are defined;



*(2)  The Level Traversal Generation Algorithm*

According to the information of the class dependency defined in previous
part, I’ll describe the The Level Traversal Generation Algorithm to generate
the smallest classes enclosure for an application to run.

I will use a HashSet classesSet to contain the smallest classes enclosure
and a Queue queueNeedToScan to contain the temporary classes which need to
scan to generate the new required classes. The generating process is as
follows:

(a)  First put the main class of the application to the queueNeedToScan;

(b)  Remove the head (we  call it headClass) of the queueNeedToScan, if it
isn’t already in the classesSet, put it to the classesSet;

(c)  Scan the headClass to find all the classes that headClass depends on
according to the dependency rules and put them to the tail of
queueNeedToScan;

(d)  If the queueNeedToScan is not empty, goto (b);



*Design Issues:*

In this sections, I will first give the interface of the tool, then I will
give the pseudocode the main procedures.

*(1)  Interface*

Here I will list three important interfaces of the tool,they are as follows:

(a)

    *public* *static* *boolean* dependsOn(Class A, Class B);



Description: This method can determine whether Class A depends on Class B,
If A depends on B,then return true,else return false





    (b)

    *public* *static* ArrayList<Class> scan(Class A);



    Description: This method is to scan Class A to find all the classes A
depends on



    (c)

*public* *static* HashSet enclosureGenerate(Class mainClass);



Description: This method is to generate the smallest classes enclosure
starts from the mainClass



*(2)  Pseudocode*

Here I will propose the pseudocode of The Traversal Generation Algorithm.



*public* *static* HashSet enclosureGenerate(Class mainClass) {

       HashSet classesSet = *new* HashSet();

       Queue queueNeedToScan = *new* Queue();



       queueNeedToScan.addToTail(mainClass);



       enclosureGenerate(classesSet, queueNeedToScan);



       *return* classesSet;

    }



    //level traversal generation algorithm

*public* *static* *void* enclosureGenerate(HashSet classeSet, Queue
queueNeedToScan) {

       *if*(queueNeedToScan.isEmpty()) {

           *return*;

       } *else* {

           *while*(!queueNeedToScan.isEmpty()) {

              Class headClass = queueNeedToScan.removeHead();



                *if*(!classSet.contains(headClass)) {

                  classSet.add(headClass);

                }



                Iterator dependedItr = scan(headClass);

                *while*(dependeItr.hasNext()) {

                  Class dependedClass = dependedItr.next();

                  queueNeedToScan.addToTail(dependedClass);

                }

           }

       }

}





*Challenges:*

Finding the smallest classes enclosure is not very difficult, but finding  the
other resources the application needs to run is very difficult. Since
different applications may need different types of resources, we can’t
anticipate all the resource types that the application needs.Here I will
propose a possible solution to this challenge.

The detail steps of the solution are as follows:

(a)  Design some popular resource types configuration interfaces. For
example, the disk file, the socket, the database connections and so on.

(b)  When an application is to run, the customers need to configure the
configuration interfaces, the tool then automatically find the resources
according to the customer configuration.

(c)  For those special types of resources, the customers need to manually
select the required resources for the application.



*Schedule*

I will spend more than four months on the project from April to August and I
will spend five days per week and more than four hours per day.

*Analysis Stage*: from now to May.15, I will refine the requirements of the
project and survey some technical issues for coding.

*Coding Stage*:  from May.15 to June 15, I will code for the project.

*Testing Stage*:  from June15 to July 15  I will do a lot of tests of the
project.

*Maintenance Stage*  from July 15 to August 13  I will add some new ideas to
the project.



Certainlly, the schedule is not absolute, it only describes the deadline for
every stage and I will try my best to complete every stage as soon as
possible, so that I will have enough time for the modification stage of the
project according to new ideas.



*Why I’m Qualified*

   In this section, I will show myself to prove that I’m qualified for the
project.

   (1)  First I am an enthusiast and I feel very interested in this project.
So I will try my best to complete the project well. I plan to spend more
than four hours every day and five days every week when I’m not on summer
vocation and whole day when I’m on summer vocation.

   (2)  Second My research interest includes program analysis, testing and
verification. This project is very similar to my research projects. I feel
very familiar to the first part of this project which is to analysis the
class dependency, for I’ve already developed a tool to find all the depended
classes of one class.The tool is used as a prototype tool for my research
paper, though it is based on bytecode level, I think it’s easy to translate
it into source level.

   (3)  Third I love coding very much. Now I’ve coded more than *60,000
lines of code*. And I’ve got a lot of project experiences.

   (4)  The projects I have experienced about Java bytecode are as follows:

     (a)  *IA4J:*  IA4J stands for Immutability Analysis For Java.  This
tool is used to automatically analyse the immutability of Java programs
through scanning the bytecode. In this project I applied BCEL as the
bytecode analysing library. I have acquired the Copyright license from the
National Agency. During this project, I have coded more than 6,000 lines of
code. After finished this project, I have learned the detailed knowledge of
Java Bytecode and the basic principals of JVM.



     (b)  *Jasmine*: Jasmine is tool to verify the accordance of UML model
and code.My work is to instrument some special statements to the classfile,
so that we can record the traces of the application. I also applied the BCEL
to manipulate bytecode. This project is supported by the National Science
Found and the National 863 High-Tech Research and Development Plan of
China.During this project I have coded more than 10,000 lines of code and I
have understood the mechanisms of Java Programming Language.



     (c)   *CDAT:* CDAT stands for Class Dependency Analyzer Tool. This tool
is used to analyse the dependency between classes. First I defined the
dependency rules then I scan every two classes to determine if they are
depended on each other.During this project, I have coded more than 2,000
lines of code.


-- 
君子之行,静以修身,俭以养德。非淡泊无以明志,非宁静无以致远

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message