All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.code_intelligence.jazzer.mutation.api.InPlaceMutator Maven / Gradle / Ivy

There is a newer version: 0.22.1
Show newest version
/*
 * Copyright 2023 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.mutation.api;

/**
 * Knows how to initialize and mutate (parts of) an existing object of type {@code T} in place and
 * how to incorporate (cross over) parts of another object of the same type.
 *
 * 

Certain types, such as immutable and primitive types, can not be mutated in place. For * example, {@link java.util.List} can be mutated in place whereas {@link String} and {@code int} * can't. In such cases, use {@link ValueMutator} instead. * *

Implementations * *

    *
  • MAY weakly associate mutable state with the identity (not equality class) of objects they * have been passed as arguments or returned from initialization functions; *
  • MAY assume that they are only passed arguments that they have initialized or mutated; *
  • SHOULD use {@link com.code_intelligence.jazzer.mutation.support.WeakIdentityHashMap} for * this purpose; *
  • MUST otherwise be deeply immutable; *
  • SHOULD override {@link Object#toString()} to return {@code * Debuggable.getDebugString(this)}. *
* * @param the reference type this mutator operates on */ public interface InPlaceMutator extends Debuggable { /** * Implementations * *
    *
  • MUST accept any mutable instance of {@code T}, not just those it creates itself. *
  • SHOULD, when called repeatedly, initialize the object in ways that are likely to be * distinct. *
*/ void initInPlace(T reference, PseudoRandom prng); /** * Implementations * *
    *
  • MUST ensure that {@code reference} does not {@link Object#equals(Object)} the state it * had prior to the call (if possible); *
  • MUST accept any mutable instance of {@code T}, not just those it creates itself. *
  • SHOULD, when called repeatedly, be able to eventually reach any valid state of the part * of {@code T} governed by this mutator; *
*/ void mutateInPlace(T reference, PseudoRandom prng); /** * Implementations * *
    *
  • MUST ensure that {@code reference} does not {@link Object#equals(Object)} the state it * had prior to the call (if possible); *
  • MUST accept any mutable instance of {@code T}, not just those it creates itself. *
  • MUST NOT mutate {@code otherReference} *
*/ void crossOverInPlace(T reference, T otherReference, PseudoRandom prng); /** * Whether the type {@code T} mutated by this mutator has a fixed size in memory. This information * can be used by mutators for collections of {@code T}s. * *

Examples of types with fixed size include primitive types, enums, and classes with only * primitive types and enums as members. */ boolean hasFixedSize(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy