Add support for class loader context in dex2oat
The context can be passed to dex2oat using '--class-loader-
context=<string spec>'. It accepts a string specifying the intended
runtime loading context for the compiled dex files.
e.g. --class-loader-context=PCL[lib1.dex:lib2.dex];DLC[lib3.dex].
It describes how the class loader chain should be build in order to
ensure classes are resolved during dex2aot as they would be resolved at
runtime. This spec will be encoded in the oat file. If at runtime the
dex file will be loaded in a different context, the oat file will be
rejected.
The chain is interpreted in the natural 'parent order', meaning that
class loader 'i+1' will be the parent of class loader 'i'. The
compilation sources will be added to the classpath of the last class
loader. This allows the compiled dex files to be loaded at runtime in a
class loader that contains other dex files as well (e.g. shared
libraries).
Note that the compiler will be tolerant if the source dex files
specified with --dex-file are found in the classpath. The source dex
files will be removed from the any class loader's classpath possibly
resulting in empty class loaders.
Test: m test-art-host
Bug: 38138251
Change-Id: I3446ac7b2949d367dbc6d15729d3b203791eaac0
4 files changed