8311175: Move BufWriter::asByteBuffer to BufWriterImpl

Reviewed-by: asotona
This commit is contained in:
Chen Liang 2024-05-21 08:02:18 +00:00 committed by Adam Sotona
parent 451cc23905
commit 414a7fdc5e
4 changed files with 4 additions and 11 deletions

View File

@ -24,7 +24,6 @@
*/
package java.lang.classfile;
import java.nio.ByteBuffer;
import java.util.List;
import java.lang.classfile.constantpool.ConstantPool;
@ -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.
*

View File

@ -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
@ -171,9 +171,8 @@ public final class BufWriterImpl implements BufWriter {
return offset;
}
@Override
public ByteBuffer asByteBuffer() {
return ByteBuffer.wrap(elems, 0, offset);
return ByteBuffer.wrap(elems, 0, offset).slice();
}
@Override

View File

@ -51,7 +51,7 @@ public final class StackCounter {
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);
}

View File

@ -151,7 +151,7 @@ public final class StackMapGenerator {
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);