Skip to content

Commit 414a7fd

Browse files
liachasotona
authored andcommitted
8311175: Move BufWriter::asByteBuffer to BufWriterImpl
Reviewed-by: asotona
1 parent 451cc23 commit 414a7fd

File tree

4 files changed

+4
-11
lines changed

4 files changed

+4
-11
lines changed

src/java.base/share/classes/java/lang/classfile/BufWriter.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
package java.lang.classfile;
2626

27-
import java.nio.ByteBuffer;
2827
import java.util.List;
2928

3029
import java.lang.classfile.constantpool.ConstantPool;
@@ -192,11 +191,6 @@ public sealed interface BufWriter
192191
*/
193192
int size();
194193

195-
/**
196-
* {@return a {@link java.nio.ByteBuffer ByteBuffer} view of the bytes in the buffer}
197-
*/
198-
ByteBuffer asByteBuffer();
199-
200194
/**
201195
* Copy the contents of the buffer into a byte array.
202196
*

src/java.base/share/classes/jdk/internal/classfile/impl/BufWriterImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -171,9 +171,8 @@ public int size() {
171171
return offset;
172172
}
173173

174-
@Override
175174
public ByteBuffer asByteBuffer() {
176-
return ByteBuffer.wrap(elems, 0, offset);
175+
return ByteBuffer.wrap(elems, 0, offset).slice();
177176
}
178177

179178
@Override

src/java.base/share/classes/jdk/internal/classfile/impl/StackCounter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static StackCounter of(DirectCodeBuilder dcb, BufWriterImpl buf) {
5151
dcb.methodInfo.methodName().stringValue(),
5252
dcb.methodInfo.methodTypeSymbol(),
5353
(dcb.methodInfo.methodFlags() & ACC_STATIC) != 0,
54-
dcb.bytecodesBufWriter.asByteBuffer().slice(0, dcb.bytecodesBufWriter.size()),
54+
((BufWriterImpl) dcb.bytecodesBufWriter).asByteBuffer(),
5555
dcb.constantPool,
5656
dcb.handlers);
5757
}

src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static StackMapGenerator of(DirectCodeBuilder dcb, BufWriterImpl buf) {
151151
dcb.methodInfo.methodName().stringValue(),
152152
dcb.methodInfo.methodTypeSymbol(),
153153
(dcb.methodInfo.methodFlags() & ACC_STATIC) != 0,
154-
dcb.bytecodesBufWriter.asByteBuffer().slice(0, dcb.bytecodesBufWriter.size()),
154+
((BufWriterImpl) dcb.bytecodesBufWriter).asByteBuffer(),
155155
dcb.constantPool,
156156
dcb.context,
157157
dcb.handlers);

0 commit comments

Comments
 (0)