Table of Contents

How to Use Ptidej to Identify Occurrences of Design Motifs

By Chushu Gao and Yann-Gaël Guéhéneuc.

1. Environment

This guide based on the experience on Ecilpes 3.5 in WindowsXP and Fedora Eclipse released with FC11. It should work with any Eclipse version but you must install the C/C++ Development Tooling (CDT) for the C++ creator to work. To do so, install first Eclipse; then go to Help → Install New Software, visit the CDT Web site, and install the CDT Main Features.

2. Checking out the Ptidej Projects

You need an account to access Ptidej SVN repository, please ask Yann-Gaël Guéhéneuc by e-mail. Check out Ptidej using the appropriate Team Set file. If there are build errors after checking out the projects, they usually result of missing project dependencies. Use the quick fix in Eclipse or manually add projects in the project's Java Build Path. Other errors may relate to the incorrect library setting, such as JUnit or JRE.

3. Running in Eclipse

3.1 Ptidej UI Viewer Swing Standalone

Even if some projects fail to build, the Ptidej UI Viewer Swing Standalone can still run thanks to the use of reflection. In Eclipse, run it as an application and watch this video for details on how to use the GUI.

3.2 Batch Mode

Make sure the project Ptidej Solver Tests is successfully built. Some projects are not required though listed in the required projects section of the project properties, under Java Build Path. A working set of projects includes CPL, JChoco, PADL, PADL Analyses, PADL Creator ClassFile, PADL Design Motifs, Ptidej, and Ptidej Solver 4, see also the available Team Project Files. The path to the JAR or class files that you want to analyse must be set in class ptidej.solver.helper.DesignMotifsIdentifer: modify its code to fit your settings and run its main method. The path for the result files is also set in this class.

4. Running as a JAR

The classes necessary to identify occurrences of design motifs can be packaged into a runnable JAR using Run Configuration in Step 3.2 and the Eclipse Export in Eclipse 3.5 on Windows XP. You may get the error messages below when running this JAR on Fedora, where the default JDK is OpenJDK1.6:

padl.FileAccessException
at padl.util.repository.file.ClassFileRepository.storeFiles(ClassFileRepository.java:60)
at padl.util.repository.file.ClassFileRepository.getMetaModelFiles(ClassFileRepository.java:115)
at padl.util.repository.file.ClassFileRepository.getFiles(ClassFileRepository.java:134)
at padl.util.repository.constituent.ConstituentRepository.<init>(ConstituentRepository.java:62)
at padl.util.repository.constituent.ConstituentRepository.getInstance(ConstituentRepository.java:37)
at ptidej.solver.helper.DesignMotifIdentificationCaller.analyseCodeLevelModelFromJAR(DesignMotifIdentificationCaller.java:920)
at ptidej.solver.helper.DesignMotifIdentificationCaller.main(DesignMotifIdentificationCaller.java:100)
Loading class files in: ./1_0/org.eclipse.jdt.core/jdtcore.jar
Exception in thread "main" java.lang.NullPointerException
at padl.creator.AbstractClassFileCreator.createElements(AbstractClassFileCreator.java:239)
at padl.creator.AbstractClassFileCreator.create(AbstractClassFileCreator.java:224)
at padl.kernel.impl.CodeLevelModel.create(CodeLevelModel.java:48)
at ptidej.solver.helper.DesignMotifIdentificationCaller.analyseCodeLevelModelFromJAR(DesignMotifIdentificationCaller.java:919)
at ptidej.solver.helper.DesignMotifIdentificationCaller.main(DesignMotifIdentificationCaller.java:100)

Please contact Yann-Gaël Guéhéneuc if you run into this problem or consider running this JAR using Sun's JDK.

5. Memory Usage

When analysing large JAR files or large sets of class files, give enough memory to the JVM, with -Xmx2048M. Tests show that it is possible to analyse Eclipse entirely.