// Copyright 2021 Code Intelligence GmbH // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package com.code_intelligence.jazzer.api; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.invoke.MethodType; /** * Registers this method as a hook that should run after the method * specified by the annotation parameters has returned. *

* This method will be called after every call to the target method and has * access to its return value. The target method is specified by * {@link #targetClassName()} and {@link #targetMethod()}. In case of an * overloaded method, {@link #targetMethodDescriptor()} can be used to restrict * the application of the hook to a particular overload. *

* The signature of the annotated method must be as follows (this does not * restrict the method name and parameter names, which are arbitrary), * depending on the value of {@link #type()}: * *

*
{@link HookType#BEFORE} *
*
{@code
 * public static void hook(MethodHandle method, Object thisObject, Object[] arguments, int hookId)
 * }
* Arguments: *

* *
{@link HookType#REPLACE} *
*
{@code
 * public static Object hook(MethodHandle method, Object thisObject, Object[] arguments, int hookId)
 * }
* The return type may alternatively be taken to be the exact return type of * target method or a wrapper type thereof. The returned object will be casted * and unwrapped automatically. *

* Arguments: *

*

* Return value: the value that should take the role of the value the target * method would have returned * *

{@link HookType#AFTER} *
*
{@code
 * public static void hook(MethodHandle method, Object thisObject, Object[] arguments, int hookId,
 * Object returnValue)
 * }
* Arguments: *