List of usage examples for org.objectweb.asm Opcodes ACC_SYNTHETIC
int ACC_SYNTHETIC
To view the source code for org.objectweb.asm Opcodes ACC_SYNTHETIC.
Click Source Link
From source file:org.eclipse.virgo.bundlor.support.asm.ArtifactAnalyzerClassVisitor.java
License:Open Source License
/** * @inheritDoc/*from ww w. j a v a 2 s .c o m*/ */ @Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { Type t = Type.getType(desc); if ((access & Opcodes.ACC_SYNTHETIC) == Opcodes.ACC_SYNTHETIC) { if (Class.class.getName().equals(t.getClassName())) { if (name != null && name.startsWith(CLASS_NAME_PREFIX)) { name = name.substring(CLASS_NAME_PREFIX.length()); name = name.replace('$', '.'); int lastDotIndex = name.lastIndexOf('.'); for (int i = 0; i < lastDotIndex; i++) { if (Character.isUpperCase(name.charAt(i))) { if (i == 0) { return null; } if (name.charAt(i - 1) == '.') { name = name.substring(0, i) + name.substring(i).replace('.', '$'); break; } } } if (Character.isJavaIdentifierStart(name.charAt(0))) { this.partialManifest.recordReferencedType(name); } } } } VisitorUtils.recordReferencedTypes(this.partialManifest, t); return new ArtifactAnalyzerFieldVisitor(this.partialManifest, this.type); }
From source file:org.eclipse.virgo.ide.bundlor.internal.core.asm.ArtefactAnalyserClassVisitor.java
License:Open Source License
/** * @inheritDoc/* ww w . j av a2s. c o m*/ */ @Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { Type t = Type.getType(desc); if ((access & Opcodes.ACC_SYNTHETIC) == Opcodes.ACC_SYNTHETIC) { if (Class.class.getName().equals(t.getClassName())) { if (name != null && name.startsWith(CLASS_NAME_PREFIX)) { name = name.substring(CLASS_NAME_PREFIX.length()); name = name.replace('$', '.'); int lastDotIndex = name.lastIndexOf('.'); for (int i = 0; i < lastDotIndex; i++) { if (Character.isUpperCase(name.charAt(i))) { if (i == 0) { return null; } if (name.charAt(i - 1) == '.') { name = name.substring(0, i) + name.substring(i).replace('.', '$'); break; } } } if (Character.isJavaIdentifierStart(name.charAt(0))) { this.partialManifest.recordReferencedType(name); } } } } VisitorUtils.recordReferencedTypes(this.partialManifest, t); return new ArtefactAnalyserFieldVisitor(this.partialManifest, this.type); }
From source file:org.elasticsearch.painless.node.SFunction.java
License:Apache License
/** Writes the function to given ClassVisitor. */ void write(ClassVisitor writer, CompilerSettings settings, Globals globals) { int access = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC; if (synthetic) { access |= Opcodes.ACC_SYNTHETIC; }/*from w ww.j a va 2s.co m*/ final MethodWriter function = new MethodWriter(access, method.method, writer, globals.getStatements(), settings); function.visitCode(); write(function, globals); function.endMethod(); }
From source file:org.elasticsearch.plan.a.Writer.java
License:Apache License
private void writeBegin() { final int compute = ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS; final int version = Opcodes.V1_7; final int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC; final String base = BASE_CLASS_TYPE.getInternalName(); final String name = CLASS_TYPE.getInternalName(); writer = new ClassWriter(compute); writer.visit(version, access, name, null, base, null); writer.visitSource(source, null);/* w w w . j ava 2 s . c om*/ }
From source file:org.elasticsearch.plan.a.Writer.java
License:Apache License
private void writeConstructor() { final int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC; final GeneratorAdapter constructor = new GeneratorAdapter(access, CONSTRUCTOR, null, null, writer); constructor.loadThis();/*from w ww . j av a2s . c o m*/ constructor.loadArgs(); constructor.invokeConstructor(org.objectweb.asm.Type.getType(Executable.class), CONSTRUCTOR); constructor.returnValue(); constructor.endMethod(); }
From source file:org.elasticsearch.plan.a.Writer.java
License:Apache License
private void writeExecute() { final int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC; execute = new GeneratorAdapter(access, EXECUTE, SIGNATURE, null, writer); final Label fals = new Label(); final Label end = new Label(); execute.visitVarInsn(Opcodes.ALOAD, metadata.inputValueSlot); execute.push("#score"); execute.invokeInterface(MAP_TYPE, MAP_GET); execute.dup();// www .j ava 2 s . c o m execute.ifNull(fals); execute.checkCast(SCORE_ACCESSOR_TYPE); execute.invokeVirtual(SCORE_ACCESSOR_TYPE, SCORE_ACCESSOR_FLOAT); execute.goTo(end); execute.mark(fals); execute.pop(); execute.push(0F); execute.mark(end); execute.visitVarInsn(Opcodes.FSTORE, metadata.scoreValueSlot); execute.push(settings.getMaxLoopCounter()); execute.visitVarInsn(Opcodes.ISTORE, metadata.loopCounterSlot); visit(root); execute.endMethod(); }
From source file:org.evosuite.graphs.cfg.CFGClassAdapter.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from www. j ava 2 s. c o m*/ public MethodVisitor visitMethod(int methodAccess, String name, String descriptor, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(methodAccess, name, descriptor, signature, exceptions); mv = new JSRInlinerAdapter(mv, methodAccess, name, descriptor, signature, exceptions); if ((methodAccess & Opcodes.ACC_SYNTHETIC) != 0 || (methodAccess & Opcodes.ACC_BRIDGE) != 0) { return mv; } // We ignore deprecated only for dependencies, not for the SUT // if (!Properties.USE_DEPRECATED // && (methodAccess & Opcodes.ACC_DEPRECATED) == Opcodes.ACC_DEPRECATED) { // logger.info("Skipping deprecated method " + name); // return mv; // } if (isEnum) { if (name.equals("valueOf") || name.equals("values")) { logger.info("Skipping enum valueOf"); return mv; } if (name.equals("<init>") && descriptor.equals("(Ljava/lang/String;I)V")) { logger.info("Skipping enum default constructor"); return mv; } } logger.info("Analyzing CFG of " + className); String classNameWithDots = ResourceList.getClassNameFromResourcePath(className); mv = new CFGMethodAdapter(classLoader, classNameWithDots, methodAccess, name, descriptor, signature, exceptions, mv); return mv; }
From source file:org.evosuite.graphs.cfg.CFGMethodAdapter.java
License:Open Source License
/** * See description of CFGMethodAdapter.EXCLUDE * //w w w .j a va 2s . co m * @return */ private boolean isUsable() { if ((this.access & Opcodes.ACC_SYNTHETIC) != 0) return false; if ((this.access & Opcodes.ACC_BRIDGE) != 0) return false; if ((this.access & Opcodes.ACC_NATIVE) != 0) return false; if (methodName.contains("<clinit>")) return false; // If we are not using reflection, covering private constructors is difficult? if (Properties.P_REFLECTION_ON_PRIVATE <= 0.0) { if (methodName.contains("<init>") && (access & Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE) return false; } return true; }
From source file:org.evosuite.instrumentation.ExecutionPathClassAdapter.java
License:Open Source License
/** {@inheritDoc} */ @Override//from ww w . ja va 2 s. c o m public MethodVisitor visitMethod(int methodAccess, String name, String descriptor, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(methodAccess, name, descriptor, signature, exceptions); // Don't touch bridge and synthetic methods if ((methodAccess & Opcodes.ACC_SYNTHETIC) > 0 || (methodAccess & Opcodes.ACC_BRIDGE) > 0) { return mv; } if (name.equals("<clinit>")) return mv; if (name.equals(ClassResetter.STATIC_RESET)) return mv; if (!DependencyAnalysis.shouldInstrument(className, name + descriptor)) return mv; if (isEnum && (name.equals("valueOf") || name.equals("values"))) { return mv; } // Default constructors of anonymous classes are synthetic // but the Java Compiler is inconsistent in whether it has // line numbers, so we skip it. // https://bugs.openjdk.java.net/browse/JDK-8061778 if (isAnonymous && name.equals("<init>")) { return mv; } if (isMutation()) { mv = new ReturnValueAdapter(mv, className, name, descriptor); } mv = new MethodEntryAdapter(mv, methodAccess, className, name, descriptor); mv = new LineNumberMethodAdapter(mv, className, name, descriptor); mv = new ArrayAllocationLimitMethodAdapter(mv, className, name, methodAccess, descriptor); mv = new ExplicitExceptionHandler(mv, className, name, descriptor); return mv; }
From source file:org.evosuite.runtime.instrumentation.CreateClassResetClassAdapter.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from w ww . j a v a2s. co m*/ public MethodVisitor visitMethod(int methodAccess, String methodName, String descriptor, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(methodAccess, methodName, descriptor, signature, exceptions); if (methodName.equals("<clinit>") && !isInterface && !isAnonymous && !resetMethodAdded) { clinitFound = true; logger.info("Found static initializer in class " + className); // determineSerialisableUID(); // duplicates existing <clinit> // TODO: Removed | Opcodes.ACC_PUBLIC // Does __STATIC_RESET need to be public? // <clinit> apparently can be private, resulting // in illegal modifiers MethodVisitor visitMethod = super.visitMethod(methodAccess | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC, ClassResetter.STATIC_RESET, descriptor, signature, exceptions); CreateClassResetMethodAdapter staticResetMethodAdapter = new CreateClassResetMethodAdapter(visitMethod, className, this.static_fields, finalFields); resetMethodAdded = true; if (this.removeUpdatesOnFinalFields) { MethodVisitor mv2 = new RemoveFinalMethodAdapter(className, staticResetMethodAdapter, finalFields); return new MultiMethodVisitor(mv2, mv); } else { return new MultiMethodVisitor(staticResetMethodAdapter, mv); } } else if (methodName.equals(ClassResetter.STATIC_RESET)) { if (resetMethodAdded) { // Do not add reset method a second time } else { resetMethodAdded = true; } } return mv; }