summaryrefslogtreecommitdiff
path: root/libart/src/main/java/dalvik/system/ClassExt.java
blob: e52303536d87807e5f5786c58bf891b180c463e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package dalvik.system;

/**
 * Holder class for extraneous Class data.
 *
 * This class holds data for Class objects that is either rarely useful, only necessary for
 * debugging purposes or both. This allows us to extend the Class class without impacting memory
 * use.
 *
 * @hide For internal runtime use only.
 */
public final class ClassExt {
    /**
     * A Pointer-sized-array of instance jfieldIDs in the same order as the ifields_ array.
     * The jfieldID is associated with the ArtField at the corresonding index in the ifields_ array.
     */
    private Object instanceJfieldIDs;

    /**
     * A Pointer-sized-array of jmethodIDS in the same order as the methods_
     * array. The jmethodID is associated with the ArtField at the corresonding
     * index in the methods_ array.
     */
    private Object jmethodIDs;

    /**
     * If the class has undergone structural redefinition, the now obsolete class object.
     *
     * Needed to ensure that the class isn't unloaded before its jit code is. Normally this is
     * handled by the classloader but since the class is now obsolete it's no longer held live
     * there and instead we must do so manually. This class should not be used for anything.
     */
    private Class<?> obsoleteClass;

    /**
     * An array of all obsolete DexCache objects that are needed for obsolete methods.
     *
     * These entries are associated with the obsolete ArtMethod pointers at the same indexes in the
     * obsoleteMethods array.
     *
     * This field has native components and is a logical part of the 'Class' type.
     */
    private Object[] obsoleteDexCaches;

    /**
     * An array of all native obsolete ArtMethod pointers.
     *
     * These are associated with their DexCaches at the same index in the obsoleteDexCaches array.
     *
     * This field is actually either an int[] or a long[] depending on size of a pointer.
     *
     * This field contains native pointers and is a logical part of the 'Class' type.
     */
    private Object obsoleteMethods;

    /**
     * If set, the bytes, native pointer (as a java.lang.Long), or DexCache of the original dex-file
     * associated with the related class.
     *
     * In this instance 'original' means either (1) the dex-file loaded for this class when it was
     * first loaded after all non-retransformation capable transformations had been performed but
     * before any retransformation capable ones had been done or (2) the most recent dex-file bytes
     * given for a class redefinition.
     *
     * Needed in order to implement retransformation of classes.
     *
     * This field is a logical part of the 'Class' type.
     */
    private Object originalDexFile;

    /**
     * A Pointer-sized-array of static jfieldIDs in the same order as the sfields_ array.
     * The jfieldID is associated with the ArtField at the corresonding index in the sfields_ array.
     */
    private Object staticJfieldIDs;

    /**
     * If class verify fails, we must return same error on subsequent tries. We may store either
     * the class of the error, or an actual instance of Throwable here.
     *
     * This field is a logical part of the 'Class' type.
     */
    private Object verifyError;

    /**
     * If set, native pointer to the initial, pre-redefine, dex file associated with the related
     * class. This is different from the {@code originalDexFile} which is the pre-retransform dex
     * file, i.e. could contain the bytes of the dex file provided during redefine.
     *
     * It is enough to store the native pointer because the pre-redefine dex file is either part
     * of boot classpath or it is being kept alive by its class loader. Class loaders always keep
     * dex files alive even if all their classes have been redefined.
     *
     * Needed in order to preserve access to dex-level hiddenapi flags after JVMTI redefine.
     *
     * This field is a logical part of the 'Class' type.
     */
    private long preRedefineDexFilePtr;

    /**
     * ClassDef index of the related class in the pre-redefine dex file. Set together with
     * {@code preRedefineDexFilePtr}.
     *
     * Needed in order to preserve access to dex-level hiddenapi flags after JVMTI redefine.
     *
     * This field is a logical part of the 'Class' type.
     */
    private int preRedefineClassDefIndex;


    /**
    * Private constructor.
    *
    * Only created by the runtime.
    */
    private ClassExt() {}
}