summaryrefslogtreecommitdiffstats
path: root/dexcomparator
diff options
context:
space:
mode:
authorYohann Roussel <yroussel@google.com>2014-03-19 16:25:37 +0100
committerYohann Roussel <yroussel@google.com>2014-03-20 15:13:33 +0100
commit4eceb95409e844fdc33c9c706e1dc307bfd40303 (patch)
treeee9f4f3fc79f757c79081c336bce4f1782c6ccd8 /dexcomparator
parent3d2402901b1a6462e2cf47a6fd09711f327961c3 (diff)
downloadtoolchain_jack-4eceb95409e844fdc33c9c706e1dc307bfd40303.tar.gz
toolchain_jack-4eceb95409e844fdc33c9c706e1dc307bfd40303.tar.bz2
toolchain_jack-4eceb95409e844fdc33c9c706e1dc307bfd40303.zip
Initial Jack import.
Change-Id: I953cf0a520195a7187d791b2885848ad0d5a9b43
Diffstat (limited to 'dexcomparator')
-rw-r--r--dexcomparator/.checkstyle10
-rw-r--r--dexcomparator/.classpath14
-rw-r--r--dexcomparator/.project29
-rw-r--r--dexcomparator/.settings/edu.umd.cs.findbugs.core.prefs134
-rw-r--r--dexcomparator/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--dexcomparator/.settings/org.eclipse.jdt.core.prefs425
-rw-r--r--dexcomparator/.settings/org.eclipse.jdt.ui.prefs63
-rw-r--r--dexcomparator/.settings/org.eclipse.ltk.core.refactoring.prefs2
-rw-r--r--dexcomparator/Android.mk21
-rw-r--r--dexcomparator/NOTICE176
-rw-r--r--dexcomparator/jackstyle.xml295
-rw-r--r--dexcomparator/src/com/android/jack/DexAnnotationsComparator.java697
-rw-r--r--dexcomparator/src/com/android/jack/DexComparator.java930
-rw-r--r--dexcomparator/src/com/android/jack/DifferenceFoundException.java40
-rw-r--r--dexcomparator/src/com/android/jack/comparator/DebugInfo.java282
15 files changed, 3120 insertions, 0 deletions
diff --git a/dexcomparator/.checkstyle b/dexcomparator/.checkstyle
new file mode 100644
index 00000000..6928075a
--- /dev/null
+++ b/dexcomparator/.checkstyle
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="false" sync-formatter="false">
+ <local-check-config name="Jack Checkstyle" location="jackstyle.xml" type="project" description="">
+ <additional-data name="protect-config-file" value="true"/>
+ </local-check-config>
+ <fileset name="Java Source Files" enabled="true" check-config-name="Jack Checkstyle" local="true">
+ <file-match-pattern match-pattern="^src.*\.java$" include-pattern="true"/>
+ </fileset>
+</fileset-config>
diff --git a/dexcomparator/.classpath b/dexcomparator/.classpath
new file mode 100644
index 00000000..e756a65c
--- /dev/null
+++ b/dexcomparator/.classpath
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/dx-jack_intermediates/javalib.jar" sourcepath="/ANDROID_BUILD_TOP/toolchain/jack/dx/src"/>
+ <classpathentry kind="var" path="ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/dexlib-jack_intermediates/javalib.jar" sourcepath="/ANDROID_BUILD_TOP/toolchain/jack/dexlib/src/main/java"/>
+ <classpathentry kind="var" path="ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/jsr305lib-jack_intermediates/javalib.jar" sourcepath="/ANDROID_BUILD_TOP/toolchain/jack/jsr305/ri/src/main/java"/>
+ <classpathentry kind="src" path=".apt_generated">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/dexcomparator/.project b/dexcomparator/.project
new file mode 100644
index 00000000..bc13270b
--- /dev/null
+++ b/dexcomparator/.project
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dexcomparator</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
+ <nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature>
+ </natures>
+</projectDescription>
diff --git a/dexcomparator/.settings/edu.umd.cs.findbugs.core.prefs b/dexcomparator/.settings/edu.umd.cs.findbugs.core.prefs
new file mode 100644
index 00000000..ea6af7aa
--- /dev/null
+++ b/dexcomparator/.settings/edu.umd.cs.findbugs.core.prefs
@@ -0,0 +1,134 @@
+#FindBugs User Preferences
+#Fri Feb 28 14:57:04 CET 2014
+cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud
+detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
+detectorAtomicityProblem=AtomicityProblem|true
+detectorBadAppletConstructor=BadAppletConstructor|false
+detectorBadResultSetAccess=BadResultSetAccess|true
+detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true
+detectorBadUseOfReturnValue=BadUseOfReturnValue|true
+detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true
+detectorBooleanReturnNull=BooleanReturnNull|true
+detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false
+detectorCheckExpectedWarnings=CheckExpectedWarnings|false
+detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true
+detectorCheckRelaxingNullnessAnnotation=CheckRelaxingNullnessAnnotation|true
+detectorCheckTypeQualifiers=CheckTypeQualifiers|true
+detectorCloneIdiom=CloneIdiom|true
+detectorComparatorIdiom=ComparatorIdiom|true
+detectorConfusedInheritance=ConfusedInheritance|true
+detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true
+detectorCrossSiteScripting=CrossSiteScripting|true
+detectorDefaultEncodingDetector=DefaultEncodingDetector|true
+detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true
+detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true
+detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true
+detectorDontUseEnum=DontUseEnum|true
+detectorDroppedException=DroppedException|true
+detectorDumbMethodInvocations=DumbMethodInvocations|true
+detectorDumbMethods=DumbMethods|true
+detectorDuplicateBranches=DuplicateBranches|true
+detectorEmptyZipFileEntry=EmptyZipFileEntry|true
+detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true
+detectorExplicitSerialization=ExplicitSerialization|true
+detectorFinalizerNullsFields=FinalizerNullsFields|true
+detectorFindBadCast2=FindBadCast2|true
+detectorFindBadForLoop=FindBadForLoop|true
+detectorFindCircularDependencies=FindCircularDependencies|false
+detectorFindDeadLocalStores=FindDeadLocalStores|true
+detectorFindDoubleCheck=FindDoubleCheck|true
+detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true
+detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true
+detectorFindFinalizeInvocations=FindFinalizeInvocations|true
+detectorFindFloatEquality=FindFloatEquality|true
+detectorFindHEmismatch=FindHEmismatch|true
+detectorFindInconsistentSync2=FindInconsistentSync2|true
+detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true
+detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true
+detectorFindMaskedFields=FindMaskedFields|true
+detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true
+detectorFindNakedNotify=FindNakedNotify|true
+detectorFindNonShortCircuit=FindNonShortCircuit|true
+detectorFindNullDeref=FindNullDeref|true
+detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true
+detectorFindOpenStream=FindOpenStream|true
+detectorFindPuzzlers=FindPuzzlers|true
+detectorFindRefComparison=FindRefComparison|true
+detectorFindReturnRef=FindReturnRef|true
+detectorFindRunInvocations=FindRunInvocations|true
+detectorFindSelfComparison=FindSelfComparison|true
+detectorFindSelfComparison2=FindSelfComparison2|true
+detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true
+detectorFindSpinLoop=FindSpinLoop|true
+detectorFindSqlInjection=FindSqlInjection|true
+detectorFindTwoLockWait=FindTwoLockWait|true
+detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true
+detectorFindUnconditionalWait=FindUnconditionalWait|true
+detectorFindUninitializedGet=FindUninitializedGet|true
+detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true
+detectorFindUnreleasedLock=FindUnreleasedLock|true
+detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true
+detectorFindUnsyncGet=FindUnsyncGet|true
+detectorFindUseOfNonSerializableValue=FindUseOfNonSerializableValue|true
+detectorFindUselessControlFlow=FindUselessControlFlow|true
+detectorFormatStringChecker=FormatStringChecker|true
+detectorHugeSharedStringConstants=HugeSharedStringConstants|true
+detectorIDivResultCastToDouble=IDivResultCastToDouble|true
+detectorIncompatMask=IncompatMask|true
+detectorInconsistentAnnotations=InconsistentAnnotations|true
+detectorInefficientMemberAccess=InefficientMemberAccess|false
+detectorInefficientToArray=InefficientToArray|true
+detectorInfiniteLoop=InfiniteLoop|true
+detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true
+detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true
+detectorInitializationChain=InitializationChain|true
+detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true
+detectorInstantiateStaticClass=InstantiateStaticClass|true
+detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true
+detectorInvalidJUnitTest=InvalidJUnitTest|true
+detectorIteratorIdioms=IteratorIdioms|true
+detectorLazyInit=LazyInit|true
+detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true
+detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true
+detectorMethodReturnCheck=MethodReturnCheck|true
+detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true
+detectorMutableLock=MutableLock|true
+detectorMutableStaticFields=MutableStaticFields|true
+detectorNaming=Naming|true
+detectorNoteUnconditionalParamDerefs=NoteUnconditionalParamDerefs|true
+detectorNumberConstructor=NumberConstructor|true
+detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true
+detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true
+detectorPublicSemaphores=PublicSemaphores|false
+detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true
+detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true
+detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true
+detectorRedundantInterfaces=RedundantInterfaces|true
+detectorRepeatedConditionals=RepeatedConditionals|true
+detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true
+detectorSerializableIdiom=SerializableIdiom|true
+detectorStartInConstructor=StartInConstructor|true
+detectorStaticCalendarDetector=StaticCalendarDetector|true
+detectorStringConcatenation=StringConcatenation|true
+detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true
+detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true
+detectorSwitchFallthrough=SwitchFallthrough|true
+detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true
+detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true
+detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true
+detectorURLProblems=URLProblems|true
+detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true
+detectorUnnecessaryMath=UnnecessaryMath|true
+detectorUnreadFields=UnreadFields|true
+detectorUselessSubclassMethod=UselessSubclassMethod|false
+detectorVarArgsProblems=VarArgsProblems|true
+detectorVolatileUsage=VolatileUsage|true
+detectorWaitInLoop=WaitInLoop|true
+detectorWrongMapIterator=WrongMapIterator|true
+detectorXMLFactoryBypass=XMLFactoryBypass|true
+detector_threshold=2
+effort=default
+excludefilter0=.settings/findbugs-exclude.xml|true
+filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,EXPERIMENTAL,MALICIOUS_CODE,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false|20
+filter_settings_neg=NOISE,I18N|
+run_at_full_build=true
diff --git a/dexcomparator/.settings/org.eclipse.core.resources.prefs b/dexcomparator/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..99f26c02
--- /dev/null
+++ b/dexcomparator/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/dexcomparator/.settings/org.eclipse.jdt.core.prefs b/dexcomparator/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..405f687c
--- /dev/null
+++ b/dexcomparator/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,425 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=javax.annotation.CheckForNull
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=ignore
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=warning
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=error
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=1585
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field.count_dependent=1585|-1|1585
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=1585
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable.count_dependent=1585|-1|1585
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=1585
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method.count_dependent=1585|-1|1585
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=1585
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package.count_dependent=1585|-1|1585
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=1040
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter.count_dependent=1040|-1|1040
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=1585
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type.count_dependent=1585|-1|1585
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression.count_dependent=16|5|80
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation.count_dependent=16|-1|16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant.count_dependent=16|-1|16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call.count_dependent=16|5|80
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation.count_dependent=16|5|80
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression.count_dependent=16|4|80
+org.eclipse.jdt.core.formatter.alignment_for_assignment=16
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression.count_dependent=16|-1|16
+org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_arguments=16
+org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_arguments.count_dependent=16|-1|16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants.count_dependent=16|5|48
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer.count_dependent=16|5|80
+org.eclipse.jdt.core.formatter.alignment_for_field_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_for_statement=16
+org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments=16
+org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments.count_dependent=16|-1|16
+org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields.count_dependent=16|-1|16
+org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class=20
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration.count_dependent=16|5|80
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration.count_dependent=16|5|80
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation.count_dependent=16|4|48
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration.count_dependent=16|4|49
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration.count_dependent=16|4|48
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration.count_dependent=16|4|48
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration.count_dependent=16|4|48
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=0
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=0
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=2
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=true
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
+org.eclipse.jdt.core.formatter.comment.line_length=100
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph=true
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.force_if_else_statement_brace=true
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comment_prefix=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=100
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=3
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false
+org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=2
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_comment_inline_tags=false
+org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation=true
+org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation=true
+org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation=true
+org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation=false
+org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
+org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments=false
diff --git a/dexcomparator/.settings/org.eclipse.jdt.ui.prefs b/dexcomparator/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000..d44207bd
--- /dev/null
+++ b/dexcomparator/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,63 @@
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_Jack Format 100
+formatter_settings_version=13
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=com.google;android;antenna;antlr;ar;asposewobfuscated;asquare;atg;au;beaver;bibtex;bmsi;bsh;ccl;cern;ChartDirector;checkers;com;COM;common;contribs;corejava;cryptix;cybervillains;dalvik;danbikel;de;EDU;eg;eu;examples;fat;fit;fitlibrary;fmpp;freemarker;gnu;groovy;groovyjarjarantlr;groovyjarjarasm;hak;hep;ie;imageinfo;info;it;jal;Jama;japa;japacheckers;jas;jasmin;javancss;javanet;javassist;javazoom;java_cup;jcifs;jetty;JFlex;jj2000;jline;jp;JSci;jsr166y;junit;jxl;jxxload_help;kawa;kea;libcore;libsvm;lti;memetic;mt;mx4j;net;netscape;nl;nu;oauth;ognl;opennlp;oracle;org;penn2dg;pennconverter;pl;prefuse;proguard;repackage;scm;se;serp;simple;soot;sqlj;src;ssa;sun;sunlabs;tcl;testdata;testshell;testsuite;twitter4j;uk;ViolinStrings;weka;wet;winstone;woolfel;wowza;;java;javax;
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.ondemandthreshold=999
+org.eclipse.jdt.ui.staticondemandthreshold=999
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n * Copyright (C) ${year} The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http\://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment"/><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=false
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=false
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=false
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=false
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=false
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=false
+sp_cleanup.remove_unused_private_types=false
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/dexcomparator/.settings/org.eclipse.ltk.core.refactoring.prefs b/dexcomparator/.settings/org.eclipse.ltk.core.refactoring.prefs
new file mode 100644
index 00000000..b196c64a
--- /dev/null
+++ b/dexcomparator/.settings/org.eclipse.ltk.core.refactoring.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
diff --git a/dexcomparator/Android.mk b/dexcomparator/Android.mk
new file mode 100644
index 00000000..651520f1
--- /dev/null
+++ b/dexcomparator/Android.mk
@@ -0,0 +1,21 @@
+#
+# Dex comparator
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_MODULE := dexcomparator
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_JAVA_LIBRARIES := \
+ dx-jack \
+ dexlib-jack \
+ jsr305lib-jack
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
diff --git a/dexcomparator/NOTICE b/dexcomparator/NOTICE
new file mode 100644
index 00000000..2bb9ad24
--- /dev/null
+++ b/dexcomparator/NOTICE
@@ -0,0 +1,176 @@
+ 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 \ No newline at end of file
diff --git a/dexcomparator/jackstyle.xml b/dexcomparator/jackstyle.xml
new file mode 100644
index 00000000..59286c82
--- /dev/null
+++ b/dexcomparator/jackstyle.xml
@@ -0,0 +1,295 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
+
+<!-- This is a checkstyle configuration file. For descriptions of
+what the following rules do, please see the checkstyle configuration
+page at http://checkstyle.sourceforge.net/config.html -->
+
+<!-- Checks with numbered comments refer to recommendations made
+by Joshua Bloch in his book Effective Java -->
+
+<module name="Checker">
+ <property name="charset" value="UTF-8"/>
+ <module name="FileTabCharacter">
+ <!-- Checks that there are no tab characters in the file.
+ -->
+ </module>
+
+ <module name="RegexpSingleline">
+ <!-- Checks that FIXME is not used in comments. TODO is preferred.
+ -->
+ <property name="format" value="((//.*)|(\*.*))FIXME" />
+ <property name="message" value='TODO is preferred to FIXME. e.g. "TODO(johndoe): Refactor when v2 is released."' />
+ </module>
+
+ <module name="RegexpSingleline">
+ <!-- Checks that TODOs are properly formatted.
+
+ The (?&lt;!TODO\(.{0,100}) makes the regex ignore any secondary TODO's on the line
+ so that things like //TODO(bob): remove this TODO on 1/1/2020 don't trigger a warning
+ because of the second TODO. (The {0,100} is because java doesn't recoginize arbitrary
+ length look backs, but we know each java line should be < 100 chars.)
+ -->
+ <property name="format" value="((//.*)|(\*.*))(?&lt;!TODO\(.{0,100})(TODO[^(])|(TODO\([^)]*$)" />
+ <property name="message" value='All TODOs should be named. e.g. "TODO(johndoe): Refactor when v2 is released."' />
+ </module>
+
+
+ <!-- All Java AST specific tests live under TreeWalker module. -->
+ <module name="TreeWalker">
+
+ <!--
+
+ IMPORT CHECKS
+
+ -->
+
+ <module name="RedundantImport">
+ <property name="severity" value="error"/>
+ </module>
+
+ <module name="AvoidStarImport">
+ <property name="severity" value="error"/>
+ </module>
+
+ <module name="UnusedImports">
+ <!-- DPL is a notable violator of this rule. -->
+ <property name="severity" value="error"/>
+ <!-- Imports used only in Javadoc are tolerated. -->
+ <property name="processJavadoc" value="true"/>
+ <message
+ key="import.unused"
+ value="Unused import: {0}." />
+ </module>
+
+ <module name="ImportOrder">
+ <!-- Checks for out of order import statements. -->
+ <property name="severity" value="warning"/>
+ <property name="groups" value="com.google,*,java,javax"/>
+ <!-- This ensures that static imports go first. -->
+ <property name="option" value="top"/>
+ <property name="tokens" value="STATIC_IMPORT, IMPORT"/>
+ </module>
+
+ <!--
+
+ NAMING CHECKS
+
+ -->
+
+ <!-- Item 38 - Adhere to generally accepted naming conventions -->
+
+ <module name="PackageName">
+ <!-- Validates identifiers for package names against the
+ supplied expression. -->
+ <!-- Here the default checkstyle rule restricts package name parts to
+ seven characters, this is not in line with common practice at Google.
+ -->
+ <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
+ <property name="severity" value="warning"/>
+ </module>
+
+ <module name="TypeNameCheck">
+ <metadata name="altname" value="TypeName"/>
+ <property name="severity" value="warning"/>
+ </module>
+
+ <module name="StaticVariableNameCheck">
+ <!-- Validates static, non-final fields against the supplied
+ expression "^[a-z][a-zA-Z0-9]*?$". -->
+ <metadata name="altname" value="StaticVariableName"/>
+ <property name="applyToPublic" value="true"/>
+ <property name="applyToProtected" value="true"/>
+ <property name="applyToPackage" value="true"/>
+ <property name="applyToPrivate" value="true"/>
+ <property name="format" value="^[a-z][a-zA-Z0-9]*?$"/>
+ <property name="severity" value="warning"/>
+ </module>
+
+ <module name="MemberNameCheck">
+ <!-- Validates non-static members against the supplied expression. -->
+ <metadata name="altname" value="MemberName"/>
+ <property name="applyToPublic" value="true"/>
+ <property name="applyToProtected" value="true"/>
+ <property name="applyToPackage" value="true"/>
+ <property name="applyToPrivate" value="true"/>
+ <property name="format" value="^[a-z][a-zA-Z0-9]*?$"/>
+ <property name="severity" value="warning"/>
+ </module>
+
+ <module name="MethodNameCheck">
+ <!-- Validates identifiers for method names. -->
+ <metadata name="altname" value="MethodName"/>
+ <property name="format" value="^[a-z][a-zA-Z0-9]*([a-zA-Z0-9]+)*$"/>
+ <property name="severity" value="warning"/>
+ </module>
+
+ <module name="ParameterName">
+ <!-- Validates identifiers for method parameters against the
+ expression "^[a-z][a-zA-Z0-9]*$". -->
+ <property name="severity" value="warning"/>
+ </module>
+
+ <module name="LocalFinalVariableName">
+ <!-- Validates identifiers for local final variables against the
+ expression "^[a-z][a-zA-Z0-9]*$". -->
+ <property name="severity" value="warning"/>
+ </module>
+
+ <module name="LocalVariableName">
+ <!-- Validates identifiers for local variables against the
+ expression "^[a-z][a-zA-Z0-9]*$". -->
+ <property name="severity" value="warning"/>
+ </module>
+
+
+ <!--
+
+ LENGTH and CODING CHECKS
+
+ -->
+
+ <module name="LineLength">
+ <!-- Checks if a line is too long. -->
+ <property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="100"/>
+ <property name="severity" value="error"/>
+
+ <!--
+ The default ignore pattern exempts the following elements:
+ - import statements
+ - long URLs inside comments
+ -->
+
+ <property name="ignorePattern"
+ value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
+ default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)|(\s*@[\w\.\$]+::\w+(?:\([^\(]*\)|\(\)\(\))?[,;]?)|(\s+\* \{@(link|see) [^\s][^\}]*\}[\.,;]?)$"/>
+ </module>
+
+ <module name="LeftCurly">
+ <!-- Checks for placement of the left curly brace ('{'). -->
+ <property name="severity" value="warning"/>
+ </module>
+
+ <module name="RightCurly">
+ <!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
+ the same line. e.g., the following example is fine:
+ <pre>
+ if {
+ ...
+ } else
+ </pre>
+ -->
+ <!-- This next example is not fine:
+ <pre>
+ if {
+ ...
+ }
+ else
+ </pre>
+ -->
+ <property name="option" value="same"/>
+ <property name="severity" value="warning"/>
+ </module>
+
+ <!-- Checks for braces around if and else blocks -->
+ <module name="NeedBraces">
+ <property name="severity" value="warning"/>
+ <property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
+ </module>
+
+ <module name="UpperEll">
+ <!-- Checks that long constants are defined with an upper ell.-->
+ <property name="severity" value="error"/>
+ </module>
+
+ <module name="FallThrough">
+ <!-- Warn about falling through to the next case statement. Similar to
+ javac -Xlint:fallthrough, but the check is suppressed if there is a single-line comment
+ on the last non-blank line preceding the fallen-into case.
+ -->
+ <property name="reliefPattern"
+ value=".*"/>
+ <property name="severity" value="error"/>
+ </module>
+
+
+ <!--
+
+ MODIFIERS CHECKS
+
+ -->
+
+ <module name="ModifierOrder">
+ <!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
+ 8.4.3. The prescribed order is:
+ public, protected, private, abstract, static, final, transient, volatile,
+ synchronized, native, strictfp
+ -->
+ </module>
+
+
+ <!--
+
+ WHITESPACE CHECKS
+
+ -->
+
+ <module name="WhitespaceAround">
+ <!-- Checks that various tokens are surrounded by whitespace.
+ This includes most binary operators and keywords followed
+ by regular or curly braces.
+ -->
+ <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
+ BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
+ EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
+ LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
+ LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
+ MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
+ SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
+ <property name="severity" value="error"/>
+ </module>
+
+ <module name="WhitespaceAfter">
+ <!-- Checks that commas, semicolons and typecasts are followed by
+ whitespace.
+ -->
+ <property name="tokens" value="COMMA, SEMI, TYPECAST"/>
+ </module>
+
+ <module name="NoWhitespaceAfter">
+ <!-- Checks that there is no whitespace after various unary operators.
+ Linebreaks are allowed.
+ -->
+ <property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
+ UNARY_PLUS"/>
+ <property name="allowLineBreaks" value="true"/>
+ <property name="severity" value="error"/>
+ </module>
+
+ <module name="NoWhitespaceBefore">
+ <!-- Checks that there is no whitespace before various unary operators.
+ Linebreaks are allowed.
+ -->
+ <property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
+ <property name="allowLineBreaks" value="true"/>
+ <property name="severity" value="error"/>
+ </module>
+
+ <module name="ParenPad">
+ <!-- Checks that there is no whitespace before close parens or after
+ open parens.
+ -->
+ <property name="severity" value="warning"/>
+ </module>
+
+ <!--
+
+ MISC CHECKS
+
+ -->
+
+ </module>
+</module>
+
diff --git a/dexcomparator/src/com/android/jack/DexAnnotationsComparator.java b/dexcomparator/src/com/android/jack/DexAnnotationsComparator.java
new file mode 100644
index 00000000..df7b2a7b
--- /dev/null
+++ b/dexcomparator/src/com/android/jack/DexAnnotationsComparator.java
@@ -0,0 +1,697 @@
+package com.android.jack;
+
+import com.android.jack.dx.rop.code.AccessFlags;
+
+import org.jf.dexlib.AnnotationDirectoryItem;
+import org.jf.dexlib.AnnotationDirectoryItem.MethodAnnotation;
+import org.jf.dexlib.AnnotationItem;
+import org.jf.dexlib.AnnotationSetItem;
+import org.jf.dexlib.AnnotationSetRefList;
+import org.jf.dexlib.ClassDataItem;
+import org.jf.dexlib.ClassDataItem.EncodedField;
+import org.jf.dexlib.ClassDataItem.EncodedMethod;
+import org.jf.dexlib.ClassDefItem;
+import org.jf.dexlib.DexFile;
+import org.jf.dexlib.FieldIdItem;
+import org.jf.dexlib.ItemType;
+import org.jf.dexlib.MethodIdItem;
+import org.jf.dexlib.ProtoIdItem;
+import org.jf.dexlib.Section;
+import org.jf.dexlib.StringIdItem;
+import org.jf.dexlib.TypeIdItem;
+import org.jf.dexlib.TypeListItem;
+import org.jf.dexlib.EncodedValue.AnnotationEncodedSubValue;
+import org.jf.dexlib.EncodedValue.ArrayEncodedSubValue;
+import org.jf.dexlib.EncodedValue.ArrayEncodedValue;
+import org.jf.dexlib.EncodedValue.EncodedValue;
+import org.jf.dexlib.EncodedValue.EnumEncodedValue;
+import org.jf.dexlib.EncodedValue.IntEncodedValue;
+import org.jf.dexlib.EncodedValue.MethodEncodedValue;
+import org.jf.dexlib.EncodedValue.StringEncodedValue;
+import org.jf.dexlib.EncodedValue.TypeEncodedValue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+/**
+ * This tool compares 2 dex files. The candidate is compared to the reference dex file, and MUST
+ * have at least all the features present in the reference. (Class, super class, fields, methods)
+ */
+public class DexAnnotationsComparator {
+
+ @Nonnull
+ private static final String MEMBER_CLASSES_DESCRIPTOR = "Ldalvik/annotation/MemberClasses;";
+ @Nonnull
+ private final Logger logger;
+ @Nonnull
+ private final DexFile referenceDexFile;
+ @Nonnull
+ private final DexFile candidateDexFile;
+ @Nonnull
+ private static final Level ERROR_LEVEL = Level.SEVERE;
+ @Nonnull
+ private static final Level DEBUG_LEVEL = Level.FINE;
+
+ private static final boolean IGNORE_ANONYMOUS_CLASSES = true;
+ private static final boolean TOLERATE_MISSING_SYNTHETICS = true;
+ private static final boolean TOLERATE_MISSING_INITS = true;
+ private static final boolean TOLERATE_MISSING_CLINITS = true;
+
+ public DexAnnotationsComparator(
+ @Nonnull File referenceFile, @Nonnull File candidateFile) throws IOException {
+ logger = Logger.getLogger(this.getClass().getName());
+ logger.setLevel(ERROR_LEVEL);
+
+ referenceDexFile = new DexFile(referenceFile);
+ candidateDexFile = new DexFile(candidateFile);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void compare() throws DifferenceFoundException {
+
+ /* Reuse delegate instance for maximum memory saving */
+ CompareElementAnnotation compareElementAnnotation =
+ new CompareElementAnnotation(logger);
+
+ /* build a lookup table for candidate classes */
+ HashMap<String, ClassDefItem> candidateClassDefItemLookUpTable =
+ new HashMap<String, ClassDefItem>();
+ Section<ClassDefItem> candidateClassDefSection =
+ candidateDexFile.getSectionForType(ItemType.TYPE_CLASS_DEF_ITEM);
+ for (ClassDefItem classDefItem : candidateClassDefSection.getItems()) {
+ candidateClassDefItemLookUpTable.put(
+ classDefItem.getClassType().getTypeDescriptor(), classDefItem);
+ }
+
+ Section<ClassDefItem> classDefSection =
+ referenceDexFile.getSectionForType(ItemType.TYPE_CLASS_DEF_ITEM);
+
+ for (ClassDefItem classDefItem : classDefSection.getItems()) {
+
+ ClassDefItem candidateClassDefItem =
+ candidateClassDefItemLookUpTable.get(classDefItem.getClassType().getTypeDescriptor());
+ String className = classDefItem.getClassType().getTypeDescriptor();
+
+ if (!IGNORE_ANONYMOUS_CLASSES || !isAnonymousTypeName(className)) {
+
+ /* class */
+ if (candidateClassDefItem != null) {
+
+ logger.log(DEBUG_LEVEL, "Class {0} OK", className);
+ int accessFlags = classDefItem.getAccessFlags();
+ boolean synthetic = isSynthetic(accessFlags);
+
+ if (synthetic && TOLERATE_MISSING_SYNTHETICS) {
+ continue;
+ }
+
+ /* check ClassData field */
+ ClassDataItem classDataItem = classDefItem.getClassData();
+ ClassDataItem candidateClassDataItem = candidateClassDefItem.getClassData();
+
+ if (classDataItem == null && candidateClassDataItem == null) {
+ logger.log(DEBUG_LEVEL, "ClassData of {0} OK: both are null", className);
+ } else if (classDataItem == null || candidateClassDataItem == null) {
+ String errorString =
+ ((classDataItem == null) ? ("reference's is null and not candidate's")
+ : ("candidate's is null and not reference's"));
+ throw new DifferenceFoundException(
+ "ClassDatas of '" + className + "' do not match: " + errorString);
+ } else {
+ /* Annotation pre check */
+ boolean doCheckAnnotations = false;
+ AnnotationDirectoryItem annotationDirectoryItem = classDefItem.getAnnotations();
+ AnnotationDirectoryItem candidateAnnotationDirectoryItem =
+ candidateClassDefItem.getAnnotations();
+
+ if (annotationDirectoryItem == null && candidateAnnotationDirectoryItem == null) {
+ logger.log(DEBUG_LEVEL, "AnnotationDirectoryItem of {0} OK: both are null", className);
+ } else if (annotationDirectoryItem == null || candidateAnnotationDirectoryItem == null) {
+ String errorString =
+ ((annotationDirectoryItem == null) ? ("reference's is null and not candidate's")
+ : ("candidate's is null and not reference's"));
+
+ logger.log(ERROR_LEVEL, "AnnotationDirectoryItem of {0} NOK: {1}",
+ new Object[] {className, errorString});
+
+ if (annotationDirectoryItem != null) {
+ boolean containsOnlyAnnotationsOnSyntheticMethods = true;
+ for (MethodAnnotation anno : annotationDirectoryItem.getMethodAnnotations()) {
+ containsOnlyAnnotationsOnSyntheticMethods =
+ containsOnlyAnnotationsOnSyntheticMethods
+ && isSynthetic(getMethodAccessFlags(classDataItem, anno.method));
+
+ }
+
+ if (containsOnlyAnnotationsOnSyntheticMethods) {
+ continue;
+ }
+ }
+
+ throw new DifferenceFoundException(
+ "AnnotationDirectoryItems of '" + className + "' do not match: " + errorString);
+ } else {
+ logger.log(DEBUG_LEVEL, "AnnotationDirectoryItem of {0}: not null", className);
+ doCheckAnnotations = true;
+ }
+
+ /* Class Annotations */
+ {
+ if (doCheckAnnotations) {
+ checkClassAnnotations(annotationDirectoryItem, candidateAnnotationDirectoryItem,
+ compareElementAnnotation, className);
+ }
+ } /* class annotation */
+
+ /* Field Annotations */
+ {
+ if (doCheckAnnotations) {
+ compareElementAnnotation.reset();
+ compareElementAnnotation.isCandidate = true;
+ assert candidateAnnotationDirectoryItem != null;
+ processFields(compareElementAnnotation, candidateAnnotationDirectoryItem,
+ candidateClassDataItem.getStaticFields());
+ processFields(compareElementAnnotation, candidateAnnotationDirectoryItem,
+ candidateClassDataItem.getInstanceFields());
+ compareElementAnnotation.isCandidate = false;
+ assert annotationDirectoryItem != null;
+ processFields(compareElementAnnotation, annotationDirectoryItem,
+ classDataItem.getStaticFields());
+ processFields(compareElementAnnotation, annotationDirectoryItem,
+ classDataItem.getInstanceFields());
+ }
+ }
+
+ /* Method and parameter Annotations */
+ {
+ if (doCheckAnnotations) {
+ compareElementAnnotation.reset();
+ compareElementAnnotation.isCandidate = true;
+ assert candidateAnnotationDirectoryItem != null;
+ processMethods(compareElementAnnotation, candidateAnnotationDirectoryItem,
+ candidateClassDataItem.getDirectMethods());
+ processMethods(compareElementAnnotation, candidateAnnotationDirectoryItem,
+ candidateClassDataItem.getVirtualMethods());
+ compareElementAnnotation.isCandidate = false;
+ assert annotationDirectoryItem != null;
+ compareElementAnnotation.classData = classDataItem;
+ processMethods(compareElementAnnotation, annotationDirectoryItem,
+ classDataItem.getDirectMethods());
+ processMethods(compareElementAnnotation, annotationDirectoryItem,
+ classDataItem.getVirtualMethods());
+ }
+ }
+ } /* check ClassData field */
+
+ classDataItem = null;
+ candidateClassDataItem = null;
+ } else /* Class */ {
+ logger.log(ERROR_LEVEL, "Class {0} NOK: missing", className);
+
+ if (!TOLERATE_MISSING_SYNTHETICS || !isSynthetic(classDefItem.getAccessFlags())) {
+ throw new DifferenceFoundException("Class " + className + " was not found in candidate.");
+ }
+ }
+ }
+ } /* for each class */
+
+ }
+
+ private void processMethods(@Nonnull CompareElementAnnotation compareElementAnnotation,
+ @Nonnull AnnotationDirectoryItem annotationDirectoryItem,
+ @Nonnull List<EncodedMethod> methods) {
+ for (EncodedMethod method : methods) {
+ AnnotationSetItem methodAnnotations =
+ annotationDirectoryItem.getMethodAnnotations(method.method);
+ if (methodAnnotations != null) {
+ compareElementAnnotation.processMethodAnnotations(method.method, methodAnnotations);
+ }
+ AnnotationSetRefList parameterAnnotations =
+ annotationDirectoryItem.getParameterAnnotations(method.method);
+ if (parameterAnnotations != null) {
+ compareElementAnnotation.processParameterAnnotations(method.method, parameterAnnotations);
+ }
+ }
+ }
+
+ private void processFields(@Nonnull CompareElementAnnotation compareElementAnnotation,
+ @Nonnull AnnotationDirectoryItem annotationDirectoryItem,
+ @Nonnull List<EncodedField> fields) {
+ for (EncodedField field : fields) {
+ AnnotationSetItem fieldAnnotations = annotationDirectoryItem.getFieldAnnotations(field.field);
+ if (fieldAnnotations != null) {
+ compareElementAnnotation.processFieldAnnotations(field.field, fieldAnnotations);
+ }
+ }
+ }
+
+ private void checkClassAnnotations(AnnotationDirectoryItem annotationDirectoryItem,
+ AnnotationDirectoryItem candidateAnnotationDirectoryItem,
+ CompareElementAnnotation compareElementAnnotationDelegate, String className)
+ throws DifferenceFoundException {
+ assert annotationDirectoryItem != null;
+ assert candidateAnnotationDirectoryItem != null;
+ AnnotationSetItem classAnnotations = annotationDirectoryItem.getClassAnnotations();
+ AnnotationSetItem candidateClassAnnotations =
+ candidateAnnotationDirectoryItem.getClassAnnotations();
+
+ if (classAnnotations == null && candidateClassAnnotations == null) {
+ logger.log(DEBUG_LEVEL, "ClassAnnotations of {0} OK: both are null", className);
+ } else if (classAnnotations == null || candidateClassAnnotations == null) {
+ String errorString =
+ ((classAnnotations == null) ? ("reference's is null and not candidate's")
+ : ("candidate's is null and not reference's"));
+
+ logger.log(ERROR_LEVEL, "ClassAnnotations of {0} NOK: {1}",
+ new Object[] {className, errorString});
+
+ boolean onlyAnonymousMemberClassesAnnot = true;
+ if (classAnnotations != null) {
+ AnnotationItem[] annots = classAnnotations.getAnnotations();
+ for (AnnotationItem annot : annots) {
+ TypeIdItem type = annot.getEncodedAnnotation().annotationType;
+ boolean isMemberClassesAnnot =
+ type.getTypeDescriptor().equals(MEMBER_CLASSES_DESCRIPTOR);
+ if (isMemberClassesAnnot) {
+ onlyAnonymousMemberClassesAnnot &=
+ checkMemberClassesAnnotationOnlyHasAnonymousOrSynthetics(
+ annot.getEncodedAnnotation());
+ } else {
+ onlyAnonymousMemberClassesAnnot = false;
+ }
+ if (!onlyAnonymousMemberClassesAnnot) {
+ break;
+ }
+ }
+ }
+
+ if (!onlyAnonymousMemberClassesAnnot) {
+ throw new DifferenceFoundException(
+ "ClassAnnotations of '" + className + "' do not match: " + errorString);
+ } else {
+ return;
+ }
+ } else {
+ compareElementAnnotationDelegate.reset();
+ compareElementAnnotationDelegate.isCandidate = true;
+ compareElementAnnotationDelegate.processGeneric(
+ "class " + className,
+ candidateClassAnnotations);
+ compareElementAnnotationDelegate.isCandidate = false;
+ compareElementAnnotationDelegate.processGeneric(
+ "class " + className, classAnnotations);
+ }
+ }
+
+ private static boolean checkMemberClassesAnnotationOnlyHasAnonymousOrSynthetics(
+ AnnotationEncodedSubValue encodedAnnotation) {
+ boolean result = true;
+ for (EncodedValue value : encodedAnnotation.values) {
+ for (EncodedValue subvalue : ((ArrayEncodedValue) value).values) {
+ TypeIdItem typeId = ((TypeEncodedValue) subvalue).value;
+ result &= isAnonymousTypeName(typeId.getTypeDescriptor());
+ if (!result) {
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Compares annotations for each element (field method) in reference. Please re use instance for
+ * performance's sake (call reset() beforehand)
+ *
+ */
+ private static class CompareElementAnnotation {
+
+ public boolean isCandidate = false;
+ @CheckForNull
+ public ClassDataItem classData = null;
+
+ @Nonnull
+ private final HashMap<String, AnnotationSetItem> candidateElementAnnotations =
+ new HashMap<String, AnnotationSetItem>();
+
+ @Nonnull
+ private final Logger logger;
+
+ public CompareElementAnnotation(Logger logger) {
+ this.logger = logger;
+ }
+
+ public void processGeneric(@Nonnull String elementString,
+ @Nonnull AnnotationSetItem annotations) throws DifferenceFoundException {
+
+ if (isCandidate) {
+ /* fill lookup table */
+ candidateElementAnnotations.put(elementString, annotations);
+ } else {
+
+ /* reference : compare against lookup table */
+ AnnotationSetItem candidateAnnotationsForField =
+ candidateElementAnnotations.get(elementString);
+ AnnotationItem[] candidatesAnnots =
+ (candidateAnnotationsForField != null) ? (candidateAnnotationsForField.getAnnotations())
+ : (new AnnotationItem[] {});
+ AnnotationItem[] refAnnots = annotations.getAnnotations();
+
+ for (int i = 0; i < refAnnots.length; i++) {
+ //for (AnnotationItem annot : refAnnots) {
+ AnnotationItem annot = refAnnots[i];
+
+ // if the annotation is a MemberClass annotation that only contains anonymous classes,
+ // it may not be in our candidate so we ignore it
+ boolean isMemberClassAnnotation = annot
+ .getEncodedAnnotation().annotationType.getTypeDescriptor()
+ .equals(MEMBER_CLASSES_DESCRIPTOR);
+ if (IGNORE_ANONYMOUS_CLASSES && isMemberClassAnnotation) {
+ if (checkMemberClassesAnnotationOnlyHasAnonymousOrSynthetics(annot
+ .getEncodedAnnotation())) {
+ continue;
+ }
+ }
+ boolean isAnnotFound = false;
+ for (AnnotationItem candidateAnnot : candidatesAnnots) {
+ /* found the same annotation for this element? (based on its type) */
+ if (compareTypeIds(annot.getEncodedAnnotation().annotationType,
+ candidateAnnot.getEncodedAnnotation().annotationType)) {
+ checkEncodedAnnotations(annot.getEncodedAnnotation(),
+ candidateAnnot.getEncodedAnnotation(), elementString);
+ isAnnotFound = true;
+ break;
+ }
+ }
+
+ if (!isAnnotFound) {
+ if ((!TOLERATE_MISSING_INITS || !elementString.contains("<init>")) &&
+ (!TOLERATE_MISSING_CLINITS || !elementString.contains("<clinit>"))) {
+ throw new DifferenceFoundException("NOK: for " + elementString
+ + ": Could not find annotation "
+ + annot.getEncodedAnnotation().annotationType.getTypeDescriptor()
+ + " in candidate.");
+ }
+ }
+ }
+ }
+ }
+
+ private boolean compareValues(EncodedValue encodedValue, EncodedValue candEncodedValue,
+ String elementString, String type, String name) throws DifferenceFoundException {
+ boolean isEqual = false;
+ if (encodedValue.getValueType().value == candEncodedValue.getValueType().value) {
+ if (encodedValue instanceof StringEncodedValue) {
+ isEqual = ((StringEncodedValue) encodedValue).value.getStringValue()
+ .equals(((StringEncodedValue) candEncodedValue).value.getStringValue());
+ } else if (encodedValue instanceof TypeEncodedValue) {
+ isEqual = compareTypeIds(
+ ((TypeEncodedValue) encodedValue).value, ((TypeEncodedValue) candEncodedValue).value);
+ } else if (encodedValue instanceof EnumEncodedValue) {
+ isEqual = compareFieldIds(
+ ((EnumEncodedValue) encodedValue).value, ((EnumEncodedValue) candEncodedValue).value);
+ } else if (encodedValue instanceof MethodEncodedValue) {
+ isEqual = compareMethodIds(((MethodEncodedValue) encodedValue).value,
+ ((MethodEncodedValue) candEncodedValue).value);
+ } else if (encodedValue instanceof AnnotationEncodedSubValue) {
+ AnnotationEncodedSubValue encodedAnnotation =
+ (AnnotationEncodedSubValue) encodedValue;
+ AnnotationEncodedSubValue candEncodedAnnotation =
+ (AnnotationEncodedSubValue) candEncodedValue;
+ boolean sameAnnotationType = compareTypeIds(
+ encodedAnnotation.annotationType, candEncodedAnnotation.annotationType);
+ if (sameAnnotationType) {
+ checkEncodedAnnotations(encodedAnnotation, candEncodedAnnotation, elementString);
+ isEqual = true;
+ } else {
+ throw new AssertionError("sub annotation types do not match");
+ }
+ } else if (encodedValue instanceof ArrayEncodedSubValue) {
+ ArrayEncodedSubValue arrayEncodedValue = (ArrayEncodedSubValue) encodedValue;
+ ArrayEncodedSubValue candArrayEncodedValue = (ArrayEncodedSubValue) candEncodedValue;
+ isEqual = true;
+ boolean isMemberClass = type.equals(MEMBER_CLASSES_DESCRIPTOR);
+
+ List<EncodedValue> refEncodedValues = Arrays.asList(arrayEncodedValue.values);
+ List<EncodedValue> candEncodedValues = Arrays.asList(candArrayEncodedValue.values);
+ Collections.sort(refEncodedValues);
+ Collections.sort(candEncodedValues);
+ Iterator<EncodedValue> refEncodedValuesIterator = refEncodedValues.iterator();
+ Iterator<EncodedValue> candEncodedValuesIterator = candEncodedValues.iterator();
+
+ while (refEncodedValuesIterator.hasNext()) {
+ if (!candEncodedValuesIterator.hasNext()) {
+ isEqual = false;
+ break;
+ }
+ EncodedValue refValue = refEncodedValuesIterator.next();
+
+ // our reference may have synthetic anonymous classes that we should ignore
+ if (isMemberClass) {
+ TypeEncodedValue typeRefValue = (TypeEncodedValue) refValue;
+ if (isAnonymousTypeName(typeRefValue.value.getTypeDescriptor())) {
+ continue;
+ }
+ }
+
+ EncodedValue candValue = candEncodedValuesIterator.next();
+ isEqual = compareValues(refValue, candValue, elementString, type, name);
+ if (!isEqual) {
+ break;
+ }
+ }
+ if (candEncodedValuesIterator.hasNext()) {
+ isEqual = false;
+ }
+ } else {
+ isEqual = encodedValue.compareTo(candEncodedValue) == 0;
+ }
+
+ if (!isEqual) {
+ // print access flags of InnerClass annotations
+ if (type.equals("Ldalvik/annotation/InnerClass;") && name.equals("accessFlags")) {
+ int flags = ((IntEncodedValue) encodedValue).value;
+ int candFlags = ((IntEncodedValue) candEncodedValue).value;
+ logger.log(DEBUG_LEVEL, "Difference in access flags of InnerClass annotations of "
+ + elementString + ": ref=0x" + Integer.toHexString(flags) + " - cand=0x"
+ + Integer.toHexString(candFlags));
+ }
+
+ throw new DifferenceFoundException("NOK: for " + elementString + ":annotation "
+ + type
+ + ", name = " + name
+ + " is present but values differ");
+ }
+ } else {
+ throw new DifferenceFoundException("NOK: for " + elementString + ":annotation "
+ + type
+ + ", name = " + name
+ + ", encoded values have different types");
+ }
+ return isEqual;
+ }
+
+ private boolean compareMethodIds(MethodIdItem value, MethodIdItem value2) {
+ boolean isEqual = compareTypeIds(value.getContainingClass(), value2.getContainingClass());
+ isEqual &= compareProtoIds(value.getPrototype(), value2.getPrototype());
+ isEqual &=
+ value.getMethodName().getStringValue().equals(value2.getMethodName().getStringValue());
+ return isEqual;
+ }
+
+ private boolean compareProtoIds(ProtoIdItem value, ProtoIdItem value2) {
+ boolean isEqual = false;
+ if (value == null && value2 == null) {
+ isEqual = true;
+ } else if (value != null && value2 != null) {
+ if (compareTypeIds(value.getReturnType(), value2.getReturnType())) {
+ TypeListItem tyleList = value.getParameters();
+ TypeListItem tyleList2 = value2.getParameters();
+ if (tyleList == null && tyleList2 == null) {
+ isEqual = true;
+ } else if (tyleList != null && tyleList2 != null) {
+ if (tyleList.getTypeCount() == tyleList2.getTypeCount()) {
+ Iterator<TypeIdItem> tyleListIter = tyleList.getTypes().iterator();
+ Iterator<TypeIdItem> tyleListIter2 = tyleList2.getTypes().iterator();
+ isEqual = true;
+ while (isEqual && tyleListIter.hasNext()) {
+ isEqual &= compareTypeIds(tyleListIter.next(), tyleListIter2.next());
+ }
+ }
+ }
+ }
+ }
+ return isEqual;
+ }
+
+ private boolean compareFieldIds(FieldIdItem value, FieldIdItem value2) {
+ boolean isEqual = compareTypeIds(value.getContainingClass(), value2.getContainingClass());
+ isEqual &= compareTypeIds(value.getFieldType(), value2.getFieldType());
+ isEqual &=
+ value.getFieldName().getStringValue().equals(value2.getFieldName().getStringValue());
+ return isEqual;
+ }
+
+ private boolean compareTypeIds(TypeIdItem annotationType, TypeIdItem annotationType2) {
+ return annotationType.getTypeDescriptor().equals(annotationType2.getTypeDescriptor());
+ }
+
+ private void checkEncodedAnnotations(AnnotationEncodedSubValue encodedAnnotation,
+ AnnotationEncodedSubValue encodedAnnotation2, String elementString)
+ throws DifferenceFoundException {
+ assert compareTypeIds(encodedAnnotation.annotationType, encodedAnnotation2.annotationType);
+
+ /* check every name and values for this annotation */
+ for (int i = 0; i < encodedAnnotation.names.length; i++) {
+ StringIdItem name = encodedAnnotation.names[i];
+ boolean isAnnotNameFound = false;
+ for (int j = 0; !isAnnotNameFound && j < encodedAnnotation2.names.length; j++) {
+ StringIdItem candidateName = encodedAnnotation2.names[j];
+ if (name.getStringValue().equals(candidateName.getStringValue())) {
+ EncodedValue subSubValue = encodedAnnotation.values[i];
+ EncodedValue candSubSubValue = encodedAnnotation2.values[j];
+ boolean isEqual = compareValues(subSubValue, candSubSubValue, elementString,
+ encodedAnnotation.annotationType.getTypeDescriptor(), name.getStringValue());
+ if (!isEqual) {
+ throw new DifferenceFoundException("NOK: for " + elementString + ":annotation "
+ + encodedAnnotation.annotationType.getTypeDescriptor()
+ + ", value type differs : reference = "
+ + encodedAnnotation.getValueType().toString() + ", candidate = "
+ + encodedAnnotation2.getValueType().toString());
+ }
+ isAnnotNameFound = true;
+ break; // We found the right name, stop searching
+ }
+ }
+
+ if (!isAnnotNameFound) {
+ throw new DifferenceFoundException("NOK: for " + elementString + ": Could not find name "
+ + name.getStringValue() + " for annotation "
+ + encodedAnnotation.annotationType.getTypeDescriptor() + " in candidate.");
+ }
+ }
+ }
+
+ public void processFieldAnnotations(FieldIdItem field, AnnotationSetItem fieldAnnotations) {
+ try {
+ processGeneric("field " + field.getFieldString(), fieldAnnotations);
+ } catch (DifferenceFoundException e) {
+ //TODO
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void processMethodAnnotations(MethodIdItem method, AnnotationSetItem annotations) {
+ try {
+ String elementString = "method " + method.getMethodString();
+
+ if (isCandidate) {
+ /* fill lookup table */
+ candidateElementAnnotations.put(elementString, annotations);
+ } else {
+ assert classData != null;
+ boolean synthetic = isSynthetic(getMethodAccessFlags(classData, method));
+
+ /* reference : compare against lookup table */
+ AnnotationSetItem candidateAnnotationsForField =
+ candidateElementAnnotations.get(elementString);
+ AnnotationItem[] candidatesAnnots =
+ (candidateAnnotationsForField != null) ? (candidateAnnotationsForField
+ .getAnnotations())
+ : (new AnnotationItem[] {});
+ AnnotationItem[] refAnnots = annotations.getAnnotations();
+
+ for (AnnotationItem annot : refAnnots) {
+ boolean isAnnotFound = false;
+ for (AnnotationItem candidateAnnot : candidatesAnnots) {
+ /* found the same annotation for this element? (based on its type) */
+ if (compareTypeIds(annot.getEncodedAnnotation().annotationType,
+ candidateAnnot.getEncodedAnnotation().annotationType)) {
+ checkEncodedAnnotations(annot.getEncodedAnnotation(),
+ candidateAnnot.getEncodedAnnotation(), elementString);
+ isAnnotFound = true;
+ break;
+ }
+ }
+
+ //TODO
+ if (!isAnnotFound) {
+ if ((!TOLERATE_MISSING_SYNTHETICS || !synthetic) &&
+ (!TOLERATE_MISSING_INITS || !elementString.contains("<init>")) &&
+ (!TOLERATE_MISSING_CLINITS || !elementString.contains("<clinit>"))) {
+ throw new DifferenceFoundException("NOK: for " + elementString
+ + ": Could not find annotation "
+ + annot.getEncodedAnnotation().annotationType.getTypeDescriptor()
+ + " in candidate.");
+ }
+ }
+ }
+ }
+ } catch (DifferenceFoundException e) {
+ //TODO
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void processParameterAnnotations(
+ MethodIdItem method, AnnotationSetRefList parameterAnnotations) {
+ int cptParam = 0;
+ for (AnnotationSetItem asi : parameterAnnotations.getAnnotationSets()) {
+ try {
+ processGeneric("param " + cptParam + " " + method.getMethodString(), asi);
+ } catch (DifferenceFoundException e) {
+ // TODO
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public void reset() {
+ isCandidate = false;
+ candidateElementAnnotations.clear();
+ }
+ }
+
+ private static boolean isAnonymousTypeName(String typeName) {
+ //TODO(benoitlamarche): use Annotations to determine if the class is anonymous
+ int location = typeName.lastIndexOf('$');
+ if (location != -1) {
+ String num = typeName.substring(location + 1, typeName.length() - 1);
+ try {
+ Integer.parseInt(num);
+ return true;
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ private static boolean isSynthetic(int modifier) {
+ return ((modifier & AccessFlags.ACC_SYNTHETIC) == AccessFlags.ACC_SYNTHETIC);
+ }
+
+ private static int getMethodAccessFlags(ClassDataItem classData, MethodIdItem methodId) {
+ for (EncodedMethod encodedMethod : classData.getDirectMethods()) {
+ if (encodedMethod.method == methodId) {
+ return encodedMethod.accessFlags;
+ }
+ }
+ for (EncodedMethod encodedMethod : classData.getVirtualMethods()) {
+ if (encodedMethod.method == methodId) {
+ return encodedMethod.accessFlags;
+ }
+ }
+ return -1;
+ }
+} \ No newline at end of file
diff --git a/dexcomparator/src/com/android/jack/DexComparator.java b/dexcomparator/src/com/android/jack/DexComparator.java
new file mode 100644
index 00000000..89ab8cd9
--- /dev/null
+++ b/dexcomparator/src/com/android/jack/DexComparator.java
@@ -0,0 +1,930 @@
+/*
+ * Copyright (C) 2012 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.jack;
+
+import com.android.jack.comparator.DebugInfo;
+import com.android.jack.comparator.DebugInfo.LocalVar;
+import com.android.jack.dx.dex.file.DebugInfoDecoder;
+import com.android.jack.dx.io.ClassData;
+import com.android.jack.dx.io.ClassData.Method;
+import com.android.jack.dx.io.ClassDef;
+import com.android.jack.dx.io.Code;
+import com.android.jack.dx.io.DexBuffer;
+import com.android.jack.dx.io.FieldId;
+import com.android.jack.dx.io.MethodId;
+import com.android.jack.dx.io.ProtoId;
+import com.android.jack.dx.rop.code.AccessFlags;
+import com.android.jack.dx.rop.type.Prototype;
+import com.android.jack.dx.util.ByteInput;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.annotation.Nonnull;
+
+/**
+ * This tool compares the structure of two dex files.
+ */
+public class DexComparator {
+
+ private Logger logger;
+ private DexBuffer referenceDexFile;
+ private DexBuffer candidateDexFile;
+ private static final Level ERROR_LEVEL = Level.SEVERE;
+ private static final Level WARNING_LEVEL = Level.WARNING;
+ private static final Level DEBUG_LEVEL = Level.FINE;
+ private boolean strict;
+ private boolean debugInfo;
+ private byte[] referenceData;
+ private byte[] candidateData;
+ private int refThisIndex;
+ private int candidateThisIndex;
+ private static final boolean IGNORE_ID_COMPARISON = true;
+ private static final boolean IGNORE_ANONYMOUS_CLASSES = true;
+ private static final boolean TOLERATE_MISSING_SYNTHETICS = true;
+ private static final boolean TOLERATE_MISSING_INITS = true;
+ private static final boolean TOLERATE_MISSING_CLINITS = true;
+ private boolean enableBinaryDebugInfoComparison = false;
+ private boolean enableInstructionNumberComparison = false;
+ private float instructionNumberTolerance = 0f;
+
+ private static final List<String> skippedMethods = new ArrayList<String>();
+
+ static {
+ skippedMethods.add("Ljava/lang/Throwable;."
+ + "countDuplicates([Ljava/lang/StackTraceElement;[Ljava/lang/StackTraceElement;)I");
+ }
+
+ @Nonnull
+ private static final String INIT_NAME = "<init>";
+ @Nonnull
+ private static final String STATIC_INIT_NAME = "<clinit>";
+
+ /**
+ * Launch the comparison between a reference Dex {@code File} and a candidate Dex {@code File}.
+ *
+ * @param referenceFile the reference Dex {@code File}
+ * @param candidateFile the candidate Dex {@code File}
+ * @param withDebugInfo also compare debug infos
+ * @param strict if false, the candidate Dex must <i>at least<i/> contain all the structures of
+ * the reference Dex; if true, the candidate Dex must <i>exactly<i/> contain all the
+ * structures of the reference Dex
+ * @param compareDebugInfoBinary enable binary comparison of debug infos
+ * @param compareInstructionNumber enable comparison of number of instructions
+ * @param instructionNumberTolerance tolerance factor for comparison of number of instructions
+ * @throws DifferenceFoundException if a difference between the two Dex files is found
+ * @throws IOException if an error occurs while loading the dex files
+ */
+ public void compare(File referenceFile,
+ File candidateFile,
+ boolean withDebugInfo,
+ boolean strict,
+ boolean compareDebugInfoBinary,
+ boolean compareInstructionNumber,
+ float instructionNumberTolerance) throws DifferenceFoundException, IOException {
+
+ logger = Logger.getLogger(this.getClass().getName());
+ logger.setLevel(WARNING_LEVEL);
+
+ referenceDexFile = new DexBuffer(referenceFile);
+ referenceData = referenceDexFile.getBytes();
+ refThisIndex = referenceDexFile.strings().indexOf("this");
+ candidateDexFile = new DexBuffer(candidateFile);
+ candidateData = candidateDexFile.getBytes();
+ candidateThisIndex = candidateDexFile.strings().indexOf("this");
+ this.strict = strict;
+ enableBinaryDebugInfoComparison = compareDebugInfoBinary;
+ enableInstructionNumberComparison = compareInstructionNumber;
+ this.instructionNumberTolerance = instructionNumberTolerance;
+ debugInfo = withDebugInfo;
+
+ if (!IGNORE_ID_COMPARISON) {
+ checkStringIds();
+ checkTypeIds();
+ checkProtoIds();
+ checkFieldIds();
+ checkMethodIds();
+ }
+
+ /* build a lookup table for candidate classes */
+ HashMap<String, ClassDef> candidateClassDefItemLookUpTable = new HashMap<String, ClassDef>();
+ for (ClassDef classDef : candidateDexFile.classDefs()) {
+ String typeName = candidateDexFile.typeNames().get(classDef.getTypeIndex());
+ candidateClassDefItemLookUpTable.put(typeName, classDef);
+ }
+
+ Iterable<ClassDef> refClassDefs = referenceDexFile.classDefs();
+
+ for (ClassDef classDefItem : refClassDefs) {
+
+ if (!IGNORE_ANONYMOUS_CLASSES
+ || !isAnomymousTypeName(referenceDexFile.typeNames().get(classDefItem.getTypeIndex()))) {
+
+ String className = getClassName(referenceDexFile, classDefItem);
+
+ ClassDef candidateClassDefItem =
+ candidateClassDefItemLookUpTable.get(className);
+
+ /* class */
+ if (candidateClassDefItem != null) {
+ logger.log(DEBUG_LEVEL, "Class {0} OK", className);
+
+ checkAccessFlags(classDefItem, candidateClassDefItem);
+ checkSuperclass(classDefItem, candidateClassDefItem);
+ checkInterfaces(classDefItem, candidateClassDefItem);
+ checkClassData(classDefItem, candidateClassDefItem);
+
+ candidateClassDefItemLookUpTable.remove(className);
+
+ } else {
+ logger.log(
+ ERROR_LEVEL, "Class {0} NOK: missing", getClassName(referenceDexFile, classDefItem));
+
+ if (!TOLERATE_MISSING_SYNTHETICS || !isSynthetic(classDefItem.getAccessFlags())) {
+ throw new DifferenceFoundException("Class "
+ + getClassName(referenceDexFile, classDefItem) + " was not found in candidate.");
+ }
+ }
+ }
+ }
+ if (strict) {
+ for (ClassDef classDefItem : candidateClassDefItemLookUpTable.values()) {
+ if (!IGNORE_ANONYMOUS_CLASSES || !isAnomymousTypeName(
+ candidateDexFile.typeNames().get(classDefItem.getTypeIndex()))) {
+ String className = getClassName(candidateDexFile, classDefItem);
+ logger.log(
+ ERROR_LEVEL, "Class {0} NOK: missing", className);
+
+ if (!TOLERATE_MISSING_SYNTHETICS || !isSynthetic(classDefItem.getAccessFlags())) {
+ throw new DifferenceFoundException("Class " + className
+ + " was not found in reference.");
+ }
+ }
+ }
+ }
+ }
+
+ private void checkStringIds() throws DifferenceFoundException {
+ checkStringIterables(referenceDexFile.strings(), candidateDexFile.strings(), "String");
+ }
+
+ private void checkTypeIds() throws DifferenceFoundException {
+ checkStringIterables(referenceDexFile.typeNames(), candidateDexFile.typeNames(), "Type");
+ }
+
+ private void checkFieldIds() throws DifferenceFoundException {
+ List<FieldId> referenceFieldIds = referenceDexFile.fieldIds();
+ List<FieldId> candidateFieldIds = candidateDexFile.fieldIds();
+ List<String> referenceFieldNames = getFieldNameList(referenceFieldIds, referenceDexFile);
+ List<String> candidateFieldNames = getFieldNameList(candidateFieldIds, candidateDexFile);
+ checkStringIterables(referenceFieldNames, candidateFieldNames, "Field");
+ }
+
+ private void checkMethodIds() throws DifferenceFoundException {
+ List<MethodId> referenceMethodIds = referenceDexFile.methodIds();
+ List<MethodId> candidateMethodIds = candidateDexFile.methodIds();
+ List<String> referenceMethodNames = getMethodNameList(referenceMethodIds, referenceDexFile);
+ List<String> candidateMethodNames = getMethodNameList(candidateMethodIds, candidateDexFile);
+ checkStringIterables(referenceMethodNames, candidateMethodNames, "Method");
+ }
+
+ private void checkProtoIds() throws DifferenceFoundException {
+ List<ProtoId> referenceProtoIds = referenceDexFile.protoIds();
+ List<ProtoId> candidateProtoIds = candidateDexFile.protoIds();
+ List<String> referenceProtoStrings = getProtoStringList(referenceProtoIds, referenceDexFile);
+ List<String> candidateProtoStrings = getProtoStringList(candidateProtoIds, candidateDexFile);
+ checkStringIterables(referenceProtoStrings, candidateProtoStrings, "Proto");
+ }
+
+ private static List<String> getProtoStringList(List<ProtoId> protoIds, DexBuffer dex) {
+ List<String> protoStrings = new ArrayList<String>();
+ for (ProtoId protoId : protoIds) {
+ protoStrings.add(getProtoString(protoId, dex));
+ }
+ return protoStrings;
+ }
+
+ private static String getProtoString(ProtoId protoId, DexBuffer dex) {
+ return dex.readTypeList(protoId.getParametersOffset()) + dex.typeNames().get(
+ protoId.getReturnTypeIndex());
+ }
+
+ private static List<String> getFieldNameList(List<FieldId> fieldIds, DexBuffer dex) {
+ List<String> fieldNames = new ArrayList<String>();
+ for (FieldId fieldId : fieldIds) {
+ fieldNames.add(dex.strings().get(fieldId.getNameIndex()));
+ }
+ return fieldNames;
+ }
+
+ private static List<String> getMethodNameList(List<MethodId> methodIds, DexBuffer dex) {
+ List<String> methodNames = new ArrayList<String>();
+ for (MethodId methodId : methodIds) {
+ ProtoId protoId = dex.protoIds().get(methodId.getProtoIndex());
+ String sortableMethodName = dex.typeNames().get(methodId.getDeclaringClassIndex()) + "."
+ + dex.strings().get(methodId.getNameIndex()) + getProtoString(protoId, dex);
+ methodNames.add(sortableMethodName);
+ }
+ return methodNames;
+ }
+
+ private void checkStringIterables(
+ Iterable<String> referenceStrings, Iterable<String> candidateStrings, String logTypeName)
+ throws DifferenceFoundException {
+ Iterator<String> candidateStringIter = candidateStrings.iterator();
+ for (String refString : referenceStrings) {
+ boolean found = false;
+ while (!found) {
+ if (!candidateStringIter.hasNext()) {
+ throw new DifferenceFoundException(logTypeName + " '" + refString
+ + "' was not found in candidate as expected");
+ }
+
+ String candidateString = candidateStringIter.next();
+ int stringComparison = candidateString.compareTo(refString);
+ if (stringComparison == 0) {
+ found = true;
+ logger.log(DEBUG_LEVEL, "{0} {1} OK", new Object[] {logTypeName, refString});
+ } else if (stringComparison > 0 || strict) { // candidateString is after refString
+ logger.log(ERROR_LEVEL, "{0} {1} NOK: missing", new Object[] {logTypeName, refString});
+
+ throw new DifferenceFoundException(logTypeName + " '" + refString
+ + "' was not found in candidate as expected");
+ }
+ }
+ }
+ if (strict && candidateStringIter.hasNext()) {
+ String leftOverString = candidateStringIter.next();
+
+ throw new DifferenceFoundException(logTypeName + " '" + leftOverString
+ + "' is in candidate but not in reference");
+ }
+ }
+
+ private void checkAccessFlags(ClassDef classDefItem, ClassDef candidateClassDefItem)
+ throws DifferenceFoundException {
+ String className = getClassName(referenceDexFile, classDefItem);
+ int candidateAccessFlags = candidateClassDefItem.getAccessFlags();
+ int refAccessFlags = classDefItem.getAccessFlags();
+ if (refAccessFlags == candidateAccessFlags) {
+ logger.log(DEBUG_LEVEL, "Class Access Flags of {0} OK", className);
+ } else {
+ logger.log(ERROR_LEVEL,
+ "Class Access Flags of {0} NOK: reference = {1}, candidate = {2}", new Object[] {
+ className, Integer.valueOf(refAccessFlags),
+ Integer.valueOf(candidateAccessFlags)});
+
+ throw new DifferenceFoundException("Access flags do not match for Class '" + className
+ + "'. Candidate flags: " + candidateAccessFlags + ". Reference flags: "
+ + refAccessFlags + ".");
+ }
+ }
+
+ private void checkClassData(ClassDef classDefItem, ClassDef candidateClassDefItem)
+ throws DifferenceFoundException {
+ String className = getClassName(referenceDexFile, classDefItem);
+ boolean referenceDexFileHasClassData = classDefItem.getClassDataOffset() != 0;
+ boolean candidateDexFileHasClassData = candidateClassDefItem.getClassDataOffset() != 0;
+
+ if (!referenceDexFileHasClassData && !candidateDexFileHasClassData) {
+ logger.log(DEBUG_LEVEL, "ClassData of {0} OK: both are null", className);
+ } else if (!referenceDexFileHasClassData || !candidateDexFileHasClassData) {
+ // If one DexFile has no ClassData, we have to check if all the
+ // methods in the other one are tolerated
+ ClassData.Field[] emptyFieldList = new ClassData.Field[0];
+ ClassData.Method[] emptyMethodList = new ClassData.Method[0];
+ ClassData classDataItem;
+ if (referenceDexFileHasClassData) {
+ classDataItem = referenceDexFile.readClassData(classDefItem);
+ handleFields(classDataItem.getInstanceFields(), emptyFieldList, className);
+ handleFields(classDataItem.getStaticFields(), emptyFieldList, className);
+ handleMethods(classDataItem.allMethods(), emptyMethodList, className);
+ } else {
+ assert candidateDexFileHasClassData;
+ classDataItem = candidateDexFile.readClassData(candidateClassDefItem);
+ handleFields(emptyFieldList, classDataItem.getInstanceFields(), className);
+ handleFields(emptyFieldList, classDataItem.getStaticFields(), className);
+ handleMethods(emptyMethodList, classDataItem.allMethods(), className);
+ }
+ } else {
+ // TODO(benoitlamarche): check annotations
+
+ ClassData classDataItem = referenceDexFile.readClassData(classDefItem);
+ ClassData candidateClassDataItem = candidateDexFile.readClassData(candidateClassDefItem);
+
+ checkFields(classDataItem, candidateClassDataItem, classDefItem);
+
+ checkMethods(classDataItem, candidateClassDataItem, classDefItem);
+ }
+ }
+
+ private void checkMethods(
+ ClassData classDataItem, ClassData candidateClassDataItem, ClassDef classDefItem)
+ throws DifferenceFoundException {
+ String className = getClassName(referenceDexFile, classDefItem);
+
+ ClassData.Method[] methods = classDataItem.allMethods();
+ ClassData.Method[] candidateMethods = candidateClassDataItem.allMethods();
+
+ handleMethods(methods, candidateMethods, className);
+ }
+
+ private void checkFields(
+ ClassData classDataItem, ClassData candidateClassDataItem, ClassDef classDefItem)
+ throws DifferenceFoundException {
+ String className = getClassName(referenceDexFile, classDefItem);
+
+ /* Instance fields */
+ {
+ ClassData.Field[] instanceFields = classDataItem.getInstanceFields();
+ ClassData.Field[] candidateInstanceFields = candidateClassDataItem.getInstanceFields();
+
+ handleFields(instanceFields, candidateInstanceFields, className);
+ }
+
+ /* Static fields */
+ // TODO(benoitlamarche): should static initializers be checked?
+ {
+ ClassData.Field[] instanceFields = classDataItem.getStaticFields();
+ ClassData.Field[] candidateInstanceFields = candidateClassDataItem.getStaticFields();
+
+ handleFields(instanceFields, candidateInstanceFields, className);
+ }
+ }
+
+ private void checkInterfaces(ClassDef classDefItem, ClassDef candidateClassDefItem)
+ throws DifferenceFoundException {
+
+ String className = getClassName(referenceDexFile, classDefItem);
+ short[] interfaces = classDefItem.getInterfaces();
+ short[] candidateInterfaces = candidateClassDefItem.getInterfaces();
+
+ List<String> interfacesList = getInterfaceNames(referenceDexFile, interfaces);
+ List<String> candidateInterfacesList = getInterfaceNames(candidateDexFile, candidateInterfaces);
+
+ for (String interfaceName : interfacesList) {
+ boolean contained = candidateInterfacesList.remove(interfaceName);
+ if (contained) {
+ logger.log(DEBUG_LEVEL, "Implemented interface of {0} OK: {1}",
+ new Object[] {className, interfaceName});
+ } else {
+ logger.log(ERROR_LEVEL, "Implemented interface of {0} NOK: {1} missing in candidate",
+ new Object[] {className, interfaceName});
+
+ throw new DifferenceFoundException("Interface " + interfaceName + " is not implemented by "
+ + className + " in candidate");
+ }
+ }
+
+ if (!candidateInterfacesList.isEmpty()) {
+ String leftOverInterface = candidateInterfacesList.get(0);
+ logger.log(ERROR_LEVEL, "Implemented interface of {0} NOK: {1} missing in reference",
+ new Object[] {className, leftOverInterface});
+
+ throw new DifferenceFoundException("Interface " + leftOverInterface
+ + " is not implemented by " + className + " in reference");
+ }
+ }
+
+ private void checkSuperclass(ClassDef classDefItem, ClassDef candidateClassDefItem)
+ throws DifferenceFoundException {
+ String className = getClassName(referenceDexFile, classDefItem);
+ String superClass = (classDefItem.getSupertypeIndex() == ClassDef.NO_INDEX) ? ("empty")
+ : (getSuperclassName(referenceDexFile, classDefItem));
+ String candidateSuperClass =
+ (candidateClassDefItem.getSupertypeIndex() == ClassDef.NO_INDEX) ? ("empty")
+ : (getSuperclassName(candidateDexFile, candidateClassDefItem));
+
+ if (superClass.equals(candidateSuperClass)) {
+ logger.log(DEBUG_LEVEL, "Superclass of {0} OK: {1}", new Object[] {className, superClass});
+ } else {
+ logger.log(ERROR_LEVEL, "Superclass of {0} NOK: reference = {1}, candidate = {2}",
+ new Object[] {className, superClass, candidateSuperClass});
+
+ throw new DifferenceFoundException("Superclasses of '" + className
+ + "' do not match. Candidate superclass: " + candidateSuperClass
+ + ". Reference superclass: " + superClass + ".");
+ }
+ }
+
+ /**
+ * Checks that all the elements of {@code referenceFields} can be found in
+ * {@code candidateFields} based on their name and type, and check accessFlags are the same. If in
+ * strict mode, all the elements of {@code candidateFields} must also be in
+ * {@code referenceFields}.
+ *
+ * @param referenceFields Contains fields of current class in reference dex file.
+ * @param candidateFields Contains fields of current class in candidate dex file
+ * @param className Name of the current class
+ * @throws DifferenceFoundException If a difference is found while comparing fields
+ */
+ private void handleFields(ClassData.Field[] referenceFields,
+ ClassData.Field[] candidateFields, String className) throws DifferenceFoundException {
+
+ boolean isFound;
+ List<ClassData.Field> foundFields = null;
+ if (strict) {
+ foundFields = new ArrayList<ClassData.Field>(candidateFields.length);
+ }
+ for (ClassData.Field encField : referenceFields) {
+ isFound = false;
+ String refFieldName = getFieldName(referenceDexFile, encField.getFieldIndex());
+ String refFieldType = getFieldTypeName(referenceDexFile, encField.getFieldIndex());
+ for (ClassData.Field candidateEncField : candidateFields) {
+ String candFieldName = getFieldName(candidateDexFile, candidateEncField.getFieldIndex());
+ String candFieldType = getFieldTypeName(
+ candidateDexFile, candidateEncField.getFieldIndex());
+ if (refFieldName.equals(candFieldName) && refFieldType.equals(candFieldType)) {
+ logger.log(DEBUG_LEVEL,
+ "Field {0}.{1} OK", new Object[] {className, refFieldName});
+
+ /* Access flags */
+ if (encField.getAccessFlags() != candidateEncField.getAccessFlags()) {
+ logger.log(ERROR_LEVEL,
+ "Access Flags for Field {0}.{1} NOK: reference = {2}, candidate = {3}",
+ new Object[] {className, refFieldName, Integer.valueOf(encField.getAccessFlags()),
+ Integer.valueOf(candidateEncField.getAccessFlags())});
+
+ throw new DifferenceFoundException("Access flags do not match for Field '" + className
+ + "." + refFieldName + "'. Candidate flags: " + candidateEncField.getAccessFlags()
+ + ". Reference flags: " + encField.getAccessFlags() + ".");
+
+ } else {
+ logger.log(DEBUG_LEVEL, "Field Access Flags of {0}.{1} OK",
+ new Object[] {className, refFieldName});
+ isFound = true;
+ if (strict) {
+ assert foundFields != null;
+ foundFields.add(candidateEncField);
+ }
+ break;
+ }
+ }
+ }
+
+ if (!isFound && !isTolerated(encField)) {
+ logger.log(
+ ERROR_LEVEL, "Field {0}.{1} NOK: missing", new Object[] {className, refFieldName});
+ throw new DifferenceFoundException("Field " + className + "." + refFieldName + " of type '"
+ + refFieldType + "' not found in candidate file.");
+ }
+ }
+ if (strict) {
+ List<ClassData.Field> candidateFieldList =
+ new ArrayList<ClassData.Field>(Arrays.asList(candidateFields));
+ candidateFieldList.removeAll(foundFields);
+
+ // remove tolerated fields
+ Iterator<ClassData.Field> candidateFieldIter = candidateFieldList.iterator();
+ while (candidateFieldIter.hasNext()) {
+ ClassData.Field field = candidateFieldIter.next();
+ if (isTolerated(field)) {
+ candidateFieldIter.remove();
+ }
+ }
+
+ if (!candidateFieldList.isEmpty()) {
+ StringBuffer sb = new StringBuffer(
+ "Too many fields in candidate for class '" + className + "'. Unwanted fields are: ");
+ for (ClassData.Field unwantedField: candidateFieldList) {
+ sb.append(getFieldTypeName(candidateDexFile, unwantedField.getFieldIndex()));
+ sb.append(" ");
+ sb.append(getFieldName(candidateDexFile, unwantedField.getFieldIndex()));
+ sb.append(" - ");
+ }
+ throw new DifferenceFoundException(sb.toString());
+ }
+ }
+ }
+
+ /**
+ * Checks that all the elements of {@code referenceMethods} can be found in
+ * {@code candidateMethods} based on their name and prototype, and check accessFlags are the same.
+ * If in strict mode, all the elements of {@code candidateMethods} must also be in
+ * {@code referenceMethods}.
+ *
+ * @param referenceMethods Contains methods of current class in reference dex file.
+ * @param candidateMethods Contains methods of current class in candidate dex file
+ * @param className Name of the current class
+ * @throws DifferenceFoundException If a difference is found while comparing methods
+ */
+ private void handleMethods(
+ ClassData.Method[] referenceMethods, ClassData.Method[] candidateMethods, String className)
+ throws DifferenceFoundException {
+ boolean isFound;
+ List<ClassData.Method> foundMethods = null;
+ if (strict) {
+ foundMethods = new ArrayList<ClassData.Method>(candidateMethods.length);
+ }
+ for (ClassData.Method encMeth : referenceMethods) {
+ isFound = false;
+ String refMethodName = getMethodName(referenceDexFile, encMeth.getMethodIndex());
+ String refMethodProto = getMethodProto(referenceDexFile, encMeth.getMethodIndex());
+
+ if (isSkipped(className, refMethodName, refMethodProto)) {
+ continue;
+ }
+
+ for (ClassData.Method candidateEncMeth : candidateMethods) {
+ String candMethodName = getMethodName(candidateDexFile, candidateEncMeth.getMethodIndex());
+ String candMethodProto = getMethodProto(
+ candidateDexFile, candidateEncMeth.getMethodIndex());
+
+ if (refMethodName.equals(candMethodName) && refMethodProto.equals(candMethodProto)) {
+ logger.log(DEBUG_LEVEL,
+ "Method {0}.{1}{2} OK", new Object[] {className, refMethodName, refMethodProto});
+
+ if (enableInstructionNumberComparison) {
+ handleInstructionNumberComparison(
+ className, refMethodName, refMethodProto, encMeth, candidateEncMeth);
+ }
+
+ /* Access flags */
+ // TODO(?): remove testing of debugInfo and do something else to be able to not check
+ // structure when comparing debug info
+ if ((!debugInfo) && (encMeth.getAccessFlags() != candidateEncMeth.getAccessFlags())) {
+ logger.log(ERROR_LEVEL,
+ "Method Access Flags of {0}.{1}{2} NOK: reference = {3}, candidate = {4}",
+ new Object[] {className, refMethodName, refMethodProto, Integer.valueOf(
+ encMeth.getAccessFlags()), Integer.valueOf(candidateEncMeth.getAccessFlags())});
+
+ throw new DifferenceFoundException("Access flags do not match for Method '" + className
+ + "." + refMethodName + "'. Candidate flags: " + candidateEncMeth.getAccessFlags()
+ + ". Reference flags: " + encMeth.getAccessFlags() + ".");
+
+ } else {
+ logger.log(DEBUG_LEVEL, "Access Flags for Method {0}.{1}{2} OK",
+ new Object[] {className, refMethodName, refMethodProto});
+ isFound = true;
+
+ if (strict) {
+ assert foundMethods != null;
+ foundMethods.add(candidateEncMeth);
+ }
+ if (debugInfo) {
+ checkDebugInfo(encMeth, candidateEncMeth, className);
+ }
+ break;
+ }
+ }
+ }
+
+ if (!isFound && !isTolerated(encMeth, refMethodName)) {
+ logger.log(ERROR_LEVEL, "Method {0}.{1}{2} NOK: missing",
+ new Object[] {className, refMethodName, refMethodProto});
+ throw new DifferenceFoundException("Method " + className + "." + refMethodName
+ + refMethodProto + " not found in candidate file.");
+ }
+ }
+ if (strict) {
+ List<ClassData.Method> candidateMethodList =
+ new ArrayList<ClassData.Method>(Arrays.asList(candidateMethods));
+ candidateMethodList.removeAll(foundMethods);
+
+ // remove tolerated methods
+ Iterator<ClassData.Method> candidateMethodIter = candidateMethodList.iterator();
+ while (candidateMethodIter.hasNext()) {
+ ClassData.Method method = candidateMethodIter.next();
+ String methodName = getMethodName(candidateDexFile, method.getMethodIndex());
+ if (isTolerated(method, methodName)) {
+ candidateMethodIter.remove();
+ }
+ }
+
+ if (!candidateMethodList.isEmpty()) {
+ StringBuffer sb = new StringBuffer(
+ "Too many methods in candidate for class '" + className + "'. Unwanted methods are: ");
+ for (ClassData.Method unwantedMethod: candidateMethodList) {
+ sb.append(getMethodName(candidateDexFile, unwantedMethod.getMethodIndex()));
+ sb.append(getMethodProto(candidateDexFile, unwantedMethod.getMethodIndex()));
+ sb.append(" - ");
+ }
+ throw new DifferenceFoundException(sb.toString());
+ }
+ }
+ }
+
+ private void handleInstructionNumberComparison(
+ String className, String methodName, String methodProto, Method refMeth, Method candidateMeth)
+ throws DifferenceFoundException {
+
+ if (refMeth.getCodeOffset() == 0 && candidateMeth.getCodeOffset() == 0) {
+ logger.log(DEBUG_LEVEL, "Method {0}.{1}{2} code comparison OK",
+ new Object[] {className, methodName, methodProto});
+ return;
+ }
+ if (refMeth.getCodeOffset() != 0 && candidateMeth.getCodeOffset() == 0) {
+ logger.log(
+ ERROR_LEVEL,
+ "Method {0}.{1}{2} NOK: candidate has no code whereas reference has",
+ new Object[] {className, methodName, methodProto});
+ throw getDifferenceFoundException(className, refMeth, referenceDexFile,
+ "Candidate method has no code whereas reference has");
+ }
+ if (refMeth.getCodeOffset() == 0 && candidateMeth.getCodeOffset() != 0) {
+ logger.log(
+ ERROR_LEVEL,
+ "Method {0}.{1}{2} NOK: candidate has code whereas reference has not",
+ new Object[] {className, methodName, methodProto});
+ throw getDifferenceFoundException(className, refMeth, referenceDexFile,
+ "Candidate method has code whereas reference has not");
+ }
+
+ int refInsSize = referenceDexFile.readCode(refMeth).getInstructions().length;
+ int candidateInsSize = candidateDexFile.readCode(candidateMeth).getInstructions().length;
+ float ratio;
+ if (refInsSize != 0) {
+ ratio = ((float) (candidateInsSize - refInsSize)) / refInsSize;
+ } else {
+ if (candidateInsSize == 0) {
+ ratio = 0f;
+ } else {
+ ratio = 1f;
+ }
+ }
+ boolean tolerated = ratio <= instructionNumberTolerance;
+ if (!tolerated) {
+ logger.log(WARNING_LEVEL,
+ "Method {0}.{1}{2} NOK: number of instructions differs more than allowed: "
+ + "percentage = {3}%, reference = {4}, candidate = {5}, delta allowed = {6}%",
+ new Object[] {className,
+ methodName,
+ methodProto,
+ Float.valueOf(ratio * 100),
+ Integer.valueOf(refInsSize),
+ Integer.valueOf(candidateInsSize),
+ Float.valueOf(instructionNumberTolerance * 100)});
+ }
+ }
+
+ private void handleBinaryDebugInfoComparison(String className,
+ String methodName,
+ String methodProto,
+ Method refMeth,
+ DebugInfo refDbgInfo,
+ DebugInfo candidateDbgInfo)
+ throws DifferenceFoundException {
+ byte[] refBytes = referenceDexFile.getBytes();
+ byte[] candidateBytes = candidateDexFile.getBytes();
+
+ int refDbgInfOffset = refDbgInfo.getDebugInfoOffset();
+ int candidateDbgInfOffset = candidateDbgInfo.getDebugInfoOffset();
+
+ int refDbgInfoLength = refDbgInfo.getSizeInBytes();
+ int candidateDbgInfoLength = candidateDbgInfo.getSizeInBytes();
+
+ int i = 0;
+ for (; (i < refDbgInfoLength) && ((refDbgInfOffset + i) < refBytes.length); ++i) {
+ if ((candidateDbgInfOffset + i) >= candidateBytes.length
+ || i >= candidateDbgInfoLength) {
+ logger.log(
+ ERROR_LEVEL, "Method {0}.{1}{2} NOK: debug infos size is smaller than reference",
+ new Object[] {className, methodName, methodProto});
+ throw getDifferenceFoundException(className, refMeth, referenceDexFile,
+ "There's less debug infos in candidate than in reference");
+ } else if (refBytes[refDbgInfOffset + i] != candidateBytes[candidateDbgInfOffset + i]) {
+ logger.log(ERROR_LEVEL, "Method {0}.{1}{2} NOK: debug infos differ",
+ new Object[] {className, methodName, methodProto});
+ throw getDifferenceFoundException(className, refMeth, referenceDexFile,
+ "Debug infos differ");
+ }
+ }
+ assert (refDbgInfOffset + i) < refBytes.length;
+ if (i == candidateDbgInfoLength) {
+ logger.log(DEBUG_LEVEL, "Method {0}.{1}{2} debug infos comparison OK",
+ new Object[] {className, methodName, methodProto});
+ } else {
+ logger.log(ERROR_LEVEL, "Method {0}.{1}{2} NOK: debug infos size is larger than reference",
+ new Object[] {className, methodName, methodProto});
+ throw getDifferenceFoundException(className, refMeth, referenceDexFile,
+ "There's more debug infos in candidate than in reference");
+ }
+ }
+
+ private boolean isSkipped(String className, String methodName, String methodProto) {
+ boolean isSkipped = skippedMethods.contains(className + "." + methodName + methodProto);
+ return isSkipped;
+ }
+
+ private boolean isTolerated(ClassData.Field field) {
+ return TOLERATE_MISSING_SYNTHETICS && isSynthetic(field.getAccessFlags());
+ }
+
+ private boolean isTolerated(ClassData.Method method, String methodName) {
+ boolean tolerated = (TOLERATE_MISSING_SYNTHETICS && isSynthetic(method.getAccessFlags())) ||
+ (TOLERATE_MISSING_INITS && methodName.equals(INIT_NAME)) ||
+ (TOLERATE_MISSING_CLINITS && methodName.equals(STATIC_INIT_NAME));
+ return tolerated;
+ }
+
+ private boolean isTolerated(LocalVar localVar) {
+ boolean tolerated = TOLERATE_MISSING_SYNTHETICS && localVar.isSynthetic();
+ return tolerated;
+ }
+
+ private void checkDebugInfo(Method reference, Method candidate, String className)
+ throws DifferenceFoundException {
+
+ if (isSynthetic(reference.getAccessFlags())) {
+ assert isSynthetic(candidate.getAccessFlags());
+ // ignore synthetic methods
+ return;
+ }
+
+ if (AccessFlags.isConstructor(reference.getAccessFlags())) {
+ assert AccessFlags.isConstructor(candidate.getAccessFlags());
+ // Ignore all constructors because debug infos for default constructors may not use the same
+ // line numbers. It would be better to ignore only default constructors but they are not
+ // flagged as synthetic, and in the case of inner classes may have parameters.
+ return;
+ }
+
+ if (reference.getCodeOffset() == 0) {
+ if (candidate.getCodeOffset() != 0) {
+ throw getDifferenceFoundException(className, reference, referenceDexFile,
+ "Candidate has code while reference has not");
+
+ } else {
+ return;
+ }
+ } else if (candidate.getCodeOffset() == 0) {
+ throw getDifferenceFoundException(className, reference, referenceDexFile,
+ "Candidate is missing code");
+ }
+ DebugInfo refInfo = decodeDebugInfo(reference, referenceDexFile, referenceData,
+ refThisIndex);
+ DebugInfo candidateInfo = decodeDebugInfo(candidate, candidateDexFile, candidateData,
+ candidateThisIndex);
+ if (refInfo == null) {
+ if (candidateInfo != null) {
+ throw getDifferenceFoundException(className, reference, referenceDexFile,
+ "Candidate has debug info while reference has not");
+ } else {
+ return;
+ }
+ } else if (candidateInfo == null) {
+ throw getDifferenceFoundException(className, reference, referenceDexFile,
+ "Candidate is missing debug info");
+
+ }
+
+ if (enableBinaryDebugInfoComparison) {
+ String refMethodName = getMethodName(referenceDexFile, reference.getMethodIndex());
+ String refMethodProto = getMethodProto(referenceDexFile, candidate.getMethodIndex());
+ handleBinaryDebugInfoComparison(className,
+ refMethodName,
+ refMethodProto,
+ candidate,
+ refInfo,
+ candidateInfo);
+ }
+
+ for (LocalVar refLocal : refInfo.getLocals()) {
+ LocalVar candidateLocal = candidateInfo.getLocal(refLocal);
+ if (candidateLocal == null) {
+ if (!isTolerated(refLocal)) {
+ throw getDifferenceFoundException(className, reference, referenceDexFile,
+ "Missing local variable in candidate: " + refLocal.getTypeSignature() + " "
+ + refLocal.getName());
+ }
+ } else {
+ if (!refLocal.getScope().equals(candidateLocal.getScope())) {
+ throw getDifferenceFoundException(className, reference, referenceDexFile,
+ "Scope differs for local: " + refLocal.getTypeSignature() + " " +
+ refLocal.getName() + ", reference: " + refLocal.getScope() +
+ ", candidate:" + candidateLocal.getScope());
+ }
+ }
+
+ }
+ }
+
+ private DifferenceFoundException getDifferenceFoundException(String inClass, Method inMethod,
+ DexBuffer dexOfMethod, String message) {
+ return new DifferenceFoundException("In method " + inClass + "." +
+ getMethodName(dexOfMethod, inMethod.getMethodIndex()) +
+ getMethodProto(dexOfMethod, inMethod.getMethodIndex()) + ":" + message);
+ }
+
+ private static DebugInfo decodeDebugInfo(Method method, DexBuffer dex, byte[] dexData,
+ int thisIdx) {
+ boolean isStatic = (method.getAccessFlags() & AccessFlags.ACC_STATIC) != 0;
+ Prototype prototype = Prototype.intern(getMethodProto(
+ dex, method.getMethodIndex()));
+ Code codeItem = dex.readCode(method);
+ if (codeItem.getDebugInfoOffset() == 0) {
+ return null;
+ }
+
+ ByteArrayInput bai = new ByteArrayInput(codeItem.getDebugInfoOffset(), dexData);
+ DebugInfoDecoder decoder = new DebugInfoDecoder(
+ bai,
+ codeItem.getRegistersSize(),
+ isStatic,
+ prototype,
+ thisIdx);
+ decoder.decode();
+ return new DebugInfo(decoder, dex, codeItem, bai.getPosition());
+ }
+
+ private static String getClassName(DexBuffer dex, ClassDef classDef) {
+ return dex.typeNames().get(classDef.getTypeIndex());
+ }
+
+ private static String getMethodName(DexBuffer dex, int methodIndex) {
+ MethodId methodId = dex.methodIds().get(methodIndex);
+ return dex.strings().get(methodId.getNameIndex());
+ }
+
+ private static String getMethodProto(DexBuffer dex, int methodIndex) {
+ MethodId methodId = dex.methodIds().get(methodIndex);
+ ProtoId protoId = dex.protoIds().get(methodId.getProtoIndex());
+ return getProtoString(protoId, dex);
+ }
+
+ private static String getFieldName(DexBuffer dex, int fieldIndex) {
+ FieldId fieldId = dex.fieldIds().get(fieldIndex);
+ return dex.strings().get(fieldId.getNameIndex());
+ }
+
+ private static String getFieldTypeName(DexBuffer dex, int fieldIndex) {
+ FieldId fieldId = dex.fieldIds().get(fieldIndex);
+ Integer stringIndex = dex.typeIds().get(fieldId.getTypeIndex());
+ return dex.strings().get(stringIndex.intValue());
+ }
+
+ private static String getSuperclassName(DexBuffer dex, ClassDef classDef) {
+ return dex.typeNames().get(classDef.getSupertypeIndex());
+ }
+
+ private static List<String> getInterfaceNames(DexBuffer dex, short[] interfaces) {
+
+ List<String> interfaceNames = new ArrayList<String>(interfaces.length);
+ for (short interfIndex : interfaces) {
+ String typeName = dex.typeNames().get(interfIndex);
+ interfaceNames.add(typeName);
+ }
+ return interfaceNames;
+ }
+
+ private static boolean isAnomymousTypeName(String typeName) {
+ //TODO(benoitlamarche): use Annotations to determine if the class is anonymous
+ int location = typeName.lastIndexOf('$');
+ if (location != -1) {
+ String num = typeName.substring(location + 1, typeName.length() - 1);
+ try {
+ Integer.parseInt(num);
+ return true;
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ private static boolean isSynthetic(int modifier) {
+ return ((modifier & AccessFlags.ACC_SYNTHETIC) == AccessFlags.ACC_SYNTHETIC);
+ }
+
+ private static class ByteArrayInput implements ByteInput {
+ private final byte[] bytes;
+ private int position;
+
+ public ByteArrayInput(int start, byte... bytes) {
+ this.position = start;
+ this.bytes = bytes;
+ }
+
+ @Override
+ public byte readByte() {
+ return bytes[position++];
+ }
+
+ public int getPosition() {
+ return position;
+ }
+ }
+
+}
diff --git a/dexcomparator/src/com/android/jack/DifferenceFoundException.java b/dexcomparator/src/com/android/jack/DifferenceFoundException.java
new file mode 100644
index 00000000..31736e8a
--- /dev/null
+++ b/dexcomparator/src/com/android/jack/DifferenceFoundException.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 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.jack;
+
+/**
+ * Thrown while comparing two dex files when a difference is found.
+ */
+public class DifferenceFoundException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public DifferenceFoundException() {}
+
+ public DifferenceFoundException(String arg0) {
+ super(arg0);
+ }
+
+ public DifferenceFoundException(Throwable arg0) {
+ super(arg0);
+ }
+
+ public DifferenceFoundException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+}
diff --git a/dexcomparator/src/com/android/jack/comparator/DebugInfo.java b/dexcomparator/src/com/android/jack/comparator/DebugInfo.java
new file mode 100644
index 00000000..ea11f297
--- /dev/null
+++ b/dexcomparator/src/com/android/jack/comparator/DebugInfo.java
@@ -0,0 +1,282 @@
+/*
+ * Copyright (C) 2012 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.jack.comparator;
+
+import com.android.jack.dx.dex.file.DebugInfoDecoder;
+import com.android.jack.dx.dex.file.DebugInfoDecoder.LocalEntry;
+import com.android.jack.dx.dex.file.DebugInfoDecoder.PositionEntry;
+import com.android.jack.dx.io.Code;
+import com.android.jack.dx.io.DexBuffer;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+/**
+ * Debug information for one method.
+ */
+public class DebugInfo {
+
+ public static class Interval {
+ private int start;
+ private int end;
+ private int pendingCloseCount;
+
+ public Interval(int start) {
+ this.start = start;
+ this.end = start;
+ pendingCloseCount = 1;
+ }
+
+ public Interval(int start, int end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ /**
+ * @return the end
+ */
+ public int getEnd() {
+ return end;
+ }
+
+ /**
+ * @return the start
+ */
+ public int getStart() {
+ return start;
+ }
+
+ /**
+ * @param start the start to set
+ */
+ public void setStart(int start) {
+ augment(start);
+ pendingCloseCount++;
+ }
+
+ /**
+ * @param end the end to set
+ */
+ public void setEnd(int end) {
+ augment(end);
+ pendingCloseCount--;
+ assert pendingCloseCount >= 0;
+ }
+
+ @Override
+ public String toString() {
+ return "[" + start + ", " + end + "]";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Interval) {
+ Interval other = (Interval) obj;
+ return start == other.start && end == other.end;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 7529 * start + 11113 * end;
+ }
+
+ /**
+ * Increase this interval so that it includes the new limit.
+ */
+ private void augment(int limit) {
+ if (this.end < limit) {
+ this.end = limit;
+ }
+ if (this.start > limit) {
+ this.start = limit;
+ }
+ }
+
+ private boolean isClosed() {
+ return pendingCloseCount == 0;
+ }
+ }
+
+ public static class LocalVar {
+ @Nonnull
+ private final String name;
+ @CheckForNull
+ private final String typeSignature;
+
+ @Nonnull
+ private final Interval scope;
+
+ @Nonnull
+ private static final char NON_SOURCE_CONFLICTING_CHAR = '-';
+
+ private LocalVar(@Nonnull String name, @CheckForNull String typeSignature, int start) {
+ this.name = name;
+ this.typeSignature = typeSignature;
+ scope = new Interval(start);
+ }
+
+ @Nonnull
+ public String getName() {
+ return name;
+ }
+
+ @CheckForNull
+ public String getTypeSignature() {
+ return typeSignature;
+ }
+
+ @Nonnull
+ public Interval getScope() {
+ return scope;
+ }
+
+ public boolean isSynthetic() {
+ return name.indexOf(NON_SOURCE_CONFLICTING_CHAR) != -1;
+ }
+
+ @Nonnull
+ @Override
+ public String toString() {
+ return typeSignature + " " + name + " " + scope;
+ }
+
+ void addInterval(int start) {
+ scope.setStart(start);
+ }
+
+ void closeInterval(int end) {
+ scope.setEnd(end);
+ }
+ }
+
+ private static final int NO_INDEX = -1;
+
+ private List<PositionEntry> lines;
+ private final HashMap<String, LocalVar> locals = new HashMap<String, DebugInfo.LocalVar>();
+ private DexBuffer dex;
+ private int sizeInBytes;
+ private int debugInfoOffset;
+
+ public DebugInfo(DebugInfoDecoder decoder, DexBuffer dex, Code codeItem, int sizeInbytes) {
+ this.dex = dex;
+ this.sizeInBytes = sizeInbytes;
+ debugInfoOffset = codeItem.getDebugInfoOffset();
+ lines = decoder.getPositionList();
+ Collections.sort(lines, new Comparator<PositionEntry>() {
+ @Override
+ public int compare(PositionEntry o1, PositionEntry o2) {
+ return o2.address > o1.address ? -1 : (o2.address == o1.address ? 0 : 1);
+ }});
+
+ LocalVar[] regs = new LocalVar[codeItem.getRegistersSize()];
+
+ for (LocalEntry localEntry : decoder.getLocals()) {
+
+ int reg = localEntry.reg;
+ int line = getLine(localEntry.address - 1);
+ if (localEntry.isStart && regs[reg] != null) {
+ regs[reg].closeInterval(line);
+ regs[reg] = null;
+ }
+
+ if (localEntry.nameIndex != NO_INDEX) {
+
+ LocalVar localVar = getOrCreate(localEntry);
+
+ if (localEntry.isStart) {
+ localVar.addInterval(line);
+ regs[reg] = localVar;
+ } else {
+ localVar.closeInterval(line);
+ regs[reg] = null;
+ }
+ }
+ }
+
+ int endLine = -1;
+ for (PositionEntry line : lines) {
+ endLine = Math.max(line.line, endLine);
+ }
+ for (LocalVar localVar : locals.values()) {
+ if (!localVar.getScope().isClosed()) {
+ localVar.closeInterval(endLine);
+ }
+ }
+ }
+
+ private LocalVar getOrCreate(LocalEntry localEntry) {
+ String name = dex.strings().get(localEntry.nameIndex);
+ String desc = null;
+ if (localEntry.signatureIndex != NO_INDEX) {
+ desc = dex.strings().get(localEntry.signatureIndex);
+ } else if (localEntry.typeIndex != NO_INDEX) {
+ desc = dex.typeNames().get(localEntry.typeIndex);
+ }
+
+ String key = name + desc;
+ LocalVar local = locals.get(key);
+ if (local == null) {
+ assert localEntry.isStart;
+ local = new LocalVar(name, desc, getLine(localEntry.address));
+ locals.put(key, local);
+ }
+ return local;
+ }
+
+ public int getLine(int address) {
+ int line = -1;
+ for (PositionEntry entry : lines) {
+ if (entry.address > address) {
+ if (line == -1) {
+ line = entry.line;
+ }
+ break;
+ } else {
+ line = entry.line;
+ }
+ }
+ return line;
+ }
+
+ public Collection<LocalVar> getLocals() {
+ return locals.values();
+ }
+
+ public LocalVar getLocal(LocalVar other) {
+ return getLocal(other.getName(), other.getTypeSignature());
+ }
+
+ public LocalVar getLocal(String name, String desc) {
+ return locals.get(name + desc);
+ }
+
+ public int getSizeInBytes() {
+ return sizeInBytes;
+ }
+
+ public int getDebugInfoOffset() {
+ return debugInfoOffset;
+ }
+}