Java Code Examples for org.objectweb.asm.Opcodes#ACC_VARARGS

The following examples show how to use org.objectweb.asm.Opcodes#ACC_VARARGS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodInfo.java    From java-almanac with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
public String getParameterDeclaration(String sep, boolean simpleTypeNames) {
	final StringBuilder result = new StringBuilder();
	final Type[] arguments = Type.getArgumentTypes(getDesc());
	boolean comma = false;
	for (final Type arg : arguments) {
		if (comma) {
			result.append(sep);
		} else {
			comma = true;
		}
		String name = arg.getClassName();
		if (simpleTypeNames) {
			name = getSimpleTypeName(name);
		}
		name = name.replace('$', '.');
		result.append(name);
	}
	if ((getAccess() & Opcodes.ACC_VARARGS) != 0) {
		result.setLength(result.length() - 2);
		result.append("...");
	}
	return result.toString();
}
 
Example 2
Source File: JavaDocTestBase.java    From java-almanac with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
@Test
public void link_method_varargs() {
	ClassInfo owner = new ClassInfo("java/lang/String", 0, "java.base", null, null);
	MethodInfo info = new MethodInfo(owner, "format", Opcodes.ACC_VARARGS,
			"(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", null);
	assertEquals(link_method_varargs, javadoc.getMethodLink(info));
}
 
Example 3
Source File: MethodAnalyzeVisitor.java    From meghanada-server with GNU General Public License v3.0 5 votes vote down vote up
MethodAnalyzeVisitor(
    final ClassAnalyzeVisitor classAnalyzeVisitor,
    final int access,
    final String name,
    final String desc,
    final String signature,
    final String[] exceptions) {
  super(Opcodes.ASM7);
  final EntryMessage entryMessage =
      log.traceEntry(
          "classAnalyzeVisitor={} access={} name={} desc={} signature={} exceptions={}",
          classAnalyzeVisitor,
          access,
          name,
          desc,
          signature,
          exceptions);
  this.classAnalyzeVisitor = classAnalyzeVisitor;
  this.access = access;
  this.name = name;
  this.exceptions = exceptions;

  Type[] args = Type.getArgumentTypes(desc);
  this.parameterNames = new String[args.length];
  boolean isStatic = (Opcodes.ACC_STATIC & access) > 0;
  this.lvtSlotIndex = computeLvtSlotIndices(isStatic, args);
  this.hasVarargs = (Opcodes.ACC_VARARGS & access) > 0;
  String target = desc;
  if (signature != null) {
    target = signature;
  }
  this.methodSignature = target;
  this.interfaceMethod = this.classAnalyzeVisitor.getClassIndex().isInterface();

  // log.telemetry("name:{} sig:{}", name, target);
  // log.telemetry("classIndex:{}", classAnalyzeVisitor.getClassIndex().isInterface);
  // log.debug("methodName {} desc {} sig {}", name, desc, signature);
  log.traceExit(entryMessage);
}
 
Example 4
Source File: MethodNodeDecompiler.java    From java-disassembler with GNU General Public License v3.0 5 votes vote down vote up
protected static String getAccessString(int access) {
    // public, protected, private, abstract, static,
    // final, synchronized, native & strictfp are permitted
    List<String> tokens = new ArrayList<>();
    if ((access & Opcodes.ACC_PUBLIC) != 0)
        tokens.add("public");
    if ((access & Opcodes.ACC_PRIVATE) != 0)
        tokens.add("private");
    if ((access & Opcodes.ACC_PROTECTED) != 0)
        tokens.add("protected");
    if ((access & Opcodes.ACC_STATIC) != 0)
        tokens.add("static");
    if ((access & Opcodes.ACC_ABSTRACT) != 0)
        tokens.add("abstract");
    if ((access & Opcodes.ACC_FINAL) != 0)
        tokens.add("final");
    if ((access & Opcodes.ACC_SYNCHRONIZED) != 0)
        tokens.add("synchronized");
    if ((access & Opcodes.ACC_NATIVE) != 0)
        tokens.add("native");
    if ((access & Opcodes.ACC_STRICT) != 0)
        tokens.add("strictfp");
    if ((access & Opcodes.ACC_BRIDGE) != 0)
        tokens.add("bridge");
    if ((access & Opcodes.ACC_VARARGS) != 0)
        tokens.add("varargs");
    if (tokens.size() == 0)
        return "";
    // hackery delimeters
    StringBuilder sb = new StringBuilder(tokens.get(0));
    for (int i = 1; i < tokens.size(); i++) {
        sb.append(" ");
        sb.append(tokens.get(i));
    }
    return sb.toString();
}
 
