Commit 18aef79f authored by Lukáš Marek's avatar Lukáš Marek

Added jar support for DiSL - see ClassByteLoadersource for usage info

parent 09525bc3
asm.path=lib/asm-debug-all-4.0_RC1.jar
jborat.path=lib/jborat.jar
jborat-runtime.path=lib/jborat-runtime.jar
instr.jar.name=dislinstr.jar
\ No newline at end of file
......@@ -11,7 +11,11 @@
<target name="package" depends="compile">
<mkdir dir="build"/>
<jar basedir="bin" destfile="build/disl-${disl.version}.jar"/>
<jar basedir="bin" destfile="build/disl-${disl.version}.jar">
<manifest>
<attribute name="Class-Path" value="${instr.jar.name}"/>
</manifest>
</jar>
</target>
......
......@@ -62,8 +62,9 @@ public class DiSL implements Instrumentation {
if(dislClasses == null) {
throw new InitException("Cannot load DiSL classes. Please set" +
" the property " + ClassByteLoader.DISL_CLASSES
+ " or supply " + ClassByteLoader.INSTR_JAR);
" the property " + ClassByteLoader.PROP_DISL_CLASSES
+ " or supply jar with DiSL classes"
+ " and proper manifest");
}
// *** parse disl classes ***
......
......@@ -17,15 +17,23 @@ public abstract class ClassByteLoader {
private static final String MANIFEST = "META-INF/MANIFEST.MF";
public static final String INSTR_JAR = "dislinstr.jar";
public static final String PROP_DISL_CLASSES = "disl.classes";
public static final String DISL_CLASSES = "disl.classes";
public static final String ATTR_DISL_CLASSES = "DiSL-Classes";
public static final String DISL_CLASSES_DELIM = ":";
// TODO ! jar support - add jar dependency
// TODO ! jar support - create ant task for test compilation
// TODO ! jar support - create processor manifest
// TODO ! jar support - test
// How to use jar support
// 1) Create jar with a name specified in build.properties (instr.jar.name)
// 2) Include manifest file that contains names of all used DiSL classes
// - for the name of the manifest attribute see ATTR_DISL_CLASSES
// Jar should contain all additional classes needed for instrumentation
// like Markers, Static analyses, ...
//
// NOTE: Example of the usage is processor test case
// To build the jar for the processor test case go to the test directory
// and call "ant package -Dtest.name=processor"
// To run the test case with the instrumentation located in jar call
// "./run-pkg.sh processor"
public static List<InputStream> loadDiSLClasses()
throws InitException {
......@@ -48,7 +56,7 @@ public abstract class ClassByteLoader {
private static List<InputStream> loadClassesFromProperty()
throws IOException {
String classesList = System.getProperty(DISL_CLASSES);
String classesList = System.getProperty(PROP_DISL_CLASSES);
if ( (classesList != null) && (! classesList.isEmpty()) ) {
......@@ -105,7 +113,7 @@ public abstract class ClassByteLoader {
// contains disl classes
if(attrs != null) {
String dislClasses = attrs.getValue(DISL_CLASSES);
String dislClasses = attrs.getValue(ATTR_DISL_CLASSES);
if(dislClasses != null) {
return dislClasses;
......
......@@ -35,6 +35,27 @@
</jar>
</target>
<target name="check-test-property">
<condition property="test.set">
<isset property="test.name"/>
</condition>
</target>
<target name="report-missing-property" depends="check-test-property" unless="test.set">
<fail message="Property test.name is not set. Set it using -Dtest.name=value" />
</target>
<property name="test.path" value="ch/usi/dag/disl/test/${test.name}"/>
<target name="package" depends="report-missing-property" description="create instrumentation package for specified test">
<jar jarfile="../build/${instr.jar.name}"
basedir="./bin"
includes="${test.path}/*"
excludes="${test.path}/TargetClass.class ${test.path}/MANIFEST.MF"
manifest="./src/${test.path}/MANIFEST.MF">
</jar>
</target>
<target name="clean">
<delete dir="bin"/>
<delete dir="build"/>
......
# /bin/sh
EXPECTED_ARGS=1
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` {test case}"
exit
fi
TARGET_CLASS="ch.usi.dag.disl.test.$1.TargetClass"
java -javaagent:../lib/jborat-agent.jar -Dch.usi.dag.jborat.exclusionList="conf/exclusion.lst" -Dch.usi.dag.jborat.liblist="conf/lib.lst" -Dch.usi.dag.jborat.instrumentation="ch.usi.dag.disl.DiSL" -Dch.usi.dag.jborat.codemergerList="conf/codemerger.lst" -Dch.usi.dag.jborat.uninstrumented="uninstrumented" -Dch.usi.dag.jborat.instrumented="instrumented" -Xbootclasspath/p:../lib/Thread_jborat.jar:../lib/jborat-runtime.jar -Ddisl.dynbypass=yes -cp "./bin/" ${TARGET_CLASS}
Manifest-Version: 1.0
DiSL-Classes: ch/usi/dag/disl/test/processor/DiSLClass.class:ch/usi/dag/disl/test/processor/ProcessorTest.class
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment