Java Code Examples for com.android.dx.dex.cf.CfOptions

The following examples show how to use com.android.dx.dex.cf.CfOptions. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Box   Source File: Main.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Copies relevant arguments over into CfOptions and DexOptions instances.
 */
public void makeOptionsObjects() {
    cfOptions = new CfOptions();
    cfOptions.positionInfo = positionInfo;
    cfOptions.localInfo = localInfo;
    cfOptions.strictNameCheck = strictNameCheck;
    cfOptions.optimize = optimize;
    cfOptions.optimizeListFile = optimizeListFile;
    cfOptions.dontOptimizeListFile = dontOptimizeListFile;
    cfOptions.statistics = statistics;

    if (warnings) {
        cfOptions.warn = context.err;
    } else {
        cfOptions.warn = context.noop;
    }

    dexOptions = new DexOptions(context.err);
    dexOptions.minSdkVersion = minSdkVersion;
    dexOptions.forceJumbo = forceJumbo;
    dexOptions.allowAllInterfaceMethodInvokes = allowAllInterfaceMethodInvokes;
}
 
Example 2
Source Project: Box   Source File: Main.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Copies relevant arguments over into CfOptions and DexOptions instances.
 */
public void makeOptionsObjects() {
    cfOptions = new CfOptions();
    cfOptions.positionInfo = positionInfo;
    cfOptions.localInfo = localInfo;
    cfOptions.strictNameCheck = strictNameCheck;
    cfOptions.optimize = optimize;
    cfOptions.optimizeListFile = optimizeListFile;
    cfOptions.dontOptimizeListFile = dontOptimizeListFile;
    cfOptions.statistics = statistics;

    if (warnings) {
        cfOptions.warn = context.err;
    } else {
        cfOptions.warn = context.noop;
    }

    dexOptions = new DexOptions(context.err);
    dexOptions.minSdkVersion = minSdkVersion;
    dexOptions.forceJumbo = forceJumbo;
    dexOptions.allowAllInterfaceMethodInvokes = allowAllInterfaceMethodInvokes;
}
 
Example 3
Source Project: J2ME-Loader   Source File: Main.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Copies relevant arguments over into CfOptions and DexOptions instances.
 */
public void makeOptionsObjects() {
    cfOptions = new CfOptions();
    cfOptions.positionInfo = positionInfo;
    cfOptions.localInfo = localInfo;
    cfOptions.strictNameCheck = strictNameCheck;
    cfOptions.optimize = optimize;
    cfOptions.optimizeListFile = optimizeListFile;
    cfOptions.dontOptimizeListFile = dontOptimizeListFile;
    cfOptions.statistics = statistics;

    if (warnings) {
        cfOptions.warn = context.err;
    } else {
        cfOptions.warn = context.noop;
    }

    dexOptions = new DexOptions();
    dexOptions.minSdkVersion = minSdkVersion;
    dexOptions.forceJumbo = forceJumbo;
}
 
Example 4
Source Project: rhino-android   Source File: BaseAndroidClassLoader.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Class<?> defineClass(String name, byte[] data) {
    try {
        DexOptions dexOptions = new DexOptions();
        DexFile dexFile = new DexFile(dexOptions);
        DirectClassFile classFile = new DirectClassFile(data, name.replace('.', '/') + ".class", true);
        classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
        classFile.getMagic();
        DxContext context = new DxContext();
        dexFile.add(CfTranslator.translate(context, classFile, null, new CfOptions(), dexOptions, dexFile));
        Dex dex = new Dex(dexFile.toDex(null, false));
        Dex oldDex = getLastDex();
        if (oldDex != null) {
            dex = new DexMerger(new Dex[]{dex, oldDex}, CollisionPolicy.KEEP_FIRST, context).merge();
        }
        return loadClass(dex, name);
    } catch (IOException | ClassNotFoundException e) {
        throw new FatalLoadingException(e);
    }
}
 
Example 5
Source Project: buck   Source File: Main.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Copies relevant arguments over into CfOptions and
 * DexOptions instances.
 */
public void makeOptionsObjects(DxContext context) {
    cfOptions = new CfOptions();
    cfOptions.positionInfo = positionInfo;
    cfOptions.localInfo = localInfo;
    cfOptions.strictNameCheck = strictNameCheck;
    cfOptions.optimize = optimize;
    cfOptions.optimizeListFile = optimizeListFile;
    cfOptions.dontOptimizeListFile = dontOptimizeListFile;
    cfOptions.statistics = statistics;

    if (warnings) {
        cfOptions.warn = context.err;
    } else {
        cfOptions.warn = context.noop;
    }

    dexOptions = new DexOptions();
    dexOptions.forceJumbo = forceJumbo;
}
 