Example 5
Source File: MethodNodeDecompiler.java    From bytecode-viewer with GNU General Public License v3.0 5 votes vote down vote up
private static String getAccessString(int access) {
    // public, protected, private, abstract, static,
    // final, synchronized, native & strictfp are permitted
    List<String> tokens = new ArrayList<String>();
    if ((access & Opcodes.ACC_PUBLIC) != 0)
        tokens.add("public");
    if ((access & Opcodes.ACC_PRIVATE) != 0)
        tokens.add("private");
    if ((access & Opcodes.ACC_PROTECTED) != 0)
        tokens.add("protected");
    if ((access & Opcodes.ACC_STATIC) != 0)
        tokens.add("static");
    if ((access & Opcodes.ACC_ABSTRACT) != 0)
        tokens.add("abstract");
    if ((access & Opcodes.ACC_FINAL) != 0)
        tokens.add("final");
    if ((access & Opcodes.ACC_SYNCHRONIZED) != 0)
        tokens.add("synchronized");
    if ((access & Opcodes.ACC_NATIVE) != 0)
        tokens.add("native");
    if ((access & Opcodes.ACC_STRICT) != 0)
        tokens.add("strictfp");
    if ((access & Opcodes.ACC_BRIDGE) != 0)
        tokens.add("bridge");
    if ((access & Opcodes.ACC_SYNTHETIC) != 0)
        tokens.add("synthetic");
    if ((access & Opcodes.ACC_VARARGS) != 0)
        tokens.add("varargs");
    if (tokens.size() == 0)
        return "";
    // hackery delimeters
    StringBuilder sb = new StringBuilder(tokens.get(0));
    for (int i = 1; i < tokens.size(); i++) {
        sb.append(" ");
        sb.append(tokens.get(i));
    }
    return sb.toString();
}
 
Example 6
Source File: AccessFlags.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the method access flags (see JVMS8 4.6) for the given executable element, augmented by the
 * special ASM pseudo-access flag for @Deprecated methods.
 */
public int getAccessFlags(ExecutableElement executableElement) {
  int result = getCommonAccessFlags(executableElement);

  if (executableElement.isVarArgs()) {
    result = result | Opcodes.ACC_VARARGS;
  }

  return result;
}
 
Example 7
Source File: GizmoClassVisitor.java    From gizmo with Apache License 2.0 4 votes vote down vote up
public GizmoMethodVisitor visitMethod(final int access, final String name, final String descriptor, final String signature, final String[] exceptions) {
    if (currentMethod != null) {
        throw new IllegalStateException("Multiple active method visitors");
    }
    final MethodVisitor delegate = super.visitMethod(access, name, descriptor, signature, exceptions);
    final GizmoMethodVisitor zigMethodVisitor = new GizmoMethodVisitor(api, delegate, this);
    currentMethod = zigMethodVisitor;
    final Type returnType = Type.getReturnType(descriptor);
    append("// Access:");
    for (int mods = access; mods != 0;) {
        int mod = Integer.lowestOneBit(mods);
        switch (mod) {
            case Opcodes.ACC_PUBLIC: {
                append(" public");
                break;
            }
            case Opcodes.ACC_PRIVATE: {
                append(" private");
                break;
            }
            case Opcodes.ACC_PROTECTED: {
                append(" protected");
                break;
            }
            case Opcodes.ACC_STATIC: {
                append(" static");
                break;
            }
            case Opcodes.ACC_FINAL: {
                append(" final");
                break;
            }
            case Opcodes.ACC_SYNCHRONIZED: {
                append(" synchronized");
                break;
            }
            case Opcodes.ACC_BRIDGE: {
                append(" bridge");
                break;
            }
            case Opcodes.ACC_VARARGS: {
                append(" varargs");
                break;
            }
            case Opcodes.ACC_NATIVE: {
                append(" native");
                break;
            }
            case Opcodes.ACC_ABSTRACT: {
                append(" abstract");
                break;
            }
            case Opcodes.ACC_STRICT: {
                append(" strictfp");
                break;
            }
            case Opcodes.ACC_SYNTHETIC: {
                append(" synthetic");
                break;
            }
        }
        mods ^= mod;
    }
    newLine();
    append("Method ").append(name).append(" : ").append(returnType);
    if (exceptions != null && exceptions.length > 0) {
        addIndent().newLine().append("throws ");
        append(exceptions[0]);
        for (int i = 1; i < exceptions.length; i++) {
            append(", ").append(exceptions[i]);
        }
        removeIndent();
    }
    newLine().append("(").addIndent().newLine();
    final Type[] argumentTypes = Type.getArgumentTypes(descriptor);
    if (argumentTypes.length > 0) {
        int base = ((access & Opcodes.ACC_STATIC) != 0) ? 0 : 1;
        append("arg ").append(base).append(" = ").append(argumentTypes[0]);
        for (int i = 1; i < argumentTypes.length; i ++) {
            append(',').newLine();
            append("arg ").append(base + i).append(" = ").append(argumentTypes[i]);
        }
    } else {
        append("// (no arguments)");
    }
    removeIndent().newLine().append(") {").addIndent().newLine();
    return zigMethodVisitor;
}
 
