List of usage examples for org.objectweb.asm Opcodes ACC_STATIC
int ACC_STATIC
To view the source code for org.objectweb.asm Opcodes ACC_STATIC.
Click Source Link
From source file:com.intellij.compiler.notNullVerification.NotNullInstrumenterClassVisitor.java
License:Apache License
private boolean isStatic(final int access) { return (access & Opcodes.ACC_STATIC) != 0; }
From source file:com.intellij.compiler.notNullVerification.ThrowOnNullMethodVisitor.java
License:Apache License
private boolean isStatic() { return (methodAccess & Opcodes.ACC_STATIC) != 0; }
From source file:com.intellij.compiler.notNullVerification.ThrowOnNullMethodVisitor.java
License:Apache License
/** * Starts the visit of the method's code, if any (ie non abstract method). *//*from ww w.j a v a 2 s. c om*/ @Override public void visitCode() { if (shouldInclude()) { if (!notNullParams.isEmpty()) { startGeneratedCodeLabel = new Label(); mv.visitLabel(startGeneratedCodeLabel); } for (final Integer notNullParam : notNullParams) { int var = ((methodAccess & Opcodes.ACC_STATIC) == 0) ? 1 : 0; for (int i = 0; i < notNullParam + syntheticCount; ++i) { var += argumentTypes[i].getSize(); } mv.visitVarInsn(Opcodes.ALOAD, var); final Label end = new Label(); mv.visitJumpInsn(Opcodes.IFNONNULL, end); generateThrow(IAE_CLASS_NAME, getThrowMessage(notNullParam), end); } } mv.visitCode(); }
From source file:com.jcoverage.coverage.asm.AsmClassInstrumenter.java
License:Open Source License
private boolean isEnumDefaultMethod(int access, String name, String desc) { if ("<init>".equals(name)) return true; if ("<clinit>".equals(name)) return true; if ((access & Opcodes.ACC_STATIC) != Opcodes.ACC_STATIC) return false; if (!isEnumDefaultMethodName(name)) return false; if (!isEnumDefaultMethodSignature(name, desc)) return false; return true;/* w w w.j av a2s . co m*/ }
From source file:com.jcwhatever.nucleus.localizer.LanguageGenerator.java
License:MIT License
private List<LiteralInfo> parseClass(ClassNode classNode, Map<String, AnnotationInfo> annotations) { List<LiteralInfo> result = new ArrayList<>(10); // parse class annotations @SuppressWarnings("unchecked") List<AnnotationNode> classAnnotations = classNode.visibleAnnotations; if (classAnnotations != null) { for (AnnotationNode node : classAnnotations) { String nodeName = node.desc.substring(1, node.desc.length() - 1); AnnotationInfo info = annotations.get(nodeName); if (info == null) continue; result.addAll(parseAnnotationUsage(classNode, node)); }/*ww w.j a v a 2 s.c o m*/ } // parse fields @SuppressWarnings("unchecked") List<FieldNode> fields = (List<FieldNode>) classNode.fields; if (fields == null) return new ArrayList<>(0); for (FieldNode node : fields) { @SuppressWarnings("unchecked") List<AnnotationNode> annotationNodes = node.visibleAnnotations; if (annotationNodes == null) continue; for (AnnotationNode annotation : annotationNodes) { if (!isLocalizableAnnotation(annotation.desc)) continue; boolean isStatic = (node.access & Opcodes.ACC_STATIC) != 0; boolean isFinal = (node.access & Opcodes.ACC_FINAL) != 0; String desc = "FIELD: " + node.name + ' ' + classNode.name; if (!isStatic) { System.out.println("[IGNORED] @Localizable field found but isn't static: " + desc); } if (!isFinal) { System.out.println("[IGNORED] @Localizable field found but isn't final: " + desc); } if (!isStatic || !isFinal) continue; if (node.value instanceof String) { System.out.println("@Localizable field found: " + desc); result.add(new LiteralInfo((String) node.value, desc)); } else { System.out.println( "[IGNORED] @Localizable field found but did not contain a String value: " + desc); } } } return result; }
From source file:com.khubla.jvmbasic.jvmbasicc.JVMBasicCompiler.java
License:Open Source License
/** * generate void main(String[])/*ww w .j a v a 2 s. co m*/ * <p> * <code> * public static void main(String[] args) { * ExampleProgram exampleProgram = new ExampleProgram(); * try { * exampleProgram.inputStream = System.in; * exampleProgram.outputStream = System.out; * exampleProgram.program(); * } catch (Exception e) { * e.printStackTrace(); * } * } * </code> * </p> */ protected void generateMain(String classname, ClassWriter classWriter) throws Exception { try { /* * make method */ final MethodVisitor methodVisitor = classWriter.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null); methodVisitor.visitCode(); final Label l0 = new Label(); final Label l1 = new Label(); final Label l2 = new Label(); methodVisitor.visitTryCatchBlock(l0, l1, l2, "java/lang/Exception"); final Label l3 = new Label(); methodVisitor.visitLabel(l3); /* * declare a local instance of the class in the void() main, store as variable 1. */ methodVisitor.visitTypeInsn(Opcodes.NEW, classname); methodVisitor.visitInsn(Opcodes.DUP); methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, classname, "<init>", "()V"); methodVisitor.visitVarInsn(Opcodes.ASTORE, 1); /* * assign the input stream */ methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/System", "in", "Ljava/io/InputStream;"); methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, classname, "inputStream", "Ljava/io/InputStream;"); /* * assign the output stream */ methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"); methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, classname, "outputStream", "Ljava/io/PrintStream;"); /* * load the class instance from variable 1 and call "program" */ methodVisitor.visitLabel(l0); methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classname, "program", "()V"); methodVisitor.visitLabel(l1); final Label l4 = new Label(); methodVisitor.visitJumpInsn(Opcodes.GOTO, l4); methodVisitor.visitLabel(l2); methodVisitor.visitFrame(Opcodes.F_FULL, 2, new Object[] { "[Ljava/lang/String;", classname }, 1, new Object[] { "java/lang/Exception" }); methodVisitor.visitVarInsn(Opcodes.ASTORE, 2); final Label l5 = new Label(); methodVisitor.visitLabel(l5); methodVisitor.visitLineNumber(21, l5); methodVisitor.visitVarInsn(Opcodes.ALOAD, 2); methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Exception", "printStackTrace", "()V"); /* * return */ methodVisitor.visitLabel(l4); methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null); methodVisitor.visitInsn(Opcodes.RETURN); /* * declare the parameters */ final Label l6 = new Label(); methodVisitor.visitLabel(l6); methodVisitor.visitLocalVariable("args", "[Ljava/lang/String;", null, l3, l6, 0); methodVisitor.visitLocalVariable("exampleProgram", "L" + classname + ";", null, l0, l6, 1); methodVisitor.visitLocalVariable("e", "Ljava/lang/Exception;", null, l5, l4, 2); /* * done */ methodVisitor.visitMaxs(2, 3); methodVisitor.visitEnd(); } catch (final Exception e) { throw new Exception("Exception in generateMain", e); } }
From source file:com.masetta.spann.metadata.reader.asm3_2.ModifierImpl.java
License:Apache License
public boolean isStatic() { return (modifier & Opcodes.ACC_STATIC) != 0; }
From source file:com.mebigfatguy.baremetal4j.Sourcifier.java
License:Apache License
public String accessString(int access) { String separator = ""; StringBuilder sb = new StringBuilder(32); if ((access & Opcodes.ACC_PUBLIC) != 0) { sb.append("public"); separator = " "; } else if ((access & Opcodes.ACC_PROTECTED) != 0) { sb.append("protected"); separator = " "; } else if ((access & Opcodes.ACC_PRIVATE) != 0) { sb.append("private"); separator = " "; }/*from w w w . ja v a 2s . c om*/ if ((access & Opcodes.ACC_STATIC) != 0) { sb.append(separator).append("static"); separator = " "; } if ((access & Opcodes.ACC_FINAL) != 0) { sb.append(separator).append("final"); separator = " "; } return sb.toString(); }
From source file:com.mebigfatguy.deadmethods.FindDeadMethods.java
License:Apache License
private void removeMainMethods(ClassRepository repo, Set<String> methods) { MethodInfo mainInfo = new MethodInfo("main", "([Ljava/lang/String;)V", Opcodes.ACC_STATIC); for (ClassInfo classInfo : repo.getAllClassInfos()) { Set<MethodInfo> methodInfo = classInfo.getMethodInfo(); if (methodInfo.contains(mainInfo)) { methods.remove(classInfo.getClassName() + ":main([Ljava/lang/String;)V"); }/*from www. j a va 2s . c om*/ } }
From source file:com.mebigfatguy.deadmethods.FindDeadMethods.java
License:Apache License
private void removeNoArgCtors(ClassRepository repo, Set<String> methods) { MethodInfo ctorInfo = new MethodInfo("<init>", "()V", Opcodes.ACC_STATIC); for (ClassInfo classInfo : repo.getAllClassInfos()) { Set<String> infs = new HashSet<String>(Arrays.asList(classInfo.getInterfaceNames())); if (infs.contains("java/lang/Serializable")) { Set<MethodInfo> methodInfo = classInfo.getMethodInfo(); if (methodInfo.contains(ctorInfo)) { methods.remove(classInfo.getClassName() + ":" + methodInfo); }//from w ww.ja va 2 s .c o m } } }