• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012, Google LLC
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google LLC nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 package com.android.tools.smali.dexlib2.iface;
32 
33 import com.android.tools.smali.dexlib2.iface.reference.TypeReference;
34 
35 import javax.annotation.Nonnull;
36 import javax.annotation.Nullable;
37 import java.util.List;
38 import java.util.Set;
39 
40 /**
41  * This class represents a class definition.
42  *
43  * It also acts as a TypeReference to itself. Any equality/comparison is based on its identity as a TypeReference,
44  * and shouldn't take into account anything other than the type of this class.
45  */
46 public interface ClassDef extends TypeReference, Annotatable {
47     /**
48      * Gets the class type.
49      *
50      * This will be a type descriptor per the dex file specification.
51      *
52      * @return The class type
53      */
getType()54     @Override @Nonnull String getType();
55 
56     /**
57      * Gets the access flags for this class.
58      *
59      * This will be a combination of the AccessFlags.* flags that are marked as compatible for use with a class.
60      *
61      * @return The access flags for this class
62      */
getAccessFlags()63     int getAccessFlags();
64 
65     /**
66      * Gets the superclass of this class.
67      *
68      * This will only be null if this is the base java.lang.Object class.
69      *
70      * @return The superclass of this class
71      */
getSuperclass()72     @Nullable String getSuperclass();
73 
74     /**
75      * Gets a list of the interfaces that this class implements.
76      *
77      * @return A list of the interfaces that this class implements
78      */
getInterfaces()79     @Nonnull List<String> getInterfaces();
80 
81     /**
82      * Gets the name of the primary source file that this class is defined in, if available.
83      *
84      * This will be the default source file associated with all methods defined in this class. This can be overridden
85      * for sections of an individual method with the SetSourceFile debug item.
86      *
87      * @return The name of the primary source file for this class, or null if not available
88      */
getSourceFile()89     @Nullable String getSourceFile();
90 
91     /**
92      * Gets a set of the annotations that are applied to this class.
93      *
94      * The annotations in the returned set are guaranteed to have unique types.
95      *
96      * @return A set of the annotations that are applied to this class
97      */
getAnnotations()98     @Override @Nonnull Set<? extends Annotation> getAnnotations();
99 
100     /**
101      * Gets the static fields that are defined by this class.
102      *
103      * The static fields that are returned must have no duplicates.
104      *
105      * @return The static fields that are defined by this class
106      */
getStaticFields()107     @Nonnull Iterable<? extends Field> getStaticFields();
108 
109     /**
110      * Gets the instance fields that are defined by this class.
111      *
112      * The instance fields that are returned must have no duplicates.
113      *
114      * @return The instance fields that are defined by this class
115      */
getInstanceFields()116     @Nonnull Iterable<? extends Field> getInstanceFields();
117 
118     /**
119      * Gets all the fields that are defined by this class.
120      *
121      * This is a convenience method that combines getStaticFields() and getInstanceFields()
122      *
123      * The returned fields may be in any order. I.e. It's not safe to assume that all instance fields will come after
124      * all static fields.
125      *
126      * Note that there typically should not be any duplicate fields between the two, but some versions of
127      * dalvik inadvertently allow duplicate static/instance fields, and are supported here for completeness
128      *
129      * @return A set of the fields that are defined by this class
130      */
getFields()131     @Nonnull Iterable<? extends Field> getFields();
132 
133     /**
134      * Gets the direct methods that are defined by this class.
135      *
136      * The direct methods that are returned must have no duplicates.
137      *
138      * @return The direct methods that are defined by this class.
139      */
getDirectMethods()140     @Nonnull Iterable<? extends Method> getDirectMethods();
141 
142     /**
143      * Gets the virtual methods that are defined by this class.
144      *
145      * The virtual methods that are returned must have no duplicates.
146      *
147      * @return The virtual methods that are defined by this class.
148      */
getVirtualMethods()149     @Nonnull Iterable<? extends Method> getVirtualMethods();
150 
151     /**
152      * Gets all the methods that are defined by this class.
153      *
154      * This is a convenience method that combines getDirectMethods() and getVirtualMethods().
155      *
156      * The returned methods may be in any order. I.e. It's not safe to assume that all virtual methods will come after
157      * all direct methods.
158      *
159      * Note that there typically should not be any duplicate methods between the two, but some versions of
160      * dalvik inadvertently allow duplicate direct/virtual methods, and are supported here for completeness
161      *
162      * @return An iterable of the methods that are defined by this class.
163      */
getMethods()164     @Nonnull Iterable<? extends Method> getMethods();
165 }
166