...
 
Commits (66)
......@@ -5,6 +5,26 @@
<classpathentry kind="src" output="output/build/util" path="src-util"/>
<classpathentry kind="src" output="output/build/test" path="src-test"/>
<classpathentry kind="src" output="output/build/shvm-dispatch" path="src-shvm-dispatch"/>
<classpathentry kind="src" path="disl/src/src-classparser"/>
<classpathentry kind="src" path="disl/src/src-exception"/>
<classpathentry kind="src" path="disl/src/src-main"/>
<classpathentry kind="src" path="disl/src/src-resolver"/>
<classpathentry kind="src" path="disl/src/src-coderep"/>
<classpathentry kind="src" path="disl/src/src-util"/>
<classpathentry kind="src" path="disl/src/src-snippet"/>
<classpathentry kind="src" path="disl/src/src-processor"/>
<classpathentry kind="src" path="disl/src/src-guard"/>
<classpathentry kind="src" path="disl/src/src-localvar"/>
<classpathentry kind="src" path="disl/src/src-scope"/>
<classpathentry kind="src" path="disl-server/src"/>
<classpathentry kind="src" path="disl/src/src-staticcontext"/>
<classpathentry kind="src" path="disl/src/src-staticcontext-uid"/>
<classpathentry kind="src" path="disl/src/src-marker"/>
<classpathentry kind="src" path="disl/src/src-weaver"/>
<classpathentry kind="src" path="disl/src/src-weaver-pe"/>
<classpathentry kind="src" path="disl/src/src-annotation"/>
<classpathentry kind="src" path="disl/src/src-context"/>
<classpathentry kind="src" path="disl/src-test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="output/lib/disl-bypass.jar"/>
<classpathentry kind="lib" path="lib/disl/log4j.jar" sourcepath="lib/devel/log4j-source.jar"/>
......
......@@ -5,6 +5,17 @@ src-disl-agent/windows-*
# Compiled shared libraries
*.so
*.jnilib
# Compiled object files
*.o
# Compiled examples
examples/**/*.class
examples/**/*.jar
# Logs
*.log
# Anything in the output
output/*
......
......@@ -424,7 +424,7 @@ def run_server(args, parser):
s_cmd = ["java"]
s_cmd+= args.s_opts
s_cmd+= ["-cp", args.instrumentation + ":" + s_jar]
s_cmd+= ["-cp", args.instrumentation + ":" + s_jar + ":" + args.disl_home+"/lib/dislre-server.jar"]
s_cmd+= [s_class]
s_cmd+= args.s_args
......@@ -485,6 +485,7 @@ def run_client(args, parser):
c_cmd = ["java"]
c_cmd+= args.c_opts
c_cmd+= ["-agentpath:"+cagent]
c_cmd+= ["-Ddisl.instrumentation="+args.instrumentation]
if args.cse == True:
c_cmd+= ["-agentpath:"+eagent]
......
lib.dir=lib
lib.ant.dir=${lib.dir}/ant
lib.disl.dir=${lib.dir}/disl
lib.test.dir=${lib.dir}/test
lib.devel.dir=${lib.dir}/devel
src.bin=bin
src.disl=src-disl
src.disl.bypass=src-disl-bypass
src.disl.agent=src-disl-agent
src.shvm=src-shvm
......@@ -20,40 +12,9 @@ src.doc.intro=${src.doc}/intro
src.examples=examples
# Base output directory
out.dir=output
# Directories for build artifacts
build.dir=${out.dir}/build
build.util=${build.dir}/util
build.tools=${build.dir}/tools
build.disl=${build.dir}/disl
build.disl.thread=${build.disl}-thread
build.disl.bypass=${build.disl}-bypass
build.shvm=${build.dir}/shvm
build.shvm.dispatch=${build.shvm}-dispatch
build.test=${build.dir}/test
build.doc.intro=${build.dir}/intro
# Build system libraries
build.ivy.url = http://central.maven.org/maven2/org/apache/ivy/ivy/${ivy.rev}/ivy-${ivy.rev}.jar
build.ivy.path = ${lib.ant.dir}/ivy.jar
build.ivy.file = dependencies.xml
build.artifacts.list = ${lib.dir}/artifacts.lst
# Directories for output artifacts
out.lib=${out.dir}/lib
out.src=${out.dir}/src
out.test=${out.dir}/test
out.junit=${out.dir}/junit
out.doc.jdoc=${out.dir}/jdoc
# Output library artifact names
disl.lib=disl-server.jar
disl.bypass.lib=disl-bypass.jar
disl.agent.lib.base=dislagent
......
......@@ -6,7 +6,7 @@
<property name="build.sysclasspath" value="ignore"/>
<property file="disl.version"/>
<property file="disl.version.properties"/>
<property file="dependencies.local.properties"/>
<property file="dependencies.properties"/>
......@@ -14,6 +14,8 @@
<property file="build.local.properties"/>
<property file="build.properties"/>
<property file="common.properties" />
<!-- ================================================================== -->
<!-- IVY SETUP & TASKS -->
......@@ -264,7 +266,11 @@
</path>
<path id="disl.classpath">
<pathelement location="${build.disl}"/>
<pathelement location="${src.disl.prefix}/${build.disl}"/>
</path>
<path id="disl-server.classpath">
<pathelement location="${src.disl-server.prefix}/${build.disl-server}"/>
</path>
<path id="disl.bypass.classpath">
......@@ -473,38 +479,17 @@
<!-- DiSL -->
<target name="compile-disl" depends="compile-util,compile-disl-bypass">
<mkdir dir="${build.disl}"/>
<javac destdir="${build.disl}" srcdir="${src.disl}" debug="true">
<classpath>
<path refid="disl.bypass.classpath"/>
<path refid="util.classpath"/>
<path refid="asm.classpath"/>
<path refid="protobuf.classpath"/>
</classpath>
</javac>
<ant antfile="${src.disl.prefix}/build.xml" target="compile" usenativebasedir="true"/>
</target>
<target name="compile-disl-server" depends="compile-disl">
<ant dir="${src.disl-server.prefix}" target="compile"/>
</target>
<target name="build-disl" depends="compile-disl,build-disl-bypass">
<local name="server.class"/>
<find-class property="server.class" dir="${build.disl}" name="DiSLServer"/>
<local name="classfinder.class"/>
<find-class property="classfinder.class" dir="${build.disl}" name="DislClassFinder"/>
<jar destfile="${out.lib}/${disl.lib}">
<manifest>
<attribute name="Class-Path" value="${asm.libs} ${protobuf.libs}"/>
<attribute name="Main-Class" value="${server.class}"/>
<attribute name="DiSL-Version" value="${disl.version}"/>
</manifest>
<service type="javax.annotation.processing.Processor" provider="${classfinder.class}"/>
<fileset dir="${build.util}"/>
<fileset dir="${build.disl}"/>
<resources refid="disl.bypass.files"/>
</jar>
<target name="build-disl" depends="compile-disl,build-disl-bypass">
<ant dir="${src.disl-server.prefix}" target="build" />
<copy file="${src.disl-server.prefix}/${out.lib}/${disl.lib}" tofile="${out.lib}/${disl.lib}" />
</target>
......@@ -518,7 +503,7 @@
<target name="-check-disl-agent-codeflags">
<property name="build.disl.agent.codeflags.path" value="${src.disl.agent}/codeflags.h"/>
<uptodate property="build.disl.agent.codeflags.uptodate" targetfile="${build.disl.agent.codeflags.path}">
<srcfiles dir="${src.disl}" includes="**/DiSL.java"/>
<srcfiles dir="${src.disl.prefix}/src" includes="**/DiSL.java"/>
</uptodate>
</target>
......@@ -528,7 +513,7 @@
<target name="-generate-disl-agent-codeflags" depends="compile-disl">
<local name="flags.class"/>
<find-class property="flags.class" dir="${build.disl}" name="*CodeOption$Flag"/>
<find-class property="flags.class" dir="${src.disl.prefix}/${build.disl}" name="*CodeOption$Flag"/>
<javah outputFile="${build.disl.agent.codeflags.path}" force="yes">
<class name="${flags.class}"/>
......@@ -691,6 +676,7 @@
<path id="test.classpath">
<path refid="util.classpath"/>
<path refid="disl.classpath"/>
<path refid="disl-server.classpath"/>
<path refid="shvm.classpath"/>
<path refid="junit.classpath"/>
<path refid="asm.classpath"/>
......@@ -772,7 +758,7 @@
<tempfile property="classfinder.output" prefix="@{name}-disl-classes-" suffix=".lst" destDir="${out.dir}" createFile="true" deleteOnExit="true"/>
<local name="classfinder.class"/>
<find-class property="classfinder.class" dir="${build.disl}" name="DislClassFinder"/>
<find-class property="classfinder.class" dir="${src.disl.prefix}/${build.disl}" name="DislClassFinder"/>
<mkdir dir="${out.dir}/empty"/>
<javac srcdir="${src.test}" destDir="${out.dir}/empty">
......@@ -800,8 +786,12 @@
</sequential>
</macrodef>
<!-- Run nested instrumentation library tests -->
<target name="disl-test">
<ant antfile="${src.disl.prefix}/build.xml" target="test" usenativebasedir="true"/>
</target>
<target name="test" depends="build,build-test" description="Runs all tests or a selected (-Dtest.name=...) test suite.">
<target name="test" depends="build,build-test,disl-test" description="Runs all tests or a selected (-Dtest.name=...) test suite.">
<!--
If test.name is set to a name of a test suite, only include the test suite
in the batch of tests to be run, otherwise include all tests and suites.
......@@ -838,7 +828,8 @@
<path refid="junit.classpath"/>
<pathelement location="${build.test}"/>
<pathelement location="${build.util}"/>
<pathelement location="${build.disl}"/>
<pathelement location="${src.disl-server.prefix}/${build.disl-server}" />
<pathelement location="${src.disl.prefix}/${build.disl}"/>
<pathelement location="${build.shvm}"/>
</classpath>
......@@ -935,11 +926,11 @@
source="1.8"
>
<sourcepath>
<pathelement path="${src.disl}"/>
<pathelement path="${src.disl.prefix}/src"/>
</sourcepath>
<sourcefiles>
<fileset dir="${src.disl}">
<fileset dir="${src.disl.prefix}/src">
<include name="**/DiSL.java"/>
<include name="**/Reflection.java"/>
<include name="**/Scope.java"/>
......@@ -969,14 +960,6 @@
<path refid="util.classpath"/>
<path refid="asm.classpath"/>
</classpath>
<package name="ch.usi.dag.disl.annotation"/>
<package name="ch.usi.dag.disl.marker"/>
<package name="ch.usi.dag.disl.guardcontext"/>
<package name="ch.usi.dag.disl.staticcontext"/>
<package name="ch.usi.dag.disl.dynamiccontext"/>
<package name="ch.usi.dag.disl.classcontext"/>
<package name="ch.usi.dag.disl.processorcontext"/>
</javadoc>
</target>
......@@ -993,7 +976,7 @@
<target name="package-src">
<zip destfile="${out.src}/src.zip">
<zipfileset dir="${src.disl}"/>
<zipfileset dir="${src.disl.prefix}/src"/>
<zipfileset dir="${src.disl.bypass}/dynamic"/>
<zipfileset dir="${src.shvm}"/>
<zipfileset dir="${src.shvm.dispatch}"/>
......@@ -1083,8 +1066,16 @@
<ant dir="${src.examples}" target="clean"/>
</target>
<target name="clean-disl">
<ant dir="${src.disl.prefix}" target="clean" />
</target>
<target name="clean-disl-server">
<ant dir="${src.disl-server.prefix}" target="clean" />
</target>
<target name="clean" description="Removes all files produced during the build.">
<target name="clean" depends="clean-disl, clean-disl-server" description="Removes all files produced during the build.">
<exec executable="make" dir="${src.disl.agent}">
<arg value="cleanall"/>
</exec>
......
#
# Build properties common for the main project and all subprojects.
#
lib.dir=lib
lib.ant.dir=${lib.dir}/ant
lib.disl.dir=${lib.dir}/disl
lib.test.dir=${lib.dir}/test
lib.devel.dir=${lib.dir}/devel
build.artifacts.list = ${lib.dir}/artifacts.lst
# Build system libraries
build.ivy.url = http://central.maven.org/maven2/org/apache/ivy/ivy/${ivy.rev}/ivy-${ivy.rev}.jar
build.ivy.path = ${lib.ant.dir}/ivy.jar
build.ivy.file = dependencies.xml
src.bin=bin
src.disl.prefix=disl
src.disl-server.prefix=disl-server
disl.lib=disl-server.jar
# Base output directory
out.dir=output
# Directories for output artifacts
out.lib=${out.dir}/lib
out.src=${out.dir}/src
out.test=${out.dir}/test
out.junit=${out.dir}/junit
out.doc.jdoc=${out.dir}/jdoc
# Directories for build artifacts
build.dir=${out.dir}/build
build.util=${build.dir}/util
build.tools=${build.dir}/tools
build.disl=${build.dir}/disl
build.disl-server=${build.dir}/disl-server
build.disl.thread=${build.disl}-thread
build.disl.bypass=${build.disl}-bypass
build.shvm=${build.dir}/shvm
build.shvm.dispatch=${build.shvm}-dispatch
build.test=${build.dir}/test
build.doc.intro=${build.dir}/intro
# DiSL instrumentation server
<project name="disl-server" default="build" basedir=".">
<!--
Import required property files.
-->
<property file="../common.properties"/>
<property file="build.properties" />
<property file="../disl.version.properties" />
<!--
Initialize the build directory
-->
<target name="init">
<mkdir dir="${build.disl-server}" />
</target>
<!--
Dependency class paths
-->
<path id="asm.classpath">
<fileset dir="../${lib.disl.dir}" includes="asm*.jar" id="asm.fileset"/>
</path>
<path id="util.classpath">
<pathelement location="../${build.util}"/>
</path>
<path id="protobuf.classpath">
<fileset dir="../${lib.disl.dir}" includes="protobuf*.jar"/>
</path>
<!--
Refer to the parent targets
-->
<target name="compile-util">
<ant antfile="../build.xml" target="compile-util" usenativebasedir="true" />
</target>
<target name="compile-disl">
<ant antfile="../build.xml" target="compile-disl" usenativebasedir="true" />
</target>
<target name="build-disl-bypass">
<ant antfile="../build.xml" target="build-disl-bypass" usenativebasedir="true" />
</target>
<!-- DiSL Server -->
<target name="compile" depends="compile-util,init, compile-disl">
<javac destdir="${build.disl-server}" debug="true" srcdir="src/">
<classpath>
<path path="../${src.disl.prefix}/${build.disl}" />
<path refid="util.classpath"/>
<path refid="protobuf.classpath"/>
</classpath>
</javac>
</target>
<union id="disl.bypass.files">
<fileset dir="../${build.disl.bypass}/always" includes="**/BypassCheck.class"/>
<fileset dir="../${build.disl.bypass}/dynamic" includes="**/DynamicBypass.class"/>
</union>
<!-- Get ASM libs from ASM class path. -->
<pathconvert pathsep=" " property="asm.libs" refid="asm.classpath">
<mapper type="flatten"/>
</pathconvert>
<!-- Get ProtoBuf Java libs from ProtoBuf class path. -->
<pathconvert pathsep=" " property="protobuf.libs" refid="protobuf.classpath">
<mapper type="flatten"/>
</pathconvert>
<target name="build" depends="compile, build-disl-bypass">
<jar destfile="${out.lib}/${disl.lib}">
<manifest>
<attribute name="Class-Path" value="${asm.libs} ${protobuf.libs}"/>
<attribute name="Main-Class" value="ch.usi.dag.dislserver.DiSLServer"/>
<attribute name="DiSL-Version" value="${disl.version}"/>
</manifest>
<service type="javax.annotation.processing.Processor" provider="ch.usi.dag.disl.DislClassFinder"/>
<fileset dir="${build.disl-server}" />
<fileset dir="../${build.util}"/>
<fileset dir="../${src.disl.prefix}/${build.disl}"/>
<resources refid="disl.bypass.files"/>
</jar>
</target>
<!--
Clean the build directory
-->
<target name="clean">
<delete dir="output" />
</target>
</project>
This diff is collapsed.
This diff is collapsed.
package ch.usi.dag.dislserver;
import ch.usi.dag.disl.DiSL;
import ch.usi.dag.disl.DiSL.CodeOption;
import ch.usi.dag.disl.DiSLException;
import ch.usi.dag.disl.JavaNames;
import ch.usi.dag.dislserver.Protocol.InstrumentClassRequest;
import ch.usi.dag.dislserver.Protocol.InstrumentClassResponse;
import ch.usi.dag.util.Strings;
import ch.usi.dag.util.logging.Logger;
import com.google.protobuf.ByteString;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
......@@ -7,22 +17,10 @@ import java.io.StringWriter;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.objectweb.asm.ClassReader;
import com.google.protobuf.ByteString;
import ch.usi.dag.disl.DiSL;
import ch.usi.dag.disl.DiSL.CodeOption;
import ch.usi.dag.disl.exception.DiSLException;
import ch.usi.dag.disl.util.JavaNames;
import ch.usi.dag.dislserver.Protocol.InstrumentClassRequest;
import ch.usi.dag.dislserver.Protocol.InstrumentClassResponse;
import ch.usi.dag.util.Strings;
import ch.usi.dag.util.logging.Logger;
final class RequestProcessor {
......@@ -81,13 +79,13 @@ final class RequestProcessor {
}
return InstrumentClassResponse.newBuilder ()
.setResult (Protocol.InstrumentClassResult.CLASS_MODIFIED)
.setResult (Protocol.InstrumentClassResponse.InstrumentClassResult.CLASS_MODIFIED)
.setClassBytes (ByteString.copyFrom (newClassBytes))
.build ();
} else {
return InstrumentClassResponse.newBuilder ()
.setResult (Protocol.InstrumentClassResult.CLASS_UNMODIFIED)
.setResult (Protocol.InstrumentClassResponse.InstrumentClassResult.CLASS_UNMODIFIED)
.build ();
}
......@@ -99,7 +97,7 @@ final class RequestProcessor {
__log.error (message);
return InstrumentClassResponse.newBuilder ()
.setResult (Protocol.InstrumentClassResult.ERROR)
.setResult (Protocol.InstrumentClassResponse.InstrumentClassResult.ERROR)
.setErrorMessage (message)
.build ();
}
......@@ -122,7 +120,7 @@ final class RequestProcessor {
}
if (result.isEmpty ()) {
result = new ClassReader (classBytes).getClassName ();
result = JavaNames.getClassNameFromBytes (classBytes);
if (result == null || result.isEmpty ()) {
result = UUID.randomUUID ().toString ();
}
......@@ -171,19 +169,27 @@ final class RequestProcessor {
//
public void terminate () {
void terminate () {
__disl.terminate ();
}
//
public static RequestProcessor newInstance () throws DiSLException {
/**
* Creates new instance of RequestProcessor class.
*
* @param instrumentationJars List of bytearrays representing instrumentation jars.
* @return New instance of RequestProcessor
* @throws DiSLException
*/
static RequestProcessor newInstance (final List<byte[]> instrumentationJars) throws DiSLException {
// TODO LB: Configure bypass on a per-request basis.
if (disableBypass) {
System.setProperty ("disl.disablebypass", "true");
}
final DiSL disl = DiSL.init ();
final DiSL disl = new DiSL(System.getProperties (), instrumentationJars);
return new RequestProcessor (disl);
}
......
/*
* Pack the values related to one session.
*
* File: SessionCredentials.java
* Created by Vit Kabele <vit@kabele.me> on 16/10/2018
*/
package ch.usi.dag.dislserver;
import java.util.ArrayList;
import java.util.List;
/**
* Pack the values related to one session.
*/
class SessionCredentials {
/**
* Session identifier
*/
final int sessionId;
/**
* Available states of the session.
*/
enum SessionState {
/**
* Default
*/
INITIALIZED,
/**
* Instrumentation obtained and OK.
*/
READY,
/**
* Error while processing one of the previous requests.
*/
ERROR,
/**
* Session was closed by the client.
*/
CLOSED
}
/**
* State of the session.
*/
private SessionState state = SessionState.INITIALIZED;
void setState(SessionState state){ this.state = state; }
SessionState getState(){ return state; }
/**
* Byte arrays representing files with instrumentation.
*/
final List<byte[]> instrumentationJars = new ArrayList<>();
/**
* A request processor to handle the instrumentation requests.
*/
private RequestProcessor processor;
void setProcessor(RequestProcessor processor){ this.processor = processor; }
RequestProcessor getProcessor(){ return processor; }
/**
* Construct the class
* @param sessionId Session identifier.
*/
SessionCredentials(int sessionId){
this.sessionId = sessionId;
}
}
# DiSL
## The instrumentation library
# Build properties related to the DiSL instrumentation library
src.disl.annotation=src-annotation
src.disl.classparser=src-classparser
src.disl.coderep=src-coderep
src.disl.context=src-context
src.disl.exception=src-exception
src.disl.guard=src-guard
src.disl.localvar=src-localvar
src.disl.main=src-main
src.disl.marker=src-marker
src.disl.processor=src-processor
src.disl.resolver=src-resolver
src.disl.scope=src-scope
src.disl.snippet=src-snippet
src.disl.staticcontext-uid=src-staticcontext-uid
src.disl.staticcontext=src-staticcontext
src.disl.util=src-util
src.disl.weaver-pe=src-weaver-pe
src.disl.weaver=src-weaver
src.disl.test=src-test
build.disl.test=${build.dir}/test
<project name="disl" default="compile" basedir=".">
<!--
Import required property files.
-->
<property file="../common.properties"/>
<property file="build.properties" />
<!--
Dependency class paths
-->
<path id="asm.classpath">
<fileset dir="../${lib.disl.dir}" includes="asm*.jar" id="asm.fileset"/>
</path>
<path id="util.classpath">
<pathelement location="../${build.util}"/>
</path>
<path id="junit.classpath">
<fileset dir="../${lib.test.dir}" includes="*.jar"/>
</path>
<path id="disl.bypass.classpath">
<pathelement location="../${build.disl.bypass}/dynamic"/>
</path>
<!--
Initialize the build directory
-->
<target name="init">
<mkdir dir="${build.disl}" />
<mkdir dir="${build.disl.test}" />
</target>
<!--
Refer to the parent targets
-->
<target name="compile-util">
<ant antfile="../build.xml" target="compile-util" usenativebasedir="true" />
</target>
<target name="compile-disl-bypass">
<ant antfile="../build.xml" target="compile-disl-bypass" usenativebasedir="true" />
</target>
<!-- DiSL -->
<target name="compile" depends="compile-util,compile-disl-bypass, init">
<javac destdir="${build.disl}" debug="true" includeantruntime="false">
<src path="src/${src.disl.annotation}"/>
<src path="src/${src.disl.classparser}"/>
<src path="src/${src.disl.coderep}"/>
<src path="src/${src.disl.context}"/>
<src path="src/${src.disl.exception}"/>
<src path="src/${src.disl.guard}"/>
<src path="src/${src.disl.localvar}"/>
<src path="src/${src.disl.main}"/>
<src path="src/${src.disl.marker}"/>
<src path="src/${src.disl.processor}"/>
<src path="src/${src.disl.resolver}"/>
<src path="src/${src.disl.scope}"/>
<src path="src/${src.disl.snippet}"/>
<src path="src/${src.disl.staticcontext-uid}"/>
<src path="src/${src.disl.staticcontext}"/>
<src path="src/${src.disl.util}"/>
<src path="src/${src.disl.weaver-pe}"/>
<src path="src/${src.disl.weaver}"/>
<classpath>
<path refid="disl.bypass.classpath"/>
<path refid="util.classpath"/>
<path refid="asm.classpath"/>
</classpath>
</javac>
</target>
<target name="compile-tests" depends="compile">
<javac destdir="${build.disl.test}" debug="true" srcdir="${src.disl.test}" includeantruntime="false">
<classpath>
<path refid="disl.bypass.classpath"/>
<path refid="util.classpath"/>
<path refid="asm.classpath"/>
<path refid="junit.classpath"/>
<path path="${build.disl}"/>
</classpath>
</javac>
</target>
<target name="test" depends="compile-tests" description="Run all unit tests">
<echo>Running DiSL intrumentation library tests...</echo>
<junit haltonfailure="yes" haltonerror="yes" failureproperty="junit.failure">
<formatter type="brief" usefile="false"/>
<classpath>
<path refid="asm.classpath"/>
<path refid="junit.classpath"/>
<path path="${build.disl.test}"/>
<path path="../${build.util}"/>
<path path="${build.disl}"/>
</classpath>
<batchtest fork="yes">
<fileset dir="${src.disl.test}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
<!--
Clean the build directory
-->
<target name="clean">
<delete dir="${out.dir}" />
</target>
</project>
package ch.usi.dag.disl.util.cfg;
package ch.usi.dag.disl;
import java.io.IOException;
import java.util.function.Predicate;
......@@ -9,8 +9,6 @@ import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import ch.usi.dag.disl.util.Insn;
import ch.usi.dag.disl.util.JavaNames;
import ch.usi.dag.util.asm.ClassNodeHelper;
......
package ch.usi.dag.disl;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.Manifest;
import static org.junit.Assert.*;
/**
* This file is part of disl project
* Author: Vit Kabele <vit@kabele.me>
* Created on the 26/10/2018
*/
public class DiSLManifestTest {
@Test
public void testGetDiSLClasses () throws ManifestException {
String dislClass = "Abcdef";
Manifest manifest = new Manifest ();
manifest.getMainAttributes ().putValue ( DiSLManifest.DISL_CLASSES, dislClass );
DiSLManifest diSLManifest = new DiSLManifest (manifest);
List<String> classes = diSLManifest.getDiSLClasses ();
assertEquals ( classes.get (0), dislClass);
}
@Test
public void testGetMultipleDiSLClasses () throws ManifestException {
ArrayList<String> list = new ArrayList<>();
list.add ("DislClass");
list.add ("JustAnotherDislClass");
Manifest manifest = new Manifest ();
manifest.getMainAttributes ().putValue (
DiSLManifest.DISL_CLASSES,
String.join (DiSLManifest.SEPARATOR, list)
);
DiSLManifest diSLManifest = new DiSLManifest (manifest);
assertArrayEquals (
list.toArray (),
diSLManifest.getDiSLClasses ().toArray ()
);
}
@Test
public void getTransformers() throws ManifestException {
String[] transformers = new String[]{
"OptimusPrime",
"Bumblebee",
"Deceptikon"
};
String[] transformers_tail = java.util.Arrays.copyOfRange (transformers,1, transformers.length);
Manifest manifest = new Manifest ();
manifest.getMainAttributes ().putValue (
DiSLManifest.DISL_CLASSES,
"RandomValue"
);
manifest.getMainAttributes ().putValue (
DiSLManifest.DISL_TRANSFORMER,
transformers[0]
);
manifest.getMainAttributes ().putValue (
DiSLManifest.DISL_TRANSFORMERS,
String.join (DiSLManifest.SEPARATOR, transformers_tail)
);
DiSLManifest diSLManifest = new DiSLManifest (manifest);
assertArrayEquals(
transformers,
diSLManifest.getTransformersClasses ().toArray ()
);
}
}
This diff is collapsed.
package ch.usi.dag.disl.scope;
package ch.usi.dag.disl;
import ch.usi.dag.disl.ParameterMatcher;
import org.junit.Assert;
import org.junit.Test;
......
package ch.usi.dag.disl.scope;
package ch.usi.dag.disl;
import java.util.Arrays;
import java.util.List;
......@@ -300,7 +300,7 @@ public class ScopeMatcherTest {
);
}
@Test(expected=MalformedScopeException.class)
@Test(expected= MalformedScopeException.class)
public void throwOnEmptyScope() throws MalformedScopeException {
ScopeMatcher.forPattern ("");
}
......
package ch.usi.dag.disl.scope;
package ch.usi.dag.disl;
import ch.usi.dag.disl.TypeMatcher;
import org.junit.Assert;
import org.junit.Test;
......
package ch.usi.dag.disl.scope;
package ch.usi.dag.disl;
import ch.usi.dag.disl.WildCardMatcher;
import org.junit.Assert;
import org.junit.Test;
......
package ch.usi.dag.disl.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import ch.usi.dag.disl.classcontext.ClassContext;
import ch.usi.dag.disl.dynamiccontext.DynamicContext;
import ch.usi.dag.disl.marker.Marker;
import ch.usi.dag.disl.processorcontext.ArgumentProcessorContext;
import ch.usi.dag.disl.staticcontext.StaticContext;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
* Marks a method as a DiSL snippet to be inserted after the marked code region.
......@@ -62,7 +62,7 @@ public @interface After {
* Selects the marker class. A marker determines the region of code within a
* method where to apply the snippet.
*
* @see ch.usi.dag.disl.marker.Marker Implementation details
* @see Marker Implementation details
*/
Class <? extends Marker> marker();
......
package ch.usi.dag.disl.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import ch.usi.dag.disl.classcontext.ClassContext;
import ch.usi.dag.disl.dynamiccontext.DynamicContext;
import ch.usi.dag.disl.marker.Marker;
import ch.usi.dag.disl.processorcontext.ArgumentProcessorContext;
import ch.usi.dag.disl.staticcontext.StaticContext;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
* Marks a method as a DiSL snippet to be inserted after the marked code region.
......@@ -62,7 +62,7 @@ public @interface AfterReturning {
* Selects the marker class. A marker determines the region of code within a
* method where to apply the snippet.
*
* @see ch.usi.dag.disl.marker.Marker Implementation details
* @see Marker Implementation details
*/
Class <? extends Marker> marker();
......
package ch.usi.dag.disl.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import ch.usi.dag.disl.classcontext.ClassContext;
import ch.usi.dag.disl.dynamiccontext.DynamicContext;
import ch.usi.dag.disl.marker.Marker;
import ch.usi.dag.disl.processorcontext.ArgumentProcessorContext;
import ch.usi.dag.disl.staticcontext.StaticContext;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
* Marks a method as a DiSL snippet to be inserted after the marked code region.
......@@ -61,7 +61,7 @@ public @interface AfterThrowing {
* Selects the marker class. A marker determines the region of code within a
* method where to apply the snippet.
*
* @see ch.usi.dag.disl.marker.Marker Implementation details
* @see Marker Implementation details
*/
Class <? extends Marker> marker();
......
package ch.usi.dag.disl.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import ch.usi.dag.disl.processorcontext.ArgumentContext;
import ch.usi.dag.disl.classcontext.ClassContext;
import ch.usi.dag.disl.dynamiccontext.DynamicContext;
import ch.usi.dag.disl.processorcontext.ArgumentContext;
import ch.usi.dag.disl.staticcontext.StaticContext;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
* Indicates that the class contains methods for processing method arguments
......
package ch.usi.dag.disl.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import ch.usi.dag.disl.classcontext.ClassContext;
import ch.usi.dag.disl.dynamiccontext.DynamicContext;
import ch.usi.dag.disl.marker.Marker;
import ch.usi.dag.disl.processorcontext.ArgumentProcessorContext;
import ch.usi.dag.disl.staticcontext.StaticContext;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
* Marks a method as a DiSL snippet to be inserted before the marked code
......@@ -61,7 +61,7 @@ public @interface Before {
* Selects the marker class. A marker determines the region of code within a
* method where to apply the snippet.
*
* @see ch.usi.dag.disl.marker.Marker Implementation details
* @see Marker Implementation details
*/
Class <? extends Marker> marker();
......
package ch.usi.dag.disl.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import ch.usi.dag.disl.processorcontext.ArgumentContext;
import ch.usi.dag.disl.guardcontext.GuardContext;
import ch.usi.dag.disl.Shadow;
import ch.usi.dag.disl.staticcontext.StaticContext;
import java.lang.annotation.*;
/**
......
......@@ -34,7 +34,7 @@ public @interface ProcessAlso {
//
/**
* @see ch.usi.dag.disl.annotation.ProcessAlso
* @see ProcessAlso
*/
public enum Type {
BOOLEAN, BYTE, SHORT
......
......@@ -36,7 +36,7 @@ public @interface SyntheticLocal {
//
/**
* @see ch.usi.dag.disl.annotation.SyntheticLocal
* @see SyntheticLocal
*/
public enum Initialize {
ALWAYS, NEVER, BEST_EFFORT
......
package ch.usi.dag.disl.classparser;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
package ch.usi.dag.disl;
import ch.usi.dag.disl.AsmHelper.Insns;
import ch.usi.dag.disl.annotation.SyntheticLocal;
import ch.usi.dag.disl.annotation.SyntheticLocal.Initialize;
import ch.usi.dag.disl.annotation.ThreadLocal;
import ch.usi.dag.util.logging.Logger;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.IntInsnNode;
import org.objectweb.asm.tree.LabelNode