0

Hello i have problems in this code and it's really bothering me because i don't know how to fix it, if you guys could help me then that would be great!

public void execute(final String name, final ClassNode cn) {
    Updater.getInstance().getClasses().set("Animable", cn);
    addProcessor(new AddInterfaceProcessor(this, cn.name, ACCESSOR_DESC + "Animable"));
    for (final MethodNode mn : cn.methods) {
        if ((mn.access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC | Opcodes.ACC_NATIVE)) != 0 || !mn.desc.equals("()Z")) {
            continue;
        }
        final RIS ris = new RIS(mn);
        FieldInsnNode fin;
        for (int i = 0; i < 4; i++) {
            if ((fin = ris.next(FieldInsnNode.class, Opcodes.GETFIELD)) == null) {
                continue;
            }
            addProcessor(new AddGetterProcessor(this, "get" + ((i & 1) != 0 ? "Max" : "Min") + (char) (Math.max(0, Math.min(1, i - 1)) + 88), fin.desc, cn.name, fin.name, fin.desc, false));
        }
        break;
    }
}

And the problem is in this part:

for (final MethodNode mn : cn.methods) {
        if ((mn.access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC | Opcodes.ACC_NATIVE)) != 0 || !mn.desc.equals("()Z")) {
            continue;
        }

How do i fix it?

Perception
  • 79,279
  • 19
  • 185
  • 195
Frunk
  • 180
  • 1
  • 2
  • 11

2 Answers2

1

The type of cn.methods must be either Object[] or Iterable<Object>.

You will have to use:

for (final Object obj : cn.methods) {
  MethodNode mn = (MethodNode)obj;

Or fix the type of cn.methods to be more specific.

jtahlborn
  • 52,909
  • 5
  • 76
  • 118
0
Objects mn and cn needs to be Initialized before u use in . 

for (final MethodNode mn : cn.methods) {
        if ((mn.access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC | Opcodes.ACC_NATIVE)) != 0 || !mn.desc.equals("()Z")) {
            continue;
        }
c.pramod
  • 606
  • 1
  • 8
  • 22