Example: bachelor of science

Static Analysis for Java in Eclipse - City Tech OpenLab

PLDI 2005, Chicago, IL USAS tatic Analysis for java Static Analysis for java in Eclipsein EclipseThe Dirty Little SecretsThe Dirty Little SecretsDr. Robert M. FuhrerDr. Robert M. FuhrerResearch Staff MemberResearch Staff MemberProgram Analysis & Transformation GroupProgram Analysis & Transformation GroupIBM Watson Research CenterIBM Watson Research Robert M. Fuhrer 200522 IntroductionIntroductionTutorial MotivationTutorial Motivation Eclipse ( Eclipse (http:// ): one of the most popular java ): one of the most popular java ((IDE'sIDE's)) openopen--source distributionsource distribution portabilityportability powerful plugpowerful plug--in extension mechanismin extension mechanism extend environment with tools, views, and analyses to suit speciextend environment with tools, views, and analyses to suit specific needsfic needs advanced feature setadvanced feature set mature java development tool chainmature java development tool chain stable API's for representing and manipulating java programsstable API's for representing and manipulating java programs support for the latest language features in java for the latest language features in java An ideal platform for hosting commercial & experimental java An ideal platform for hosting commercial & experimental

3 Introduction Tutorial Prerequisites Who: • researchers and practitioners interested in implementing static analyses and tools for Java in the setting of a

Tags:

  Eclipse, Analysis, Static, Java, Static analysis for java in eclipse

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Static Analysis for Java in Eclipse - City Tech OpenLab

1 PLDI 2005, Chicago, IL USAS tatic Analysis for java Static Analysis for java in Eclipsein EclipseThe Dirty Little SecretsThe Dirty Little SecretsDr. Robert M. FuhrerDr. Robert M. FuhrerResearch Staff MemberResearch Staff MemberProgram Analysis & Transformation GroupProgram Analysis & Transformation GroupIBM Watson Research CenterIBM Watson Research Robert M. Fuhrer 200522 IntroductionIntroductionTutorial MotivationTutorial Motivation Eclipse ( Eclipse (http:// ): one of the most popular java ): one of the most popular java ((IDE'sIDE's)) openopen--source distributionsource distribution portabilityportability powerful plugpowerful plug--in extension mechanismin extension mechanism extend environment with tools, views, and analyses to suit speciextend environment with tools, views, and analyses to suit specific needsfic needs advanced feature setadvanced feature set mature java development tool chainmature java development tool chain stable API's for representing and manipulating java programsstable API's for representing and manipulating java programs support for the latest language features in java for the latest language features in java An ideal platform for hosting commercial & experimental java An ideal platform for hosting commercial & experimental java analyses and tools!

2 Analyses and tools! But: size & complexity of API's make for daunting learning curveBut: size & complexity of API's make for daunting learning curve!! So far, few researchers implement their analyses in EclipseSo far, few researchers implement their analyses in Eclipse Tutorial Goal: help bridge the gap between potential and realityTutorial Goal: help bridge the gap between potential and reality give participants insight into important aspects of developing sgive participants insight into important aspects of developing Static tatic analyses within the Eclipse IDE and exposing their results to usanalyses within the Eclipse IDE and exposing their results to PrerequisitesTutorial Prerequisites Who:Who: researchers and practitioners interested in implementing researchers and practitioners interested in implementing Static analyses and tools for java in the setting of a Static analyses and tools for java in the setting of a realistic IDErealistic IDE Prerequisites:Prerequisites.

3 Working knowledge of Eclipse as development working knowledge of Eclipse as development environment for ordinary java applicationsenvironment for ordinary java applications knowledge of java language syntax and semanticsknowledge of java language syntax and semantics basic knowledge of fundamental Static Analysis basic knowledge of fundamental Static Analysis techniquestechniques44 IntroductionIntroductionTutorial OverviewTutorial Overview Part I: Eclipse Overview (1 hour)Part I: Eclipse Overview (1 hour)<break> <break> Part II: Intraprocedural Flow Analysis Part II: Intraprocedural Flow Analysis ( hours)( hours)<break> <break> Part III: Part III: InterproceduralInterproceduralType Analysis Type Analysis ( hours)( hours)55 Part I: Eclipse OverviewPart I: Eclipse OverviewPart I: Eclipse Overview (1 hour)Part I: Eclipse Overview (1 hour) PurposePurpose flow of plugflow of plug--in development in development hook into the user interface to trigger analyses hook into the user interface to trigger analyses and present Analysis resultsand present Analysis results describe Eclipse java Development Toolkit describe Eclipse java Development Toolkit (JDT) API's(JDT) API's66 Part I: Eclipse OverviewPart I: Eclipse OverviewEclipse Overview: TopicsEclipse Overview.

4 Topics PlugPlug--in architecturein architecture plugplug--ins, extension points and extensionsins, extension points and extensions creating plugcreating plug--in projectsin projects managing plugmanaging plug--in dependencies in dependencies ResourcesResources builders & markersbuilders & markers Contributing user interface actionsContributing user interface actions view--specific context menu itemsspecific context menu items java API's ( java API's ( JDT/CoreJDT/Core & & JDT/UIJDT/UI )) highhigh--level java modellevel java model abstract syntax trees (AST's)abstract syntax trees (AST's) parsing, traversing, rewritingparsing, traversing, rewriting type representations & type hierarchiestype representations & type hierarchies searchingsearching77 Part I: Eclipse OverviewPart I: Eclipse OverviewPlugPlug--in Architecturein Architecture All functionality provided by some plugAll functionality provided by some plug--inin Core resource APICore resource API ss representing artifacts (folders, source files, class files, representing artifacts (folders, source files, class files, projects)projects) UI UI componentrycomponentry(SWT/(SWT/JFaceJFa ce/Workbench)/Workbench) tables, tree widgets, text, menu items, dialogstables, tree widgets, text, menu items, dialogs ViewsViews java Editor, Package Explorer, Problems ViewJava Editor, Package Explorer, Problems View java Compiler, java DebuggerJava Compiler, java Debugger : Even : Even non-- Eclipse functionality must be Eclipse functionality must be encapsulated in a plugencapsulated in a plug--in!

5 In! ANT, ANT, xalanxalan PlugPlug--ins are lazily instantiated to reduce memory ins are lazily instantiated to reduce memory footprint and speed launchingfootprint and speed launching88 Part I: Eclipse OverviewPart I: Eclipse OverviewPlugPlug--in Architecturein Architecture PlugPlug--in consists of:in consists of: ID ( ID ( )) Name (humanName (human--readable, readable, JDT/CoreJDT/Core )) VersionVersion PlugPlug--in class (plugin class (plug--in initialization/teardown)in initialization/teardown) 0 or more dependencies on other plug0 or more dependencies on other plug--insins 0 or more extensions0 or more extensions : menu items, views, : menu items, views, builders 0 or more extension points0 or more extension points defines sites for other plugdefines sites for other plug--ins to add functionalityins to add functionality99 Part I: Eclipse OverviewPart I: Eclipse OverviewPlugPlug--in Architecture: in Architecture: <?

6 Xml version=" " encoding="UTF-8"?> <? Eclipse version=" "?> <pluginid=" "name="PLDI 2005 name=" "/> </runtime> <requires> <import plugin=" "/> <import plugin=" "/> <import plugin=" "/> </requires> </plugin>specify dependencies1010 Part I: Eclipse OverviewPart I: Eclipse OverviewCreating a PlugCreating a Plug--in Project, 1/3in Project, 1/31111 Part I: Eclipse OverviewPart I: Eclipse OverviewCreating a PlugCreating a Plug--in Project, 2/3in Project, 2/31212 Part I: Eclipse OverviewPart I: Eclipse OverviewCreating a PlugCreating a Plug--in Project, 3/3in Project, 3/31313 Part I: Eclipse OverviewPart I: Eclipse OverviewPlugPlug--in Architecture: Extensionsin Architecture: Extensions extension point extension point a socket to plug extensions intoa socket to plug extensions into ID ( ID ( )) <extension<extension--specific structure>specific structure> <view name=<view name=.

7 Icon=icon= .. category=category= .. class=class= .. />/> extension extension added functionality to plug into an extension ptadded functionality to plug into an extension pt ID of extension point being extendedID of extension point being extended <structure consistent with extension point <structure consistent with extension point defndefn>> Most extension points are hooks for JavaMost extension points are hooks for java --implemented implemented functionalityfunctionality no code need be involved (pure metadata): key bindings, helpno code need be involved (pure metadata): key bindings, helpplug-in Aplug-in Bextension point #1extension #1extension #2extension point #21414 Part I: Eclipse OverviewPart I: Eclipse OverviewPlugPlug--in Architecture: Extensionsin Architecture: Extensions Example 1: UI ExtensionsExample 1: UI Smell Detection menu Smell Detectors Preference Page extension pointsadds extensions onto extension points1515 Part I: Eclipse OverviewPart I: Eclipse OverviewPlugPlug--in Architecture: Extensionsin Architecture: Extensions Example 2: nonExample 2: non--UI extensionsUI extensionsSmell Detector Suite Detector Suite overly-specific detector rampant instanceof detector dead code detector duplicate code detectordefines extension pointadd detection algorithm extensions1616 Part I: Eclipse OverviewPart I: Eclipse OverviewPlugPlug--in Architecture: Extension Point in Architecture: Extension Point SchemasSchemas XML Schema defines XML Schema defines structure of an extension structure of an extension pointpoint Use the Extension Point Use the Extension Point Schema Editor!

8 Schema Editor! Constraints on type of Constraints on type of implementation class for an implementation class for an extension are either:extension are either: EXPLICITLY defined in EXPLICITLY defined in extension point schema extension point schema (but NOT CHECKED (but NOT CHECKED statically!)statically!) IMPLICITLY defined by IMPLICITLY defined by casts in extension point casts in extension point implementation (NOT implementation (NOT CHECKED statically!)CHECKED statically!)1717 Part I: Eclipse OverviewPart I: Eclipse OverviewPlugPlug--in Architecture: Extension in Architecture: Extension InstantiationInstantiationWhen your plug-in needs to instantiate the extensions that hook into one of its extension points:classMyPluginextendsAbstractUIPlu gin{// The following two strings must match what s in !!!staticfinalString pluginID= ;staticfinalString pointID= ;privatevoidcreateExtensions() {IExtensionRegistryer= ();IExtensionPointep= (pluginID, pointID);IExtension[] exts= ();for(inti=0; i < ; i++) {IConfigurationElement[] ces=exts[i].}}}

9 GetConfigurationElements();for(intj=0; j < ; j++) {MyExtensionIntfext = (MyExtensionIntf)ces[i].createExecutableExtension( elementID ); ();}}}instantiate extension implementation classmetadata ops1818 Part I: Eclipse OverviewPart I: Eclipse OverviewPlugPlug--in Architecture: Plugin Architecture: Plug--in Statein State private state used by your plugprivate state used by your plug--inin persists across workbench invocationspersists across workbench invocations distinct from preferences storedistinct from preferences store stored in userstored in user s workspace ats workspace <your-plug-in-dir>privateFile getStateFile() {MyPluginplugin= ();IPathpath = ();path = ( ); // or whatever you ();}1919 Part I: Eclipse OverviewPart I: Eclipse OverviewUI Contributions: Menu ActionsUI Contributions: Menu Actions Main menu contributionsMain menu contributions<extension point=" "> <actionSetlabel="Watson Refactorings description="Watson Refactorings visible="true id=" "> <menulabel= Refactor path="edit id=" "> <separator name= watsonGroup /> </menu> <actionlabel="Infer Type Arguments class=" menubarPath=" id=" "> </action> </actionSet> </extension>implements an existing menu:repeat the menu definitionpath = id + group2020 Part I: Eclipse OverviewPart I: Eclipse OverviewUI Contributions: PopUI Contributions: Pop--up Menu Actionsup Menu Actions Viewer contextViewer context--menu contributionsmenu contributions , Task List context menu , Task List context menu contribution.

10 <extension point=" "> <viewerContributionid=" targetID=" "> <actionid=" " label="&ShowXYZ style="toggle state="true menubarPath="additions" icon=" " class=" "> </action> </viewerContribution> </extension>to this this action2121 Part I: Eclipse OverviewPart I: Eclipse OverviewUI Contributions: PopUI Contributions: Pop--up Menu Actionsup Menu Actions Object contributionsObject contributions common actions appearing in popcommon actions appearing in pop--up up menus for selected entities of a given typemenus for selected entities of a given type Appear in, , Navigator and Outline viewsAppear in, , Navigator and Outline views<extension point=" "> <objectContributionobjectClass=" id="watson"> <menu label="Refactor path="additions id=" "> <separator name="undoRedoGroup /> <separator name="reorgGroup /> <separator name="typeGroup /> <separator name="codingGroup /> </menu> <actionlabel= Infer Type Arguments class=" menubarPath=" id=" "> </action> </objectContribution> </extension>for objects of this this action2222 Part I: Eclipse OverviewPart I: Eclipse OverviewUI Contributions: UI Contributions.


Related search queries