Example 6
public DexFile generateDexFile(List<byte[]> classByteCodes){
    DxContext dxContext=new DxContext();
    DexOptions dexOptions=new DexOptions();
    CfOptions cfOptions=new CfOptions();
    DexFile dexFile=new DexFile(dexOptions);
    for (byte[] cls:classByteCodes){
        DirectClassFile directClassFile=new DirectClassFile(cls,"",false);
        directClassFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
        directClassFile.getMagic();
        dexFile.add(CfTranslator.translate(dxContext,directClassFile,cls,cfOptions,dexOptions,dexFile));
    }
    return dexFile;
}
 
Example 7
Source Project: bazel   Source File: Dexing.java    License: Apache License 2.0 5 votes vote down vote up
public CfOptions toCfOptions(DxContext context) {
  CfOptions result = new CfOptions();
  result.localInfo = this.localInfo;
  result.optimize = this.optimize;
  result.warn = printWarnings ? context.err : Dexing.nullout;
  // Use dx's defaults
  result.optimizeListFile = null;
  result.dontOptimizeListFile = null;
  result.positionInfo = positionInfo;
  result.strictNameCheck = true;
  result.statistics = false; // we're not supporting statistics anyways
  return result;
}
 
Example 8
Source Project: bazel   Source File: DexFileAggregatorTest.java    License: Apache License 2.0 5 votes vote down vote up
private static DexFile convertClass(Class<?> clazz) throws IOException {
  String path = clazz.getName().replace('.', '/') + ".class";
  try (InputStream in =
      Thread.currentThread().getContextClassLoader().getResourceAsStream(path)) {
    return new DexConverter(new Dexing(new DxContext(), new DexOptions(), new CfOptions()))
        .toDexFile(ByteStreams.toByteArray(in), path);
  }
}
 
Example 9
Source Project: bazel   Source File: DexConversionEnqueuerTest.java    License: Apache License 2.0 5 votes vote down vote up
private void makeStuffer() {
  stuffer =
      new DexConversionEnqueuer(
          zip,
          newDirectExecutorService(),
          new DexConverter(new Dexing(new DxContext(), new DexOptions(), new CfOptions())),
          cache);
}
 
Example 10
Source Project: bazel   Source File: DexLimitTrackerTest.java    License: Apache License 2.0 5 votes vote down vote up
private static DexFile convertClass(Class<?> clazz) throws IOException {
  String path = clazz.getName().replace('.', '/') + ".class";
  try (InputStream in =
      Thread.currentThread().getContextClassLoader().getResourceAsStream(path)) {
    return new DexConverter(new Dexing(new DxContext(), new DexOptions(), new CfOptions()))
        .toDexFile(ByteStreams.toByteArray(in), path);
  }
}
 
Example 11
Source Project: byte-buddy   Source File: AndroidClassLoadingStrategy.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public ClassDefItem translate(DirectClassFile directClassFile,
                              byte[] binaryRepresentation,
                              CfOptions dexCompilerOptions,
                              DexOptions dexFileOptions,
                              DexFile dexFile) {
    throw new IllegalStateException("Could not resolve dispatcher: " + message);
}
 
Example 12
Source Project: bazel   Source File: Dexing.java    License: Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
Dexing(DxContext context, DexOptions dexOptions, CfOptions cfOptions) {
  this.context = context;
  this.dexOptions = dexOptions;
  this.cfOptions = cfOptions;
}
 
Example 13
Source Project: byte-buddy   Source File: AndroidClassLoadingStrategy.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Creates a default dex processor that ensures API version compatibility.
 *
 * @return A dex processor using an SDK compiler that ensures compatibility.
 */
protected static DexProcessor makeDefault() {
    DexOptions dexOptions = new DexOptions();
    DISPATCHER.setTargetApi(dexOptions, DEX_COMPATIBLE_API_VERSION);
    return new ForSdkCompiler(dexOptions, new CfOptions());
}
 
Example 14
public Conversion create() {
    return new AndroidClassLoadingStrategy.DexProcessor.ForSdkCompiler(new DexOptions(), new CfOptions()).create();
}
 
Example 15
Source Project: byte-buddy   Source File: AndroidClassLoadingStrategy.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new Android SDK dex compiler-based dex processor.
 *
 * @param dexFileOptions     The dex file options to apply.
 * @param dexCompilerOptions The dex compiler options to apply.
 */
public ForSdkCompiler(DexOptions dexFileOptions, CfOptions dexCompilerOptions) {
    this.dexFileOptions = dexFileOptions;
    this.dexCompilerOptions = dexCompilerOptions;
}
 
Example 16
Source Project: byte-buddy   Source File: AndroidClassLoadingStrategy.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new class file definition.
 *
 * @param directClassFile      The direct class file to translate.
 * @param binaryRepresentation The file's binary representation.
 * @param dexCompilerOptions   The dex compiler options.
 * @param dexFileOptions       The dex file options.
 * @param dexFile              The dex file.
 * @return The translated class file definition.
 */
ClassDefItem translate(DirectClassFile directClassFile,
                       byte[] binaryRepresentation,
                       CfOptions dexCompilerOptions,
                       DexOptions dexFileOptions,
                       DexFile dexFile);