01: //
02: // This file is part of the prose package.
03: //
04: // The contents of this file are subject to the Mozilla Public License
05: // Version 1.1 (the "License"); you may not use this file except in
06: // compliance with the License. You may obtain a copy of the License at
07: // http://www.mozilla.org/MPL/
08: //
09: // Software distributed under the License is distributed on an "AS IS" basis,
10: // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11: // for the specific language governing rights and limitations under the
12: // License.
13: //
14: // The Original Code is prose.
15: //
16: // The Initial Developers of the Original Code are Angela Nicoara and Gerald Linhofer.
17: // All Rights Reserved.
18: //
19: // Contributor(s):
20: // $Id$
21: // =================================================================
22: //
23: // (history at the end)
24: //
25:
26: package ch.ethz.prose.crosscut;
27:
28: import java.lang.reflect.Method;
29: import java.lang.reflect.Modifier;
30:
31: import ch.ethz.jvmai.CodeJoinPoint;
32: import ch.ethz.prose.engine.JoinPointRequest;
33: import ch.ethz.prose.engine.MethodRedefineRequest;
34:
35: /**
36: * A specializer for method redefine cuts.
37: *
38: * @version $Revision$
39: * @author Angela Nicoara
40: * @author Gerald Linhofer
41: */
42: public class MethodRedefineCutSpecializer extends MethodCutSpecializer {
43:
44: private static final long serialVersionUID = 3257567312931272241L;
45:
46: public MethodRedefineCutSpecializer(
47: MethodCutSignaturePattern adviceSignature) {
48: super (adviceSignature);
49: mayFilterStaticallyMask = MASK_METHOD_REDEFINE_JP;
50: canFilterStaticallyMask = MASK_METHOD_REDEFINE_JP;
51: }
52:
53: protected boolean doIsSpecialRequest(JoinPointRequest jpr) {
54: Class targetClass = null;
55: Method methodToExecute = null;
56: int methodModifiers = 0;
57:
58: if (jpr instanceof MethodRedefineRequest) {
59: targetClass = ((MethodRedefineRequest) jpr)
60: .getTargetClass();
61: methodToExecute = ((MethodRedefineRequest) jpr).getMethod();
62: }
63:
64: methodModifiers = methodToExecute.getModifiers();
65:
66: return ((methodModifiers & Modifier.ABSTRACT) != Modifier.ABSTRACT)
67: && ((methodModifiers & Modifier.NATIVE) != Modifier.NATIVE)
68: && adviceSignature.matchesTarget(targetClass)
69: && adviceSignature.matchesParameters(methodToExecute)
70: && methodToExecute.getReturnType().isAssignableFrom(
71: adviceSignature.methodObj.getReturnType());
72: }
73:
74: protected boolean doIsSpecialEvent(CodeJoinPoint jpe) {
75: throw new RuntimeException("Not supported");
76: }
77:
78: }
79:
80: //======================================================================
81: //
82: // $Log$
83: //
|