1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 /*
18  * Copyright (C) 2012 The Android Open Source Project
19  *
20  * Licensed under the Apache License, Version 2.0 (the "License");
21  * you may not use this file except in compliance with the License.
22  * You may obtain a copy of the License at
23  *
24  *      http://www.apache.org/licenses/LICENSE-2.0
25  *
26  * Unless required by applicable law or agreed to in writing, software
27  * distributed under the License is distributed on an "AS IS" BASIS,
28  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29  * See the License for the specific language governing permissions and
30  * limitations under the License.
31  */
32 
33 package java.lang;
34 
35 import android.compat.annotation.UnsupportedAppUsage;
36 import dalvik.annotation.optimization.FastNative;
37 
38 /**
39  * A dex cache holds resolved copies of strings, fields, methods, and classes from the dexfile.
40  */
41 final class DexCache {
42     /** The classloader this dex cache is for. */
43     private ClassLoader classLoader;
44 
45     /** The location of the associated dex file. */
46     private String location;
47 
48     /** Holds C pointer to dexFile. */
49     @UnsupportedAppUsage
50     private long dexFile;
51 
52     /**
53      * References to pre resolved strings.
54      */
55     private long preResolvedStrings;
56 
57     /**
58      * References to CallSite (C array pointer) as they become resolved following
59      * interpreter semantics.
60      */
61     private long resolvedCallSites;
62 
63     /**
64      * References to fields (C array pointer) as they become resolved following
65      * interpreter semantics. May refer to fields defined in other dex files.
66      */
67     private long resolvedFields;
68 
69     /**
70      * References to MethodType (C array pointer) as they become resolved following
71      * interpreter semantics.
72      */
73     private long resolvedMethodTypes;
74 
75     /**
76      * References to methods (C array pointer) as they become resolved following
77      * interpreter semantics. May refer to methods defined in other dex files.
78      */
79     private long resolvedMethods;
80 
81     /**
82      * References to types (C array pointer) as they become resolved following
83      * interpreter semantics. May refer to types defined in other dex files.
84      */
85     private long resolvedTypes;
86 
87     /**
88      * References to strings (C array pointer) as they become resolved following
89      * interpreter semantics. All strings are interned.
90      */
91     private long strings;
92 
93     /**
94      * The number of elements in the native pre resolved strings array.
95      */
96     private int numPreResolvedStrings;
97 
98     /**
99      * The number of elements in the native call sites array.
100      */
101     private int numResolvedCallSites;
102 
103     /**
104      * The number of elements in the native resolvedFields array.
105      */
106     private int numResolvedFields;
107 
108     /**
109      * The number of elements in the native method types array.
110      */
111     private int numResolvedMethodTypes;
112 
113     /**
114      * The number of elements in the native resolvedMethods array.
115      */
116     private int numResolvedMethods;
117 
118     /**
119      * The number of elements in the native resolvedTypes array.
120      */
121     private int numResolvedTypes;
122 
123     /**
124      * The number of elements in the native strings array.
125      */
126     private int numStrings;
127 
128     // Only created by the VM.
DexCache()129     private DexCache() {}
130 }
131