Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Backport inclusion of dx tool sources from 'android' branch.

Conflicts:

	pom.xml
	src/clj/clojure/main.clj
	src/jvm/clojure/lang/DalvikDynamicClassLoader.java
	src/jvm/clojure/lang/RT.java
  • Loading branch information...
commit 60a1b8af529634f1f128b11417aece446d92be67 1 parent 1fa0873
@sattvik authored
Showing with 30,218 additions and 51 deletions.
  1. +6 −46 build.xml
  2. +0 −1  local.properties.example
  3. +194 −0 readme.txt
  4. +1 −1  src/clj/clojure/main.clj
  5. +7 −2 src/jvm/clojure/lang/DalvikDynamicClassLoader.java
  6. +1 −1  src/jvm/clojure/lang/RT.java
  7. +67 −0 src/jvm/com/android/dx/cf/attrib/AttAnnotationDefault.java
  8. +145 −0 src/jvm/com/android/dx/cf/attrib/AttCode.java
  9. +77 −0 src/jvm/com/android/dx/cf/attrib/AttConstantValue.java
  10. +37 −0 src/jvm/com/android/dx/cf/attrib/AttDeprecated.java
  11. +78 −0 src/jvm/com/android/dx/cf/attrib/AttEnclosingMethod.java
  12. +68 −0 src/jvm/com/android/dx/cf/attrib/AttExceptions.java
  13. +64 −0 src/jvm/com/android/dx/cf/attrib/AttInnerClasses.java
  14. +65 −0 src/jvm/com/android/dx/cf/attrib/AttLineNumberTable.java
  15. +36 −0 src/jvm/com/android/dx/cf/attrib/AttLocalVariableTable.java
  16. +36 −0 src/jvm/com/android/dx/cf/attrib/AttLocalVariableTypeTable.java
  17. +40 −0 src/jvm/com/android/dx/cf/attrib/AttRuntimeInvisibleAnnotations.java
  18. +42 −0 src/jvm/com/android/dx/cf/attrib/AttRuntimeInvisibleParameterAnnotations.java
  19. +40 −0 src/jvm/com/android/dx/cf/attrib/AttRuntimeVisibleAnnotations.java
  20. +42 −0 src/jvm/com/android/dx/cf/attrib/AttRuntimeVisibleParameterAnnotations.java
  21. +59 −0 src/jvm/com/android/dx/cf/attrib/AttSignature.java
  22. +59 −0 src/jvm/com/android/dx/cf/attrib/AttSourceFile.java
  23. +37 −0 src/jvm/com/android/dx/cf/attrib/AttSynthetic.java
  24. +72 −0 src/jvm/com/android/dx/cf/attrib/BaseAnnotations.java
  25. +46 −0 src/jvm/com/android/dx/cf/attrib/BaseAttribute.java
  26. +65 −0 src/jvm/com/android/dx/cf/attrib/BaseLocalVariables.java
  27. +73 −0 src/jvm/com/android/dx/cf/attrib/BaseParameterAnnotations.java
  28. +137 −0 src/jvm/com/android/dx/cf/attrib/InnerClassList.java
  29. +91 −0 src/jvm/com/android/dx/cf/attrib/RawAttribute.java
  30. +579 −0 src/jvm/com/android/dx/cf/code/BaseMachine.java
  31. +452 −0 src/jvm/com/android/dx/cf/code/BasicBlocker.java
  32. +145 −0 src/jvm/com/android/dx/cf/code/ByteBlock.java
  33. +75 −0 src/jvm/com/android/dx/cf/code/ByteBlockList.java
  34. +317 −0 src/jvm/com/android/dx/cf/code/ByteCatchList.java
  35. +649 −0 src/jvm/com/android/dx/cf/code/ByteOps.java
  36. +1,422 −0 src/jvm/com/android/dx/cf/code/BytecodeArray.java
  37. +257 −0 src/jvm/com/android/dx/cf/code/ConcreteMethod.java
  38. +343 −0 src/jvm/com/android/dx/cf/code/ExecutionStack.java
  39. +415 −0 src/jvm/com/android/dx/cf/code/Frame.java
  40. +184 −0 src/jvm/com/android/dx/cf/code/LineNumberList.java
  41. +373 −0 src/jvm/com/android/dx/cf/code/LocalVariableList.java
  42. +182 −0 src/jvm/com/android/dx/cf/code/LocalsArray.java
  43. +462 −0 src/jvm/com/android/dx/cf/code/LocalsArraySet.java
  44. +216 −0 src/jvm/com/android/dx/cf/code/Machine.java
  45. +305 −0 src/jvm/com/android/dx/cf/code/Merger.java
  46. +246 −0 src/jvm/com/android/dx/cf/code/OneLocalsArray.java
  47. +108 −0 src/jvm/com/android/dx/cf/code/ReturnAddress.java
  48. +1,675 −0 src/jvm/com/android/dx/cf/code/Ropper.java
  49. +963 −0 src/jvm/com/android/dx/cf/code/RopperMachine.java
  50. +37 −0 src/jvm/com/android/dx/cf/code/SimException.java
  51. +772 −0 src/jvm/com/android/dx/cf/code/Simulator.java
  52. +193 −0 src/jvm/com/android/dx/cf/code/SwitchList.java
  53. +199 −0 src/jvm/com/android/dx/cf/code/ValueAwareMachine.java
  54. +352 −0 src/jvm/com/android/dx/cf/cst/ConstantPoolParser.java
  55. +55 −0 src/jvm/com/android/dx/cf/cst/ConstantTags.java
  56. +471 −0 src/jvm/com/android/dx/cf/direct/AnnotationParser.java
  57. +134 −0 src/jvm/com/android/dx/cf/direct/AttributeFactory.java
  58. +164 −0 src/jvm/com/android/dx/cf/direct/AttributeListParser.java
  59. +306 −0 src/jvm/com/android/dx/cf/direct/CodeObserver.java
  60. +636 −0 src/jvm/com/android/dx/cf/direct/DirectClassFile.java
  61. +86 −0 src/jvm/com/android/dx/cf/direct/FieldListParser.java
  62. +240 −0 src/jvm/com/android/dx/cf/direct/MemberListParser.java
  63. +86 −0 src/jvm/com/android/dx/cf/direct/MethodListParser.java
  64. +763 −0 src/jvm/com/android/dx/cf/direct/StdAttributeFactory.java
  65. +38 −0 src/jvm/com/android/dx/cf/iface/Attribute.java
  66. +75 −0 src/jvm/com/android/dx/cf/iface/AttributeList.java
  67. +123 −0 src/jvm/com/android/dx/cf/iface/ClassFile.java
  68. +35 −0 src/jvm/com/android/dx/cf/iface/Field.java
  69. +48 −0 src/jvm/com/android/dx/cf/iface/FieldList.java
  70. +74 −0 src/jvm/com/android/dx/cf/iface/Member.java
  71. +34 −0 src/jvm/com/android/dx/cf/iface/Method.java
  72. +47 −0 src/jvm/com/android/dx/cf/iface/MethodList.java
  73. +37 −0 src/jvm/com/android/dx/cf/iface/ParseException.java
  74. +68 −0 src/jvm/com/android/dx/cf/iface/ParseObserver.java
  75. +104 −0 src/jvm/com/android/dx/cf/iface/StdAttributeList.java
  76. +54 −0 src/jvm/com/android/dx/cf/iface/StdField.java
  77. +49 −0 src/jvm/com/android/dx/cf/iface/StdFieldList.java
  78. +110 −0 src/jvm/com/android/dx/cf/iface/StdMember.java
  79. +55 −0 src/jvm/com/android/dx/cf/iface/StdMethod.java
  80. +49 −0 src/jvm/com/android/dx/cf/iface/StdMethodList.java
  81. +98 −0 src/jvm/com/android/dx/dex/DexFormat.java
  82. +40 −0 src/jvm/com/android/dx/dex/DexOptions.java
  83. +103 −0 src/jvm/com/android/dx/dex/SizeOf.java
  84. +426 −0 src/jvm/com/android/dx/dex/cf/AttributeTranslator.java
  85. +50 −0 src/jvm/com/android/dx/dex/cf/CfOptions.java
  86. +387 −0 src/jvm/com/android/dx/dex/cf/CfTranslator.java
  87. +172 −0 src/jvm/com/android/dx/dex/cf/CodeStatistics.java
  88. +185 −0 src/jvm/com/android/dx/dex/cf/OptimizerOptions.java
  89. +199 −0 src/jvm/com/android/dx/dex/code/ArrayData.java
  90. +143 −0 src/jvm/com/android/dx/dex/code/BlockAddresses.java
  91. +48 −0 src/jvm/com/android/dx/dex/code/CatchBuilder.java
  92. +238 −0 src/jvm/com/android/dx/dex/code/CatchHandlerList.java
  93. +192 −0 src/jvm/com/android/dx/dex/code/CatchTable.java
  94. +57 −0 src/jvm/com/android/dx/dex/code/CodeAddress.java
  95. +205 −0 src/jvm/com/android/dx/dex/code/CstInsn.java
  96. +232 −0 src/jvm/com/android/dx/dex/code/DalvCode.java
  97. +450 −0 src/jvm/com/android/dx/dex/code/DalvInsn.java
  98. +269 −0 src/jvm/com/android/dx/dex/code/DalvInsnList.java
  99. +173 −0 src/jvm/com/android/dx/dex/code/Dop.java
  100. +1,441 −0 src/jvm/com/android/dx/dex/code/Dops.java
  101. +73 −0 src/jvm/com/android/dx/dex/code/FixedSizeInsn.java
  102. +147 −0 src/jvm/com/android/dx/dex/code/HighRegisterPrefix.java
  103. +715 −0 src/jvm/com/android/dx/dex/code/InsnFormat.java
  104. +90 −0 src/jvm/com/android/dx/dex/code/LocalEnd.java
  105. +948 −0 src/jvm/com/android/dx/dex/code/LocalList.java
  106. +96 −0 src/jvm/com/android/dx/dex/code/LocalSnapshot.java
  107. +98 −0 src/jvm/com/android/dx/dex/code/LocalStart.java
  108. +76 −0 src/jvm/com/android/dx/dex/code/OddSpacer.java
  109. +121 −0 src/jvm/com/android/dx/dex/code/OutputCollector.java
  110. +750 −0 src/jvm/com/android/dx/dex/code/OutputFinisher.java
  111. +192 −0 src/jvm/com/android/dx/dex/code/PositionList.java
  112. +587 −0 src/jvm/com/android/dx/dex/code/RopToDop.java
  113. +879 −0 src/jvm/com/android/dx/dex/code/RopTranslator.java
  114. +59 −0 src/jvm/com/android/dx/dex/code/SimpleInsn.java
  115. +316 −0 src/jvm/com/android/dx/dex/code/StdCatchBuilder.java
  116. +258 −0 src/jvm/com/android/dx/dex/code/SwitchData.java
  117. +132 −0 src/jvm/com/android/dx/dex/code/TargetInsn.java
  118. +49 −0 src/jvm/com/android/dx/dex/code/VariableSizeInsn.java
  119. +62 −0 src/jvm/com/android/dx/dex/code/ZeroSizeInsn.java
  120. +86 −0 src/jvm/com/android/dx/dex/code/form/Form10t.java
  121. +72 −0 src/jvm/com/android/dx/dex/code/form/Form10x.java
  122. +110 −0 src/jvm/com/android/dx/dex/code/form/Form11n.java
  123. +88 −0 src/jvm/com/android/dx/dex/code/form/Form11x.java
  124. +138 −0 src/jvm/com/android/dx/dex/code/form/Form12x.java
  125. +86 −0 src/jvm/com/android/dx/dex/code/form/Form20t.java
  126. +149 −0 src/jvm/com/android/dx/dex/code/form/Form21c.java
  127. +126 −0 src/jvm/com/android/dx/dex/code/form/Form21h.java
  128. +110 −0 src/jvm/com/android/dx/dex/code/form/Form21s.java
  129. +106 −0 src/jvm/com/android/dx/dex/code/form/Form21t.java
  130. +113 −0 src/jvm/com/android/dx/dex/code/form/Form22b.java
  131. +115 −0 src/jvm/com/android/dx/dex/code/form/Form22c.java
  132. +114 −0 src/jvm/com/android/dx/dex/code/form/Form22s.java
  133. +110 −0 src/jvm/com/android/dx/dex/code/form/Form22t.java
  134. +93 −0 src/jvm/com/android/dx/dex/code/form/Form22x.java
  135. +96 −0 src/jvm/com/android/dx/dex/code/form/Form23x.java
  136. +82 −0 src/jvm/com/android/dx/dex/code/form/Form30t.java
  137. +142 −0 src/jvm/com/android/dx/dex/code/form/Form31c.java
  138. +106 −0 src/jvm/com/android/dx/dex/code/form/Form31i.java
  139. +100 −0 src/jvm/com/android/dx/dex/code/form/Form31t.java
  140. +94 −0 src/jvm/com/android/dx/dex/code/form/Form32x.java
  141. +211 −0 src/jvm/com/android/dx/dex/code/form/Form35c.java
  142. +106 −0 src/jvm/com/android/dx/dex/code/form/Form3rc.java
  143. +144 −0 src/jvm/com/android/dx/dex/code/form/Form41c.java
  144. +103 −0 src/jvm/com/android/dx/dex/code/form/Form51l.java
  145. +115 −0 src/jvm/com/android/dx/dex/code/form/Form52c.java
