List of usage examples for org.objectweb.asm Opcodes ACC_FINAL
int ACC_FINAL
To view the source code for org.objectweb.asm Opcodes ACC_FINAL.
Click Source Link
From source file:org.formulacompiler.compiler.internal.bytecode.SubSectionOutputAccessorCompiler.java
License:Open Source License
SubSectionOutputAccessorCompiler(SectionCompiler _section, SubSectionCompiler _sub, CallFrame _callToImplement) {/*from ww w .jav a 2s . co m*/ super(_section, Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL, _callToImplement.getMethod().getName(), Type.getMethodDescriptor(_callToImplement.getMethod())); this.sub = _sub; this.callToImplement = _callToImplement; }
From source file:org.formulacompiler.compiler.internal.bytecode.TypeCompilerForBigDecimals.java
License:Open Source License
private final String defineOrReuseStaticConstant(String _value) { String result = this.constantPool.get(_value); if (result == null) { final ClassWriter cw = rootCompiler().cw(); final GeneratorAdapter ci = rootCompiler().initializer(); result = "C$" + Integer.toString(this.constantPool.size()); cw.visitField(Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, result, B, null, null).visitEnd(); final BigDecimal bigValue = new BigDecimal(_value); if (bigValue.precision() <= MAX_LONG_PREC) { final long longValue = bigValue.unscaledValue().longValue(); ci.push(longValue);/* w w w . ja va 2s . c om*/ ci.push(bigValue.scale()); ci.visitMethodInsn(Opcodes.INVOKESTATIC, BNAME, "valueOf", LI2B); if (needsAdjustment(bigValue)) { compileAdjustment(ci); } } else { ci.push(_value); compileRuntimeMethod(ci, "newBigDecimal", S2B); compileAdjustment(ci); } ci.visitFieldInsn(Opcodes.PUTSTATIC, rootCompiler().classInternalName(), result, B); this.constantPool.put(_value, result); } return result; }
From source file:org.formulacompiler.compiler.internal.bytecode.TypeCompilerForPrecisionBigDecimals.java
License:Open Source License
final void buildStaticContext() { if (this.staticContextBuilt) return;/*from ww w . j av a 2 s .c o m*/ this.staticContextBuilt = true; final SectionCompiler root = engineCompiler().rootCompiler(); final ClassWriter cw = root.cw(); final FieldVisitor fv = cw.visitField(Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, RUNTIME_CONTEXT_NAME, RUNTIME_CONTEXT_TYPE.getDescriptor(), null, null); fv.visitEnd(); final GeneratorAdapter mv = root.initializer(); final MathContext mc = numericType().mathContext(); if (mc == MathContext.DECIMAL32) { compilePredefinedMathContext(mv, "DECIMAL32"); } else if (mc == MathContext.DECIMAL64) { compilePredefinedMathContext(mv, "DECIMAL64"); } else if (mc == MathContext.DECIMAL128) { compilePredefinedMathContext(mv, "DECIMAL128"); } else if (mc == MathContext.UNLIMITED) { compilePredefinedMathContext(mv, "UNLIMITED"); } else { mv.visitTypeInsn(Opcodes.NEW, RUNTIME_CONTEXT_TYPE.getInternalName()); mv.visitInsn(Opcodes.DUP); mv.push(mc.getPrecision()); final Type modeType = Type.getType(RoundingMode.class); mv.getStatic(modeType, mc.getRoundingMode().name(), modeType); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, RUNTIME_CONTEXT_TYPE.getInternalName(), "<init>", "(ILjava/math/RoundingMode;)V"); } mv.visitFieldInsn(Opcodes.PUTSTATIC, root.classInternalName(), RUNTIME_CONTEXT_NAME, RUNTIME_CONTEXT_DESCRIPTOR); }
From source file:org.formulacompiler.compiler.internal.bytecode.TypeCompilerForScaledLongs.java
License:Open Source License
final void buildStaticContext() { if (this.staticContextBuilt) return;/*from w ww . j a va2s . c o m*/ this.staticContextBuilt = true; final SectionCompiler root = engineCompiler().rootCompiler(); final ClassWriter cw = root.cw(); final FieldVisitor fv = cw.visitField(Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, RUNTIME_CONTEXT_NAME, RUNTIME_CONTEXT_TYPE.getDescriptor(), null, null); fv.visitEnd(); final GeneratorAdapter mv = root.initializer(); mv.visitTypeInsn(Opcodes.NEW, RUNTIME_CONTEXT_TYPE.getInternalName()); mv.visitInsn(Opcodes.DUP); mv.push(numericType().scale()); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, RUNTIME_CONTEXT_TYPE.getInternalName(), "<init>", "(I)V"); mv.visitFieldInsn(Opcodes.PUTSTATIC, root.classInternalName(), RUNTIME_CONTEXT_NAME, RUNTIME_CONTEXT_DESCRIPTOR); }
From source file:org.freud.analysed.classbytecode.parser.asm.AsmElement.java
License:Apache License
@Override public boolean isFinal() { return isAccessModifier(Opcodes.ACC_FINAL); }
From source file:org.gradle.api.internal.tasks.compile.incremental.analyzer.ClassDependenciesVisitor.java
License:Apache License
private static boolean isConstant(int access) { return (access & Opcodes.ACC_FINAL) != 0 && (access & Opcodes.ACC_STATIC) != 0; }
From source file:org.greencheek.gc.memusage.agent.MonitoringAspectGenerator.java
License:Apache License
/** * Visits a field of the class.// w ww . ja v a 2 s . c o m * The method is overriden to perform the functions of: * <ol> * <li>Adding a static AtomicLong to the class</li> * <li>statically initialising the AtomicLong if a static initialiser isn't already present</li> * </ol> * * @param access the field's access flags (see {@link Opcodes}). This * parameter also indicates if the field is synthetic and/or * deprecated. * @param name the field's name. * @param desc the field's descriptor (see {@link Type Type}). * @param signature the field's signature. May be <tt>null</tt> if the * field's type does not use generic types. * @param value the field's initial value. This parameter, which may be * <tt>null</tt> if the field does not have an initial value, must * be an {@link Integer}, a {@link Float}, a {@link Long}, a * {@link Double} or a {@link String} (for <tt>int</tt>, * <tt>float</tt>, <tt>long</tt> or <tt>String</tt> fields * respectively). <i>This parameter is only used for static fields</i>. * Its value is ignored for non static fields, which must be * initialized through bytecode instructions in constructors or * methods. * @return a visitor to visit field annotations and attributes, or * <tt>null</tt> if this class visitor is not interested in * visiting these annotations and attributes. */ public void visitEnd() { for (MethodInfo method : overrideMethodNames.values()) { System.out.println("Adding: public final static AtomicLong " + method.getFieldName()); FieldVisitor fv = cv.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, method.getFieldName(), "Ljava/util/concurrent/atomic/AtomicLong;", null, null); fv.visitEnd(); } if (!hasCinit) { MethodVisitor mv = cv.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null); mv.visitCode(); AddStaticAtomicLongInitializer initialiser = new AddStaticAtomicLongInitializer(Opcodes.ASM4, mv, overrideMethodNames.values()); initialiser.visitCode(); mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } super.visitEnd(); }
From source file:org.iobserve.mobile.instrument.bytecode.visitors.StandardClassVisitor.java
License:Apache License
/** * {@inheritDoc}/*w ww . j a v a 2 s. c o m*/ */ @Override public void visit(final int version, final int access, final String name, final String signature, final String supername, final String[] interfaces) { super.visit(version, access & (~Opcodes.ACC_FINAL), name, signature, supername, interfaces); this.className = name; this.superName = supername; this.traceClass = config.isTraceRelevantClass(name); // monitor this.systemWebViewClient = name.equals("org/apache/cordova/engine/SystemWebViewClient"); if (this.superName != null) { final Type superType = Type.getType(this.superName); this.classWithInit = matchesActivityClass(superType.getInternalName()) && !matchesActivityClass(name); } }
From source file:org.jruby.javasupport.proxy.JavaProxyClassFactory.java
License:LGPL
private static ClassWriter beginProxyClass(final String targetClassName, final Class superClass, final Class[] interfaces) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_STATIC; String name = toInternalClassName(targetClassName); String signature = null;//from ww w. ja v a 2s . c o m String supername = toInternalClassName(superClass); String[] interfaceNames = new String[interfaces.length + 1]; for (int i = 0; i < interfaces.length; i++) { interfaceNames[i] = toInternalClassName(interfaces[i]); } interfaceNames[interfaces.length] = toInternalClassName(InternalJavaProxy.class); // start class cw.visit(Opcodes.V1_3, access, name, signature, supername, interfaceNames); cw.visitField(Opcodes.ACC_PRIVATE, INVOCATION_HANDLER_FIELD_NAME, INVOCATION_HANDLER_TYPE.getDescriptor(), null, null).visitEnd(); cw.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC, PROXY_CLASS_FIELD_NAME, PROXY_CLASS_TYPE.getDescriptor(), null, null).visitEnd(); return cw; }
From source file:org.mbte.groovypp.compiler.bytecode.PropertyUtil.java
License:Apache License
public static BytecodeExpr createSetProperty(ASTNode parent, CompilerTransformer compiler, String propName, BytecodeExpr object, BytecodeExpr value, Object prop) { if (prop instanceof MethodNode) { return new ResolvedMethodBytecodeExpr.Setter(parent, (MethodNode) prop, object, new ArgumentListExpression(value), compiler); }/*from ww w. j av a 2 s .co m*/ if (prop instanceof PropertyNode) { final PropertyNode propertyNode = (PropertyNode) prop; if ((propertyNode.getModifiers() & Opcodes.ACC_FINAL) != 0) { final FieldNode fieldNode = compiler.findField(propertyNode.getDeclaringClass(), propName); return new ResolvedFieldBytecodeExpr(parent, fieldNode, object, value, compiler); } return new ResolvedPropertyBytecodeExpr(parent, propertyNode, object, value, compiler); } if (prop instanceof FieldNode) { final FieldNode field = (FieldNode) prop; if ((field.getModifiers() & Opcodes.ACC_PRIVATE) != 0 && field.getDeclaringClass() != compiler.classNode) { MethodNode setter = compiler.context.getFieldSetter(field); return new ResolvedMethodBytecodeExpr.Setter(parent, setter, object, new ArgumentListExpression(value), compiler); } return new ResolvedFieldBytecodeExpr(parent, field, object, value, compiler); } if (prop instanceof GetUnresolved) { final MethodCallExpression setUnresolvedProperty = new MethodCallExpression(object, "setUnresolvedProperty", new ArgumentListExpression(new ConstantExpression(propName), value)); setUnresolvedProperty.setSourcePosition(parent); return (BytecodeExpr) compiler.transform(setUnresolvedProperty); } final ClassNode type = object != null ? object.getType() : compiler.classNode; return dynamicOrFail(parent, compiler, propName, type, object, value, "assign"); }