Example 8
Source File: Textifier.java    From Concurnas with MIT License 4 votes vote down vote up
@Override
public Textifier visitMethod(
    final int access,
    final String name,
    final String descriptor,
    final String signature,
    final String[] exceptions) {
  stringBuilder.setLength(0);
  stringBuilder.append('\n');
  if ((access & Opcodes.ACC_DEPRECATED) != 0) {
    stringBuilder.append(tab).append(DEPRECATED);
  }
  stringBuilder.append(tab);
  appendRawAccess(access);

  if (signature != null) {
    stringBuilder.append(tab);
    appendDescriptor(METHOD_SIGNATURE, signature);
    stringBuilder.append(tab);
    appendJavaDeclaration(name, signature);
  }

  stringBuilder.append(tab);
  appendAccess(access & ~(Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT));
  if ((access & Opcodes.ACC_NATIVE) != 0) {
    stringBuilder.append("native ");
  }
  if ((access & Opcodes.ACC_VARARGS) != 0) {
    stringBuilder.append("varargs ");
  }
  if ((access & Opcodes.ACC_BRIDGE) != 0) {
    stringBuilder.append("bridge ");
  }
  if ((this.access & Opcodes.ACC_INTERFACE) != 0
      && (access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC)) == 0) {
    stringBuilder.append("default ");
  }

  stringBuilder.append(name);
  appendDescriptor(METHOD_DESCRIPTOR, descriptor);
  if (exceptions != null && exceptions.length > 0) {
    stringBuilder.append(" throws ");
    for (String exception : exceptions) {
      appendDescriptor(INTERNAL_NAME, exception);
      stringBuilder.append(' ');
    }
  }

  stringBuilder.append('\n');
  text.add(stringBuilder.toString());
  return addNewTextifier(null);
}
 
