Commit db7b0734 authored by Lubomir Bulej's avatar Lubomir Bulej
Browse files

DiSLException: added a constructor for formatted messages.

DynamicContextException: renamed to InvalidContextUsageException to better fit its usage.
DiSL, Weaver, WeavingCode: updated to reflect the change.
parent e5d304a4
...@@ -25,7 +25,7 @@ import ch.usi.dag.disl.classparser.ClassParser; ...@@ -25,7 +25,7 @@ import ch.usi.dag.disl.classparser.ClassParser;
import ch.usi.dag.disl.exception.DiSLException; import ch.usi.dag.disl.exception.DiSLException;
import ch.usi.dag.disl.exception.DiSLIOException; import ch.usi.dag.disl.exception.DiSLIOException;
import ch.usi.dag.disl.exception.DiSLInMethodException; import ch.usi.dag.disl.exception.DiSLInMethodException;
import ch.usi.dag.disl.exception.DynamicContextException; import ch.usi.dag.disl.exception.InvalidContextUsageException;
import ch.usi.dag.disl.exception.InitException; import ch.usi.dag.disl.exception.InitException;
import ch.usi.dag.disl.exception.ManifestInfoException; import ch.usi.dag.disl.exception.ManifestInfoException;
import ch.usi.dag.disl.exception.MarkerException; import ch.usi.dag.disl.exception.MarkerException;
...@@ -211,7 +211,7 @@ public class DiSL { ...@@ -211,7 +211,7 @@ public class DiSL {
private boolean instrumentMethod( private boolean instrumentMethod(
final ClassNode classNode, final MethodNode methodNode final ClassNode classNode, final MethodNode methodNode
) throws ReflectionException, StaticContextGenException, ) throws ReflectionException, StaticContextGenException,
ProcessorException, DynamicContextException, MarkerException { ProcessorException, InvalidContextUsageException, MarkerException {
// skip abstract methods // skip abstract methods
if ((methodNode.access & Opcodes.ACC_ABSTRACT) != 0) { if ((methodNode.access & Opcodes.ACC_ABSTRACT) != 0) {
......
...@@ -19,4 +19,9 @@ public abstract class DiSLException extends Exception { ...@@ -19,4 +19,9 @@ public abstract class DiSLException extends Exception {
public DiSLException(Throwable cause) { public DiSLException(Throwable cause) {
super(cause); super(cause);
} }
public DiSLException (final String format, final Object ... args) {
super (String.format (format, args));
}
} }
package ch.usi.dag.disl.exception;
public class DynamicContextException extends DiSLException {
private static final long serialVersionUID = -4897273691513425444L;
public DynamicContextException() {
super();
}
public DynamicContextException(String message, Throwable cause) {
super(message, cause);
}
public DynamicContextException(String message) {
super(message);
}
public DynamicContextException(Throwable cause) {
super(cause);
}
}
package ch.usi.dag.disl.exception;
/**
* Thrown when an illegal context usage is detected. This usually happens when a
* literal argument is expected in a static or dynamic context method
* invocation, but something else is found instead.
*/
public class InvalidContextUsageException extends DiSLException {
private static final long serialVersionUID = -4897273691513425444L;
public InvalidContextUsageException () {
super ();
}
public InvalidContextUsageException (String message) {
super (message);
}
public InvalidContextUsageException (final String format, final Object ... args) {
super (format, args);
}
}
...@@ -19,7 +19,7 @@ import ch.usi.dag.disl.annotation.AfterReturning; ...@@ -19,7 +19,7 @@ import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.annotation.AfterThrowing; import ch.usi.dag.disl.annotation.AfterThrowing;
import ch.usi.dag.disl.annotation.Before; import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.annotation.SyntheticLocal.Initialize; import ch.usi.dag.disl.annotation.SyntheticLocal.Initialize;
import ch.usi.dag.disl.exception.DynamicContextException; import ch.usi.dag.disl.exception.InvalidContextUsageException;
import ch.usi.dag.disl.localvar.SyntheticLocalVar; import ch.usi.dag.disl.localvar.SyntheticLocalVar;
import ch.usi.dag.disl.processor.generator.PIResolver; import ch.usi.dag.disl.processor.generator.PIResolver;
import ch.usi.dag.disl.snippet.Shadow; import ch.usi.dag.disl.snippet.Shadow;
...@@ -213,7 +213,7 @@ public class Weaver { ...@@ -213,7 +213,7 @@ public class Weaver {
private static void insert(MethodNode methodNode, private static void insert(MethodNode methodNode,
SCGenerator staticInfoHolder, PIResolver piResolver, SCGenerator staticInfoHolder, PIResolver piResolver,
WeavingInfo info, Snippet snippet, SnippetCode code, Shadow shadow, WeavingInfo info, Snippet snippet, SnippetCode code, Shadow shadow,
AbstractInsnNode loc) throws DynamicContextException { AbstractInsnNode loc) throws InvalidContextUsageException {
// exception handler will discard the stack and push the // exception handler will discard the stack and push the
// exception object. Thus, before entering this snippet, // exception object. Thus, before entering this snippet,
...@@ -240,7 +240,7 @@ public class Weaver { ...@@ -240,7 +240,7 @@ public class Weaver {
Map<Snippet, List<Shadow>> snippetMarkings, Map<Snippet, List<Shadow>> snippetMarkings,
List<SyntheticLocalVar> syntheticLocalVars, List<SyntheticLocalVar> syntheticLocalVars,
SCGenerator staticInfoHolder, PIResolver piResolver) SCGenerator staticInfoHolder, PIResolver piResolver)
throws DynamicContextException { throws InvalidContextUsageException {
WeavingInfo info = new WeavingInfo(classNode, methodNode, WeavingInfo info = new WeavingInfo(classNode, methodNode,
snippetMarkings); snippetMarkings);
......
...@@ -24,7 +24,7 @@ import ch.usi.dag.disl.classcontext.ClassContext; ...@@ -24,7 +24,7 @@ import ch.usi.dag.disl.classcontext.ClassContext;
import ch.usi.dag.disl.coderep.Code; import ch.usi.dag.disl.coderep.Code;
import ch.usi.dag.disl.dynamiccontext.DynamicContext; import ch.usi.dag.disl.dynamiccontext.DynamicContext;
import ch.usi.dag.disl.exception.DiSLFatalException; import ch.usi.dag.disl.exception.DiSLFatalException;
import ch.usi.dag.disl.exception.DynamicContextException; import ch.usi.dag.disl.exception.InvalidContextUsageException;
import ch.usi.dag.disl.processor.generator.PIResolver; import ch.usi.dag.disl.processor.generator.PIResolver;
import ch.usi.dag.disl.processor.generator.ProcInstance; import ch.usi.dag.disl.processor.generator.ProcInstance;
import ch.usi.dag.disl.processor.generator.ProcMethodInstance; import ch.usi.dag.disl.processor.generator.ProcMethodInstance;
...@@ -145,7 +145,7 @@ public class WeavingCode { ...@@ -145,7 +145,7 @@ public class WeavingCode {
} }
} }
private void preFixDynamicInfoCheck() throws DynamicContextException { private void preFixDynamicInfoCheck() throws InvalidContextUsageException {
for (AbstractInsnNode instr : Insns.selectAll (iList)) { for (AbstractInsnNode instr : Insns.selectAll (iList)) {
// it is invocation... // it is invocation...
...@@ -182,7 +182,7 @@ public class WeavingCode { ...@@ -182,7 +182,7 @@ public class WeavingCode {
break; break;
default: default:
throw new DynamicContextException("In snippet " throw new InvalidContextUsageException("In snippet "
+ snippet.getOriginClassName() + "." + snippet.getOriginClassName() + "."
+ snippet.getOriginMethodName() + snippet.getOriginMethodName()
+ " - pass the first (pos)" + " - pass the first (pos)"
...@@ -192,7 +192,7 @@ public class WeavingCode { ...@@ -192,7 +192,7 @@ public class WeavingCode {
// second operand test // second operand test
if (! AsmHelper.isTypeConstLoadInsn (secondOperand)) { if (! AsmHelper.isTypeConstLoadInsn (secondOperand)) {
throw new DynamicContextException("In snippet " throw new InvalidContextUsageException("In snippet "
+ snippet.getOriginClassName() + "." + snippet.getOriginClassName() + "."
+ snippet.getOriginMethodName() + snippet.getOriginMethodName()
+ " - pass the second (type)" + " - pass the second (type)"
...@@ -221,7 +221,7 @@ public class WeavingCode { ...@@ -221,7 +221,7 @@ public class WeavingCode {
// NOTE that if the user requests for the stack value, some store // NOTE that if the user requests for the stack value, some store
// instructions will be inserted to the target method, and new local slot // instructions will be inserted to the target method, and new local slot
// will be used for storing this. // will be used for storing this.
public void fixDynamicInfo(boolean throwing) throws DynamicContextException { public void fixDynamicInfo(boolean throwing) throws InvalidContextUsageException {
preFixDynamicInfoCheck(); preFixDynamicInfoCheck();
...@@ -303,7 +303,7 @@ public class WeavingCode { ...@@ -303,7 +303,7 @@ public class WeavingCode {
// index should be less than the stack height // index should be less than the stack height
if (operand >= basicframe.getStackSize() || operand < 0) { if (operand >= basicframe.getStackSize() || operand < 0) {
throw new DynamicContextException("In snippet " throw new InvalidContextUsageException("In snippet "
+ snippet.getOriginClassName() + "." + snippet.getOriginClassName() + "."
+ snippet.getOriginMethodName() + snippet.getOriginMethodName()
+ " - trying to access the stack item NO." + " - trying to access the stack item NO."
...@@ -316,7 +316,7 @@ public class WeavingCode { ...@@ -316,7 +316,7 @@ public class WeavingCode {
operand).getType(); operand).getType();
if (t.getSort() != targetType.getSort()) { if (t.getSort() != targetType.getSort()) {
throw new DynamicContextException("In snippet " throw new InvalidContextUsageException("In snippet "
+ snippet.getOriginClassName() + "." + snippet.getOriginClassName() + "."
+ snippet.getOriginMethodName() + snippet.getOriginMethodName()
+ " - trying to access the stack item NO." + " - trying to access the stack item NO."
...@@ -354,7 +354,7 @@ public class WeavingCode { ...@@ -354,7 +354,7 @@ public class WeavingCode {
// index should be less than the size of local variables // index should be less than the size of local variables
if (operand >= args || operand < 0) { if (operand >= args || operand < 0) {
throw new DynamicContextException("In snippet " throw new InvalidContextUsageException("In snippet "
+ snippet.getOriginClassName() + "." + snippet.getOriginClassName() + "."
+ snippet.getOriginMethodName() + snippet.getOriginMethodName()
+ " - trying to access the method argument NO." + " - trying to access the method argument NO."
...@@ -368,7 +368,7 @@ public class WeavingCode { ...@@ -368,7 +368,7 @@ public class WeavingCode {
if (t.getSort() != targetType.getSort()) { if (t.getSort() != targetType.getSort()) {
throw new DynamicContextException("In snippet " throw new InvalidContextUsageException("In snippet "
+ snippet.getOriginClassName() + "." + snippet.getOriginClassName() + "."
+ snippet.getOriginMethodName() + snippet.getOriginMethodName()
+ " - trying to access the method argument NO." + " - trying to access the method argument NO."
...@@ -393,7 +393,7 @@ public class WeavingCode { ...@@ -393,7 +393,7 @@ public class WeavingCode {
// index should be less than the size of local variables // index should be less than the size of local variables
if (operand >= basicframe.getLocals() || operand < 0) { if (operand >= basicframe.getLocals() || operand < 0) {
throw new DynamicContextException("In snippet " throw new InvalidContextUsageException("In snippet "
+ snippet.getOriginClassName() + "." + snippet.getOriginClassName() + "."
+ snippet.getOriginMethodName() + snippet.getOriginMethodName()
+ " - trying to access the local variable NO." + " - trying to access the local variable NO."
...@@ -407,7 +407,7 @@ public class WeavingCode { ...@@ -407,7 +407,7 @@ public class WeavingCode {
if (t.getSort() != targetType.getSort()) { if (t.getSort() != targetType.getSort()) {
throw new DynamicContextException("In snippet " throw new InvalidContextUsageException("In snippet "
+ snippet.getOriginClassName() + "." + snippet.getOriginClassName() + "."
+ snippet.getOriginMethodName() + snippet.getOriginMethodName()
+ " - trying to access the local variable NO." + " - trying to access the local variable NO."
...@@ -865,7 +865,7 @@ public class WeavingCode { ...@@ -865,7 +865,7 @@ public class WeavingCode {
} }
public void transform(SCGenerator staticInfoHolder, PIResolver piResolver, boolean throwing) public void transform(SCGenerator staticInfoHolder, PIResolver piResolver, boolean throwing)
throws DynamicContextException { throws InvalidContextUsageException {
fixProcessor(piResolver); fixProcessor(piResolver);
fixProcessorInfo(); fixProcessorInfo();
fixStaticInfo(staticInfoHolder); fixStaticInfo(staticInfoHolder);
......
Supports Markdown
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