use of org.evosuite.runtime.util.ComputeClassWriter in project evosuite by EvoSuite.
the class ComputeClassWriter_ESTest method test4.
@Test
public void test4() throws Throwable {
ComputeClassWriter computeClassWriter0 = new ComputeClassWriter((-32768));
// Undeclared exception!
try {
computeClassWriter0.getCommonSuperClass("", "37SFrh2");
fail("Expecting exception: RuntimeException");
} catch (RuntimeException e) {
//
// Class not found: : shaded.org.evosuite.runtime.mock.java.lang.MockThrowable: Class not found
//
assertThrownBy("org.evosuite.runtime.util.ComputeClassWriter", e);
}
}
use of org.evosuite.runtime.util.ComputeClassWriter in project evosuite by EvoSuite.
the class ComputeClassWriter_ESTest method test0.
@Test
public void test0() throws Throwable {
ComputeClassWriter computeClassWriter0 = new ComputeClassWriter((-2878));
String string0 = computeClassWriter0.getCommonSuperClass("java/lang/Class", "java/lang/Throwable");
assertEquals("java/lang/Object", string0);
}
use of org.evosuite.runtime.util.ComputeClassWriter in project evosuite by EvoSuite.
the class RuntimeInstrumentation method transformBytes.
public byte[] transformBytes(ClassLoader classLoader, String className, ClassReader reader, boolean skipInstrumentation) {
String classNameWithDots = className.replace('/', '.');
if (!checkIfCanInstrument(classNameWithDots)) {
throw new IllegalArgumentException("Should not transform a shared class (" + classNameWithDots + ")! Load by parent (JVM) classloader.");
}
int asmFlags = ClassWriter.COMPUTE_FRAMES;
ClassWriter writer = new ComputeClassWriter(asmFlags);
ClassVisitor cv = writer;
if (!skipInstrumentation) {
if (RuntimeSettings.resetStaticState && !retransformingMode) {
/*
* FIXME: currently reset does add a new method, but that does no work
* when retransformingMode :(
*/
CreateClassResetClassAdapter resetClassAdapter = new CreateClassResetClassAdapter(cv, className, true);
cv = resetClassAdapter;
}
if (RuntimeSettings.isUsingAnyMocking()) {
cv = new MethodCallReplacementClassAdapter(cv, className, !retransformingMode);
}
cv = new KillSwitchClassAdapter(cv);
cv = new RemoveFinalClassAdapter(cv);
if (RuntimeSettings.maxNumberOfIterationsPerLoop >= 0) {
cv = new LoopCounterClassAdapter(cv);
}
}
ClassNode cn = new AnnotatedClassNode();
int readFlags = ClassReader.SKIP_FRAMES;
reader.accept(cn, readFlags);
cv = new JSRInlinerClassVisitor(cv);
try {
cn.accept(cv);
} catch (Throwable ex) {
logger.error("Error while instrumenting class " + className + ": " + ex.getMessage(), ex);
}
return writer.toByteArray();
}
Aggregations