Example 9
Source File: Textifier.java    From JByteMod-Beta with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Textifier visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
  buf.setLength(0);
  buf.append('\n');
  if ((access & Opcodes.ACC_DEPRECATED) != 0) {
    buf.append(tab).append("// DEPRECATED\n");
  }
  buf.append(tab).append("// access flags 0x").append(Integer.toHexString(access).toUpperCase()).append('\n');

  if (signature != null) {
    buf.append(tab);
    appendDescriptor(METHOD_SIGNATURE, signature);

    TraceSignatureVisitor v = new TraceSignatureVisitor(0);
    SignatureReader r = new SignatureReader(signature);
    r.accept(v);
    String genericDecl = v.getDeclaration();
    String genericReturn = v.getReturnType();
    String genericExceptions = v.getExceptions();

    buf.append(tab).append("// declaration: ").append(genericReturn).append(' ').append(name).append(genericDecl);
    if (genericExceptions != null) {
      buf.append(" throws ").append(genericExceptions);
    }
    buf.append('\n');
  }

  buf.append(tab);
  appendAccess(access & ~(Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT));
  if ((access & Opcodes.ACC_NATIVE) != 0) {
    buf.append("native ");
  }
  if ((access & Opcodes.ACC_VARARGS) != 0) {
    buf.append("varargs ");
  }
  if ((access & Opcodes.ACC_BRIDGE) != 0) {
    buf.append("bridge ");
  }
  if ((this.access & Opcodes.ACC_INTERFACE) != 0 && (access & Opcodes.ACC_ABSTRACT) == 0 && (access & Opcodes.ACC_STATIC) == 0) {
    buf.append("default ");
  }

  buf.append(name);
  appendDescriptor(METHOD_DESCRIPTOR, desc);
  if (exceptions != null && exceptions.length > 0) {
    buf.append(" throws ");
    for (int i = 0; i < exceptions.length; ++i) {
      appendDescriptor(INTERNAL_NAME, exceptions[i]);
      buf.append(' ');
    }
  }

  buf.append('\n');
  text.add(buf.toString());

  Textifier t = createTextifier();
  text.add(t.getText());
  return t;
}
 
Example 10
Source File: IncrementalSupportVisitor.java    From AnoleFix with MIT License 4 votes vote down vote up
/***
 * Inserts a trampoline to this class so that the updated methods can make calls to super
 * class methods.
 * <p/>
 * Pseudo code for this trampoline:
 * <code>
 * Object access$super($classType instance, String name, object[] args) {
 * switch(name) {
 * case "firstMethod.(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;":
 * return super~instance.firstMethod((String)arg[0], arg[1]);
 * case "secondMethod.(Ljava/lang/String;I)V":
 * return super~instance.firstMethod((String)arg[0], arg[1]);
 * <p>
 * default:
 * StringBuilder $local1 = new StringBuilder();
 * $local1.append("Method not found ");
 * $local1.append(name);
 * $local1.append(" in " $classType $super implementation");
 * throw new $package/InstantReloadException($local1.toString());
 * }
 * </code>
 */
