Html程序  |  502行  |  29.47 KB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_26) on Tue Jan 10 12:29:36 EST 2012 -->
<TITLE>
DexMaker (dexmaker)
</TITLE>

<META NAME="date" CONTENT="2012-01-10">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="DexMaker (dexmaker)";
    }
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">
<HR>


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../com/google/dexmaker/Comparison.html" title="enum in com.google.dexmaker"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../com/google/dexmaker/FieldId.html" title="class in com.google.dexmaker"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../index.html?com/google/dexmaker/DexMaker.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="DexMaker.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.google.dexmaker</FONT>
<BR>
Class DexMaker</H2>
<PRE>
<A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A>
  <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>com.google.dexmaker.DexMaker</B>
</PRE>
<HR>
<DL>
<DT><PRE>public final class <B>DexMaker</B><DT>extends <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL>
</PRE>

<P>
Generates a </i><strong>D</strong>alvik <strong>EX</strong>ecutable (dex)
 file for execution on Android. Dex files define classes and interfaces,
 including their member methods and fields, executable code, and debugging
 information. They also define annotations, though this API currently has no
 facility to create a dex file that contains annotations.

 <p>This library is intended to satisfy two use cases:
 <ul>
   <li><strong>For runtime code generation.</strong> By embedding this library
       in your Android application, you can dynamically generate and load
       executable code. This approach takes advantage of the fact that the
       host environment and target environment are both Android.
   <li><strong>For compile time code generation.</strong> You may use this
       library as a part of a compiler that targets Android. In this scenario
       the generated dex file must be installed on an Android device before it
       can be executed.
 </ul>

 <h3>Example: Fibonacci</h3>
 To illustrate how this API is used, we'll use DexMaker to generate a class
 equivalent to the following Java source: <pre> <code>package com.publicobject.fib;

 public class Fibonacci {
   public static int fib(int i) {
     if (i &lt; 2) {
       return i;
     }
     return fib(i - 1) + fib(i - 2);
   }
 }</code></pre>

 <p>We start by creating a <A HREF="../../../com/google/dexmaker/TypeId.html" title="class in com.google.dexmaker"><CODE>TypeId</CODE></A> to identify the generated <code>Fibonacci</code> class. DexMaker identifies types by their internal names like
 <code>Ljava/lang/Object;</code> rather than their Java identifiers like <code>java.lang.Object</code>. <pre>   <code>TypeId&lt;?&gt; fibonacci = TypeId.get("Lcom/google/dexmaker/examples/Fibonacci;");
 </code></pre>

 <p>Next we declare the class. It allows us to specify the type's source file
 for stack traces, its modifiers, its superclass, and the interfaces it
 implements. In this case, <code>Fibonacci</code> is a public class that extends
 from <code>Object</code>: <pre>   <code>String fileName = "Fibonacci.generated";
   DexMaker dexMaker = new DexMaker();
   dexMaker.declare(fibonacci, fileName, Modifier.PUBLIC, TypeId.OBJECT);
 </code></pre>
 It is illegal to declare members of a class without also declaring the class
 itself.

 <p>To make it easier to go from our Java method to dex instructions, we'll
 manually translate it to pseudocode fit for an assembler. We need to replace
 control flow like <code>if()</code> blocks and <code>for()</code> loops with labels and
 branches. We'll also avoid performing multiple operations in one statement,
 using local variables to hold intermediate values as necessary:
 <pre>   <code>int constant1 = 1;
   int constant2 = 2;
   if (i &lt; constant2) goto baseCase;
   int a = i - constant1;
   int b = i - constant2;
   int c = fib(a);
   int d = fib(b);
   int result = c + d;
   return result;
 baseCase:
   return i;
 </code></pre>

 <p>We look up the <code>MethodId</code> for the method on the declaring type. This
 takes the method's return type (possibly <A HREF="../../../com/google/dexmaker/TypeId.html#VOID"><CODE>TypeId.VOID</CODE></A>), its name and
 its parameters types. Next we declare the method, specifying its modifiers by
 bitwise ORing constants from <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true" title="class or interface in java.lang.reflect"><CODE>Modifier</CODE></A>. The declare
 call returns a <A HREF="../../../com/google/dexmaker/Code.html" title="class in com.google.dexmaker"><CODE>Code</CODE></A> object, which we'll use to define the method's
 instructions. <pre>   <code>MethodId&lt;?, Integer&gt; fib = fibonacci.getMethod(TypeId.INT, "fib", TypeId.INT);
   Code code = dexMaker.declare(fib, Modifier.PUBLIC | Modifier.STATIC);
 </code></pre>

 <p>One limitation of <code>DexMaker</code>'s API is that it requires all local
 variables to be created before any instructions are emitted. Use <A HREF="../../../com/google/dexmaker/Code.html#newLocal(com.google.dexmaker.TypeId)"><CODE>newLocal()</CODE></A> to create a new local variable. The method's
 parameters are exposed as locals using <A HREF="../../../com/google/dexmaker/Code.html#getParameter(int, com.google.dexmaker.TypeId)"><CODE>getParameter()</CODE></A>. For non-static methods the <code>this</code> pointer is exposed
 using <A HREF="../../../com/google/dexmaker/Code.html#getThis(com.google.dexmaker.TypeId)"><CODE>getThis()</CODE></A>. Here we declare all of the local
 variables that we'll need for our <code>fib()</code> method: <pre>   <code>Local&lt;Integer&gt; i = code.getParameter(0, TypeId.INT);
   Local&lt;Integer&gt; constant1 = code.newLocal(TypeId.INT);
   Local&lt;Integer&gt; constant2 = code.newLocal(TypeId.INT);
   Local&lt;Integer&gt; a = code.newLocal(TypeId.INT);
   Local&lt;Integer&gt; b = code.newLocal(TypeId.INT);
   Local&lt;Integer&gt; c = code.newLocal(TypeId.INT);
   Local&lt;Integer&gt; d = code.newLocal(TypeId.INT);
   Local&lt;Integer&gt; result = code.newLocal(TypeId.INT);
 </code></pre>

 <p>Notice that <A HREF="../../../com/google/dexmaker/Local.html" title="class in com.google.dexmaker"><CODE>Local</CODE></A> has a type parameter of <code>Integer</code>. This is
 useful for generating code that works with existing types like <code>String</code>
 and <code>Integer</code>, but it can be a hindrance when generating code that
 involves new types. For this reason you may prefer to use raw types only and
 add <code>@SuppressWarnings("unsafe")</code> on your calling code. This will yield
 the same result but you won't get IDE support if you make a type error.

 <p>We're ready to start defining our method's instructions. The <A HREF="../../../com/google/dexmaker/Code.html" title="class in com.google.dexmaker"><CODE>Code</CODE></A>
 class catalogs the available instructions and their use. <pre>   <code>code.loadConstant(constant1, 1);
   code.loadConstant(constant2, 2);
   Label baseCase = new Label();
   code.compare(Comparison.LT, baseCase, i, constant2);
   code.op(BinaryOp.SUBTRACT, a, i, constant1);
   code.op(BinaryOp.SUBTRACT, b, i, constant2);
   code.invokeStatic(fib, c, a);
   code.invokeStatic(fib, d, b);
   code.op(BinaryOp.ADD, result, c, d);
   code.returnValue(result);
   code.mark(baseCase);
   code.returnValue(i);
 </code></pre>

 <p>We're done defining the dex file. We just need to write it to the
 filesystem or load it into the current process. For this example we'll load
 the generated code into the current process. This only works when the current
 process is running on Android. We use <A HREF="../../../com/google/dexmaker/DexMaker.html#generateAndLoad(java.lang.ClassLoader, java.io.File)"><CODE>generateAndLoad()</CODE></A> which takes the class loader that will be used as our
 generated code's parent class loader. It also requires a directory where
 temporary files can be written. <pre>   <code>ClassLoader loader = dexMaker.generateAndLoad(
       FibonacciMaker.class.getClassLoader(), getDataDirectory());
 </code></pre>
 Finally we'll use reflection to lookup our generated class on its class
 loader and invoke its <code>fib()</code> method: <pre>   <code>Class&lt;?&gt; fibonacciClass = loader.loadClass("com.google.dexmaker.examples.Fibonacci");
   Method fibMethod = fibonacciClass.getMethod("fib", int.class);
   System.out.println(fibMethod.invoke(null, 8));
 </code></pre>
