Skip to content

Commit

Permalink
8311175: Move BufWriter::asByteBuffer to BufWriterImpl
Browse files Browse the repository at this point in the history
Reviewed-by: asotona
  • Loading branch information
liach authored and asotona committed May 21, 2024
1 parent 451cc23 commit 414a7fd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package java.lang.classfile;

import java.nio.ByteBuffer;
import java.util.List;

import java.lang.classfile.constantpool.ConstantPool;
Expand Down Expand Up @@ -192,11 +191,6 @@ public sealed interface BufWriter
*/
int size();

/**
* {@return a {@link java.nio.ByteBuffer ByteBuffer} view of the bytes in the buffer}
*/
ByteBuffer asByteBuffer();

/**
* Copy the contents of the buffer into a byte array.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -171,9 +171,8 @@ public int size() {
return offset;
}

@Override
public ByteBuffer asByteBuffer() {
return ByteBuffer.wrap(elems, 0, offset);
return ByteBuffer.wrap(elems, 0, offset).slice();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static StackCounter of(DirectCodeBuilder dcb, BufWriterImpl buf) {
dcb.methodInfo.methodName().stringValue(),
dcb.methodInfo.methodTypeSymbol(),
(dcb.methodInfo.methodFlags() & ACC_STATIC) != 0,
dcb.bytecodesBufWriter.asByteBuffer().slice(0, dcb.bytecodesBufWriter.size()),
((BufWriterImpl) dcb.bytecodesBufWriter).asByteBuffer(),
dcb.constantPool,
dcb.handlers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static StackMapGenerator of(DirectCodeBuilder dcb, BufWriterImpl buf) {
dcb.methodInfo.methodName().stringValue(),
dcb.methodInfo.methodTypeSymbol(),
(dcb.methodInfo.methodFlags() & ACC_STATIC) != 0,
dcb.bytecodesBufWriter.asByteBuffer().slice(0, dcb.bytecodesBufWriter.size()),
((BufWriterImpl) dcb.bytecodesBufWriter).asByteBuffer(),
dcb.constantPool,
dcb.context,
dcb.handlers);
Expand Down

0 comments on commit 414a7fd

Please sign in to comment.