"Thread-782" daemon prio=10 tid=0x00007f7db4654800 nid=0x2286d9 in Object.wait() [0x00007f7b929d6000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000b843f3c8> (a java.util.LinkedList) at java.lang.Object.wait(Object.java:503) at com.aol.saabclient.SAABConnection.AsynchMsgProcessor.run(AsynchMsgProcessor.java:83) - locked <0x00000000b843f3c8> (a java.util.LinkedList) "Thread-781" daemon prio=10 tid=0x00007f7db4651000 nid=0x2286d7 in Object.wait() [0x00007f7de37ee000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000b843f3c8> (a java.util.LinkedList) at java.lang.Object.wait(Object.java:503) at com.aol.saabclient.SAABConnection.AsynchMsgProcessor.run(AsynchMsgProcessor.java:83) - locked <0x00000000b843f3c8> (a java.util.LinkedList) "Thread-780" daemon prio=10 tid=0x00007f7db464f000 nid=0x2286d5 in Object.wait() [0x00007f7de118a000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000b843f3c8> (a java.util.LinkedList) at java.lang.Object.wait(Object.java:503) at com.aol.saabclient.SAABConnection.AsynchMsgProcessor.run(AsynchMsgProcessor.java:83) - locked <0x00000000b843f3c8> (a java.util.LinkedList)
Textifier textifier = new Textifier(Opcodes.ASM5) { @Override public void visitLabel(Label label) { buf.setLength(0); buf.append('#'); appendLabel(label); buf.append(":\n"); text.add(buf.toString()); } @Override public void visitLineNumber(int line, Label start) { buf.setLength(0); buf.append("// line ").append(line).append('\n'); text.add(buf.toString()); } @Override public void visitMaxs(int maxStack, int maxLocals) { buf.setLength(0); buf.append("// MAXSTACK = ").append(maxStack).append('\n'); text.add(buf.toString()); buf.setLength(0); buf.append("// MAXLOCALS = ").append(maxLocals).append('\n'); text.add(buf.toString()); } @Override public void visitLdcInsn(Object cst) { buf.setLength(0); buf.append(tab2).append("LDC "); if (cst instanceof String) { Printer.appendString(buf, (String) cst); } else if (cst instanceof org.objectweb.asm.Type) { buf.append(((org.objectweb.asm.Type) cst).getDescriptor()).append(".class"); } else if (cst instanceof Long) { buf.append(cst).append('L'); } else if (cst instanceof Float) { buf.append(cst).append('F'); } else if (cst instanceof Double) { buf.append(cst).append('D'); } else if (cst instanceof Integer) { buf.append(cst); } else { throw new IllegalArgumentException("cst " + cst); } buf.append('\n'); text.add(buf.toString()); } @Override public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) { } };
for (String line : methodCode.getText().split("\n")) { int lastCommentPos = line.lastIndexOf("//"); if (lastCommentPos != -1) { line = line.substring(0, lastCommentPos); } line = line.trim(); if (line.isEmpty()) { continue; } String[] withParams = line.split("\\s+"); String command = withParams[0]; if (command.startsWith("#")) { verify(command.endsWith(":")); String substring = command.substring(1, command.length() - 1); method.visitLabel(getLabel(substring, labels)); } else if (command.equals("TRYCATCHBLOCK")) { verify(withParams.length == 5); Label start = getLabel(withParams[1], labels); Label end = getLabel(withParams[2], labels); Label handler = getLabel(withParams[3], labels); String type = withParams[4]; if (type.equals("null")) { type = null; } method.visitTryCatchBlock(start, end, handler, type); } else { Opcode opcode = OPCODES.get(command); // ASM if (opcode == null) { throw new RuntimeException("Unknown " + command); } else { switch (opcode.type) { case OpcodeGroup.INSN: verify(withParams.length == 1); method.visitInsn(opcode.opcode); break; case OpcodeGroup.INSN_INT: verify(withParams.length == 2); method.visitIntInsn(opcode.opcode, Integer.valueOf(withParams[1])); break; case OpcodeGroup.INSN_VAR: verify(withParams.length == 2); method.visitVarInsn(opcode.opcode, Integer.valueOf(withParams[1])); break; case OpcodeGroup.INSN_TYPE: verify(withParams.length == 2); method.visitTypeInsn(opcode.opcode, withParams[1]); break; case OpcodeGroup.INSN_FIELD: verify(withParams.length == 4); verify(withParams[2].equals(":")); int dotIndex = withParams[1].indexOf('.'); String owner = withParams[1].substring(0, dotIndex); String name = withParams[1].substring(dotIndex + 1); method.visitFieldInsn(opcode.opcode, owner, name, withParams[3]); break; case OpcodeGroup.INSN_METHOD: verify(withParams.length == 3); dotIndex = withParams[1].indexOf('.'); owner = withParams[1].substring(0, dotIndex); name = withParams[1].substring(dotIndex + 1); method.visitMethodInsn(opcode.opcode, owner, name, withParams[2], opcode.opcode == INVOKEINTERFACE); break; case OpcodeGroup.INSN_JUMP: verify(withParams.length == 2); method.visitJumpInsn(opcode.opcode, getLabel(withParams[1], labels)); break; case OpcodeGroup.INSN_LDC: withParams = line.split("\\s+", 2); verify(withParams.length == 2); method.visitLdcInsn(parseLdc(withParams[1])); break; case OpcodeGroup.INSN_IINC: verify(withParams.length == 3); method.visitIincInsn(Integer.valueOf(withParams[1]), Integer.valueOf(withParams[2])); break; case OpcodeGroup.INSN_MULTIANEWARRAY: verify(withParams.length == 3); method.visitMultiANewArrayInsn(withParams[1], Integer.valueOf(withParams[2])); break; default: throw new IllegalArgumentException(); } } } }
Source: https://habr.com/ru/post/271829/
All Articles