src/java.base/share/classes/jdk/internal/jimage/ImageStream.java
author erikj
Wed, 07 Mar 2018 13:26:15 -0800
changeset 49357 aaedb8343784
parent 47216 71c04702a3d5
permissions -rw-r--r--
8198243: Add build time check for global operator new/delete in object files Reviewed-by: tbell, kbarrett, dholmes, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     1
/*
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     4
 *
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
39759
427916042881 8161718: Copyright/License updates to corba, jdk
bchristi
parents: 38582
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    10
 *
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
39759
427916042881 8161718: Copyright/License updates to corba, jdk
bchristi
parents: 38582
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    15
 * accompanied this code).
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    16
 *
39759
427916042881 8161718: Copyright/License updates to corba, jdk
bchristi
parents: 38582
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    20
 *
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    23
 * questions.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    24
 */
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    25
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    26
package jdk.internal.jimage;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    27
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    28
import java.nio.ByteBuffer;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    29
import java.nio.ByteOrder;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    30
import java.util.Arrays;
38582
8618f4ccb220 8156209: Add argument checks to BasicImageReader calls
jlaskey
parents: 36511
diff changeset
    31
import java.util.Objects;
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    32
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    33
/**
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    34
 * @implNote This class needs to maintain JDK 8 source compatibility.
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    35
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    36
 * It is used internally in the JDK to implement jimage/jrtfs access,
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    37
 * but also compiled and delivered as part of the jrtfs.jar to support access
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    38
 * to the jimage file provided by the shipped JDK by tools running on JDK 8.
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    39
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    40
public class ImageStream {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    41
    private ByteBuffer buffer;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    42
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    43
    public ImageStream() {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    44
        this(1024, ByteOrder.nativeOrder());
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    45
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    46
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    47
    public ImageStream(int size) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    48
        this(size, ByteOrder.nativeOrder());
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    49
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    50
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    51
    public ImageStream(byte[] bytes) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    52
       this(bytes, ByteOrder.nativeOrder());
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    53
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    54
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    55
    public ImageStream(ByteOrder byteOrder) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    56
        this(1024, byteOrder);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    57
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    58
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    59
    public ImageStream(int size, ByteOrder byteOrder) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    60
        buffer = ByteBuffer.allocate(size);
38582
8618f4ccb220 8156209: Add argument checks to BasicImageReader calls
jlaskey
parents: 36511
diff changeset
    61
        buffer.order(Objects.requireNonNull(byteOrder));
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    62
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    63
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    64
    public ImageStream(byte[] bytes, ByteOrder byteOrder) {
38582
8618f4ccb220 8156209: Add argument checks to BasicImageReader calls
jlaskey
parents: 36511
diff changeset
    65
        buffer = ByteBuffer.wrap(Objects.requireNonNull(bytes));
8618f4ccb220 8156209: Add argument checks to BasicImageReader calls
jlaskey
parents: 36511
diff changeset
    66
        buffer.order(Objects.requireNonNull(byteOrder));
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    67
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    68
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    69
    public ImageStream(ByteBuffer buffer) {
38582
8618f4ccb220 8156209: Add argument checks to BasicImageReader calls
jlaskey
parents: 36511
diff changeset
    70
        this.buffer = Objects.requireNonNull(buffer);
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    71
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    72
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    73
    public ImageStream align(int alignment) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    74
        int padding = (getSize() - 1) & ((1 << alignment) - 1);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    75
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    76
        for (int i = 0; i < padding; i++) {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    77
            put((byte)0);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    78
        }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    79
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    80
        return this;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    81
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    82
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    83
    public void ensure(int needs) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    84
        if (needs < 0) {
41121
91734a3ed04b 8151832: Improve exception messages in exception thrown by new JDK 9 code
coffeys
parents: 39759
diff changeset
    85
            throw new IndexOutOfBoundsException("Bad value: " + needs);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    86
        }
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    87
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    88
        if (needs > buffer.remaining()) {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    89
            byte[] bytes = buffer.array();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    90
            ByteOrder byteOrder = buffer.order();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    91
            int position = buffer.position();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    92
            int newSize = needs <= bytes.length ? bytes.length << 1 : position + needs;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    93
            buffer = ByteBuffer.allocate(newSize);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    94
            buffer.order(byteOrder);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    95
            buffer.put(bytes, 0, position);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    96
        }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    97
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    98
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
    99
    public boolean hasByte() {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   100
        return buffer.remaining() != 0;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   101
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   102
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   103
    public boolean hasBytes(int needs) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   104
        return needs <= buffer.remaining();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   105
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   106
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   107
    public void skip(int n) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   108
        if (n < 0) {
41121
91734a3ed04b 8151832: Improve exception messages in exception thrown by new JDK 9 code
coffeys
parents: 39759
diff changeset
   109
            throw new IndexOutOfBoundsException("skip value = " + n);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   110
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   111
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   112
        buffer.position(buffer.position() + n);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   113
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   114
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   115
    public int get() {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   116
        return buffer.get() & 0xFF;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   117
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   118
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   119
    public void get(byte bytes[], int offset, int size) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   120
        buffer.get(bytes, offset, size);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   121
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   122
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   123
    public int getShort() {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   124
        return buffer.getShort();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   125
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   126
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   127
    public int getInt() {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   128
        return buffer.getInt();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   129
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   130
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   131
    public long getLong() {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   132
        return buffer.getLong();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   133
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   134
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   135
    public ImageStream put(byte byt) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   136
        ensure(1);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   137
        buffer.put(byt);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   138
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   139
        return this;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   140
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   141
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   142
    public ImageStream put(int byt) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   143
        return put((byte)byt);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   144
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   145
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   146
    public ImageStream put(byte bytes[], int offset, int size) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   147
        ensure(size);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   148
        buffer.put(bytes, offset, size);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   149
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   150
        return this;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   151
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   152
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   153
    public ImageStream put(ImageStream stream) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   154
        put(stream.buffer.array(), 0, stream.buffer.position());
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   155
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   156
        return this;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   157
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   158
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   159
    public ImageStream putShort(short value) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   160
        ensure(2);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   161
        buffer.putShort(value);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   162
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   163
        return this;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   164
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   165
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   166
    public ImageStream putShort(int value) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   167
        return putShort((short)value);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   168
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   169
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   170
    public ImageStream putInt(int value) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   171
        ensure(4);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   172
        buffer.putInt(value);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   173
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   174
        return this;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   175
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   176
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   177
    public ImageStream putLong(long value) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   178
        ensure(8);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   179
        buffer.putLong(value);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   180
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   181
        return this;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   182
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   183
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   184
    public ByteBuffer getBuffer() {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   185
        return buffer;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   186
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   187
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   188
    public int getPosition() {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   189
        return buffer.position();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   190
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   191
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   192
    public int getSize() {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   193
        return buffer.position();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   194
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   195
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   196
    public byte[] getBytes() {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   197
        return buffer.array();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   198
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   199
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   200
    public void setPosition(int offset) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   201
        buffer.position(offset);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   202
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   203
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31673
diff changeset
   204
    public byte[] toArray() {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   205
        return Arrays.copyOf(buffer.array(), buffer.position());
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   206
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   207
}