public static MethodCallReplacementCache getInstance() { if (instance == null) { instance = new MethodCallReplacementCache(); } return instance; }
/** * Check if we can instrument the given class * * @param className * a {@link java.lang.String} object. * @return a boolean. */ public static boolean checkIfCanInstrument(String className) { return RuntimeInstrumentation.checkIfCanInstrument(className); }
public EvoClassLoader() { this(new RuntimeInstrumentation()); }
private MethodCallReplacementCache() { if (RuntimeSettings.mockJVMNonDeterminism) { // java.lang.* addJavaLangCalls(); // javax.swing.JComponent.getPreferredSize() addReplacementCall(new MethodCallReplacement("javax/swing/JComponent", "getPreferredSize", "()Ljava/awt/Dimension;", Opcodes.INVOKEVIRTUAL, PackageInfo.getNameWithSlash(org.evosuite.runtime.mock.javax.swing.MockJComponent.class), "getPreferredSize", "()Ljava/awt/Dimension;", true, false)); addExtraceExceptionReplacements(); } handleMockList(); }
public void tagBranchExit() { Label dummyTag = new AnnotatedLabel(false, false); // dummyTag.info = Boolean.FALSE; super.visitLabel(dummyTag); }
private static void setupRuntimeProperties(){ RuntimeSettings.useVFS = Properties.VIRTUAL_FS; RuntimeSettings.mockJVMNonDeterminism = Properties.REPLACE_CALLS; RuntimeSettings.mockSystemIn = Properties.REPLACE_SYSTEM_IN; RuntimeSettings.mockGUI = Properties.REPLACE_GUI; RuntimeSettings.sandboxMode = Properties.SANDBOX_MODE; RuntimeSettings.maxNumberOfThreads = Properties.MAX_STARTED_THREADS; RuntimeSettings.maxNumberOfIterationsPerLoop = Properties.MAX_LOOP_ITERATIONS; RuntimeSettings.useVNET = Properties.VIRTUAL_NET; RuntimeSettings.useSeparateClassLoader = Properties.USE_SEPARATE_CLASSLOADER; RuntimeSettings.className = Properties.TARGET_CLASS; RuntimeSettings.useJEE = Properties.JEE; RuntimeSettings.applyUIDTransformation = true; RuntimeSettings.isRunningASystemTest = Properties.IS_RUNNING_A_SYSTEM_TEST; MethodCallReplacementCache.resetSingleton(); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) { MethodNode mn = new AnnotatedMethodNode(access, name, desc, signature, exceptions); methods.add(mn); return mn; } }
/** {@inheritDoc} */ @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if(name.equals("hashCode")) definesHashCode = true; MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); if(name.equals("<init>")) { mv = new RegisterObjectForDeterministicHashCodeVisitor(mv, access, name, desc); } return new MethodCallReplacementMethodAdapter(mv, className, superClassName, name, access, desc); }
@Override public void visitJumpInsn(int opcode, Label label) { addInstrumentation(); //add instrumentation before of the jump super.visitJumpInsn(opcode, label); }
public void setRetransformingMode(boolean on){ instrumenter.setRetransformingMode(on); }
@Override public void visitJumpInsn(int opcode, Label label) { addInstrumentation(); //add instrumentation before of the jump super.visitJumpInsn(opcode, label); }
@Override public void visitLabel(Label label) { if (label instanceof AnnotatedLabel) { AnnotatedLabel aLabel = (AnnotatedLabel) label; if (aLabel.isStartTag()) { inInstrumentation = true; } else { inInstrumentation = false; } } super.visitLabel(label); }
public void tagBranch() { Label dummyTag = new AnnotatedLabel(false, true); // dummyTag.info = Boolean.TRUE; super.visitLabel(dummyTag); }
public TransformerForTests(){ active = false; instrumenter = new RuntimeInstrumentation(); instrumentedClasses = new LinkedHashSet<>(); }
@Override public void visitLineNumber(int line, Label start) { super.visitLineNumber(line, start); addInstrumentation(); }
public void tagBranchExit() { Label dummyTag = new AnnotatedLabel(false, false); // dummyTag.info = Boolean.FALSE; super.visitLabel(dummyTag); }
/** {@inheritDoc} */ @Override public void visitLookupSwitchInsn(Label arg0, int[] arg1, Label[] arg2) { mv1.visitLookupSwitchInsn(arg0, arg1, arg2); Label[] arg2Copy = new Label[arg2.length]; for (int i = 0; i < arg2.length; i++) arg2Copy[i] = getLabel(arg2[i]); mv2.visitLookupSwitchInsn(getLabel(arg0), arg1, arg2Copy); }
/** {@inheritDoc} */ @Override public void visitTableSwitchInsn(int arg0, int arg1, Label arg2, Label... arg3) { mv1.visitTableSwitchInsn(arg0, arg1, arg2, arg3); Label[] arg3Copy = new Label[arg3.length]; for (int i = 0; i < arg3.length; i++) arg3Copy[i] = getLabel(arg3[i]); mv2.visitTableSwitchInsn(arg0, arg1, getLabel(arg2), arg3Copy); }