1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.dx.dex; 18 19 import com.android.dex.DexFormat; 20 import com.android.dx.dex.code.DalvInsnList; 21 import java.io.PrintStream; 22 23 /** 24 * Container for options used to control details of dex file generation. 25 */ 26 public final class DexOptions { 27 28 /** 29 * Enable alignment support of 64-bit registers on Dalvik even registers. This is a temporary 30 * configuration flag allowing to quickly go back on the default behavior to face up to problem. 31 */ 32 public static final boolean ALIGN_64BIT_REGS_SUPPORT = true; 33 34 /** 35 * Does final processing of 64-bit alignment into output finisher to gets output as 36 * {@link DalvInsnList} with 64-bit registers aligned at best. Disabled the final processing is 37 * required for tools such as Dasm to avoid modifying user inputs. 38 */ 39 public boolean ALIGN_64BIT_REGS_IN_OUTPUT_FINISHER = ALIGN_64BIT_REGS_SUPPORT; 40 41 /** minimum SDK version targeted */ 42 public int minSdkVersion = DexFormat.API_NO_EXTENDED_OPCODES; 43 44 /** force generation of jumbo opcodes */ 45 public boolean forceJumbo = false; 46 47 /** Enable user override for default and static interface method invocation. */ 48 public boolean allowAllInterfaceMethodInvokes = false; 49 50 /** output stream for reporting warnings */ 51 public final PrintStream err; 52 DexOptions()53 public DexOptions() { 54 err = System.err; 55 } 56 DexOptions(PrintStream stream)57 public DexOptions(PrintStream stream) { 58 err = stream; 59 } 60 61 /** 62 * Gets the dex file magic number corresponding to this instance. 63 * @return string representing the dex file magic number 64 */ getMagic()65 public String getMagic() { 66 return DexFormat.apiToMagic(minSdkVersion); 67 } 68 69 /** 70 * Checks whether an API feature is supported. 71 * @param apiLevel the API level to test 72 * @return returns true if the current API level is at least sdkVersion 73 */ apiIsSupported(int apiLevel)74 public boolean apiIsSupported(int apiLevel) { 75 // TODO: the naming here is awkward. Tooling may rely on the minSdkVersion, 76 // but it is referred to as API in DexFormat. Currently indistinguishable. 77 return minSdkVersion >= apiLevel; 78 } 79 } 80