diff options
Diffstat (limited to 'jill')
52 files changed, 0 insertions, 7758 deletions
diff --git a/jill/.checkstyle b/jill/.checkstyle deleted file mode 100644 index 5c5a2d1..0000000 --- a/jill/.checkstyle +++ /dev/null @@ -1,10 +0,0 @@ -<?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="Jill Checkstyle" location="jillstyle.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="Jill Checkstyle" local="true"> - <file-match-pattern match-pattern="^src.*\.java$" include-pattern="true"/> - </fileset> -</fileset-config> diff --git a/jill/.classpath b/jill/.classpath deleted file mode 100644 index abd8305..0000000 --- a/jill/.classpath +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="tests"/> - <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> - <classpathentry combineaccessrules="false" kind="src" path="/Jack"/> - <classpathentry kind="lib" path="libs/args4j-lib.jar"/> - <classpathentry kind="lib" path="libs/asm4-lib.jar"/> - <classpathentry kind="lib" path="libs/dexcomparator-lib.jar"/> - <classpathentry kind="lib" path="libs/guava-lib.jar"/> - <classpathentry kind="lib" path="libs/jsr305-lib.jar"/> - <classpathentry combineaccessrules="false" kind="src" path="/Dx"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> - <classpathentry combineaccessrules="false" kind="src" path="/jack-tests"/> - <classpathentry combineaccessrules="false" kind="src" path="/jill-api"/> - <classpathentry combineaccessrules="false" kind="src" path="/Scheduler"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/jill/.project b/jill/.project deleted file mode 100644 index 9817aca..0000000 --- a/jill/.project +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>jill</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/jill/.settings/edu.umd.cs.findbugs.core.prefs b/jill/.settings/edu.umd.cs.findbugs.core.prefs deleted file mode 100644 index c36d3e5..0000000 --- a/jill/.settings/edu.umd.cs.findbugs.core.prefs +++ /dev/null @@ -1,133 +0,0 @@ -#FindBugs User Preferences -#Wed Jul 16 10:48:53 CEST 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 -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/jill/.settings/org.eclipse.core.resources.prefs b/jill/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c0..0000000 --- a/jill/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/<project>=UTF-8 diff --git a/jill/.settings/org.eclipse.jdt.core.prefs b/jill/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 159ed4a..0000000 --- a/jill/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,425 +0,0 @@ -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=false -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/jill/.settings/org.eclipse.jdt.ui.prefs b/jill/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index d44207b..0000000 --- a/jill/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,63 +0,0 @@ -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/jill/.settings/org.eclipse.ltk.core.refactoring.prefs b/jill/.settings/org.eclipse.ltk.core.refactoring.prefs deleted file mode 100644 index b196c64..0000000 --- a/jill/.settings/org.eclipse.ltk.core.refactoring.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/jill/Android.mk b/jill/Android.mk deleted file mode 100644 index 9648796..0000000 --- a/jill/Android.mk +++ /dev/null @@ -1,131 +0,0 @@ -# Copyright (C) 2013 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. - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := jill -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := EXECUTABLES - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_JAVA_RESOURCE_DIRS := rsc -LOCAL_JAR_MANIFEST := etc/manifest.txt - -LOCAL_STATIC_JAVA_LIBRARIES := \ - jill-api \ - asm-all-4.1-jack \ - guava-jack \ - jsr305lib-jack \ - args4j-jack \ - schedlib - -JILL_VERSION_FILE := $(call local-intermediates-dir,COMMON)/generated.version/jill-version.properties -LOCAL_JAVA_RESOURCE_FILES += $(JILL_VERSION_FILE) -LOCAL_ADDITIONAL_DEPENDENCIES += $(JILL_VERSION_FILE) - -include $(BUILD_HOST_JAVA_LIBRARY) - -$(JILL_VERSION_FILE): $(TOP_DIR)$(LOCAL_PATH)/../version.properties | $(ACP) - $(copy-file-to-target) - -# Include this library in the build server's output directory -$(call dist-for-goals, dist_files, $(LOCAL_BUILT_MODULE):jill.jar) - -include $(CLEAR_VARS) - -LOCAL_MODULE := jill-jarjar-asm -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := EXECUTABLES - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_JAVA_RESOURCE_DIRS := rsc -LOCAL_JAR_MANIFEST := etc/manifest.txt - -LOCAL_STATIC_JAVA_LIBRARIES := \ - jill-api \ - asm-all-4.1-jack \ - guava-jack \ - jsr305lib-jack \ - args4j-jack \ - schedlib - -LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt -LOCAL_JAVA_RESOURCE_FILES += $(JILL_VERSION_FILE) -LOCAL_ADDITIONAL_DEPENDENCIES += $(JILL_VERSION_FILE) - -include $(BUILD_HOST_JAVA_LIBRARY) - -# -# Build Jill tests -# - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-java-files-under, tests) - -LOCAL_MODULE := libjillunittests - -LOCAL_MODULE_TAGS := optional -LOCAL_JAVACFLAGS := -processor com.android.sched.build.SchedAnnotationProcessor - -LOCAL_STATIC_JAVA_LIBRARIES := jill jill-api - -LOCAL_JAVA_LIBRARIES := \ - libjackunittests \ - sched-build \ - schedlib - -LOCAL_REQUIRED_MODULES:= \ - core \ - bouncycastle \ - ext \ - core-junit \ - framework \ - telephony-common \ - android.policy - -include $(BUILD_HOST_JAVA_LIBRARY) - -# -# Test targets -# - -LIB_JILL_UNIT_TESTS := $(LOCAL_BUILT_MODULE) - -local_unit_libs := $(call java-lib-files,core-libart-hostdex junit4-hostdex-jack,true) - -.PHONY: test-jill -test-jill-unit: PRIVATE_RUN_TESTS := ./run-jill-unit-tests -test-jill-unit: PRIVATE_PATH := $(LOCAL_PATH) -test-jill-unit: $(LIB_JILL_UNIT_TESTS) $(LOCAL_PATH)/run-jill-unit-tests $(local_unit_libs) $(JACK_JAR) $(JILL_JAR) - $(hide) cd $(PRIVATE_PATH) && $(PRIVATE_RUN_TESTS) com.android.jill.PreSubmitTests - -local_long_libs := $(call java-lib-files,core bouncycastle core-junit ext framework guava services \ - libarity google-play-services-first-party telephony-common,) -.PHONY: test-jill-long -test-jill-long: PRIVATE_RUN_TESTS := ./run-jill-unit-tests -test-jill-long: PRIVATE_PATH := $(LOCAL_PATH) -test-jill-long: $(LIB_JILL_UNIT_TESTS) $(LOCAL_PATH)/run-jill-unit-tests $(local_long_libs) $(JACK_JAR) $(JILL_JAR) - $(hide) cd $(PRIVATE_PATH) && $(PRIVATE_RUN_TESTS) com.android.jill.LongLastingTests - -.PHONY: test-jill-unit-all -test-jill-unit-all: PRIVATE_RUN_TESTS := ./run-jill-unit-tests -test-jill-unit-all: PRIVATE_PATH := $(LOCAL_PATH) -test-jill-unit-all: $(LIB_JILL_UNIT_TESTS) $(LOCAL_PATH)/run-jill-unit-tests $(local_unit_libs) $(local_long_libs) $(JACK_JAR) $(JILL_JAR) - $(hide) cd $(PRIVATE_PATH) && $(PRIVATE_RUN_TESTS) com.android.jill.AllTests - diff --git a/jill/MODULE_LICENSE_APACHE2 b/jill/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29..0000000 --- a/jill/MODULE_LICENSE_APACHE2 +++ /dev/null diff --git a/jill/NOTICE b/jill/NOTICE deleted file mode 100644 index 2bb9ad2..0000000 --- a/jill/NOTICE +++ /dev/null @@ -1,176 +0,0 @@ - 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/jill/README.eclipse b/jill/README.eclipse deleted file mode 100644 index 0d5bd71..0000000 --- a/jill/README.eclipse +++ /dev/null @@ -1,5 +0,0 @@ -To import the eclipse project you have to define one "Classpath variable" in -your workspace: -Window->Preferences->Java->Build Path->Classpath Variables -Create a variable named "ANDROID_BUILD_TOP" pointing to your android source -folder. diff --git a/jill/etc/manifest.txt b/jill/etc/manifest.txt deleted file mode 100644 index 6ca9f54..0000000 --- a/jill/etc/manifest.txt +++ /dev/null @@ -1 +0,0 @@ -Main-Class: com.android.jill.Main diff --git a/jill/jarjar-rules.txt b/jill/jarjar-rules.txt deleted file mode 100644 index ee6f403..0000000 --- a/jill/jarjar-rules.txt +++ /dev/null @@ -1 +0,0 @@ -rule org.objectweb.** com.android.jill.@0
\ No newline at end of file diff --git a/jill/jillstyle.xml b/jill/jillstyle.xml deleted file mode 100644 index 3940973..0000000 --- a/jill/jillstyle.xml +++ /dev/null @@ -1,314 +0,0 @@ -<?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 (?<!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="((//.*)|(\*.*))(?<!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> - - <!-- - - JAVADOC CHECKS - - --> - - <module name="JavadocType"> - <!-- Item 28 - Write doc comments for all exposed API elements. --> - <!-- Ensure all classes with visability greater than or equal to - protected have class level documentation. --> - <property name="scope" value="protected"/> - <property name="severity" value="error"/> - <!-- Style guide doesn't prohibit custom tags. Typos will be caught by other tools. --> - <property name="allowUnknownTags" value="true"/> - <property name="allowMissingParamTags" value="true"/> - <message key="javadoc.missing" - value="Missing a Javadoc comment."/> - </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/jill/rsc/META-INF/services/com.android.jill.api.JillProvider b/jill/rsc/META-INF/services/com.android.jill.api.JillProvider deleted file mode 100644 index ec6da23..0000000 --- a/jill/rsc/META-INF/services/com.android.jill.api.JillProvider +++ /dev/null @@ -1 +0,0 @@ -com.android.jill.api.impl.JillProviderImpl
\ No newline at end of file diff --git a/jill/run-jill-unit-tests b/jill/run-jill-unit-tests deleted file mode 100755 index f005752..0000000 --- a/jill/run-jill-unit-tests +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (C) 2014 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. - -#!/bin/bash - -CURRENT_DIR=$(dirname $0) - -if [ -z "$ANDROID_BUILD_TOP" ] || [ "${ANDROID_BUILD_TOP}+testDefinedButNotSet" = "testDefinedButNotSet" ]; -then - echo "Error: environment not set. Please run source build/core/envsetup.sh." - exit -fi - -REF_JAVA_COMPILER='javac' \ -java -cp ${ANDROID_BUILD_TOP}/out/host/common/obj/JAVA_LIBRARIES/libjackunittests_intermediates/javalib.jar:\ -${ANDROID_BUILD_TOP}/out/host/common/obj/JAVA_LIBRARIES/libjillunittests_intermediates/javalib.jar \ -org.junit.runner.JUnitCore $1 diff --git a/jill/src/com/android/jill/ContainerType.java b/jill/src/com/android/jill/ContainerType.java deleted file mode 100644 index edb6e6f..0000000 --- a/jill/src/com/android/jill/ContainerType.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2013 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.jill; - -/** - * Represents whether a file is a directory or a zip archive. - */ -public enum ContainerType { - DIR, ZIP; -}
\ No newline at end of file diff --git a/jill/src/com/android/jill/ExitStatus.java b/jill/src/com/android/jill/ExitStatus.java deleted file mode 100644 index 0ac0f0f..0000000 --- a/jill/src/com/android/jill/ExitStatus.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2013 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.jill; - -/** - * Jill exit status. - */ -public class ExitStatus { - /** - * Success. - */ - public static final int SUCCESS = 0; - /** - * Unknown error. - */ - public static final int FAILURE_UNKNOWN = 1; - /** - * Usage, syntax or configuration file error. - */ - public static final int FAILURE_USAGE = 2; - /** - * Jill internal error. - */ - public static final int FAILURE_INTERNAL = 3; -} diff --git a/jill/src/com/android/jill/IllegalOptionsException.java b/jill/src/com/android/jill/IllegalOptionsException.java deleted file mode 100644 index bc295c7..0000000 --- a/jill/src/com/android/jill/IllegalOptionsException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2013 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.jill; - -import javax.annotation.Nonnull; - -/** - * Thrown when a {@code Options} is not valid. - */ -public class IllegalOptionsException extends Exception { - private static final long serialVersionUID = 1L; - - public IllegalOptionsException() { - super(); - } - - public IllegalOptionsException(@Nonnull String message) { - super(message); - } - - public IllegalOptionsException(@Nonnull String message, @Nonnull Throwable cause) { - super(message, cause); - } - - public IllegalOptionsException(@Nonnull Throwable cause) { - super(cause); - } -} diff --git a/jill/src/com/android/jill/Jill.java b/jill/src/com/android/jill/Jill.java deleted file mode 100644 index 6e1e9ac..0000000 --- a/jill/src/com/android/jill/Jill.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2013 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.jill; - -import com.android.jill.frontend.java.JavaTransformer; -import com.android.jill.utils.FileUtils; -import com.android.sched.util.Version; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.jar.JarFile; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * Main class of Jill. - */ -public class Jill { - - @CheckForNull - private static Version version = null; - - public static void process(@Nonnull Options options) { - File binaryFile = options.getBinaryFile(); - JavaTransformer jt = new JavaTransformer(getVersion().getVersion(), options); - if (binaryFile.isFile()) { - if (FileUtils.isJavaBinaryFile(binaryFile)) { - List<File> javaBinaryFiles = new ArrayList<File>(); - javaBinaryFiles.add(binaryFile); - jt.transform(javaBinaryFiles); - } else if (FileUtils.isJarFile(binaryFile)) { - try { - jt.transform(new JarFile(binaryFile)); - } catch (IOException e) { - throw new JillException("Fails to create jar file " + binaryFile.getName(), e); - } - } else { - throw new JillException("Unsupported file type: " + binaryFile.getName()); - } - } else { - List<File> javaBinaryFiles = new ArrayList<File>(); - FileUtils.getJavaBinaryFiles(binaryFile, javaBinaryFiles); - jt.transform(javaBinaryFiles); - } - } - - @Nonnull - public static Version getVersion() { - if (version == null) { - try { - version = new Version("jill", Jill.class.getClassLoader()); - } catch (IOException e) { - System.err.println("Failed to read version properties file: " + e.getMessage()); - throw new AssertionError(); - } - } - - assert version != null; - return version; - } - -} diff --git a/jill/src/com/android/jill/JillException.java b/jill/src/com/android/jill/JillException.java deleted file mode 100644 index dcfd541..0000000 --- a/jill/src/com/android/jill/JillException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2013 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.jill; - -import javax.annotation.Nonnull; - -/** - * Thrown when something goes wrong into Jill. - */ -public class JillException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public JillException() { - super(); - } - - public JillException(@Nonnull String message) { - super(message); - } - - public JillException(@Nonnull String message, @Nonnull Throwable cause) { - super(message, cause); - } - - public JillException(@Nonnull Throwable cause) { - super(cause); - } -} diff --git a/jill/src/com/android/jill/Main.java b/jill/src/com/android/jill/Main.java deleted file mode 100644 index 172c355..0000000 --- a/jill/src/com/android/jill/Main.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2013 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.jill; - -import com.android.sched.util.config.cli.TokenIterator; -import com.android.sched.util.location.NoLocation; - -import org.kohsuke.args4j.CmdLineException; -import org.kohsuke.args4j.CmdLineParser; -import org.kohsuke.args4j.ParserProperties; - -import java.io.IOException; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; - -/** - * Main class for Jill tool. - */ -public class Main { - - public static void main(@Nonnull String[] args) { - Options options = null; - - try { - options = getOptions(args); - - if (options.askForHelp()) { - printUsage(System.out); - System.exit(ExitStatus.SUCCESS); - } - - if (options.askForVersion()) { - System.out.println("Jill"); - System.out.println("Version: " + Jill.getVersion().getVerboseVersion() + '.'); - System.exit(ExitStatus.SUCCESS); - } - - System.exit(runJill(System.err, options)); - - } catch (CmdLineException e) { - if (e.getMessage() != null) { - System.err.println(e.getMessage()); - } - CmdLineParser parser = e.getParser(); - if (parser != null) { - printUsage(System.out); - } else { - System.err.println("Try --help for help"); - } - System.exit(ExitStatus.FAILURE_USAGE); - } catch (IOException e) { - System.err.println(e.getMessage()); - - System.exit(ExitStatus.FAILURE_USAGE); - } - - System.exit(ExitStatus.FAILURE_UNKNOWN); - } - - protected static int runJill(@Nonnull PrintStream err, @Nonnull Options options) { - try { - Jill.process(options); - - } catch (JillException e) { - if (options != null) { - err.println("Binary transformation of " + options.getBinaryFile().getName() - + " failed."); - if (options.isVerbose()) { - e.printStackTrace(err); - } - } else { - err.println("Binary transformation failed."); - } - - return ExitStatus.FAILURE_INTERNAL; - } - return ExitStatus.SUCCESS; - } - - @Nonnull - public static Options getOptions(@Nonnull String[] args) throws CmdLineException, IOException { - Options options = new Options(); - - - CmdLineParser parser = - new CmdLineParser(options, ParserProperties.defaults().withUsageWidth(100)); - - TokenIterator iterator = new TokenIterator(new NoLocation(), args); - List<String> list = new ArrayList<String>(); - while (iterator.hasNext()) { - list.add(iterator.next()); - } - parser.parseArgument(list); - parser.stopOptionParsing(); - - try { - options.checkValidity(); - } catch (IllegalOptionsException e) { - throw new CmdLineException(parser, e.getMessage(), e); - } - - return options; - } - - protected static void printUsage(@Nonnull PrintStream printStream) { - CmdLineParser parser = - new CmdLineParser(new Options(), ParserProperties.defaults().withUsageWidth(100)); - printStream.println("Usage: <options> <class files to be transformed contained recursively" - + " in directories or in a zip/jar file>"); - printStream.println(); - printStream.println("Options:"); - parser.printUsage(printStream); - } -} diff --git a/jill/src/com/android/jill/Options.java b/jill/src/com/android/jill/Options.java deleted file mode 100644 index 420d364..0000000 --- a/jill/src/com/android/jill/Options.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2013 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.jill; - -import com.android.jill.utils.FileUtils; - -import org.kohsuke.args4j.Argument; -import org.kohsuke.args4j.Option; - -import java.io.File; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * Jill command line options. - */ -public class Options { - - @CheckForNull - @Argument(usage = "read command line from file", metaVar = "@<FILE>") - private File binaryFile; - - @Option(name = "--verbose", usage = "enable verbosity (default: false)") - private boolean verbose = false; - - @Option(name = "-h", aliases = "--help", usage = "display help") - protected boolean help; - - @CheckForNull - @Option(name = "--output", usage = "output file", metaVar = "FILE") - protected File output; - - @Option(name = "--version", usage = "display version") - protected boolean version; - - @Option(name = "--tolerant", usage = "be tolerant to malformed input (default: false)") - protected boolean tolerant = false; - - private final ContainerType outputContainer = ContainerType.ZIP; - - @Option(name = "--no-debug", usage = "disable debug info emission") - protected boolean disableEmitDebugInfo = false; - - @CheckForNull - private PrintStream err; - @CheckForNull - private File workingDir; - - public void checkValidity() throws IllegalOptionsException { - if (askForVersion() || askForHelp()) { - return; - } - - if (binaryFile != null) { - checkBinaryFileValidity(); - } else { - throw new IllegalOptionsException("Input file not provided"); - } - if (output != null) { - if (outputContainer == ContainerType.DIR) { - checkOutputDir(); - } - } else { - throw new IllegalOptionsException("Output directory not provided"); - } - } - - public void setBinaryFile(@Nonnull File binaryFile) { - this.binaryFile = binaryFile; - } - - public void setOutput(@Nonnull File output) { - this.output = output; - } - - @Nonnull - public File getOutput() { - assert output != null; - if (workingDir != null && !output.isAbsolute()) { - return new File(workingDir, output.getPath()); - } else { - return output; - } - } - - @Nonnull - public File getBinaryFile() { - assert binaryFile != null; - if (workingDir != null && !binaryFile.isAbsolute()) { - return new File(workingDir, binaryFile.getPath()); - } else { - return binaryFile; - } - } - - public boolean askForVersion() { - return version; - } - - public boolean askForHelp() { - return help; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - - public boolean isVerbose() { - return verbose; - } - - public void setTolerant(boolean tolerant) { - this.tolerant = tolerant; - } - - public boolean isTolerant() { - return tolerant; - } - - public boolean isEmitDebugInfo() { - return !disableEmitDebugInfo; - } - - public void setEmitDebugInfo(boolean emitDebugInfo) { - disableEmitDebugInfo = !emitDebugInfo; - } - - @Nonnull - public ContainerType getOutputContainer() { - return outputContainer; - } - - - public void setStandardError(@Nonnull PrintStream standardError) { - err = standardError; - } - - @CheckForNull - public PrintStream getStandardError() { - return err; - } - - public void setWorkingDirectory(@Nonnull File workingDir) { - this.workingDir = workingDir; - } - - private void checkBinaryFileValidity() throws IllegalOptionsException { - assert binaryFile != null; - - File binaryFile = getBinaryFile(); - - if (!binaryFile.exists()) { - throw new IllegalOptionsException(binaryFile.getName() + " does not exists."); - } - - if (binaryFile.isFile() && FileUtils.isJarFile(binaryFile)) { - return; - } - - if (binaryFile.isFile() && !FileUtils.isJavaBinaryFile(binaryFile) - && !FileUtils.isJarFile(binaryFile)) { - throw new IllegalOptionsException(binaryFile.getName() + " is not a supported binary file."); - } - - List<File> binaryFiles = new ArrayList<File>(); - FileUtils.getJavaBinaryFiles(binaryFile, binaryFiles); - if (binaryFiles.isEmpty()) { - System.err.println("Warning: Folder " + binaryFile.getName() - + " does not contains class files."); - } - } - - private void checkOutputDir() throws IllegalOptionsException { - assert output != null; - - File output = getOutput(); - - if (!output.exists()) { - throw new IllegalOptionsException(output.getName() + " does not exist."); - } - - if (!output.canRead() || !output.canWrite()) { - throw new IllegalOptionsException("The specified output folder '" - + output.getAbsolutePath() - + "' for jack files cannot be written to or read from."); - } - } -} diff --git a/jill/src/com/android/jill/api/impl/JillProviderImpl.java b/jill/src/com/android/jill/api/impl/JillProviderImpl.java deleted file mode 100644 index e3f3863..0000000 --- a/jill/src/com/android/jill/api/impl/JillProviderImpl.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2015 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.jill.api.impl; - -import com.android.jill.Jill; -import com.android.jill.api.ConfigNotSupportedException; -import com.android.jill.api.JillConfig; -import com.android.jill.api.JillProvider; -import com.android.jill.api.v01.Api01Config; -import com.android.jill.api.v01.Cli01Config; -import com.android.jill.api.v01.impl.Api01ConfigImpl; -import com.android.jill.api.v01.impl.Cli01ConfigImpl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * This class provides an implementation to build the requested {@link JillConfig} - */ -public class JillProviderImpl implements JillProvider { - - @Override - @Nonnull - @SuppressWarnings("unchecked") - public <T extends JillConfig> T createConfig(@Nonnull Class<T> cls) - throws ConfigNotSupportedException { - if (cls == Api01Config.class) { - return (T) new Api01ConfigImpl(); - } else if (cls == Cli01Config.class) { - return (T) new Cli01ConfigImpl(); - } - - throw new ConfigNotSupportedException(cls.getName() + " are not supported"); - } - - @Override - @Nonnull - public <T extends JillConfig> boolean isConfigSupported(@Nonnull Class<T> cls) { - return cls == Api01Config.class || cls == Cli01Config.class; - } - - @Override - @Nonnull - public Collection<Class<? extends JillConfig>> getSupportedConfigs() { - List<Class<? extends JillConfig>> result = new ArrayList<Class<? extends JillConfig>>(2); - result.add(Api01Config.class); - result.add(Cli01Config.class); - return result; - } - - @Override - @Nonnull - public String getTranslatorVersion() { - return Jill.getVersion().getVersion(); - } - - @Override - @Nonnull - public String getTranslatorReleaseName() { - return Jill.getVersion().getReleaseName(); - } - - @Override - public int getTranslatorReleaseCode() { - return Jill.getVersion().getReleaseCode(); - } - - @Override - public int getTranslatorSubReleaseCode() { - return Jill.getVersion().getSubReleaseCode(); - } - - @Override - @Nonnull - public SubReleaseKind getTranslatorSubReleaseKind() { - switch (Jill.getVersion().getSubReleaseKind()) { - case ENGINEERING: - return SubReleaseKind.ENGINEERING; - case PRE_ALPHA: - return SubReleaseKind.PRE_ALPHA; - case ALPHA: - return SubReleaseKind.ALPHA; - case BETA: - return SubReleaseKind.BETA; - case CANDIDATE: - return SubReleaseKind.CANDIDATE; - case RELEASE: - return SubReleaseKind.RELEASE; - default: - throw new AssertionError(Jill.getVersion().getSubReleaseKind().name()); - } - } - - @Override - @CheckForNull - public String getTranslatorBuildId() { - return Jill.getVersion().getBuildId(); - } - - @Override - @CheckForNull - public String getTranslatorSourceCodeBase() { - return Jill.getVersion().getCodeBase(); - } -}
\ No newline at end of file diff --git a/jill/src/com/android/jill/api/v01/impl/Api01ConfigImpl.java b/jill/src/com/android/jill/api/v01/impl/Api01ConfigImpl.java deleted file mode 100644 index 6aba8a0..0000000 --- a/jill/src/com/android/jill/api/v01/impl/Api01ConfigImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2015 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.jill.api.v01.impl; - -import com.android.jill.Jill; -import com.android.jill.Options; -import com.android.jill.api.v01.Api01Config; -import com.android.jill.api.v01.Api01TranslationTask; -import com.android.jill.api.v01.ConfigurationException; -import com.android.jill.utils.FileUtils; - -import java.io.File; - -import javax.annotation.Nonnull; - -/** - * This class provides the version 01 implementation of Jill API. - */ -public class Api01ConfigImpl implements Api01Config { - - @Nonnull - private final Options options; - - public Api01ConfigImpl() { - options = new Options(); - } - - @Override - @Nonnull - public Api01TranslationTask getTask() { - return new Api01TranslationTaskImpl(options); - } - - private static class Api01TranslationTaskImpl implements Api01TranslationTask { - - @Nonnull - private final Options options; - - public Api01TranslationTaskImpl(@Nonnull Options options) { - this.options = options; - } - - @Override - public void run() { - Jill.process(options); - } - - } - - @Override - public void setVerbose(boolean isVerbose) { - options.setVerbose(isVerbose); - } - - @Override - public void setInputJavaBinaryFile(@Nonnull File input) throws ConfigurationException { - if (!input.exists()) { - throw new ConfigurationException("Input file does not exist: " + input.getPath()); - } - if (!input.getAbsoluteFile().isFile()) { - throw new ConfigurationException("Input is not a file: " + input.getPath()); - } - if (!FileUtils.isJarFile(input)) { - throw new ConfigurationException("Unsupported file type: " + input.getName()); - } - options.setBinaryFile(input); - } - - @Override - public void setOutputJackFile(@Nonnull File outputJackFile) { - options.setOutput(outputJackFile); - } - - @Override - public void setDebugInfo(boolean debugInfo) { - options.setEmitDebugInfo(debugInfo); - } - -} diff --git a/jill/src/com/android/jill/api/v01/impl/Cli01ConfigImpl.java b/jill/src/com/android/jill/api/v01/impl/Cli01ConfigImpl.java deleted file mode 100644 index 186aff0..0000000 --- a/jill/src/com/android/jill/api/v01/impl/Cli01ConfigImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2015 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.jill.api.v01.impl; - -import com.android.jill.Main; -import com.android.jill.Options; -import com.android.jill.api.v01.Cli01Config; -import com.android.jill.api.v01.Cli01TranslationTask; -import com.android.jill.api.v01.ConfigurationException; - -import org.kohsuke.args4j.CmdLineException; - -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * This class provides the version 01 implementation of Jill CLI. - */ -public class Cli01ConfigImpl implements Cli01Config { - - @CheckForNull - private PrintStream standardError; - @CheckForNull - private File workingDirectory; - - @Override - @Nonnull - public Cli01TranslationTask getTask(@Nonnull String[] args) throws ConfigurationException { - try { - Options options = Main.getOptions(args); - options.setStandardError(standardError); - options.setWorkingDirectory(workingDirectory); - return new Cli01TranslationTaskImpl(options); - } catch (CmdLineException e) { - throw new ConfigurationException(e.getMessage(), e); - } catch (IOException e) { - throw new ConfigurationException(e.getMessage(), e); - } - } - - private static class Cli01TranslationTaskImpl extends Main implements Cli01TranslationTask { - - @Nonnull - private final Options options; - - public Cli01TranslationTaskImpl(@Nonnull Options options) { - this.options = options; - } - - @Override - public int run() { - PrintStream err = options.getStandardError(); - if (err == null) { - err = System.err; - } - return runJill(err, options); - } - - } - - @Override - public void setStandardError(@Nonnull PrintStream standardError) { - this.standardError = standardError; - } - - @Override - public void setStandardOutput(@Nonnull PrintStream standardOutput) { - } - - @Override - public void setWorkingDirectory(@Nonnull File workingDirectory) { - this.workingDirectory = workingDirectory; - } -} - diff --git a/jill/src/com/android/jill/backend/jayce/JayceOutputStream.java b/jill/src/com/android/jill/backend/jayce/JayceOutputStream.java deleted file mode 100644 index 885b3db..0000000 --- a/jill/src/com/android/jill/backend/jayce/JayceOutputStream.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.backend.jayce; - -import java.io.DataOutput; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -import javax.annotation.Nonnull; - -/** - * This class extends {@code DataOutputStream} to add uleb128 support for int and long. - */ -class JayceOutputStream implements DataOutput { - - @Nonnull - private final DataOutputStream out; - - public JayceOutputStream(@Nonnull OutputStream out) { - this.out = new DataOutputStream(out); - } - - /** - * Converts a string into its Java-style UTF-8 form. Java-style UTF-8 - * differs from normal UTF-8 in the handling of character '\0' and - * surrogate pairs. - * - * @param string {@code non-null;} the string to convert - * @return {@code non-null;} the UTF-8 bytes for it - */ - @Nonnull - private static byte[] stringToUtf8Bytes(@Nonnull String string) { - int len = string.length(); - byte[] bytes = new byte[len * 3]; // Avoid having to reallocate. - int outAt = 0; - - for (int i = 0; i < len; i++) { - char c = string.charAt(i); - if ((c != 0) && (c < 0x80)) { - bytes[outAt] = (byte) c; - outAt++; - } else if (c < 0x800) { - bytes[outAt] = (byte) (((c >> 6) & 0x1f) | 0xc0); - bytes[outAt + 1] = (byte) ((c & 0x3f) | 0x80); - outAt += 2; - } else { - bytes[outAt] = (byte) (((c >> 12) & 0x0f) | 0xe0); - bytes[outAt + 1] = (byte) (((c >> 6) & 0x3f) | 0x80); - bytes[outAt + 2] = (byte) ((c & 0x3f) | 0x80); - outAt += 3; - } - } - - byte[] result = new byte[outAt]; - System.arraycopy(bytes, 0, result, 0, outAt); - return result; - } - - @Override - public void write(int b) throws IOException { - out.write(b); - } - - @Override - public void write(byte[] b) throws IOException { - out.write(b); - } - - @Override - public void write(byte[] b, int off, int len) throws IOException { - out.write(b, off, len); - } - - @Override - public void writeBoolean(boolean v) throws IOException { - out.writeBoolean(v); - } - - @Override - public void writeByte(int v) throws IOException { - out.writeByte(v); - } - - @Override - public void writeShort(int v) throws IOException { - out.writeShort(v); - } - - @Override - public void writeChar(int v) throws IOException { - out.writeChar(v); - } - - /** - * Encode an integer value into uleb128 format and write it to the stream. - */ - @Override - public void writeInt(int v) throws IOException { - int remaining = v >> 7; - boolean hasMore = true; - int end = ((v & Integer.MIN_VALUE) == 0) ? 0 : -1; - - while (hasMore) { - hasMore = (remaining != end) || ((remaining & 1) != ((v >> 6) & 1)); - - writeByte((byte) ((v & 0x7f) | (hasMore ? 0x80 : 0))); - v = remaining; - remaining >>= 7; - } - } - /** - * Encode a long value into uleb128 format and write it to the stream. - */ - @Override - public void writeLong(long v) throws IOException { - long remaining = v >> 7; - boolean hasMore = true; - long end = ((v & Long.MIN_VALUE) == 0) ? 0 : -1; - - while (hasMore) { - hasMore = (remaining != end) || ((remaining & 1) != ((v >> 6) & 1)); - - writeByte((byte) ((v & 0x7f) | (hasMore ? 0x80 : 0))); - v = remaining; - remaining >>= 7; - } - } - - @Override - public void writeFloat(float v) throws IOException { - out.writeFloat(v); - } - - @Override - public void writeDouble(double v) throws IOException { - out.writeDouble(v); - } - - @Override - public void writeBytes(String s) throws IOException { - out.writeBytes(s); - } - - @Override - public void writeChars(String s) throws IOException { - out.writeChars(s); - } - - @Override - public void writeUTF(String s) throws IOException { - if (s == null) { - writeInt(-1); - } else { - byte[] utf8String = stringToUtf8Bytes(s); - writeInt(utf8String.length); - write(utf8String); - } - } - - public void flush() throws IOException { - out.flush(); - } - - public void close() throws IOException { - out.close(); - } -} diff --git a/jill/src/com/android/jill/backend/jayce/JaycePrettyWriter.java b/jill/src/com/android/jill/backend/jayce/JaycePrettyWriter.java deleted file mode 100644 index 10a3f0c..0000000 --- a/jill/src/com/android/jill/backend/jayce/JaycePrettyWriter.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.backend.jayce; - -import com.google.common.base.Strings; - -import java.io.IOException; -import java.io.OutputStream; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * Jayce pretty writer. - */ -public class JaycePrettyWriter extends JayceWriter { - - @Nonnull - private static final String LINE_SEPARATOR = System.getProperty("line.separator"); - - @Nonnull - private static final String INDENT_GRANULARITY = " "; - - @Nonnegative - private int indent = 0; - - public JaycePrettyWriter(@Nonnull OutputStream out) { - super(out); - } - - @Override - public void writeKeyword(@Nonnull Token token) throws IOException { - writeIdent(); - super.writeKeyword(token); - writeLn(); - } - - @Override - public void writeOpen() throws IOException { - writeIdent(); - super.writeOpen(); - writeLn(); - indentIn(); - } - - @Override - public void writeClose() throws IOException { - indentOut(); - writeIdent(); - super.writeClose(); - writeLn(); - } - - @Override - public void writeString(@CheckForNull String string) throws IOException { - writeIdent(); - super.writeString(string); - writeLn(); - } - - @Override - public void writeNull() throws IOException { - writeIdent(); - super.writeNull(); - } - - @Override - public void writeFileName(@CheckForNull String fileName) throws IOException { - writeIdent(); - super.writeFileName(fileName); - writeLn(); - } - - @Override - public void writeCurrentLineInfo(int lineNumber) - throws IOException { - writeIdent(); - super.writeCurrentLineInfo(lineNumber); - writeLn(); - } - - @Override - protected void writeSpace() throws IOException { - writeLn(); - } - - @Override - public void writeInt(int value) throws IOException { - writeIdent(); - super.writeInt(value); - } - - @Override - public void writeByte(byte value) throws IOException { - writeIdent(); - super.writeByte(value); - } - - @Override - public void writeChar(char value) throws IOException { - writeIdent(); - super.writeChar(value); - } - - @Override - public void writeShort(short value) throws IOException { - writeIdent(); - super.writeShort(value); - } - - @Override - public void writeLong(long value) throws IOException { - writeIdent(); - super.writeLong(value); - } - - @Override - public void writeFloat(float value) throws IOException { - writeIdent(); - super.writeFloat(value); - } - - @Override - public void writeDouble(double value) throws IOException { - writeIdent(); - super.writeDouble(value); - } - - private void writeIdent() throws IOException { - writers.peek().writeChars(Strings.repeat(INDENT_GRANULARITY, indent)); - } - - private void writeLn() throws IOException { - writers.peek().writeChars(LINE_SEPARATOR); - } - - private void indentIn() { - indent++; - } - - private void indentOut() { - indent--; - } -} diff --git a/jill/src/com/android/jill/backend/jayce/JayceWriter.java b/jill/src/com/android/jill/backend/jayce/JayceWriter.java deleted file mode 100644 index 07e418b..0000000 --- a/jill/src/com/android/jill/backend/jayce/JayceWriter.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.backend.jayce; - -import com.android.jill.utils.enums.DispatchKindIdHelper; -import com.android.jill.utils.enums.FieldRefKindIdHelper; -import com.android.jill.utils.enums.MethodKindIdHelper; -import com.android.jill.utils.enums.ReceiverKindIdHelper; -import com.android.jill.utils.enums.RetentionPolicyIdHelper; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.Stack; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * Jayce writer. - */ -public class JayceWriter { - - protected final Stack<JayceOutputStream> writers = new Stack<JayceOutputStream>(); - private final Stack<ByteArrayOutputStream> outputStreams = new Stack<ByteArrayOutputStream>(); - private final Stack<Integer> nodeCounters = new Stack<Integer>(); - - @Nonnull - private final List<String> currentCatchBlockList = new ArrayList<String>(); - - public JayceWriter(@Nonnull OutputStream out) { - writers.push(new JayceOutputStream(out)); - nodeCounters.push(Integer.valueOf(0)); - } - - public void writeBoolean(boolean value) throws IOException { - writers.peek().writeBoolean(value); - } - - private void writeIntInternal(int value) throws IOException { - writers.peek().writeInt(value); - } - - public void writeInt(int value) throws IOException { - writeIntInternal(value); - writeSpace(); - } - - public void writeTrimmedInt(int value) throws IOException { - writeIntInternal(value); - } - - private void writeLongInternal(long value) throws IOException { - writers.peek().writeLong(value); - } - - public void writeLong(long value) throws IOException { - writeLongInternal(value); - writeSpace(); - } - - public void writeByte(byte value) throws IOException { - writers.peek().writeByte(value); - writeSpace(); - } - - public void writeShort(short value) throws IOException { - writers.peek().writeShort(value); - writeSpace(); - } - - public void writeChar(char value) throws IOException { - writers.peek().writeChar(value); - writeSpace(); - } - - public void writeFloat(float value) throws IOException { - writeIntInternal(Float.floatToRawIntBits(value)); - writeSpace(); - } - - public void writeDouble(double value) throws IOException { - writeLongInternal(Double.doubleToRawLongBits(value)); - writeSpace(); - } - - public void writeKeyword(@Nonnull Token token) throws IOException { - writers.peek().writeByte(token.ordinal()); - nodeCounters.push(Integer.valueOf(nodeCounters.pop().intValue() + 1)); - } - - public void writeToken(@Nonnull Token token) throws IOException { - writers.peek().writeByte(token.ordinal()); - } - - @SuppressWarnings("unused") - public void writeOpen() throws IOException { - nodeCounters.push(Integer.valueOf(0)); - } - - public void writeClose() throws IOException { - writeToken(Token.RPARENTHESIS); - nodeCounters.pop(); - } - - public void writeOpenNodeList() { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - outputStreams.push(baos); - writers.push(new JayceOutputStream(baos)); - nodeCounters.push(Integer.valueOf(0)); - } - - public void writeCloseNodeList() throws IOException { - JayceOutputStream w = writers.pop(); - w.flush(); - ByteArrayOutputStream baos = outputStreams.pop(); - writeIntInternal(nodeCounters.pop().intValue()); - writers.peek().write(baos.toByteArray()); - w.close(); - writeToken(Token.RPARENTHESIS); - } - - public void writeRetentionPolicyEnum(@Nonnull Enum<?> enumValue) throws IOException { - writeByte(RetentionPolicyIdHelper.getId(enumValue)); - } - - public void writeFieldRefKindEnum(@Nonnull Enum<?> enumValue) throws IOException { - writeByte(FieldRefKindIdHelper.getId(enumValue)); - } - - public void writeMethodKindEnum(@Nonnull Enum<?> enumValue) throws IOException { - writeByte(MethodKindIdHelper.getId(enumValue)); - } - - public void writeReceiverKindEnum(@Nonnull Enum<?> enumValue) throws IOException { - writeByte(ReceiverKindIdHelper.getId(enumValue)); - } - - public void writeDispatchKindEnum(@Nonnull Enum<?> enumValue) throws IOException { - writeByte(DispatchKindIdHelper.getId(enumValue)); - } - - public void writeIds(@Nonnull List<String> list) throws IOException { - writeOpen(); - writeIntInternal(list.size()); - for (String id : list) { - writeId(id); - } - - writeClose(); - } - - public void writeCatchBlockIds(@Nonnull Set<String> list) throws IOException { - List<String> removedIds = new ArrayList<String>(currentCatchBlockList.size()); - List<String> addedIds = new ArrayList<String>(list.size()); - - for (String s : currentCatchBlockList) { - removedIds.add(s); - } - for (String s : list) { - addedIds.add(s); - } - - // intersection(current, list) - currentCatchBlockList.retainAll(list); - // current \ intersection(current, list) - removedIds.removeAll(currentCatchBlockList); - // list \ intersection(current, list) - addedIds.removeAll(currentCatchBlockList); - - int addedIdsSize = addedIds.size(); - int removedIdsSize = removedIds.size(); - - if (addedIdsSize > 0) { - writeOpenAddCatchBlockIds(); - writeTrimmedInt(addedIdsSize); - for (int i = 0; i < addedIdsSize; i++) { - writeString(addedIds.get(i)); - } - writeCloseCatchBlockIds(); - } - - if (removedIdsSize > 0) { - writeOpenRemoveCatchBlockIds(); - writeTrimmedInt(removedIdsSize); - for (int i = 0; i < removedIdsSize; i++) { - writeString(removedIds.get(i)); - } - writeCloseCatchBlockIds(); - } - currentCatchBlockList.addAll(addedIds); - } - - public void clearCatchBlockIds() { - currentCatchBlockList.clear(); - } - - public boolean isCurrentCatchBlockListEmpty() { - return currentCatchBlockList.isEmpty(); - } - - public void writeId(@CheckForNull String id) throws IOException { - writeStringInternal(id); - } - - private void writeStringInternal(@CheckForNull String string) throws IOException { - writers.peek().writeUTF(string); - } - - public void writeString(@CheckForNull String string) throws IOException { - writeStringInternal(string); - } - - public void writeNull() throws IOException { - writeToken(Token.NULL); - writeSpace(); - nodeCounters.push(Integer.valueOf(nodeCounters.pop().intValue() + 1)); - } - - @SuppressWarnings("unused") - protected void writeSpace() throws IOException{ - } - - public void writeFileName(@CheckForNull String fileName) throws IOException { - writeOpenFileName(); - writeStringInternal(fileName); - writeCloseFileName(); - } - - private void writeOpenFileName() throws IOException { - writeToken(Token.SHARP); - } - - @SuppressWarnings("unused") - private void writeCloseFileName() throws IOException{ - } - - public void writeCurrentLineInfo(int lineNumber) - throws IOException { - writeOpenLineInfo(); - writeIntInternal(lineNumber); - writeCloseLineInfo(); - } - - private void writeOpenLineInfo() throws IOException { - writeToken(Token.LBRACKET); - } - - @SuppressWarnings("unused") - private void writeCloseLineInfo() throws IOException{ - } - - private void writeOpenAddCatchBlockIds() throws IOException { - writeToken(Token.LCURLY_ADD); - } - - private void writeOpenRemoveCatchBlockIds() throws IOException { - writeToken(Token.LCURLY_REMOVE); - } - - @SuppressWarnings("unused") - private void writeCloseCatchBlockIds() throws IOException{ - } - - public void flush() throws IOException { - writers.peek().flush(); - } -} diff --git a/jill/src/com/android/jill/backend/jayce/Token.java b/jill/src/com/android/jill/backend/jayce/Token.java deleted file mode 100644 index d1113a5..0000000 --- a/jill/src/com/android/jill/backend/jayce/Token.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.backend.jayce; - - -import javax.annotation.CheckForNull; - -/** - * Tokens of Jayce. - */ -public enum Token { - - EOF(null), - - DOUBLE_QUOTE("\""), - - LPARENTHESIS("("), - RPARENTHESIS(")"), - SHARP("#"), - LBRACKET("["), - RBRACKET("]"), - LCURLY_ADD("{+"), - LCURLY_REMOVE("{-"), - RCURLY("}"), - NULL("null"), - - NUMBER_VALUE(null), - STRING_VALUE(null), - - ABSENT_ARRAY_DIMENSION("absent-array-dimension"), - ADD_OPERATION("+"), - ALLOC("alloc"), - AND_OPERATION("&&"), - ANNOTATION("annotation-literal"), - ANNOTATION_METHOD("annotation-method"), - ANNOTATION_TYPE("annotation"), - ARRAY_LENGTH("array-length"), - ARRAY_LITERAL("array-literal"), - ARRAY_REF("array-ref"), - ASG_ADD_OPERATION("+="), - ASG_BIT_AND_OPERATION("&="), - ASG_BIT_OR_OPERATION("|="), - ASG_BIT_XOR_OPERATION("^="), - ASG_CONCAT_OPERATION("asg-concat"), - ASG_DIV_OPERATION("/="), - ASG_MOD_OPERATION("%="), - ASG_MUL_OPERATION("*="), - ASG_OPERATION("="), - ASG_SHL_OPERATION("<<="), - ASG_SHR_OPERATION(">>="), - ASG_SHRU_OPERATION(">>>="), - ASG_SUB_OPERATION("-="), - ASSERT_STATEMENT("assert"), - BIT_AND_OPERATION("&"), - BIT_OR_OPERATION("|"), - BIT_XOR_OPERATION("^"), - BLOCK("block"), - BOOLEAN_LITERAL("boolean"), - BREAK_STATEMENT("break"), - BYTE_LITERAL("byte"), - CASE_STATEMENT("case"), - CATCH_BLOCK("catch"), - CHAR_LITERAL("char"), - CLASS("class"), - CLASS_LITERAL("class-literal"), - CONCAT_OPERATION("concat"), - CONDITIONAL_EXPRESSION ("?"), - CONSTRUCTOR ("constructor"), - CONTINUE_STATEMENT("continue"), - DIV_OPERATION("/"), - DO_STATEMENT("do"), - DOUBLE_LITERAL("double"), - DYNAMIC_CAST_OPERATION("cast"), - ENUM("enum"), - ENUM_FIELD("enum-field"), - ENUM_LITERAL("enum-literal"), - EQ_OPERATION("=="), - EXCEPTION_RUNTIME_VALUE("ex-runtime-value"), - EXPRESSION_STATEMENT("expression-statement"), - FIELD("field"), - FIELD_INITIALIZER("field-intializer"), - FIELD_REF("field-ref"), - FLOAT_LITERAL("float"), - FOR_STATEMENT("for"), - GENERIC_SIGNATURE("generic-signature"), - GOTO("goto"), - GTE_OPERATION(">="), - GT_OPERATION(">"), - IF_STATEMENT("if"), - INSTANCE_OF("instanceof"), - INT_LITERAL("int"), - INTERFACE("interface"), - LABELED_STATEMENT("label"), - LOCAL("local"), - LOCAL_REF("local-ref"), - LOCK("lock"), - LONG_LITERAL("long"), - LTE_OPERATION("<="), - LT_OPERATION("<"), - METHOD("method"), - METHOD_BODY("body"), - METHOD_CALL("call"), - METHOD_LITERAL("method-literal"), - MOD_OPERATION("%"), - MUL_OPERATION("*"), - MULTI_EXPRESSION("multi-expression"), - NAME_VALUE_PAIR("name-value-pair"), - NEQ_OPERATION("!="), - NATIVE_METHOD_BODY("native-body"), - NEW_ARRAY("new-array"), - NEW_INSTANCE("new"), - NULL_LITERAL("null-literal"), - OR_OPERATION("||"), - PARAMETER("parameter"), - PARAMETER_REF("parameter-ref"), - POSTFIX_DEC_OPERATION("postfix-dec"), - POSTFIX_INC_OPERATION("postfix-inc"), - PREFIX_BIT_NOT_OPERATION("~"), - PREFIX_DEC_OPERATION("prefix-dec"), - PREFIX_INC_OPERATION("prefix-inc"), - PREFIX_NEG_OPERATION("neg"), - PREFIX_NOT_OPERATION("not"), - RESERVED("reserved"), - REINTERPRETCAST_OPERATION("reinterpret-cast"), - RETURN_STATEMENT("return"), - SHL_OPERATION("<<"), - SHORT_LITERAL("short"), - SHR_OPERATION(">>"), - SHRU_OPERATION(">>>"), - SIMPLE_NAME("simple-name"), - SUB_OPERATION("-"), - STRING_LITERAL("string"), - SWITCH_STATEMENT("switch"), - SYNCHRONIZED_BLOCK("synchronized-block"), - THIS_REF("this"), - THIS_REF_TYPE_INFO("this-type-info"), - THROW_STATEMENT("throw"), - THROWN_EXCEPTION("thrown-exception"), - TRY_STATEMENT("try"), - UNLOCK("unlock"), - WHILE_STATEMENT("while") - ; - - @CheckForNull - private String label; - - private Token(@CheckForNull String text) { - this.label = text; - } - - public int getId() { - return ordinal(); - } - - @CheckForNull - public String getText() { - return label; - } -} diff --git a/jill/src/com/android/jill/frontend/java/AnnotationWriter.java b/jill/src/com/android/jill/frontend/java/AnnotationWriter.java deleted file mode 100644 index 4bb366e..0000000 --- a/jill/src/com/android/jill/frontend/java/AnnotationWriter.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.frontend.java; - -import com.android.jill.JillException; -import com.android.jill.backend.jayce.JayceWriter; -import com.android.jill.backend.jayce.Token; - -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.AnnotationNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; -import org.objectweb.asm.tree.MethodNode; - -import java.io.IOException; -import java.lang.annotation.Retention; -import java.util.List; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * Annotation transformer to Jayce. - */ -public class AnnotationWriter extends JillWriter { - - private static final String JAVA_LANG_SYNTHETIC = "Ljava/lang/Synthetic;"; - - public AnnotationWriter(@Nonnull JayceWriter writer, - @Nonnull SourceInfoWriter sourceInfoWriter) { - super(writer, sourceInfoWriter); - } - - public void writeRetentionPolicy(@Nonnull ClassNode cn) throws IOException { - assert AsmHelper.isAnnotation(cn); - - boolean retentionAnnotationFound = false; - - if (cn.visibleAnnotations != null) { - for (AnnotationNode anno : cn.visibleAnnotations) { - // Into Jayce, retention policy is written as a token - if (anno.desc.equals(Type.getType(Retention.class).getDescriptor())) { - assert anno.values.size() == 2; - assert anno.values.get(0) instanceof String; - assert ((String) anno.values.get(0)).equals("value"); - assert anno.values.get(1) instanceof String[]; - - retentionAnnotationFound = true; - - String[] enumAccess = (String[]) anno.values.get(1); - assert enumAccess.length == 2; - assert enumAccess[0].equals(Type.getType(java.lang.annotation.RetentionPolicy.class) - .getDescriptor()); - if (enumAccess[1].equals(RetentionPolicy.CLASS.toString())) { - writer.writeRetentionPolicyEnum(RetentionPolicy.CLASS); - } else if (enumAccess[1].equals(RetentionPolicy.SOURCE.toString())) { - writer.writeRetentionPolicyEnum(RetentionPolicy.SOURCE); - } else if (enumAccess[1].equals(RetentionPolicy.RUNTIME.toString())) { - writer.writeRetentionPolicyEnum(RetentionPolicy.RUNTIME); - } else { - throw new JillException("Unknown retention policy."); - } - break; - } - } - } - - if (!retentionAnnotationFound) { - // Default retention policy as specify in java doc of Annotation Type Retention. - writer.writeRetentionPolicyEnum(RetentionPolicy.CLASS); - } - } - - public void writeAnnotations(@Nonnull ClassNode cn) throws IOException { - writer.writeOpenNodeList(); - - writeAnnotations(cn.invisibleAnnotations, RetentionPolicy.CLASS); - writeAnnotations(cn.visibleAnnotations, RetentionPolicy.RUNTIME); - - writer.writeCloseNodeList(); - } - - public void writeAnnotations(@Nonnull MethodNode mn) throws IOException { - writer.writeOpenNodeList(); - - writeAnnotations(mn.invisibleAnnotations, RetentionPolicy.CLASS); - writeAnnotations(mn.visibleAnnotations, RetentionPolicy.RUNTIME); - - writer.writeCloseNodeList(); - } - - public void writeAnnotations(@Nonnull FieldNode fn) throws IOException { - writer.writeOpenNodeList(); - - writeAnnotations(fn.invisibleAnnotations, RetentionPolicy.CLASS); - writeAnnotations(fn.visibleAnnotations, RetentionPolicy.RUNTIME); - - writer.writeCloseNodeList(); - } - - public void writeAnnotations(@Nonnull MethodNode mn, @Nonnegative int parameterAnnotIdx) - throws IOException { - writer.writeOpenNodeList(); - - if (mn.invisibleParameterAnnotations != null) { - writeAnnotations(mn.invisibleParameterAnnotations[parameterAnnotIdx], RetentionPolicy.CLASS); - } - - if (mn.visibleParameterAnnotations != null) { - writeAnnotations(mn.visibleParameterAnnotations[parameterAnnotIdx], RetentionPolicy.RUNTIME); - } - - writer.writeCloseNodeList(); - } - - @Override - public void writeValue(Object value) throws IOException { - if (value instanceof String) { - writeValue((String) value); - } else if (value instanceof Integer) { - writeValue(((Integer) value).intValue()); - } else if (value instanceof Boolean) { - writeValue(((Boolean) value).booleanValue()); - } else if (value instanceof Byte) { - writeValue(((Byte) value).byteValue()); - } else if (value instanceof Character) { - writeValue(((Character) value).charValue()); - } else if (value instanceof Short) { - writeValue(((Short) value).shortValue()); - } else if (value instanceof Float) { - writeValue(((Float) value).floatValue()); - } else if (value instanceof Double) { - writeValue(((Double) value).doubleValue()); - } else if (value instanceof Long) { - writeValue(((Long) value).longValue()); - } else if (value instanceof String[]) { - writeValue((String[]) value); - } else if (value == null) { - writeValue(); - } else if (value instanceof Type) { - writeValue((Type) value); - } else if (value.getClass().isArray() && value.getClass().getComponentType().isPrimitive()) { - writeValue(convertPrimitiveArrayToObject(value)); - } else if (value instanceof List) { - writeValue(((List<?>) value).toArray()); - } else if (value instanceof AnnotationNode) { - AnnotationNode annotationNode = (AnnotationNode) value; - assert !JAVA_LANG_SYNTHETIC.equals(annotationNode.desc); - writeAnnotation(annotationNode, RetentionPolicy.UNKNOWN); - } else { - throw new JillException("Not yet supported."); - } - } - - private void writeAnnotations(@CheckForNull List<AnnotationNode> annotations, - @Nonnull RetentionPolicy retentionPolicy) throws IOException { - if (annotations != null) { - for (AnnotationNode anno : annotations) { - if (!JAVA_LANG_SYNTHETIC.equals(anno.desc)) { - writeAnnotation(anno, retentionPolicy); - } - } - } - } - - private void writeAnnotation(@Nonnull AnnotationNode anno, - @Nonnull RetentionPolicy retentionPolicy) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.ANNOTATION); - writer.writeOpen(); - writer.writeRetentionPolicyEnum(retentionPolicy); - writer.writeId(anno.desc); - writeNameValuePair(anno.values); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - private void writeNameValuePair(@CheckForNull List<Object> values) throws IOException { - writer.writeOpenNodeList(); - - if (values != null) { - for (int i = 0; i < values.size(); i += 2) { - String name = (String) values.get(i); - Object value = values.get(i + 1); - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.NAME_VALUE_PAIR); - writer.writeOpen(); - writer.writeString(name); - writeValue(value); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - } - - writer.writeCloseNodeList(); - } - - private void writeValue(@Nonnull String[] value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.ENUM_LITERAL); - writer.writeOpen(); - writer.writeId(value[0]); - writer.writeString(value[1]); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } -} diff --git a/jill/src/com/android/jill/frontend/java/AsmHelper.java b/jill/src/com/android/jill/frontend/java/AsmHelper.java deleted file mode 100644 index 7dd6442..0000000 --- a/jill/src/com/android/jill/frontend/java/AsmHelper.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.frontend.java; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; -import org.objectweb.asm.tree.IincInsnNode; -import org.objectweb.asm.tree.InnerClassNode; -import org.objectweb.asm.tree.MethodNode; -import org.objectweb.asm.tree.VarInsnNode; - -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * Asm helpers. - */ -public class AsmHelper { - - @Nonnull - private static final String JAVA_LANG_ENUM = "java/lang/Enum"; - - private static final int JAVA_ACCESS_FLAGS_MASK = 0xFFFF; - - @Nonnull - private static final String GENERIC_SIGNATURE_START = "<"; - @Nonnull - private static final String GENERIC_SIGNATURE_END = ">"; - - public static boolean isGenericSignature(@Nonnull ClassNode cn) { - if (cn.signature != null && cn.signature.contains(GENERIC_SIGNATURE_START)) { - assert cn.signature.contains(GENERIC_SIGNATURE_END); - return true; - } - return false; - } - - public static boolean isInterface(@Nonnull ClassNode cn) { - return ((cn.access & Opcodes.ACC_INTERFACE) != 0); - } - - public static boolean isAnnotation(@Nonnull ClassNode cn) { - return ((cn.access & Opcodes.ACC_ANNOTATION) != 0); - } - - public static boolean isEnum(@Nonnull ClassNode cn) { - if ((cn.access & Opcodes.ACC_ENUM) != 0) { - assert cn.superName != null; - return cn.superName.equals(JAVA_LANG_ENUM); - } - return false; - } - - public static boolean isStatic(@Nonnull FieldNode fn) { - return ((fn.access & Opcodes.ACC_STATIC) != 0); - } - - public static boolean isEnumField(@Nonnull FieldNode fn) { - return ((fn.access & Opcodes.ACC_ENUM) != 0); - } - - public static boolean isNative(@Nonnull MethodNode mn) { - return ((mn.access & Opcodes.ACC_NATIVE) != 0); - } - - public static boolean isAbstract(@Nonnull MethodNode mn) { - return ((mn.access & Opcodes.ACC_ABSTRACT) != 0); - } - - public static boolean isStatic(@Nonnull MethodNode mn) { - return ((mn.access & Opcodes.ACC_STATIC) != 0); - } - - public static boolean isPrivate(MethodNode mn) { - return ((mn.access & Opcodes.ACC_PRIVATE) != 0); - } - - public static boolean isConstructor(@Nonnull MethodNode mn) { - return mn.name.equals("<init>"); - } - - public static boolean isStaticInit(@Nonnull MethodNode mn) { - return mn.name.equals("<clinit>"); - } - - public static boolean isLocalStoreOf(@Nonnull AbstractInsnNode insn, @Nonnegative int localIdx) { - if (!(insn instanceof VarInsnNode) && !(insn instanceof IincInsnNode)) { - return false; - } - - switch (insn.getOpcode()) { - case Opcodes.IINC: { - return ((IincInsnNode) insn).var == localIdx; - } - case Opcodes.ASTORE: - case Opcodes.LSTORE: - case Opcodes.DSTORE: - case Opcodes.FSTORE: - case Opcodes.ISTORE: { - VarInsnNode varInsn = (VarInsnNode) insn; - return varInsn.var == localIdx; - } - default : { - return false; - } - } - } - - public static boolean isLocalLoadOf(@Nonnull AbstractInsnNode insn, @Nonnegative int localIdx) { - if (!(insn instanceof VarInsnNode) && !(insn instanceof IincInsnNode)) { - return false; - } - - switch (insn.getOpcode()) { - case Opcodes.IINC: { - return ((IincInsnNode) insn).var == localIdx; - } - case Opcodes.ALOAD: - case Opcodes.LLOAD: - case Opcodes.DLOAD: - case Opcodes.FLOAD: - case Opcodes.ILOAD: { - VarInsnNode varInsn = (VarInsnNode) insn; - return varInsn.var == localIdx; - } - default : { - return false; - } - } - } - - @Nonnull - public static String getDescriptor(@Nonnull ClassNode cn) { - return Type.getObjectType(cn.name).getDescriptor(); - } - - @Nonnull - public static List<String> getDescriptorsFromInternalNames( - @Nonnull List<String> internalInterfaceNames) { - List<String> interfaceDescs = new ArrayList<String>(internalInterfaceNames.size()); - - for (String internalName : internalInterfaceNames) { - interfaceDescs.add(Type.getObjectType(internalName).getDescriptor()); - } - - return interfaceDescs; - } - - @Nonnull - public static String getSourceName(@Nonnull ClassNode cn) { - if (cn.innerClasses != null) { - // Class is either an inner/local/anonymous or has inner classes - InnerClassNode matchingInnerClassNode = null; - for (InnerClassNode innerClassNode : cn.innerClasses) { - if (innerClassNode.name.equals(cn.name)) { - matchingInnerClassNode = innerClassNode; - break; - } - } - if (matchingInnerClassNode != null) { - return (matchingInnerClassNode.innerName != null) ? matchingInnerClassNode.innerName : ""; - } - } - int lastPathSeparatorIndex = cn.name.lastIndexOf('/'); - int startIndex = lastPathSeparatorIndex >= 0 ? lastPathSeparatorIndex + 1 : 0; - return cn.name.substring(startIndex); - } - - public static int getModifiers(@Nonnull ClassNode cn) { - int modifier = cn.access; - - if (cn.innerClasses != null) { - // Class is either an inner/local/anonymous or has inner classes - InnerClassNode matchingInnerClassNode = null; - for (InnerClassNode innerClassNode : cn.innerClasses) { - if (innerClassNode.name.equals(cn.name)) { - matchingInnerClassNode = innerClassNode; - break; - } - } - if (matchingInnerClassNode != null) { - modifier = matchingInnerClassNode.access; - } - } - // "super" is not relevant in dex format - modifier &= ~Opcodes.ACC_SUPER; - return (modifier & JAVA_ACCESS_FLAGS_MASK); - } - - public static int getModifiers(@Nonnull MethodNode mn) { - return (mn.access & JAVA_ACCESS_FLAGS_MASK); - } - - public static int getModifiers(@Nonnull FieldNode fn) { - return (fn.access & JAVA_ACCESS_FLAGS_MASK); - } - -} diff --git a/jill/src/com/android/jill/frontend/java/ClassNodeWriter.java b/jill/src/com/android/jill/frontend/java/ClassNodeWriter.java deleted file mode 100644 index d071e56..0000000 --- a/jill/src/com/android/jill/frontend/java/ClassNodeWriter.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.frontend.java; - -import com.android.jill.Options; -import com.android.jill.backend.jayce.JayceWriter; -import com.android.jill.backend.jayce.Token; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; -import org.objectweb.asm.tree.InnerClassNode; -import org.objectweb.asm.tree.LocalVariableNode; -import org.objectweb.asm.tree.MethodNode; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; - -/** - * Write class node of Asm into Jayce. - */ -public class ClassNodeWriter extends JillWriter { - - // Extra Jack modifiers - public static final int COMPILE_TIME_CONSTANT = 0x20000; - public static final int ANONYMOUS_TYPE = 0x40000; - - @Nonnull - private final AnnotationWriter annotWriter; - - private static final int ORDINAL_UNKNOWN = -1; - - @Nonnull - private final Options options; - - public ClassNodeWriter(@Nonnull JayceWriter writer, - @Nonnull SourceInfoWriter sourceInfoWriter, - @Nonnull Options options) { - super(writer, sourceInfoWriter); - annotWriter = new AnnotationWriter(writer, sourceInfoWriter); - this.options = options; - } - - public void write(@Nonnull ClassNode cn) throws IOException { - if (AsmHelper.isAnnotation(cn)) { - writeAnnotation(cn); - } else if (AsmHelper.isInterface(cn)) { - writeInterface(cn); - } else if (AsmHelper.isEnum(cn)){ - writeEnum(cn); - } else { - writeClass(cn); - } - } - - private void writeEnum(@Nonnull ClassNode cn) throws IOException { - sourceInfoWriter.writeDebugBegin(cn); - writer.writeKeyword(Token.ENUM); - writer.writeOpen(); - writer.writeInt(AsmHelper.getModifiers(cn)); - writer.writeId(AsmHelper.getDescriptor(cn)); - writer.writeId(cn.superName != null ? Type.getObjectType(cn.superName).getDescriptor() : null); - writer.writeIds(AsmHelper.getDescriptorsFromInternalNames(cn.interfaces)); - writeEnclosingInformation(cn); - writingInners(cn); - writeEnumFields(cn); - writeMethods(cn); - annotWriter.writeAnnotations(cn); - writer.writeOpenNodeList(); // Markers - writeGenericSignatureMarker(cn); - writeSourceNameMarker(cn); - writeThisRefTypeInfoMarker(cn); - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(cn); - writer.writeClose(); - } - - private void writeClass(@Nonnull ClassNode cn) throws IOException { - sourceInfoWriter.writeDebugBegin(cn); - writer.writeKeyword(Token.CLASS); - writer.writeOpen(); - writer.writeInt( - AsmHelper.getModifiers(cn) | (AsmHelper.getSourceName(cn).equals("") ? ANONYMOUS_TYPE : 0)); - writer.writeId(AsmHelper.getDescriptor(cn)); - writer.writeId(cn.superName != null ? Type.getObjectType(cn.superName).getDescriptor() : null); - writer.writeIds(AsmHelper.getDescriptorsFromInternalNames(cn.interfaces)); - writeEnclosingInformation(cn); - writingInners(cn); - writeFields(cn); - writeMethods(cn); - annotWriter.writeAnnotations(cn); - writer.writeOpenNodeList(); // Markers - writeGenericSignatureMarker(cn); - writeSourceNameMarker(cn); - writeThisRefTypeInfoMarker(cn); - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(cn); - writer.writeClose(); - } - - private void writeInterface(@Nonnull ClassNode cn) throws IOException { - assert isPackageInfoIfNotAbstract(cn); - sourceInfoWriter.writeDebugBegin(cn); - writer.writeKeyword(Token.INTERFACE); - writer.writeOpen(); - writer.writeInt(AsmHelper.getModifiers(cn) | Opcodes.ACC_ABSTRACT); - writer.writeId(AsmHelper.getDescriptor(cn)); - writer.writeIds(AsmHelper.getDescriptorsFromInternalNames(cn.interfaces)); - writeEnclosingInformation(cn); - writingInners(cn); - writeFields(cn); - writeMethods(cn); - annotWriter.writeAnnotations(cn); - writer.writeOpenNodeList(); // Markers - writeGenericSignatureMarker(cn); - writeSourceNameMarker(cn); - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(cn); - writer.writeClose(); - } - - private boolean isPackageInfoIfNotAbstract(@Nonnull ClassNode cn) { - return !(((AsmHelper.getModifiers(cn) & Opcodes.ACC_ABSTRACT) == 0) - && !cn.name.endsWith("package-info")); - } - - private void writeAnnotation(@Nonnull ClassNode cn) throws IOException { - sourceInfoWriter.writeDebugBegin(cn); - writer.writeKeyword(Token.ANNOTATION_TYPE); - writer.writeOpen(); - annotWriter.writeRetentionPolicy(cn); - writer.writeInt(AsmHelper.getModifiers(cn)); - writer.writeId(AsmHelper.getDescriptor(cn)); - writer.writeIds(AsmHelper.getDescriptorsFromInternalNames(cn.interfaces)); - writeEnclosingInformation(cn); - writingInners(cn); - writeFields(cn); - writeAnnotationMethods(cn); - annotWriter.writeAnnotations(cn); - writer.writeOpenNodeList(); // Markers - writeGenericSignatureMarker(cn); - writeSourceNameMarker(cn); - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(cn); - writer.writeClose(); - } - - private void writeThisRefTypeInfoMarker(@Nonnull ClassNode cn) throws IOException { - String thisRefSignature = null; - for (MethodNode mn : cn.methods) { - if (!AsmHelper.isStatic(mn) && mn.localVariables != null) { - for (LocalVariableNode lvn : mn.localVariables) { - if (lvn.name.equals("this")) { - if (thisRefSignature == null) { - thisRefSignature = lvn.signature; - } else { - assert thisRefSignature.equals(lvn.signature); - } - } - } - } - } - if (thisRefSignature != null) { - writer.writeKeyword(Token.THIS_REF_TYPE_INFO); - writer.writeOpen(); - writer.writeString(thisRefSignature); - writer.writeClose(); - } - } - - private void writeGenericSignatureMarker(@Nonnull ClassNode cn) throws IOException { - if (AsmHelper.isGenericSignature(cn)) { - writer.writeKeyword(Token.GENERIC_SIGNATURE); - writer.writeOpen(); - writer.writeString(cn.signature); - writer.writeClose(); - } - } - - private void writeSourceNameMarker(@Nonnull ClassNode cn) throws IOException { - writer.writeKeyword(Token.SIMPLE_NAME); - writer.writeOpen(); - writer.writeString(AsmHelper.getSourceName(cn)); - writer.writeClose(); - } - - private void writeGenericSignatureMarker(@Nonnull FieldNode fn) throws IOException { - if (fn.signature != null) { - writer.writeKeyword(Token.GENERIC_SIGNATURE); - writer.writeOpen(); - writer.writeString(fn.signature); - writer.writeClose(); - } - } - - private void writeFields(@Nonnull ClassNode cn) throws IOException { - writer.writeOpenNodeList(); - for (FieldNode fn : cn.fields) { - writeField(cn, fn, Token.FIELD); - } - writer.writeCloseNodeList(); - } - - private void writeEnumFields(@Nonnull ClassNode cn) throws IOException { - writer.writeOpenNodeList(); - for (FieldNode fn : cn.fields) { - if (!AsmHelper.isEnumField(fn)) { - writeField(cn, fn, Token.FIELD); - } else { - writeField(cn, fn, Token.ENUM_FIELD); - } - } - writer.writeCloseNodeList(); - } - - private void writeField(@Nonnull ClassNode cn, @Nonnull FieldNode fn, @Nonnull Token kind) - throws IOException { - assert kind == Token.FIELD || kind == Token.ENUM_FIELD; - sourceInfoWriter.writeDebugBegin(cn, fn); - writer.writeKeyword(kind); - writer.writeOpen(); - writer.writeInt(fn.value != null ? AsmHelper.getModifiers(fn) | COMPILE_TIME_CONSTANT - : AsmHelper.getModifiers(fn)); - writer.writeString(fn.desc); - writer.writeString(fn.name); - writeFieldValue(cn, fn); - if (kind == Token.ENUM_FIELD) { - writer.writeInt(ORDINAL_UNKNOWN); - } - annotWriter.writeAnnotations(fn); - writer.writeOpenNodeList(); // Markers - writeGenericSignatureMarker(fn); - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(cn, fn); - writer.writeClose(); - } - - private void writeFieldValue(@Nonnull ClassNode cn, @Nonnull FieldNode fn) throws IOException { - if (AsmHelper.isStatic(fn)) { - Object value = fn.value; - if (value instanceof Integer) { - int intValue = ((Integer) value).intValue(); - if (fn.desc.equals("Z")) { - writeValue(intValue != 0); - } else if (fn.desc.equals("B")) { - writeValue((byte) intValue); - } else if (fn.desc.equals("C")) { - writeValue((char) intValue); - } else if (fn.desc.equals("S")) { - writeValue((short) intValue); - } else { - writeValue(intValue); - } - } else if (value instanceof Long) { - writeValue(((Long) value).longValue()); - } else if (value instanceof Float) { - writeValue(((Float) value).floatValue()); - } else if (value instanceof Double) { - writeValue(((Double) value).doubleValue()); - } else if (value instanceof String) { - writeValue((String) value); - } else { - writer.writeNull(); // No initial value - } - } else { - writer.writeNull(); // No initial value - } - } - - private void writeAnnotationMethods(@Nonnull ClassNode cn) throws IOException { - assert AsmHelper.isAnnotation(cn); - - writer.writeOpenNodeList(); - - for (MethodNode mn : cn.methods) { - new MethodBodyWriter(writer, annotWriter, cn, mn, sourceInfoWriter, options).write(); - } - writer.writeCloseNodeList(); - } - - private void writeMethods(@Nonnull ClassNode cn) throws IOException { - writer.writeOpenNodeList(); - - for (MethodNode mn : cn.methods) { - new MethodBodyWriter(writer, annotWriter, cn, mn, sourceInfoWriter, options).write(); - } - writer.writeCloseNodeList(); - } - - private void writingInners(@Nonnull ClassNode cn) throws IOException { - List<InnerClassNode> innerClasses = cn.innerClasses; - List<String> innerIds = new ArrayList<String>(); - - if (innerClasses != null) { - // Class is either an inner/local/anonymous or has inner classes - InnerClassNode matchingInnerClassNode = null; - for (InnerClassNode innerClassNode : innerClasses) { - if (innerClassNode.outerName != null && innerClassNode.outerName.equals(cn.name) - && innerClassNode.name != null) { - innerIds.add(Type.getObjectType(innerClassNode.name).getDescriptor()); - } - } - } - writer.writeIds(innerIds); - } - - private void writeEnclosingInformation(@Nonnull ClassNode cn) throws IOException { - List<InnerClassNode> innerClasses = cn.innerClasses; - if (innerClasses != null) { - // Class is either an inner/local/anonymous or has inner classes - InnerClassNode matchingInnerClassNode = null; - for (InnerClassNode innerClassNode : innerClasses) { - if (innerClassNode.name.equals(cn.name)) { - matchingInnerClassNode = innerClassNode; - break; - } - } - if (matchingInnerClassNode != null) { - // Inner, anonymous or local) - if (cn.outerMethod != null) { - // Local or anonymous in method - assert cn.outerMethodDesc != null; - if (!(AsmHelper.isInterface(cn) || AsmHelper.isAnnotation(cn))) { - // EnclosingClass - writer.writeId(Type.getObjectType(cn.outerClass).getDescriptor()); // EnclosingType - writer.writeId(Type.getObjectType(cn.outerClass).getDescriptor()); - writer.writeId(cn.outerMethod + cn.outerMethodDesc); // EnclosingMethod - } else { - writer.writeId(null); // EnclosingType - } - } else { - // Inner or anonymous as init of field - String outerClassName = - (cn.outerClass != null) ? (cn.outerClass) : (matchingInnerClassNode.outerName); - if (outerClassName != null) { - writer.writeId(Type.getObjectType(outerClassName).getDescriptor()); // EnclosingType - } else { - writer.writeId(null); // EnclosingType unknown - } - if (!(AsmHelper.isInterface(cn) || AsmHelper.isAnnotation(cn))) { - writer.writeId(null); // EnclosingMethodClass - writer.writeId(null); // EnclosingMethod - } - } - } else { - writer.writeId(null); // EnclosingType - if (!(AsmHelper.isInterface(cn) || AsmHelper.isAnnotation(cn))) { - writer.writeId(null); // EnclosingMethodClass - writer.writeId(null); // EnclosingMethod - } - } - } else { - writer.writeId(null); // EnclosingType - if (!(AsmHelper.isInterface(cn) || AsmHelper.isAnnotation(cn))) { - writer.writeId(null); // EnclosingMethodClass - writer.writeId(null); // EnclosingMethod - } - } - } - -} diff --git a/jill/src/com/android/jill/frontend/java/DuplicateJackFileException.java b/jill/src/com/android/jill/frontend/java/DuplicateJackFileException.java deleted file mode 100644 index 55239a2..0000000 --- a/jill/src/com/android/jill/frontend/java/DuplicateJackFileException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.frontend.java; - -import javax.annotation.Nonnull; - -/** - * Thrown when there are 2 Jack files with the same path. - */ -public class DuplicateJackFileException extends Exception { - private static final long serialVersionUID = 1L; - - public DuplicateJackFileException() { - super(); - } - - public DuplicateJackFileException(@Nonnull String message) { - super(message); - } -} diff --git a/jill/src/com/android/jill/frontend/java/JavaTransformer.java b/jill/src/com/android/jill/frontend/java/JavaTransformer.java deleted file mode 100644 index ad6a6f0..0000000 --- a/jill/src/com/android/jill/frontend/java/JavaTransformer.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.frontend.java; - -import com.android.jill.ContainerType; -import com.android.jill.JillException; -import com.android.jill.Options; -import com.android.jill.backend.jayce.JayceWriter; -import com.android.jill.utils.FileUtils; - -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.tree.ClassNode; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Enumeration; -import java.util.List; -import java.util.Properties; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * Transforms java binary files into jayce. - */ -public class JavaTransformer { - - @Nonnull - private static final String LIB_MAJOR_VERSION = "1"; - - @Nonnull - private static final String LIB_MINOR_VERSION = "1"; - - @Nonnull - private static final String JAYCE_MAJOR_VERSION = "2"; - - @Nonnull - private static final String JAYCE_MINOR_VERSION = "15"; - - @Nonnull - private static final String KEY_LIB_MAJOR_VERSION = "lib.version.major"; - - @Nonnull - private static final String KEY_LIB_MINOR_VERSION = "lib.version.minor"; - - @Nonnull - private static final String KEY_LIB_EMITTER = "lib.emitter"; - - @Nonnull - private static final String KEY_LIB_EMITTER_VERSION = "lib.emitter.version"; - - @Nonnull - private static final String KEY_JAYCE = "jayce"; - - @Nonnull - private static final String KEY_JAYCE_MAJOR_VERSION = "jayce.version.major"; - - @Nonnull - private static final String KEY_JAYCE_MINOR_VERSION = "jayce.version.minor"; - - @Nonnull - private static final String JACK_LIBRARY_PROPERTIES = "jack.properties"; - - @Nonnull - private final String version; - - private final Options options; - - @Nonnull - private static final String JAYCE_FILE_EXTENSION = ".jayce"; - - @Nonnull - private static final String JAYCE_PREFIX_INTO_LIB = "jayce"; - - @Nonnull - private static final char TYPE_NAME_SEPARATOR = '/'; - - @Nonnull - private final Properties jackLibraryProperties; - - public JavaTransformer(@Nonnull String version, @Nonnull Options options) { - this.version = version; - this.options = options; - jackLibraryProperties = new Properties(); - jackLibraryProperties.put(KEY_LIB_EMITTER, "jill"); - jackLibraryProperties.put(KEY_LIB_EMITTER_VERSION, version); - jackLibraryProperties.put(KEY_LIB_MAJOR_VERSION, LIB_MAJOR_VERSION); - jackLibraryProperties.put(KEY_LIB_MINOR_VERSION, LIB_MINOR_VERSION); - } - - public void transform(@Nonnull List<File> javaBinaryFiles) { - ZipOutputStream zos = null; - try { - if (options.getOutputContainer() == ContainerType.ZIP) { - zos = new ZipOutputStream(new FileOutputStream(options.getOutput())); - for (File fileToTransform : javaBinaryFiles) { - FileInputStream fis = new FileInputStream(fileToTransform); - try { - transformToZip(fis, zos, null); - } catch (DuplicateJackFileException e) { - System.err.println(e.getMessage()); - } finally { - fis.close(); - } - } - } else { - for (File fileToTransform : javaBinaryFiles) { - FileInputStream fis = new FileInputStream(fileToTransform); - try { - transformToDir(fis, options.getOutput()); - } catch (DuplicateJackFileException e) { - System.err.println(e.getMessage()); - } finally { - fis.close(); - } - } - } - dumpJackLibraryProperties(zos); - } catch (IOException e) { - throw new JillException("Transformation failure.", e); - } finally { - if (zos != null) { - try { - zos.close(); - } catch (IOException e) { - throw new JillException("Error closing zip.", e); - } - } - } - } - - public void transform(@Nonnull JarFile jarFile) { - ZipOutputStream zos = null; - try { - if (options.getOutputContainer() == ContainerType.ZIP) { - zos = new ZipOutputStream(new FileOutputStream(options.getOutput())); - } - transformJavaFiles(jarFile, zos); - dumpJackLibraryProperties(zos); - } catch (Exception e) { - throw new JillException("Failed to transform " + jarFile.getName(), e); - } finally { - if (zos != null) { - try { - zos.close(); - } catch (IOException e) { - throw new JillException("Error closing zip.", e); - } - } - } - } - - private void dumpJackLibraryProperties(@CheckForNull ZipOutputStream zos) { - if (zos != null) { - dumpPropertiesToZip(zos, jackLibraryProperties); - } else { - dumpPropertiesToFile(new File(options.getOutput(), JACK_LIBRARY_PROPERTIES), - jackLibraryProperties); - } - } - - private void dumpPropertiesToZip(@Nonnull ZipOutputStream zos, - @Nonnull Properties libraryProperties) { - try { - ZipEntry entry = new ZipEntry(JACK_LIBRARY_PROPERTIES); - zos.putNextEntry(entry); - libraryProperties.store(zos, "Library Properties"); - } catch (IOException e) { - throw new JillException("Error writing '" + JACK_LIBRARY_PROPERTIES + "' to output zip", e); - } - } - - private void dumpPropertiesToFile(@Nonnull File outputFile, - @Nonnull Properties libraryProperties) { - File outputDir = options.getOutput(); - File libraryPropertiesFile = new File(outputDir, JACK_LIBRARY_PROPERTIES); - FileOutputStream fos = null; - try { - fos = new FileOutputStream(libraryPropertiesFile); - libraryProperties.store(fos, "Library Properties"); - } catch (IOException e) { - throw new JillException( - "Error writing '" + JACK_LIBRARY_PROPERTIES + "' to " + outputFile.getAbsolutePath(), e); - } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - throw new JillException("Error closing output " + outputFile.getAbsolutePath(), e); - } - } - } - } - - private void transformJavaFiles(@Nonnull JarFile jarFile, @CheckForNull ZipOutputStream zos) - throws IOException { - final Enumeration<JarEntry> entries = jarFile.entries(); - while (entries.hasMoreElements()) { - final JarEntry entry = entries.nextElement(); - String name = entry.getName(); - if (FileUtils.isJavaBinaryFile(name)) { - JarEntry fileEntry = jarFile.getJarEntry(name); - if (!fileEntry.isDirectory()) { - InputStream is = jarFile.getInputStream(fileEntry); - try { - if (zos != null) { - assert options.getOutputContainer() == ContainerType.ZIP; - transformToZip(is, zos, jarFile); - } else { - assert options.getOutputContainer() == ContainerType.DIR; - transformToDir(is, options.getOutput()); - } - } catch (DuplicateJackFileException e) { - System.err.println(e.getMessage()); - } - } - } - } - } - - private void transformToZip(@Nonnull InputStream is, @Nonnull ZipOutputStream zipOutputStream, - @CheckForNull JarFile jarFile) throws IOException, DuplicateJackFileException { - ClassNode cn = getClassNode(is); - String filePath = getFilePath(cn.name); - if (jarFile != null && jarFile.getEntry(filePath) != null) { - throw new DuplicateJackFileException("Jack file '" + filePath - + "' was already copied as a resource to archive '" + options.getOutput() - + "' and thus won't be retransformed from class file."); - } - try { - ZipEntry entry = new ZipEntry(filePath); - zipOutputStream.putNextEntry(entry); - transform(cn, zipOutputStream); - } catch (IOException e) { - throw new JillException("Error writing to output zip", e); - } - } - - private void transformToDir(@Nonnull InputStream is, @Nonnull File outputDir) - throws IOException, DuplicateJackFileException { - ClassNode cn = getClassNode(is); - String filePath = getFilePath(cn.name); - - File outputFile = new File(outputDir, filePath); - if (outputFile.exists()) { - throw new DuplicateJackFileException("Jack file '" + outputFile.getAbsolutePath() - + "' was already copied as a resource and thus won't be retransformed from class file."); - } - FileOutputStream fos = null; - try { - createParentDirectories(outputFile); - fos = new FileOutputStream(outputFile); - transform(cn, fos); - } catch (IOException e) { - throw new JillException("Unable to create output file " + outputFile.getName(), e); - } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - throw new JillException("Error closing output " + outputFile.getAbsolutePath(), e); - } - } - } - } - - private void transform(@Nonnull ClassNode cn, @Nonnull OutputStream os) throws IOException { - - JayceWriter writer = createWriter(os); - - ClassNodeWriter asm2jayce = - new ClassNodeWriter(writer, new SourceInfoWriter(writer), options); - - asm2jayce.write(cn); - - writer.flush(); - } - - private void createParentDirectories(File outputFile) throws IOException { - File parentFile = outputFile.getParentFile(); - if (!parentFile.exists() && !parentFile.mkdirs()) { - throw new IOException("Could not create directory \"" + parentFile.getName() + "\""); - } - } - - private JayceWriter createWriter(@Nonnull OutputStream os) { - JayceWriter writer = new JayceWriter(os); - setJayceProperties(); - return writer; - } - - @Nonnull - private static String getFilePath(@Nonnull String typeBinaryName) { - return JAYCE_PREFIX_INTO_LIB + File.separatorChar - + typeBinaryName.replace(TYPE_NAME_SEPARATOR, File.separatorChar) + JAYCE_FILE_EXTENSION; - } - - @Nonnull - private ClassNode getClassNode(@Nonnull InputStream is) throws IOException { - ClassReader cr = new ClassReader(is); - ClassNode cn = new ClassNode(); - cr.accept(cn, ClassReader.SKIP_FRAMES - | (options.isEmitDebugInfo() ? 0 : ClassReader.SKIP_DEBUG)); - return cn; - } - - private void setJayceProperties() { - jackLibraryProperties.put(KEY_JAYCE, String.valueOf(true)); - jackLibraryProperties.put(KEY_JAYCE_MAJOR_VERSION, JAYCE_MAJOR_VERSION); - jackLibraryProperties.put(KEY_JAYCE_MINOR_VERSION, JAYCE_MINOR_VERSION); - } -} diff --git a/jill/src/com/android/jill/frontend/java/JillWriter.java b/jill/src/com/android/jill/frontend/java/JillWriter.java deleted file mode 100644 index eeb500e..0000000 --- a/jill/src/com/android/jill/frontend/java/JillWriter.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.frontend.java; - -import com.android.jill.JillException; -import com.android.jill.backend.jayce.JayceWriter; -import com.android.jill.backend.jayce.Token; - -import org.objectweb.asm.Type; - -import java.io.IOException; -import java.lang.reflect.Array; - -import javax.annotation.Nonnull; - -/** - * {@code JillWriter}s are helper class build around a Jayce writer to realize - * Jayce file output. - */ -public abstract class JillWriter { - - @Nonnull - protected final JayceWriter writer; - - @Nonnull - protected final SourceInfoWriter sourceInfoWriter; - - public JillWriter(@Nonnull JayceWriter writer, - @Nonnull SourceInfoWriter sourceInfoWriter) { - this.writer = writer; - this.sourceInfoWriter = sourceInfoWriter; - } - - protected void writeValue(Object value) throws IOException{ - if (value == null) { - writer.writeNull(); - } else if (value instanceof Boolean) { - writeValue(((Boolean) value).booleanValue()); - } else if (value instanceof Integer) { - writeValue(((Integer) value).intValue()); - } else if (value instanceof Long){ - writeValue(((Long) value).longValue()); - } else if (value instanceof Float) { - writeValue(((Float) value).floatValue()); - } else if (value instanceof Double) { - writeValue(((Double) value).doubleValue()); - } else if (value instanceof String) { - writeValue((String) value); - } else if (value instanceof Type) { - writeValue((Type) value); - } else { - throw new JillException("Unsupported object value."); - } - } - - protected void writeValue(@Nonnull String value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.STRING_LITERAL); - writer.writeOpen(); - writer.writeString(value); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - protected void writeValue(boolean value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.BOOLEAN_LITERAL); - writer.writeOpen(); - writer.writeBoolean(value); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - protected void writeValue(byte value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.BYTE_LITERAL); - writer.writeOpen(); - writer.writeByte(value); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - protected void writeValue(char value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.CHAR_LITERAL); - writer.writeOpen(); - writer.writeChar(value); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - protected void writeValue(short value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.SHORT_LITERAL); - writer.writeOpen(); - writer.writeShort(value); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - protected void writeValue(int value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.INT_LITERAL); - writer.writeOpen(); - writer.writeInt(value); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - protected void writeValue(float value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.FLOAT_LITERAL); - writer.writeOpen(); - writer.writeFloat(value); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - protected void writeValue(double value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.DOUBLE_LITERAL); - writer.writeOpen(); - writer.writeDouble(value); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - protected void writeValue(long value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.LONG_LITERAL); - writer.writeOpen(); - writer.writeLong(value); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - protected void writeValue() throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.NULL_LITERAL); - writer.writeOpen(); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - protected void writeValue(@Nonnull Type value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.CLASS_LITERAL); - writer.writeOpen(); - writer.writeId(value.getDescriptor()); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - protected void writeValue(@Nonnull Object[] value) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.ARRAY_LITERAL); - writer.writeOpen(); - writer.writeOpenNodeList(); - for (int j = 0; j < value.length; ++j) { - writeValue(value[j]); - } - writer.writeCloseNodeList(); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - @Nonnull - protected Object[] convertPrimitiveArrayToObject(@Nonnull Object array) { - assert array.getClass().isArray(); - assert array.getClass().getComponentType().isPrimitive(); - - int length = Array.getLength(array); - Object objectArray[] = new Object[length]; - - for (int i = 0; i < length; i++) { - objectArray[i] = Array.get(array, i); - } - - return objectArray; - } -} diff --git a/jill/src/com/android/jill/frontend/java/MethodBodyWriter.java b/jill/src/com/android/jill/frontend/java/MethodBodyWriter.java deleted file mode 100644 index 0788f1d..0000000 --- a/jill/src/com/android/jill/frontend/java/MethodBodyWriter.java +++ /dev/null @@ -1,2516 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.frontend.java; - -import com.android.jill.JillException; -import com.android.jill.Options; -import com.android.jill.backend.jayce.JayceWriter; -import com.android.jill.backend.jayce.Token; -import com.android.jill.frontend.java.analyzer.JillAnalyzer; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.commons.JSRInlinerAdapter; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldInsnNode; -import org.objectweb.asm.tree.FrameNode; -import org.objectweb.asm.tree.IincInsnNode; -import org.objectweb.asm.tree.InsnNode; -import org.objectweb.asm.tree.IntInsnNode; -import org.objectweb.asm.tree.JumpInsnNode; -import org.objectweb.asm.tree.LabelNode; -import org.objectweb.asm.tree.LdcInsnNode; -import org.objectweb.asm.tree.LineNumberNode; -import org.objectweb.asm.tree.LocalVariableNode; -import org.objectweb.asm.tree.LookupSwitchInsnNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.MethodNode; -import org.objectweb.asm.tree.MultiANewArrayInsnNode; -import org.objectweb.asm.tree.TableSwitchInsnNode; -import org.objectweb.asm.tree.TryCatchBlockNode; -import org.objectweb.asm.tree.TypeInsnNode; -import org.objectweb.asm.tree.VarInsnNode; -import org.objectweb.asm.tree.analysis.Analyzer; -import org.objectweb.asm.tree.analysis.AnalyzerException; -import org.objectweb.asm.tree.analysis.BasicInterpreter; -import org.objectweb.asm.tree.analysis.BasicValue; -import org.objectweb.asm.tree.analysis.Frame; -import org.objectweb.asm.util.Printer; -import org.objectweb.asm.util.Textifier; -import org.objectweb.asm.util.TraceMethodVisitor; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * Method body writer. - */ -public class MethodBodyWriter extends JillWriter implements Opcodes { - - @Nonnull - private final Map<String, Variable> nameToVar = new HashMap<String, Variable>(); - - @Nonnull - private final Map<Variable, Variable> parameter2Var = new LinkedHashMap<Variable, Variable>(); - - public static final int CONSTRUCTOR = 0x10000; - - /** - * Kinds of method call dispatch. - */ - public enum DispatchKind { - VIRTUAL, - DIRECT - } - - /** - * Kinds of method. - */ - public enum MethodKind { - STATIC, - INSTANCE_NON_VIRTUAL, - INSTANCE_VIRTUAL - } - - /** - * Kinds of method call receiver. - */ - public enum MethodCallReceiverKind { - CLASS, - INTERFACE - } - - /** - * kinds of field reference. - */ - public enum FieldRefKind { - INSTANCE, - STATIC; - } - - private static class Case { - @Nonnull - LabelNode labelNode; - @CheckForNull - Integer key; - @Nonnull - String caseId; - - public Case( - @Nonnull LabelNode labelNode, @Nonnegative int switchIdx, @CheckForNull Integer key) { - this.labelNode = labelNode; - this.key = key; - caseId = switchIdx + "_" + (this.key != null ? this.key : "default"); - } - } - - private static class CmpOperands{ - @Nonnegative - int opcode; - @Nonnull - Variable lhs; - @Nonnull - Variable rhs; - - public CmpOperands(@Nonnegative int opcode, @Nonnull Variable lhs, @Nonnull Variable rhs) { - this.opcode = opcode; - this.lhs = lhs; - this.rhs = rhs; - } - } - - @Nonnull - private final HashMap<Variable, CmpOperands> cmpOperands = - new HashMap<Variable, MethodBodyWriter.CmpOperands>(); - - @Nonnull - private final AnnotationWriter annotWriter; - - @Nonnegative - private static final int NO_MODIFIER = 0; - - private static final int TOP_OF_STACK = -1; - - @Nonnull - private final Set<String> currentCatchList = new HashSet<String>(); - - @Nonnegative - private int currentLine = 0; - - @Nonnull - private final ClassNode currentClass; - - @Nonnull - private final MethodNode currentMethod; - - @Nonnull - private final Analyzer<BasicValue> analyzer; - - @Nonnegative - private int unusedVarCount = 0; - - @Nonnegative - private int currentPc = 0; - - private int startLine = -1; - private int endLine = -1; - - @Nonnull - private final Options options; - - @Nonnull - private final Map<TryCatchBlockNode, Variable> catchBlockToCatchedVariable = - new HashMap<TryCatchBlockNode, Variable>(); - - public MethodBodyWriter(@Nonnull JayceWriter writer, - @Nonnull AnnotationWriter annotWriter, - @Nonnull ClassNode cn, @Nonnull MethodNode mn, - @Nonnull SourceInfoWriter sourceInfoWriter, - @Nonnull Options options) { - super(writer, sourceInfoWriter); - this.annotWriter = annotWriter; - this.options = options; - currentClass = cn; - BasicInterpreter bi = new JillAnalyzer(); - analyzer = new Analyzer<BasicValue>(bi); - - if (mn.instructions.size() != 0) { - currentMethod = getMethodWithoutJSR(mn); - - try { - analyzer.analyze(currentClass.name, currentMethod); - - removeDeadCode(); - - analyzer.analyze(currentClass.name, currentMethod); - } catch (AnalyzerException e) { - throw new JillException("Variable analyser fails.", e); - } - } else { - currentMethod = mn; - } - } - - public void write() throws IOException { - if (AsmHelper.isAnnotation(currentClass)) { - writeAnnotationMethod(); - } else if (AsmHelper.isConstructor(currentMethod)) { - writeConstructor(); - } else { - writeMethod(); - } - } - - private void writeConstructor() throws IOException { - computeStartAndEndLine(); - sourceInfoWriter.writeDebugBegin(currentClass, startLine); - writer.writeKeyword(Token.CONSTRUCTOR); - writer.writeOpen(); - writeParameters(); - writer.writeInt(AsmHelper.getModifiers(currentMethod)); - annotWriter.writeAnnotations(currentMethod); - writeMethodBody(); - writer.writeOpenNodeList(); // Markers - writeOriginalTypeInfoMarker(); - writeThrownExceptionMarker(); - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(currentClass, endLine); - writer.writeClose(); - } - - private void writeMethod() throws IOException { - computeStartAndEndLine(); - sourceInfoWriter.writeDebugBegin(currentClass, startLine); - writer.writeKeyword(Token.METHOD); - writer.writeOpen(); - writer.writeString(currentMethod.name); - writer.writeId(Type.getReturnType(currentMethod.desc).getDescriptor()); - writeParameters(); - - MethodKind methodKind; - if (AsmHelper.isStatic(currentMethod)) { - methodKind = MethodKind.STATIC; - } else if (AsmHelper.isConstructor(currentMethod) || AsmHelper.isPrivate(currentMethod)) { - methodKind = MethodKind.INSTANCE_NON_VIRTUAL; - } else { - methodKind = MethodKind.INSTANCE_VIRTUAL; - } - writer.writeMethodKindEnum(methodKind); - - writer.writeInt(AsmHelper.isStaticInit(currentMethod) ? AsmHelper.getModifiers(currentMethod) - | CONSTRUCTOR : AsmHelper.getModifiers(currentMethod)); - annotWriter.writeAnnotations(currentMethod); - writeMethodBody(); - writer.writeOpenNodeList(); // Markers - writeOriginalTypeInfoMarker(); - writeThrownExceptionMarker(); - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(currentClass, endLine); - writer.writeClose(); - } - - private void writeAnnotationMethod() throws IOException { - computeStartAndEndLine(); - sourceInfoWriter.writeDebugBegin(currentClass, startLine); - writer.writeKeyword(Token.ANNOTATION_METHOD); - writer.writeOpen(); - writer.writeString(currentMethod.name); - writer.writeId(Type.getReturnType(currentMethod.desc).getDescriptor()); - writer.writeInt(AsmHelper.getModifiers(currentMethod)); - annotWriter.writeAnnotations(currentMethod); - if (currentMethod.annotationDefault != null) { - annotWriter.writeValue(currentMethod.annotationDefault); - } else { - writer.writeNull(); - } - writer.writeOpenNodeList(); // Markers - writeOriginalTypeInfoMarker(); - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(currentClass, endLine); - writer.writeClose(); - } - - private void writeOriginalTypeInfoMarker() throws IOException { - if (currentMethod.signature != null) { - writer.writeKeyword(Token.GENERIC_SIGNATURE); - writer.writeOpen(); - writer.writeString(currentMethod.signature); - writer.writeClose(); - } else { - writer.writeNull(); - } - } - - private void writeThrownExceptionMarker() throws IOException { - if (currentMethod.exceptions != null && !currentMethod.exceptions.isEmpty()) { - writer.writeKeyword(Token.THROWN_EXCEPTION); - writer.writeOpen(); - writer.writeIds(AsmHelper.getDescriptorsFromInternalNames(currentMethod.exceptions)); - writer.writeClose(); - } - } - - @Nonnull - private MethodNode getMethodWithoutJSR(@Nonnull MethodNode mn) { - JSRInlinerAdapter jsrInliner = - new JSRInlinerAdapter(null, mn.access, mn.name, mn.desc, mn.signature, - mn.exceptions.toArray(new String[mn.exceptions.size()])); - - mn.accept(jsrInliner); - - return jsrInliner; - } - - private void writeMethodBody() throws IOException { - currentCatchList.clear(); - writer.clearCatchBlockIds(); - - if (AsmHelper.isNative(currentMethod)) { - writeNativeMethodBody(); - } else if (AsmHelper.isAbstract(currentMethod)) { - writer.writeNull(); - } else { - createCaughtVariables(); - currentLine = startLine; - writeJavaMethodBody(); - } - - assert writer.isCurrentCatchBlockListEmpty(); - } - - private void computeStartAndEndLine() { - for (AbstractInsnNode insn : currentMethod.instructions.toArray()) { - if (insn instanceof LineNumberNode) { - LineNumberNode lnn = (LineNumberNode) insn; - - if (startLine == -1) { - startLine = lnn.line; - endLine = lnn.line + 1; - continue; - } - - if (lnn.line < startLine) { - startLine = lnn.line; - } else if (lnn.line > endLine) { - endLine = lnn.line; - } - } - } - } - - private void createCaughtVariables() { - for (TryCatchBlockNode tryCatchNode : currentMethod.tryCatchBlocks) { - Variable declaringCatchVariable = null; - Type caughtType; - if (tryCatchNode.type == null) { - // Jack represents finally by a catch on java.lang.Object. - caughtType = Type.getType(Object.class); - } else { - // If there are multi catches, it is not possible to compute precisely the common type of - // exceptions without having the full classpath and by loading all classes. Jill uses - // Throwable as common type even when a more precise type is known. - // This type will be cast with a reinterpret cast to the right type when it will be used. - caughtType = Type.getType(Throwable.class); - } - String id = "-e_" + (unusedVarCount++); - declaringCatchVariable = new Variable(id, id, caughtType, null); - catchBlockToCatchedVariable.put(tryCatchNode, declaringCatchVariable); - } - } - - private void writeNativeMethodBody() throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.NATIVE_METHOD_BODY); - writer.writeOpen(); - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - private void writeJavaMethodBody() throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, startLine); - writer.writeKeyword(Token.METHOD_BODY); - writer.writeOpen(); - writeLocals(); - writeBody(); - sourceInfoWriter.writeDebugEnd(currentClass, endLine); - writer.writeClose(); - } - - private void writeBody() throws IOException { - - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.BLOCK); - writer.writeOpen(); - writer.writeOpenNodeList(); - - if (currentMethod.instructions.size() == 0) { - if (options.isTolerant()) { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.THROW_STATEMENT); - writer.writeOpen(); - writer.writeKeyword(Token.NEW_INSTANCE); - writer.writeOpen(); - // Type of created object - writer.writeId("Ljava/lang/AssertionError;"); - // Empty argument types - writer.writeIds(Collections.<String>emptyList()); - // No arguments - writer.writeOpenNodeList(); - writer.writeCloseNodeList(); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } else { - throw new JillException("Method should have instructions."); - } - } else { - for (Map.Entry<Variable, Variable> entry : parameter2Var.entrySet()) { - Variable p = entry.getKey(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeLocalRef(entry.getValue()); - if (p.getType() == Type.BOOLEAN_TYPE) { - writeCastOperation(Token.REINTERPRETCAST_OPERATION, p, Type.INT_TYPE.getDescriptor()); - } else { - writeLocalRef(p); - } - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - Frame<BasicValue>[] frames = analyzer.getFrames(); - - for (int insnIdx = 0; insnIdx < currentMethod.instructions.size(); insnIdx++) { - currentPc = insnIdx; - AbstractInsnNode insn = currentMethod.instructions.get(insnIdx); - Frame<BasicValue> currentFrame = frames[insnIdx]; - // There's no next frame if insn is a return, and the last instruction. - Frame<BasicValue> nextFrame = (insnIdx < frames.length - 1) ? frames[insnIdx + 1] : null; - - if (insn instanceof JumpInsnNode) { - writeInsn(currentFrame, (JumpInsnNode) insn, insnIdx); - } else if (insn instanceof LdcInsnNode) { - assert nextFrame != null; - writeInsn(nextFrame, (LdcInsnNode) insn); - } else if (insn instanceof InsnNode) { - writeInsn(currentFrame, nextFrame, (InsnNode) insn); - } else if (insn instanceof VarInsnNode) { - assert nextFrame != null; - writeInsn(currentFrame, nextFrame, (VarInsnNode) insn); - } else if (insn instanceof LabelNode) { - computeCatchList((LabelNode) insn); - writeCatchBlock((LabelNode) insn, insnIdx, frames); - writeLabelInsn(insnIdx); - } else if (insn instanceof FieldInsnNode) { - assert nextFrame != null; - writeInsn(currentFrame, nextFrame, (FieldInsnNode) insn); - } else if (insn instanceof MethodInsnNode) { - assert nextFrame != null; - writeInsn(currentFrame, nextFrame, (MethodInsnNode) insn); - } else if (insn instanceof LineNumberNode) { - currentLine = ((LineNumberNode) insn).line; - } else if (insn instanceof FrameNode) { - // Nothing to do. - } else if (insn instanceof TypeInsnNode) { - assert nextFrame != null; - writeInsn(currentFrame, nextFrame, (TypeInsnNode) insn); - } else if (insn instanceof TableSwitchInsnNode) { - assert nextFrame != null; - writeInsn(currentFrame, nextFrame, (TableSwitchInsnNode) insn, insnIdx); - } else if (insn instanceof LookupSwitchInsnNode) { - assert nextFrame != null; - writeInsn(currentFrame, nextFrame, (LookupSwitchInsnNode) insn, insnIdx); - } else if (insn instanceof IntInsnNode) { - assert nextFrame != null; - writeInsn(currentFrame, nextFrame, (IntInsnNode) insn); - } else if (insn instanceof IincInsnNode) { - assert nextFrame != null; - writeInsn(currentFrame, nextFrame, (IincInsnNode) insn); - } else if (insn instanceof MultiANewArrayInsnNode) { - assert nextFrame != null; - writeInsn(currentFrame, nextFrame, (MultiANewArrayInsnNode) insn); - } else { - throw new JillException("Unsupported instruction."); - } - } - - // Current solution for comparison requires its result to be consumed by an "if" - if (!cmpOperands.isEmpty()) { - throw new AssertionError("A comparison has not been followed by an if"); - } - } - - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeCatchBlock(@Nonnull LabelNode labelNode, @Nonnegative int labelIdx, - @Nonnull Frame<BasicValue>[] frames) throws IOException { - for (TryCatchBlockNode tryCatchNode : currentMethod.tryCatchBlocks) { - if (tryCatchNode.handler == labelNode) { - // Always create a variable that will be typed with catched exception. Reuse computed - // variable is not possible since type could be lost due to merging. - Variable declaringCatchVariable = catchBlockToCatchedVariable.get(tryCatchNode); - - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.CATCH_BLOCK); - writer.writeOpen(); - writer.writeId(getCatchId(tryCatchNode.handler)); - - // Take into account multi catches by computing the list of caught types for this handler - List<String> ids = new ArrayList<String>(); - if (tryCatchNode.type == null) { - // Jack represents finally by a catch on java.lang.Object. - ids.add(Type.getType(Object.class).getDescriptor()); - } else { - ids.add(Type.getObjectType(tryCatchNode.type).getDescriptor()); - for (TryCatchBlockNode tryCatchNode2 : currentMethod.tryCatchBlocks) { - if (labelNode == tryCatchNode2.handler && tryCatchNode != tryCatchNode2 - && !tryCatchNode.type.equals(tryCatchNode2.type)) { - ids.add(Type.getObjectType(tryCatchNode2.type).getDescriptor()); - } - } - } - writer.writeIds(ids); - - writeLocal(declaringCatchVariable); - - writer.writeOpenNodeList(); - - if (frames[labelIdx] != null) { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(frames[labelIdx], TOP_OF_STACK); - writeLocalRef(declaringCatchVariable); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - writeGoto(tryCatchNode.handler); - - writer.writeCloseNodeList(); - - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; // Write catch block only one time even if the handler is used severals times. - } - } - } - - private void computeCatchList(@Nonnull LabelNode labelNode) { - for (TryCatchBlockNode tryCatchNode : currentMethod.tryCatchBlocks) { - String id = getCatchId(tryCatchNode.handler); - if (tryCatchNode.start == labelNode) { - currentCatchList.add(id); - } else if (tryCatchNode.end == labelNode) { - currentCatchList.remove(id); - } - } - } - - @Nonnull - private String getCatchId(@Nonnull LabelNode labelNode) { - int insnIndex = currentMethod.instructions.indexOf(labelNode); - return Integer.toString(insnIndex) + "-catch"; - } - - private void writeLabelInsn(@Nonnegative int insnIdx) - throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.LABELED_STATEMENT); - writer.writeOpen(); - String id = Integer.toString(insnIdx); - writer.writeString(id); - writer.writeId(id); - writeEmptyBlock(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeEmptyBlock() throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.BLOCK); - writer.writeOpen(); - writer.writeOpenNodeList(); - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeInsn(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame, - @Nonnull IincInsnNode iincInsn) throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeLocalAccess(nextFrame, iincInsn.var); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ADD_OPERATION); - writer.writeOpen(); - writeLocalAccess(frame, iincInsn.var); - writeValue(iincInsn.incr); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeInsn(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame, - @Nonnull IntInsnNode intInsn) throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - - switch (intInsn.getOpcode()) { - case BIPUSH: { - writeValue(intInsn.operand); - break; - } - case SIPUSH: { - writeValue(intInsn.operand); - break; - } - case NEWARRAY: { - - switch (intInsn.operand) { - case T_BOOLEAN: { - writeNewArray(frame, "[Z", 1); - break; - } - case T_CHAR: { - writeNewArray(frame, "[C", 1); - break; - } - case T_FLOAT: { - writeNewArray(frame, "[F", 1); - break; - } - case T_DOUBLE: { - writeNewArray(frame, "[D", 1); - break; - } - case T_BYTE: { - writeNewArray(frame, "[B", 1); - break; - } - case T_SHORT: { - writeNewArray(frame, "[S", 1); - break; - } - case T_INT: { - writeNewArray(frame, "[I", 1); - break; - } - case T_LONG: { - writeNewArray(frame, "[J", 1); - break; - } - default: { - throw new JillException("Unsupported array type."); - } - } - break; - } - default: { - throw new JillException("Not yet supported " + Printer.OPCODES[intInsn.getOpcode()]); - } - } - - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeInsn(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame, - @Nonnull MultiANewArrayInsnNode manaIns) throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - writeNewArray(frame, manaIns.desc, manaIns.dims); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeNewArray( - @Nonnull Frame<BasicValue> frame, @Nonnull String typeDesc, @Nonnegative int dims) - throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.NEW_ARRAY); - writer.writeOpen(); - writer.writeId(typeDesc); - writer.writeOpenNodeList(); - for (int i = (dims - 1); i >= 0; i--) { - writeStackAccess(frame, TOP_OF_STACK - i); - } - writer.writeCloseNodeList(); - writer.writeOpenNodeList(); // Empty initializers list. - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeArrayRef(@Nonnull Frame<BasicValue> frame, int startIdx, - @Nonnegative int opcode) throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ARRAY_REF); - writer.writeOpen(); - Type refType = frame.getStack(frame.getStackSize() + startIdx).getType(); - - // Ensure reference to array, or null. Null case can happen in this case: - // int a[] = null; - // return a[0] <- aload_0, iconst_0, iaload - assert refType.getSort() == Type.ARRAY || "null".equals(refType.getInternalName()); - - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.REINTERPRETCAST_OPERATION); - writer.writeOpen(); - switch (opcode) { - case BALOAD: - case BASTORE: { - if (refType.getDescriptor().equals("[Z")) { - writer.writeId(Type.getType("[Z").getDescriptor()); - } else { - writer.writeId(Type.getType("[B").getDescriptor()); - } - break; - } - case CALOAD: - case CASTORE: { - writer.writeId(Type.getType("[C").getDescriptor()); - break; - } - case SALOAD: - case SASTORE: { - writer.writeId(Type.getType("[S").getDescriptor()); - break; - } - case IALOAD: - case IASTORE: { - writer.writeId(Type.getType("[I").getDescriptor()); - break; - } - case LALOAD: - case LASTORE: { - writer.writeId(Type.getType("[J").getDescriptor()); - break; - } - case FALOAD: - case FASTORE: { - writer.writeId(Type.getType("[F").getDescriptor()); - break; - } - case DALOAD: - case DASTORE: { - writer.writeId(Type.getType("[D").getDescriptor()); - break; - } - case AALOAD: - case AASTORE: { - writer.writeId(Type.getType("[Ljava/lang/Object;").getDescriptor()); - break; - } - default: { - throw new JillException("Not yet supported " + Printer.OPCODES[opcode]); - } - } - writeStackAccess(frame, startIdx); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - - writeStackAccess(frame, startIdx + 1); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeInsn(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame, - @Nonnull LookupSwitchInsnNode switchInsn, @Nonnegative int idx) throws IOException { - List<String> cases = new ArrayList<String>(); - List<Case> casesLabelNodeAndKey = new ArrayList<Case>(); - Case defaultCase = new Case(switchInsn.dflt, idx, null); - casesLabelNodeAndKey.add(defaultCase); - cases.add(defaultCase.caseId); - int caseIdx = 0; - for (LabelNode labelNode : switchInsn.labels) { - Case c = new Case(labelNode, idx, switchInsn.keys.get(caseIdx++)); - casesLabelNodeAndKey.add(c); - cases.add(c.caseId); - } - writeSwitch(frame, cases, casesLabelNodeAndKey); - } - - private void writeInsn(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame, - @Nonnull TableSwitchInsnNode switchInsn, @Nonnegative int idx) throws IOException { - List<String> cases = new ArrayList<String>(); - List<Case> casesLabelNodeAndKey = new ArrayList<Case>(); - Case defaultCase = new Case(switchInsn.dflt, idx, null); - casesLabelNodeAndKey.add(defaultCase); - cases.add(defaultCase.caseId); - int key = switchInsn.min; - for (LabelNode labelNode : switchInsn.labels) { - Case c = new Case(labelNode, idx, Integer.valueOf(key++)); - casesLabelNodeAndKey.add(c); - cases.add(c.caseId); - } - writeSwitch(frame, cases, casesLabelNodeAndKey); - } - - private void writeSwitch(@Nonnull Frame<BasicValue> frame, @Nonnull List<String> cases, - @Nonnull List<Case> casesLabelNodeAndKey) - throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.SWITCH_STATEMENT); - writer.writeOpen(); - writeStackAccess(frame, TOP_OF_STACK); - writer.writeIds(cases); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.BLOCK); - writer.writeOpen(); - writer.writeOpenNodeList(); - for (Case c : casesLabelNodeAndKey) { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.CASE_STATEMENT); - writer.writeOpen(); - writer.writeId(c.caseId); - writeValue(c.key); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - writeGoto(c.labelNode); - } - writer.writeCloseNodeList(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeInsn(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame, - @Nonnull TypeInsnNode typeInsn) throws IOException { - - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - - String descriptor = Type.getObjectType(typeInsn.desc).getDescriptor(); - - switch (typeInsn.getOpcode()) { - case NEW: { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ALLOC); - writer.writeOpen(); - writer.writeId(descriptor); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case ANEWARRAY: { - writeNewArray(frame, "[" + descriptor, 1); - break; - } - case INSTANCEOF: { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.REINTERPRETCAST_OPERATION); - writer.writeOpen(); - writer.writeId(Type.BOOLEAN_TYPE.getDescriptor()); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.INSTANCE_OF); - writer.writeOpen(); - writeStackAccess(frame, TOP_OF_STACK); - writer.writeId(descriptor); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, - currentLine + 1); - writer.writeClose(); - break; - } - case CHECKCAST: { - writeCastOperation(Token.DYNAMIC_CAST_OPERATION, frame, descriptor, TOP_OF_STACK); - break; - } - default: { - throw new JillException("Not yet supported " + Printer.OPCODES[typeInsn.getOpcode()]); - } - } - - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeInsn(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame, - @Nonnull FieldInsnNode fldInsn) throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - - switch (fldInsn.getOpcode()) { - case PUTFIELD: { - writeInstanceFieldRef(fldInsn, frame, TOP_OF_STACK - 1); - if (Type.getType(fldInsn.desc) == Type.BOOLEAN_TYPE) { - writeCastOperation(Token.REINTERPRETCAST_OPERATION, frame, - Type.BOOLEAN_TYPE.getDescriptor(), TOP_OF_STACK); - } else { - writeStackAccess(frame, TOP_OF_STACK); - } - break; - } - case PUTSTATIC: { - writeStaticFieldRef(fldInsn); - if (Type.getType(fldInsn.desc) == Type.BOOLEAN_TYPE) { - writeCastOperation(Token.REINTERPRETCAST_OPERATION, frame, - Type.BOOLEAN_TYPE.getDescriptor(), TOP_OF_STACK); - } else { - writeStackAccess(frame, TOP_OF_STACK); - } - break; - } - case GETFIELD: { - writeStackAccess(nextFrame, TOP_OF_STACK); - if (Type.getType(fldInsn.desc) == Type.BOOLEAN_TYPE) { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.REINTERPRETCAST_OPERATION); - writer.writeOpen(); - writer.writeId(Type.INT_TYPE.getDescriptor()); - writeInstanceFieldRef(fldInsn, frame, TOP_OF_STACK); - sourceInfoWriter.writeDebugEnd(currentClass, - currentLine + 1); - writer.writeClose(); - } else { - writeInstanceFieldRef(fldInsn, frame, TOP_OF_STACK); - } - break; - } - case GETSTATIC: { - writeStackAccess(nextFrame, TOP_OF_STACK); - if (Type.getType(fldInsn.desc) == Type.BOOLEAN_TYPE) { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.REINTERPRETCAST_OPERATION); - writer.writeOpen(); - writer.writeId(Type.INT_TYPE.getDescriptor()); - writeStaticFieldRef(fldInsn); - sourceInfoWriter.writeDebugEnd(currentClass, - currentLine + 1); - writer.writeClose(); - } else { - writeStaticFieldRef(fldInsn); - } - break; - } - default: - throw new JillException("Not yet supported " + Printer.OPCODES[fldInsn.getOpcode()]); - } - - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - - } - - private void writeInsn(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame, - @Nonnull MethodInsnNode mthInsn) throws IOException { - switch (mthInsn.getOpcode()) { - case INVOKEINTERFACE: - case INVOKESTATIC: - case INVOKEVIRTUAL: - case INVOKESPECIAL: { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - - Type returnType = Type.getReturnType(mthInsn.desc); - if (returnType != Type.VOID_TYPE) { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - if (returnType == Type.BOOLEAN_TYPE) { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.REINTERPRETCAST_OPERATION); - writer.writeOpen(); - writer.writeId(Type.INT_TYPE.getDescriptor()); - } - } - - DispatchKind dispatchKind; - MethodKind methodKind; - MethodCallReceiverKind receiverKind; - switch (mthInsn.getOpcode()) { - case INVOKEINTERFACE: { - dispatchKind = DispatchKind.VIRTUAL; - methodKind = MethodKind.INSTANCE_VIRTUAL; - receiverKind = MethodCallReceiverKind.INTERFACE; - break; - } - case INVOKESTATIC: { - dispatchKind = DispatchKind.DIRECT; - methodKind = MethodKind.STATIC; - receiverKind = MethodCallReceiverKind.CLASS; - break; - } - case INVOKEVIRTUAL: { - dispatchKind = DispatchKind.VIRTUAL; - methodKind = MethodKind.INSTANCE_VIRTUAL; - receiverKind = MethodCallReceiverKind.CLASS; - break; - } - case INVOKESPECIAL: { - if (mthInsn.owner.equals(currentClass.name) || mthInsn.name.equals("<init>")) { - dispatchKind = DispatchKind.DIRECT; - methodKind = MethodKind.INSTANCE_NON_VIRTUAL; - receiverKind = MethodCallReceiverKind.CLASS; - } else { - dispatchKind = DispatchKind.DIRECT; - methodKind = MethodKind.INSTANCE_VIRTUAL; - receiverKind = MethodCallReceiverKind.CLASS; - } - break; - } - default: { - throw new JillException("Opcode not supported " + Printer.OPCODES[mthInsn.getOpcode()]); - } - } - - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.METHOD_CALL); - writer.writeOpen(); - Type receiverType = Type.getObjectType(mthInsn.owner); - int stackArgIndex = Type.getArgumentTypes(mthInsn.desc).length; - - if (mthInsn.getOpcode() == INVOKESTATIC) { - writer.writeNull(); // Instance - } else { - // Add implicit argument 'this' - stackArgIndex++; - // Cast instance to receiver type - if (receiverType.equals(frame.getStack(frame.getStackSize() - stackArgIndex).getType()) - || mthInsn.name.equals("<init>")) { - // It is not possible to add cast on object before call to init - writeStackAccess(frame, -stackArgIndex); - } else { - writeCastOperation(Token.REINTERPRETCAST_OPERATION, frame, receiverType.getDescriptor(), - -stackArgIndex); - } - stackArgIndex--; - } - - if (receiverType.getSort() == Type.ARRAY) { - // Currently Jack file does not support that array types are used as a receiver or - // declaring type into a method call. - receiverType = Type.getType(Object.class); - } - writer.writeId(receiverType.getDescriptor()); // Receiver type - writer.writeReceiverKindEnum(receiverKind); - - writer.writeId(mthInsn.name); - Type[] argumentTypes = Type.getArgumentTypes(mthInsn.desc); - List<String> argsTypeIds = new ArrayList<String>(argumentTypes.length); - for (Type argType : argumentTypes) { - argsTypeIds.add(argType.getDescriptor()); - } - writer.writeIds(argsTypeIds); - writer.writeMethodKindEnum(methodKind); - - writer.writeId(returnType.getDescriptor()); - int argIdx = 0; - writer.writeOpenNodeList(); - while (stackArgIndex > 0) { - Type argType = argumentTypes[argIdx++]; - if (argType.getSort() == Type.OBJECT || argType.getSort() == Type.ARRAY - || argType.getSort() == Type.BYTE || argType.getSort() == Type.CHAR - || argType.getSort() == Type.SHORT || argType.getSort() == Type.BOOLEAN) { - writeCastOperation(Token.REINTERPRETCAST_OPERATION, frame, argType.getDescriptor(), - -stackArgIndex); - } else { - writeStackAccess(frame, -stackArgIndex); - } - stackArgIndex--; - } - writer.writeCloseNodeList(); - writer.writeDispatchKindEnum(dispatchKind); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - - if (returnType != Type.VOID_TYPE) { - if (returnType == Type.BOOLEAN_TYPE) { - sourceInfoWriter.writeDebugEnd(currentClass, - currentLine + 1); - writer.writeClose(); - } - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - default: { - throw new JillException("Not yet supported " + Printer.OPCODES[mthInsn.getOpcode()]); - } - } - } - - private void writeInsn(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame, - @Nonnull VarInsnNode varInsn) throws IOException { - switch (varInsn.getOpcode()) { - case FLOAD: - case DLOAD: - case LLOAD: - case ILOAD: - case ALOAD: { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - if (getLocalVariable(frame, varInsn.var).getType() == Type.BOOLEAN_TYPE) { - writeCastOperation(Token.REINTERPRETCAST_OPERATION, getLocalVariable(frame, varInsn.var), - Type.INT_TYPE.getDescriptor()); - } else { - writeLocalAccess(frame, varInsn.var); - } - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case FSTORE: - case DSTORE: - case LSTORE: - case ISTORE: - case ASTORE: { - // Uninitialize variable means dead store. Do not generate them. - if (nextFrame.getLocal(varInsn.var) != BasicValue.UNINITIALIZED_VALUE) { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeLocalAccess(nextFrame, varInsn.var); - Type destType = getLocalVariable(nextFrame, varInsn.var).getType(); - if (destType == Type.BOOLEAN_TYPE) { - writeCastOperation(Token.REINTERPRETCAST_OPERATION, frame, - Type.BOOLEAN_TYPE.getDescriptor(), TOP_OF_STACK); - } else if (getStackVariable(frame, TOP_OF_STACK).getType() != destType) { - writeCastOperation(Token.REINTERPRETCAST_OPERATION, frame, destType.getDescriptor(), - TOP_OF_STACK); - } else { - writeStackAccess(frame, TOP_OF_STACK); - } - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - break; - } - default: { - throw new JillException("Not yet supported " + Printer.OPCODES[varInsn.getOpcode()]); - } - } - } - - private void writeInsn(@Nonnull Frame<BasicValue> frame, - @CheckForNull Frame<BasicValue> nextFrame, @Nonnull InsnNode insn) throws IOException { - switch (insn.getOpcode()) { - case ICONST_M1: - case ICONST_0: - case ICONST_1: - case ICONST_2: - case ICONST_3: - case ICONST_4: - case ICONST_5: { - assert nextFrame != null; - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - writeValue(insn.getOpcode() - ICONST_0); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case ACONST_NULL: { - assert nextFrame != null; - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - writeValue(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case LCONST_0: - case LCONST_1: { - assert nextFrame != null; - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - writeValue((long) (insn.getOpcode() - LCONST_0)); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case FCONST_0: - case FCONST_1: - case FCONST_2: { - assert nextFrame != null; - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - writeValue((float) (insn.getOpcode() - FCONST_0)); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case DCONST_0: - case DCONST_1: { - assert nextFrame != null; - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - writeValue((double) (insn.getOpcode() - DCONST_0)); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case D2L: - case F2L: - case I2L: { - assert nextFrame != null; - writePrimitiveTypeConversion(long.class, frame, nextFrame); - break; - } - case D2F: - case I2F: - case L2F:{ - assert nextFrame != null; - writePrimitiveTypeConversion(float.class, frame, nextFrame); - break; - } - case F2D: - case I2D: - case L2D: { - assert nextFrame != null; - writePrimitiveTypeConversion(double.class, frame, nextFrame); - break; - } - case D2I: - case F2I: - case L2I: { - assert nextFrame != null; - writePrimitiveTypeConversion(int.class, frame, nextFrame); - break; - } - case I2B: { - assert nextFrame != null; - writePrimitiveTypeConversion(byte.class, frame, nextFrame); - break; - } - case I2C: { - assert nextFrame != null; - writePrimitiveTypeConversion(char.class, frame, nextFrame); - break; - } - case I2S: { - assert nextFrame != null; - writePrimitiveTypeConversion(short.class, frame, nextFrame); - break; - } - case DRETURN: - case LRETURN: - case FRETURN: { - writeReturn(frame, TOP_OF_STACK); - break; - } - case ARETURN: - case IRETURN: { - Type returnType = Type.getReturnType(currentMethod.desc); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.RETURN_STATEMENT); - writer.writeOpen(); - writeCastOperation(Token.REINTERPRETCAST_OPERATION, frame, returnType.getDescriptor(), - TOP_OF_STACK); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case RETURN: { - writeReturn(frame, 0); - break; - } - case DADD: - case FADD: - case IADD: - case LADD: { - assert nextFrame != null; - writeBinaryOperation(Token.ADD_OPERATION, frame, nextFrame); - break; - } - case LCMP: - case FCMPL: - case FCMPG: - case DCMPL: - case DCMPG: { - assert nextFrame != null; - Variable lhs = getStackVariable(frame, TOP_OF_STACK - 1); - Variable rhs = getStackVariable(frame, TOP_OF_STACK); - Variable result = getStackVariable(nextFrame, TOP_OF_STACK); - cmpOperands.put(result, new CmpOperands(insn.getOpcode(), lhs, rhs)); - break; - } - case DSUB: - case FSUB: - case ISUB: - case LSUB: { - assert nextFrame != null; - writeBinaryOperation(Token.SUB_OPERATION, frame, nextFrame); - break; - } - case DMUL: - case FMUL: - case IMUL: - case LMUL: { - assert nextFrame != null; - writeBinaryOperation(Token.MUL_OPERATION, frame, nextFrame); - break; - } - case DDIV: - case FDIV: - case IDIV: - case LDIV: { - assert nextFrame != null; - writeBinaryOperation(Token.DIV_OPERATION, frame, nextFrame); - break; - } - case DREM: - case FREM: - case IREM: - case LREM: { - assert nextFrame != null; - writeBinaryOperation(Token.MOD_OPERATION, frame, nextFrame); - break; - } - case DNEG: - case FNEG: - case INEG: - case LNEG: { - assert nextFrame != null; - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.PREFIX_NEG_OPERATION); - writer.writeOpen(); - writeStackAccess(frame, TOP_OF_STACK); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case ISHL: - case LSHL: { - assert nextFrame != null; - writeBinaryOperation(Token.SHL_OPERATION, frame, nextFrame); - break; - } - case ISHR: - case LSHR: { - assert nextFrame != null; - writeBinaryOperation(Token.SHR_OPERATION, frame, nextFrame); - break; - } - case IUSHR: - case LUSHR: { - assert nextFrame != null; - writeBinaryOperation(Token.SHRU_OPERATION, frame, nextFrame); - break; - } - case IAND: - case LAND: { - assert nextFrame != null; - writeBinaryOperation(Token.BIT_AND_OPERATION, frame, nextFrame); - break; - } - case IOR: - case LOR: { - assert nextFrame != null; - writeBinaryOperation(Token.BIT_OR_OPERATION, frame, nextFrame); - break; - } - case IXOR: - case LXOR: { - assert nextFrame != null; - writeBinaryOperation(Token.BIT_XOR_OPERATION, frame, nextFrame); - break; - } - case ARRAYLENGTH: { - assert nextFrame != null; - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ARRAY_LENGTH); - writer.writeOpen(); - writeStackAccess(frame, TOP_OF_STACK); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - - case IALOAD: - case LALOAD: - case FALOAD: - case DALOAD: - case AALOAD: - case BALOAD: - case CALOAD: - case SALOAD: { - assert nextFrame != null; - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - writeArrayRef(frame, TOP_OF_STACK - 1, insn.getOpcode()); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case IASTORE: - case LASTORE: - case FASTORE: - case DASTORE: - case AASTORE: - case BASTORE: - case CASTORE: - case SASTORE: { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeArrayRef(frame, TOP_OF_STACK - 2, insn.getOpcode()); - writeStackAccess(frame, TOP_OF_STACK); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case MONITORENTER: { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.LOCK); - writer.writeOpen(); - writeStackAccess(frame, TOP_OF_STACK); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case MONITOREXIT: { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.UNLOCK); - writer.writeOpen(); - writeStackAccess(frame, TOP_OF_STACK); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case SWAP: { - // frame and nextFrame have the same height, thus frame can always be used to compute stack - // variables. - Variable tmpVar = getTempVarFromTopOfStack(frame); - - // tmpVar = frame.stack[frame.stack.size() + TOP_OF_STACK - 1] - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeLocalRef(tmpVar); - writeStackAccess(frame, TOP_OF_STACK - 1); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - - // frame.stack[frame.stack.size() + TOP_OF_STACK - 1] = - // frame.stack[frame.stack.size() + TOP_OF_STACK] - writeAssign(frame, TOP_OF_STACK, frame, TOP_OF_STACK - 1); - - // frame.stack[frame.stack.size() + TOP_OF_STACK] = tmpVar - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(frame, TOP_OF_STACK); - writeLocalRef(tmpVar); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case DUP: { - assert nextFrame != null; - writeDup(frame, nextFrame); - break; - } - case DUP2: { - assert nextFrame != null; - if (frame.getStack(frame.getStackSize() + TOP_OF_STACK).getSize() == 1) { - assert frame.getStack(frame.getStackSize() + TOP_OF_STACK - 1).getSize() == 1; - writeDup2(frame, nextFrame); - } else { - writeDup(frame, nextFrame); - } - break; - } - case DUP_X1: { - assert nextFrame != null; - assert frame.getStack(frame.getStackSize() + TOP_OF_STACK).getSize() == 1; - assert frame.getStack(frame.getStackSize() + TOP_OF_STACK - 1).getSize() == 1; - writeDupX1(frame, nextFrame); - break; - } - case DUP_X2: { - assert nextFrame != null; - Variable value1 = getStackVariable(frame, TOP_OF_STACK); - Variable value2 = getStackVariable(frame, TOP_OF_STACK - 1); - assert value1.getType().getSize() == 1; - if (value2.getType().getSize() == 1) { - Variable value3 = getStackVariable(frame, TOP_OF_STACK - 2); - assert value3.getType().getSize() == 1; - writeDupX2(frame, nextFrame); - } else { - writeDupX1(frame, nextFrame); - } - break; - } - case DUP2_X1: { - assert nextFrame != null; - Variable value1 = getStackVariable(frame, TOP_OF_STACK); - Variable value2 = getStackVariable(frame, TOP_OF_STACK - 1); - assert value2.getType().getSize() == 1; - if (value1.getType().getSize() == 1) { - Variable value3 = getStackVariable(frame, TOP_OF_STACK - 2); - assert value3.getType().getSize() == 1; - writeDup2X1(frame, nextFrame); - } else { - writeDupX1(frame, nextFrame); - } - break; - } - case DUP2_X2: { - assert nextFrame != null; - Variable value1 = getStackVariable(frame, TOP_OF_STACK); - Variable value2 = getStackVariable(frame, TOP_OF_STACK - 1); - if (value1.getType().getSize() == 1) { - Variable value3 = getStackVariable(frame, TOP_OF_STACK - 2); - if (value3.getType().getSize() == 1) { - Variable value4 = getStackVariable(frame, TOP_OF_STACK - 3); - assert value4.getType().getSize() == 1; - writeDup2X2(frame, nextFrame); - } else { - writeDup2X1(frame, nextFrame); - } - } else { - if (value2.getType().getSize() == 1) { - Variable value3 = getStackVariable(frame, TOP_OF_STACK - 2); - assert value3.getType().getSize() == 1; - writeDupX2(frame, nextFrame); - } else { - writeDupX1(frame, nextFrame); - } - } - break; - } - case NOP: - case POP: - case POP2:{ - break; - } - case ATHROW: { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.THROW_STATEMENT); - writer.writeOpen(); - writeStackAccess(frame, TOP_OF_STACK); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - default: { - throw new JillException("Not yet supported " + Printer.OPCODES[insn.getOpcode()]); - } - } - } - - private void writeInsn(@Nonnull Frame<BasicValue> nextFrame, @Nonnull LdcInsnNode ldcInsn) - throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - writeValue(ldcInsn.cst); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeInsn( - @Nonnull Frame<BasicValue> frame, @Nonnull JumpInsnNode jumpInsn, @Nonnegative int insIndex) - throws IOException { - switch (jumpInsn.getOpcode()) { - case IFNONNULL: - case IFNULL: - case IFEQ: - case IFGE: - case IFGT: - case IFLE: - case IFLT: - case IFNE: { - Variable topOfStackVariable = getStackVariable(frame, TOP_OF_STACK); - CmpOperands cmpOps = cmpOperands.get(topOfStackVariable); - if (cmpOps != null) { - // CmpOperands concerns double, float and long types - assert jumpInsn.getOpcode() != IFNONNULL && jumpInsn.getOpcode() != IFNULL; - // Not operator can be generate only for double and long types to manage comparisons with - // Nan. - Token comparisonToken = getConditionToken(jumpInsn.getOpcode()); - boolean needNotoperator = needNotOperator(comparisonToken, cmpOps); - - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.IF_STATEMENT); - writer.writeOpen(); - if (needNotoperator) { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.PREFIX_NOT_OPERATION); - writer.writeOpen(); - } else { - // Condition is inverted to be compliant with language level semantics - // This has been done for comparison to NaN, which forces the branching order. - comparisonToken = invertComparisonToken(comparisonToken); - } - - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(comparisonToken); - writer.writeOpen(); - writeLocalRef(cmpOps.lhs); - writeLocalRef(cmpOps.rhs); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - - if (needNotoperator) { - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - int labeledStatmentIndex = insIndex + 1; - writeGoto(labeledStatmentIndex); - writeGoto(jumpInsn.label); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - - insertLabeledStatementIfNecessary(labeledStatmentIndex); - - cmpOperands.remove(topOfStackVariable); - } else { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.IF_STATEMENT); - writer.writeOpen(); - Token conditionalToken = getConditionToken(jumpInsn.getOpcode()); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(conditionalToken); - writer.writeOpen(); - writeStackAccess(frame, TOP_OF_STACK); - Variable v = getStackVariable(frame, TOP_OF_STACK); - if (v.getType().equals(Type.BOOLEAN_TYPE)) { - writeValue(false); - } else if (v.getType().equals(Type.BYTE_TYPE) - || v.getType().equals(Type.CHAR_TYPE) - || v.getType().equals(Type.SHORT_TYPE) - || v.getType().equals(Type.INT_TYPE)) { - writeValue(0); - } else { - writeValue(); - } - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - writeGoto(jumpInsn.label); - writer.writeNull(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - break; - } - case IF_ICMPEQ: - case IF_ICMPGE: - case IF_ICMPGT: - case IF_ICMPLE: - case IF_ICMPLT: - case IF_ICMPNE: - case IF_ACMPEQ: - case IF_ACMPNE: { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.IF_STATEMENT); - writer.writeOpen(); - Token conditionalToken = getConditionToken(jumpInsn.getOpcode()); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(conditionalToken); - writer.writeOpen(); - writeStackAccess(frame, TOP_OF_STACK - 1); - writeStackAccess(frame, TOP_OF_STACK); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - writeGoto(jumpInsn.label); - writer.writeNull(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - break; - } - case GOTO: { - writeGoto(jumpInsn.label); - break; - } - default: { - throw new JillException("Not yet supported " + Printer.OPCODES[jumpInsn.getOpcode()]); - } - } - } - - - private void insertLabeledStatementIfNecessary(@Nonnegative int labeledStatmentIndex) - throws IOException { - AbstractInsnNode existing = currentMethod.instructions.get(labeledStatmentIndex); - if (existing instanceof LabelNode) { - return; - } else { - writeLabelInsn(labeledStatmentIndex); - } - } - - @Nonnull - private Token getConditionToken(@Nonnegative int opcode) { - switch (opcode) { - case IFNULL: - case IF_ACMPEQ: - case IF_ICMPEQ: - case IFEQ: - return Token.EQ_OPERATION; - case IF_ICMPGE: - case IFGE: - return Token.GTE_OPERATION; - case IF_ICMPGT: - case IFGT: - return Token.GT_OPERATION; - case IF_ICMPLE: - case IFLE: - return Token.LTE_OPERATION; - case IF_ICMPLT: - case IFLT: - return Token.LT_OPERATION; - case IFNONNULL: - case IF_ACMPNE: - case IF_ICMPNE: - case IFNE: - return Token.NEQ_OPERATION; - } - throw new JillException("Unsupported condition."); - } - - @Nonnull - private Token invertComparisonToken(@Nonnull Token cmpToken) { - switch (cmpToken) { - case GTE_OPERATION: { - return Token.LT_OPERATION; - } - case GT_OPERATION: { - return Token.LTE_OPERATION; - } - case LTE_OPERATION: { - return Token.GT_OPERATION; - } - case LT_OPERATION: { - return Token.GTE_OPERATION; - } - case EQ_OPERATION: { - return Token.NEQ_OPERATION; - } - case NEQ_OPERATION: { - return Token.EQ_OPERATION; - } - default: { - return cmpToken; - } - } - } - - @Nonnull - private boolean needNotOperator(@Nonnull Token cmpToken, @Nonnull CmpOperands cmpOps) { - switch (cmpToken) { - case GTE_OPERATION: - case GT_OPERATION: { - return !isCmpg(cmpOps); - } - case LTE_OPERATION: - case LT_OPERATION: { - return !isCmpl(cmpOps); - } - default: { - return false; - } - } - } - - private boolean isCmpl(@Nonnull CmpOperands cmpOps) { - return cmpOps.opcode == DCMPL || cmpOps.opcode == FCMPL; - } - - private boolean isCmpg(@Nonnull CmpOperands cmpOps) { - return cmpOps.opcode == DCMPG || cmpOps.opcode == FCMPG; - } - - private void writeGoto(LabelNode labelNode) throws IOException { - int insIndex = currentMethod.instructions.indexOf(labelNode); - writeGoto(insIndex); - } - - private void writeGoto(int insIndex) throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.GOTO); - writer.writeOpen(); - writer.writeId(Integer.toString(insIndex)); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeReturn(@Nonnull Frame<BasicValue> frame, int stackIdx) throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.RETURN_STATEMENT); - writer.writeOpen(); - if (stackIdx == 0) { - writer.writeNull(); - } else { - writeStackAccess(frame, stackIdx); - } - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeStackAccess(@Nonnull Frame<BasicValue> frame, int stackIdx) - throws IndexOutOfBoundsException, IOException { - writeLocalRef(getStackVariable(frame, stackIdx)); - } - - private void writeLocalAccess(@Nonnull Frame<BasicValue> frame, @Nonnegative int localIdx) - throws IndexOutOfBoundsException, IOException { - writeLocalRef(getLocalVariable(frame, localIdx)); - } - - private void writeLocalRef(@Nonnull Variable v) throws IOException { - if (v.isThis()) { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.THIS_REF); - writer.writeOpen(); - writer.writeId(v.getType().getDescriptor()); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } else { - Token token = v.isParameter() ? Token.PARAMETER_REF : Token.LOCAL_REF; - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(token); - writer.writeOpen(); - writer.writeId(v.getId()); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - } - - private void writeInstanceFieldRef(@Nonnull FieldInsnNode fldInsn, - @Nonnull Frame<BasicValue> frame, int offset) throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.FIELD_REF); - writer.writeOpen(); - writer.writeId(fldInsn.name); - writer.writeId(fldInsn.desc); - writer.writeId(Type.getObjectType(fldInsn.owner).getDescriptor()); - writer.writeFieldRefKindEnum(FieldRefKind.INSTANCE); - writeStackAccess(frame, offset); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeStaticFieldRef(@Nonnull FieldInsnNode fldInsn) - throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.FIELD_REF); - writer.writeOpen(); - writer.writeId(fldInsn.name); - writer.writeId(fldInsn.desc); - writer.writeId(Type.getObjectType(fldInsn.owner).getDescriptor()); - writer.writeFieldRefKindEnum(FieldRefKind.STATIC); - writer.writeNull(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - public void dump() { - Textifier t = new Textifier(); - Frame<BasicValue>[] frames = analyzer.getFrames(); - List<Object> text = t.getText(); - int insnIdx = 0; - - currentMethod.accept(new TraceMethodVisitor(t)); - - for (Object o : text) { - if (insnIdx < frames.length && frames[insnIdx] != null) { - System.out.print(insnIdx + " : ["); - for (int i = 0; i < frames[insnIdx].getLocals(); i++) { - BasicValue bv = frames[insnIdx].getLocal(i); - System.out.print(bv.toString() + " "); - } - System.out.print("| "); - for (int i = 0; i < frames[insnIdx].getStackSize(); i++) { - BasicValue bv = frames[insnIdx].getStack(i); - System.out.print(bv.toString() + " "); - } - System.out.println("]"); - } - System.out.print(o); - insnIdx++; - } - } - - private void writeLocals() throws IOException { - writer.writeOpenNodeList(); - - if (currentMethod.instructions.size() != 0) { - Iterator<Variable> varIt = collectLocals(); - while (varIt.hasNext()) { - writeLocal(varIt.next()); - } - } - - writer.writeCloseNodeList(); - } - - private void writeLocal(Variable v) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.LOCAL); - writer.writeOpen(); - writer.writeId(v.getId()); - writer.writeInt(v.isSynthetic() ? Opcodes.ACC_SYNTHETIC : NO_MODIFIER); - writer.writeId(v.getType().getDescriptor()); - writer.writeId(v.getName()); - writer.writeOpenNodeList(); // Empty annotation set, annotations on locals are not kept - writer.writeCloseNodeList(); - writer.writeOpenNodeList(); - if (v.hasSignature()) { - writer.writeKeyword(Token.GENERIC_SIGNATURE); // Marker generic signature - writer.writeOpen(); - writer.writeString(v.getSignature()); - writer.writeClose(); - } - writer.writeCloseNodeList(); - // TODO(mikaelpeltier): Add debug information. - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - private void writePrimitiveTypeConversion(@Nonnull Class<?> targetType, - @Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame) throws IOException { - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - writeCastOperation(Token.DYNAMIC_CAST_OPERATION, frame, Type.getDescriptor(targetType), - TOP_OF_STACK); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeCastOperation(@Nonnull Token cast, @Nonnull Variable var, - @Nonnull String typeDesc) throws IOException { - assert cast == Token.DYNAMIC_CAST_OPERATION || cast == Token.REINTERPRETCAST_OPERATION; - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(cast); - writer.writeOpen(); - writer.writeId(typeDesc); - writeLocalRef(var); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeCastOperation(@Nonnull Token cast, @Nonnull Frame<BasicValue> frame, - @Nonnull String typeDesc, int stackIdx) throws IOException { - writeCastOperation(cast, getStackVariable(frame, stackIdx), typeDesc); - } - - private void writeDup(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame) - throws IOException { - writeAssign(frame, TOP_OF_STACK, nextFrame, TOP_OF_STACK); - } - - private void writeDupX1(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame) - throws IOException { - writeAssign(frame, TOP_OF_STACK, nextFrame, TOP_OF_STACK); - writeAssign(frame, TOP_OF_STACK - 1, nextFrame, TOP_OF_STACK - 1); - writeAssign(nextFrame, TOP_OF_STACK, nextFrame, TOP_OF_STACK - 2); - } - - private void writeDupX2(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame) - throws IOException { - writeAssign(frame, TOP_OF_STACK, nextFrame, TOP_OF_STACK); - writeAssign(frame, TOP_OF_STACK - 1, nextFrame, TOP_OF_STACK - 1); - writeAssign(frame, TOP_OF_STACK - 2, nextFrame, TOP_OF_STACK - 2); - writeAssign(nextFrame, TOP_OF_STACK, nextFrame, TOP_OF_STACK - 3); - } - - private void writeDup2(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame) - throws IOException { - writeAssign(frame, TOP_OF_STACK, nextFrame, TOP_OF_STACK); - writeAssign(frame, TOP_OF_STACK - 1, nextFrame, TOP_OF_STACK - 1); - } - - private void writeDup2X1(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame) - throws IOException { - writeAssign(frame, TOP_OF_STACK, nextFrame, TOP_OF_STACK); - writeAssign(frame, TOP_OF_STACK - 1, nextFrame, TOP_OF_STACK - 1); - writeAssign(frame, TOP_OF_STACK - 2, nextFrame, TOP_OF_STACK - 2); - writeAssign(nextFrame, TOP_OF_STACK, nextFrame, TOP_OF_STACK - 3); - writeAssign(nextFrame, TOP_OF_STACK - 1, nextFrame, TOP_OF_STACK - 4); - } - - private void writeDup2X2(@Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame) - throws IOException { - writeAssign(frame, TOP_OF_STACK, nextFrame, TOP_OF_STACK); - writeAssign(frame, TOP_OF_STACK - 1, nextFrame, TOP_OF_STACK - 1); - writeAssign(frame, TOP_OF_STACK - 2, nextFrame, TOP_OF_STACK - 2); - writeAssign(frame, TOP_OF_STACK - 3, nextFrame, TOP_OF_STACK - 3); - writeAssign(nextFrame, TOP_OF_STACK, nextFrame, TOP_OF_STACK - 4); - writeAssign(nextFrame, TOP_OF_STACK - 1, nextFrame, TOP_OF_STACK - 5); - } - - /** - * writes frame2.stack[frame.stack.size() + offset2] = frame1.stack[frame.stack.size() + offset1] - * - * @throws IOException - */ - private void writeAssign(@Nonnull Frame<BasicValue> frame1, int offset1, - @Nonnull Frame<BasicValue> frame2, int offset2) throws IOException { - assert !isBooleanAssignIssue( - getStackVariable(frame2, offset2), - getStackVariable(frame1, offset1)); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(frame2, offset2); - writeStackAccess(frame1, offset1); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - private void writeBinaryOperation( - @Nonnull Token op, @Nonnull Frame<BasicValue> frame, @Nonnull Frame<BasicValue> nextFrame) - throws IOException { - assert !isBooleanAssignIssue( - getStackVariable(frame, TOP_OF_STACK - 1), - getStackVariable(frame, TOP_OF_STACK)); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeCatchBlockIds(currentCatchList); - writer.writeKeyword(Token.EXPRESSION_STATEMENT); - writer.writeOpen(); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(Token.ASG_OPERATION); - writer.writeOpen(); - writeStackAccess(nextFrame, TOP_OF_STACK); - sourceInfoWriter.writeDebugBegin(currentClass, currentLine); - writer.writeKeyword(op); - writer.writeOpen(); - writeStackAccess(frame, TOP_OF_STACK - 1); - writeStackAccess(frame, TOP_OF_STACK); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - sourceInfoWriter.writeDebugEnd(currentClass, currentLine + 1); - writer.writeClose(); - } - - @Nonnull - private Iterator<Variable> collectLocals() { - Set<Variable> locals = new LinkedHashSet<Variable>(); - - Frame<BasicValue>[] frames = analyzer.getFrames(); - for (int frameIdx = 0; frameIdx < frames.length; frameIdx++) { - currentPc = frameIdx; - Frame<BasicValue> frame = frames[frameIdx]; - if (frame != null) { - for (int localIdx = 0; localIdx < frame.getLocals(); localIdx++) { - BasicValue bv = frame.getLocal(localIdx); - if (bv != BasicValue.UNINITIALIZED_VALUE) { - Variable local = getLocalVariable(frame, localIdx); - if (!local.isParameter() && !local.isThis()) { - locals.add(local); - } - } - } - for (int stackIdx = 0; stackIdx < frame.getStackSize(); stackIdx++) { - Variable v = getStackVariable(frame, -stackIdx - 1); - locals.add(v); - } - } - } - - // Do not forget to collect temporary variable required by some instructions. - for (int insnIdx = 0; insnIdx < currentMethod.instructions.size(); insnIdx++) { - AbstractInsnNode insn = currentMethod.instructions.get(insnIdx); - if (insn.getOpcode() == SWAP) { - locals.add(getTempVarFromTopOfStack(frames[insnIdx])); - } - } - - return locals.iterator(); - } - - @Nonnull - private Variable getTempVarFromTopOfStack(@Nonnull Frame<BasicValue> frame) { - Variable topOfStackBeforeInst = getStackVariable(frame, TOP_OF_STACK); - String tmpVarId = "-swap_tmp_" + typeToUntypedDesc(topOfStackBeforeInst.getType()); - Variable tmpVariable = - getVariable(tmpVarId, tmpVarId, topOfStackBeforeInst.getType(), null); - tmpVariable.setSynthetic(); - return tmpVariable; - } - - private void writeParameters() - throws IOException { - writer.writeOpenNodeList(); - - int parameterIdx = 0; - int parameterAnnotationIdx = 0; - currentPc = 0; - - if (!AsmHelper.isStatic(currentMethod)) { - Type parameterType = Type.getObjectType(currentClass.name); - LocalVariableNode lvn = getLocalVariableNode(parameterIdx); - if (lvn == null) { - String pid = getUnnamedParameterId(parameterIdx, parameterType); - Variable p = getVariable(pid, pid, parameterType, null); - p.setThis(); - - Type untypedParameter = typeToUntyped(parameterType); - String lid = getUnnamedLocalId(parameterIdx, untypedParameter); - Variable local = getVariable(lid, lid, untypedParameter, null); - - parameter2Var.put(p, local); - } else { - assert parameterType.getDescriptor().equals(lvn.desc); - Variable p = getVariable(getNamedLocalId(lvn), lvn.name, parameterType, lvn.signature); - p.setThis(); - } - parameterIdx++; - } - - for (Type paramType : Type.getArgumentTypes(currentMethod.desc)) { - LocalVariableNode lvn = getLocalVariableNode(parameterIdx); - if (lvn == null) { - String pid = getUnnamedParameterId(parameterIdx, paramType); - Variable p = getVariable(pid, pid, paramType, null); - p.setParameter(); - writeParameter(paramType, parameterIdx, p, parameterAnnotationIdx++); - - Type untypedParameter = typeToUntyped(paramType); - String lid = getUnnamedLocalId(parameterIdx, untypedParameter); - Variable local = getVariable(lid, lid, untypedParameter, null); - - parameter2Var.put(p, local); - } else { - assert paramType.getDescriptor().equals(lvn.desc); - Variable p = getVariable(getNamedLocalId(lvn), lvn.name, paramType, lvn.signature); - p.setParameter(); - writeParameter(paramType, parameterIdx, p, parameterAnnotationIdx++); - } - parameterIdx += paramType.getSize(); - } - - writer.writeCloseNodeList(); - } - - private void writeParameter(@Nonnull Type paramType, @Nonnegative int localIdx, - @Nonnull Variable param, @Nonnegative int parameterAnnotationIdx) throws IOException { - sourceInfoWriter.writeUnknwonDebugBegin(); - writer.writeKeyword(Token.PARAMETER); - writer.writeOpen(); - writer.writeId(param.getId()); - writer.writeInt(NO_MODIFIER); - writer.writeId(paramType.getDescriptor()); - writer.writeString(param.getName()); - annotWriter.writeAnnotations(currentMethod, parameterAnnotationIdx); - writer.writeOpenNodeList(); - if (param.hasSignature()) { - writer.writeKeyword(Token.GENERIC_SIGNATURE); // Marker generic signature - writer.writeOpen(); - writer.writeString(param.getSignature()); - writer.writeClose(); - } - writer.writeCloseNodeList(); - // TODO(mikaelpeltier) Add debug information of parameter - sourceInfoWriter.writeUnknownDebugEnd(); - writer.writeClose(); - } - - @CheckForNull - private LocalVariableNode getLocalVariableNode(@Nonnegative int localIdx) { - assert localIdx >= 0; - if (options.isEmitDebugInfo() && currentMethod.localVariables != null) { - for (LocalVariableNode lvn : currentMethod.localVariables) { - int startScope = currentMethod.instructions.indexOf(lvn.start) - 1; - int endScope = currentMethod.instructions.indexOf(lvn.end); - if (lvn.index == localIdx && currentPc >= startScope && currentPc <= endScope) { - assert lvn.desc != null; - return lvn; - } - } - } - - return null; - } - - private void removeDeadCode() { - Frame<BasicValue>[] frames = analyzer.getFrames(); - AbstractInsnNode[] insns = currentMethod.instructions.toArray(); - for (int i = 0; i < frames.length; ++i) { - if (frames[i] == null) { - // do not remove labels, they may be used as local scope bounds or catch bounds. - AbstractInsnNode insn = insns[i]; - if (insn instanceof LabelNode) { - continue; - } - currentMethod.instructions.remove(insn); - } - } - } - - private boolean isBooleanAssignIssue(@Nonnull Variable lhs, @Nonnull Variable rhs) { - return isBooleanAssignIssue(lhs.getType(), rhs.getType()); - } - - private boolean isBooleanAssignIssue(@Nonnull Type lhs, @Nonnull Type rhs) { - return (lhs == Type.BOOLEAN_TYPE && rhs != Type.BOOLEAN_TYPE) - || (rhs == Type.BOOLEAN_TYPE && lhs != Type.BOOLEAN_TYPE); - } - - @Nonnull - private Variable getLocalVariable(@Nonnull Frame<BasicValue> frame, @Nonnegative int localIdx){ - BasicValue bv = frame.getLocal(localIdx); - assert bv != BasicValue.UNINITIALIZED_VALUE; - LocalVariableNode lvn = getLocalVariableNode(localIdx); - String localName; - String id; - Type localType; - String signature; - Variable v; - if (lvn == null) { - id = getUnnamedLocalId(localIdx, bv.getType()); - localName = id; - localType = typeToUntyped(bv.getType()); - signature = null; - v = getVariable(id, localName, localType, signature); - // Unnamed variable will be define as synthetic - v.setSynthetic(); - } else { - id = getNamedLocalId(lvn); - localName = lvn.name; - localType = Type.getType(lvn.desc); - signature = lvn.signature; - v = getVariable(id, localName, localType, signature); - } - return v; - } - - @Nonnull - private String getUnnamedParameterId(@Nonnegative int localIdx, @Nonnull Type localType) { - return "-p_" + localIdx + "_" + stringLegalizer(localType.getDescriptor()); - } - - @Nonnull - private String getUnnamedLocalId(@Nonnegative int localIdx, @Nonnull Type localType) { - return "-l_" + localIdx + "_" + typeToUntypedDesc(localType); - } - - @Nonnull - private String getNamedLocalId(@Nonnull LocalVariableNode lvn) { - return (lvn.name + "_" + lvn.index + "_" + (lvn.signature != null ? - stringLegalizer(lvn.signature) : stringLegalizer(lvn.desc))); - } - - @Nonnull - private Variable getStackVariable(@Nonnull Frame<BasicValue> frame, int stackIdx){ - int stackHeight = frame.getStackSize() + stackIdx; - BasicValue bv = frame.getStack(stackHeight); - assert bv != BasicValue.UNINITIALIZED_VALUE; - String id = "-s_" + stackHeight + "_" + typeToUntypedDesc(bv.getType()); - Variable variable = getVariable(id, id, typeToUntyped(bv.getType()), null); - variable.setSynthetic(); - return variable; - } - - @Nonnull - private Variable getVariable(@Nonnull String id, @Nonnull String name, @Nonnull Type type, - @CheckForNull String signature) { - Variable var = nameToVar.get(id); - - if (var == null) { - var = new Variable(id, name, type, signature); - nameToVar.put(id, var); - } - - return var; - } - - @Nonnull - private String typeToUntypedDesc(@Nonnull Type type) { - if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { - return "R"; - } else if (type.getSort() == Type.BOOLEAN || type.getSort() == Type.BYTE - || type.getSort() == Type.CHAR || type.getSort() == Type.SHORT - || type.getSort() == Type.INT) { - return Type.INT_TYPE.getDescriptor(); - } - return type.getDescriptor(); - } - - @Nonnull - private Type typeToUntyped(@Nonnull Type type) { - if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { - return Type.getType("Ljava/lang/Object;"); - } else if (type.getSort() == Type.BOOLEAN || type.getSort() == Type.BYTE - || type.getSort() == Type.CHAR || type.getSort() == Type.SHORT - || type.getSort() == Type.INT) { - return Type.INT_TYPE; - } - return type; - } - - @Nonnull - private String stringLegalizer(@Nonnull String str) { - return str.replace('/', '_').replace(';', '_').replace('<', '_').replace('>', '_') - .replace(':', '_'); - } -} diff --git a/jill/src/com/android/jill/frontend/java/RetentionPolicy.java b/jill/src/com/android/jill/frontend/java/RetentionPolicy.java deleted file mode 100644 index 53bb6cb..0000000 --- a/jill/src/com/android/jill/frontend/java/RetentionPolicy.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.frontend.java; - - - -/** - * Annotation retention policy - */ -public enum RetentionPolicy { - /** - * @see RetentionPolicy#SOURCE - */ - SOURCE, - /** - * @see RetentionPolicy#CLASS - */ - CLASS, - /** - * @see RetentionPolicy#RUNTIME - */ - RUNTIME, - /** - * Retention policy is unknown, it is useful for annotation literal where only root - * annotation have a retention policy, others annotation literal have unknown retention. - */ - UNKNOWN -} diff --git a/jill/src/com/android/jill/frontend/java/SourceInfoWriter.java b/jill/src/com/android/jill/frontend/java/SourceInfoWriter.java deleted file mode 100644 index bf46df2..0000000 --- a/jill/src/com/android/jill/frontend/java/SourceInfoWriter.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.frontend.java; - -import com.android.jill.backend.jayce.JayceWriter; - -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; - -import java.io.IOException; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * This writer handles source info writing context. - */ -public class SourceInfoWriter { - - @Nonnull - protected final JayceWriter writer; - - /* debug infos */ - @Nonnegative - private static final int NO_START_LINE = 0; - - @Nonnegative - private static final int NO_END_LINE = 0; - - private static final String NO_FILENAME = null; - - @CheckForNull - private String currentFileName; - - @Nonnegative - private int currentLineNumber; - - public SourceInfoWriter(JayceWriter writer) { - this.writer = writer; - } - - public void writeDebugBegin(@Nonnull ClassNode cn) throws IOException { - writeDebugBegin(cn, NO_START_LINE); - } - - public void writeDebugBegin(@Nonnull ClassNode cn, @Nonnull FieldNode fn) - throws IOException { - writeUnknwonDebugBegin(); - } - - public void writeDebugBegin(@Nonnull ClassNode cn, int startLine) - throws IOException { - if (cn.sourceFile == null) { - writeUnknwonDebugBegin(); - } else { - writeDebugBeginInternal(cn.sourceFile, startLine); - } - } - - public void writeUnknwonDebugBegin() throws IOException { - writeDebugBeginInternal(NO_FILENAME, NO_START_LINE); - } - - private void writeDebugBeginInternal(@CheckForNull String sourceFile, int startLine) - throws IOException { - writeFileNameIfDifferentFromCurrent(sourceFile); - writeLineIfDifferentFromCurrent(startLine, true); - } - - public void writeDebugEnd(@Nonnull ClassNode cn) - throws IOException { - writeDebugEnd(cn, NO_END_LINE); - } - - public void writeDebugEnd(@Nonnull ClassNode cn, @Nonnull FieldNode fn) - throws IOException { - writeUnknownDebugEnd(); - } - - public void writeDebugEnd(@Nonnull ClassNode cn, int endLine) throws IOException { - if (cn.sourceFile == null) { - writeUnknownDebugEnd(); - } else { - writeLineIfDifferentFromCurrent(endLine, false); - } - } - - public void writeUnknownDebugEnd() throws IOException { - writeLineIfDifferentFromCurrent(NO_END_LINE, false); - } - - private void writeFileNameIfDifferentFromCurrent(@CheckForNull String fileName) - throws IOException { - if (fileName != null && !fileName.equals(currentFileName)) { - writeCurrentFileName(fileName); - } - // Assume that elements with unknown debug infos are in same file. - } - - private void writeCurrentFileName(@Nonnull String fileName) - throws IOException { - writer.writeFileName(fileName); - currentFileName = fileName; - } - - private void writeLineIfDifferentFromCurrent(@Nonnegative int lineNumber, - boolean isStartLine) - throws IOException { - if (lineNumber != currentLineNumber) { - writeCurrentLine(lineNumber); - } - } - - private void writeCurrentLine(@Nonnegative int lineNumber) - throws IOException { - writer.writeCurrentLineInfo(lineNumber); - currentLineNumber = lineNumber; - } -} diff --git a/jill/src/com/android/jill/frontend/java/Variable.java b/jill/src/com/android/jill/frontend/java/Variable.java deleted file mode 100644 index 526b282..0000000 --- a/jill/src/com/android/jill/frontend/java/Variable.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.frontend.java; - -import org.objectweb.asm.Type; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * Represents variables that are used by Jill to represent local and stack items. - */ -public class Variable { - - @Nonnull - private final Type type; - - @Nonnull - private final String id; - - @CheckForNull - private final String signature; - - @Nonnull - private String name; - - private boolean isThis; - - private boolean isParameter; - - private boolean isSynthetic; - - public Variable(@Nonnull String id, @Nonnull String name, @Nonnull Type type, - @CheckForNull String signature) { - this.id = id; - this.name = name; - this.type = type; - this.signature = signature; - isThis = false; - isParameter = false; - isSynthetic = false; - } - - @Nonnull - public Type getType() { - return type; - } - - public void setName(@Nonnull String name) { - this.name = name; - } - - public boolean hasSignature() { - return signature != null; - } - - @Nonnull - public String getSignature() { - assert signature != null; - return signature; - } - - @Nonnull - public String getName() { - return name; - } - - @Nonnull - public String getId() { - return id; - } - - public boolean isThis() { - return isThis; - } - - public void setThis() { - this.isThis = true; - } - - public boolean isParameter() { - return isParameter; - } - - public void setParameter() { - this.isParameter = true; - } - - public boolean isSynthetic() { - return isSynthetic; - } - - public void setSynthetic() { - this.isSynthetic = true; - } -} diff --git a/jill/src/com/android/jill/frontend/java/analyzer/JillAnalyzer.java b/jill/src/com/android/jill/frontend/java/analyzer/JillAnalyzer.java deleted file mode 100644 index 34aa756..0000000 --- a/jill/src/com/android/jill/frontend/java/analyzer/JillAnalyzer.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.frontend.java.analyzer; - -import com.google.common.base.Strings; - -import com.android.jill.JillException; - -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.analysis.AnalyzerException; -import org.objectweb.asm.tree.analysis.BasicInterpreter; -import org.objectweb.asm.tree.analysis.BasicValue; - -import javax.annotation.Nonnull; - -/** - * Jill analyzer computes types by separating arrays and references, instead of using a single - * "object reference" type. Nevertheless it does not compute always the exact type of object - * reference but uses {@Code java.lang.Object} when exact type computation requires to load - * classes. - */ -public class JillAnalyzer extends BasicInterpreter { - - @Override - public BasicValue newValue(Type type) { - if (type == null) { - return BasicValue.UNINITIALIZED_VALUE; - } - switch (type.getSort()) { - case Type.VOID: - return null; - case Type.BOOLEAN: - case Type.CHAR: - case Type.BYTE: - case Type.SHORT: - case Type.INT: - return BasicValue.INT_VALUE; - case Type.FLOAT: - return BasicValue.FLOAT_VALUE; - case Type.LONG: - return BasicValue.LONG_VALUE; - case Type.DOUBLE: - return BasicValue.DOUBLE_VALUE; - case Type.ARRAY: - case Type.OBJECT: - return new BasicValue(type); - default: - throw new Error("Internal error"); - } - } - - - @Override - public BasicValue binaryOperation(AbstractInsnNode insn, BasicValue value1, BasicValue value2) - throws AnalyzerException { - if (insn.getOpcode() == AALOAD) { - // value1 means array reference. - Type arrayType = value1.getType(); - String arrayTypeDesc = arrayType.getDescriptor(); - if (arrayType.getSort() == Type.ARRAY) { - return newValue(Type.getType(arrayTypeDesc.substring(1))); - } else if ("Lnull;".equals(arrayTypeDesc)) { - return value1; - } - - throw new JillException("Fails to retrieve array element value"); - } - return super.binaryOperation(insn, value1, value2); - } - - @Override - public BasicValue merge(final BasicValue v, final BasicValue w) { - assert v != null; - assert w != null; - - if (v.equals(w) || v == BasicValue.UNINITIALIZED_VALUE) { - return v; - } else if (w == BasicValue.UNINITIALIZED_VALUE) { - return BasicValue.UNINITIALIZED_VALUE; - } else { - Type type1 = v.getType(); - Type type2 = w.getType(); - - if ((type1.getSort() == Type.ARRAY && type2.getSort() == Type.OBJECT - && !isKnownNull(type2)) - || (type1.getSort() == Type.OBJECT && !isKnownNull(type1) && - type2.getSort() == Type.ARRAY)) { - return BasicValue.REFERENCE_VALUE; - } else if ((type1.getSort() == Type.ARRAY || isKnownNull(type1)) - && (type2.getSort() == Type.ARRAY || isKnownNull(type2))) { - if (isKnownNull(type1)) { - return w; - } else if (isKnownNull(type2)) { - return v; - } else { - BasicValue componentUnion = - merge(new BasicValue(type1.getElementType()), new BasicValue(type2.getElementType())); - if (componentUnion == BasicValue.UNINITIALIZED_VALUE) { - return BasicValue.REFERENCE_VALUE; - } - return new BasicValue(Type.getType( - Strings.repeat("[", Math.min(type1.getDimensions(), type2.getDimensions())) - + componentUnion.getType().getDescriptor())); - } - } else if (type1.getSort() == Type.OBJECT && type2.getSort() == Type.OBJECT) { - if (isKnownNull(type1)) { - return w; - } else if (isKnownNull(type2)) { - return v; - } else { - return BasicValue.REFERENCE_VALUE; - } - } else if (isIntLike(type1) && isIntLike(type2)) { - return BasicValue.INT_VALUE; - } else { - return BasicValue.UNINITIALIZED_VALUE; - } - } - } - - private boolean isIntLike(@Nonnull Type t) { - return t == Type.BOOLEAN_TYPE || t == Type.BYTE_TYPE || t == Type.CHAR_TYPE - || t == Type.SHORT_TYPE || t == Type.INT_TYPE; - } - - private boolean isKnownNull(@Nonnull Type t) { - return ("Lnull;".equals(t.getDescriptor())); - } -} diff --git a/jill/src/com/android/jill/utils/FileUtils.java b/jill/src/com/android/jill/utils/FileUtils.java deleted file mode 100644 index 460baa5..0000000 --- a/jill/src/com/android/jill/utils/FileUtils.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.utils; - -import java.io.File; -import java.util.List; - -import javax.annotation.Nonnull; - -/** - * Utilities related to file support. - */ -public class FileUtils { - - @Nonnull - public static final String JAVA_BINARY_FILE_EXTENSION = ".class"; - - @Nonnull - public static final String JAR_FILE_EXTENSION = ".jar"; - - public static void getJavaBinaryFiles(@Nonnull File file, @Nonnull List<File> binaryFiles) { - if (file.isDirectory()) { - File allFiles[] = file.listFiles(); - for (File aFile : allFiles) { - getJavaBinaryFiles(aFile, binaryFiles); - } - } else if (isJavaBinaryFile(file)) { - binaryFiles.add(file.getAbsoluteFile()); - } - } - - public static boolean isJavaBinaryFile(@Nonnull File file) { - return isJavaBinaryFile(file.getName()); - } - - public static boolean isJavaBinaryFile(@Nonnull String fileName) { - return fileName.endsWith(FileUtils.JAVA_BINARY_FILE_EXTENSION); - } - - public static boolean isJarFile(@Nonnull File file) { - return file.getName().endsWith(FileUtils.JAR_FILE_EXTENSION); - } -} diff --git a/jill/src/com/android/jill/utils/enums/DispatchKindIdHelper.java b/jill/src/com/android/jill/utils/enums/DispatchKindIdHelper.java deleted file mode 100644 index bd0b504..0000000 --- a/jill/src/com/android/jill/utils/enums/DispatchKindIdHelper.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.utils.enums; - -import com.android.jill.frontend.java.MethodBodyWriter.DispatchKind; - -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * A helper class to encode {@link DispatchKind} enum values in Jayce format. - */ -public class DispatchKindIdHelper { - - @Nonnull - private static byte[] ids; - - static { - ids = new byte[2]; - ids[DispatchKind.VIRTUAL.ordinal()] = 0; - ids[DispatchKind.DIRECT.ordinal()] = 1; - } - - @Nonnegative - public static byte getId(@Nonnull Enum<?> enumValue) { - return ids[enumValue.ordinal()]; - } -} diff --git a/jill/src/com/android/jill/utils/enums/FieldRefKindIdHelper.java b/jill/src/com/android/jill/utils/enums/FieldRefKindIdHelper.java deleted file mode 100644 index 8f01158..0000000 --- a/jill/src/com/android/jill/utils/enums/FieldRefKindIdHelper.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.utils.enums; - -import com.android.jill.frontend.java.MethodBodyWriter.FieldRefKind; - -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * A helper class to encode {@link FieldRefKind} enum values in Jayce format. - */ -public class FieldRefKindIdHelper { - - @Nonnull - private static byte[] ids; - - static { - ids = new byte[2]; - ids[FieldRefKind.INSTANCE.ordinal()] = 0; - ids[FieldRefKind.STATIC.ordinal()] = 1; - } - - @Nonnegative - public static byte getId(@Nonnull Enum<?> enumValue) { - return ids[enumValue.ordinal()]; - } -} diff --git a/jill/src/com/android/jill/utils/enums/MethodKindIdHelper.java b/jill/src/com/android/jill/utils/enums/MethodKindIdHelper.java deleted file mode 100644 index e8f5c6e..0000000 --- a/jill/src/com/android/jill/utils/enums/MethodKindIdHelper.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.utils.enums; - -import com.android.jill.frontend.java.MethodBodyWriter.MethodKind; - -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * A helper class to encode {@link MethodKind} enum values in Jayce format. - */ -public class MethodKindIdHelper { - - @Nonnull - private static byte[] ids; - - static { - ids = new byte[3]; - ids[MethodKind.STATIC.ordinal()] = 0; - ids[MethodKind.INSTANCE_NON_VIRTUAL.ordinal()] = 1; - ids[MethodKind.INSTANCE_VIRTUAL.ordinal()] = 2; - } - - @Nonnegative - public static byte getId(@Nonnull Enum<?> enumValue) { - return ids[enumValue.ordinal()]; - } -} diff --git a/jill/src/com/android/jill/utils/enums/ReceiverKindIdHelper.java b/jill/src/com/android/jill/utils/enums/ReceiverKindIdHelper.java deleted file mode 100644 index 047e606..0000000 --- a/jill/src/com/android/jill/utils/enums/ReceiverKindIdHelper.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.utils.enums; - -import com.android.jill.frontend.java.MethodBodyWriter.MethodCallReceiverKind; - -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * A helper class to encode {@link MethodCallReceiverKind} enum values in Jayce format. - */ -public class ReceiverKindIdHelper { - - @Nonnull - private static byte[] ids; - - static { - ids = new byte[2]; - ids[MethodCallReceiverKind.CLASS.ordinal()] = 0; - ids[MethodCallReceiverKind.INTERFACE.ordinal()] = 1; - } - - @Nonnegative - public static byte getId(@Nonnull Enum<?> enumValue) { - return ids[enumValue.ordinal()]; - } -} diff --git a/jill/src/com/android/jill/utils/enums/RetentionPolicyIdHelper.java b/jill/src/com/android/jill/utils/enums/RetentionPolicyIdHelper.java deleted file mode 100644 index f955601..0000000 --- a/jill/src/com/android/jill/utils/enums/RetentionPolicyIdHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2013 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.jill.utils.enums; - -import com.android.jill.frontend.java.RetentionPolicy; - -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * A helper class to encode {@link RetentionPolicy} enum values in Jayce format. - */ -public class RetentionPolicyIdHelper { - - @Nonnull - private static byte[] ids; - - static { - ids = new byte[5]; - ids[RetentionPolicy.SOURCE.ordinal()] = 0; - ids[RetentionPolicy.CLASS.ordinal()] = 1; - ids[RetentionPolicy.RUNTIME.ordinal()] = 2; - ids[RetentionPolicy.UNKNOWN.ordinal()] = 4; - } - - @Nonnegative - public static byte getId(@Nonnull Enum<?> enumValue) { - return ids[enumValue.ordinal()]; - } -} diff --git a/jill/tests/com/android/jill/AllTests.java b/jill/tests/com/android/jill/AllTests.java deleted file mode 100644 index e3ead54..0000000 --- a/jill/tests/com/android/jill/AllTests.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2014 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.jill; - - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite containing all tests. - */ -@RunWith(Suite.class) -@SuiteClasses(value = { - Core.class}) -public class AllTests { -} diff --git a/jill/tests/com/android/jill/Core.java b/jill/tests/com/android/jill/Core.java deleted file mode 100644 index 7c26772..0000000 --- a/jill/tests/com/android/jill/Core.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2013 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.jill; - -import com.android.jack.TestTools; -import com.android.jack.test.TestsProperties; - -import org.junit.Ignore; -import org.junit.Test; - -import java.io.File; - -@Ignore("Tree") -public class Core { - - @Test - public void coreToJayceFromJar() throws Exception { - Options options = new Options(); - options.setBinaryFile(new File(TestsProperties.getAndroidRootDir().getPath() - + "/out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar")); - options.setVerbose(true); - options.output = TestTools.createTempFile("jillTest", ".zip"); - Jill.process(options); - } - - @Test - public void coreToJayceFromFolder() throws Exception { - Options options = new Options(); - options.setBinaryFile(new File(TestsProperties.getAndroidRootDir().getPath() - + "/out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes/")); - options.setVerbose(true); - options.output = TestTools.createTempFile("jillTest", ".zip"); - Jill.process(options); - } -} diff --git a/jill/tests/com/android/jill/LongLastingTests.java b/jill/tests/com/android/jill/LongLastingTests.java deleted file mode 100644 index edcab23..0000000 --- a/jill/tests/com/android/jill/LongLastingTests.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2014 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.jill; - - -import com.android.jack.category.SlowTests; - -import org.junit.experimental.categories.Categories; -import org.junit.experimental.categories.Categories.IncludeCategory; -import org.junit.runner.RunWith; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite containing tests that are too time-consuming and cannot be run before submitting each - * CL. - */ -@RunWith(Categories.class) -@IncludeCategory(SlowTests.class) -@SuiteClasses(value = {AllTests.class}) -public class LongLastingTests { -} diff --git a/jill/tests/com/android/jill/PreSubmitTests.java b/jill/tests/com/android/jill/PreSubmitTests.java deleted file mode 100644 index 0d4afcc..0000000 --- a/jill/tests/com/android/jill/PreSubmitTests.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2014 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.jill; - - -import com.android.jack.category.NonPreSubmitTests; - -import org.junit.experimental.categories.Categories; -import org.junit.experimental.categories.Categories.ExcludeCategory; -import org.junit.runner.RunWith; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Test suite to run before submitting a CL. - */ -@RunWith(Categories.class) -@ExcludeCategory(NonPreSubmitTests.class) -@SuiteClasses(value = {AllTests.class}) -public class PreSubmitTests { -} |