public CodeAttribute(ClassMethod method, ConstPool constPool) { super(NAME, constPool); this.method = method; this.constPool = constPool; this.finalDataBytes = new ByteArrayOutputStream(); this.data = new DataOutputStream(finalDataBytes); if (!Modifier.isStatic(method.getAccessFlags())) { maxLocals++; } for (String param : method.getParameters()) { if (DescriptorUtils.isWide(param)) { maxLocals += 2; } else { maxLocals++; } } // creates a new initial stack frame currentFrame = new StackFrame(method); stackFrames.put(0, currentFrame); currentOffset = 0; stackMapTableAttribute = new StackMapTableAttribute(method, constPool); }
@Override public void writeData(ByteArrayDataOutputStream stream) throws IOException { // as we don't know the size yet we write everything to a byte stream first // TODO: make this better final CodeAttribute ca = method.getCodeAttribute(); // now we need to write the stack frames. // for now we are going to write all frames as full frames // TODO: optimise the frame creation // write to dstream LazySize size = stream.writeSize(); stream.writeShort(ca.getStackFrames().size()); int lastPos = -1; for (Entry<Integer, StackFrame> entry : method.getCodeAttribute().getStackFrames().entrySet()) { int offset = entry.getKey() - lastPos - 1; lastPos = entry.getKey(); StackFrame frame = entry.getValue(); if (frame.getType() == StackFrameType.SAME_FRAME || frame.getType() == StackFrameType.SAME_FRAME_EXTENDED) { writeSameFrame(stream, offset, lastPos, frame); } else if (frame.getType() == StackFrameType.SAME_LOCALS_1_STACK && offset < (127 - 64)) { writeSameLocals1Stack(stream, offset, lastPos, frame); } else { writeFullFrame(stream, offset, lastPos, entry.getValue()); } } size.markEnd(); }
@Override public void writeData(ByteArrayDataOutputStream stream) throws IOException { // as we don't know the size yet we write everything to a byte stream first // TODO: make this better final CodeAttribute ca = method.getCodeAttribute(); // now we need to write the stack frames. // for now we are going to write all frames as full frames // TODO: optimise the frame creation // write to dstream LazySize size = stream.writeSize(); stream.writeShort(ca.getStackFrames().size()); int lastPos = -1; for (Entry<Integer, StackFrame> entry : method.getCodeAttribute().getStackFrames().entrySet()) { int offset = entry.getKey() - lastPos - 1; lastPos = entry.getKey(); StackFrame frame = entry.getValue(); if (frame.getType() == StackFrameType.SAME_FRAME || frame.getType() == StackFrameType.SAME_FRAME_EXTENDED) { writeSameFrame(stream, offset, lastPos, frame); } else if (frame.getType() == StackFrameType.SAME_LOCALS_1_STACK && offset < (127 - 64)) { writeSameLocals1Stack(stream, offset, lastPos, frame); } else { writeFullFrame(stream, offset, lastPos, entry.getValue()); } } size.markEnd(); }
@Override public void writeData(ByteArrayDataOutputStream stream) throws IOException { // as we don't know the size yet we write everything to a byte stream first // TODO: make this better final CodeAttribute ca = method.getCodeAttribute(); // now we need to write the stack frames. // for now we are going to write all frames as full frames // TODO: optimise the frame creation // write to dstream LazySize size = stream.writeSize(); stream.writeShort(ca.getStackFrames().size()); int lastPos = -1; for (Entry<Integer, StackFrame> entry : method.getCodeAttribute().getStackFrames().entrySet()) { int offset = entry.getKey() - lastPos - 1; lastPos = entry.getKey(); StackFrame frame = entry.getValue(); if (frame.getType() == StackFrameType.SAME_FRAME || frame.getType() == StackFrameType.SAME_FRAME_EXTENDED) { writeSameFrame(stream, offset, lastPos, frame); } else if (frame.getType() == StackFrameType.SAME_LOCALS_1_STACK && offset < (127 - 64)) { writeSameLocals1Stack(stream, offset, lastPos, frame); } else { writeFullFrame(stream, offset, lastPos, entry.getValue()); } } size.markEnd(); }
public CodeAttribute(ClassMethod method, ConstPool constPool) { super(NAME, constPool); this.method = method; this.constPool = constPool; this.finalDataBytes = new ByteArrayOutputStream(); this.data = new DataOutputStream(finalDataBytes); if (!Modifier.isStatic(method.getAccessFlags())) { maxLocals++; } for (String param : method.getParameters()) { if (DescriptorUtils.isWide(param)) { maxLocals += 2; } else { maxLocals++; } } // creates a new initial stack frame currentFrame = new StackFrame(method); stackFrames.put(0, currentFrame); currentOffset = 0; stackMapTableAttribute = new StackMapTableAttribute(method, constPool); }
@Override public void writeData(ByteArrayDataOutputStream stream) throws IOException { // as we don't know the size yet we write everything to a byte stream first // TODO: make this better final CodeAttribute ca = method.getCodeAttribute(); // now we need to write the stack frames. // for now we are going to write all frames as full frames // TODO: optimise the frame creation // write to dstream LazySize size = stream.writeSize(); stream.writeShort(ca.getStackFrames().size()); int lastPos = -1; for (Entry<Integer, StackFrame> entry : method.getCodeAttribute().getStackFrames().entrySet()) { int offset = entry.getKey() - lastPos - 1; lastPos = entry.getKey(); StackFrame frame = entry.getValue(); if (frame.getType() == StackFrameType.SAME_FRAME || frame.getType() == StackFrameType.SAME_FRAME_EXTENDED) { writeSameFrame(stream, offset, lastPos, frame); } else if (frame.getType() == StackFrameType.SAME_LOCALS_1_STACK && offset < (127 - 64)) { writeSameLocals1Stack(stream, offset, lastPos, frame); } else { writeFullFrame(stream, offset, lastPos, entry.getValue()); } } size.markEnd(); }
public CodeAttribute(ClassMethod method, ConstPool constPool) { super(NAME, constPool); this.method = method; this.constPool = constPool; this.finalDataBytes = new ByteArrayOutputStream(); this.data = new DataOutputStream(finalDataBytes); if (!Modifier.isStatic(method.getAccessFlags())) { maxLocals++; } for (String param : method.getParameters()) { if (DescriptorUtils.isWide(param)) { maxLocals += 2; } else { maxLocals++; } } // creates a new initial stack frame currentFrame = new StackFrame(method); stackFrames.put(0, currentFrame); currentOffset = 0; stackMapTableAttribute = new StackMapTableAttribute(method, constPool); }
@Override public void writeData(ByteArrayDataOutputStream stream) throws IOException { // as we don't know the size yet we write everything to a byte stream first // TODO: make this better final CodeAttribute ca = method.getCodeAttribute(); // now we need to write the stack frames. // for now we are going to write all frames as full frames // TODO: optimise the frame creation // write to dstream LazySize size = stream.writeSize(); stream.writeShort(ca.getStackFrames().size()); int lastPos = -1; for (Entry<Integer, StackFrame> entry : method.getCodeAttribute().getStackFrames().entrySet()) { int offset = entry.getKey() - lastPos - 1; lastPos = entry.getKey(); StackFrame frame = entry.getValue(); if (frame.getType() == StackFrameType.SAME_FRAME || frame.getType() == StackFrameType.SAME_FRAME_EXTENDED) { writeSameFrame(stream, offset, lastPos, frame); } else if (frame.getType() == StackFrameType.SAME_LOCALS_1_STACK && offset < (127 - 64)) { writeSameLocals1Stack(stream, offset, lastPos, frame); } else { writeFullFrame(stream, offset, lastPos, entry.getValue()); } } size.markEnd(); }
public CodeAttribute(ClassMethod method, ConstPool constPool) { super(NAME, constPool); this.method = method; this.constPool = constPool; this.finalDataBytes = new ByteArrayOutputStream(); this.data = new DataOutputStream(finalDataBytes); if (!Modifier.isStatic(method.getAccessFlags())) { maxLocals++; } for (String param : method.getParameters()) { if (DescriptorUtils.isWide(param)) { maxLocals += 2; } else { maxLocals++; } } // creates a new initial stack frame currentFrame = new StackFrame(method); stackFrames.put(0, currentFrame); currentOffset = 0; stackMapTableAttribute = new StackMapTableAttribute(method, constPool); }
public CodeAttribute(ClassMethod method, ConstPool constPool) { super(NAME, constPool); this.method = method; this.constPool = constPool; this.finalDataBytes = new ByteArrayOutputStream(); this.data = new DataOutputStream(finalDataBytes); if (!Modifier.isStatic(method.getAccessFlags())) { maxLocals++; } for (String param : method.getParameters()) { if (DescriptorUtils.isWide(param)) { maxLocals += 2; } else { maxLocals++; } } // creates a new initial stack frame currentFrame = new StackFrame(method); stackFrames.put(0, currentFrame); currentOffset = 0; stackMapTableAttribute = new StackMapTableAttribute(method, constPool); }