private void createAccessSuper() {
    int access = Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC
            | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_VARARGS;
    Method m = new Method("access$super", "(L" + visitedClassName
            + ";Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;");
    MethodVisitor visitor = super.visitMethod(access,
            m.getName(),
            m.getDescriptor(),
            null, null);

    final GeneratorAdapter mv = new GeneratorAdapter(access, m, visitor);

    // Gather all methods from itself and its superclasses to generate a giant access$super
    // implementation.
    // This will work fine as long as we don't support adding methods to a class.
    final Map<String, MethodReference> uniqueMethods =
            new HashMap<String, MethodReference>();
    if (parentNodes.isEmpty()) {
        // if we cannot determine the parents for this class, let's blindly add all the
        // method of the current class as a gateway to a possible parent version.
        addAllNewMethods(uniqueMethods, classNode);
    } else {
        // otherwise, use the parent list.
        for (ClassNode parentNode : parentNodes) {
            addAllNewMethods(uniqueMethods, parentNode);
        }
    }

    new StringSwitch() {
        @Override
        void visitString() {
            mv.visitVarInsn(Opcodes.ALOAD, 1);
        }

        @Override
        void visitCase(String methodName) {
            MethodReference methodRef = uniqueMethods.get(methodName);

            mv.visitVarInsn(Opcodes.ALOAD, 0);

            Type[] args = Type.getArgumentTypes(methodRef.method.desc);
            int argc = 0;
            for (Type t : args) {
                mv.visitVarInsn(Opcodes.ALOAD, 2);
                mv.push(argc);
                mv.visitInsn(Opcodes.AALOAD);
                ByteCodeUtils.unbox(mv, t);
                argc++;
            }

            if (TRACING_ENABLED) {
                trace(mv, "super selected ", methodRef.owner.name,
                        methodRef.method.name, methodRef.method.desc);
            }
            // Call super on the other object, yup this works cos we are on the right place to
            // call from.
            mv.visitMethodInsn(Opcodes.INVOKESPECIAL,
                    methodRef.owner.name,
                    methodRef.method.name,
                    methodRef.method.desc, false);

            Type ret = Type.getReturnType(methodRef.method.desc);
            if (ret.getSort() == Type.VOID) {
                mv.visitInsn(Opcodes.ACONST_NULL);
            } else {
                mv.box(ret);
            }
            mv.visitInsn(Opcodes.ARETURN);
        }

        @Override
        void visitDefault() {
            writeMissingMessageWithHash(mv, visitedClassName);
        }
    }.visit(mv, uniqueMethods.keySet());

    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
 
Example 11
Source File: ASMClassParser.java    From TickDynamic with MIT License 4 votes vote down vote up
protected int parseAccessFlags() throws Exception {
	String current;
	int access = 0;
	
	//They share value(Mutually exclusive, one is for method, one is for field)
	boolean gotTransient = false;
	boolean gotVarargs = false;
	while(true)
	{
		current = nextToken();
		if(current == null)
			return access;
		
		//A lot of these actually are not a keyword, but something the compiler adds, just keep it here for now
		if(current.equals("public"))
			access += Opcodes.ACC_PUBLIC;
		else if(current.equals("private"))
			access += Opcodes.ACC_PRIVATE;
		else if(current.equals("protected"))
			access += Opcodes.ACC_PROTECTED;
		else if(current.equals("static"))
			access += Opcodes.ACC_STATIC;
		else if(current.equals("final"))
			access += Opcodes.ACC_FINAL;
		/*else if(current.equals("super"))
			access += Opcodes.ACC_SUPER;*/ //This one is added on newer compilers whenever a class has a super class
		else if(current.equals("synchronized"))
			access += Opcodes.ACC_SYNCHRONIZED;
		else if(current.equals("volatile"))
			access += Opcodes.ACC_VOLATILE;
		else if(current.equals("bridge"))
			access += Opcodes.ACC_BRIDGE;
		else if(current.equals("varargs"))
		{
			if(!gotTransient)
			{
				access += Opcodes.ACC_VARARGS;
				gotVarargs = true;
			}
		}
		else if(current.equals("transient"))
		{
			if(!gotVarargs)
			{
				access += Opcodes.ACC_TRANSIENT;
				gotTransient = true;
			}
		}
		else if(current.equals("native"))
			access += Opcodes.ACC_NATIVE;
		else if(current.equals("interface"))
			access += Opcodes.ACC_INTERFACE;
		else if(current.equals("abstract"))
			access += Opcodes.ACC_ABSTRACT;
		else if(current.equals("strict"))
			access += Opcodes.ACC_STRICT;
		else if(current.equals("synthetic"))
			access += Opcodes.ACC_SYNTHETIC;
		else if(current.equals("annotation"))
			access += Opcodes.ACC_ANNOTATION;
		else if(current.equals("enum"))
			access += Opcodes.ACC_ENUM;
		else if(current.equals("mandated"))
			access += Opcodes.ACC_MANDATED;
		else
		{
			//Move back from our peek
			currentToken--;
			//System.out.println("Access: " + Integer.toHexString(access).toUpperCase());
			return access;
		}
	}
}
 
Example 12
Source File: Engine.java    From JReFrameworker with MIT License 4 votes vote down vote up
@SuppressWarnings("unused")
private static String getAccessModifiers(int access){
	LinkedList<String> modifiers = new LinkedList<String>();
	if((Opcodes.ACC_ABSTRACT & access) == Opcodes.ACC_ABSTRACT){
		modifiers.add("abstract");
	}
	if((Opcodes.ACC_ANNOTATION & access) == Opcodes.ACC_ANNOTATION){
		modifiers.add("annotation");
	}
	if((Opcodes.ACC_BRIDGE & access) == Opcodes.ACC_BRIDGE){
		modifiers.add("bridge");
	}
	if((Opcodes.ACC_DEPRECATED & access) == Opcodes.ACC_DEPRECATED){
		modifiers.add("deprecated");
	}
	if((Opcodes.ACC_ENUM & access) == Opcodes.ACC_ENUM){
		modifiers.add("enum");
	}
	if((Opcodes.ACC_FINAL & access) == Opcodes.ACC_FINAL){
		modifiers.add("final");
	}
	if((Opcodes.ACC_INTERFACE & access) == Opcodes.ACC_INTERFACE){
		modifiers.add("interface");
	}
	if((Opcodes.ACC_MANDATED & access) == Opcodes.ACC_MANDATED){
		modifiers.add("mandated");
	}
	if((Opcodes.ACC_NATIVE & access) == Opcodes.ACC_NATIVE){
		modifiers.add("native");
	}
	if((Opcodes.ACC_PRIVATE & access) == Opcodes.ACC_PRIVATE){
		modifiers.add("private");
	}
	if((Opcodes.ACC_PROTECTED & access) == Opcodes.ACC_PROTECTED){
		modifiers.add("protected");
	}
	if((Opcodes.ACC_PUBLIC & access) == Opcodes.ACC_PUBLIC){
		modifiers.add("public");
	}
	if((Opcodes.ACC_STATIC & access) == Opcodes.ACC_STATIC){
		modifiers.add("static");
	}
	if((Opcodes.ACC_STRICT & access) == Opcodes.ACC_STRICT){
		modifiers.add("strict");
	}
	if((Opcodes.ACC_SUPER & access) == Opcodes.ACC_SUPER){
		modifiers.add("super");
	}
	if((Opcodes.ACC_SYNCHRONIZED & access) == Opcodes.ACC_SYNCHRONIZED){
		modifiers.add("synchronized");
	}
	if((Opcodes.ACC_SYNTHETIC & access) == Opcodes.ACC_SYNTHETIC){
		modifiers.add("synthetic");
	}
	if((Opcodes.ACC_TRANSIENT & access) == Opcodes.ACC_TRANSIENT){
		modifiers.add("transient");
	}
	if((Opcodes.ACC_VARARGS & access) == Opcodes.ACC_VARARGS){
		modifiers.add("varargs");
	}
	if((Opcodes.ACC_VOLATILE & access) == Opcodes.ACC_VOLATILE){
		modifiers.add("volatile");
	}
	return modifiers.toString();
}
 
Example 13
Source File: Textifier.java    From JReFrameworker with MIT License 4 votes vote down vote up
@Override
public Textifier visitMethod(
    final int access,
    final String name,
    final String descriptor,
    final String signature,
    final String[] exceptions) {
  stringBuilder.setLength(0);
  stringBuilder.append('\n');
  if ((access & Opcodes.ACC_DEPRECATED) != 0) {
    stringBuilder.append(tab).append(DEPRECATED);
  }
  stringBuilder.append(tab);
  appendRawAccess(access);

  if (signature != null) {
    stringBuilder.append(tab);
    appendDescriptor(METHOD_SIGNATURE, signature);
    stringBuilder.append(tab);
    appendJavaDeclaration(name, signature);
  }

  stringBuilder.append(tab);
  appendAccess(access & ~(Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT));
  if ((access & Opcodes.ACC_NATIVE) != 0) {
    stringBuilder.append("native ");
  }
  if ((access & Opcodes.ACC_VARARGS) != 0) {
    stringBuilder.append("varargs ");
  }
  if ((access & Opcodes.ACC_BRIDGE) != 0) {
    stringBuilder.append("bridge ");
  }
  if ((this.access & Opcodes.ACC_INTERFACE) != 0
      && (access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC)) == 0) {
    stringBuilder.append("default ");
  }

  stringBuilder.append(name);
  appendDescriptor(METHOD_DESCRIPTOR, descriptor);
  if (exceptions != null && exceptions.length > 0) {
    stringBuilder.append(" throws ");
    for (String exception : exceptions) {
      appendDescriptor(INTERNAL_NAME, exception);
      stringBuilder.append(' ');
    }
  }

  stringBuilder.append('\n');
  text.add(stringBuilder.toString());
  return addNewTextifier(null);
}
 