<P>

<P>
<HR>

<P>

<!-- ======== CONSTRUCTOR SUMMARY ======== -->

<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../com/google/dexmaker/DexMaker.html#DexMaker()">DexMaker</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates a new <code>DexMaker</code> instance, which can be used to create a
 single dex file.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/dexmaker/DexMaker.html#declare(com.google.dexmaker.FieldId, int, java.lang.Object)">declare</A></B>(<A HREF="../../../com/google/dexmaker/FieldId.html" title="class in com.google.dexmaker">FieldId</A>&lt;?,?&gt;&nbsp;fieldId,
        int&nbsp;flags,
        <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;staticValue)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Declares a field.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/dexmaker/Code.html" title="class in com.google.dexmaker">Code</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/dexmaker/DexMaker.html#declare(com.google.dexmaker.MethodId, int)">declare</A></B>(<A HREF="../../../com/google/dexmaker/MethodId.html" title="class in com.google.dexmaker">MethodId</A>&lt;?,?&gt;&nbsp;method,
        int&nbsp;flags)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Declares a method or constructor.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/dexmaker/DexMaker.html#declare(com.google.dexmaker.TypeId, java.lang.String, int, com.google.dexmaker.TypeId, com.google.dexmaker.TypeId...)">declare</A></B>(<A HREF="../../../com/google/dexmaker/TypeId.html" title="class in com.google.dexmaker">TypeId</A>&lt;?&gt;&nbsp;type,
        <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;sourceFile,
        int&nbsp;flags,
        <A HREF="../../../com/google/dexmaker/TypeId.html" title="class in com.google.dexmaker">TypeId</A>&lt;?&gt;&nbsp;supertype,
        <A HREF="../../../com/google/dexmaker/TypeId.html" title="class in com.google.dexmaker">TypeId</A>&lt;?&gt;...&nbsp;interfaces)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Declares <code>type</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;byte[]</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/dexmaker/DexMaker.html#generate()">generate</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Generates a dex file and returns its bytes.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html?is-external=true" title="class or interface in java.lang">ClassLoader</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/dexmaker/DexMaker.html#generateAndLoad(java.lang.ClassLoader, java.io.File)">generateAndLoad</A></B>(<A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html?is-external=true" title="class or interface in java.lang">ClassLoader</A>&nbsp;parent,
                <A HREF="http://download.oracle.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A>&nbsp;dexDir)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Generates a dex file and loads its types into the current process.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ========= CONSTRUCTOR DETAIL ======== -->

