• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package dalvik.system;
18 
19 /**
20  * Holder class for extraneous Class data.
21  *
22  * This class holds data for Class objects that is either rarely useful, only necessary for
23  * debugging purposes or both. This allows us to extend the Class class without impacting memory
24  * use.
25  *
26  * @hide For internal runtime use only.
27  */
28 public final class ClassExt {
29     /**
30      * A Pointer-sized-array of instance jfieldIDs in the same order as the ifields_ array.
31      * The jfieldID is associated with the ArtField at the corresonding index in the ifields_ array.
32      */
33     private Object instanceJfieldIDs;
34 
35     /**
36      * A Pointer-sized-array of jmethodIDS in the same order as the methods_
37      * array. The jmethodID is associated with the ArtField at the corresonding
38      * index in the methods_ array.
39      */
40     private Object jmethodIDs;
41 
42     /**
43      * If the class has undergone structural redefinition, the now obsolete class object.
44      *
45      * Needed to ensure that the class isn't unloaded before its jit code is. Normally this is
46      * handled by the classloader but since the class is now obsolete it's no longer held live
47      * there and instead we must do so manually. This class should not be used for anything.
48      */
49     private Class<?> obsoleteClass;
50 
51     /**
52      * An array of all obsolete DexCache objects that are needed for obsolete methods.
53      *
54      * These entries are associated with the obsolete ArtMethod pointers at the same indexes in the
55      * obsoleteMethods array.
56      *
57      * This field has native components and is a logical part of the 'Class' type.
58      */
59     private Object[] obsoleteDexCaches;
60 
61     /**
62      * An array of all native obsolete ArtMethod pointers.
63      *
64      * These are associated with their DexCaches at the same index in the obsoleteDexCaches array.
65      *
66      * This field is actually either an int[] or a long[] depending on size of a pointer.
67      *
68      * This field contains native pointers and is a logical part of the 'Class' type.
69      */
70     private Object obsoleteMethods;
71 
72     /**
73      * If set, the bytes, native pointer (as a java.lang.Long), or DexCache of the original dex-file
74      * associated with the related class.
75      *
76      * In this instance 'original' means either (1) the dex-file loaded for this class when it was
77      * first loaded after all non-retransformation capable transformations had been performed but
78      * before any retransformation capable ones had been done or (2) the most recent dex-file bytes
79      * given for a class redefinition.
80      *
81      * Needed in order to implement retransformation of classes.
82      *
83      * This field is a logical part of the 'Class' type.
84      */
85     private Object originalDexFile;
86 
87     /**
88      * A Pointer-sized-array of static jfieldIDs in the same order as the sfields_ array.
89      * The jfieldID is associated with the ArtField at the corresonding index in the sfields_ array.
90      */
91     private Object staticJfieldIDs;
92 
93     /**
94      * If class verify fails, we must return same error on subsequent tries. We may store either
95      * the class of the error, or an actual instance of Throwable here.
96      *
97      * This field is a logical part of the 'Class' type.
98      */
99     private Object verifyError;
100 
101     /**
102      * If set, native pointer to the initial, pre-redefine, dex file associated with the related
103      * class. This is different from the {@code originalDexFile} which is the pre-retransform dex
104      * file, i.e. could contain the bytes of the dex file provided during redefine.
105      *
106      * It is enough to store the native pointer because the pre-redefine dex file is either part
107      * of boot classpath or it is being kept alive by its class loader. Class loaders always keep
108      * dex files alive even if all their classes have been redefined.
109      *
110      * Needed in order to preserve access to dex-level hiddenapi flags after JVMTI redefine.
111      *
112      * This field is a logical part of the 'Class' type.
113      */
114     private long preRedefineDexFilePtr;
115 
116     /**
117      * ClassDef index of the related class in the pre-redefine dex file. Set together with
118      * {@code preRedefineDexFilePtr}.
119      *
120      * Needed in order to preserve access to dex-level hiddenapi flags after JVMTI redefine.
121      *
122      * This field is a logical part of the 'Class' type.
123      */
124     private int preRedefineClassDefIndex;
125 
126 
127     /**
128     * Private constructor.
129     *
130     * Only created by the runtime.
131     */
ClassExt()132     private ClassExt() {}
133 }
134