Example 14
Source File: Textifier.java    From JReFrameworker with MIT License 4 votes vote down vote up
@Override
public Textifier visitMethod(
    final int access,
    final String name,
    final String descriptor,
    final String signature,
    final String[] exceptions) {
  stringBuilder.setLength(0);
  stringBuilder.append('\n');
  if ((access & Opcodes.ACC_DEPRECATED) != 0) {
    stringBuilder.append(tab).append(DEPRECATED);
  }
  stringBuilder.append(tab);
  appendRawAccess(access);

  if (signature != null) {
    stringBuilder.append(tab);
    appendDescriptor(METHOD_SIGNATURE, signature);
    stringBuilder.append(tab);
    appendJavaDeclaration(name, signature);
  }

  stringBuilder.append(tab);
  appendAccess(access & ~(Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT));
  if ((access & Opcodes.ACC_NATIVE) != 0) {
    stringBuilder.append("native ");
  }
  if ((access & Opcodes.ACC_VARARGS) != 0) {
    stringBuilder.append("varargs ");
  }
  if ((access & Opcodes.ACC_BRIDGE) != 0) {
    stringBuilder.append("bridge ");
  }
  if ((this.access & Opcodes.ACC_INTERFACE) != 0
      && (access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC)) == 0) {
    stringBuilder.append("default ");
  }

  stringBuilder.append(name);
  appendDescriptor(METHOD_DESCRIPTOR, descriptor);
  if (exceptions != null && exceptions.length > 0) {
    stringBuilder.append(" throws ");
    for (String exception : exceptions) {
      appendDescriptor(INTERNAL_NAME, exception);
      stringBuilder.append(' ');
    }
  }

  stringBuilder.append('\n');
  text.add(stringBuilder.toString());
  return addNewTextifier(null);
}
 