<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="DexMaker()"><!-- --></A><H3>
DexMaker</H3>
<PRE>
public <B>DexMaker</B>()</PRE>
<DL>
<DD>Creates a new <code>DexMaker</code> instance, which can be used to create a
 single dex file.
<P>
</DL>

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="declare(com.google.dexmaker.TypeId, java.lang.String, int, com.google.dexmaker.TypeId, com.google.dexmaker.TypeId...)"><!-- --></A><H3>
declare</H3>
<PRE>
public void <B>declare</B>(<A HREF="../../../com/google/dexmaker/TypeId.html" title="class in com.google.dexmaker">TypeId</A>&lt;?&gt;&nbsp;type,
                    <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;sourceFile,
                    int&nbsp;flags,
                    <A HREF="../../../com/google/dexmaker/TypeId.html" title="class in com.google.dexmaker">TypeId</A>&lt;?&gt;&nbsp;supertype,
                    <A HREF="../../../com/google/dexmaker/TypeId.html" title="class in com.google.dexmaker">TypeId</A>&lt;?&gt;...&nbsp;interfaces)</PRE>
<DL>
<DD>Declares <code>type</code>.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>flags</CODE> - a bitwise combination of <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#PUBLIC" title="class or interface in java.lang.reflect"><CODE>Modifier.PUBLIC</CODE></A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#FINAL" title="class or interface in java.lang.reflect"><CODE>Modifier.FINAL</CODE></A> and <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#ABSTRACT" title="class or interface in java.lang.reflect"><CODE>Modifier.ABSTRACT</CODE></A>.</DL>
</DD>
</DL>
<HR>

<A NAME="declare(com.google.dexmaker.MethodId, int)"><!-- --></A><H3>
declare</H3>
<PRE>
public <A HREF="../../../com/google/dexmaker/Code.html" title="class in com.google.dexmaker">Code</A> <B>declare</B>(<A HREF="../../../com/google/dexmaker/MethodId.html" title="class in com.google.dexmaker">MethodId</A>&lt;?,?&gt;&nbsp;method,
                    int&nbsp;flags)</PRE>
