List of usage examples for org.objectweb.asm Opcodes ACC_INTERFACE
int ACC_INTERFACE
To view the source code for org.objectweb.asm Opcodes ACC_INTERFACE.
Click Source Link
From source file:org.evosuite.instrumentation.CreateClassResetClassAdapter.java
License:Open Source License
/** {@inheritDoc} */ @Override//from w w w . ja v a2s. c om public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { super.visit(version, access, name, signature, superName, interfaces); isInterface = ((access & Opcodes.ACC_INTERFACE) == Opcodes.ACC_INTERFACE); }
From source file:org.evosuite.instrumentation.MethodCallReplacementClassAdapter.java
License:Open Source License
@Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {/*from w w w. java 2 s . c o m*/ String superNameWithDots = superName.replace('/', '.'); superClassName = superNameWithDots; if ((access & Opcodes.ACC_INTERFACE) == Opcodes.ACC_INTERFACE) isInterface = true; if (MockList.shouldBeMocked(superNameWithDots)) { Class<?> mockSuperClass = MockList.getMockClass(superNameWithDots); String mockSuperClassName = mockSuperClass.getCanonicalName().replace('.', '/'); super.visit(version, access, name, signature, mockSuperClassName, interfaces); } else { super.visit(version, access, name, signature, superName, interfaces); } }
From source file:org.evosuite.instrumentation.PurityAnalysisClassVisitor.java
License:Open Source License
@Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {/* w w w.ja v a2 s . com*/ if ((access & Opcodes.ACC_INTERFACE) == Opcodes.ACC_INTERFACE) { visitingInterface = true; } super.visit(version, access, name, signature, superName, interfaces); }
From source file:org.evosuite.runtime.instrumentation.CreateClassResetClassAdapter.java
License:Open Source License
/** * Detects if the current class is an anonymous class *///from www . j a v a 2 s . co m @Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { super.visit(version, access, name, signature, superName, interfaces); isInterface = ((access & Opcodes.ACC_INTERFACE) == Opcodes.ACC_INTERFACE); if (ANONYMOUS_MATCHER1.matcher(name).matches()) { isAnonymous = true; } if (superName.equals(java.lang.Enum.class.getName().replace(".", "/"))) { isEnum = true; } }
From source file:org.evosuite.runtime.instrumentation.MethodCallReplacementClassAdapter.java
License:Open Source License
@Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {// w w w.ja v a 2 s . c om String superNameWithDots = superName.replace('/', '.'); superClassName = superNameWithDots; if ((access & Opcodes.ACC_INTERFACE) == Opcodes.ACC_INTERFACE) isInterface = true; else { /* FIXME: this should be moved in its own adapter, because it is not executed if we do only reset of static state and no mocking */ boolean found = false; String instrumentedInterface = InstrumentedClass.class.getCanonicalName().replace('.', '/'); for (String interf : interfaces) { if (interf.equals(instrumentedInterface)) found = true; } if (!found) { logger.info("Adding mock interface to class " + name); String[] mockedInterfaces = Arrays.copyOf(interfaces, interfaces.length + 1); mockedInterfaces[interfaces.length] = InstrumentedClass.class.getCanonicalName().replace('.', '/'); interfaces = mockedInterfaces; } } if (MockList.shouldBeMocked(superNameWithDots)) { /* * TODO: likely need to suppress the change of superclass if !canChangeSignature */ Class<?> mockSuperClass = MockList.getMockClass(superNameWithDots); String mockSuperClassName = mockSuperClass.getCanonicalName().replace('.', '/'); super.visit(version, access, name, signature, mockSuperClassName, interfaces); } else { super.visit(version, access, name, signature, superName, interfaces); } }
From source file:org.evosuite.setup.InheritanceTreeGenerator.java
License:Open Source License
@SuppressWarnings("unchecked") private static void analyzeClassNode(InheritanceTree inheritanceTree, ClassNode cn, boolean onlyPublic) { logger.info("Analyzing class {}", cn.name); // Don't load classes already seen from a different CP entry if (inheritanceTree.hasClass(cn.name)) return;//w w w . ja v a 2 s . co m if ((Opcodes.ACC_INTERFACE & cn.access) != Opcodes.ACC_INTERFACE) { for (Object m : cn.methods) { MethodNode mn = (MethodNode) m; inheritanceTree.addAnalyzedMethod(cn.name, mn.name, mn.desc); } if ((Opcodes.ACC_ABSTRACT & cn.access) == Opcodes.ACC_ABSTRACT) { inheritanceTree.registerAbstractClass(cn.name); } } else { inheritanceTree.registerInterface(cn.name); } if (onlyPublic) { if ((cn.access & Opcodes.ACC_PUBLIC) == 0) { return; } // } else { // if (!canUse(cn)) { // logger.info("Cannot use "+cn.name); // return; // } } if (cn.superName != null) inheritanceTree.addSuperclass(cn.name, cn.superName, cn.access); List<String> interfaces = cn.interfaces; for (String interfaceName : interfaces) { inheritanceTree.addInterface(cn.name, interfaceName); } }
From source file:org.evosuite.symbolic.instrument.AccessFlags.java
License:Open Source License
static boolean isInterface(int access) { return is(access, Opcodes.ACC_INTERFACE); }
From source file:org.evosuite.testcarver.instrument.Instrumenter.java
License:Open Source License
@SuppressWarnings("unchecked") public void transformClassNode(ClassNode cn, final String internalClassName) { if (!TransformerUtil.isClassConsideredForInstrumentation(internalClassName)) { logger.debug("Class {} has not been instrumented because its name is on the blacklist", internalClassName);//from w ww .j a v a 2 s. c o m return; } // consider only public and protected classes which are not interfaces if ((cn.access & Opcodes.ACC_INTERFACE) != 0) { return; } // No private if ((cn.access & Opcodes.ACC_PRIVATE) != 0) { // TODO: Why is this not detecting $DummyIntegrator? logger.debug("Ignoring private class {}", cn.name); return; } String packageName = internalClassName.replace('/', '.'); if (packageName.contains(".")) packageName = packageName.substring(0, packageName.lastIndexOf('.')); // ASM has some problem with the access of inner classes // so we check if the inner class name is the current class name // and if so, check if the inner class is actually accessible List<InnerClassNode> in = cn.innerClasses; for (InnerClassNode inc : in) { if (cn.name.equals(inc.name)) { logger.info("ASM Bug: Inner class equals class."); if ((inc.access & Opcodes.ACC_PROTECTED) == Opcodes.ACC_PROTECTED) { if (!Properties.CLASS_PREFIX.equals(packageName)) { return; } } if ((inc.access & Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE) { return; } logger.debug("Can use inner class {}", inc.name); } } logger.info("Checking package {} for class {}", packageName, cn.name); // Protected/default only if in same package if ((cn.access & Opcodes.ACC_PUBLIC) == 0) { if (!Properties.CLASS_PREFIX.equals(packageName)) { logger.info("Not using protected/default class because package name does not match"); return; } else { logger.info("Using protected/default class because package name matches"); } } /* if( (cn.access & Opcodes.ACC_PUBLIC) == 0 && (cn.access & Opcodes.ACC_PROTECTED) == 0) { return; } */ final ArrayList<MethodNode> wrappedMethods = new ArrayList<MethodNode>(); MethodNode methodNode; final Iterator<MethodNode> methodIter = cn.methods.iterator(); while (methodIter.hasNext()) { methodNode = methodIter.next(); // consider only public methods which are not abstract or native if (!TransformerUtil.isPrivate(methodNode.access) && !TransformerUtil.isAbstract(methodNode.access) && !TransformerUtil.isNative(methodNode.access) && !methodNode.name.equals("<clinit>")) { if (!TransformerUtil.isPublic(methodNode.access)) { //if(!Properties.CLASS_PREFIX.equals(packageName)) { transformWrapperCalls(methodNode); continue; //} } if (methodNode.name.equals("<init>")) { if (TransformerUtil.isAbstract(cn.access)) { // We cannot invoke constructors of abstract classes directly continue; } this.addFieldRegistryRegisterCall(methodNode); } this.instrumentPUTXXXFieldAccesses(cn, internalClassName, methodNode); this.instrumentGETXXXFieldAccesses(cn, internalClassName, methodNode); this.instrumentMethod(cn, internalClassName, methodNode, wrappedMethods); } else { transformWrapperCalls(methodNode); } } final int numWM = wrappedMethods.size(); for (int i = 0; i < numWM; i++) { cn.methods.add(wrappedMethods.get(i)); } TraceClassVisitor tcv = new TraceClassVisitor(new PrintWriter(System.err)); cn.accept(tcv); }
From source file:org.evosuite.testcarver.instrument.TransformerUtil.java
License:Open Source License
public static boolean isClassAccessible(final ClassNode cn) { return (cn.access & Opcodes.ACC_INTERFACE) == 0 && (((cn.access & Opcodes.ACC_PUBLIC) != 0) || ((cn.access & Opcodes.ACC_PROTECTED) != 0)); }
From source file:org.freud.analysed.classbytecode.parser.asm.AsmClassByteCode.java
License:Apache License
@Override public boolean isInterface() { return isAccessModifier(Opcodes.ACC_INTERFACE); }