# Interface: com.pnfsoftware.jeb.core.units.code.android.IDexUnit

Interface for units representing Android Dalvik bytecode containers, aka Dex files. The Dex unit interface is a virtual view of the Dex bytecode contained an Android application \(APK\). 

 Dex units use Java\-style internal addresses to identify items:
 \- package: `Lcom/abc/`
 \- type: `Lcom/abc/Foo;`
 \- method: `Lcom/abc/Foo;->bar(I[JLjava/Lang/String;)V`
 \- field: `Lcom/abc/Foo;->flag1:Z`
 More information here. 

 Note that in the case of multi\-Dex APKs, the Dex unit represents a virtual, unified view of the separate Dex files contained in the APK. If required, the individual information about those Dex files can be retrieved via [IDexFile](IDexFile). 

 Like many units, Dex unit objects emit [J#UnitChange](J#UnitChange) when the unit contents is being changed. IDexUnit set up event objects such that [JebEvent#getData()](JebEvent#getData()) will return a [UnitChangeEventData](UnitChangeEventData) with fields reasonably populated. 

 How use the JEB API to interact with those objects?
 \- Writing JEB client scripts in Python is a great way to ease into the JEB API.
 \- Visit this public GitHub repository for sample code
 \- In the JEB client, use F2 to bring up the script manager, and try out some sample scripts
 

 Below is a sample client script that shows how to retrieve a project, find the main dex unit, enumerate dex methods, check the bytecode and search for specific instructions.
 File: `ListDexMethodsWithXor.py`  

```

#?description=List dex methods making use of xor instructions
#?shortcut=

from com.pnfsoftware.jeb.client.api import IScript
from com.pnfsoftware.jeb.core.units.code.android import IDexUnit

class ListDexMethodsWithXor(IScript):

  def run(self, ctx):
    prj = ctx.getMainProject()
    assert prj, 'Need a project'

    dex = prj.findUnit(IDexUnit)
    assert dex, 'Need a dex unit'

    cnt = 0
    for m in dex.getMethods():
      if m.isInternal():
        ci = m.getData().getCodeItem()
        if ci and self.checkMethod(ci):
          print(m.getSignature(True, False))
          cnt += 1
    print('Found %d methods' % cnt)

  def checkMethod(self, ci):
    for insn in ci.getInstructions():
      if insn.toString().find('xor-') >= 0:
        return True
    return False
 
```

## Static Field: ACC_ABSTRACT
Type: `int`

Constant value: `1024`

## Static Field: ACC_ANNOTATION
Type: `int`

Constant value: `8192`

## Static Field: ACC_BRIDGE
Type: `int`

Constant value: `64`

## Static Field: ACC_CONSTRUCTOR
Type: `int`

Constant value: `65536`

## Static Field: ACC_DECLARED_SYNCHRONIZED
Type: `int`

Constant value: `131072`

## Static Field: ACC_ENUM
Type: `int`

Constant value: `16384`

## Static Field: ACC_FINAL
Type: `int`

Constant value: `16`

## Static Field: ACC_INTERFACE
Type: `int`

Constant value: `512`

## Static Field: ACC_NATIVE
Type: `int`

Constant value: `256`

## Static Field: ACC_PRIVATE
Type: `int`

Constant value: `2`

## Static Field: ACC_PROTECTED
Type: `int`

Constant value: `4`

## Static Field: ACC_PUBLIC
Type: `int`

Constant value: `1`

## Static Field: ACC_STATIC
Type: `int`

Constant value: `8`

## Static Field: ACC_STRICT
Type: `int`

Constant value: `2048`

## Static Field: ACC_SYNCHRONIZED
Type: `int`

Constant value: `32`

## Static Field: ACC_SYNTHETIC
Type: `int`

Constant value: `4096`

## Static Field: ACC_TRANSIENT
Type: `int`

Constant value: `128`

## Static Field: ACC_VARARGS
Type: `int`

Constant value: `128`

## Static Field: ACC_VOLATILE
Type: `int`

Constant value: `64`

## Static Field: INLINE_ALLOWED
Type: `int`

Constant value: `2`
Description: Inlining mode: allowed. The method may be inlined by code processors.

## Static Field: INLINE_AUTO
Type: `int`

Constant value: `0`
Description: Inlining mode: auto\-determined. This mode is to be understood as 'limited', that is, inlining is blocked except for trivial cases

## Static Field: INLINE_BLOCKED
Type: `int`

Constant value: `1`
Description: Inlining mode: blocked. The method must not be inlined by code processors.

## Static Field: INLINE_FORCED
Type: `int`

Constant value: `3`
Description: Inlining mode: forced. The method should be inlined by code processors if possible.

## Static Field: ITAG_BYTECODE
Type: `int`

Constant value: `7`

## Static Field: ITAG_CLASS
Type: `int`

Constant value: `4`

## Static Field: ITAG_CUSTOM
Type: `int`

Constant value: `16`
Description: Do not use directly \- reserved by dex decompilers

## Static Field: ITAG_FIELD
Type: `int`

Constant value: `5`

## Static Field: ITAG_IMMEDIATE
Type: `int`

Constant value: `10`

## Static Field: ITAG_METHOD
Type: `int`

Constant value: `6`

## Static Field: ITAG_PACKAGE
Type: `int`

Constant value: `2`

## Static Field: ITAG_PARAMETER
Type: `int`

Constant value: `8`

## Static Field: ITAG_STRING
Type: `int`

Constant value: `1`

## Static Field: ITAG_TYPE
Type: `int`

Constant value: `3`

## Static Field: ITAG_VARIABLE
Type: `int`

Constant value: `9`

## Static Field: ITAG_VIRTUAL_VAR
Type: `int`

Constant value: `11`

## Static Field: itagBitsize
Type: `int`

Constant value: `8`

## Static Field: itagItemIdShift
Type: `int`

Constant value: `56`

## Static Field: propnameContextInfoDb
Type: `java.lang.String`

Constant value: `ContextInfoDb`

## Method: addDex
- parameter: `dexInput`, type: `com.pnfsoftware.jeb.core.input.IInput`

Description: Add \(merge\) an additional Dex file into this Dex unit.
parameter: dexInput: a Dex [input](IInput) \(file input, bytes input, etc.\) or a ZIP input            containing a single `classes.dex` entry
throws: 

## Method: addField
- parameter: `signature`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexField`

Description: Create a new field and add it to the field pool index.
parameter: signature: full, eg `Lcom/foo/Bar;->val:I`
return: 

## Method: addField
- parameter: `type`, type: `java.lang.String`
- parameter: `fieldname`, type: `java.lang.String`
- parameter: `fieldtype`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexField`

Description: Create a new field and add it to the field pool index.
parameter: type: full, eg `Lcom/foo/Bar;->val:I`
parameter: fieldname: simple name
parameter: fieldtype: full, eg `Lcom/foo/Bar;->val:I`
return: 

## Method: addMethod
- parameter: `signature`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexMethod`

Description: Create a new method reference and add it to the method pool index.
parameter: signature: full signature, including type name, eg:            `La/b/Foo;->bar(ILjava/lang/String;)Z`
return: 

## Method: addMethod
- parameter: `type`, type: `java.lang.String`
- parameter: `methodname`, type: `java.lang.String`
- parameter: `protostring`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexMethod`

Description: 
parameter: type: 
parameter: methodname: 
parameter: protostring: 
return: 

## Method: addPackage
- parameter: `signature`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexPackage`

Description: 
parameter: signature: fully\-qualified package name, e.g. `com.foo.bar`
return: 

## Method: addPrototype
- parameter: `prototypeString`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexPrototype`

Description: Create a new Dex prototype and add it to the prototype pool index.
parameter: prototypeString: a full prototype string, such as:            `(typeParam1,typeParam2,...)typeReturn`
return: 

## Method: addString
- parameter: `value`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexString`

Description: Create a new string and add it to the string pool index.
parameter: value: 
return: 

## Method: addType
- parameter: `typeString`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexType`

Description: Create a new type and add it to the type pool index.
parameter: typeString: a fully\-qualified type name, using the standard Java internal signature            notation \(`L...;`\)
return: 

## Method: findStringIndex
- parameter: `s`, type: `java.lang.String`
- return type: `int`

Description: Retrieve the pool index of a string, by value.
parameter: s: a string
return: an string pool index, \-1 if the string was not found

## Method: getBadTypeCount
- return type: `int`

Description: 
return: 

## Method: getCallSite
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexCallSite`

Description: 
parameter: index: 
return: 

## Method: getCallSites
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.android.dex.IDexCallSite>`

Description: 
return: 

## Method: getClass
- parameter: `fqname`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexClass`


## Method: getClass
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexClass`

Description: Convenience method to retrieve a class by its Dex class pool index.
parameter: index: 
return: 

## Method: getClasses
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.android.dex.IDexClass>`

Description: Get the Dex class pool

## Method: getCommentManager
- return type: `com.pnfsoftware.jeb.core.units.code.android.DexCommentManager`


## Method: getConstantsLibrary
- return type: `com.pnfsoftware.jeb.core.units.code.android.DexConstantLibrary`

Description: Retrieve the constant library object. The constants library holds the *constant* fields of this dex unit \(that is, all `static final` fields ,regardless of their visibility attributes\) as well as values attached to pure field references \(external fields\)
return: 

## Method: getContextInfoProvider
- return type: `com.pnfsoftware.jeb.core.units.code.android.IDexContextInfoProvider`

Description: Retrieve the context information provider. This provider can be used to retrieve methods' context access information \(context\-sensitivity, side\-effect\) and fields' effective finality information.
return: 

## Method: getCountOfDexEntries
- return type: `int`

Description: Retrieve the count of dex entries managed by this unit.
return: 

## Method: getCountOfDexFiles
- return type: `int`

Description: 
deprecated: use [#getCountOfDexEntries()](#getCountOfDexEntries())

## Method: getCrossReferences
- parameter: `poolType`, type: `com.pnfsoftware.jeb.core.units.code.android.dex.DexPoolType`
- parameter: `index`, type: `int`
- parameter: `cap`, type: `int`
- return type: `java.util.Collection<com.pnfsoftware.jeb.core.units.code.android.dex.IDexAddress>`

Description: Retrieve a list of addresses referencing the provided pool item. This method is left for convenience and legacy only. Newer scripts should use [#getReferenceManager()](#getReferenceManager()).
parameter: poolType: pool item type; currently supported for xrefs: STRING, TYPE, FIELD, METHOD
parameter: index: pool item index
parameter: cap: max number of references to return \(leave to 0 to mean return everything possible\)
return: 

## Method: getCrossReferences
- parameter: `poolType`, type: `com.pnfsoftware.jeb.core.units.code.android.dex.DexPoolType`
- parameter: `index`, type: `int`
- return type: `java.util.Collection<com.pnfsoftware.jeb.core.units.code.android.dex.IDexAddress>`

Description: Retrieve a list of addresses referencing the provided pool item. This method is left for convenience and legacy only. Newer scripts should use [#getReferenceManager()](#getReferenceManager()).
parameter: poolType: pool item type; currently supported for xrefs: STRING, TYPE, FIELD, METHOD
parameter: index: pool item index
return: 

## Method: getDecompiler
- return type: `com.pnfsoftware.jeb.core.units.code.android.IDexDecompilerUnit`

Description: Retrieve or create a decompiler for this unit. If `dexdec` \(the Dex Decompiler module\) is not available with your JEB license, null is returned.
return: 

## Method: getDexEntries
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.android.IDexFile>`

Description: Retrieve the collection of dex entries managed by this dex unit. 

 When the unit is the result of processing a multi\-dex APK, dex files containing multiple dex entries \(container dex, version 41\+\), or if the unit received [additional dex files](#addDex(IInput)), this method will return a list with multiple items.
return: a non\-empty collection of dex entries

## Method: getDexEntry
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.IDexFile`

Description: Retrieve a dex entry by index.
parameter: index: an index
return: the dex entry

## Method: getDexFile
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.IDexFile`

Description: 
deprecated: [#getDexEntry(int)](#getDexEntry(int))

## Method: getDexFiles
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.android.IDexFile>`

Description: 
deprecated: use [#getDexEntries()](#getDexEntries())

## Method: getDisassembly
- return type: `java.lang.String`

Description: This convenience method provides the entire disassembly of the bytecode making up the Dex file. This method is a convenience method: the disassembly text document object can always be retrieved via [#getFormatter()](#getFormatter()).

## Method: getDisassemblyDocument
- return type: `com.pnfsoftware.jeb.core.units.code.android.render.IDexDisassemblyDocument`


## Method: getField
- parameter: `fqname`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexField`


## Method: getField
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexField`

Description: Convenience method to retrieve a field by its Dex field pool index.
parameter: index: 
return: 

## Method: getFields
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.android.dex.IDexField>`

Description: Get the Dex field pool

## Method: getInstructionCount
- return type: `long`

Description: Retrieve the total amount of instructions in this Dex unit. Note that if this unit represents the virtual Dex file resulting from the merge of several classesX.dex files, the number of instructions returned is the sum of instructions of each individual Dex file.
return: 

## Method: getMethod
- parameter: `fqname`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexMethod`


## Method: getMethod
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexMethod`

Description: Convenience method to retrieve a method by its Dex method pool index.
parameter: index: 
return: 

## Method: getMethodHandle
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexMethodHandle`

Description: 
parameter: index: 
return: 

## Method: getMethodHandles
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.android.dex.IDexMethodHandle>`

Description: 
return: 

## Method: getMethodMatch
- parameter: `m`, type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexMethod`
- return type: `com.pnfsoftware.jeb.core.units.code.MethodMatch`

Description: Retrieve the method\-match object attached to a dex method. 

 This method is thread\-safe. Match objects can be attached by any component.
return: 

## Method: getMethods
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.android.dex.IDexMethod>`

Description: Get the Dex method pool

## Method: getObjectById
- parameter: `id`, type: `long`
- return type: `java.lang.Object`

Description: Feature preview.
parameter: id: 
return: 

## Method: getPackage
- parameter: `signature`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexPackage`

Description: 
parameter: signature: fully\-qualified package name, e.g. `com.foo.bar`
return: 

## Method: getPackages
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.android.dex.IDexPackage>`

Description: 

## Method: getPrototype
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexPrototype`

Description: Convenience method to retrieve a prototype by its Dex prototype pool index.
parameter: index: prototype index
return: 

## Method: getPrototypes
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.android.dex.IDexPrototype>`

Description: Get the list of Dex prototypes defined in the Dex file \(prototype pool\).
return: a list of prototypes

## Method: getReferenceManager
- return type: `com.pnfsoftware.jeb.core.units.code.android.IDexReferenceManager`

Description: Retrieve the cross\-references manager.
return: 

## Method: getRenamedIdentifiers
- return type: `java.util.Map<com.pnfsoftware.jeb.core.output.code.coordinates.IdentifierCoordinates,java.lang.String>`

Description: Retrieve a map of renamed identifiers. Only renamed identifiers are stored in the returned object.
return: 

## Method: getStaticFieldInitializer
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexValue`

Description: Retrieve the initializer for the static field of a class.
parameter: index: the field index
return: the static initializer, or null if there's none

## Method: getString
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexString`

Description: Convenience method to retrieve a string by its Dex string pool index.
parameter: index: 
return: 

## Method: getStringCount
- return type: `int`

Description: Get the number of strings present in the aggregated string pools represented by this Dex unit.
return: 

## Method: getStrings
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.android.dex.IDexString>`

Description: Get the Dex string pool, including extra strings added via [addString](#addString(String)).

## Method: getType
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexType`

Description: Retrieve a type by its Dex type pool index.
parameter: index: 
return: 

## Method: getType
- parameter: `fqname`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexType`

Description: Retrieve a type by its fully\-qualified name.
parameter: fqname: eg, `Lcom/foo/Bar;`
return: 

## Method: getTypeHierarchy
- parameter: `typesig`, type: `java.lang.String`
- parameter: `maxNodeCount`, type: `int`
- parameter: `includeSuperTypes`, type: `boolean`
- return type: `com.pnfsoftware.jeb.core.output.tree.ICodeNode`

Description: 
parameter: typesig: 
parameter: maxNodeCount: 
parameter: includeSuperTypes: 
return: 

## Method: getTypes
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.code.android.dex.IDexType>`

Description: Get the Dex prototype pool

## Method: moveTo
- parameter: `src`, type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexItem`
- parameter: `dst`, type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexItem`
- parameter: `skipChecks`, type: `boolean`
- parameter: `neverAnonymous`, type: `boolean`
- parameter: `notify`, type: `boolean`
- return type: `boolean`

Description: Move a class or a package to another package, class, or method.
parameter: src: an [IDexPackage](IDexPackage) or [IDexClass](IDexClass)
parameter: dst: an [IDexPackage](IDexPackage), [IDexClass](IDexClass) or [IDexMethod](IDexMethod)
parameter: skipChecks: skip extra sanity checks \(if applicable\)
parameter: neverAnonymous: legal only when moving a class to another method \(else N/A\); if true,            the moved class will never be made an anonymous class of the destination method;            if false, an anonymous class will be favored, if it is possible to do so
parameter: notify: 
return: success indicator

## Method: moveTo
- parameter: `src`, type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexItem`
- parameter: `dst`, type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexItem`
- parameter: `skipChecks`, type: `boolean`
- parameter: `neverAnonymous`, type: `boolean`
- return type: `boolean`

Description: Move a class or a package to another package, class, or method.
parameter: src: an [IDexPackage](IDexPackage) or [IDexClass](IDexClass)
parameter: dst: an [IDexPackage](IDexPackage), [IDexClass](IDexClass) or [IDexMethod](IDexMethod)
parameter: skipChecks: skip extra sanity checks \(if applicable\)
parameter: neverAnonymous: legal only when moving a class to another method \(else N/A\); if true,            the moved class will never be made an anonymous class of the destination method;            if false, an anonymous class will be favored, if it is possible to do so
return: success indicator

## Method: moveTo
- parameter: `src`, type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexItem`
- parameter: `dst`, type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexItem`
- return type: `boolean`

Description: Move a class or a package to another package, class, or method. Checks are not skipped; whne moving a class to a method, the class will be made anonymous.
parameter: src: an [IDexPackage](IDexPackage) or [IDexClass](IDexClass)
parameter: dst: an [IDexPackage](IDexPackage), [IDexClass](IDexClass) or [IDexMethod](IDexMethod)
return: success indicator

## Method: setMethodMatch
- parameter: `m`, type: `com.pnfsoftware.jeb.core.units.code.android.dex.IDexMethod`
- parameter: `match`, type: `com.pnfsoftware.jeb.core.units.code.MethodMatch`
- return type: `com.pnfsoftware.jeb.core.units.code.MethodMatch`

Description: Attach a method\-match object to a dex method. 

 This method is thread\-safe. Match objects can be attached by any component.
parameter: m: the target method
parameter: match: a match item
return: the previously attached match item, null if none