<DL>
<DD>Declares a method or constructor.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>flags</CODE> - a bitwise combination of <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#PUBLIC" title="class or interface in java.lang.reflect"><CODE>Modifier.PUBLIC</CODE></A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#PRIVATE" title="class or interface in java.lang.reflect"><CODE>Modifier.PRIVATE</CODE></A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#PROTECTED" title="class or interface in java.lang.reflect"><CODE>Modifier.PROTECTED</CODE></A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#STATIC" title="class or interface in java.lang.reflect"><CODE>Modifier.STATIC</CODE></A>,
     <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#FINAL" title="class or interface in java.lang.reflect"><CODE>Modifier.FINAL</CODE></A> and <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#SYNCHRONIZED" title="class or interface in java.lang.reflect"><CODE>Modifier.SYNCHRONIZED</CODE></A>.
     <p><strong>Warning:</strong> the <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#SYNCHRONIZED" title="class or interface in java.lang.reflect"><CODE>Modifier.SYNCHRONIZED</CODE></A> flag
     is insufficient to generate a synchronized method. You must also use
     <A HREF="../../../com/google/dexmaker/Code.html#monitorEnter(com.google.dexmaker.Local)"><CODE>Code.monitorEnter(com.google.dexmaker.Local<?>)</CODE></A> and <A HREF="../../../com/google/dexmaker/Code.html#monitorExit(com.google.dexmaker.Local)"><CODE>Code.monitorExit(com.google.dexmaker.Local<?>)</CODE></A> to acquire
     a monitor.</DL>
</DD>
</DL>
<HR>

<A NAME="declare(com.google.dexmaker.FieldId, int, java.lang.Object)"><!-- --></A><H3>
declare</H3>
<PRE>
public void <B>declare</B>(<A HREF="../../../com/google/dexmaker/FieldId.html" title="class in com.google.dexmaker">FieldId</A>&lt;?,?&gt;&nbsp;fieldId,
                    int&nbsp;flags,
                    <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;staticValue)</PRE>
<DL>
<DD>Declares a field.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>flags</CODE> - a bitwise combination of <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#PUBLIC" title="class or interface in java.lang.reflect"><CODE>Modifier.PUBLIC</CODE></A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#PRIVATE" title="class or interface in java.lang.reflect"><CODE>Modifier.PRIVATE</CODE></A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#PROTECTED" title="class or interface in java.lang.reflect"><CODE>Modifier.PROTECTED</CODE></A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#STATIC" title="class or interface in java.lang.reflect"><CODE>Modifier.STATIC</CODE></A>,
     <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#FINAL" title="class or interface in java.lang.reflect"><CODE>Modifier.FINAL</CODE></A>, <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#VOLATILE" title="class or interface in java.lang.reflect"><CODE>Modifier.VOLATILE</CODE></A>, and <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Modifier.html?is-external=true#TRANSIENT" title="class or interface in java.lang.reflect"><CODE>Modifier.TRANSIENT</CODE></A>.<DD><CODE>staticValue</CODE> - a constant representing the initial value for the
     static field, possibly null. This must be null if this field is
     non-static.</DL>
</DD>
</DL>
<HR>

<A NAME="generate()"><!-- --></A><H3>
generate</H3>
<PRE>
public byte[] <B>generate</B>()</PRE>
<DL>
<DD>Generates a dex file and returns its bytes.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>

<A NAME="generateAndLoad(java.lang.ClassLoader, java.io.File)"><!-- --></A><H3>
generateAndLoad</H3>
<PRE>
public <A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html?is-external=true" title="class or interface in java.lang">ClassLoader</A> <B>generateAndLoad</B>(<A HREF="http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html?is-external=true" title="class or interface in java.lang">ClassLoader</A>&nbsp;parent,
                                   <A HREF="http://download.oracle.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A>&nbsp;dexDir)
                            throws <A HREF="http://download.oracle.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
<DL>
<DD>Generates a dex file and loads its types into the current process.

 <p>All parameters are optional; you may pass <code>null</code> and suitable
 defaults will be used.

 <p>If you opt to provide your own <code>dexDir</code>, take care to ensure
 that it is not world-writable, otherwise a malicious app may be able
 to inject code into your process.  A suitable parameter is:
 <code>getApplicationContext().getDir("dx", Context.MODE_PRIVATE); </code>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>parent</CODE> - the parent ClassLoader to be used when loading
     our generated types<DD><CODE>dexDir</CODE> - the destination directory where generated and
     optimized dex files will be written.
<DT><B>Throws:</B>
<DD><CODE><A HREF="http://download.oracle.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../com/google/dexmaker/Comparison.html" title="enum in com.google.dexmaker"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../com/google/dexmaker/FieldId.html" title="class in com.google.dexmaker"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../index.html?com/google/dexmaker/DexMaker.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="DexMaker.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>

</BODY>
</HTML>