1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package dalvik.system;
18
19import java.nio.ByteBuffer;
20
21/**
22 * A {@link ClassLoader} implementation that loads classes from a
23 * buffer containing a DEX file. This can be used to execute code that
24 * has not been written to the local file system.
25 */
26public final class InMemoryDexClassLoader extends BaseDexClassLoader {
27    /**
28     * Create an in-memory DEX class loader with the given dex buffers.
29     *
30     * @param dexBuffers array of buffers containing DEX files between
31     *                       <tt>buffer.position()</tt> and <tt>buffer.limit()</tt>.
32     * @param parent the parent class loader for delegation.
33     * @hide
34     */
35    public InMemoryDexClassLoader(ByteBuffer[] dexBuffers, ClassLoader parent) {
36        super(dexBuffers, parent);
37    }
38
39    /**
40     * Creates a new in-memory DEX class loader.
41     *
42     * @param dexBuffer buffer containing DEX file contents between
43     *                       <tt>buffer.position()</tt> and <tt>buffer.limit()</tt>.
44     * @param parent the parent class loader for delegation.
45     */
46    public InMemoryDexClassLoader(ByteBuffer dexBuffer, ClassLoader parent) {
47        this(new ByteBuffer[] { dexBuffer }, parent);
48    }
49}
50