Commit 861fafb1 authored by Vít Kabele's avatar Vít Kabele

Annotation package merged

parent 1ce50ba6
Pipeline #3380 passed with stages
in 2 minutes and 58 seconds
......@@ -22,6 +22,7 @@
<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="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"/>
......
......@@ -7,22 +7,25 @@ lib.devel.dir=${lib.dir}/devel
src.bin=bin
src.disl.prefix=disl
src.disl=src-disl
src.disl.main=src-main
src.disl.annotation=src-annotation
src.disl.classparser=src-classparser
src.disl.resolver=src-resolver
src.disl.coderep=src-coderep
src.disl.util=src-util
src.disl.snippet=src-snippet
src.disl.processor=src-processor
src.disl.exception=src-exception
src.disl.guard=src-guard
src.disl.localvar=src-localvar
src.disl.exception=src-exception
src.disl.scope=src-scope
src.disl.main=src-main
src.disl.marker=src-marker
src.disl.weaver=src-weaver
src.disl.weaver-pe=src-weaver-pe
src.disl.staticcontext=src-staticcontext
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.bypass=src-disl-bypass
src.disl.agent=src-disl-agent
src.shvm=src-shvm
......
......@@ -490,6 +490,7 @@
<src path="${src.disl.prefix}/src/${src.disl.localvar}"/>
<src path="${src.disl.prefix}/src/${src.disl.staticcontext}"/>
<src path="${src.disl.prefix}/src/${src.disl.staticcontext-uid}"/>
<src path="${src.disl.prefix}/src/${src.disl.annotation}"/>
<src path="${src.disl.prefix}/src/${src.disl.util}"/>
<src path="${src.disl.prefix}/src/${src.disl.main}"/>
......
package ch.usi.dag.disl.annotation;
package ch.usi.dag.disl;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
......
package ch.usi.dag.disl.annotation;
package ch.usi.dag.disl;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
......
package ch.usi.dag.disl.annotation;
package ch.usi.dag.disl;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
......
package ch.usi.dag.disl.annotation;
package ch.usi.dag.disl;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
......@@ -7,7 +7,6 @@ import java.lang.annotation.Target;
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;
/**
......
package ch.usi.dag.disl.annotation;
package ch.usi.dag.disl;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
......
package ch.usi.dag.disl.annotation;
package ch.usi.dag.disl;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
......
package ch.usi.dag.disl.annotation;
package ch.usi.dag.disl;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
......
package ch.usi.dag.disl.annotation;
package ch.usi.dag.disl;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
......@@ -34,7 +34,7 @@ public @interface ProcessAlso {
//
/**
* @see ch.usi.dag.disl.annotation.ProcessAlso
* @see ProcessAlso
*/
public enum Type {
BOOLEAN, BYTE, SHORT
......
package ch.usi.dag.disl.annotation;
package ch.usi.dag.disl;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
......@@ -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.annotation;
package ch.usi.dag.disl;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
......
......@@ -22,9 +22,7 @@ import org.objectweb.asm.tree.VarInsnNode;
import org.objectweb.asm.tree.analysis.Frame;
import org.objectweb.asm.tree.analysis.SourceValue;
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.disl.SyntheticLocal.Initialize;
import ch.usi.dag.disl.AsmHelper.Insns;
import ch.usi.dag.util.logging.Logger;
......@@ -105,7 +103,7 @@ abstract class AbstractParser {
// thread local
final Type tlvAnnotation = Type.getType(
ch.usi.dag.disl.annotation.ThreadLocal.class);
ThreadLocal.class);
if (annotationType.equals(tlvAnnotation)) {
final ThreadLocalVar tlv = parseThreadLocal (className, field, annotation);
result.put(tlv);
......
......@@ -13,8 +13,6 @@ import org.objectweb.asm.Type;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import ch.usi.dag.disl.annotation.Guarded;
import ch.usi.dag.disl.annotation.ProcessAlso;
import ch.usi.dag.util.Strings;
......
......@@ -6,7 +6,6 @@
*/
package ch.usi.dag.disl;
import ch.usi.dag.disl.annotation.ArgumentProcessor;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
......
......@@ -3,7 +3,6 @@ package ch.usi.dag.disl;
import java.lang.reflect.Method;
import java.util.*;
import ch.usi.dag.disl.annotation.*;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.MethodNode;
......
......@@ -20,19 +20,19 @@ public abstract class GuardHelper {
}
// TODO LB: Cache validated methods and don't validate them again?
final GuardMethod guardMethod = GuardResolver.getInstance ().getGuardMethod (guardClass);
validateGuardMethod (guardMethod, validArgs);
return guardMethod.getMethod ();
final InnerGuardMethod innerGuardMethod = GuardResolver.getInstance ().getGuardMethod (guardClass);
validateGuardMethod (innerGuardMethod, validArgs);
return innerGuardMethod.getMethod ();
}
private static void validateGuardMethod (
final GuardMethod guardMethod, final Set <Class <?>> validArgs
final InnerGuardMethod innerGuardMethod, final Set <Class <?>> validArgs
) throws GuardException {
// quick validation
if(guardMethod.getArgTypes() != null) {
if(innerGuardMethod.getArgTypes() != null) {
// only valid argument types are in the method - ok
if (validArgs.containsAll (guardMethod.getArgTypes ())) {
if (validArgs.containsAll (innerGuardMethod.getArgTypes ())) {
return;
}
......@@ -40,20 +40,20 @@ public abstract class GuardHelper {
// prepare invalid argument type set
final Set <Class <?>> invalidArgTypes =
new HashSet <Class <?>> (guardMethod.getArgTypes ());
new HashSet <Class <?>> (innerGuardMethod.getArgTypes ());
invalidArgTypes.removeAll (validArgs);
// construct the error message
throw new GuardException (String.format (
"Guard %s is using interface %s not allowed in this "+
"particular case (misused guard?)",
guardMethod.getMethod().getDeclaringClass().getName(),
innerGuardMethod.getMethod().getDeclaringClass().getName(),
invalidArgTypes.iterator().next().getName()
));
}
// validate properly
final Method method = guardMethod.getMethod();
final Method method = innerGuardMethod.getMethod();
final String methodName = __fullMethodName (method);
if (!method.getReturnType ().equals (boolean.class)) {
throw new GuardException (
......@@ -72,7 +72,7 @@ public abstract class GuardHelper {
argTypes.add (validateArgument (methodName, argType, validArgs));
}
guardMethod.setArgTypes (argTypes);
innerGuardMethod.setArgTypes (argTypes);
}
......@@ -173,15 +173,15 @@ public abstract class GuardHelper {
// The validation set depends on whether we are in a snippet (no
// processor context supplied) or in an argument processor.
//
final GuardMethod guardMethod = GuardResolver.getInstance ().
final InnerGuardMethod innerGuardMethod = GuardResolver.getInstance ().
getGuardMethod (guardClass);
final Set <Class <?>> validationSet = (ac == null) ?
snippetContextSet () : processorContextSet ();
validateGuardMethod (guardMethod, validationSet);
validateGuardMethod (innerGuardMethod, validationSet);
return invokeGuardMethod (guardMethod.getMethod (), shadow, ac);
return invokeGuardMethod (innerGuardMethod.getMethod (), shadow, ac);
}
......
......@@ -3,8 +3,6 @@ package ch.usi.dag.disl;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.InsnList;
import ch.usi.dag.disl.annotation.SyntheticLocal;
public class SyntheticLocalVar extends AbstractLocalVar {
......
......@@ -10,7 +10,6 @@ import org.objectweb.asm.commons.AdviceAdapter;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.MethodNode;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.Shadow.WeavingRegion;
import ch.usi.dag.disl.AsmHelper.Insns;
......
......@@ -3,8 +3,6 @@ package ch.usi.dag.disl;
import java.lang.reflect.Method;
import java.util.Set;
import ch.usi.dag.disl.annotation.ArgumentProcessor;
/**
* Represents an {@link ArgumentProcessor} method, which is analogous to a
......
......@@ -24,10 +24,10 @@ public class GuardResolver {
//
/** A cache of guard methods corresponding to guard classes. */
private final Map <Class <?>, GuardMethod> __guardMethodsByClass = new HashMap <> ();
private final Map <Class <?>, InnerGuardMethod> __guardMethodsByClass = new HashMap <> ();
synchronized GuardMethod getGuardMethod (
synchronized InnerGuardMethod getGuardMethod (
final Class <?> guardClass
) throws GuardException {
//
......@@ -35,7 +35,7 @@ public class GuardResolver {
// corresponding to guard classes. If it does not provide an answer,
// search of a guard method within the class.
//
final GuardMethod cachedResult = __guardMethodsByClass.get (guardClass);
final InnerGuardMethod cachedResult = __guardMethodsByClass.get (guardClass);
if (cachedResult != null) {
return cachedResult;
}
......@@ -44,7 +44,7 @@ public class GuardResolver {
}
private GuardMethod __findGuardMethod (
private InnerGuardMethod __findGuardMethod (
final Class <?> guardClass
) throws GuardException {
final List <Method> candidateMethods = Arrays
......@@ -55,7 +55,7 @@ public class GuardResolver {
if (candidateMethods.isEmpty ()) {
throw new GuardException (String.format (
"No method annotated using %s found in class %s",
ch.usi.dag.disl.annotation.GuardMethod.class.getName(),
GuardMethod.class.getName(),
guardClass.getName()
));
}
......@@ -71,7 +71,7 @@ public class GuardResolver {
final Method method = candidateMethods.get (0);
method.setAccessible (true);
final GuardMethod result = new GuardMethod (method);
final InnerGuardMethod result = new InnerGuardMethod (method);
__guardMethodsByClass.put (guardClass, result);
return result;
}
......@@ -79,7 +79,7 @@ public class GuardResolver {
private boolean __isGuardMethodCandidate (final Method m) {
return m.isAnnotationPresent(
ch.usi.dag.disl.annotation.GuardMethod.class
GuardMethod.class
);
}
......
......@@ -3,12 +3,12 @@ package ch.usi.dag.disl;
import java.lang.reflect.Method;
import java.util.Set;
public class GuardMethod {
public class InnerGuardMethod {
private Method method;
private Set<Class<?>> argTypes;
public GuardMethod(Method method) {
InnerGuardMethod (Method method) {
super();
this.method = method;
}
......@@ -17,11 +17,11 @@ public class GuardMethod {
return method;
}
public Set<Class<?>> getArgTypes() {
Set<Class<?>> getArgTypes() {
return argTypes;
}
public void setArgTypes(Set<Class<?>> argTypes) {
void setArgTypes(Set<Class<?>> argTypes) {
this.argTypes = argTypes;
}
}
......@@ -21,15 +21,6 @@ import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic.Kind;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.annotation.AfterThrowing;
import ch.usi.dag.disl.annotation.ArgumentProcessor;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.annotation.Guarded;
import ch.usi.dag.disl.annotation.ProcessAlso;
import ch.usi.dag.disl.annotation.SyntheticLocal;
/**
* Identifies DiSL classes based on the use of DiSL annotations. Only classes
......
......@@ -15,11 +15,7 @@ import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TryCatchBlockNode;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.annotation.AfterThrowing;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.annotation.SyntheticLocal.Initialize;
import ch.usi.dag.disl.SyntheticLocal.Initialize;
import ch.usi.dag.disl.Shadow.WeavingRegion;
import ch.usi.dag.disl.AsmHelper.Insns;
......
package ch.usi.dag.disl.dynamiccontext;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.AfterThrowing;
import ch.usi.dag.disl.After;
import ch.usi.dag.disl.AfterThrowing;
import ch.usi.dag.disl.FieldAccessStaticContext;
......
package ch.usi.dag.disl.processorcontext;
import ch.usi.dag.disl.annotation.ArgumentProcessor;
import ch.usi.dag.disl.ArgumentProcessor;
/**
* Provides information about a particular method argument from within an
......
package ch.usi.dag.disl.test.suite.after.instr;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.AfterThrowing;
import ch.usi.dag.disl.After;
import ch.usi.dag.disl.AfterThrowing;
import ch.usi.dag.disl.BodyMarker;
public class DiSLClass {
......
......@@ -2,9 +2,9 @@ package ch.usi.dag.disl.test.suite.after2.instr;
import java.util.Stack;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.annotation.ThreadLocal;
import ch.usi.dag.disl.After;
import ch.usi.dag.disl.Before;
import ch.usi.dag.disl.ThreadLocal;
import ch.usi.dag.disl.BodyMarker;
import ch.usi.dag.disl.RandomMethodUid;
import ch.usi.dag.disl.test.suite.after2.instr.runtime.Analysis;
......
package ch.usi.dag.disl.test.suite.after2.instr;
import ch.usi.dag.disl.annotation.GuardMethod;
import ch.usi.dag.disl.GuardMethod;
import ch.usi.dag.disl.MethodStaticContext;
public class NotInitNorClinit {
......
package ch.usi.dag.disl.test.suite.after3.instr;
import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.annotation.AfterThrowing;
import ch.usi.dag.disl.AfterReturning;
import ch.usi.dag.disl.AfterThrowing;
import ch.usi.dag.disl.BodyMarker;
import ch.usi.dag.disl.MethodStaticContext;
......
package ch.usi.dag.disl.test.suite.afterinit1.instr;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.After;
import ch.usi.dag.disl.Before;
import ch.usi.dag.disl.AfterInitBodyMarker;
......
package ch.usi.dag.disl.test.suite.afterinit2.app;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.After;
import ch.usi.dag.disl.Before;
import ch.usi.dag.disl.AfterInitBodyMarker;
......
package ch.usi.dag.disl.test.suite.afterinit2.instr;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.After;
import ch.usi.dag.disl.Before;
import ch.usi.dag.disl.AfterInitBodyMarker;
import ch.usi.dag.disl.ClassStaticContext;
import ch.usi.dag.disl.MethodStaticContext;
......
package ch.usi.dag.disl.test.suite.args.instr;
import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.AfterReturning;
import ch.usi.dag.disl.BodyMarker;
import ch.usi.dag.disl.processorcontext.ArgumentProcessorContext;
import ch.usi.dag.disl.processorcontext.ArgumentProcessorMode;
......
package ch.usi.dag.disl.test.suite.bbmarker.instr;
import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.AfterReturning;
import ch.usi.dag.disl.Before;
import ch.usi.dag.disl.BasicBlockMarker;
import ch.usi.dag.disl.PreciseBasicBlockMarker;
import ch.usi.dag.disl.BasicBlockStaticContext;
......
package ch.usi.dag.disl.test.suite.bodymarker.instr;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.After;
import ch.usi.dag.disl.AfterReturning;
import ch.usi.dag.disl.Before;
import ch.usi.dag.disl.BodyMarker;
public class DiSLClass {
......
package ch.usi.dag.disl.test.suite.bytecodemarker.instr;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.Before;
import ch.usi.dag.disl.BytecodeMarker;
import ch.usi.dag.disl.InstructionStaticContext;
......
package ch.usi.dag.disl.test.suite.cflow.instr;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.ThreadLocal;
import ch.usi.dag.disl.Before;
import ch.usi.dag.disl.After;
import ch.usi.dag.disl.ThreadLocal;
import ch.usi.dag.disl.BodyMarker;
import ch.usi.dag.disl.MethodStaticContext;
......
package ch.usi.dag.disl.test.suite.classinfo.instr;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.Before;
import ch.usi.dag.disl.BodyMarker;
import ch.usi.dag.disl.ClassStaticContext;
......
......@@ -2,7 +2,7 @@ package ch.usi.dag.disl.test.suite.dispatch.instr;