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:net.sourceforge.cobertura.instrument.ClassInstrumenter.java
License:Open Source License
/** * @param name In the format/*w w w .j a va 2 s. c o m*/ * "net/sourceforge/cobertura/coverage/ClassInstrumenter" */ public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { this.myName = name.replace('/', '.'); this.classData = this.projectData.getOrCreateClassData(this.myName); this.classData.setContainsInstrumentationInfo(); // Do not attempt to instrument interfaces or classes that // have already been instrumented if (((access & Opcodes.ACC_INTERFACE) != 0) || arrayContains(interfaces, hasBeenInstrumented)) { super.visit(version, access, name, signature, superName, interfaces); } else { instrument = true; // // Flag this class as having been instrumented // String[] newInterfaces = new String[interfaces.length + 1]; // System.arraycopy(interfaces, 0, newInterfaces, 0, interfaces.length); // newInterfaces[newInterfaces.length - 1] = hasBeenInstrumented; super.visit(version, access, name, signature, superName, interfaces); } }
From source file:net.sourceforge.cobertura.instrument.pass2.BuildClassMapClassVisitor.java
License:GNU General Public License
/** * Stores in {@link #classMap} information of className and if the class should be instrumented ({@link #shouldBeInstrumented()}) *//*w w w .j av a 2s . c o m*/ @Override public void visit(int version, int access, String name, String signature, String parent, String[] interfaces) { classMap.setClassName(name); if ((access & Opcodes.ACC_INTERFACE) != 0) { toInstrument = false; } super.visit(version, access, name, signature, parent, interfaces); }
From source file:org.adjective.stout.writer.ByteCodeWriter.java
License:Apache License
private int getModifierCode(Set<ElementModifier> modifiers, Sort sort) { int code = (sort == Sort.INTERFACE ? Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT : 0); for (ElementModifier modifier : modifiers) { code |= modifier.getCode();//from ww w. j ava 2 s. c o m } return code; }
From source file:org.adjective.stout.writer.ByteCodeWriter.java
License:Apache License
private int getModifierCode(Set<ElementModifier> modifiers, MemberType type) { int code = getModifierCode(modifiers, (Sort) null); int illegal = Opcodes.ACC_ANNOTATION | Opcodes.ACC_BRIDGE | Opcodes.ACC_ENUM | Opcodes.ACC_INTERFACE | Opcodes.ACC_SUPER;/*from www. j av a 2s .com*/ switch (type) { case FIELD: illegal |= Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE | Opcodes.ACC_STRICT | Opcodes.ACC_SYNCHRONIZED; break; case METHOD: if (isBitSet(Opcodes.ACC_ABSTRACT, code)) { illegal |= Opcodes.ACC_NATIVE | Opcodes.ACC_STRICT | Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL; } break; } if (isBitSet(illegal, code)) { throw new IllegalStateException( "Illegal combination of modifier codes: " + code + " (illegal codes: " + illegal + ")"); } return code; }
From source file:org.apache.aries.proxy.impl.weaving.SyntheticSerialVerUIDAdder.java
License:Apache License
@Override public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { computeSVUID = (access & Opcodes.ACC_INTERFACE) == 0; super.visit(version, access, name, signature, superName, interfaces); }
From source file:org.apache.commons.javaflow.providers.asm3.ContinuableClassVisitor.java
License:Apache License
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {/*from w ww . ja v a 2 s. com*/ isInterface = (access & Opcodes.ACC_INTERFACE) != 0; className = name; classInfo = cciResolver.resolve(name, originalBytes); if (null == classInfo || classInfo.isClassProcessed() || StopException .__dirtyCheckSkipContinuationsOnClass(version, access, name, signature, superName, interfaces)) { skipEnchancing = true; // Must exit by throwing exception, otherwise NPE is possible in nested visitor throw StopException.INSTANCE; } cv.visit(version, access, name, signature, superName, interfaces); }
From source file:org.apache.cxf.jaxws.WrapperClassGenerator.java
License:Apache License
private void generatePackageInfo(String className, String ns, Class clz) { ClassWriter cw = createClassWriter(); String classFileName = periodToSlashes(className); cw.visit(Opcodes.V1_5, Opcodes.ACC_ABSTRACT + Opcodes.ACC_INTERFACE, classFileName, null, "java/lang/Object", null); boolean q = qualified; SchemaInfo si = interfaceInfo.getService().getSchema(ns); if (si != null) { q = si.isElementFormQualified(); }//from www .j av a 2 s .c o m AnnotationVisitor av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlSchema;", true); av0.visit("namespace", ns); av0.visitEnum("elementFormDefault", getClassCode(XmlNsForm.class), q ? "QUALIFIED" : "UNQUALIFIED"); av0.visitEnd(); cw.visitEnd(); loadClass(className, clz, cw.toByteArray()); }
From source file:org.apache.felix.ipojo.manipulator.metadata.annotation.ClassMetadataCollector.java
License:Apache License
/** * End of the visit : compute final elements. * * @see org.objectweb.asm.ClassVisitor#visitEnd() *///from w ww .j a v a 2 s .c o m @Override public void visitEnd() { // Only process real class (no annotations, no interfaces) if (!(is(Opcodes.ACC_ANNOTATION) || is(Opcodes.ACC_INTERFACE) || is(Opcodes.ACC_ABSTRACT))) { if (workbench.getRoot() == null) { // No 'top-level' element has been contributed if (workbench.ignore()) { // Ignore this class. return; } if (!workbench.getElements().isEmpty()) { // There are other annotation's contribution on this type (additional handler declaration/configuration) // That means that there is a missing 'component type' annotation reporter.warn( "Class %s has not been marked as a component type (no @Component, @Handler, " + "...). It will be ignored by the iPOJO manipulator.", workbench.getType().getClassName()); return; } // else: no root and no elements return; } componentMetadata = workbench.build(); instanceMetadata = workbench.getInstance(); // If we have an instance declared and the component metadata has a name, we update the component's attribute // of the instance (https://issues.apache.org/jira/browse/FELIX-4052). if (componentMetadata != null && componentMetadata.containsAttribute("name") && instanceMetadata != null) { // Update the component attribute instanceMetadata.addAttribute(new Attribute("component", componentMetadata.getAttribute("name"))); } } }
From source file:org.apache.groovy.parser.antlr4.AstBuilder.java
License:Apache License
@Override public ClassNode visitClassDeclaration(ClassDeclarationContext ctx) { String packageName = moduleNode.getPackageName(); packageName = null != packageName ? packageName : ""; List<ModifierNode> modifierNodeList = ctx.getNodeMetaData(TYPE_DECLARATION_MODIFIERS); Objects.requireNonNull(modifierNodeList, "modifierNodeList should not be null"); ModifierManager modifierManager = new ModifierManager(this, modifierNodeList); int modifiers = modifierManager.getClassModifiersOpValue(); boolean syntheticPublic = ((modifiers & Opcodes.ACC_SYNTHETIC) != 0); modifiers &= ~Opcodes.ACC_SYNTHETIC; final ClassNode outerClass = classNodeStack.peek(); ClassNode classNode;//from w w w . j av a 2s. c o m String className = this.visitIdentifier(ctx.identifier()); if (VAR_STR.equals(className)) { throw createParsingFailedException("var cannot be used for type declarations", ctx.identifier()); } if (asBoolean(ctx.ENUM())) { classNode = EnumHelper.makeEnumNode(asBoolean(outerClass) ? className : packageName + className, modifiers, null, outerClass); } else { if (asBoolean(outerClass)) { classNode = new InnerClassNode(outerClass, outerClass.getName() + "$" + className, modifiers | (outerClass.isInterface() ? Opcodes.ACC_STATIC : 0), ClassHelper.OBJECT_TYPE); } else { classNode = new ClassNode(packageName + className, modifiers, ClassHelper.OBJECT_TYPE); } } configureAST(classNode, ctx); classNode.putNodeMetaData(CLASS_NAME, className); classNode.setSyntheticPublic(syntheticPublic); if (asBoolean(ctx.TRAIT())) { attachTraitAnnotation(classNode); } classNode.addAnnotations(modifierManager.getAnnotations()); classNode.setGenericsTypes(this.visitTypeParameters(ctx.typeParameters())); boolean isInterface = asBoolean(ctx.INTERFACE()) && !asBoolean(ctx.AT()); boolean isInterfaceWithDefaultMethods = false; // declaring interface with default method if (isInterface && this.containsDefaultMethods(ctx)) { isInterfaceWithDefaultMethods = true; attachTraitAnnotation(classNode); classNode.putNodeMetaData(IS_INTERFACE_WITH_DEFAULT_METHODS, true); } if (asBoolean(ctx.CLASS()) || asBoolean(ctx.TRAIT()) || isInterfaceWithDefaultMethods) { // class OR trait OR interface with default methods classNode.setSuperClass(this.visitType(ctx.sc)); classNode.setInterfaces(this.visitTypeList(ctx.is)); this.initUsingGenerics(classNode); } else if (isInterface) { // interface(NOT annotation) classNode.setModifiers(classNode.getModifiers() | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT); classNode.setSuperClass(ClassHelper.OBJECT_TYPE); classNode.setInterfaces(this.visitTypeList(ctx.scs)); this.initUsingGenerics(classNode); this.hackMixins(classNode); } else if (asBoolean(ctx.ENUM())) { // enum classNode.setModifiers(classNode.getModifiers() | Opcodes.ACC_ENUM | Opcodes.ACC_FINAL); classNode.setInterfaces(this.visitTypeList(ctx.is)); this.initUsingGenerics(classNode); } else if (asBoolean(ctx.AT())) { // annotation classNode.setModifiers(classNode.getModifiers() | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_ANNOTATION); classNode.addInterface(ClassHelper.Annotation_TYPE); this.hackMixins(classNode); } else { throw createParsingFailedException("Unsupported class declaration: " + ctx.getText(), ctx); } // we put the class already in output to avoid the most inner classes // will be used as first class later in the loader. The first class // there determines what GCL#parseClass for example will return, so we // have here to ensure it won't be the inner class if (asBoolean(ctx.CLASS()) || asBoolean(ctx.TRAIT())) { classNodeList.add(classNode); } classNodeStack.push(classNode); ctx.classBody().putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode); this.visitClassBody(ctx.classBody()); classNodeStack.pop(); if (!(asBoolean(ctx.CLASS()) || asBoolean(ctx.TRAIT()))) { classNodeList.add(classNode); } groovydocManager.handle(classNode, ctx); return classNode; }
From source file:org.apache.maven.diagrams.connectors.classes.asm_parser.AsmClassDataSource.java
License:Apache License
/** * ClassNode is internal (asm's) model. This function translates all available information form the classNode into * classModel.//from www .ja va2s .com */ private ClassModel translateClassNodeToClassModel(ClassNode classNode) throws ClassDataSourceException { ClassModel classModel = new ClassModel(); classModel.setClassifiedName(classifiedNameToDotName(classNode.name)); if (classNode.superName != null) classModel.setSuperClassName(classifiedNameToDotName(classNode.superName)); else classModel.setSuperClassName(null); classModel.setFields(translateFields(classNode)); classModel.setMethods(translateMethods(classNode)); classModel.setInterfaces(translateInterfaces(classNode)); classModel.setInterface((classNode.access & Opcodes.ACC_INTERFACE) > 0); return classModel; }