
com.fitbur.testify.analyzer.CutClassAnalyzer Maven / Gradle / Ivy
/*
* Copyright 2015 Sharmarke Aden.
*
* 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.fitbur.testify.analyzer;
import com.fitbur.asm.ClassVisitor;
import com.fitbur.asm.MethodVisitor;
import static com.fitbur.asm.Opcodes.ASM5;
import com.fitbur.asm.Type;
import static com.fitbur.asm.Type.getMethodType;
import static com.fitbur.guava.common.base.Preconditions.checkState;
import com.fitbur.testify.TestContext;
import com.fitbur.testify.descriptor.CutDescriptor;
import com.fitbur.testify.descriptor.ParameterDescriptor;
import static java.lang.Class.forName;
import java.lang.reflect.Constructor;
import java.lang.reflect.Parameter;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import static java.util.stream.Stream.of;
/**
* A class visitor implementation that performs analysis on the class under
* test.
*
* @author saden
*/
public class CutClassAnalyzer extends ClassVisitor {
public static final String CONSTRUCTOR_NAME = "";
private final TestContext context;
private int constCount = 0;
public CutClassAnalyzer(TestContext context) {
super(ASM5);
this.context = context;
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (CONSTRUCTOR_NAME.equals(name)) {
constCount++;
AccessController.doPrivileged((PrivilegedAction
© 2015 - 2025 Weber Informatics LLC | Privacy Policy