Sorry, we could not display the entire diff because too many files (338) changed.
View
52 build.xml
@@ -20,9 +20,6 @@
<property name="android.platform.dir" location="${android.sdk.dir}/platforms/android-${android.version}"/>
<property name="android.jar" location="${android.platform.dir}/android.jar"/>
<property name="dx" location="${android.platform-tools.dir}/dx"/>
- <property name="dx.jar" location="${android.platform-tools.dir}/lib/dx.jar"/>
- <property name="dx-lite.jar" location="dx-lite.jar"/>
- <property name="android.jar" location="${android.sdk.dir}/platform-tools"/>
<property name="dex.file" location="classes.dex"/>
<property name="src" location="src"/>
@@ -104,40 +101,6 @@
<chmod file="pom.xml" perm="ugo-w"/>
</target>
- <target name="-check-proguard" depends="init">
- <available property="proguard.available"
- classpath="${proguard.jar}" classname="proguard.ProGuard"/>
- </target>
-
- <target name="-shrink-dx-jar" depends="-check-proguard"
- if="proguard.available">
- <echo>ProGuard available, shrinking to create dx-lite.jar</echo>
- <taskdef resource="proguard/ant/task.properties"
- classpath="${proguard.jar}"/>
- <proguard>
- -injars ${dx.jar}
- -outjar ${dx-lite.jar}
- -libraryjars ${android.jar}
- @dx-proguard.cfg
- </proguard>
- </target>
-
- <target name="-copy-dx-jar" depends="-check-proguard"
- unless="proguard.available">
- <echo>No ProGuard available, using simple copy to create dx-lite.jar</echo>
- <jar jarfile="${dx-lite.jar}">
- <zipfileset src="${dx.jar}">
- <exclude name="junit/**"/>
- <exclude name="META-INF/**"/>
- <exclude name="**/_tests"/>
- <exclude name="**/_tests/_*.class"/>
- </zipfileset>
- </jar>
- </target>
-
- <target name="dx-lite" depends="-shrink-dx-jar,-copy-dx-jar"
- description="Creates a stripped version of dx.jar"/>
-
<macrodef name="compile-java">
<element name="compile-elements"
implicit="yes"
@@ -158,14 +121,15 @@
<compile-java>
<include name="**/*.java"/>
<exclude name="**/Dalvik*.java"/>
+ <exclude name="com/android/**/*.java"/>
</compile-java>
</target>
- <target name="-compile-java-dalvik" depends="init,dx-lite" if="android.enabled">
+ <target name="-compile-java-dalvik" depends="init" if="${android.enabled}">
<compile-java>
<include name="**/Dalvik*.java"/>
+ <include name="com/android/**/*.java"/>
<classpath>
- <pathelement path="${dx-lite.jar}"/>
<pathelement path="${android.jar}"/>
</classpath>
</compile-java>
@@ -279,15 +243,12 @@
<copy file="${src_jar}" tofile="${src_noversion_jar}" />
</target>
- <target name="clojure-jar-no-sources" depends="clojure-jar" if="android.enabled">
+ <target name="clojure-jar-no-sources" depends="clojure-jar" if="${android.enabled}">
<jar jarfile="${nosrc_jar}">
<zipfileset src="${clojure_jar}">
<include name="**/*.class"/>
<include name="clojure/version.properties"/>
</zipfileset>
- <zipfileset src="${dx-lite.jar}">
- <include name="**/*.class"/>
- </zipfileset>
<manifest>
<attribute name="Main-Class" value="clojure.main"/>
<attribute name="Class-Path" value="."/>
@@ -296,7 +257,7 @@
<copy file="${nosrc_jar}" tofile="${nosrc_noversion_jar}" />
</target>
- <target name="dex" depends="clojure-jar-no-sources" if="android.enabled">
+ <target name="dex" depends="clojure-jar-no-sources" if="${android.enabled}">
<exec executable="${dx}" failonerror="true">
<arg value="--dex"/>
<arg value="--output=${dex.file}" />
@@ -304,7 +265,7 @@
</exec>
</target>
- <target name="clojure-jar-dex" depends="dex" if="android.enabled">
+ <target name="clojure-jar-dex" depends="dex" if="${android.enabled}">
<jar jarfile="${dex_jar}">
<fileset dir="${cljsrc}" includes="clojure/version.properties"/>
<mappedresources>
@@ -324,7 +285,6 @@
<delete dir="${dist}"/>
<delete file="pom.xml"/>
<delete file="${dex.file}"/>
- <delete file="${dx-lite.jar}"/>
<delete verbose="true">
<fileset dir="${basedir}" includes="*.jar"/>
<fileset dir="${basedir}" includes="*.zip"/>
View
1  local.properties.example
@@ -1,4 +1,3 @@
android.enabled=true
android.version=7
android.sdk.dir=/opt/android-sdk-update-manager
-#proguard.jar=/path/to//proguard.jar
View
194 readme.txt
@@ -103,3 +103,197 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
+
+
+--------------------------------------------------------------------------
+This program uses source code from the Dalvik eXchange from the Android Open
+Source Project which is distributed under the following terms:
+
+Copyright (c) 2005-2008, The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
View
2  src/clj/clojure/main.clj
@@ -161,7 +161,7 @@
[& options]
(let [cl (.getContextClassLoader (Thread/currentThread))]
(.setContextClassLoader (Thread/currentThread)
- (if (= *vm-type* :dalvik-vm)
+ (if (= vm-type :dalvik-vm)
(let [cl-class (Class/forName "clojure.lang.DalvikDynamicClassLoader")
cl-constructor (.getConstructor cl-class (into-array [ClassLoader]))]
(.newInstance cl-constructor cl))
View
9 src/jvm/clojure/lang/DalvikDynamicClassLoader.java
@@ -13,6 +13,7 @@
import android.util.Log;
import com.android.dx.dex.cf.CfOptions;
import com.android.dx.dex.cf.CfTranslator;
+import com.android.dx.dex.DexOptions;
import dalvik.system.DexFile;
import java.io.File;
import java.io.FileOutputStream;
@@ -34,10 +35,14 @@
/** Reference to compile path var, used for generated jar files. */
private static final Var COMPILE_PATH =
RT.var("clojure.core", "*compile-path*");
+ /** Configure whether or not to use extended op codes. */
+ private static final DexOptions DEX_OPTIONS = new DexOptions();
static {
// disable name checks
OPTIONS.strictNameCheck = false;
+ // ensure generation of compatible DEX files
+ DEX_OPTIONS.targetApiLevel = android.os.Build.VERSION.SDK_INT;
}
/** Tag used for logging. */
@@ -70,8 +75,8 @@ public DalvikDynamicClassLoader(final ClassLoader parent) {
final Object srcForm) {
// create dx DexFile and add translated class into it
final com.android.dx.dex.file.DexFile outDexFile =
- new com.android.dx.dex.file.DexFile();
- outDexFile.add(CfTranslator.translate("", bytes, OPTIONS));
+ new com.android.dx.dex.file.DexFile(DEX_OPTIONS);
+ outDexFile.add(CfTranslator.translate("", bytes, OPTIONS, DEX_OPTIONS));
// get compile directory
final File compileDir = new File((String) COMPILE_PATH.deref());
View
2  src/jvm/clojure/lang/RT.java
@@ -187,7 +187,7 @@
static Keyword DALVIK_VM = Keyword.intern(null, "dalvik-vm");
static Keyword JAVA_VM = Keyword.intern(null, "java-vm");
final static public Var VM_TYPE =
- Var.intern(CLOJURE_NS, Symbol.create("*vm-type*"),
+ Var.intern(CLOJURE_NS, Symbol.create("vm-type"),
(System.getProperty("java.vm.name").equals("Dalvik")) ? DALVIK_VM : JAVA_VM);
static Keyword LINE_KEY = Keyword.intern(null, "line");
static Keyword FILE_KEY = Keyword.intern(null, "file");
View
67 src/jvm/com/android/dx/cf/attrib/AttAnnotationDefault.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.cst.Constant;
+
+/**
+ * Attribute class for {@code AnnotationDefault} attributes.
+ */
+public final class AttAnnotationDefault extends BaseAttribute {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "AnnotationDefault";
+
+ /** {@code non-null;} the annotation default value */
+ private final Constant value;
+
+ /** {@code >= 0;} attribute data length in the original classfile (not
+ * including the attribute header) */
+ private final int byteLength;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param value {@code non-null;} the annotation default value
+ * @param byteLength {@code >= 0;} attribute data length in the original
+ * classfile (not including the attribute header)
+ */
+ public AttAnnotationDefault(Constant value, int byteLength) {
+ super(ATTRIBUTE_NAME);
+
+ if (value == null) {
+ throw new NullPointerException("value == null");
+ }
+
+ this.value = value;
+ this.byteLength = byteLength;
+ }
+
+ /** {@inheritDoc} */
+ public int byteLength() {
+ // Add six for the standard attribute header.
+ return byteLength + 6;
+ }
+
+ /**
+ * Gets the annotation default value.
+ *
+ * @return {@code non-null;} the value
+ */
+ public Constant getValue() {
+ return value;
+ }
+}
View
145 src/jvm/com/android/dx/cf/attrib/AttCode.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.cf.code.ByteCatchList;
+import com.android.dx.cf.code.BytecodeArray;
+import com.android.dx.cf.iface.AttributeList;
+import com.android.dx.util.MutabilityException;
+
+/**
+ * Attribute class for standard {@code Code} attributes.
+ */
+public final class AttCode extends BaseAttribute {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "Code";
+
+ /** {@code >= 0;} the stack size */
+ private final int maxStack;
+
+ /** {@code >= 0;} the number of locals */
+ private final int maxLocals;
+
+ /** {@code non-null;} array containing the bytecode per se */
+ private final BytecodeArray code;
+
+ /** {@code non-null;} the exception table */
+ private final ByteCatchList catches;
+
+ /** {@code non-null;} the associated list of attributes */
+ private final AttributeList attributes;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param maxStack {@code >= 0;} the stack size
+ * @param maxLocals {@code >= 0;} the number of locals
+ * @param code {@code non-null;} array containing the bytecode per se
+ * @param catches {@code non-null;} the exception table
+ * @param attributes {@code non-null;} the associated list of attributes
+ */
+ public AttCode(int maxStack, int maxLocals, BytecodeArray code,
+ ByteCatchList catches, AttributeList attributes) {
+ super(ATTRIBUTE_NAME);
+
+ if (maxStack < 0) {
+ throw new IllegalArgumentException("maxStack < 0");
+ }
+
+ if (maxLocals < 0) {
+ throw new IllegalArgumentException("maxLocals < 0");
+ }
+
+ if (code == null) {
+ throw new NullPointerException("code == null");
+ }
+
+ try {
+ if (catches.isMutable()) {
+ throw new MutabilityException("catches.isMutable()");
+ }
+ } catch (NullPointerException ex) {
+ // Translate the exception.
+ throw new NullPointerException("catches == null");
+ }
+
+ try {
+ if (attributes.isMutable()) {
+ throw new MutabilityException("attributes.isMutable()");
+ }
+ } catch (NullPointerException ex) {
+ // Translate the exception.
+ throw new NullPointerException("attributes == null");
+ }
+
+ this.maxStack = maxStack;
+ this.maxLocals = maxLocals;
+ this.code = code;
+ this.catches = catches;
+ this.attributes = attributes;
+ }
+
+ public int byteLength() {
+ return 10 + code.byteLength() + catches.byteLength() +
+ attributes.byteLength();
+ }
+
+ /**
+ * Gets the maximum stack size.
+ *
+ * @return {@code >= 0;} the maximum stack size
+ */
+ public int getMaxStack() {
+ return maxStack;
+ }
+
+ /**
+ * Gets the number of locals.
+ *
+ * @return {@code >= 0;} the number of locals
+ */
+ public int getMaxLocals() {
+ return maxLocals;
+ }
+
+ /**
+ * Gets the bytecode array.
+ *
+ * @return {@code non-null;} the bytecode array
+ */
+ public BytecodeArray getCode() {
+ return code;
+ }
+
+ /**
+ * Gets the exception table.
+ *
+ * @return {@code non-null;} the exception table
+ */
+ public ByteCatchList getCatches() {
+ return catches;
+ }
+
+ /**
+ * Gets the associated attribute list.
+ *
+ * @return {@code non-null;} the attribute list
+ */
+ public AttributeList getAttributes() {
+ return attributes;
+ }
+}
View
77 src/jvm/com/android/dx/cf/attrib/AttConstantValue.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.cst.CstDouble;
+import com.android.dx.rop.cst.CstFloat;
+import com.android.dx.rop.cst.CstInteger;
+import com.android.dx.rop.cst.CstLong;
+import com.android.dx.rop.cst.CstString;
+import com.android.dx.rop.cst.TypedConstant;
+
+/**
+ * Attribute class for standard {@code ConstantValue} attributes.
+ */
+public final class AttConstantValue extends BaseAttribute {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "ConstantValue";
+
+ /** {@code non-null;} the constant value */
+ private final TypedConstant constantValue;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param constantValue {@code non-null;} the constant value, which must
+ * be an instance of one of: {@code CstString},
+ * {@code CstInteger}, {@code CstLong},
+ * {@code CstFloat}, or {@code CstDouble}
+ */
+ public AttConstantValue(TypedConstant constantValue) {
+ super(ATTRIBUTE_NAME);
+
+ if (!((constantValue instanceof CstString) ||
+ (constantValue instanceof CstInteger) ||
+ (constantValue instanceof CstLong) ||
+ (constantValue instanceof CstFloat) ||
+ (constantValue instanceof CstDouble))) {
+ if (constantValue == null) {
+ throw new NullPointerException("constantValue == null");
+ }
+ throw new IllegalArgumentException("bad type for constantValue");
+ }
+
+ this.constantValue = constantValue;
+ }
+
+ /** {@inheritDoc} */
+ public int byteLength() {
+ return 8;
+ }
+
+ /**
+ * Gets the constant value of this instance. The returned value
+ * is an instance of one of: {@code CstString},
+ * {@code CstInteger}, {@code CstLong},
+ * {@code CstFloat}, or {@code CstDouble}.
+ *
+ * @return {@code non-null;} the constant value
+ */
+ public TypedConstant getConstantValue() {
+ return constantValue;
+ }
+}
View
37 src/jvm/com/android/dx/cf/attrib/AttDeprecated.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+/**
+ * Attribute class for standard {@code Deprecated} attributes.
+ */
+public final class AttDeprecated extends BaseAttribute {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "Deprecated";
+
+ /**
+ * Constructs an instance.
+ */
+ public AttDeprecated() {
+ super(ATTRIBUTE_NAME);
+ }
+
+ /** {@inheritDoc} */
+ public int byteLength() {
+ return 6;
+ }
+}
View
78 src/jvm/com/android/dx/cf/attrib/AttEnclosingMethod.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.cst.CstNat;
+import com.android.dx.rop.cst.CstType;
+
+/**
+ * Attribute class for standards-track {@code EnclosingMethod}
+ * attributes.
+ */
+public final class AttEnclosingMethod extends BaseAttribute {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "EnclosingMethod";
+
+ /** {@code non-null;} the innermost enclosing class */
+ private final CstType type;
+
+ /** {@code null-ok;} the name-and-type of the innermost enclosing method, if any */
+ private final CstNat method;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param type {@code non-null;} the innermost enclosing class
+ * @param method {@code null-ok;} the name-and-type of the innermost enclosing
+ * method, if any
+ */
+ public AttEnclosingMethod(CstType type, CstNat method) {
+ super(ATTRIBUTE_NAME);
+
+ if (type == null) {
+ throw new NullPointerException("type == null");
+ }
+
+ this.type = type;
+ this.method = method;
+ }
+
+ /** {@inheritDoc} */
+ public int byteLength() {
+ return 10;
+ }
+
+ /**
+ * Gets the innermost enclosing class.
+ *
+ * @return {@code non-null;} the innermost enclosing class
+ */
+ public CstType getEnclosingClass() {
+ return type;
+ }
+
+ /**
+ * Gets the name-and-type of the innermost enclosing method, if
+ * any.
+ *
+ * @return {@code null-ok;} the name-and-type of the innermost enclosing
+ * method, if any
+ */
+ public CstNat getMethod() {
+ return method;
+ }
+}
View
68 src/jvm/com/android/dx/cf/attrib/AttExceptions.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.type.TypeList;
+import com.android.dx.util.MutabilityException;
+
+/**
+ * Attribute class for standard {@code Exceptions} attributes.
+ */
+public final class AttExceptions extends BaseAttribute {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "Exceptions";
+
+ /** {@code non-null;} list of exception classes */
+ private final TypeList exceptions;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param exceptions {@code non-null;} list of classes, presumed but not
+ * verified to be subclasses of {@code Throwable}
+ */
+ public AttExceptions(TypeList exceptions) {
+ super(ATTRIBUTE_NAME);
+
+ try {
+ if (exceptions.isMutable()) {
+ throw new MutabilityException("exceptions.isMutable()");
+ }
+ } catch (NullPointerException ex) {
+ // Translate the exception.
+ throw new NullPointerException("exceptions == null");
+ }
+
+ this.exceptions = exceptions;
+ }
+
+ /** {@inheritDoc} */
+ public int byteLength() {
+ return 8 + exceptions.size() * 2;
+ }
+
+ /**
+ * Gets the list of classes associated with this instance. In
+ * general, these classes are not pre-verified to be subclasses of
+ * {@code Throwable}.
+ *
+ * @return {@code non-null;} the list of classes
+ */
+ public TypeList getExceptions() {
+ return exceptions;
+ }
+}
View
64 src/jvm/com/android/dx/cf/attrib/AttInnerClasses.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.util.MutabilityException;
+
+/**
+ * Attribute class for standard {@code InnerClasses} attributes.
+ */
+public final class AttInnerClasses extends BaseAttribute {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "InnerClasses";
+
+ /** {@code non-null;} list of inner class entries */
+ private final InnerClassList innerClasses;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param innerClasses {@code non-null;} list of inner class entries
+ */
+ public AttInnerClasses(InnerClassList innerClasses) {
+ super(ATTRIBUTE_NAME);
+
+ try {
+ if (innerClasses.isMutable()) {
+ throw new MutabilityException("innerClasses.isMutable()");
+ }
+ } catch (NullPointerException ex) {
+ // Translate the exception.
+ throw new NullPointerException("innerClasses == null");
+ }
+
+ this.innerClasses = innerClasses;
+ }
+
+ /** {@inheritDoc} */
+ public int byteLength() {
+ return 8 + innerClasses.size() * 8;
+ }
+
+ /**
+ * Gets the list of "inner class" entries associated with this instance.
+ *
+ * @return {@code non-null;} the list
+ */
+ public InnerClassList getInnerClasses() {
+ return innerClasses;
+ }
+}
View
65 src/jvm/com/android/dx/cf/attrib/AttLineNumberTable.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.cf.code.LineNumberList;
+import com.android.dx.util.MutabilityException;
+
+/**
+ * Attribute class for standard {@code LineNumberTable} attributes.
+ */
+public final class AttLineNumberTable extends BaseAttribute {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "LineNumberTable";
+
+ /** {@code non-null;} list of line number entries */
+ private final LineNumberList lineNumbers;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param lineNumbers {@code non-null;} list of line number entries
+ */
+ public AttLineNumberTable(LineNumberList lineNumbers) {
+ super(ATTRIBUTE_NAME);
+
+ try {
+ if (lineNumbers.isMutable()) {
+ throw new MutabilityException("lineNumbers.isMutable()");
+ }
+ } catch (NullPointerException ex) {
+ // Translate the exception.
+ throw new NullPointerException("lineNumbers == null");
+ }
+
+ this.lineNumbers = lineNumbers;
+ }
+
+ /** {@inheritDoc} */
+ public int byteLength() {
+ return 8 + 4 * lineNumbers.size();
+ }
+
+ /**
+ * Gets the list of "line number" entries associated with this instance.
+ *
+ * @return {@code non-null;} the list
+ */
+ public LineNumberList getLineNumbers() {
+ return lineNumbers;
+ }
+}
View
36 src/jvm/com/android/dx/cf/attrib/AttLocalVariableTable.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.cf.code.LocalVariableList;
+
+/**
+ * Attribute class for standard {@code LocalVariableTable} attributes.
+ */
+public final class AttLocalVariableTable extends BaseLocalVariables {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "LocalVariableTable";
+
+ /**
+ * Constructs an instance.
+ *
+ * @param localVariables {@code non-null;} list of local variable entries
+ */
+ public AttLocalVariableTable(LocalVariableList localVariables) {
+ super(ATTRIBUTE_NAME, localVariables);
+ }
+}
View
36 src/jvm/com/android/dx/cf/attrib/AttLocalVariableTypeTable.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.cf.code.LocalVariableList;
+
+/**
+ * Attribute class for standard {@code LocalVariableTypeTable} attributes.
+ */
+public final class AttLocalVariableTypeTable extends BaseLocalVariables {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "LocalVariableTypeTable";
+
+ /**
+ * Constructs an instance.
+ *
+ * @param localVariables {@code non-null;} list of local variable entries
+ */
+ public AttLocalVariableTypeTable(LocalVariableList localVariables) {
+ super(ATTRIBUTE_NAME, localVariables);
+ }
+}
View
40 src/jvm/com/android/dx/cf/attrib/AttRuntimeInvisibleAnnotations.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.annotation.Annotations;
+
+/**
+ * Attribute class for standard {@code RuntimeInvisibleAnnotations}
+ * attributes.
+ */
+public final class AttRuntimeInvisibleAnnotations extends BaseAnnotations {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "RuntimeInvisibleAnnotations";
+
+ /**
+ * Constructs an instance.
+ *
+ * @param annotations {@code non-null;} the list of annotations
+ * @param byteLength {@code >= 0;} attribute data length in the original
+ * classfile (not including the attribute header)
+ */
+ public AttRuntimeInvisibleAnnotations(Annotations annotations,
+ int byteLength) {
+ super(ATTRIBUTE_NAME, annotations, byteLength);
+ }
+}
View
42 src/jvm/com/android/dx/cf/attrib/AttRuntimeInvisibleParameterAnnotations.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.annotation.AnnotationsList;
+
+/**
+ * Attribute class for standard
+ * {@code RuntimeInvisibleParameterAnnotations} attributes.
+ */
+public final class AttRuntimeInvisibleParameterAnnotations
+ extends BaseParameterAnnotations {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME =
+ "RuntimeInvisibleParameterAnnotations";
+
+ /**
+ * Constructs an instance.
+ *
+ * @param parameterAnnotations {@code non-null;} the parameter annotations
+ * @param byteLength {@code >= 0;} attribute data length in the original
+ * classfile (not including the attribute header)
+ */
+ public AttRuntimeInvisibleParameterAnnotations(
+ AnnotationsList parameterAnnotations, int byteLength) {
+ super(ATTRIBUTE_NAME, parameterAnnotations, byteLength);
+ }
+}
View
40 src/jvm/com/android/dx/cf/attrib/AttRuntimeVisibleAnnotations.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.annotation.Annotations;
+
+/**
+ * Attribute class for standard {@code RuntimeVisibleAnnotations}
+ * attributes.
+ */
+public final class AttRuntimeVisibleAnnotations extends BaseAnnotations {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "RuntimeVisibleAnnotations";
+
+ /**
+ * Constructs an instance.
+ *
+ * @param annotations {@code non-null;} the list of annotations
+ * @param byteLength {@code >= 0;} attribute data length in the original
+ * classfile (not including the attribute header)
+ */
+ public AttRuntimeVisibleAnnotations(Annotations annotations,
+ int byteLength) {
+ super(ATTRIBUTE_NAME, annotations, byteLength);
+ }
+}
View
42 src/jvm/com/android/dx/cf/attrib/AttRuntimeVisibleParameterAnnotations.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.annotation.AnnotationsList;
+
+/**
+ * Attribute class for standard {@code RuntimeVisibleParameterAnnotations}
+ * attributes.
+ */
+public final class AttRuntimeVisibleParameterAnnotations
+ extends BaseParameterAnnotations {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME =
+ "RuntimeVisibleParameterAnnotations";
+
+ /**
+ * Constructs an instance.
+ *
+ * @param annotations {@code non-null;} the parameter annotations
+ * @param byteLength {@code >= 0;} attribute data length in the original
+ * classfile (not including the attribute header)
+ */
+ public AttRuntimeVisibleParameterAnnotations(
+ AnnotationsList annotations, int byteLength) {
+ super(ATTRIBUTE_NAME, annotations, byteLength);
+ }
+}
View
59 src/jvm/com/android/dx/cf/attrib/AttSignature.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.cst.CstString;
+
+/**
+ * Attribute class for standards-track {@code Signature} attributes.
+ */
+public final class AttSignature extends BaseAttribute {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "Signature";
+
+ /** {@code non-null;} the signature string */
+ private final CstString signature;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param signature {@code non-null;} the signature string
+ */
+ public AttSignature(CstString signature) {
+ super(ATTRIBUTE_NAME);
+
+ if (signature == null) {
+ throw new NullPointerException("signature == null");
+ }
+
+ this.signature = signature;
+ }
+
+ /** {@inheritDoc} */
+ public int byteLength() {
+ return 8;
+ }
+
+ /**
+ * Gets the signature string.
+ *
+ * @return {@code non-null;} the signature string
+ */
+ public CstString getSignature() {
+ return signature;
+ }
+}
View
59 src/jvm/com/android/dx/cf/attrib/AttSourceFile.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.cst.CstString;
+
+/**
+ * Attribute class for standard {@code SourceFile} attributes.
+ */
+public final class AttSourceFile extends BaseAttribute {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "SourceFile";
+
+ /** {@code non-null;} name of the source file */
+ private final CstString sourceFile;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param sourceFile {@code non-null;} the name of the source file
+ */
+ public AttSourceFile(CstString sourceFile) {
+ super(ATTRIBUTE_NAME);
+
+ if (sourceFile == null) {
+ throw new NullPointerException("sourceFile == null");
+ }
+
+ this.sourceFile = sourceFile;
+ }
+
+ /** {@inheritDoc} */
+ public int byteLength() {
+ return 8;
+ }
+
+ /**
+ * Gets the source file name of this instance.
+ *
+ * @return {@code non-null;} the source file
+ */
+ public CstString getSourceFile() {
+ return sourceFile;
+ }
+}
View
37 src/jvm/com/android/dx/cf/attrib/AttSynthetic.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+/**
+ * Attribute class for standard {@code Synthetic} attributes.
+ */
+public final class AttSynthetic extends BaseAttribute {
+ /** {@code non-null;} attribute name for attributes of this type */
+ public static final String ATTRIBUTE_NAME = "Synthetic";
+
+ /**
+ * Constructs an instance.
+ */
+ public AttSynthetic() {
+ super(ATTRIBUTE_NAME);
+ }
+
+ /** {@inheritDoc} */
+ public int byteLength() {
+ return 6;
+ }
+}
View
72 src/jvm/com/android/dx/cf/attrib/BaseAnnotations.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.annotation.Annotations;
+import com.android.dx.util.MutabilityException;
+
+/**
+ * Base class for annotations attributes.
+ */
+public abstract class BaseAnnotations extends BaseAttribute {
+ /** {@code non-null;} list of annotations */
+ private final Annotations annotations;
+
+ /** {@code >= 0;} attribute data length in the original classfile (not
+ * including the attribute header) */
+ private final int byteLength;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param attributeName {@code non-null;} the name of the attribute
+ * @param annotations {@code non-null;} the list of annotations
+ * @param byteLength {@code >= 0;} attribute data length in the original
+ * classfile (not including the attribute header)
+ */
+ public BaseAnnotations(String attributeName, Annotations annotations,
+ int byteLength) {
+ super(attributeName);
+
+ try {
+ if (annotations.isMutable()) {
+ throw new MutabilityException("annotations.isMutable()");
+ }
+ } catch (NullPointerException ex) {
+ // Translate the exception.
+ throw new NullPointerException("annotations == null");
+ }
+
+ this.annotations = annotations;
+ this.byteLength = byteLength;
+ }
+
+ /** {@inheritDoc} */
+ public final int byteLength() {
+ // Add six for the standard attribute header.
+ return byteLength + 6;
+ }
+
+ /**
+ * Gets the list of annotations associated with this instance.
+ *
+ * @return {@code non-null;} the list
+ */
+ public final Annotations getAnnotations() {
+ return annotations;
+ }
+}
View
46 src/jvm/com/android/dx/cf/attrib/BaseAttribute.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.cf.iface.Attribute;
+
+/**
+ * Base implementation of {@link Attribute}, which directly stores
+ * the attribute name but leaves the rest up to subclasses.
+ */
+public abstract class BaseAttribute implements Attribute {
+ /** {@code non-null;} attribute name */
+ private final String name;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param name {@code non-null;} attribute name
+ */
+ public BaseAttribute(String name) {
+ if (name == null) {
+ throw new NullPointerException("name == null");
+ }
+
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ public String getName() {
+ return name;
+ }
+}
View
65 src/jvm/com/android/dx/cf/attrib/BaseLocalVariables.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.cf.code.LocalVariableList;
+import com.android.dx.util.MutabilityException;
+
+/**
+ * Base attribute class for standard {@code LocalVariableTable}
+ * and {@code LocalVariableTypeTable} attributes.
+ */
+public abstract class BaseLocalVariables extends BaseAttribute {
+ /** {@code non-null;} list of local variable entries */
+ private final LocalVariableList localVariables;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param name {@code non-null;} attribute name
+ * @param localVariables {@code non-null;} list of local variable entries
+ */
+ public BaseLocalVariables(String name,
+ LocalVariableList localVariables) {
+ super(name);
+
+ try {
+ if (localVariables.isMutable()) {
+ throw new MutabilityException("localVariables.isMutable()");
+ }
+ } catch (NullPointerException ex) {
+ // Translate the exception.
+ throw new NullPointerException("localVariables == null");
+ }
+
+ this.localVariables = localVariables;
+ }
+
+ /** {@inheritDoc} */
+ public final int byteLength() {
+ return 8 + localVariables.size() * 10;
+ }
+
+ /**
+ * Gets the list of "local variable" entries associated with this instance.
+ *
+ * @return {@code non-null;} the list
+ */
+ public final LocalVariableList getLocalVariables() {
+ return localVariables;
+ }
+}
View
73 src/jvm/com/android/dx/cf/attrib/BaseParameterAnnotations.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.annotation.AnnotationsList;
+import com.android.dx.util.MutabilityException;
+
+/**
+ * Base class for parameter annotation list attributes.
+ */
+public abstract class BaseParameterAnnotations extends BaseAttribute {
+ /** {@code non-null;} list of annotations */
+ private final AnnotationsList parameterAnnotations;
+
+ /** {@code >= 0;} attribute data length in the original classfile (not
+ * including the attribute header) */
+ private final int byteLength;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param attributeName {@code non-null;} the name of the attribute
+ * @param parameterAnnotations {@code non-null;} the annotations
+ * @param byteLength {@code >= 0;} attribute data length in the original
+ * classfile (not including the attribute header)
+ */
+ public BaseParameterAnnotations(String attributeName,
+ AnnotationsList parameterAnnotations, int byteLength) {
+ super(attributeName);
+
+ try {
+ if (parameterAnnotations.isMutable()) {
+ throw new MutabilityException(
+ "parameterAnnotations.isMutable()");
+ }
+ } catch (NullPointerException ex) {
+ // Translate the exception.
+ throw new NullPointerException("parameterAnnotations == null");
+ }
+
+ this.parameterAnnotations = parameterAnnotations;
+ this.byteLength = byteLength;
+ }
+
+ /** {@inheritDoc} */
+ public final int byteLength() {
+ // Add six for the standard attribute header.
+ return byteLength + 6;
+ }
+
+ /**
+ * Gets the list of annotation lists associated with this instance.
+ *
+ * @return {@code non-null;} the list
+ */
+ public final AnnotationsList getParameterAnnotations() {
+ return parameterAnnotations;
+ }
+}
View
137 src/jvm/com/android/dx/cf/attrib/InnerClassList.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.cst.CstString;
+import com.android.dx.rop.cst.CstType;
+import com.android.dx.util.FixedSizeList;
+
+/**
+ * List of "inner class" entries, which are the contents of
+ * {@code InnerClasses} attributes.
+ */
+public final class InnerClassList extends FixedSizeList {
+ /**
+ * Constructs an instance.
+ *
+ * @param count the number of elements to be in the list of inner classes
+ */
+ public InnerClassList(int count) {
+ super(count);
+ }
+
+ /**
+ * Gets the indicated item.
+ *
+ * @param n {@code >= 0;} which item
+ * @return {@code null-ok;} the indicated item
+ */
+ public Item get(int n) {
+ return (Item) get0(n);
+ }
+
+ /**
+ * Sets the item at the given index.
+ *
+ * @param n {@code >= 0, < size();} which class
+ * @param innerClass {@code non-null;} class this item refers to
+ * @param outerClass {@code null-ok;} outer class that this class is a
+ * member of, if any
+ * @param innerName {@code null-ok;} original simple name of this class,
+ * if not anonymous
+ * @param accessFlags original declared access flags
+ */
+ public void set(int n, CstType innerClass, CstType outerClass,
+ CstString innerName, int accessFlags) {
+ set0(n, new Item(innerClass, outerClass, innerName, accessFlags));
+ }
+
+ /**
+ * Item in an inner classes list.
+ */
+ public static class Item {
+ /** {@code non-null;} class this item refers to */
+ private final CstType innerClass;
+
+ /** {@code null-ok;} outer class that this class is a member of, if any */
+ private final CstType outerClass;
+
+ /** {@code null-ok;} original simple name of this class, if not anonymous */
+ private final CstString innerName;
+
+ /** original declared access flags */
+ private final int accessFlags;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param innerClass {@code non-null;} class this item refers to
+ * @param outerClass {@code null-ok;} outer class that this class is a
+ * member of, if any
+ * @param innerName {@code null-ok;} original simple name of this
+ * class, if not anonymous
+ * @param accessFlags original declared access flags
+ */
+ public Item(CstType innerClass, CstType outerClass,
+ CstString innerName, int accessFlags) {
+ if (innerClass == null) {
+ throw new NullPointerException("innerClass == null");
+ }
+
+ this.innerClass = innerClass;
+ this.outerClass = outerClass;
+ this.innerName = innerName;
+ this.accessFlags = accessFlags;
+ }
+
+ /**
+ * Gets the class this item refers to.
+ *
+ * @return {@code non-null;} the class
+ */
+ public CstType getInnerClass() {
+ return innerClass;
+ }
+
+ /**
+ * Gets the outer class that this item's class is a member of, if any.
+ *
+ * @return {@code null-ok;} the class
+ */
+ public CstType getOuterClass() {
+ return outerClass;
+ }
+
+ /**
+ * Gets the original name of this item's class, if not anonymous.
+ *
+ * @return {@code null-ok;} the name
+ */
+ public CstString getInnerName() {
+ return innerName;
+ }
+
+ /**
+ * Gets the original declared access flags.
+ *
+ * @return the access flags
+ */
+ public int getAccessFlags() {
+ return accessFlags;
+ }
+ }
+}
View
91 src/jvm/com/android/dx/cf/attrib/RawAttribute.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.attrib;
+
+import com.android.dx.rop.cst.ConstantPool;
+import com.android.dx.util.ByteArray;
+
+/**
+ * Raw attribute, for holding onto attributes that are unrecognized.
+ */
+public final class RawAttribute extends BaseAttribute {
+ /** {@code non-null;} attribute data */
+ private final ByteArray data;
+
+ /**
+ * {@code null-ok;} constant pool to use for resolution of cpis in {@link
+ * #data}
+ */
+ private final ConstantPool pool;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param name {@code non-null;} attribute name
+ * @param data {@code non-null;} attribute data
+ * @param pool {@code null-ok;} constant pool to use for cpi resolution
+ */
+ public RawAttribute(String name, ByteArray data, ConstantPool pool) {
+ super(name);
+
+ if (data == null) {
+ throw new NullPointerException("data == null");
+ }
+
+ this.data = data;
+ this.pool = pool;
+ }
+
+ /**
+ * Constructs an instance from a sub-array of a {@link ByteArray}.
+ *
+ * @param name {@code non-null;} attribute name
+ * @param data {@code non-null;} array containing the attribute data
+ * @param offset offset in {@code data} to the attribute data
+ * @param length length of the attribute data, in bytes
+ * @param pool {@code null-ok;} constant pool to use for cpi resolution
+ */
+ public RawAttribute(String name, ByteArray data, int offset,
+ int length, ConstantPool pool) {
+ this(name, data.slice(offset, offset + length), pool);
+ }
+
+ /**
+ * Get the raw data of the attribute.
+ *
+ * @return {@code non-null;} the data
+ */
+ public ByteArray getData() {
+ return data;
+ }
+
+ /** {@inheritDoc} */
+ public int byteLength() {
+ return data.size() + 6;
+ }
+
+ /**
+ * Gets the constant pool to use for cpi resolution, if any. It
+ * presumably came from the class file that this attribute came
+ * from.
+ *
+ * @return {@code null-ok;} the constant pool
+ */
+ public ConstantPool getPool() {
+ return pool;
+ }
+}
View
579 src/jvm/com/android/dx/cf/code/BaseMachine.java
@@ -0,0 +1,579 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dx.cf.code;
+
+import com.android.dx.rop.code.RegisterSpec;
+import com.android.dx.rop.code.LocalItem;
+import com.android.dx.rop.cst.Constant;
+import com.android.dx.rop.type.Prototype;
+import com.android.dx.rop.type.StdTypeList;
+import com.android.dx.rop.type.Type;
+import com.android.dx.rop.type.TypeBearer;
+import java.util.ArrayList;
+
+/**
+ * Base implementation of {@link Machine}.
+ *
+ * <p><b>Note:</b> For the most part, the documentation for this class
+ * ignores the distinction between {@link Type} and {@link
+ * TypeBearer}.</p>
+ */
+public abstract class BaseMachine implements Machine {
+ /* {@code non-null;} the prototype for the associated method */
+ private final Prototype prototype;
+
+ /** {@code non-null;} primary arguments */
+ private TypeBearer[] args;
+
+ /** {@code >= 0;} number of primary arguments */
+ private int argCount;
+
+ /** {@code null-ok;} type of the operation, if salient */
+ private Type auxType;
+
+ /** auxiliary {@code int} argument */
+ private int auxInt;
+
+ /** {@code null-ok;} auxiliary constant argument */
+ private Constant auxCst;
+
+ /** auxiliary branch target argument */
+ private int auxTarget;
+
+ /** {@code null-ok;} auxiliary switch cases argument */
+ private SwitchList auxCases;
+
+ /** {@code null-ok;} auxiliary initial value list for newarray */
+ private ArrayList<Constant> auxInitValues;
+
+ /** {@code >= -1;} last local accessed */
+ private int localIndex;
+
+ /** specifies if local has info in the local variable table */
+ private boolean localInfo;
+
+ /** {@code null-ok;} local target spec, if salient and calculated */
+ private RegisterSpec localTarget;
+
+ /** {@code non-null;} results */
+ private TypeBearer[] results;
+
+ /**
+ * {@code >= -1;} count of the results, or {@code -1} if no results
+ * have been set
+ */
+ private int resultCount;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param prototype {@code non-null;} the prototype for the
+ * associated method
+ */
+ public BaseMachine(Prototype prototype) {
+ if (prototype == null) {
+ throw new NullPointerException("prototype == null");
+ }
+
+ this.prototype = prototype;
+ args = new TypeBearer[10];
+ results = new TypeBearer[6];
+ clearArgs();
+ }
+
+ /** {@inheritDoc} */
+ public Prototype getPrototype() {
+ return prototype;
+ }
+
+ /** {@inheritDoc} */
+ public final void clearArgs() {
+ argCount = 0;
+ auxType = null;
+ auxInt = 0;
+ auxCst = null;
+ auxTarget = 0;
+ auxCases = null;
+ auxInitValues = null;
+ localIndex = -1;
+ localInfo = false;
+ localTarget = null;
+ resultCount = -1;
+ }
+
+ /** {@inheritDoc} */
+ public final void popArgs(Frame frame, int count) {
+ ExecutionStack stack = frame.getStack();
+
+ clearArgs();
+
+ if (count > args.length) {
+ // Grow args, and add a little extra room to grow even more.
+ args = new TypeBearer[count + 10];
+ }
+
+ for (int i = count - 1; i >= 0; i--) {
+ args[i] = stack.pop();
+ }
+
+ argCount = count;
+ }
+
+ /** {@inheritDoc} */
+ public void popArgs(Frame frame, Prototype prototype) {
+ StdTypeList types = prototype.getParameterTypes();
+ int size = types.size();
+
+ // Use the above method to do the actual popping...
+ popArgs(frame, size);
+
+ // ...and then verify the popped types.
+
+ for (int i = 0; i < size; i++) {
+ if (! Merger.isPossiblyAssignableFrom(types.getType(i), args[i])) {
+ throw new SimException("at stack depth " + (size - 1 - i) +
+ ", expected type " + types.getType(i).toHuman() +
+ " but found " + args[i].getType().toHuman());
+ }
+ }
+ }
+
+ public final void popArgs(Frame frame, Type type) {
+ // Use the above method to do the actual popping...
+ popArgs(frame, 1);
+
+ // ...and then verify the popped type.
+ if (! Merger.isPossiblyAssignableFrom(type, args[0])) {
+ throw new SimException("expected type " + type.toHuman() +
+ " but found " + args[0].getType().toHuman());
+ }
+ }
+
+ /** {@inheritDoc} */
+ public final void popArgs(Frame frame, Type type1, Type type2) {
+ // Use the above method to do the actual popping...
+ popArgs(frame, 2);
+
+ // ...and then verify the popped types.
+
+ if (! Merger.isPossiblyAssignableFrom(type1, args[0])) {
+ throw new SimException("expected type " + type1.toHuman() +
+ " but found " + args[0].getType().toHuman());
+ }
+
+ if (! Merger.isPossiblyAssignableFrom(type2, args[1])) {
+ throw new SimException("expected type " + type2.toHuman() +
+ " but found " + args[1].getType().toHuman());
+ }
+ }
+
+ /** {@inheritDoc} */
+ public final void popArgs(Frame frame, Type type1, Type type2,
+ Type type3) {
+ // Use the above method to do the actual popping...
+ popArgs(frame, 3);
+
+ // ...and then verify the popped types.
+
+ if (! Merger.isPossiblyAssignableFrom(type1, args[0])) {
+ throw new SimException("expected type " + type1.toHuman() +
+ " but found " + args[0].getType().toHuman());
+ }
+
+ if (! Merger.isPossiblyAssignableFrom(type2, args[1])) {
+ throw new SimException("expected type " + type2.toHuman() +
+ " but found " + args[1].getType().toHuman());
+ }
+
+ if (! Merger.isPossiblyAssignableFrom(type3, args[2])) {
+ throw new SimException("expected type " + type3.toHuman() +