1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans...
-
Upload
melvin-bailey -
Category
Documents
-
view
217 -
download
0
description
Transcript of 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans...
![Page 1: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/1.jpg)
1
Development of Java tools using
SWT and WALA
Infinit Højniveausprog, 10 February 2010
Hans Søndergaard
• Builder example
• SWT, - The Standard Widget Toolkit
• WALA, - for static analysis of Java bytecode
• Example: Profile generator
• Conclusion
![Page 2: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/2.jpg)
Model: JemBuilder
2
aJile Systems:• Builder for the aJile Java processor
![Page 3: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/3.jpg)
GUI programming using SWT
• SWT : The Standard Widget Toolkit – designed to provide efficient, portable access
to the user-interface facilities of the operating systems on which it is implemented
– part of Eclipse– many code snippets– see http://www.eclipse.org/swt/
3
![Page 4: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/4.jpg)
SWT versus Swing
• No clear difference as to performance• Swing
– has more memory consumption than SWT – has all its components implemented by itself
• has much more classes to be loaded in runtime.
4
![Page 5: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/5.jpg)
Analysis of Java bytecode
5
• WALA provides static analysis capabilities for Java bytecode
• WALA features include:
Java type system and class hierarchy analysis Interprocedural dataflow analysis Pointer analysis and call graph construction General framework for iterative dataflow General analysis utilities and data structures A dynamic load-time instrumentation library for Java
• open source license• http://wala.sourceforge.net/wiki/index.php/Main_Page
![Page 6: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/6.jpg)
Example: PositiveListChecker
• Scans a list of classes to be checked• A Profile must be available
– a positive list of classes with methods• The result is written in a report file. Generated report file:
Not on positive list ==================== (type, class, method) (7, java/lang/Object, null) (10, hello/NotPositiveClass, staticMethod1) (7, hello/NotPositiveClass, null)
6
![Page 7: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/7.jpg)
Profile generator
7
![Page 8: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/8.jpg)
Profile generator: Add to Available classes
8
![Page 9: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/9.jpg)
Code snippet: Available classes: Add
Button addButton = new Button (composite, SWT.PUSH);addButton.setText (" Add ");
addButton.addSelectionListener (new SelectionAdapter () { public void widgetSelected (SelectionEvent e) { FileDialog fileDialog = new FileDialog(fileList.getShell(), SWT.OPEN); String[] filterNames = new String[] {"Class Files“,"Jar Files“,"All
Files(*)"}; String [] filterExtensions = new String [] {"*.class", "*.jar", "*"}; ... String fileName = fileDialog.open(); ... // see next slide }});
9
![Page 10: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/10.jpg)
Code snippet: Available classes: AddString[] args = {fileName}; // class or jar filetry { pjchecker.ClassList list = new ClassList (args); // uses WALA lib HashSet<ClassInfo> classSet = list.getClassList(); Iterator<ClassInfo> itr = classSet.iterator(); for (; itr.hasNext(); ) { ClassInfo info = itr.next(); if (info.methodName == null) // a class availableClassList.addClass(info.className); else // a method availableClassList.addMethod(info.className, info.methodName); } createTree (availableListTree, availableClassList);}catch(...) {...}
10
![Page 11: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/11.jpg)
Code snippet: Using WALA classes
• com.ibm.wala.shrikeBT.shrikeCT.OfflineInstrumenter;
OfflineInstrumenter oi = new OfflineInstrumenter(); oi.parseStandardArgs(args);
• com.ibm.wala.shrikeBT.shrikeCT.ClassInstrumenter;
ClassInstrumenter ci; oi.beginTraversal(); while ((ci = oi.nextClass()) != null)
doClass( ci.getReader() );
11
![Page 12: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/12.jpg)
Code snippet: Using WALA classes
• com.ibm.wala.shrikeCT.ClassReader;
String className = cr.getName(); ClassInfo c = new ClassInfo (ClassConstants.CONSTANT_Class, className, null);classSet.add(c);
for (int i = 1; i < cr.getMethodCount(); i++) { int accessFlag = cr.getMethodAccessFlags(i); if ((accessFlag & 0x0002) != 0x0002) // private methods not included in list { if (! cr.getMethodName(i).equals("<init>") &&
!cr.getMethodName(i).equals("<clinit>")) { c = new ClassInfo ( ClassConstants.CONSTANT_MethodRef, className, cr.getMethodName(i));
classSet.add(c); } } }
12
![Page 13: 1 Development of Java tools using SWT and WALA Infinit Højniveausprog, 10 February 2010 Hans Søndergaard Builder example SWT, - The Standard Widget Toolkit.](https://reader035.fdocuments.in/reader035/viewer/2022062503/5a4d1afe7f8b9ab059985928/html5/thumbnails/13.jpg)
Conclusion
• SWT is an alternative to Swing– part of Eclipse– less classes and less memory consumption– many code snippets
• WALA– harder to install and get down to use– but many features for static analysis of Java
bytecode
13