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

The following examples show how to use org.objectweb.asm.Opcodes#SOURCE_MASK . 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: CodeSizeEvaluator.java    From Concurnas with MIT License 6 votes vote down vote up
@Override
public void visitMethodInsn(
    final int opcodeAndSource,
    final String owner,
    final String name,
    final String descriptor,
    final boolean isInterface) {
  if (api < Opcodes.ASM5 && (opcodeAndSource & Opcodes.SOURCE_DEPRECATED) == 0) {
    // Redirect the call to the deprecated version of this method.
    super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface);
    return;
  }
  int opcode = opcodeAndSource & ~Opcodes.SOURCE_MASK;

  if (opcode == INVOKEINTERFACE) {
    minSize += 5;
    maxSize += 5;
  } else {
    minSize += 3;
    maxSize += 3;
  }
  super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface);
}
 
Example 2
Source File: AdviceAdapter.java    From Concurnas with MIT License 6 votes vote down vote up
@Override
public void visitMethodInsn(
    final int opcodeAndSource,
    final String owner,
    final String name,
    final String descriptor,
    final boolean isInterface) {
  if (api < Opcodes.ASM5 && (opcodeAndSource & Opcodes.SOURCE_DEPRECATED) == 0) {
    // Redirect the call to the deprecated version of this method.
    super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface);
    return;
  }
  super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface);
  int opcode = opcodeAndSource & ~Opcodes.SOURCE_MASK;

  doVisitMethodInsn(opcode, descriptor);
}
 
Example 3
Source File: MethodNode.java    From Concurnas with MIT License 6 votes vote down vote up
@Override
public void visitMethodInsn(
    final int opcodeAndSource,
    final String owner,
    final String name,
    final String descriptor,
    final boolean isInterface) {
  if (api < Opcodes.ASM5 && (opcodeAndSource & Opcodes.SOURCE_DEPRECATED) == 0) {
    // Redirect the call to the deprecated version of this method.
    super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface);
    return;
  }
  int opcode = opcodeAndSource & ~Opcodes.SOURCE_MASK;

  instructions.add(new MethodInsnNode(opcode, owner, name, descriptor, isInterface));
}
 
Example 4
Source File: MethodNode.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void visitMethodInsn(final int opcodeAndSource, final String owner, final String name, final String descriptor,
		final boolean isInterface) {
	if (api < Opcodes.ASM5 && (opcodeAndSource & Opcodes.SOURCE_DEPRECATED) == 0) {
		// Redirect the call to the deprecated version of this method.
		super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface);
		return;
	}
	int opcode = opcodeAndSource & ~Opcodes.SOURCE_MASK;

	instructions.add(new MethodInsnNode(opcode, owner, name, descriptor, isInterface));
}
 
Example 5
Source File: InstructionAdapter.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
public void visitMethodInsn(
    final int opcodeAndSource,
    final String owner,
    final String name,
    final String descriptor,
    final boolean isInterface) {
  if (api < Opcodes.ASM5 && (opcodeAndSource & Opcodes.SOURCE_DEPRECATED) == 0) {
    // Redirect the call to the deprecated version of this method.
    super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface);
    return;
  }
  int opcode = opcodeAndSource & ~Opcodes.SOURCE_MASK;

  switch (opcode) {
    case Opcodes.INVOKESPECIAL:
      invokespecial(owner, name, descriptor, isInterface);
      break;
    case Opcodes.INVOKEVIRTUAL:
      invokevirtual(owner, name, descriptor, isInterface);
      break;
    case Opcodes.INVOKESTATIC:
      invokestatic(owner, name, descriptor, isInterface);
      break;
    case Opcodes.INVOKEINTERFACE:
      invokeinterface(owner, name, descriptor);
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
Example 6
Source File: CheckMethodAdapter.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
public void visitMethodInsn(
    final int opcodeAndSource,
    final String owner,
    final String name,
    final String descriptor,
    final boolean isInterface) {
  if (api < Opcodes.ASM5 && (opcodeAndSource & Opcodes.SOURCE_DEPRECATED) == 0) {
    // Redirect the call to the deprecated version of this method.
    super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface);
    return;
  }
  int opcode = opcodeAndSource & ~Opcodes.SOURCE_MASK;

  checkVisitCodeCalled();
  checkVisitMaxsNotCalled();
  checkOpcodeMethod(opcode, Method.VISIT_METHOD_INSN);
  if (opcode != Opcodes.INVOKESPECIAL || !"<init>".equals(name)) {
    checkMethodIdentifier(version, name, "name");
  }
  checkInternalName(version, owner, "owner");
  checkMethodDescriptor(version, descriptor);
  if (opcode == Opcodes.INVOKEVIRTUAL && isInterface) {
    throw new IllegalArgumentException("INVOKEVIRTUAL can't be used with interfaces");
  }
  if (opcode == Opcodes.INVOKEINTERFACE && !isInterface) {
    throw new IllegalArgumentException("INVOKEINTERFACE can't be used with classes");
  }
  if (opcode == Opcodes.INVOKESPECIAL && isInterface && (version & 0xFFFF) < Opcodes.V1_8) {
    throw new IllegalArgumentException(
        "INVOKESPECIAL can't be used with interfaces prior to Java 8");
  }
  super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface);
  ++insnCount;
}
 
Example 7
Source File: AnalyzerAdapter.java    From Concurnas with MIT License 4 votes vote down vote up
@Override
public void visitMethodInsn(
    final int opcodeAndSource,
    final String owner,
    final String name,
    final String descriptor,
    final boolean isInterface) {
  if (api < Opcodes.ASM5 && (opcodeAndSource & Opcodes.SOURCE_DEPRECATED) == 0) {
    // Redirect the call to the deprecated version of this method.
    super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface);
    return;
  }
  super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface);
  int opcode = opcodeAndSource & ~Opcodes.SOURCE_MASK;

  if (this.locals == null) {
    labels = null;
    return;
  }
  pop(descriptor);
  if (opcode != Opcodes.INVOKESTATIC) {
    Object value = pop();
    if (opcode == Opcodes.INVOKESPECIAL && name.equals("<init>")) {
      Object initializedValue;
      if (value == Opcodes.UNINITIALIZED_THIS) {
        initializedValue = this.owner;
      } else {
        initializedValue = uninitializedTypes.get(value);
      }
      for (int i = 0; i < locals.size(); ++i) {
        if (locals.get(i) == value) {
          locals.set(i, initializedValue);
        }
      }
      for (int i = 0; i < stack.size(); ++i) {
        if (stack.get(i) == value) {
          stack.set(i, initializedValue);
        }
      }
    }
  }
  pushDescriptor(descriptor);
  labels = null;
}