Example 15
Source File: Engine.java    From JReFrameworker with MIT License 4 votes vote down vote up
@SuppressWarnings("unused")
private static String getAccessModifiers(int access){
	LinkedList<String> modifiers = new LinkedList<String>();
	if((Opcodes.ACC_ABSTRACT & access) == Opcodes.ACC_ABSTRACT){
		modifiers.add("abstract");
	}
	if((Opcodes.ACC_ANNOTATION & access) == Opcodes.ACC_ANNOTATION){
		modifiers.add("annotation");
	}
	if((Opcodes.ACC_BRIDGE & access) == Opcodes.ACC_BRIDGE){
		modifiers.add("bridge");
	}
	if((Opcodes.ACC_DEPRECATED & access) == Opcodes.ACC_DEPRECATED){
		modifiers.add("deprecated");
	}
	if((Opcodes.ACC_ENUM & access) == Opcodes.ACC_ENUM){
		modifiers.add("enum");
	}
	if((Opcodes.ACC_FINAL & access) == Opcodes.ACC_FINAL){
		modifiers.add("final");
	}
	if((Opcodes.ACC_INTERFACE & access) == Opcodes.ACC_INTERFACE){
		modifiers.add("interface");
	}
	if((Opcodes.ACC_MANDATED & access) == Opcodes.ACC_MANDATED){
		modifiers.add("mandated");
	}
	if((Opcodes.ACC_NATIVE & access) == Opcodes.ACC_NATIVE){
		modifiers.add("native");
	}
	if((Opcodes.ACC_PRIVATE & access) == Opcodes.ACC_PRIVATE){
		modifiers.add("private");
	}
	if((Opcodes.ACC_PROTECTED & access) == Opcodes.ACC_PROTECTED){
		modifiers.add("protected");
	}
	if((Opcodes.ACC_PUBLIC & access) == Opcodes.ACC_PUBLIC){
		modifiers.add("public");
	}
	if((Opcodes.ACC_STATIC & access) == Opcodes.ACC_STATIC){
		modifiers.add("static");
	}
	if((Opcodes.ACC_STRICT & access) == Opcodes.ACC_STRICT){
		modifiers.add("strict");
	}
	if((Opcodes.ACC_SUPER & access) == Opcodes.ACC_SUPER){
		modifiers.add("super");
	}
	if((Opcodes.ACC_SYNCHRONIZED & access) == Opcodes.ACC_SYNCHRONIZED){
		modifiers.add("synchronized");
	}
	if((Opcodes.ACC_SYNTHETIC & access) == Opcodes.ACC_SYNTHETIC){
		modifiers.add("synthetic");
	}
	if((Opcodes.ACC_TRANSIENT & access) == Opcodes.ACC_TRANSIENT){
		modifiers.add("transient");
	}
	if((Opcodes.ACC_VARARGS & access) == Opcodes.ACC_VARARGS){
		modifiers.add("varargs");
	}
	if((Opcodes.ACC_VOLATILE & access) == Opcodes.ACC_VOLATILE){
		modifiers.add("volatile");
	}
	return modifiers.toString();
}